Custom Post Type Templates from Plugin Folder?

You can use single_template filter hook. /* Filter the single_template with our custom function*/ add_filter(‘single_template’, ‘my_custom_template’); function my_custom_template($single) { global $post; /* Checks for single template by post type */ if ( $post->post_type == ‘POST TYPE NAME’ ) { if ( file_exists( PLUGIN_PATH . ‘/Custom_File.php’ ) ) { return PLUGIN_PATH . ‘/Custom_File.php’; } } return … Read more

Between functions.php (theme), widgets, and plugins, which is loaded first?

The plugins are loaded right before theme (yes, I’ve been looking for excuse to use this): However it is wrong to think about either as point of code execution. For most cases everything should be hooked and executed no earlier than init hook. According to Codex widget registration with register_widget() should be hooked to widget_init. … Read more

Which banner plugin is this? [closed]

That would be revslider http://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380 Warning, last year there was some information about it having a vulnerability on wordpress websites. The 2 websites I had it pre installed on via themes have also broken due to a update in rev slider requiring me to go in and amend the rev slider code to disable it. … Read more

Best way to initiate a class in a WP plugin?

Good question, there are a number of approaches and it depends on what you want to achieve. I often do; add_action( ‘plugins_loaded’, array( ‘someClassy’, ‘init’ )); class someClassy { public static function init() { $class = __CLASS__; new $class; } public function __construct() { //construct what you see fit here… } //etc… } A more … Read more

Uninstall, Activate, Deactivate a plugin: typical features & how-to

There are three different hooks. They trigger in the following cases: Uninstall Deactivation Activation How-to trigger functions safely during the scenarios The following shows the right ways to safely hook callback functions that get triggered during the mentioned actions. As you could use this code in a plugin that uses plain functions, a class or … Read more