Changeset 3784 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-coming-soon-page/classes/wordcamp-coming-soon-page.php
- Timestamp:
- 08/09/2016 02:53:51 PM (8 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
r3780 r3784 3 3 class WordCamp_Coming_Soon_Page { 4 4 protected $override_theme_template; 5 const VERSION = '0. 1';5 const VERSION = '0.2'; 6 6 7 7 /** … … 22 22 public function init() { 23 23 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 24 $this->override_theme_template = 'on' == $settings['enabled'] && ! current_user_can( 'edit_posts' ); 24 $show_page = 'on' == $settings['enabled'] && ! current_user_can( 'edit_posts' ); 25 $this->override_theme_template = $show_page || $this->is_coming_soon_preview(); 26 } 27 28 /** 29 * Check if the current page is our section of the Previewer 30 * 31 * @return bool 32 */ 33 public function is_coming_soon_preview() { 34 global $wp_customize; 35 36 return isset( $_GET['wccsp-preview'] ) && $wp_customize->is_preview(); 25 37 } 26 38 27 39 /** 28 40 * Ensure the template has a consistent base of CSS rules, regardless of the current theme or Custom CSS 29 * Dequeue irrelevant stylesheets and use TwentyThirteen as the base style30 41 */ 31 42 public function manage_plugin_theme_stylesheets() { … … 35 46 36 47 $this->dequeue_all_stylesheets(); 37 $this->register_twentythirteen_styles();38 48 39 49 wp_enqueue_style( 40 50 'wccsp-template', 41 51 plugins_url( '/css/template-coming-soon.css', __DIR__ ), 42 array( 'twentythirteen-fonts', 'genericons', 'twentythirteen-style', 'admin-bar'),43 self::VERSION52 array(), 53 1 44 54 ); 45 55 } … … 57 67 58 68 /** 59 * Register TwentyThirteen's base styles60 */61 protected function register_twentythirteen_styles() {62 $twentythirteen_uri = get_theme_root_uri( 'twentythirteen' ) . '/twentythirteen';63 64 if ( ! wp_style_is( 'twentythirteen-fonts', 'registered' ) ) {65 wp_register_style( 'twentythirteen-fonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro%3A300%2C400%2C700%2C300italic%2C400italic%2C700italic%7CBitter%3A400%2C700&subset=latin%2Clatin-ext', array(), null );66 }67 68 if ( ! wp_style_is( 'genericons', 'registered' ) ) {69 wp_register_style( 'genericons', $twentythirteen_uri . '/fonts/genericons.css' );70 }71 72 if ( ! wp_style_is( 'twentythirteen-style', 'registered' ) ) {73 wp_register_style( 'twentythirteen-style', $twentythirteen_uri . '/style.css' );74 }75 }76 77 /**78 69 * Render dynamic CSS styles 79 70 */ … … 83 74 } 84 75 85 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 86 ?> 87 88 <!-- BEGIN wordcamp-coming-soon-page --> 89 <style type="text/css"> 90 html, body { 91 color: <?php echo esc_html( $settings['text_color'] ); ?>; 92 } 93 94 #wccsp-container, 95 .widget { 96 background-color: <?php echo esc_html( $settings['container_background_color'] ); ?>; 97 } 98 99 @media all and ( min-width: 800px ) { 100 html, body { 101 background-color: <?php echo esc_html( $settings['body_background_color'] ); ?>; 102 } 103 } 104 </style> 105 <!-- END wordcamp-coming-soon-page --> 106 107 <?php 76 extract( $GLOBALS['WordCamp_Coming_Soon_Page']->get_template_variables() ); 77 78 require_once( dirname( __DIR__ ) . '/css/template-coming-soon-dynamic.php' ); 108 79 } 109 80 … … 131 102 $variables = array( 132 103 'image_url' => $this->get_image_url(), 104 'background_url' => $this->get_bg_image_url(), 133 105 'dates' => $this->get_dates(), 134 106 'active_modules' => Jetpack::$instance->get_active_modules(), 135 107 'contact_form_shortcode' => $this->get_contact_form_shortcode(), 108 'colors' => $this->get_colors(), 136 109 ); 137 110 … … 140 113 141 114 /** 142 * Retrieve the URL of the image displayed in the template 115 * Retrieve the colors for the template 116 * 117 * @return array 118 */ 119 public function get_colors() { 120 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 121 122 if ( ! class_exists( 'Jetpack_Color' ) && function_exists( 'jetpack_require_lib' ) ) { 123 jetpack_require_lib( 'class.color' ); 124 } 125 126 // If they never changed from the old default background color, then use the new default 127 $background = $settings['body_background_color']; 128 if ( '#666666' === $background ) { 129 $background = '#0073aa'; 130 } 131 132 // Just in case we can't find Jetpack_Color 133 if ( class_exists( 'Jetpack_Color' ) ) { 134 $color = new Jetpack_Color( $background, 'hex' ); 135 $color_hsl = $color->toHsl(); 136 137 $lighter_color = new Jetpack_Color( array( 138 $color_hsl['h'], 139 $color_hsl['s'], 140 ( $color_hsl['l'] >= 85 ) ? 100 : $color_hsl['l'] + 15 141 ), 'hsl' ); 142 143 $darker_color = new Jetpack_Color( array( 144 $color_hsl['h'], 145 $color_hsl['s'], 146 ( $color_hsl['l'] < 10 ) ? 0 : $color_hsl['l'] - 10 147 ), 'hsl' ); 148 149 $background_lighter = '#' . $lighter_color->toHex(); 150 $background_darker = '#' . $darker_color->toHex(); 151 } else { 152 $background_lighter = $background; 153 $background_darker = $background; 154 } 155 156 $colors['main'] = $background; 157 $colors['lighter'] = $background_lighter; 158 $colors['darker'] = $background_darker; 159 160 // Not currently customizable 161 $colors['text'] = '#32373c'; 162 $colors['light-text'] = '#b4b9be'; 163 $colors['border'] = '#00669b'; 164 165 return $colors; 166 } 167 168 /** 169 * Retrieve the URL of the logo image displayed in the template 143 170 * 144 171 * @return string|false … … 154 181 155 182 /** 183 * Retrieve the URL of the background image displayed in the template 184 * 185 * @return string|false 186 */ 187 public function get_bg_image_url() { 188 $settings = $GLOBALS['WCCSP_Settings']->get_settings(); 189 $image_meta = wp_get_attachment_metadata( $settings['background_id'] ); 190 $image = wp_get_attachment_image_src( $settings['background_id'], 'full' ); 191 192 return empty( $image[0] ) ? false : $image[0]; 193 } 194 195 /** 156 196 * Retrieve the dates of the WordCamp 157 197 * … … 165 205 if ( ! empty( $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] ) ) { 166 206 // translators: date format, see https://php.net/date 167 $dates = date_i18n( __( ' l,F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] );207 $dates = date_i18n( __( 'F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] ); 168 208 169 209 if ( ! empty( $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) ) { 170 210 if ( $wordcamp_post->meta['Start Date (YYYY-mm-dd)'][0] !== $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ) { 171 211 // translators: date format, see https://php.net/date 172 $dates .= ' - ' . date_i18n( __( ' l,F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] );212 $dates .= ' - ' . date_i18n( __( 'F jS Y' , 'wordcamporg' ), $wordcamp_post->meta['End Date (YYYY-mm-dd)'][0] ); 173 213 } 174 214 }
Note: See TracChangeset
for help on using the changeset viewer.