How to update mu-plugin

First, please check this out: https://codex.wordpress.org/Must_Use_Plugins In most cases mu plugins consist of a singular php file in that directory. In that case you could just replace the file. In any case, there is neither a process for installation nor uninstallation, you simply drop files in that dir or delete them from it. It’s as … Read more

Notice: Uninitialized string offset: 0 in social sharing mu-plugin

Your custom get_the_post_thumbnail_src() function returns a string and not an array, hence in the following code, $sb_thumb is not an array: $sb_thumb = get_the_post_thumbnail_src(get_the_post_thumbnail()); So the PHP notice in question occurred because you used $sb_thumb[0] in the following code, which appears twice in your wpvkp_social_buttons() function: $pinterestURL = ‘https://pinterest.com/pin/create/button/?url=”.$sb_url.”&media=”.$sb_thumb[0].”&description=’.$sb_title; And to get rid of the … Read more

Certain functions are undefined when called form mu-plugins

Thanks to diggy from StackOverflow I’ve foudn that in the WordPress cycle, the file vars.php (containing my needed functions) is included after muplugins_loaded executes. Including wp_is_mobile() and current_user_can() in wrapper functions fixed my problem. CORRECT function my_epic_function() { if(current_user_can( ‘edit_posts’ )) { if(!wp_is_mobile()) { //code to be executed } } } add_action(‘init’, ‘my_epic_function’); INCORRECT function … Read more

Using WP_Query within an mu-plugin

I figured it out. I moved the reference to WP Alchemy within a function that fires after init. Everything now works great and I can use WP_Query within the setup files. Here’s a code reference: // WP Alchemy Setup function jd_setup_wp_alchemy() { include_once WPMU_PLUGIN_DIR . ‘/jonathanwold/metaboxes/setup.php’; include_once WPMU_PLUGIN_DIR . ‘/jonathanwold/metaboxes/cpt-spec.php’; } add_action(‘init’, ‘jd_setup_wp_alchemy’);

Get post/page data outside the loop

You’re using non-existent variables in your function, $post_id, $post, $page. Use get_queried_object to get data from the current page. if( is_single() || is_page() ){ $this_page = get_queried_object(); $excerpt = get_post_field( ‘post_excerpt’, $this_page->ID ); }