WP Plugin with Upgrade option

If you want your plugin being hosted on WordPress.org Plugin Repository, you cannot combine Free and Premium version, in one plugin. You have to maintain two versions, Lite, hosted on WordPress.org, and Premium, hosted on your website. Plugins hosted on WordPress.org cannot make any remote requests to your website ( aka “calling home” ), therefore, … Read more

How to get current logged-in user details in multisite?

As described in the documentation, you have call this inside a hook. For wordpress versions < 3.4: use the init or any subsequent action to call this function. Calling it outside of an action can lead to troubles. See #14024 for details. Example: add_action(‘init’, ‘get_user_email’); function get_user_email() { $logged_in_user = wp_get_current_user(); if($logged_in_user->ID != 0){ $email … Read more

plugin content on front-page only. Nowhere else

After turning on WP_DEBUG, define(‘WP_DEBUG’, true); I was receiving the error: Conditional query tags do not work before the query is run. Before then, they always return false. After googling that error, I found a solution that works: add_action( ‘template_redirect’, ‘check_for_frontpage’ ); function check_for_frontpage() { if ( is_front_page() || is_home() ) { echo “<script>console.log( ‘Debug … Read more

How add default term meta to prevent an error?

You don’t, or at least not in the way you expect. If the code in the question worked as expected, it would still be committing a mortal performance sin, database writes on the frontend. So lets take the relevant code: $cat_id = $_GET[‘tag_ID’]; if (metadata_exists(‘term’, $cat_id, ‘cat_settings’ )) { $catSettings = get_term_meta($cat_id, ‘cat_settings’, false); } … Read more

How do I get variables from my plugin’s settings page?

In your options page each field should be put into an options array. For Example: When you registered your settings page you should have used a code like this: register_setting( ‘pluginPage’, ‘rt_fed_settings’, ‘rt_validate’); Once on your page where you want to call settings, use this code: $options_fed = get_option(‘rt_fed_settings’); // this is calling your settings … Read more

How to add Plugin functionality in WordPress Frontend Menus

At the time of registering taxonomy, make sure you use the show_in_nav_menus parameter and set it true. For Example: $args = array( ‘label’ => __( ‘book’, ‘textdomain’ ), ‘public’ => true, ‘rewrite’ => array(‘slug’ => ‘book’, ‘with_front’ => true), ‘hierarchical’ => true, ‘show_in_nav_menus’ => true, ‘show_ui’ => true, ); register_taxonomy( ‘book’, ‘products’, $args);