WordPress.org

Plugin Directory

Changeset 592210


Ignore:
Timestamp:
08/30/12 05:06:44 (20 months ago)
Author:
batmoo
Message:

Sync over the latest and greatest changes from Github in preparation for v1.1

https://github.com/Automattic/developer/commit/89354e1f778de5f2bf58937c9a57ebfddadcdfd1

Location:
developer/trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • developer/trunk/developer.js

    r560881 r592210  
    6060            } ) 
    6161                .success( function( result ) { 
    62                     if ( '1' == result ) { 
     62                    if ( '1' === result ) { 
    6363                        $(button).html( a8c_developer_i18n.installed ); 
    6464                        $(button).unbind('click').prop('disabled', true); 
    6565                    } else { 
     66                        alert( result ); 
    6667                        $(button).html( a8c_developer_i18n.error ); 
    6768                    } 
     
    8485            } ) 
    8586                .success( function( result ) { 
    86                     if ( '1' == result ) { 
     87                    if ( '1' === result ) { 
    8788                        $(button).html( a8c_developer_i18n.activated ); 
    8889                        $(button).unbind('click').prop('disabled', true); 
    8990                    } else { 
     91                        alert( result ); 
    9092                        $(button).html( a8c_developer_i18n.error ); 
    9193                    } 
  • developer/trunk/developer.php

    r560881 r592210  
    66Plugin URI:   http://wordpress.org/extend/plugins/developer/ 
    77Description:  The first stop for every WordPress developer 
    8 Version:      1.0.0 
     8Version:      1.1 
    99Author:       Automattic 
    10 Author URI:   http://automattic.com/wordpress-plugins/ 
     10Author URI:   http://automattic.com 
    1111License:      GPLv2 or later 
    1212 
     
    2626    public $default_settings       = array(); 
    2727 
    28     // Using "private" for read-only functionality. See __get(). 
    29     private $version               = '1.0.0'; 
    30  
    31     private $option_name           = 'a8c_developer'; 
    32     private $settings_page_slug    = 'a8c_developer'; 
     28    const VERSION                  = '1.1'; 
     29    const OPTION                   = 'a8c_developer'; 
     30    const PAGE_SLUG                = 'a8c_developer'; 
    3331 
    3432    private $recommended_plugins   = array(); 
     
    3634 
    3735    function __construct() { 
    38         add_action( 'init',           array( &$this, 'init' ) ); 
    39         add_action( 'admin_init',     array( &$this, 'admin_init' ) ); 
    40  
    41         add_action( 'admin_menu',     array( &$this, 'register_settings_page' ) ); 
    42         add_action( 'admin_bar_menu', array( &$this, 'add_node_to_admin_bar' ) ); 
    43  
    44         add_action( 'admin_enqueue_scripts', array( &$this, 'load_settings_page_script_and_style' ) ); 
    45  
    46         add_action( 'wp_ajax_a8c_developer_lightbox_step_1',  array( &$this, 'ajax_handler' ) ); 
    47         add_action( 'wp_ajax_a8c_developer_install_plugin',   array( &$this, 'ajax_handler' ) ); 
    48         add_action( 'wp_ajax_a8c_developer_activate_plugin',  array( &$this, 'ajax_handler' ) ); 
     36        add_action( 'init',           array( $this, 'init' ) ); 
     37        add_action( 'admin_init',     array( $this, 'admin_init' ) ); 
     38 
     39        add_action( 'admin_menu',     array( $this, 'register_settings_page' ) ); 
     40        add_action( 'admin_bar_menu', array( $this, 'add_node_to_admin_bar' ) ); 
     41 
     42        add_action( 'admin_enqueue_scripts', array( $this, 'load_settings_page_script_and_style' ) ); 
     43 
     44        add_action( 'wp_ajax_a8c_developer_lightbox_step_1',  array( $this, 'ajax_handler' ) ); 
     45        add_action( 'wp_ajax_a8c_developer_install_plugin',   array( $this, 'ajax_handler' ) ); 
     46        add_action( 'wp_ajax_a8c_developer_activate_plugin',  array( $this, 'ajax_handler' ) ); 
    4947    } 
    5048 
     
    5957        ); 
    6058 
    61         $this->settings = wp_parse_args( (array) get_option( $this->option_name ), $this->default_settings ); 
     59        $this->settings = wp_parse_args( (array) get_option( self::OPTION ), $this->default_settings ); 
    6260    } 
    6361 
    6462    public function admin_init() { 
     63        if ( ! empty( $_GET['developer_plugin_reset'] ) && current_user_can( 'manage_options' ) ) { 
     64            delete_option( self::OPTION ); 
     65        } 
     66 
    6567        $this->recommended_plugins = array( 
    6668            'debug-bar' => array( 
     
    8587            ), 
    8688            'vip-scanner' => array( 
    87                 'project_type' => 'all', 
     89                'project_type' => 'wpcom-vip', 
    8890                'name'         => esc_html__( 'VIP Scanner', 'a8c-developer' ), 
    8991                'active'       => class_exists( 'VIP_Scanner' ), 
     
    9294            'jetpack' => array( 
    9395                'project_type' => 'wpcom-vip', 
    94                 'name'   => esc_html__( 'Jetpack', 'a8c-developer' ), 
    95                 'active' => class_exists( 'Jetpack' ), 
     96                'name'         => esc_html__( 'Jetpack', 'a8c-developer' ), 
     97                'active'       => class_exists( 'Jetpack' ), 
    9698            ), 
    9799            /**/ 
     
    111113                'active'       => class_exists( 'Monster_Widget' ), 
    112114            ), 
     115            'user-switching' => array( 
     116                'project_type' => 'all', 
     117                'name'         => esc_html__( 'User Switching', 'a8c-developer' ), 
     118                'active'       => class_exists( 'user_switching' ), 
     119            ), 
     120            'pig-latin' => array( 
     121                'project_type'  => 'all', 
     122                'name'      => esc_html__( 'Pig Latin', 'a8c-developer' ), 
     123                'active'    => class_exists( 'PigLatin' ), 
     124            ), 
    113125            'wordpress-beta-tester' => array( 
    114126                'project_type' => 'all', 
    115127                'name'         => esc_html__( 'Beta Tester', 'a8c-developer' ), 
    116128                'active'       => class_exists( 'wp_beta_tester' ), 
    117                 'filename'       => 'wp-beta-tester.php', 
    118             ), 
    119             /* 
    120             'foobar' => array( 
    121                 'name'     => 'Dummy Test Plugin', 
    122                 'active'   => false, 
    123                 'filename' => 'blah.php', 
    124             ), 
    125             /**/ 
     129                'filename'     => 'wp-beta-tester.php', 
     130            ), 
     131 
     132            // Theme Developer 
     133            'rtl-tester' => array( 
     134                'project_type' => 'wporg-theme', 
     135                'name'         => esc_html__( 'RTL Tester', 'a8c-developer' ), 
     136                'active'       => false, 
     137            ), 
     138            'regenerate-thumbnails' => array( 
     139                'project_type' => 'wporg-theme', 
     140                'name'         => esc_html__( 'Regenerate Thumbnails', 'a8c-developer' ), 
     141                'active'       => false, 
     142            ), 
     143            'reveal-ids' => array( 
     144                'project_type' => 'wporg-theme', 
     145                'name'         => esc_html__( 'Reveal IDs', 'a8c-developer' ), 
     146                'active'       => false, 
     147            ), 
     148            'theme-test-drive' => array( 
     149                'project_type' => 'wporg-theme', 
     150                'name'         => esc_html__( 'Theme Test Drive', 'a8c-developer' ), 
     151                'active'       => false, 
     152            ), 
     153            'theme-check' => array( 
     154                'project_type' => 'wporg-theme', 
     155                'name'         => esc_html__( 'Theme Check', 'a8c-developer' ), 
     156                'active'       => false, 
     157            ), 
    126158        ); 
    127159 
     
    131163        ); 
    132164 
    133         register_setting( $this->option_name, $this->option_name, array( &$this, 'settings_validate' ) ); 
    134  
    135  
    136         wp_register_script( 'a8c-developer', plugins_url( 'developer.js', __FILE__ ), array( 'jquery' ), $this->version ); 
     165        register_setting( self::OPTION, self::OPTION, array( $this, 'settings_validate' ) ); 
     166 
     167 
     168        wp_register_script( 'a8c-developer', plugins_url( 'developer.js', __FILE__ ), array( 'jquery' ), self::VERSION ); 
    137169        $strings = array( 
    138             'settings_slug'  => $this->settings_page_slug, 
     170            'settings_slug'  => self::PAGE_SLUG, 
    139171            'go_to_step_2'   => ( current_user_can( 'install_plugins' ) && current_user_can( 'activate_plugins' ) && 'direct' == get_filesystem_method() ) ? 'yes' : 'no', 
    140172            'lightbox_title' => __( 'Developer: Plugin Setup', 'a8c-developer' ), 
     
    147179            'ACTIVE'         => __( 'ACTIVE', 'a8c-developer' ), 
    148180            'INSTALLED'      => __( 'INSTALLED', 'a8c-developer' ), 
    149             'ERROR'              => __( 'ERROR!', 'a8c-developer' ), 
     181            'ERROR'          => __( 'ERROR!', 'a8c-developer' ), 
    150182        ); 
    151183        wp_localize_script( 'a8c-developer', 'a8c_developer_i18n', $strings ); 
    152184 
    153         wp_register_style( 'a8c-developer', plugins_url( 'developer.css', __FILE__ ), array(), $this->version ); 
     185        wp_register_style( 'a8c-developer', plugins_url( 'developer.css', __FILE__ ), array(), self::VERSION ); 
    154186 
    155187 
     
    163195        } 
    164196 
    165         if ( ! get_option( $this->option_name ) ) { 
     197        if ( ! get_option( self::OPTION ) ) { 
    166198            if ( ! empty( $_GET['a8cdev_errorsaving'] ) ) { 
    167                 add_settings_error( $this->settings_page_slug, $this->settings_page_slug . '_error_saving', __( 'Error saving settings. Please try again.', 'a8c-developer' ) ); 
    168             } elseif ( current_user_can( 'manage_options' ) ) { 
    169                 add_action( 'admin_enqueue_scripts', array( &$this, 'load_lightbox_scripts_and_styles' ) ); 
    170                 add_action( 'admin_footer', array( &$this, 'output_setup_box_html' ) ); 
     199                add_settings_error( self::PAGE_SLUG, self::PAGE_SLUG . '_error_saving', __( 'Error saving settings. Please try again.', 'a8c-developer' ) ); 
     200            } elseif ( ! is_network_admin() && current_user_can( 'manage_options' ) ) { 
     201                add_action( 'admin_enqueue_scripts', array( $this, 'load_lightbox_scripts_and_styles' ) ); 
     202                add_action( 'admin_footer', array( $this, 'output_setup_box_html' ) ); 
    171203            } 
    172204        } 
     
    174206 
    175207    public function register_settings_page() { 
    176         add_options_page( esc_html__( 'Automattic Developer Helper', 'a8c-developer' ), esc_html__( 'Developer', 'a8c-developer' ), 'manage_options', $this->settings_page_slug, array( &$this, 'settings_page' ) ); 
     208        add_management_page( esc_html__( 'Developer Helper', 'a8c-developer' ), esc_html__( 'Developer', 'a8c-developer' ), 'manage_options', self::PAGE_SLUG, array( $this, 'settings_page' ) ); 
    177209    } 
    178210 
    179211    public function add_node_to_admin_bar( $wp_admin_bar ) { 
     212 
     213        if ( !current_user_can( 'manage_options' ) ) 
     214            return; 
     215 
    180216        $wp_admin_bar->add_node( array( 
    181             'id'     => $this->settings_page_slug, 
     217            'id'     => self::PAGE_SLUG, 
    182218            'title'  => esc_html__( 'Developer', 'a8c-developer' ), 
    183219            'parent' => 'top-secondary', // Off on the right side 
    184             'href'   => admin_url( 'options-general.php?page=' . $this->settings_page_slug ), 
     220            'href'   => admin_url( 'tools.php?page=' . self::PAGE_SLUG ), 
    185221            'meta'   => array( 
    186                 'title' => esc_html__( 'View the Automattic Developer Helper settings and status page', 'a8c-developer' ), 
     222            'title'  => esc_html__( 'View the Developer Helper settings and status page', 'a8c-developer' ), 
    187223            ), 
    188224        ) ); 
     
    190226 
    191227    public function load_settings_page_script_and_style( $hook_suffix ) { 
    192         if ( 'settings_page_' . $this->settings_page_slug != $hook_suffix ) 
     228        if ( 'tools_page_' . self::PAGE_SLUG != $hook_suffix ) 
    193229            return; 
    194230 
     
    210246        <div style="display:none"> 
    211247            <div id="a8c-developer-setup-dialog-step-1" class="a8c-developer-dialog"> 
    212                 <strong><?php esc_html_e( "Thanks for installing Automattic's Developer helper plugin!", 'a8c-developer' ); ?></strong> 
     248                <strong><?php esc_html_e( "Thanks for installing the Developer Helper plugin!", 'a8c-developer' ); ?></strong> 
    213249 
    214250                <p><?php esc_html_e( 'Before we begin, what type of website are you developing?', 'a8c-developer' ); ?></p> 
    215251 
    216252                <form id="a8c-developer-setup-dialog-step-1-form" action="options-general.php?page=a8c_developer" method="post"> 
    217                     <?php wp_nonce_field( 'a8c_developer_lightbox_step_1' ); ?>  
     253                    <?php wp_nonce_field( 'a8c_developer_lightbox_step_1' ); ?> 
    218254                    <input type="hidden" name="action" value="a8c_developer_lightbox_step_1" /> 
    219255 
    220                     <p><label><input type="radio" name="a8c_developer_project_type" value="wporg" checked="checked" /> <?php esc_html_e( 'A normal WordPress.org website', 'a8c-developer' ); ?></label></p> 
    221                     <p><label><input type="radio" name="a8c_developer_project_type" value="wpcom-vip" /> <?php esc_html_e( 'A website hosted on WordPress.com VIP', 'a8c-developer' ); ?></label></p> 
     256                    <?php $i = 0; ?> 
     257                    <?php foreach ( $this->get_project_types() as $project_slug => $project_description ) : ?> 
     258                        <?php $i++; ?> 
     259                        <p> 
     260                            <label> 
     261                                <input type="radio" name="a8c_developer_project_type" value="<?php echo esc_attr( $project_slug ); ?>" <?php checked( $i, 1 ); ?> /> 
     262                                <?php echo $project_description; ?> 
     263                            </label> 
     264                        </p> 
     265                    <?php endforeach; ?> 
    222266 
    223267                    <?php submit_button( null, 'primary', 'a8c-developer-setup-dialog-step-1-submit' ); ?> 
     
    289333            case 'a8c_developer_install_plugin': 
    290334                if ( empty( $_POST['plugin_slug'] ) ) 
    291                     die( '-1' ); 
     335                    die( __( 'ERROR: No slug was passed to the AJAX callback.', 'a8c-developer' ) ); 
    292336 
    293337                check_ajax_referer( 'a8c_developer_install_plugin_' . $_POST['plugin_slug'] ); 
    294338 
    295339                if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) 
    296                     die( '-1' ); 
     340                    die( __( 'ERROR: You lack permissions to install and/or activate plugins.', 'a8c-developer' ) ); 
    297341 
    298342                include_once ( ABSPATH . 'wp-admin/includes/plugin-install.php' ); 
     
    301345 
    302346                if ( is_wp_error( $api ) ) 
    303                     die( '-1' ); 
     347                    die( sprintf( __( 'ERROR: Error fetching plugin information: %s', 'a8c-developer' ), get_error_message( $api ) ) ); 
    304348 
    305349                $upgrader = new Plugin_Upgrader( new Automattic_Developer_Empty_Upgrader_Skin( array( 
     
    312356 
    313357                if ( ! $install_result || is_wp_error( $install_result ) ) 
    314                     die( '-1' ); 
     358                    die( sprintf( __( 'ERROR: Failed to install plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) ); 
    315359 
    316360                $activate_result = activate_plugin( $this->get_path_for_recommended_plugin( $_POST['plugin_slug'] ) ); 
    317361 
    318362                if ( is_wp_error( $activate_result ) ) 
    319                     die( '-1' ); 
     363                    die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) ); 
    320364 
    321365                exit( '1' ); 
     
    323367            case 'a8c_developer_activate_plugin': 
    324368                if ( empty( $_POST['path'] ) ) 
    325                     die( '-1' ); 
     369                    die( __( 'ERROR: No slug was passed to the AJAX callback.', 'a8c-developer' ) ); 
    326370 
    327371                check_ajax_referer( 'a8c_developer_activate_plugin_' . $_POST['path'] ); 
    328372 
    329373                if ( ! current_user_can( 'activate_plugins' ) ) 
    330                     die( '-1' ); 
     374                    die( __( 'ERROR: You lack permissions to activate plugins.', 'a8c-developer' ) ); 
    331375 
    332376                $activate_result = activate_plugin( $_POST['path'] ); 
    333377 
    334378                if ( is_wp_error( $activate_result ) ) 
    335                     die( '-1' ); 
     379                    die( sprintf( __( 'ERROR: Failed to activate plugin: %s', 'a8c-developer' ), get_error_message( $api ) ) ); 
    336380 
    337381                exit( '1' ); 
     
    343387 
    344388    public function settings_page() { 
    345         add_settings_section( 'a8c_developer_main', esc_html__( 'Main Configuration', 'a8c-developer' ), '__return_false', $this->settings_page_slug . '_settings' ); 
    346         add_settings_field( 'a8c_developer_project_type', esc_html__( 'Project Type', 'a8c-developer' ), array( &$this, 'settings_field_select' ), $this->settings_page_slug . '_settings', 'a8c_developer_main', array( 
     389        add_settings_section( 'a8c_developer_main', esc_html__( 'Main Configuration', 'a8c-developer' ), '__return_false', self::PAGE_SLUG . '_settings' ); 
     390        add_settings_field( 'a8c_developer_project_type', esc_html__( 'Project Type', 'a8c-developer' ), array( $this, 'settings_field_radio' ), self::PAGE_SLUG . '_settings', 'a8c_developer_main', array( 
    347391            'name'        => 'project_type', 
    348             'description' => __( 'Are you developing plugins and themes for <a href="http://wordpress.org/">self-hosted blogs</a> or are you working on a <a href="http://vip.wordpess.com/">WordPress.com VIP</a> project?', 'a8c-developer' ), 
    349             'options'     => array( 
    350                 'wporg'     => esc_html__( 'WordPress.org', 'a8c-developer' ), 
    351                 'wpcom-vip' => esc_html__( 'WordPress.com VIP', 'a8c-developer' ), 
    352             ), 
     392            'description' => '', 
     393            'options'     => $this->get_project_types(), 
    353394        ) ); 
    354395 
     
    358399            }); 
    359400        </script>'; 
    360          
    361         add_settings_section( 'a8c_developer_plugins', esc_html__( 'Plugins', 'a8c-developer' ), array( &$this, 'settings_section_plugins' ), $this->settings_page_slug . '_status' ); 
     401 
     402        // Plugins 
     403        add_settings_section( 'a8c_developer_plugins', esc_html__( 'Plugins', 'a8c-developer' ), array( $this, 'settings_section_plugins' ), self::PAGE_SLUG . '_status' ); 
    362404        foreach ( $this->recommended_plugins as $plugin_slug => $plugin_details ) { 
    363405            if ( 'all' != $plugin_details['project_type'] && $plugin_details['project_type'] != $this->settings['project_type'] ) 
     
    365407 
    366408            $plugin_details = array_merge( array( 'slug' => $plugin_slug ), $plugin_details ); 
    367             add_settings_field( 'a8c_developer_plugin_' . $plugin_slug, $plugin_details['name'], array( &$this, 'settings_field_plugin' ), $this->settings_page_slug . '_status', 'a8c_developer_plugins', $plugin_details ); 
    368         } 
    369  
    370         add_settings_section( 'a8c_developer_constants', esc_html__( 'Constants', 'a8c-developer' ), array( &$this, 'settings_section_constants' ), $this->settings_page_slug . '_status' ); 
     409            add_settings_field( 'a8c_developer_plugin_' . $plugin_slug, $plugin_details['name'], array( $this, 'settings_field_plugin' ), self::PAGE_SLUG . '_status', 'a8c_developer_plugins', $plugin_details ); 
     410        } 
     411 
     412        // Constants 
     413        add_settings_section( 'a8c_developer_constants', esc_html__( 'Constants', 'a8c-developer' ), array( $this, 'settings_section_constants' ), self::PAGE_SLUG . '_status' ); 
    371414        foreach ( $this->recommended_constants as $constant => $description ) { 
    372             add_settings_field( 'a8c_developer_constant_' . $constant, $constant, array( &$this, 'settings_field_constant' ), $this->settings_page_slug . '_status', 'a8c_developer_constants', array( 
     415            add_settings_field( 'a8c_developer_constant_' . $constant, $constant, array( $this, 'settings_field_constant' ), self::PAGE_SLUG . '_status', 'a8c_developer_constants', array( 
    373416                'constant'    => $constant, 
    374417                'description' => $description, 
     
    376419        } 
    377420 
    378         add_settings_section( 'a8c_developer_settings', esc_html__( 'Settings', 'a8c-developer' ), array( &$this, 'settings_section_settings' ), $this->settings_page_slug . '_status' ); 
    379         add_settings_field( 'a8c_developer_setting_permalink_structure', esc_html__( 'Pretty Permalinks', 'a8c-developer' ), array( &$this, 'settings_field_setting_permalink_structure' ), $this->settings_page_slug . '_status', 'a8c_developer_settings' ); 
     421        // Settings 
     422        add_settings_section( 'a8c_developer_settings', esc_html__( 'Settings', 'a8c-developer' ), array( $this, 'settings_section_settings' ), self::PAGE_SLUG . '_status' ); 
     423        add_settings_field( 'a8c_developer_setting_permalink_structure', esc_html__( 'Pretty Permalinks', 'a8c-developer' ), array( $this, 'settings_field_setting_permalink_structure' ), self::PAGE_SLUG . '_status', 'a8c_developer_settings' ); 
    380424        if ( 'wpcom-vip' == $this->settings['project_type'] ) { 
    381       add_settings_field( 'a8c_developer_setting_development_version', esc_html__( 'Development Version', 'a8c-developer' ), array( &$this, 'settings_field_setting_development_version' ), $this->settings_page_slug . '_status', 'a8c_developer_settings' ); 
    382       add_settings_field( 'a8c_developer_setting_shared_plugins', esc_html__( 'Shared Plugins', 'a8c-developer' ), array( &$this, 'settings_field_setting_shared_plugins' ), $this->settings_page_slug . '_status', 'a8c_developer_settings' ); 
    383         } 
    384  
     425            add_settings_field( 'a8c_developer_setting_development_version', esc_html__( 'Development Version', 'a8c-developer' ), array( $this, 'settings_field_setting_development_version' ), self::PAGE_SLUG . '_status', 'a8c_developer_settings' ); 
     426            add_settings_field( 'a8c_developer_setting_shared_plugins', esc_html__( 'Shared Plugins', 'a8c-developer' ), array( $this, 'settings_field_setting_shared_plugins' ), self::PAGE_SLUG . '_status', 'a8c_developer_settings' ); 
     427        } 
     428 
     429        // Resources 
     430        add_settings_section( 'a8c_developer_resources', esc_html__( 'Resources', 'a8c-developer' ), array( $this, 'settings_section_resources' ), self::PAGE_SLUG . '_status' ); 
     431 
     432        add_settings_field( 'a8c_developer_setting_codex', esc_html__( 'Codex', 'a8c-developer' ), array( $this, 'settings_field_setting_resource_codex' ), self::PAGE_SLUG . '_status', 'a8c_developer_resources' ); 
     433 
     434        if ( 'wpcom-vip' == $this->settings['project_type'] ) 
     435            add_settings_field( 'a8c_developer_setting_vip_lobby', esc_html__( 'VIP Lobby', 'a8c-developer' ), array( $this, 'settings_field_setting_resource_vip_lobby' ), self::PAGE_SLUG . '_status', 'a8c_developer_resources' ); 
     436 
     437        if ( in_array( $this->settings['project_type'], array( 'wporg-theme', 'wpcom-vip' ) ) ) 
     438            add_settings_field( 'a8c_developer_setting_starter_themes', esc_html__( 'Starter Themes', 'a8c-developer' ), array( $this, 'settings_field_setting_resource_starter_themes' ), self::PAGE_SLUG . '_status', 'a8c_developer_resources' ); 
    385439 
    386440        # Add more sections and fields here as needed 
     
    391445        <?php screen_icon( 'tools' ); ?> 
    392446 
    393         <h2><?php esc_html_e( 'Automattic Developer Helper', 'a8c-developer' ); ?></h2> 
     447        <h2><?php esc_html_e( 'Developer Helper', 'a8c-developer' ); ?></h2> 
    394448 
    395449        <form action="options.php" method="post"> 
    396450 
    397             <?php settings_fields( $this->option_name ); // matches value from register_setting() ?> 
    398  
    399             <?php do_settings_sections( $this->settings_page_slug . '_settings' ); // matches values from add_settings_section/field() ?> 
     451            <?php settings_fields( self::OPTION ); // matches value from register_setting() ?> 
     452 
     453            <?php do_settings_sections( self::PAGE_SLUG . '_settings' ); // matches values from add_settings_section/field() ?> 
    400454 
    401455            <?php submit_button(); ?> 
    402456 
    403             <?php do_settings_sections( $this->settings_page_slug . '_status' ); ?> 
     457            <?php do_settings_sections( self::PAGE_SLUG . '_status' ); ?> 
    404458        </form> 
    405459 
    406460        </div> 
    407461<?php 
     462    } 
     463 
     464    public function settings_field_radio( $args ) { 
     465        if ( empty( $args['name'] ) || ! is_array( $args['options'] ) ) 
     466            return false; 
     467 
     468        $selected = ( isset( $this->settings[ $args['name'] ] ) ) ? $this->settings[ $args['name'] ] : ''; 
     469 
     470        foreach ( (array) $args['options'] as $value => $label ) 
     471            echo '<p><label><input type="radio" name="a8c_developer[' . esc_attr( $args['name'] ) . ']" value="' . esc_attr( $value ) . '"' . checked( $value, $selected, false ) . '> ' . $label . '</input></label></p>'; 
     472 
     473        if ( ! empty( $args['description'] ) ) 
     474            echo ' <p class="description">' . $args['description'] . '</p>'; 
    408475    } 
    409476 
     
    422489 
    423490        if ( ! empty( $args['description'] ) ) 
    424             echo ' <span class="description">' . $args['description'] . '</span>'; 
     491            echo ' <p class="description">' . $args['description'] . '</p>'; 
    425492    } 
    426493 
     
    436503            if ( current_user_can('activate_plugins') ) { 
    437504                $path = $this->get_path_for_recommended_plugin( $args['slug'] ); 
    438                 echo '<a class="a8c-developer-notactive a8c-developer-button-activate" href="' . esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) . '" data-path="' . esc_attr( $path ) . '" data-nonce="' . wp_create_nonce( 'a8c_developer_activate_plugin_' . $path ) . '" title="' . esc_attr__( 'Click here to activate', 'a8c-developer' ) . '">' . esc_html__( 'INACTIVE', 'a8c-developer' ) . '</a>';                   
     505                echo '<a class="a8c-developer-notactive a8c-developer-button-activate" href="' . esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) . '" data-path="' . esc_attr( $path ) . '" data-nonce="' . wp_create_nonce( 'a8c_developer_activate_plugin_' . $path ) . '" title="' . esc_attr__( 'Click here to activate', 'a8c-developer' ) . '">' . esc_html__( 'INACTIVE', 'a8c-developer' ) . '</a>'; 
    439506            } else { 
    440507                echo '<span class="a8c-developer-notactive">' . esc_html__( 'INACTIVE', 'a8c-developer' ) . '</span>'; 
     
    478545    } 
    479546 
    480   public function settings_field_setting_development_version() { 
    481     $cur = get_preferred_from_update_core(); 
    482  
    483     if( $cur->response == 'development' ) { 
    484       echo '<span class="a8c-developer-active">' . esc_html__( 'ENABLED', 'a8c-developer' ) . '</span>'; 
    485     } else { 
    486       echo '<a href="'. network_admin_url( 'update-core.php' ) .'" class="a8c-developer-notactive">' . esc_html__( 'DISABLED', 'a8c-developer' ) . '</a>';     
    487     } 
    488   } 
    489  
    490   public function settings_field_setting_shared_plugins() {  
    491         if( file_exists(WP_CONTENT_DIR . '/themes/vip') && file_exists(WP_CONTENT_DIR . '/themes/vip/plugins') ) { 
     547    public function settings_field_setting_development_version() { 
     548        $cur = get_preferred_from_update_core(); 
     549 
     550        if ( $cur->response == 'development' ) { 
     551            echo '<span class="a8c-developer-active">' . esc_html__( 'ENABLED', 'a8c-developer' ) . '</span>'; 
     552        } else { 
     553            echo '<a href="'. network_admin_url( 'update-core.php' ) .'" class="a8c-developer-notactive">' . esc_html__( 'DISABLED', 'a8c-developer' ) . '</a>'; 
     554        } 
     555    } 
     556 
     557    public function settings_field_setting_shared_plugins() { 
     558        if ( file_exists( WP_CONTENT_DIR . '/themes/vip' ) && file_exists( WP_CONTENT_DIR . '/themes/vip/plugins' ) ) { 
    492559            echo '<span class="a8c-developer-active">' . esc_html__( 'ENABLED', 'a8c-developer' ) . '</span>'; 
    493560        } else { 
     
    496563    } 
    497564 
     565    public function settings_section_resources() {} 
     566 
     567    public function settings_field_setting_resource_codex() { 
     568        _e( "The <a href='http://codex.wordpress.org/Developer_Documentation'>Developer Documentation section</a> of the Codex offers guidelines and references for anyone wishing to modify, extend, or contribute to WordPress.", 'a8c-developer' ); 
     569    } 
     570 
     571    public function settings_field_setting_resource_vip_lobby() { 
     572        _e( "The <a href='http://lobby.vip.wordpress.com'>VIP Lobby</a> is a technical documentation resource for developing sites on WordPress.com including best practices and helpful tips to help you code better, faster, and stronger.", 'a8c-developer' ); 
     573    } 
     574 
     575    public function settings_field_setting_resource_starter_themes() { 
     576        _e( "<a href='http://underscores.me'>_s (or underscores)</a>: a starter theme meant for hacking that will give you a \"1000-Hour Head Start\". Use it to create the next, most awesome WordPress theme out there.", 'a8c-developer' ); 
     577    } 
     578 
    498579    public function settings_validate( $raw_settings ) { 
    499580        $settings = array(); 
    500581 
    501         $settings['project_type'] = ( ! empty( $raw_settings['project_type'] ) && 'wpcom-vip' == $raw_settings['project_type'] ) ? 'wpcom-vip' : 'wporg'; 
     582        $project_type_slugs = array_keys( $this->get_project_types() ); 
     583        if ( empty( $raw_settings['project_type'] ) || ! in_array( $raw_settings['project_type'], $project_type_slugs ) ) 
     584            $settings['project_type'] = current( $project_type_slugs ); 
     585        else 
     586            $settings['project_type'] = $raw_settings['project_type']; 
    502587 
    503588        return $settings; 
     
    510595        $this->settings = $this->settings_validate( $settings ); 
    511596 
    512         update_option( $this->option_name, $this->settings ); 
     597        update_option( self::OPTION, $this->settings ); 
    513598    } 
    514599 
     
    535620        return false; 
    536621    } 
     622 
     623    private function get_project_types() { 
     624        return array( 
     625            'wporg'       => __( 'Plugin for a self-hosted WordPress installation', 'a8c-developer' ), 
     626            'wporg-theme' => __( 'Theme for a self-hosted WordPress installation', 'a8c-developer' ), 
     627            'wpcom-vip'   => __( 'Theme for a <a href="http://vip.wordpress.com" target="_blank">WordPress.com VIP</a> site', 'a8c-developer' ), 
     628        ); 
     629    } 
    537630} 
    538631 
    539 $Automattic_Developer = new Automattic_Developer(); 
    540  
    541 ?> 
     632$automattic_developer = new Automattic_Developer(); 
  • developer/trunk/readme.txt

    r561042 r592210  
    33Tags: developer, development, local 
    44Requires at least: 3.4 
    5 Tested up to: 3.4 
    6 Stable tag: 1.0 
     5Tested up to: 3.4.1 
     6Stable tag: 1.1 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    1414A plugin, which helps WordPress developers develop. 
    1515 
    16 The plugin will help you optimize your development environment by making sure that you have all the essential tools and plugins installed and available. 
     16This plugin will help you optimize your development environment by making sure that you have all the essential tools and plugins installed. 
    1717 
    18 If you'd like to check out the code and cotribute, [join us on github](https://github.com/Automattic/developer), pull requests are more than welcome. 
     18If you'd like to check out the code and contribute, [join us on GitHub](https://github.com/Automattic/developer). Pull requests, issues, and plugin recommendations are more than welcome! 
    1919 
    20 We would like to thank Ejner Galaz for lettign us use the `developer` slug in the WordPress plugin repository. 
     20We would like to thank Ejner Galaz for letting us use the `developer` slug in the WordPress.org plugin repository. 
    2121 
    2222== Installation == 
    2323 
    24241. Upload the `developer` folder to your plugins directory (e.g. `/wp-content/plugins/`) 
    25 1. Activate the plugin through the 'Plugins' menu in WordPress 
    26 1. Follow the instructions 
     252. Activate the plugin through the 'Plugins' menu in WordPress 
     263. Follow the instructions 
    2727 
    2828== Frequently Asked Questions == 
    2929 
    30 = Why are there no FAQs? = 
     30= Why are there no FAQs besides this one? = 
    3131 
    3232Because you haven't asked one yet. 
     
    3434== Screenshots == 
    3535 
    36 1. The plugin will check to make sure you have the correct plugins and settings available. 
     361. On activation, the plugin prompts you to specify what type of developer you are. This is used to configure the plugins checks. 
     372. On activation, the plugin does a quick check to see if you have essential developer plugins installed. 
     383. With one click you can install and activate the plugin. 
     394. The plugin's settings page (Tools > Developer) will check to make sure your environment is correctly configured, including plugins, constants, and other settings. 
    3740 
    3841== Changelog == 
    3942 
     43= 1.1 (2012-08-30) = 
     44* New "WP.org Theme" project type for developers building themes for self-hosted installs with a number of sweet plugins recommended by the WordPress.com Theme Team. 
     45* Simplify some of the wording across the plugin. 
     46* Added John Blackbourn's [User Switching](http://wordpress.org/extend/plugins/user-switching/) is now a recommended plugin for all projects. 
     47* Added [Pig Latin](http://wordpress.org/extend/plugins/pig-latin) plugin to help developer i18n their code. 
     48* Added resources for all projects. 
     49* Bug fix: don't show installation prompt in network admin. 
     50 
    4051= 1.0 = 
    4152* Initial Release 
Note: See TracChangeset for help on using the changeset viewer.