| 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 | |