Making WordPress.org

Ticket #859: 859.3.patch

File 859.3.patch, 2.8 KB (added by JayantiC, 9 years ago)

Thank you for feedback. I have improved code accordingly. Please find attachment.

  • classes/wordcamp-coming-soon-page.php

     
    1414                add_filter( 'template_include',   array( $this, 'override_theme_template' ) );
    1515
    1616                add_image_size( 'wccsp_image_medium_rectangle', 500, 300 );
     17
     18                add_action( 'admin_bar_menu', array( $this, 'display_coming_soon_top_notice' ), 1000 );
    1719        }
    1820
    1921        /**
     
    219221               
    220222                return $contact_form_shortcode;
    221223        }
     224
     225/**
     226     * Display notice in admin bar when coming soon mode is on
     227     */
     228         
     229    function display_coming_soon_top_notice($str){
     230        global $wp_admin_bar;
     231                       
     232        $settings = $GLOBALS['WCCSP_Settings'] -> get_settings();
     233        $msg = '';
     234               
     235               
     236        if ( $settings['enabled'] == 'on' ) {
     237                       
     238                                $msg = __('You are in coming soon mode','wordcamporg');
     239                               
     240                         $wp_admin_bar -> add_node( array(
     241            'id'     => 'wordcamp-coming-soon-info',
     242            'href' => $setting_url,
     243            'parent' => 'top-secondary',
     244            'title'  => $msg,
     245            'meta'   => array( 'class' => 'wc-coming-soon-info' ),
     246        ) );
     247                               
     248           }
     249                $this -> block_new_post_coming_soon();
     250       
     251               
     252    }
     253        public function block_new_post_coming_soon(){
     254               
     255                global $wp_roles;
     256       
     257                global $wp_admin_bar, $current_screen;
     258               
     259                $screen = get_current_screen ();
     260        $settings = $GLOBALS['WCCSP_Settings'] -> get_settings();
     261        $msg = '';
     262               
     263                $setting_url = admin_url ().'options-general.php?page=wccsp_settings';
     264               
     265        if ( $settings['enabled'] == 'on' ) {
     266                        if ( trim($screen -> id) == 'post' ) {
     267                                                        $class = 'notice notice-error';
     268                                                        $message = __( 'You cannot pubilsh posts while in Coming Soon mode. 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' );
     269                                                        printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
     270                                                        $editor = get_role( 'admin' );
     271                                                        $editor -> remove_cap( 'publish_posts' );
     272                                                        $editor = get_role( 'editor' );
     273                                                        $editor -> remove_cap( 'publish_posts' );
     274                                                        $editor = get_role( 'author' );
     275                                                        $editor -> remove_cap( 'publish_posts' );
     276                        }
     277                }
     278        }
     279
    222280} // end WordCamp_Coming_Soon_Page
  • css/template-coming-soon.css

     
    7575                .grunion-field-label span {
    7676                        padding-left: 5px;
    7777                }
     78                .wc-coming-soon-info{
     79                        background-color:#0085ba !important;
     80                }
    7881
    7982@media all and ( min-width: 800px ) {
    8083        #wccsp-container {