• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Simplify

Simplify

Wordpress Development

  • Blog
  • Form Examples
  • Contact Us

Setting up a wordpress site using Local (for local development)

The process to set up a local wordpress site is quite simple. There are, however, certain settings that need to be changed during the initial setup:

  • Webserver: Apache
  • PHP Version: 7.4.30
  • Database: MySQL 5.4

Filed Under: Uncategorized June 23, 2023 Leave a Comment

Install Website from Duplicator Pro Backup

  • Upload backup files to the public folder of your host
  • On the front end, navigate to the domain. Sometimes you need to include the file name of the installer.php file included in your backup
  • Insert
    • Database name
    • Username
    • User email
  • Validate
  • Run

Filed Under: Web Development June 14, 2023 Leave a Comment

WordPress Development Environment Setup and Ongoing Development

  1. Setup local version for site development using LocalWP
  2. Create github repositories to store repo’s for folders you will develop, typically a plugin you are developing
  3. Create a file changelog.md
  4. Add all changes to the change log
  5. After each development stage, commit changes to the Github Repo
  6. When ready, create a dev site on the hosting server and test on dev site
  7. Only when dev site is updated to match live site ( if it exists), update live site

Filed Under: Web Development, WordPress Development June 12, 2023

Exclude page from caching via .htaccess

# EXCLUDE URI's from caching
<If "%{THE_REQUEST} =~ m#/page_name#">
  <IfModule mod_headers.c>
    Header set Cache-Control "private"
  </IfModule>
</If>

Filed Under: Caching May 22, 2023 Leave a Comment

wp_get_current_user()

Purpose

  • Retrieves the current user object.

Implementation

  • Include in
    • Plugin
    • functions.php of active theme
<?php
$current_user = wp_get_current_user();

Example of output of Object $current_user

WP_User Object
(
    [data] => stdClass Object
        (
            [ID] => 8
            [user_login] => subscriber
            [user_pass] => {Users Password}
            [user_nicename] => subscriber
            [user_email] => subscriber@sblik.com
            [user_url] => 
            [user_registered] => 2023-05-02 19:41:27
            [user_activation_key] => 
            [user_status] => 0
            [display_name] => Subscriber Sblik
        )

    [ID] => 8
    [caps] => Array
        (
            [subscriber] => 1
        )

    [cap_key] => wp_capabilities
    [roles] => Array
        (
            [0] => subscriber
        )

    [allcaps] => Array
        (
            [read] => 1
            [level_0] => 1
            [subscriber] => 1
        )

    [filter] => 
    [site_id:WP_User:private] => 1
)

Filed Under: User Functionality, WordPress Development May 2, 2023

WordPress Get Logged In User Info for Front End

Objective

Get logged in user information to use in javascript.

  • In order to use user information on the front end with Javascript or jQuery, you can use wp_localize_script
  • wp_localize_script creates a Javascript object that can be accessed by javascript.
    • function: wp_localize_script($handle, $nameOfObject, $dataStoredInObject)
    • $handle: script handle the data will be attached to
    • $nameOfObject: Name of Javascript Object
    • $dataStoredInObject: single or multi-dimensional array
    • Reference

Step 1: How to include wp_localize_script in a plugin

<?php

/**
 * Plugin Name: Bliksem Sandbox Plugin
 * Version: 1.0.0
 * Description: Sandbox development for
 * Author: Andre Nell
 * Author URI: http://www.simplifysmallbiz.com/
 *
 *
 * @package Bliksem
 * @author Andre Nell
 * @since 1.0.0
 */

if (!function_exists('get_option')) {
  header('HTTP/1.0 403 Forbidden');
  die; // Silence is golden, direct call is prohibited
}

// DEFINE CONSTANTS
define('BS_NAME_VERSION', '1.0.1');
define('BS_NAME_PLUGIN_URL', plugin_dir_url(__FILE__));

// IMPLEMENTATION
function bs_enqueue_bs_frontend_scripts()
{
    global $current_user;
    $current_user = wp_get_current_user(); 
    
    wp_register_script('bs-sandbox-js', BS_NAME_PLUGIN_URL . 'js/sandbox.js', array('jquery'), '1.0.0', true);
    wp_enqueue_script('bs-sandbox-js');

    wp_localize_script('bs-sandbox-js', 'theUser', array(
        'roles' => $current_user->roles,
    ));

}
add_action('wp_enqueue_scripts', 'bs_enqueue_bs_frontend_scripts');

Step2: How to access the data stored in the Javascript Object created in Step 1

jQuery(window).load(function ($) {
    var user_roles = theUser.roles;
    console.log(user_roles);
    if (jQuery.inArray("Subscriber", user_roles)) {
        console.log("is in array");
    } else {
        console.log("is NOT in array");
    }
});

Filed Under: User Functionality, WordPress Development May 2, 2023 Leave a Comment

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 10
  • Go to Next Page »

Primary Sidebar

Categories

  • Affinipay
  • ApproveMe.com
  • Caching
  • Genesis Framework
  • Gravity Forms
  • Gravityflow
  • Gravityforms
  • HubSpot
  • Integrations
  • Javascript
  • LegalSigning
  • MemberPress
  • Oncehub
  • SiteGround Management
  • Stripe
  • Testing
  • Troubleshooting
  • Uncategorized
  • User Functionality
  • Web Development
  • WordPress Development
  • WP Webhook Pro

Footer

Design

With an emphasis on typography, white space, and mobile-optimized design, your website will look absolutely breathtaking.

Learn more about design.

Content

Our team will teach you the art of writing audience-focused content that will help you achieve the success you truly deserve.

Learn more about content.

Strategy

We help creative entrepreneurs build their digital business by focusing on three key elements of a successful online platform.

Learn more about strategy.

Copyright © 2023 · Genesis Sample on Genesis Framework · WordPress · Log in