Changeset 7173 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php
- Timestamp:
- 04/26/2018 10:18:32 PM (6 years ago)
- 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 9 9 */ 10 10 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 styles13 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' ) ); 21 21 add_filter( 'get_post_metadata', array( $this, 'jetpack_dont_email_post_to_subs' ), 10, 4 ); 22 22 … … 29 29 public function init() { 30 30 $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' ); 32 32 $this->override_theme_template = $show_page || $this->is_coming_soon_preview(); 33 33 } … … 77 77 */ 78 78 protected function dequeue_all_stylesheets() { 79 foreach ( $GLOBALS['wp_styles']->queue as $stylesheet ) {79 foreach ( $GLOBALS['wp_styles']->queue as $stylesheet ) { 80 80 wp_dequeue_style( $stylesheet ); 81 81 } … … 141 141 * @return array 142 142 */ 143 function get_template_variables() {143 public function get_template_variables() { 144 144 $variables = array( 145 145 'image_url' => $this->get_image_url(), … … 167 167 } 168 168 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. 170 170 $background = $settings['body_background_color']; 171 171 if ( '#666666' === $background ) { … … 173 173 } 174 174 175 // Just in case we can't find Jetpack_Color 175 // Just in case we can't find Jetpack_Color. 176 176 if ( class_exists( 'Jetpack_Color' ) ) { 177 177 $color = new Jetpack_Color( $background, 'hex' ); … … 181 181 $color_hsl['h'], 182 182 $color_hsl['s'], 183 ( $color_hsl['l'] >= 85 ) ? 100 : $color_hsl['l'] + 15 183 ( $color_hsl['l'] >= 85 ) ? 100 : $color_hsl['l'] + 15, 184 184 ), 'hsl' ); 185 185 … … 187 187 $color_hsl['h'], 188 188 $color_hsl['s'], 189 ( $color_hsl['l'] < 10 ) ? 0 : $color_hsl['l'] - 10 189 ( $color_hsl['l'] < 10 ) ? 0 : $color_hsl['l'] - 10, 190 190 ), 'hsl' ); 191 191 … … 201 201 $colors['darker'] = $background_darker; 202 202 203 // Not currently customizable 203 // Not currently customizable. 204 204 $colors['text'] = '#32373c'; 205 205 $colors['light-text'] = '#b4b9be'; … … 210 210 211 211 /** 212 * Retrieve the URL of the logo image displayed in the template 212 * Retrieve the URL of the logo image displayed in the template. 213 213 * 214 214 * @return string|false … … 224 224 225 225 /** 226 * Retrieve the URL of the background image displayed in the template 226 * Retrieve the URL of the background image displayed in the template. 227 227 * 228 228 * @return string|false … … 242 242 */ 243 243 public function get_dates() { 244 $dates = false;244 $dates = false; 245 245 $wordcamp_post = get_wordcamp_post(); 246 246 247 247 if ( isset( $wordcamp_post->ID ) ) { 248 248 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' 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] ); 251 251 252 252 if ( ! empty( $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) ) { 253 253 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' 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] ); 256 256 } 257 257 } … … 310 310 */ 311 311 public function get_introduction() { 312 $settings 312 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 313 313 314 314 return $settings['introduction']; … … 318 318 * Display notice in admin bar when Coming Soon mode is on. 319 319 * 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 ) { 323 323 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 324 if ( $settings['enabled'] !== 'on' ) { 324 325 if ( 'on' !== $settings['enabled'] ) { 325 326 return; 326 327 } 327 328 328 $menu_slug 329 $menu_slug = add_query_arg( 329 330 array( 330 331 'autofocus[section]' => 'wccsp_live_preview', … … 353 354 public function admin_bar_styling() { 354 355 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 355 if ( $settings['enabled'] !== 'on' ) { 356 357 if ( 'on' !== $settings['enabled'] ) { 356 358 return; 357 359 } … … 370 372 } 371 373 372 /* 374 /** 373 375 * Show a notice if Coming Soon is enabled. 374 376 * … … 377 379 public function block_new_post_admin_notice() { 378 380 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 379 if ( $settings['enabled'] !== 'on' ) { 381 382 if ( 'on' !== $settings['enabled'] ) { 380 383 return; 381 384 } 382 385 383 $menu_slug 386 $menu_slug = add_query_arg( 384 387 array( 385 388 'autofocus[section]' => 'wccsp_live_preview', … … 389 392 ); 390 393 $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'; 395 398 $message = sprintf( 396 399 __( '<a href="%s">Coming Soon mode</a> is enabled. Site subscribers will not receive email notifications about published posts.', 'wordcamporg' ), … … 402 405 } 403 406 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 ) ); 405 408 } 406 409 } … … 414 417 * @param string $meta_key Meta key. 415 418 * @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 ) { 418 423 if ( '_jetpack_dont_email_post_to_subs' === $meta_key ) { 419 424 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 420 425 421 if ( $settings['enabled'] === 'on') {426 if ( 'on' === $settings['enabled'] ) { 422 427 return true; 423 428 } … … 427 432 } 428 433 429 } // end WordCamp_Coming_Soon_Page 434 } // end WordCamp_Coming_Soon_Page.
Note: See TracChangeset
for help on using the changeset viewer.