Making WordPress.org


Ignore:
Timestamp:
04/26/2018 10:18:32 PM (8 years ago)
Author:
iandunn
Message:

WordCamp Coming Soon Page: Apply coding standards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php

    r6664 r7173  
    99         */
    1010        public function __construct() {
    11                 add_action( 'init',                       array( $this, 'init' ), 11 );                               // after WCCSP_Settings::init()
    12                 add_action( 'wp_enqueue_scripts',         array( $this, 'manage_plugin_theme_stylesheets' ), 99 );    // (hopefully) after all plugins/themes have enqueued their styles
    13                 add_action( 'wp_head',                    array( $this, 'render_dynamic_styles' ) );
    14                 add_filter( 'template_include',           array( $this, 'override_theme_template' ) );
    15                 add_action( 'template_redirect',          array( $this, 'disable_jetpacks_open_graph' ) );
    16                 add_filter( 'rest_authentication_errors', array( $this, 'disable_rest_endpoints' ) );
    17                 add_action( 'admin_bar_menu',             array( $this, 'admin_bar_menu_item' ), 1000 );
    18                 add_action( 'admin_head',                 array( $this, 'admin_bar_styling' ) );
    19                 add_action( 'wp_head',                    array( $this, 'admin_bar_styling' ) );
    20                 add_action( 'admin_notices',              array( $this, 'block_new_post_admin_notice' ) );
     11                add_action( 'init',                       array( $this, 'init'                            ), 11    );  // After WCCSP_Settings::init().
     12                add_action( 'wp_enqueue_scripts',         array( $this, 'manage_plugin_theme_stylesheets' ), 99    );  // (Hopefully) after all plugins/themes have enqueued their styles.
     13                add_action( 'wp_head',                    array( $this, 'render_dynamic_styles'           )        );
     14                add_filter( 'template_include',           array( $this, 'override_theme_template'         )        );
     15                add_action( 'template_redirect',          array( $this, 'disable_jetpacks_open_graph'     )        );
     16                add_filter( 'rest_authentication_errors', array( $this, 'disable_rest_endpoints'          )        );
     17                add_action( 'admin_bar_menu',             array( $this, 'admin_bar_menu_item'             ), 1000 );
     18                add_action( 'admin_head',                 array( $this, 'admin_bar_styling'               )        );
     19                add_action( 'wp_head',                    array( $this, 'admin_bar_styling'               )        );
     20                add_action( 'admin_notices',              array( $this, 'block_new_post_admin_notice'     )        );
    2121                add_filter( 'get_post_metadata',          array( $this, 'jetpack_dont_email_post_to_subs' ), 10, 4 );
    2222
     
    2929        public function init() {
    3030                $settings                      = $GLOBALS['WCCSP_Settings']->get_settings();
    31                 $show_page                     = 'on' == $settings['enabled'] && ! current_user_can( 'edit_posts' );
     31                $show_page                     = 'on' === $settings['enabled'] && ! current_user_can( 'edit_posts' );
    3232                $this->override_theme_template = $show_page || $this->is_coming_soon_preview();
    3333        }
     
    7777         */
    7878        protected function dequeue_all_stylesheets() {
    79                 foreach( $GLOBALS['wp_styles']->queue as $stylesheet ) {
     79                foreach ( $GLOBALS['wp_styles']->queue as $stylesheet ) {
    8080                        wp_dequeue_style( $stylesheet );
    8181                }
     
    141141         * @return array
    142142         */
    143         function get_template_variables() {
     143        public function get_template_variables() {
    144144                $variables = array(
    145145                        'image_url'              => $this->get_image_url(),
     
    167167                }
    168168
    169                 // If they never changed from the old default background color, then use the new default
     169                // If they never changed from the old default background color, then use the new default.
    170170                $background = $settings['body_background_color'];
    171171                if ( '#666666' === $background ) {
     
    173173                }
    174174
    175                 // Just in case we can't find Jetpack_Color
     175                // Just in case we can't find Jetpack_Color.
    176176                if ( class_exists( 'Jetpack_Color' ) ) {
    177177                        $color     = new Jetpack_Color( $background, 'hex' );
     
    181181                                $color_hsl['h'],
    182182                                $color_hsl['s'],
    183                                 ( $color_hsl['l'] >= 85 ) ? 100 : $color_hsl['l'] + 15
     183                                ( $color_hsl['l'] >= 85 ) ? 100 : $color_hsl['l'] + 15,
    184184                        ), 'hsl' );
    185185
     
    187187                                $color_hsl['h'],
    188188                                $color_hsl['s'],
    189                                 ( $color_hsl['l'] < 10 ) ? 0 : $color_hsl['l'] - 10
     189                                ( $color_hsl['l'] < 10 ) ? 0 : $color_hsl['l'] - 10,
    190190                        ), 'hsl' );
    191191
     
    201201                $colors['darker']  = $background_darker;
    202202
    203                 // Not currently customizable
     203                // Not currently customizable.
    204204                $colors['text']       = '#32373c';
    205205                $colors['light-text'] = '#b4b9be';
     
    210210
    211211        /**
    212          * Retrieve the URL of the logo image displayed in the template
     212         * Retrieve the URL of the logo image displayed in the template.
    213213         *
    214214         * @return string|false
     
    224224
    225225        /**
    226          * Retrieve the URL of the background image displayed in the template
     226         * Retrieve the URL of the background image displayed in the template.
    227227         *
    228228         * @return string|false
     
    242242         */
    243243        public function get_dates() {
    244                 $dates = false;
     244                $dates         = false;
    245245                $wordcamp_post = get_wordcamp_post();
    246246
    247247                if ( isset( $wordcamp_post->ID ) ) {
    248248                        if ( ! empty( $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] ) ) {
    249                                 // translators: date format, see https://php.net/date
    250                                 $dates = date_i18n( __( 'F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] );
     249                                // translators: date format, see https://php.net/date.
     250                                $dates = date_i18n( __( 'F jS Y', 'wordcamporg' ), $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] );
    251251
    252252                                if ( ! empty( $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) ) {
    253253                                        if ( $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] !== $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) {
    254                                                 // translators: date format, see https://php.net/date
    255                                                 $dates .= ' - ' . date_i18n( __( 'F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] );
     254                                                // translators: date format, see https://php.net/date.
     255                                                $dates .= ' - ' . date_i18n( __( 'F jS Y', 'wordcamporg' ), $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] );
    256256                                        }
    257257                                }
     
    310310         */
    311311        public function get_introduction() {
    312                 $settings     = $GLOBALS['WCCSP_Settings']->get_settings();
     312                $settings = $GLOBALS['WCCSP_Settings']->get_settings();
    313313
    314314                return $settings['introduction'];
     
    318318         * Display notice in admin bar when Coming Soon mode is on.
    319319         *
    320          * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference
    321          */
    322         function admin_bar_menu_item( $wp_admin_bar ) {
     320         * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference.
     321         */
     322        public function admin_bar_menu_item( $wp_admin_bar ) {
    323323                $settings = $GLOBALS['WCCSP_Settings']->get_settings();
    324                 if ( $settings['enabled'] !== 'on' ) {
     324
     325                if ( 'on' !== $settings['enabled'] ) {
    325326                        return;
    326327                }
    327328
    328                 $menu_slug   = add_query_arg(
     329                $menu_slug = add_query_arg(
    329330                        array(
    330331                                'autofocus[section]' => 'wccsp_live_preview',
     
    353354        public function admin_bar_styling() {
    354355                $settings = $GLOBALS['WCCSP_Settings']->get_settings();
    355                 if ( $settings['enabled'] !== 'on' ) {
     356
     357                if ( 'on' !== $settings['enabled'] ) {
    356358                        return;
    357359                }
     
    370372        }
    371373
    372         /*
     374        /**
    373375         * Show a notice if Coming Soon is enabled.
    374376         *
     
    377379        public function block_new_post_admin_notice() {
    378380                $settings = $GLOBALS['WCCSP_Settings']->get_settings();
    379                 if ( $settings['enabled'] !== 'on' ) {
     381
     382                if ( 'on' !== $settings['enabled'] ) {
    380383                        return;
    381384                }
    382385
    383                 $menu_slug   = add_query_arg(
     386                $menu_slug = add_query_arg(
    384387                        array(
    385388                                'autofocus[section]' => 'wccsp_live_preview',
     
    389392                );
    390393                $setting_url = admin_url( $menu_slug );
    391 
    392                 $screen = get_current_screen();
    393                 if ( trim( $screen->id ) == 'post' ) {
    394                         $class = 'notice notice-warning';
     394                $screen      = get_current_screen();
     395
     396                if ( 'post' === trim( $screen->id ) ) {
     397                        $class   = 'notice notice-warning';
    395398                        $message = sprintf(
    396399                                __( '<a href="%s">Coming Soon mode</a> is enabled. Site subscribers will not receive email notifications about published posts.', 'wordcamporg' ),
     
    402405                        }
    403406
    404                         printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
     407                        printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), wp_kses_data( $message ) );
    405408                }
    406409        }
     
    414417         * @param string            $meta_key  Meta key.
    415418         * @param bool              $single    Whether to return only the first value of the specified $meta_key.
    416          */
    417         function jetpack_dont_email_post_to_subs( $value, $object_id, $meta_key, $single ) {
     419         *
     420         * @return null|array|string
     421         */
     422        public function jetpack_dont_email_post_to_subs( $value, $object_id, $meta_key, $single ) {
    418423                if ( '_jetpack_dont_email_post_to_subs' === $meta_key ) {
    419424                        $settings = $GLOBALS['WCCSP_Settings']->get_settings();
    420425
    421                         if ( $settings['enabled'] === 'on' ) {
     426                        if ( 'on' === $settings['enabled'] ) {
    422427                                return true;
    423428                        }
     
    427432        }
    428433
    429 } // end WordCamp_Coming_Soon_Page
     434} // end WordCamp_Coming_Soon_Page.
Note: See TracChangeset for help on using the changeset viewer.