Redirect Plugins.php to New Plugin Page

After a little bit of trial and error, I finally got my code to work. This will redirect http://example.com/wp-admin/plugins to http://example.com/wp-admin/admin.php?page=pretty-plugins.php if the current user doesn’t have access to update core. add_action( ‘admin_menu’, ‘block_direct_plugin_page_access’ ); function block_direct_plugin_page_access() { global $pagenow; if ( ! current_user_can(‘update_core’) && ‘plugins.php’ === $pagenow ) { if ( function_exists(‘admin_url’) ) { … Read more

Add key and value to an array in another file

I tried another solution and that did the trick. I found in the WooCommerce docs this little snippet: // Display 24 products per page. Goes in functions.php add_filter( ‘loop_shop_per_page’, create_function( ‘$cols’, ‘return 24;’ ), 20 );. It is overriding the settings in the customizer. I only have to change the number ’24’ to my liking.

Comment Approve – Add custom function when comment is approved

Sadly there are no hooks or filters that you could use in edit-comments.php. You’d have to build your own admin page with a custom button and use wp_set_comment_status( $comment, ‘approve’ ); to approve comment and do whatever you need to do… EDIT: I was wrong – there’s the wp_set_comment_status action inside wp_set_comment_status function https://wpseek.com/function/wp_set_comment_status/ do_action( … Read more

How to reinstate previously saved option?

The only way WordPress is going to know what the previous option was, is if you save it before you change it – since you’re replacing the built-in option, it has no way of knowing how to get back to that. So, you could add a custom ‘backup’ option that you restore on deactivation. Something … Read more