Skip to content

Commit

Permalink
Version 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWinters committed Aug 23, 2019
1 parent e70c5d6 commit 634a4d5
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 108 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

# 2.0.3
**2019-08-88 - Hotfix**

* Corrected class-do-build-robotstxt.php array pairs for class-option-manager.php
* Corrected class-option-manager.php to correctly checking for array key before building the array
* Moved robotstxt build call in class-do-save-append-rules.php to fire only if the setting was updated
* Added {APPEND_WEBSITE_ROBOTSTXT} to open robots.txt file within class-do-save-preset-as-robotstxt.php

# 2.0.2
**2019-08-07 - Hotfix**

Expand Down
23 changes: 8 additions & 15 deletions inc/classes/class-do-build-robotstxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ public function init( $site_id = '' ) {

$website_option = $this->option_manager->get_option();

// Ignore If Disabled.
if ( true !== empty( $website_option['disable'] ) ) {
return;
}

$network_robotstxt_file = $this->option_manager->get_site_option();

// Return Default WordPress Robots.txt File.
Expand Down Expand Up @@ -141,17 +136,15 @@ private function replace_append_rules( $append_rules = '', $network_robotstxt )
* @param array $website_option Current Plugin Option Data.
* @param string $robotstxt_file Robots.txt File To Save.
*/
private function update_robotstxt( $website_option = [], $robotstxt_file = '' ) {
if ( true !== empty( $robotstxt_file ) ) {
// Remove Robots.txt If Set.
if ( true !== empty( $website_option['robotstxt'] ) ) {
unset( $website_option['robotstxt'] );
}

// Set Robots.txt File.
$website_option['robotstxt'] = $robotstxt_file;
private function update_robotstxt( $website_option = '', $robotstxt_file = '' ) {
if ( true === empty( $website_option ) ) {
$website_option = [];
}

$this->option_manager->update_option( $website_option );
if ( true === is_array( $website_option ) && true === array_key_exists( 'robotstxt', $website_option ) ) {
unset( $website_option['robotstxt'] );
}

$this->option_manager->update_option( array_merge( [ 'robotstxt' => $robotstxt_file ], $website_option ) );
}//end update_robotstxt()
}//end class
6 changes: 3 additions & 3 deletions inc/classes/class-do-save-append-rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ private function save_append_rules() {
// Remove Disable Marker.
$this->option_manager->delete_setting( 'disable' );

// Build Robots.txt Files.
$this->build_robotstxt->init();

if ( true === $message ) {
// Build Robots.txt Files.
$this->build_robotstxt->init();

$this->admin_notices->add_notice( 'success', 'append_success' );
}
}//end save_append_rules()
Expand Down
3 changes: 2 additions & 1 deletion inc/classes/class-do-save-preset-as-robotstxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ private function wordpress_robotstxt() {
private function open_robotstxt() {
$txt = "# robots.txt\n";
$txt .= "User-agent: *\n";
$txt .= 'Disallow:';
$txt .= "Disallow:\n";
$txt .= '{APPEND_WEBSITE_ROBOTSTXT}';

return $txt;
}
Expand Down
42 changes: 19 additions & 23 deletions inc/classes/class-option-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,15 @@ public function update_site_option( $option_value = [], $str = '' ) {
public function update_setting( $setting_name, $setting_value, $str = '' ) {
$get_option = $this->get_option( $str );

if ( true !== empty( $get_option[ $setting_name ] ) ) {
unset( $get_option[ $setting_name ] );
}

if ( true === empty( $get_option ) ) {
$get_option = [];
}

$get_option[ $setting_name ] = $setting_value;
if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) {
unset( $get_option[ $setting_name ] );
}

$this->update_option( $get_option, $str );
$this->update_option( array_merge( $get_option, [ $setting_name => $setting_value ] ), $str );
}//end update_setting()


Expand All @@ -179,17 +177,15 @@ public function update_setting( $setting_name, $setting_value, $str = '' ) {
public function update_site_setting( $setting_name, $setting_value, $str = '' ) {
$get_option = $this->get_site_option( $str );

if ( true !== empty( $get_option[ $setting_name ] ) ) {
unset( $get_option[ $setting_name ] );
}

if ( true === empty( $get_option ) ) {
$get_option = [];
}

$get_option[ $setting_name ] = $setting_value;
if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) {
unset( $get_option[ $setting_name ] );
}

$this->update_site_option( $get_option, $str );
$this->update_site_option( array_merge( $get_option, [ $setting_name => $setting_value ] ), $str );
}//end update_site_setting()


Expand Down Expand Up @@ -248,19 +244,19 @@ public function delete_setting( $setting_name = '', $str = '' ) {

$get_option = $this->get_option( $str );

if ( true === isset( $get_option[ $setting_name ] ) || true !== empty( $get_option[ $setting_name ] ) ) {
if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) {
unset( $get_option[ $setting_name ] );
}

if ( true !== empty( $get_option ) ) {
/*
* Update the value of an option that was already added.
* https://developer.wordpress.org/reference/functions/update_option/
*/
update_option(
MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str,
$get_option
);
if ( true !== empty( $get_option ) ) {
/*
* Update the value of an option that was already added.
* https://developer.wordpress.org/reference/functions/update_option/
*/
update_option(
MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str,
$get_option
);
}
}

if ( true === empty( $get_option ) ) {
Expand Down
18 changes: 18 additions & 0 deletions inc/classes/class-robotstxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public function __construct() {
* Display Robots.txt File
*/
private function robotstxt() {
/*
* If Multisite is enabled.
* https://developer.wordpress.org/reference/functions/is_multisite/
*/
if ( true === is_multisite() ) {
/*
* Retrieve the current site ID.
* https://developer.wordpress.org/reference/functions/get_current_blog_id/
*/
$site_id = get_current_blog_id();

/*
* Switch the current blog.
* https://developer.wordpress.org/reference/functions/switch_to_blog/
*/
switch_to_blog( $site_id );
}

/*
* Retrieves an option value based on an option name.
* https://developer.wordpress.org/reference/functions/get_option/
Expand Down
15 changes: 15 additions & 0 deletions inc/templates/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@
</div></div> <!-- end inside-pad & inside -->
</div> <!-- end postbox -->

<div class="postbox">
<div class="h5 p-1 font-weight-bold"><?php esc_html_e( 'Notice', 'multisite-robotstxt-manager' ); ?>:</div>
<div class="inside" style="clear:both;padding-top:1px;"><div class="para">

<?php esc_html_e( 'Please report any issues, bugs, or problems you have - your help is greatly appreciated.', 'multisite-robotstxt-manager' ); ?>

<ul>
<li><a href="<?php echo esc_url( network_site_url( 'wp-admin/network' ) ); ?>/settings.php?page=multisite-robotstxt-manager-contact"><?php esc_html_e( 'Direct Email', 'multisite-robotstxt-manager' ); ?></a></li>
<li><a href="https://github.com/ChrisWinters/multisite-robotstxt-manager/issues" target="_blank"><?php esc_html_e( 'Github Issues', 'multisite-robotstxt-manager' ); ?></a></li>
<li><a href="https://wordpress.org/support/plugin/multisite-robotstxt-manager/" target="_blank"><?php esc_html_e( 'WordPress Forum', 'multisite-robotstxt-manager' ); ?></a></li>
</ul>

</div></div> <!-- end inside-pad & inside -->
</div> <!-- end postbox -->

<?php if ( msrtm_fs()->is_not_paying() ) { ?>
<p><a href="<?php echo esc_url( network_site_url( 'wp-admin/network' ) ); ?>/settings.php?page=multisite-robotstxt-manager-pricing"><img src="<?php echo esc_url( plugin_dir_url( MS_ROBOTSTXT_MANAGER_FILE ) ); ?>/assets/images/sidebar_pro-plugin.gif" alt="<?php esc_html_e( 'Pro Automation Plugin!', 'multisite-robotstxt-manager' ); ?>" /></a></p>
<?php } ?>
Expand Down
68 changes: 42 additions & 26 deletions lang/multisite-robotstxt-manager.pot
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ msgstr ""
msgid "Robots.txt Manager"
msgstr ""

#: inc/classes/class-plugin-admin.php:198
#: inc/classes/class-plugin-admin.php:199
msgid "Settings"
msgstr ""

#: inc/classes/class-plugin-admin.php:210
#: inc/classes/class-plugin-admin.php:211
msgid "Network"
msgstr ""

#: inc/classes/class-plugin-admin.php:211
#: inc/classes/class-plugin-admin.php:212
msgid "Cleaner"
msgstr ""

Expand Down Expand Up @@ -248,59 +248,59 @@ msgstr ""
msgid "Dismiss"
msgstr ""

#: inc/templates/settings.php:47
#: inc/templates/settings.php:48
msgid "WARNING"
msgstr ""

#: inc/templates/settings.php:47
#: inc/templates/settings.php:48
msgid "The Default WordPress Robots.txt File Is Current Displaying! Update the append rules to enable the robots.txt manager for this website."
msgstr ""

#: inc/templates/settings.php:54
#: inc/templates/settings.php:55
msgid "Robots.txt Custom Append Rules"
msgstr ""

#: inc/templates/settings.php:55
#: inc/templates/settings.php:56
msgid "The custom append rules below will replace the {APPEND_WEBSITE_ROBOTSTXT} marker from the network robots.txt file, potentially creating a unique robots.txt file for this website."
msgstr ""

#: inc/templates/settings.php:55
#: inc/templates/settings.php:56
msgid "View robots.txt file"
msgstr ""

#: inc/templates/settings.php:66
#: inc/templates/settings.php:67
msgid "update append rules"
msgstr ""

#: inc/templates/settings.php:72
#: inc/templates/settings.php:73
msgid "Manual Rule Suggestions"
msgstr ""

#: inc/templates/settings.php:73
#: inc/templates/settings.php:74
msgid "The rules below will need to be manually added to the end of the robots.txt file."
msgstr ""

#: inc/templates/settings.php:77
#: inc/templates/settings.php:78
msgid "Upload Path"
msgstr ""

#: inc/templates/settings.php:81
#: inc/templates/settings.php:82
msgid "Theme Path"
msgstr ""

#: inc/templates/settings.php:85
#: inc/templates/settings.php:86
msgid "Sitemap URL"
msgstr ""

#: inc/templates/settings.php:99
#: inc/templates/settings.php:100
msgid "Live Robots.txt File"
msgstr ""

#: inc/templates/settings.php:116
#: inc/templates/settings.php:117
msgid "Current Network Robots.txt File"
msgstr ""

#: inc/templates/settings.php:146
#: inc/templates/settings.php:147
msgid "Restore the default WordPress robots.txt file on this website."
msgstr ""

Expand All @@ -320,7 +320,7 @@ msgstr ""
msgid "Contact Support"
msgstr ""

#: inc/templates/sidebar.php:54
#: inc/templates/sidebar.php:54, inc/templates/sidebar.php:70
msgid "WordPress Forum"
msgstr ""

Expand All @@ -333,39 +333,55 @@ msgid "Bugs & Feature Requests"
msgstr ""

#: inc/templates/sidebar.php:62
msgid "Pro Automation Plugin!"
msgid "Notice"
msgstr ""

#: inc/templates/sidebar.php:65
msgid "Please Rate This Plugin At Wordpress.org!"
msgid "Please report any issues, bugs, or problems you have - your help is greatly appreciated."
msgstr ""

#: inc/templates/sidebar.php:68
msgid "Direct Email"
msgstr ""

#: inc/templates/sidebar.php:69
msgid "Github Issues"
msgstr ""

#: inc/templates/sidebar.php:77
msgid "Pro Automation Plugin!"
msgstr ""

#: inc/templates/sidebar.php:80
msgid "Please Rate This Plugin At Wordpress.org!"
msgstr ""

#: inc/templates/sidebar.php:83
msgid "Robots.txt Help"
msgstr ""

#: inc/templates/sidebar.php:72
#: inc/templates/sidebar.php:87
msgid "Robots.txt Optimization Tips"
msgstr ""

#: inc/templates/sidebar.php:73
#: inc/templates/sidebar.php:88
msgid "AskAapche Robots.txt Example"
msgstr ""

#: inc/templates/sidebar.php:74
#: inc/templates/sidebar.php:89
msgid "Google Robots.txt F.A.Q."
msgstr ""

#: inc/templates/sidebar.php:75
#: inc/templates/sidebar.php:90
msgid "Robots.txt Specifications"
msgstr ""

#: inc/templates/sidebar.php:76
#: inc/templates/sidebar.php:91
msgid "Web Robots Database"
msgstr ""

#: inc/templates/upgrade.php:53
msgid "Notice! Plugin setting migration upgrade avaiable. Click the Migrate button below to maybe migrate old settings over, or click the dismiss button to ignore and remove this message."
msgid "Notice! - Possible Setting Migration Needed! NEW INSTALLS CAN DISMISS THIS NOTICE! Click the Migrate button below to maybe migrate old plugin settings to the new format, or click the dismiss button to ignore and remove this message. (This message will be removed in the next major version release.)"
msgstr ""

#: inc/templates/upgrade.php:56
Expand Down
4 changes: 2 additions & 2 deletions multisite-robotstxt-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://github.com/ChrisWinters/multisite-robotstxt-manager
* Description: A Multisite Network Robots.txt Manager. Quickly manage your Network Websites robots.txt files from a single administration area.
* Tags: robotstxt, robots.txt, robots, robot, spiders, virtual, search, google, seo, plugin, network, wpmu, multisite, technerdia, tribalnerd
* Version: 2.0.2
* Version: 2.0.3
* License: GNU GPLv3
* Copyright (c) 2017-2019 Chris Winters
* Author: tribalNerd, Chris Winters
Expand All @@ -26,7 +26,7 @@

define( 'MS_ROBOTSTXT_MANAGER_DIR', __DIR__ );
define( 'MS_ROBOTSTXT_MANAGER_FILE', __FILE__ );
define( 'MS_ROBOTSTXT_MANAGER_VERSION', '2.0.2' );
define( 'MS_ROBOTSTXT_MANAGER_VERSION', '2.0.3' );
define( 'MS_ROBOTSTXT_MANAGER_PLUGIN_DIR', dirname( __FILE__ ) );
define( 'MS_ROBOTSTXT_MANAGER_PLUGIN_NAME', 'multisite-robotstxt-manager' );
define( 'MS_ROBOTSTXT_MANAGER_SETTING_PREFIX', 'multisite-robotstxt_manager_' );
Expand Down
Loading

0 comments on commit 634a4d5

Please sign in to comment.