diff --git a/plugin.php b/plugin.php index 8e6f5e5..ff7415e 100644 --- a/plugin.php +++ b/plugin.php @@ -37,10 +37,10 @@ class PluginName { * Initializes the plugin by setting localization, filters, and administration functions. */ function __construct() { - - // TODO: replace "plugin-name-locale" with a unique value for your plugin - load_plugin_textdomain( 'plugin-name-locale', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); + // load plugin text domain + add_action( 'init', array( $this, 'textdomain' ) ); + // Register admin styles and scripts add_action( 'admin_print_styles', array( $this, 'register_admin_styles' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ) ); @@ -48,7 +48,7 @@ class PluginName { // Register site styles and scripts add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_scripts' ) ); - + register_activation_hook( __FILE__, array( $this, 'activate' ) ); register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) ); @@ -86,6 +86,14 @@ class PluginName { // TODO define deactivation functionality here } // end deactivate + /** + * Loads the plugin text domain for translation + */ + public function textdomain() { + // TODO: replace "plugin-name-locale" with a unique value for your plugin + load_plugin_textdomain( 'plugin-name-locale', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); + } + /** * Registers and enqueues admin-specific styles. */ @@ -157,4 +165,4 @@ class PluginName { } // end class // TODO: update the instantiation call of your plugin to the name given at the class definition -new PluginName(); \ No newline at end of file +$plugin_name = new PluginName(); \ No newline at end of file