From 634a4d557c8c5e4bf811991195d6e685a0fc6fa7 Mon Sep 17 00:00:00 2001 From: ChrisWinters Date: Fri, 23 Aug 2019 07:43:17 -0400 Subject: [PATCH] Version 2.0.3 --- CHANGELOG.md | 8 +++ inc/classes/class-do-build-robotstxt.php | 23 +++---- inc/classes/class-do-save-append-rules.php | 6 +- .../class-do-save-preset-as-robotstxt.php | 3 +- inc/classes/class-option-manager.php | 42 ++++++------ inc/classes/class-robotstxt.php | 18 +++++ inc/templates/sidebar.php | 15 ++++ lang/multisite-robotstxt-manager.pot | 68 ++++++++++++------- multisite-robotstxt-manager.php | 4 +- readme.txt | 8 +-- sdk/msrtm-fs.php | 68 +++++++++---------- 11 files changed, 155 insertions(+), 108 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9724aa9..e4c576c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** diff --git a/inc/classes/class-do-build-robotstxt.php b/inc/classes/class-do-build-robotstxt.php index 2849794..fa44bd8 100644 --- a/inc/classes/class-do-build-robotstxt.php +++ b/inc/classes/class-do-build-robotstxt.php @@ -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. @@ -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 diff --git a/inc/classes/class-do-save-append-rules.php b/inc/classes/class-do-save-append-rules.php index 44f22ac..7a801aa 100644 --- a/inc/classes/class-do-save-append-rules.php +++ b/inc/classes/class-do-save-append-rules.php @@ -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() diff --git a/inc/classes/class-do-save-preset-as-robotstxt.php b/inc/classes/class-do-save-preset-as-robotstxt.php index c6c9291..e15e92d 100644 --- a/inc/classes/class-do-save-preset-as-robotstxt.php +++ b/inc/classes/class-do-save-preset-as-robotstxt.php @@ -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; } diff --git a/inc/classes/class-option-manager.php b/inc/classes/class-option-manager.php index 7789ff5..94e1657 100644 --- a/inc/classes/class-option-manager.php +++ b/inc/classes/class-option-manager.php @@ -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() @@ -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() @@ -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 ) ) { diff --git a/inc/classes/class-robotstxt.php b/inc/classes/class-robotstxt.php index 3616199..df62b11 100644 --- a/inc/classes/class-robotstxt.php +++ b/inc/classes/class-robotstxt.php @@ -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/ diff --git a/inc/templates/sidebar.php b/inc/templates/sidebar.php index 608432d..ea0d148 100644 --- a/inc/templates/sidebar.php +++ b/inc/templates/sidebar.php @@ -58,6 +58,21 @@ +
+
:
+
+ + + +
    +
  • +
  • +
  • +
+ +
+
+ is_not_paying() ) { ?>

<?php esc_html_e( 'Pro Automation Plugin!', 'multisite-robotstxt-manager' ); ?>

diff --git a/lang/multisite-robotstxt-manager.pot b/lang/multisite-robotstxt-manager.pot index 696eb64..0844ffa 100644 --- a/lang/multisite-robotstxt-manager.pot +++ b/lang/multisite-robotstxt-manager.pot @@ -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 "" @@ -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 "" @@ -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 "" @@ -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 diff --git a/multisite-robotstxt-manager.php b/multisite-robotstxt-manager.php index 229671e..75a1fd1 100644 --- a/multisite-robotstxt-manager.php +++ b/multisite-robotstxt-manager.php @@ -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 @@ -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_' ); diff --git a/readme.txt b/readme.txt index 7d2ff9f..873b198 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: tribalNerd, Chris Winters, freemius Tags: robotstxt, robots.txt, robots, robot, spiders, virtual, search, google, seo, plugin, network, mu, multisite, technerdia, tribalnerd Requires at least: 3.8 Tested up to: 5.2.2 -Stable tag: 2.0.2 +Stable tag: 2.0.3 License: GNU GPLv3 License URI: https://github.com/ChrisWinters/multisite-robotstxt-manager/blob/master/LICENSE @@ -263,9 +263,9 @@ For "real" Multisite HOST Networks, use the WordPress plugin: BWP Google XML Sit == Changelog == -= 2.0.2 = -* Released: 2019-08-07 -* Changelog: https://github.com/ChrisWinters/multisite-robotstxt-manager/blob/master/CHANGELOG.md#202 += 2.0.3 = +* Released: 2019-08-22 +* Changelog: https://github.com/ChrisWinters/multisite-robotstxt-manager/blob/master/CHANGELOG.md#203 diff --git a/sdk/msrtm-fs.php b/sdk/msrtm-fs.php index 5910fe9..313c968 100644 --- a/sdk/msrtm-fs.php +++ b/sdk/msrtm-fs.php @@ -20,45 +20,45 @@ * Freemius Integration */ function msrtm_fs() { - global $msrtm_fs; + global $msrtm_fs ; - if ( false === isset( $msrtm_fs ) ) { - if ( false === defined( 'WP_FS__PRODUCT_4131_MULTISITE' ) ) { - define( 'WP_FS__PRODUCT_4131_MULTISITE', true ); - } + if ( false === isset( $msrtm_fs ) ) { + if ( false === defined( 'WP_FS__PRODUCT_4131_MULTISITE' ) ) { + define( 'WP_FS__PRODUCT_4131_MULTISITE', true ); + } - require_once dirname( MS_ROBOTSTXT_MANAGER_FILE ) . '/sdk/freemius/start.php'; + require_once dirname( MS_ROBOTSTXT_MANAGER_FILE ) . '/sdk/freemius/start.php'; - $msrtm_fs = fs_dynamic_init( - [ - 'id' => '4131', - 'slug' => 'multisite-robotstxt-manager', - 'premium_slug' => 'multisite-robotstxt-manager-pro', - 'type' => 'plugin', - 'public_key' => 'pk_fbaf5afa36f15afd0f444f9ec08e5', - 'is_premium' => false, - 'has_addons' => false, - 'has_paid_plans' => true, - 'delegation' => false, - 'has_affiliation' => 'selected', - 'is_live' => true, - 'menu' => [ - 'slug' => 'multisite-robotstxt-manager', - 'account' => true, - 'contact' => false, - 'support' => false, - 'network' => true, - 'affiliation' => false, - 'pricing' => false, - 'parent' => [ - 'slug' => 'settings.php', - ], + $msrtm_fs = fs_dynamic_init( + [ + 'id' => '4131', + 'slug' => 'multisite-robotstxt-manager', + 'premium_slug' => 'multisite-robotstxt-manager-pro', + 'type' => 'plugin', + 'public_key' => 'pk_fbaf5afa36f15afd0f444f9ec08e5', + 'is_premium' => false, + 'has_addons' => false, + 'has_paid_plans' => true, + 'delegation' => false, + 'has_affiliation' => 'selected', + 'is_live' => true, + 'menu' => [ + 'slug' => 'multisite-robotstxt-manager', + 'account' => true, + 'contact' => false, + 'support' => false, + 'network' => true, + 'affiliation' => false, + 'pricing' => false, + 'parent' => [ + 'slug' => 'settings.php', ], - ] - ); - } + ], + ] + ); + } - return $msrtm_fs; + return $msrtm_fs; }//end msrtm_fs() msrtm_fs();