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

Redirect logged in user to somepage on every page view?

I would utilize the user meta info and ‘wp’ hook for this. You can use a function similar to below: add_action( ‘wp’, ‘wpse69369_special_thingy’ ); function wpse69369_special_thingy() { if ( is_user_logged_in() && “” == get_user_meta( get_current_user_id(), ‘completioncheck’, true ) ) wp_redirect( string $location ); exit; } } Then when the user completes the action necessary you … Read more

Is there a better way of handling AJAX requests in WordPress?

Use add_rewrite_rule to make your own API and handle the endpoints yourself. Tools like Monkeyman Rewrite Analyzer will help you understand how your rewrite rules end up working with existing rules. if ( ! class_exists( ‘WPSEAPIEndpoint’ ) ): class WPSEAPIEndpoint { // WordPress hooks public function __construct() { add_filter( ‘query_vars’, array ( $this, ‘add_query_vars’ ), … 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

change or add css to theme from plugin

I believe you need to add __FILE__ to your plugins_url() function. It may not be calling the right location. It should look like this: add_action( ‘wp_enqueue_scripts’, ‘wpse_238154_register_plugin_styles’ ); function wpse_238154_register_plugin_styles() { wp_enqueue_style( ‘fh-plugin’ , plugins_url( ‘nf-plugin/includes/f-hide.css’, __FILE__ ) ); }

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