Skip to content
Snippets Groups Projects
Commit 35b7af91 authored by lucha's avatar lucha Committed by agata
Browse files

removed send mail on privacy setting change

parent a66a1b9b
No related branches found
No related tags found
No related merge requests found
...@@ -26,10 +26,10 @@ To allow everyone who is on-campus into the blog, while requiring those off-camp ...@@ -26,10 +26,10 @@ To allow everyone who is on-campus into the blog, while requiring those off-camp
Such as this: Such as this:
if ( (strncmp('155.47.', $_SERVER['REMOTE_ADDR'], 7 ) == 0) || (is_user_logged_in()) ) { if ( (strncmp('155.47.', $_SERVER['REMOTE_ADDR'], 7 ) == 0) || (is_user_logged_in()) ) {
// user is either logged in or at campus // user is either logged in or at campus
} }
else { else {
// user is either not logged in or at campus // user is either not logged in or at campus
if( is_feed() ) { if( is_feed() ) {
... ...
...@@ -69,9 +69,9 @@ Third, you could redirect any url match to the main page wp-activate.php, but th ...@@ -69,9 +69,9 @@ Third, you could redirect any url match to the main page wp-activate.php, but th
// at any rate using url matching was dumb - adding wp-activate.php to any url bypassed the login auth - so a redirect to main site may help - provided the main site isn't also private. // at any rate using url matching was dumb - adding wp-activate.php to any url bypassed the login auth - so a redirect to main site may help - provided the main site isn't also private.
// if( strpos($_SERVER['REQUEST_URI'], 'wp-activate.php') && !is_main_site()) { //DO NOT DO THIS! // if( strpos($_SERVER['REQUEST_URI'], 'wp-activate.php') && !is_main_site()) { //DO NOT DO THIS!
So, better may be PHP_SELF since we can wait for script to execute before deciding to auth_redirect it. So, better may be PHP_SELF since we can wait for script to execute before deciding to auth_redirect it.
// if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) { // if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) {
// $destination = network_home_url('wp-activate.php'); // $destination = network_home_url('wp-activate.php');
// wp_redirect( $destination ); // wp_redirect( $destination );
...@@ -86,7 +86,7 @@ Finally, changing the hook to fire at send_headers rather than template_redirect ...@@ -86,7 +86,7 @@ Finally, changing the hook to fire at send_headers rather than template_redirect
So, I have the private functions the way I actually use them on my private sites/networks. I also do many activations as the SiteAdmin manually using other plugins. So, I have the private functions the way I actually use them on my private sites/networks. I also do many activations as the SiteAdmin manually using other plugins.
Therefore, the code in this revision may make blogs more private, but somewhat more inconvenient to activate, both features I desire. Therefore, the code in this revision may make blogs more private, but somewhat more inconvenient to activate, both features I desire.
We'll see how the feedback trickles in on this issue. We'll see how the feedback trickles in on this issue.
*/ */
...@@ -95,12 +95,12 @@ class DS_More_Privacy_Options { ...@@ -95,12 +95,12 @@ class DS_More_Privacy_Options {
function __construct() { function __construct() {
global $current_blog; global $current_blog;
if ( ! is_multisite() ) { if ( ! is_multisite() ) {
add_action( 'all_admin_notices', array( $this, 'display_not_multisite_notice' ) ); add_action( 'all_admin_notices', array( $this, 'display_not_multisite_notice' ) );
return false; return false;
} }
$this->l10n_prefix = 'more-privacy-options'; $this->l10n_prefix = 'more-privacy-options';
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
...@@ -110,7 +110,7 @@ class DS_More_Privacy_Options { ...@@ -110,7 +110,7 @@ class DS_More_Privacy_Options {
// Network->Settings // Network->Settings
add_action( 'update_wpmu_options', array($this, 'sitewide_privacy_update')); add_action( 'update_wpmu_options', array($this, 'sitewide_privacy_update'));
add_action( 'wpmu_options', array($this, 'sitewide_privacy_options_page')); add_action( 'wpmu_options', array($this, 'sitewide_privacy_options_page'));
// hooks into Misc Blog Actions in Network->Sites->Edit // hooks into Misc Blog Actions in Network->Sites->Edit
add_action('wpmueditblogaction', array($this, 'wpmu_blogs_add_privacy_options'),-999); add_action('wpmueditblogaction', array($this, 'wpmu_blogs_add_privacy_options'),-999);
// hooks into Blog Columns views Network->Sites // hooks into Blog Columns views Network->Sites
...@@ -124,18 +124,18 @@ class DS_More_Privacy_Options { ...@@ -124,18 +124,18 @@ class DS_More_Privacy_Options {
$number = intval(get_site_option('ds_sitewide_privacy')); $number = intval(get_site_option('ds_sitewide_privacy'));
if (( '-1' == $current_blog->public ) || ($number == '-1')) { if (( '-1' == $current_blog->public ) || ($number == '-1')) {
//wp_is_mobile() ? is send_headers or template_redirect better for mobiles? //wp_is_mobile() ? is send_headers or template_redirect better for mobiles?
add_action('template_redirect', array($this, 'ds_users_authenticator')); add_action('template_redirect', array($this, 'ds_users_authenticator'));
// add_action('send_headers', array($this, 'ds_users_authenticator')); // add_action('send_headers', array($this, 'ds_users_authenticator'));
add_action('login_form', array($this, 'registered_users_login_message')); add_action('login_form', array($this, 'registered_users_login_message'));
add_filter('privacy_on_link_title', array($this, 'registered_users_header_title')); add_filter('privacy_on_link_title', array($this, 'registered_users_header_title'));
add_filter('privacy_on_link_text', array($this, 'registered_users_header_link') ); add_filter('privacy_on_link_text', array($this, 'registered_users_header_link') );
} }
if ( '-2' == $current_blog->public ) { if ( '-2' == $current_blog->public ) {
add_action('template_redirect', array($this, 'ds_members_authenticator')); add_action('template_redirect', array($this, 'ds_members_authenticator'));
// add_action('send_headers', array($this, 'ds_members_authenticator')); // add_action('send_headers', array($this, 'ds_members_authenticator'));
add_action('login_form', array($this, 'registered_members_login_message')); add_action('login_form', array($this, 'registered_members_login_message'));
add_filter('privacy_on_link_title', array($this, 'registered_members_header_title')); add_filter('privacy_on_link_title', array($this, 'registered_members_header_title'));
add_filter('privacy_on_link_text', array($this, 'registered_members_header_link') ); add_filter('privacy_on_link_text', array($this, 'registered_members_header_link') );
...@@ -148,7 +148,7 @@ class DS_More_Privacy_Options { ...@@ -148,7 +148,7 @@ class DS_More_Privacy_Options {
add_filter('privacy_on_link_text', array($this, 'registered_admins_header_link') ); add_filter('privacy_on_link_text', array($this, 'registered_admins_header_link') );
} }
// fixes robots.txt rules // fixes robots.txt rules
add_action('do_robots', array($this, 'do_robots'),1); add_action('do_robots', array($this, 'do_robots'),1);
// fixes noindex meta as well // fixes noindex meta as well
...@@ -158,26 +158,27 @@ class DS_More_Privacy_Options { ...@@ -158,26 +158,27 @@ class DS_More_Privacy_Options {
//no pings unless public either //no pings unless public either
add_filter('option_ping_sites', array($this, 'privacy_ping_filter'),1); add_filter('option_ping_sites', array($this, 'privacy_ping_filter'),1);
//email SuperAdmin when privacy changes //email SuperAdmin when privacy changes
add_action( 'update_blog_public', array($this,'ds_mail_super_admin')); //add_action( 'update_blog_public', array($this,'ds_mail_super_admin'));
// hook into signup form? // hook into signup form?
add_action('signup_blogform', array($this, 'add_privacy_options')); add_action('signup_blogform', array($this, 'add_privacy_options'));
} }
function display_not_multisite_notice() { function display_not_multisite_notice() {
echo '<div class="error"><p>' . __( 'More Privacy Options is a plugin just for multisites, please deactivate it.', $this->l10n_prefix) . '</p></div>'; echo '<div class="error"><p>' . __( 'More Privacy Options is a plugin just for multisites, please deactivate it.', $this->l10n_prefix) . '</p></div>';
} }
function ds_localization_init() { function ds_localization_init() {
load_plugin_textdomain( $this->l10n_prefix, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); load_plugin_textdomain( $this->l10n_prefix, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
} }
function ds_mail_super_admin() { function ds_mail_super_admin() {
return;
global $blog_id; global $blog_id;
$blog_public_new = get_blog_option($blog_id,'blog_public'); $blog_public_new = get_blog_option($blog_id,'blog_public');
$to_new = $this->ds_mail_super_admin_messages($blog_public_new); $to_new = $this->ds_mail_super_admin_messages($blog_public_new);
$blogname = get_blog_option( $blog_id, 'blogname'); $blogname = get_blog_option( $blog_id, 'blogname');
$email = stripslashes( get_site_option('admin_email') ); $email = stripslashes( get_site_option('admin_email') );
$subject = __('Site ', $this->l10n_prefix).'"'.$blogname.'" (ID: '.$blog_id.'), '.get_site_url( $blog_id ).', '. __('changed reading visibility setting to ', $this->l10n_prefix) .'"'. $to_new.'"'; $subject = __('Site ', $this->l10n_prefix).'"'.$blogname.'" (ID: '.$blog_id.'), '.get_site_url( $blog_id ).', '. __('changed reading visibility setting to ', $this->l10n_prefix) .'"'. $to_new.'"';
...@@ -204,11 +205,11 @@ class DS_More_Privacy_Options { ...@@ -204,11 +205,11 @@ class DS_More_Privacy_Options {
if ( '-3' == $blog_public ) { if ( '-3' == $blog_public ) {
return __('Site Admins Only(-3)', $this->l10n_prefix); return __('Site Admins Only(-3)', $this->l10n_prefix);
} }
} }
function do_robots() { function do_robots() {
//https://wordpress.org/support/topic/robotstxt-too-restrictive-for-allow-search-engines/ //https://wordpress.org/support/topic/robotstxt-too-restrictive-for-allow-search-engines/
remove_action('do_robots', 'do_robots'); remove_action('do_robots', 'do_robots');
header( 'Content-Type: text/plain; charset=utf-8' ); header( 'Content-Type: text/plain; charset=utf-8' );
...@@ -226,7 +227,7 @@ class DS_More_Privacy_Options { ...@@ -226,7 +227,7 @@ class DS_More_Privacy_Options {
} }
echo apply_filters('robots_txt', $output, $public); echo apply_filters('robots_txt', $output, $public);
} }
function noindex() { function noindex() {
remove_action( 'login_head', 'noindex' ); remove_action( 'login_head', 'noindex' );
...@@ -248,7 +249,7 @@ class DS_More_Privacy_Options { ...@@ -248,7 +249,7 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
//---Functions hooked into site_settings.php---------------------------------// //---Functions hooked into site_settings.php---------------------------------//
function wpmu_blogs_add_privacy_options() { function wpmu_blogs_add_privacy_options() {
global $details,$options; global $details,$options;
?> ?>
<tr> <tr>
...@@ -256,7 +257,7 @@ class DS_More_Privacy_Options { ...@@ -256,7 +257,7 @@ class DS_More_Privacy_Options {
<td> <td>
<input type='radio' name='option[blog_public]' value='1' <?php if( $details->public == '1' ) echo " checked"?>> <?php _e('Visible(1)', $this->l10n_prefix) ?> <input type='radio' name='option[blog_public]' value='1' <?php if( $details->public == '1' ) echo " checked"?>> <?php _e('Visible(1)', $this->l10n_prefix) ?>
<br /> <br />
<input type='radio' name='option[blog_public]' value='0' <?php if( $details->public == '0' ) echo " checked"?>> <?php _e('No Search(0)', $this->l10n_prefix) ?> <input type='radio' name='option[blog_public]' value='0' <?php if( $details->public == '0' ) echo " checked"?>> <?php _e('No Search(0)', $this->l10n_prefix) ?>
<br /> <br />
<input type='radio' name='option[blog_public]' value='-1' <?php if( $details->public == '-1' ) echo " checked"?>> <?php _e('Network Users Only(-1)', $this->l10n_prefix) ?> <input type='radio' name='option[blog_public]' value='-1' <?php if( $details->public == '-1' ) echo " checked"?>> <?php _e('Network Users Only(-1)', $this->l10n_prefix) ?>
<br /> <br />
...@@ -320,8 +321,8 @@ class DS_More_Privacy_Options { ...@@ -320,8 +321,8 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
//---Functions hooked into blog visibility selector(options-reading.php)-----// //---Functions hooked into blog visibility selector(options-reading.php)-----//
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
function add_privacy_options($options) { function add_privacy_options($options) {
global $blogname,$current_site; global $blogname,$current_site;
$blog_name = get_bloginfo('name', 'display'); $blog_name = get_bloginfo('name', 'display');
?> ?>
<label class="checkbox" for="blog-private-1"> <label class="checkbox" for="blog-private-1">
...@@ -335,7 +336,7 @@ class DS_More_Privacy_Options { ...@@ -335,7 +336,7 @@ class DS_More_Privacy_Options {
<label class="checkbox" for="blog-private-3"> <label class="checkbox" for="blog-private-3">
<input id="blog-private-3" type="radio" name="blog_public" value="-3" <?php checked('-3', get_option('blog_public')); ?> /><?php _e('Visible only to administrators of this site', $this->l10n_prefix); ?> <input id="blog-private-3" type="radio" name="blog_public" value="-3" <?php checked('-3', get_option('blog_public')); ?> /><?php _e('Visible only to administrators of this site', $this->l10n_prefix); ?>
</label> </label>
<?php <?php
} }
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
...@@ -364,11 +365,11 @@ class DS_More_Privacy_Options { ...@@ -364,11 +365,11 @@ class DS_More_Privacy_Options {
header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' ); header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' );
header( 'HTTP/1.0 401 Unauthorized' ); header( 'HTTP/1.0 401 Unauthorized' );
die(); die();
} }
} }
function ds_users_authenticator () { function ds_users_authenticator () {
if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && is_main_site()) return; if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && is_main_site()) return;
if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) { if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) {
$destination = network_home_url('wp-activate.php'); $destination = network_home_url('wp-activate.php');
wp_redirect( $destination ); wp_redirect( $destination );
...@@ -384,18 +385,18 @@ class DS_More_Privacy_Options { ...@@ -384,18 +385,18 @@ class DS_More_Privacy_Options {
} }
} }
} }
function registered_users_login_message () { function registered_users_login_message () {
global $current_site; global $current_site;
echo '<p>'; echo '<p>';
echo __('Visible only to registered users of this network', $this->l10n_prefix); echo __('Visible only to registered users of this network', $this->l10n_prefix);
echo '</p><br/>'; echo '</p><br/>';
} }
function registered_users_header_title () { function registered_users_header_title () {
return __('Visible only to registered users of this network', $this->l10n_prefix); return __('Visible only to registered users of this network', $this->l10n_prefix);
} }
function registered_users_header_link () { function registered_users_header_link () {
return __('Visible only to registered users of this network', $this->l10n_prefix); return __('Visible only to registered users of this network', $this->l10n_prefix);
} }
...@@ -445,7 +446,7 @@ class DS_More_Privacy_Options { ...@@ -445,7 +446,7 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------// //------------------------------------------------------------------------//
function ds_members_authenticator() { function ds_members_authenticator() {
global $current_user, $blog_id; global $current_user, $blog_id;
if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && is_main_site()) return; if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && is_main_site()) return;
if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) { if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) {
$destination = network_home_url('wp-activate.php'); $destination = network_home_url('wp-activate.php');
wp_redirect( $destination ); wp_redirect( $destination );
...@@ -455,7 +456,7 @@ class DS_More_Privacy_Options { ...@@ -455,7 +456,7 @@ class DS_More_Privacy_Options {
if( is_user_member_of_blog( $current_user->ID, $blog_id ) || is_super_admin() ) { if( is_user_member_of_blog( $current_user->ID, $blog_id ) || is_super_admin() ) {
return; return;
} else { } else {
if ( is_user_logged_in() ) { if ( is_user_logged_in() ) {
$this->ds_login_header(); ?> $this->ds_login_header(); ?>
<form name="loginform" id="loginform" /> <form name="loginform" id="loginform" />
<p><a href="<?php if (!is_user_logged_in()) { echo wp_login_url(); } else { echo network_home_url(); } ?>"><?php echo __('Click', $this->l10n_prefix).'</a>'. __(' to continue', $this->l10n_prefix); ?>.</p> <p><a href="<?php if (!is_user_logged_in()) { echo wp_login_url(); } else { echo network_home_url(); } ?>"><?php echo __('Click', $this->l10n_prefix).'</a>'. __(' to continue', $this->l10n_prefix); ?>.</p>
...@@ -464,19 +465,19 @@ class DS_More_Privacy_Options { ...@@ -464,19 +465,19 @@ class DS_More_Privacy_Options {
</div> </div>
</body> </body>
</html> </html>
<?php <?php
exit(); exit();
} else { } else {
if( is_feed()) { if( is_feed()) {
$this->ds_feed_login(); $this->ds_feed_login();
} else { } else {
auth_redirect(); auth_redirect();
} }
} }
} }
} }
function registered_members_login_message() { function registered_members_login_message() {
global $current_site; global $current_site;
echo '<p>'; echo '<p>';
...@@ -489,11 +490,11 @@ class DS_More_Privacy_Options { ...@@ -489,11 +490,11 @@ class DS_More_Privacy_Options {
} }
echo '</p><br/>'; echo '</p><br/>';
} }
function registered_members_header_title() { function registered_members_header_title() {
return __('Visible only to registered users of this site', $this->l10n_prefix); return __('Visible only to registered users of this site', $this->l10n_prefix);
} }
function registered_members_header_link() { function registered_members_header_link() {
return __ ('Visible only to registered users of this site', $this->l10n_prefix); return __ ('Visible only to registered users of this site', $this->l10n_prefix);
} }
...@@ -512,7 +513,7 @@ class DS_More_Privacy_Options { ...@@ -512,7 +513,7 @@ class DS_More_Privacy_Options {
if( current_user_can( 'manage_options' ) || is_super_admin() ) { if( current_user_can( 'manage_options' ) || is_super_admin() ) {
return; return;
} else { } else {
if (( is_user_logged_in() )) { if (( is_user_logged_in() )) {
$this->ds_login_header(); ?> $this->ds_login_header(); ?>
<form name="loginform" id="loginform" /> <form name="loginform" id="loginform" />
...@@ -522,7 +523,7 @@ class DS_More_Privacy_Options { ...@@ -522,7 +523,7 @@ class DS_More_Privacy_Options {
</div> </div>
</body> </body>
</html> </html>
<?php <?php
exit(); exit();
} else { } else {
if( is_feed()) { if( is_feed()) {
...@@ -533,17 +534,17 @@ class DS_More_Privacy_Options { ...@@ -533,17 +534,17 @@ class DS_More_Privacy_Options {
} }
} }
} }
function registered_admins_login_message() { function registered_admins_login_message() {
echo '<p>'; echo '<p>';
echo __('Visible only to administrators of this site', $this->l10n_prefix); echo __('Visible only to administrators of this site', $this->l10n_prefix);
echo '</p><br/>'; echo '</p><br/>';
} }
function registered_admins_header_title() { function registered_admins_header_title() {
return __('Visible only to administrators of this site', $this->l10n_prefix); return __('Visible only to administrators of this site', $this->l10n_prefix);
} }
function registered_admins_header_link() { function registered_admins_header_link() {
return __('Visible only to administrators of this site', $this->l10n_prefix); return __('Visible only to administrators of this site', $this->l10n_prefix);
} }
...@@ -559,7 +560,7 @@ class DS_More_Privacy_Options { ...@@ -559,7 +560,7 @@ class DS_More_Privacy_Options {
echo '<h3>'. __('Network Visibility Selector', $this->l10n_prefix).'</h3>'; echo '<h3>'. __('Network Visibility Selector', $this->l10n_prefix).'</h3>';
echo ' echo '
<table class="form-table"> <table class="form-table">
<tr valign="top"> <tr valign="top">
<th scope="row">' . __('Network Visibility', $this->l10n_prefix) . '</th><td>'; <th scope="row">' . __('Network Visibility', $this->l10n_prefix) . '</th><td>';
$checked = ( $number == "-1" ) ? " checked=''" : ""; $checked = ( $number == "-1" ) ? " checked=''" : "";
...@@ -572,14 +573,14 @@ class DS_More_Privacy_Options { ...@@ -572,14 +573,14 @@ class DS_More_Privacy_Options {
' . __('Default: visibility managed per site.', $this->l10n_prefix) . ' ' . __('Default: visibility managed per site.', $this->l10n_prefix) . '
</label><br />'; </label><br />';
echo '</td> echo '</td>
</tr> </tr>
</table>'; </table>';
} }
function sitewide_privacy_update() { function sitewide_privacy_update() {
update_site_option('ds_sitewide_privacy', $_POST['ds_sitewide_privacy']); update_site_option('ds_sitewide_privacy', $_POST['ds_sitewide_privacy']);
} }
} }
new DS_More_Privacy_Options(); new DS_More_Privacy_Options();
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment