Commit c1556448 authored by lucha's avatar lucha

removed send mail on privacy setting change

parent 7f778ce7
......@@ -26,10 +26,10 @@ To allow everyone who is on-campus into the blog, while requiring those off-camp
Such as this:
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 {
// user is either not logged in or at campus
// user is either not logged in or at campus
if( is_feed() ) {
...
......@@ -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.
// 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.
// if( strpos($_SERVER['PHP_SELF'], 'wp-activate.php') && !is_main_site()) {
// $destination = network_home_url('wp-activate.php');
// wp_redirect( $destination );
......@@ -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.
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 {
function __construct() {
global $current_blog;
if ( ! is_multisite() ) {
add_action( 'all_admin_notices', array( $this, 'display_not_multisite_notice' ) );
return false;
}
$this->l10n_prefix = 'more-privacy-options';
//------------------------------------------------------------------------//
......@@ -110,7 +110,7 @@ class DS_More_Privacy_Options {
// Network->Settings
add_action( 'update_wpmu_options', array($this, 'sitewide_privacy_update'));
add_action( 'wpmu_options', array($this, 'sitewide_privacy_options_page'));
// hooks into Misc Blog Actions in Network->Sites->Edit
add_action('wpmueditblogaction', array($this, 'wpmu_blogs_add_privacy_options'),-999);
// hooks into Blog Columns views Network->Sites
......@@ -124,18 +124,18 @@ class DS_More_Privacy_Options {
$number = intval(get_site_option('ds_sitewide_privacy'));
if (( '-1' == $current_blog->public ) || ($number == '-1')) {
//wp_is_mobile() ? is send_headers or template_redirect better for mobiles?
add_action('template_redirect', 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_text', array($this, 'registered_users_header_link') );
}
if ( '-2' == $current_blog->public ) {
add_action('template_redirect', 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_text', array($this, 'registered_members_header_link') );
......@@ -148,7 +148,7 @@ class DS_More_Privacy_Options {
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);
// fixes noindex meta as well
......@@ -158,26 +158,27 @@ class DS_More_Privacy_Options {
//no pings unless public either
add_filter('option_ping_sites', array($this, 'privacy_ping_filter'),1);
//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?
add_action('signup_blogform', array($this, 'add_privacy_options'));
}
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>';
}
function ds_localization_init() {
load_plugin_textdomain( $this->l10n_prefix, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/');
}
function ds_mail_super_admin() {
return;
global $blog_id;
$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');
$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.'"';
......@@ -204,11 +205,11 @@ class DS_More_Privacy_Options {
if ( '-3' == $blog_public ) {
return __('Site Admins Only(-3)', $this->l10n_prefix);
}
}
}
function do_robots() {
//https://wordpress.org/support/topic/robotstxt-too-restrictive-for-allow-search-engines/
remove_action('do_robots', 'do_robots');
header( 'Content-Type: text/plain; charset=utf-8' );
......@@ -226,7 +227,7 @@ class DS_More_Privacy_Options {
}
echo apply_filters('robots_txt', $output, $public);
}
}
function noindex() {
remove_action( 'login_head', 'noindex' );
......@@ -248,7 +249,7 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------//
//---Functions hooked into site_settings.php---------------------------------//
function wpmu_blogs_add_privacy_options() {
function wpmu_blogs_add_privacy_options() {
global $details,$options;
?>
<tr>
......@@ -256,7 +257,7 @@ class DS_More_Privacy_Options {
<td>
<input type='radio' name='option[blog_public]' value='1' <?php if( $details->public == '1' ) echo " checked"?>> <?php _e('Visible(1)', $this->l10n_prefix) ?>
<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 />
<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 />
......@@ -320,8 +321,8 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------//
//---Functions hooked into blog visibility selector(options-reading.php)-----//
//------------------------------------------------------------------------//
function add_privacy_options($options) {
global $blogname,$current_site;
function add_privacy_options($options) {
global $blogname,$current_site;
$blog_name = get_bloginfo('name', 'display');
?>
<label class="checkbox" for="blog-private-1">
......@@ -335,7 +336,7 @@ class DS_More_Privacy_Options {
<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); ?>
</label>
<?php
<?php
}
//------------------------------------------------------------------------//
......@@ -364,11 +365,11 @@ class DS_More_Privacy_Options {
header( 'WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"' );
header( 'HTTP/1.0 401 Unauthorized' );
die();
}
}
}
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()) {
$destination = network_home_url('wp-activate.php');
wp_redirect( $destination );
......@@ -384,18 +385,18 @@ class DS_More_Privacy_Options {
}
}
}
function registered_users_login_message () {
global $current_site;
echo '<p>';
echo __('Visible only to registered users of this network', $this->l10n_prefix);
echo '</p><br/>';
}
function registered_users_header_title () {
return __('Visible only to registered users of this network', $this->l10n_prefix);
}
function registered_users_header_link () {
return __('Visible only to registered users of this network', $this->l10n_prefix);
}
......@@ -445,7 +446,7 @@ class DS_More_Privacy_Options {
//------------------------------------------------------------------------//
function ds_members_authenticator() {
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()) {
$destination = network_home_url('wp-activate.php');
wp_redirect( $destination );
......@@ -455,7 +456,7 @@ class DS_More_Privacy_Options {
if( is_user_member_of_blog( $current_user->ID, $blog_id ) || is_super_admin() ) {
return;
} else {
if ( is_user_logged_in() ) {
if ( is_user_logged_in() ) {
$this->ds_login_header(); ?>
<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>
......@@ -464,19 +465,19 @@ class DS_More_Privacy_Options {
</div>
</body>
</html>
<?php
<?php
exit();
} else {
if( is_feed()) {
$this->ds_feed_login();
} else {
auth_redirect();
}
}
}
}
function registered_members_login_message() {
global $current_site;
echo '<p>';
......@@ -489,11 +490,11 @@ class DS_More_Privacy_Options {
}
echo '</p><br/>';
}
function registered_members_header_title() {
return __('Visible only to registered users of this site', $this->l10n_prefix);
}
function registered_members_header_link() {
return __ ('Visible only to registered users of this site', $this->l10n_prefix);
}
......@@ -512,7 +513,7 @@ class DS_More_Privacy_Options {
if( current_user_can( 'manage_options' ) || is_super_admin() ) {
return;
} else {
if (( is_user_logged_in() )) {
$this->ds_login_header(); ?>
<form name="loginform" id="loginform" />
......@@ -522,7 +523,7 @@ class DS_More_Privacy_Options {
</div>
</body>
</html>
<?php
<?php
exit();
} else {
if( is_feed()) {
......@@ -533,17 +534,17 @@ class DS_More_Privacy_Options {
}
}
}
function registered_admins_login_message() {
echo '<p>';
echo __('Visible only to administrators of this site', $this->l10n_prefix);
echo '</p><br/>';
}
}
function registered_admins_header_title() {
return __('Visible only to administrators of this site', $this->l10n_prefix);
}
function registered_admins_header_link() {
return __('Visible only to administrators of this site', $this->l10n_prefix);
}
......@@ -559,7 +560,7 @@ class DS_More_Privacy_Options {
echo '<h3>'. __('Network Visibility Selector', $this->l10n_prefix).'</h3>';
echo '
<table class="form-table">
<tr valign="top">
<tr valign="top">
<th scope="row">' . __('Network Visibility', $this->l10n_prefix) . '</th><td>';
$checked = ( $number == "-1" ) ? " checked=''" : "";
......@@ -572,14 +573,14 @@ class DS_More_Privacy_Options {
' . __('Default: visibility managed per site.', $this->l10n_prefix) . '
</label><br />';
echo '</td>
echo '</td>
</tr>
</table>';
</table>';
}
function sitewide_privacy_update() {
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment