| 223 | |
| 224 | /** |
| 225 | * Display notice in admin bar when coming soon mode is on |
| 226 | */ |
| 227 | function display_coming_soon_notice($str){ |
| 228 | global $pagenow,$wp_admin_bar; |
| 229 | wp_enqueue_script('jquery'); |
| 230 | |
| 231 | $settings= $GLOBALS['WCCSP_Settings']->get_settings(); |
| 232 | $msg = ''; |
| 233 | |
| 234 | $setting_url=admin_url().'options-general.php?page=wccsp_settings'; |
| 235 | |
| 236 | if($settings['enabled']=='on'){ |
| 237 | |
| 238 | $msg = __(' |
| 239 | <style>.wc-coming-soon-info{ |
| 240 | background-color:#0085ba !important; |
| 241 | }</style> |
| 242 | You are in coming soon mode','coming-soon'); |
| 243 | |
| 244 | if ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) { |
| 245 | $class = 'notice notice-error'; |
| 246 | $message = __( 'You cannot pubilsh posts while in Coming Soon mode. <br />Once the site is ready for a public audience, please <a href="' . $setting_url . '">disable Coming Soon mode</a> and then publish this post.', 'sample-text-domain' ); |
| 247 | |
| 248 | echo " |
| 249 | <script> |
| 250 | jQuery(document).ready(function(){ |
| 251 | jQuery('#publish').click(function() |
| 252 | { |
| 253 | alert('You cannot pubilsh posts while in Coming Soon mode. Once the site is ready for a public audience, please disable Coming Soon mode and then publish this post.'); |
| 254 | setTimeout(\"jQuery('#ajax-loading').css('visibility', 'hidden');\", 100); |
| 255 | jQuery('[id^=\"taxonomy\"]').find('.tabs-panel').css('background', '#F96'); |
| 256 | setTimeout(\"jQuery('#publish').removeClass('button-primary-disabled');\", 100); |
| 257 | return false; |
| 258 | }); |
| 259 | }); |
| 260 | </script>"; |
| 261 | |
| 262 | printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message ); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | $wp_admin_bar->add_menu( array( |
| 267 | 'id' => 'wordcamp-coming-soon-info', |
| 268 | 'href' => $setting_url, |
| 269 | 'parent' => 'top-secondary', |
| 270 | 'title' => $msg, |
| 271 | 'meta' => array( 'class' => 'wc-coming-soon-info' ), |
| 272 | ) ); |
| 273 | |
| 274 | } |