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

Is it possible to enqueue CSS files from plugin before theme’s CSS files?

It’s easy to add your plugin stylesheet after theme stylesheet. If you’re sure that your theme styles and plugin styles have the same selector weight (theme has this style .site-header { background-color: #ccc; } and your plugin has this .site-header { background-color: #f1f1f1; }) then enqueuing plugin stylesheet after theme stylesheet will work. If you’re … Read more

FacetWP group listings by custom field [closed]

I finally fixed it: <?php $state_posts = array(); while ($query->have_posts()) { $query->the_post(); $state = get_post_meta(get_the_ID(), ‘state’, true); $state_posts[$state][] = $post; } wp_reset_query(); foreach ($state_posts as $state_post => $state_title) { ?> <h1 class=”state-name”><?php echo esc_html($state_post); ?></h1> <?php foreach ($state_title as $listing => $single_listing) { setup_postdata($single_listing); $post_id = $single_listing->ID; $title = get_the_title($post_id); $distance = facetwp_get_distance($post_id); $distance = … Read more