Skip to content

Commit

Permalink
Add some moar protections to ensure it only loads on admin and only o…
Browse files Browse the repository at this point in the history
…n the one screen
  • Loading branch information
rebeccahum committed Sep 28, 2023
1 parent ae622ee commit 3297c96
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion security/class-private-sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,27 @@ public function disable_core_feeds() {
}

/**
* Force the blog_public option to be -1 and disable checkbox/radio UI in Reading Settings
* Force the blog_public option to be -1 and disable UI
*/
public function force_blog_public_option() {
add_filter( 'blog_privacy_selector', '__return_true' );
add_filter( 'option_blog_public', array( $this, 'filter_restrict_blog_public' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'disable_blog_public_ui' ) );
}

/**
* Disable checkbox/radio UI in Reading Settings
*/
public function disable_blog_public_ui() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}

$screen = get_current_screen();
if ( 'options-reading' !== $screen->base ) {
return;
}

wp_register_script( 'vip-disable-blog-public-option-ui', false, array(), '0.1', true );
wp_enqueue_script( 'vip-disable-blog-public-option-ui' );
$js_code = <<<JS
Expand Down

0 comments on commit 3297c96

Please sign in to comment.