-
-
Save bradyvercher/dde7306ba472fec8a39f to your computer and use it in GitHub Desktop.
Cedaro Blog: Structuring Plugins http://www.cedaro.com/blog/structuring-wordpress-plugins/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: My Plugin | |
* Plugin URI: https://gist.github.com/bradyvercher/dde7306ba472fec8a39f | |
* Version: 1.0.0 | |
* Author: Cedaro | |
* Author URI: http://www.cedaro.com/ | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
function myplugin() { | |
static $instance; | |
if ( null === $instance ) { | |
$instance = new MyPlugin_Plugin(); | |
} | |
return $instance; | |
} | |
myplugin()->set_basename( plugin_basename( __FILE__ ) ) | |
->set_directory( plugin_dir_path( __FILE__ ) ) | |
->set_file( __FILE__ ) | |
->set_slug( 'myplugin' ) | |
->set_url( plugin_dir_url( __FILE__ ) ); | |
myplugin()->register_hooks( new MyPlugin_Provider_I18n() ); | |
add_action( 'plugins_loaded', array( myplugin(), 'load' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hooks. | |
* | |
* @package MyPlugin | |
* @copyright Copyright (c) 2016, Cedaro, LLC | |
* @license GPL-2.0+ | |
* @since 1.0.0 | |
*/ | |
/** | |
* Hooks class. | |
* | |
* @package MyPlugin | |
* @since 1.0.0 | |
*/ | |
class MyPlugin_Hooks { | |
/** | |
* Register hooks. | |
* | |
* @since 1.0.0 | |
*/ | |
public function run() { | |
} | |
} | |
// Don't do this in the same file where the class is defined. | |
$myhooks = new MyPlugin_MyHooks(); | |
$myhooks->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment