bobbingwide / oik-shortcodes

Shortcode, block and API server
https://www.oik-plugins.com/oik-plugins/oik-shortcode-server/
GNU General Public License v2.0
1 stars 0 forks source link

Add Blocks Catalogued virtual field to display the number of blocks catalogued for a plugin #78

Closed bobbingwide closed 4 years ago

bobbingwide commented 5 years ago

Requirements

To see at a glance how many blocks have been catalogued for a particular plugin enabling us to compare it with the number we said we've done

Proposed solution

Add virtual field "Blocks Catalogued" with name blocks_catalogued

bobbingwide commented 5 years ago

I developed a prototype version that uses bw_get_posts to find the related blocks for a plugin. When applied to the full list of plugins it appeared quite slow. Consider using a query against post_meta.

Select count(*) from $wpdb->postmeta 
where meta_key = ‘_oik_sc_plugin’ and meta_value = %d

Where the meta_value is the ID of the oik-plugin. It needs to join the post_id of postmeta to posts where the post type is ‘block’, since _oik_sc_plugin is the noderef for a number of different posts.

bobbingwide commented 4 years ago

This is now released in v1.37.0 to wp-a2z.org. See image

bobbingwide commented 4 years ago

The logic using oiksc_maybe_get_current_post_id() produced the wrong results on the home page. Revert to using bw_current_post_id() and only call oiksc_count_blocks_directly() when the $id is set to other than 0.

bobbingwide commented 4 years ago

This is now active on blocks.wp-a2z.org so can be closed.