How do I use the control callback when creating a simple dashboard plugin
Solution : hover on the title bar of your widget, then click configure Don’t ask me why this works like this but it does.
Solution : hover on the title bar of your widget, then click configure Don’t ask me why this works like this but it does.
Add this line at top of your display element function: add_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this line at bottom of your display element function: remove_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this function somewhere in your themes functions.php: function add_active_class_to_nav_menu($classes) { if (in_array(‘current-menu-item’, $classes, true) || in_array(‘current_page_item’, $classes, true)) { $classes = array_diff($classes, array(‘current-menu-item’, ‘current_page_item’, ‘active’)); $classes[] = ‘active’; } return … Read more
The reason my code was failing was due to it reaching a memory limit. I was adding a filter to the_content, and was calling another plugin’s API (Custom Field Suite) to get some meta data that was of the WYSIWYG type. This type of field runs through the_content filter, so I was hitting an infinite … Read more
Sometimes an example says more than a thousand words. Here’s a small plugin that will guide you: <?php ! defined( ‘ABSPATH’ ) AND exit; /** * Plugin Name: (#65981) »kaiser« Meta Box example * Plugin URI: http://goo.gl/ls6Q6 * Description: Example showing how to add a meta box with callback args * Author: Franz Josef Kaiser … Read more
The last optional $args argument the you can pass to add_settings_fields() is passed to callback. So it seems you can use same callback just fine. Hope I am right because I just stumbled onto this two minutes ago because of discussion in chat. 🙂 PS looked through code and it’s indeed relatively recent, before ~2.9 … Read more
Hooking a callback into the code within a Gutenberg block
The handle() method is being called by an add_action(‘enqueue_block_editor_assets, [$block, ‘handle’]) method along with all the other blocks. Here lies the problem. The register_block_type is being called too late. Try to call the function inside the init action hook. You can see an example in the shortcode block of the core.
The error you’re getting is showing, because somewhere on your site (your theme or one of your plugins) is registering a filter function that doesn’t exist. Somewhere in your code, there will be such line (or similar to it): add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); It may use different hook, so it may also look like: add_filter( … Read more
Your url should be pointing to admin-ajax.php echo admin_url(‘admin-ajax.php’);
So I found the solution, callback function for when post or page is: jQuery(document).on(‘heartbeat-tick.autosave’, function( event, data ) { // your code here }); This uses the WordPress Heartbeat API.