diff --git a/Gruntfile.js b/Gruntfile.js index ae62e12f..26bedbde 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -78,34 +78,13 @@ module.exports = function( grunt ){ } }, - // Build a zip file for deployment - compress: { - main: { - options: { - archive: 'wordpress-plugin-template.zip' - }, - files: [ - {src: ['assets/css/*.css'], dest: 'assets/css/', filter: 'isFile'}, // includes css files in css path - {src: ['assets/js/*.min.js'], dest: 'assets/js/', filter: 'isFile'}, // includes js files in js path - {src: ['assets/**', '!assets/js', '!assets/css'], dest: 'assets/', filter: 'isFile'}, // includes any other assets outside js/css - {src: ['includes/**'], dest: 'includes/', filter: 'isFile'}, //includes files in includes path - {src: ['lang/**'], dest: 'lang/', filter: 'isFile' }, //includes files in lang path - {src: ['vendor/**'], dest: 'vendor/', filter: 'isFile' }, //includes files in lang path - {src: ['*.php', 'LICENSE', '*.txt'], filter: 'isFile' } //includes base directory files - ] - } - } - }); - grunt.loadTasks('tasks'); - // Load NPM tasks to be used here grunt.loadNpmTasks( 'grunt-contrib-less' ); grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); grunt.loadNpmTasks( 'grunt-contrib-uglify' ); grunt.loadNpmTasks( 'grunt-contrib-watch' ); - grunt.loadNpmTasks( 'grunt-contrib-compress' ); // Register tasks grunt.registerTask( 'default', [ @@ -114,11 +93,4 @@ module.exports = function( grunt ){ 'uglify' ]); - grunt.registerTask( 'build', [ - 'less', - 'cssmin', - 'uglify', - 'compress' - ]) - }; \ No newline at end of file diff --git a/build-plugin.sh b/build-plugin.sh index ab4075fa..8ec758ed 100755 --- a/build-plugin.sh +++ b/build-plugin.sh @@ -4,6 +4,7 @@ DEFAULT_NAME="WordPress Plugin Template" DEFAULT_CLASS=${DEFAULT_NAME// /_} DEFAULT_TOKEN=$( tr '[A-Z]' '[a-z]' <<< $DEFAULT_CLASS) DEFAULT_SLUG=${DEFAULT_TOKEN//_/-} +DEFAULT_OPT_PREFIX="wpt_" printf "Plugin name: " read NAME @@ -23,12 +24,16 @@ fi printf "Include Grunt support (y/n): " read GRUNT +printf "Options prefix: " +read OPT_PREFIX + printf "Initialise new git repo (y/n): " read NEWREPO TOKEN=$( tr '[A-Z]' '[a-z]' <<< $CLASS) SLUG=${TOKEN//_/-} +OPT_PREFIX=${OPT_PREFIX}_ git clone https://github.com/hlashbrooke/$DEFAULT_SLUG.git $FOLDER/$SLUG @@ -126,6 +131,10 @@ cp class-$SLUG-settings.php class-$SLUG-settings.tmp sed "s/$DEFAULT_SLUG/$SLUG/g" class-$SLUG-settings.tmp > class-$SLUG-settings.php rm class-$SLUG-settings.tmp +cp class-$SLUG-settings.php class-$SLUG-settings.tmp +sed "s/$DEFAULT_OPT_PREFIX/$OPT_PREFIX/g" class-$SLUG-settings.tmp > class-$SLUG-settings.php +rm class-$SLUG-settings.tmp + cd lib mv class-$DEFAULT_SLUG-post-type.php class-$SLUG-post-type.php diff --git a/includes/class-wordpress-plugin-template.php b/includes/class-wordpress-plugin-template.php index 0143cccc..03fa5abf 100644 --- a/includes/class-wordpress-plugin-template.php +++ b/includes/class-wordpress-plugin-template.php @@ -102,15 +102,6 @@ class WordPress_Plugin_Template { */ public $script_suffix; - /** - * Plugin Text Domain. - * - * @var string - * @access public - * @since 1.0.0 - */ - public $text_domain; - /** * Constructor funtion. * @@ -118,9 +109,8 @@ class WordPress_Plugin_Template { * @param string $version Plugin version. */ public function __construct( $file = '', $version = '1.0.0' ) { - $this->_version = $version; - $this->_token = 'wordpress_plugin_template'; - $this->text_domain = 'wordpress-plugin-template'; + $this->_version = $version; + $this->_token = 'wordpress_plugin_template'; // Load plugin environment variables. $this->file = $file; @@ -147,7 +137,7 @@ public function __construct( $file = '', $version = '1.0.0' ) { // Handle localisation. $this->load_plugin_textdomain(); - add_action( 'init', array( $this, 'load_plugin_textdomain' ), 0 ); + add_action( 'init', array( $this, 'load_localisation' ), 0 ); } // End __construct () /** @@ -245,6 +235,17 @@ public function admin_enqueue_scripts( $hook = '' ) { wp_enqueue_script( $this->_token . '-admin' ); } // End admin_enqueue_scripts () + /** + * Load plugin localisation + * + * @access public + * @return void + * @since 1.0.0 + */ + public function load_localisation() { + load_plugin_textdomain( 'wordpress-plugin-template', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); + } // End load_localisation () + /** * Load plugin textdomain * @@ -253,7 +254,12 @@ public function admin_enqueue_scripts( $hook = '' ) { * @since 1.0.0 */ public function load_plugin_textdomain() { - load_plugin_textdomain( $this->text_domain, false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); + $domain = 'wordpress-plugin-template'; + + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); + + load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); + load_plugin_textdomain( $domain, false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); } // End load_plugin_textdomain () /** diff --git a/includes/lib/class-wordpress-plugin-template-post-type.php b/includes/lib/class-wordpress-plugin-template-post-type.php index f6351dc7..fdbf55f8 100644 --- a/includes/lib/class-wordpress-plugin-template-post-type.php +++ b/includes/lib/class-wordpress-plugin-template-post-type.php @@ -158,7 +158,7 @@ public function updated_messages( $messages = array() ) { 3 => __( 'Custom field deleted.', 'wordpress-plugin-template' ), 4 => sprintf( __( '%1$s updated.', 'wordpress-plugin-template' ), $this->single ), 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.', 'wordpress-plugin-template' ), $this->single, wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, - 6 => sprintf( __( '%1$s published. %2$sView %3$s%4$s.', 'wordpress-plugin-template' ), $this->single, '', $this->single, '' ), + 6 => sprintf( __( '%1$s published. %2$sView %3$s%4s.', 'wordpress-plugin-template' ), $this->single, '', $this->single, '' ), 7 => sprintf( __( '%1$s saved.', 'wordpress-plugin-template' ), $this->single ), 8 => sprintf( __( '%1$s submitted. %2$sPreview post%3$s%4$s.', 'wordpress-plugin-template' ), $this->single, '', $this->single, '' ), 9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.', 'wordpress-plugin-template' ), $this->single, '' . date_i18n( __( 'M j, Y @ G:i', 'wordpress-plugin-template' ), strtotime( $post->post_date ) ) . '', '', $this->single, '' ), diff --git a/package.json b/package.json index ccdcdb10..f8f556dc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "grunt-contrib-cssmin": "~0.9.0", "grunt-contrib-less": "^2.0.0", "grunt-contrib-uglify": "~0.4.0", - "grunt-contrib-watch": "^1.1.0", - "grunt-contrib-compress": "^1.4.3" + "grunt-contrib-watch": "^1.1.0" } } diff --git a/uninstall.php b/uninstall.php index 7bcdbfb8..38b461df 100644 --- a/uninstall.php +++ b/uninstall.php @@ -14,14 +14,3 @@ } // Do something here if plugin is being uninstalled. -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { - exit; -} - -//change your plugin prefix here -delete_options_prefixed( 'test_' ); - -function delete_options_prefixed( $prefix ) { - global $wpdb; - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'" ); -}