Changeset 3056
- Timestamp:
- 05/02/2016 09:14:37 AM (10 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory
- Files:
-
- 4 added
- 1 deleted
- 1 edited
- 2 copied
- 1 moved
-
inc (added)
-
inc/class-plugin.php (copied) (copied from sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php) (2 diffs)
-
inc/cli (moved) (moved from sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/cli)
-
inc/cli/class-set-theme-project.php (copied) (copied from sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/cli/set-theme-project.php) (6 diffs)
-
inc/cli/set-theme-project.php (deleted)
-
vendor (added)
-
vendor/wordpressdotorg (added)
-
vendor/wordpressdotorg/class-autoloader.php (added)
-
wporg-gp-theme-directory.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/class-plugin.php
r3051 r3056 1 1 <?php 2 /**3 * Plugin name: GlotPress: Theme Directory Bridge4 * Description: Provides CLI commands to import themes into translate.wordpress.org or to mark themes as inactive.5 * Version: 1.06 * Author: WordPress.org7 * Author URI: http://wordpress.org/8 * License: GPLv2 or later9 */10 2 11 class WPorg_GP_Theme_Directory { 12 public $master_project = 'wp-themes'; 3 namespace WordPressdotorg\GlotPress\Theme_Directory; 13 4 14 public function __construct() { 5 use WP_CLI; 15 6 7 class Plugin { 8 9 /** 10 * @var Plugin The singleton instance. 11 */ 12 private static $instance; 13 14 /** 15 * 16 * @var Sync\Translation_Sync 17 */ 18 public $translation_sync = null; 19 20 /** 21 * Returns always the same instance of this plugin. 22 * 23 * @return Plugin 24 */ 25 public static function get_instance() { 26 if ( ! ( self::$instance instanceof Plugin ) ) { 27 self::$instance = new Plugin(); 28 } 29 return self::$instance; 30 } 31 32 /** 33 * Instantiates a new Plugin object. 34 */ 35 private function __construct() { 36 add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); 37 } 38 39 /** 40 * Initializes the plugin. 41 */ 42 public function plugins_loaded() { 16 43 if ( defined( 'WP_CLI' ) && WP_CLI ) { 17 44 $this->register_cli_commands(); … … 23 50 */ 24 51 function register_cli_commands() { 25 require_once __DIR__ . '/cli/set-theme-project.php'; 26 27 WP_CLI::add_command( 'wporg-translate set-theme-project', 'WPorg_GP_CLI_Set_Theme_Project' ); 52 WP_CLI::add_command( 'wporg-translate set-theme-project', __NAMESPACE__ . '\CLI\Set_Theme_Project' ); 28 53 } 29 54 } 30 31 function wporg_gp_theme_directory() {32 global $wporg_gp_theme_directory;33 34 if ( ! isset( $wporg_gp_theme_directory ) ) {35 $wporg_gp_theme_directory = new WPorg_GP_Theme_Directory();36 }37 38 return $wporg_gp_theme_directory;39 }40 add_action( 'plugins_loaded', 'wporg_gp_theme_directory' ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/inc/cli/class-set-theme-project.php
r3051 r3056 1 1 <?php 2 2 3 class WPorg_GP_CLI_Set_Theme_Project extends WP_CLI_Command { 3 namespace WordPressdotorg\GlotPress\Theme_Directory\CLI; 4 5 use GP; 6 use MakePOT; 7 use WP_CLI; 8 use WP_CLI_Command; 9 10 class Set_Theme_Project extends WP_CLI_Command { 4 11 5 12 /** … … 165 172 * @param string $theme_slug The theme slug to generate the project from. 166 173 * @param array $theme_data The theme data (headers + screenshot) from get_theme_data(). 174 * @return \GP_Project|false GP project on success, false on failure. 167 175 */ 168 176 private function find_create_update_glotpress_project( $theme_slug, $theme_data ) { … … 176 184 'parent_project_id' => $parent_project->id, 177 185 'source_url_template' => "https://themes.trac.wordpress.org/browser/$theme_slug/{$theme_data['version']}/%file%#L%line%", 178 'active' => 1 186 'active' => 1, 179 187 ); 180 188 … … 216 224 if ( $project ) { 217 225 $project->save( array( 218 'active' => 0 226 'active' => 0, 219 227 ) ); 220 228 } … … 240 248 } 241 249 242 WP_CLI::line( sprintf( "Creating translation set %s (%s)", $set->name, $set->locale . ( $set->slug != 'default' ? '/' . $set->slug : '' ) ) );250 WP_CLI::line( sprintf( 'Creating translation set %s (%s)', $set->name, $set->locale . ( $set->slug != 'default' ? '/' . $set->slug : '' ) ) ); 243 251 244 252 GP::$translation_set->create( array( … … 255 263 * 256 264 * @param string $pot_file The themes pot file to import. 257 * @param GP_Project $project The theme project to import into.265 * @param \GP_Project $project The theme project to import into. 258 266 */ 259 267 private function import_pot_to_glotpress( $pot_file, $project ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-theme-directory/wporg-gp-theme-directory.php
r2367 r3056 3 3 * Plugin name: GlotPress: Theme Directory Bridge 4 4 * Description: Provides CLI commands to import themes into translate.wordpress.org or to mark themes as inactive. 5 * Version: 1.05 * Version: 2.0 6 6 * Author: WordPress.org 7 7 * Author URI: http://wordpress.org/ … … 9 9 */ 10 10 11 class WPorg_GP_Theme_Directory { 12 public $master_project = 'wp-themes'; 11 namespace WordPressdotorg\GlotPress\Theme_Directory; 13 12 14 public function __construct() { 13 use WordPressdotorg\Autoload; 15 14 16 if ( defined( 'WP_CLI' ) && WP_CLI ) { 17 $this->register_cli_commands(); 18 } 19 } 15 // Store the root plugin file for usage with functions which use the plugin basename. 16 define( __NAMESPACE__ . '\PLUGIN_FILE', __FILE__ ); 20 17 21 /** 22 * Registers CLI commands if WP-CLI is loaded. 23 */ 24 function register_cli_commands() { 25 require_once __DIR__ . '/cli/set-theme-project.php'; 26 27 WP_CLI::add_command( 'wporg-translate set-theme-project', 'WPorg_GP_CLI_Set_Theme_Project' ); 28 } 18 if ( ! class_exists( '\WordPressdotorg\Autoload\Autoloader', false ) ) { 19 include __DIR__ . '/vendor/wordpressdotorg/class-autoloader.php'; 29 20 } 30 21 31 function wporg_gp_theme_directory() { 32 global $wporg_gp_theme_directory;22 // Register an Autoloader for all files. 23 Autoload\register_class_path( __NAMESPACE__, __DIR__ . '/inc' ); 33 24 34 if ( ! isset( $wporg_gp_theme_directory ) ) { 35 $wporg_gp_theme_directory = new WPorg_GP_Theme_Directory(); 36 } 37 38 return $wporg_gp_theme_directory; 39 } 40 add_action( 'plugins_loaded', 'wporg_gp_theme_directory' ); 25 // Instantiate the Plugin. 26 Plugin::get_instance();
Note: See TracChangeset
for help on using the changeset viewer.