From 696d133f368dba963a351bfd7bd69a151543a494 Mon Sep 17 00:00:00 2001 From: Pippin Williamson Date: Mon, 5 Nov 2012 21:07:10 -0600 Subject: [PATCH 1/2] Moved load_plugin_textdomain() --- plugin.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugin.php b/plugin.php index 8e6f5e5..370b2ab 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. */ From 36609340a78c101150336db4d05915259cb145be Mon Sep 17 00:00:00 2001 From: Pippin Williamson Date: Mon, 5 Nov 2012 21:07:44 -0600 Subject: [PATCH 2/2] Set bew PluginName() to a global variable --- plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.php b/plugin.php index 370b2ab..ff7415e 100644 --- a/plugin.php +++ b/plugin.php @@ -165,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