Loading external page template and enqueue script from plugin causes 403 forbidden error

Your CODE is fine, the reason you are getting 403 error is because $_SERVER[‘DOCUMENT_ROOT’] returns absolute PATH to your web root, not URL. JavaScript needs to be added as URL. So, you may use Load_Template_Scripts_wpa83855 function in your plugin and then use: wp_enqueue_script( ‘wtd’, plugins_url( ‘/js/wtd.js’ , __FILE__ ) ); CODE to add JavaScript. Note: … Read more

Is it possible to define a template for a custom post type within a plugin independent of the active theme?

You need to use the template_include filter which is the generic filter for all template inclusions. add_filter( ‘template_include’, ‘my_plugin_templates’ ); function my_plugin_templates( $template ) { $post_types = array( ‘project’ ); if ( is_post_type_archive( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/archive-project.php’ ) ) $template=”path/to/list/template/in/plugin/folder.php”; if ( is_singular( $post_types ) && ! file_exists( get_stylesheet_directory() . ‘/single-project.php’ … Read more

How to share category taxonomy with custom post type (The Event Calendar plugin)

You can use register_taxonomy_for_object_type() to use a taxonomy with a post type, without having to touch the post type registration code, example: function wpa_categories_for_events(){ register_taxonomy_for_object_type( ‘category’, ‘tribe_events’ ); } add_action( ‘init’, ‘wpa_categories_for_events’ ); To have events appear on the category pages, I believe you have to modify the default category queries via pre_get_posts to add … Read more

Schedule WordPress Auto-Updates to only run during business hours

This one is actually surprisingly simple; add this to your wp-config.php file and all automatic updates will be blocked when outside of the specified hours: // Suspend updates when outside of business hours, 9:00 AM to 5:30 PM $updates_suspended = (date(‘Hi’) < 0900 || date(‘Hi’) > 1730); define( ‘AUTOMATIC_UPDATER_DISABLED’, $updates_suspended ); You can also use … Read more

difference between add_options and register_setting

register_setting() uses Settings API, which is just an API for options.php, is easier to use, more secure and preffered way of storing options since WordPress 2.7. If you need to store only a few options or doing simple plugin just for yourself – it’s really up to you which one to use 🙂 Here’s the … Read more