How to modify shortcode attributes with data from current post

For anyone who might stumble upon this, I’ve found a solution: In my particular case, I’m using a single-[taxonomy].php template file, and was able to add the shortcode manually via the WordPress function do_shortcode() instead of modifying a shortcode within the post content. Here’s how I wrote it: <?php echo do_shortcode( ‘[mstw_schedule_table sched=”‘.$sports_slug.'” ]’ ); … Read more

Where to access the available plugin/WordPress updates?

Plugin update data is cached in the update_plugins site transient with available updates under the response property. $data = get_site_transient( ‘update_plugins’ ); var_dump( $data->response ); Response looks a bit like: array(1) { [“wordpress-seo/wp-seo.php”]=> object(stdClass)#1873 (11) { [“id”]=> string(27) “w.org/plugins/wordpress-seo” [“slug”]=> string(13) “wordpress-seo” [“plugin”]=> string(24) “wordpress-seo/wp-seo.php” [“new_version”]=> string(5) “5.5.1” [“url”]=> string(44) “https://wordpress.org/plugins/wordpress-seo/” [“package”]=> string(62) “https://downloads.wordpress.org/plugin/wordpress-seo.5.5.1.zip” [“icons”]=> … Read more

Demystifying and understanding shortcode nomenclature

It’s just [link to= “https://wordpress.stackexchange.com/”]. This is a textbook example of why extract() is bad. You can’t easily tell where variables are coming from. extract() creates variables out of an array with the keys becoming the variable name. So this part: extract(shortcode_atts(array( “to” => ‘http://net.tutsplus.com’ ), $atts)); Is creating an array with a to key, … Read more

Why this global array is returning NULL from a callback function

The problem here is that you never created $ppk_fields as a global variable. $ppk_fields = [ ‘field 1’ => [ ‘title’ => ‘Fieald One’, ‘type’ => ‘text’, ‘section’ => ‘section_1’, ‘default’ => ‘default’ ] ]; Here we have a variable that is created normally, and obeys normal scoping rules. It isn’t a global variable, and … Read more

Ran into a problem installing plugins with Composer

In order for WordPress to recognize a plugin it needs to be in the correct plugins folder. In an usual installation this is wp-content/plugins/ If you use wpackagist.org, a working example would be this composer.json: { “repositories”: [ { “type”: “composer”, “url”: “https://wpackagist.org” } ], “require”: { “wpackagist-plugin/broken-link-checker”: “*”, “wpackagist-theme/twentyseventeen”: “*” } } wpackagist-plugin signals … Read more

Update Option Error: Notice: Undefined index

This is because when a checkbox isn’t checked it didn’t send to the server. This is why the POST array doesn’t have the upo_enable index. You can, however, check if the value is empty or not: $upo_enable = !empty($_POST[‘upo_enable’]) ? true : false; Or $upo_enable = !empty($_POST[‘upo_enable’]) ? $_POST[‘upo_enable’] : false; More on this: https://www.w3.org/TR/html401/interact/forms.html … Read more

What kind of data is that?

It’s a serialized string. Here’s a good description of what it is: A PHP array or object or other complex data structure cannot be transported or stored or otherwise used outside of a running PHP script. If you want to persist such a complex data structure beyond a single run of a script, you need … Read more

Update User Role

Off the top of my head, you should be able to do something like this: $role = get_role( ‘client’ ); if ( $role && $role->has_cap( ‘install_plugins’ ) ) { // Role not updated yet, so update it. $role->remove_cap( ‘install_plugins’ ); } get_role() returns a WP_Role object on success and WP_Role::remove_cap() calls WP_Roles::remove_cap(), which directly updates … Read more

Gravatar images are not fetched in Ultimate Member plugin

Based on my testing and information from the developers, Gravatars won’t appear until you use the Gravatar Transfer feature to transfer the images to the local profile. That feature can be enabled from Ultimate Member > Settings > Extensions. Once it’s activated, you can transfer the Gravatars from Ultimate Member > Gravatar Transfer. You’ll need … Read more

Shortcode insertion in tab

Sounds like you need to wrap your shortcode contents in ob_start()and return ob_get_clean() require_once(dirname(__FILE__).’/post-type.php’); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( ‘term’ => ‘columns’ ), $atts ) ); $custom_taxonomy = $atts[‘term’]; ob_start(); // <- works like magic // add query of custom post type board_members $recentPosts = new … Read more