Options if running in WPMU add_action( 'update_wpmu_options', array( &$this, 'sitewide_privacy_update' )); add_action( 'wpmu_options', array( &$this, 'sitewide_privacy_options_page' )); // hook into options-privacy.php Dashboard->Settings->Privacy. add_action('blog_privacy_selector', array( &$this, 'privacy_options' )); if( '-1' == get_site_option( 'bsuite_site_privacy' )){ add_action('template_redirect', array( &$this, 'check_authz' )); $this->set_privacy_filters(); }else{ switch( get_option( 'blog_public' )){ case '-3': case '-2': case '-1': add_action('template_redirect', array( &$this, 'check_authz' )); case '0': $this->set_privacy_filters(); } } } function set_privacy_filters() { // fixes robots.txt rules remove_action('do_robots', 'do_robots'); add_action('do_robots', array( &$this, 'do_robots' ), 1 ); // the default noindex function doesn't understand these extended options, so we remove and replace it remove_action( 'login_head', 'noindex' ); remove_action( 'wp_head', 'noindex',1 );//priority 1 add_action('wp_head', array( &$this, 'noindex' ), 1 ); add_action('login_head', array( &$this, 'noindex' ), 1 ); // the default privacy ping filter doesn't understand these extended options, so we remove and replace it remove_filter( 'option_ping_sites', 'privacy_ping_filter' ); add_filter('option_ping_sites', array( &$this, 'privacy_ping_filter' ),1); } function do_robots() { header( 'Content-Type: text/plain; charset=utf-8' ); do_action( 'do_robotstxt' ); echo "User-agent: *\n"; echo "Disallow:\n"; echo "Disallow: /wp-admin\n"; echo "Disallow: /wp-includes\n"; echo "Disallow: /wp-login.php\n"; echo "Disallow: /wp-content/plugins\n"; echo "Disallow: /wp-content/cache\n"; echo "Disallow: /wp-content/themes\n"; echo "Disallow: /trackback\n"; echo "Disallow: /comments\n"; } function noindex() { echo "\n"; } function privacy_ping_filter($sites) { return ''; } function check_authz () { if ( !is_user_logged_in() ) auth_redirect(); switch( get_option( 'blog_public' )){ case '-3': if( !current_user_can( 'manage_options' )) $this->fail_authz(); case '-2': if( !current_user_can( 'read' )) $this->fail_authz(); } } function fail_authz() { nocache_headers(); // header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' ); header( 'HTTP/1.0 401 Unauthorized' ); ?>
/>
/>
/>
Sitewide Privacy Selector'; echo '| ' . __('Site Privacy') . ' | '; $checked = ( $number == "-1" ) ? " checked=''" : ""; echo '
' . __('Site can be viewed by registered users of this community only.') . ' | ';
$checked = ( $number == "1" ) ? " checked=''" : "";
echo '
' . __('Default: privacy managed per blog.') . ' |
|---|