OOP plugin not working

If that’s the entirety of plugin — you never create an object instance of your class. Class itself is merely a definition. Just like functions don’t do anything unless called, definition does nothing unless object of it is created. Thus new My_Custom_Plugin();. Note the if you want to be a good citizen you should allow … Read more

Disable Auto-Expanding Menu in WordPress Admin Menus

I see two options here – override the CSS, or remove the “active” classes with JavaScript (sadly there is no action/filter that we can do this server-side) – I opted for the JS approach, it’s cleaner, leaner and meaner: function wpse_227037_remove_menu_classes() { echo ‘<script>jQuery( “.wp-has-current-submenu.wp-menu-open” ).removeClass( “wp-has-current-submenu wp-menu-open” ).addClass( “wp-not-current-submenu” );</script>’; } add_action( ‘adminmenu’, ‘wpse_227037_remove_menu_classes’ … Read more

What is the replacement for rich_edit_exists()?

This is stored in the user meta table under the rich_editing meta key for each user. You could one of these (untested): 1) Add it for your specific users, e.g. via `add_user_meta( $user_id, ‘rich_editing’, ‘true’, true );` 2) Within the wp_default_editor() function, that determines the default editor, the user_can_richedit() function is applied. It checks for … Read more

Schedule some work in custom plugin

If you want to disable the “fake” WordPress cron and trigger your scheduled tasks, then you will need to use a real cron job to ping WordPress. How to disable WP Cron Just add a single line to your instances wp-config.php file: define( ‘DISABLE_WP_CRON’, true ); How to set up a real cron job The … Read more

Best way to distribute templates and code accross multiple wordpress sites?

You can bundle the files into a plugin. For the Christmas page, you could use the page_template filter – This question gives you an example on how to use it – Create custom page templates with plugins? For the CSS/JS file, you can add them using the wp_enqueue_scripts action, as you would normally use in … Read more

when i activate my plugin i want to auto create pages with shortcodes

From what I understood from your question, you will need to use register_activation_hook(), which runs when your plugin is activated. register_activation_hook(__FILE__, ‘your_function_name’); then in that function you can use `wp_insert_post’ to create your page. Refer this link to pass new post parameters as per your need: https://developer.wordpress.org/reference/functions/wp_insert_post/ Edit: In your plugin file make a function … Read more