├── CHANGELOG.md ├── LICENSE ├── assets ├── css │ ├── index.php │ ├── style.css │ └── style.min.css ├── examples │ ├── blocked-robots.txt │ ├── blogger-robots.txt │ ├── default-robots.txt │ ├── defaultalt-robots.txt │ ├── google-robots.txt │ ├── index.php │ ├── open-robots.txt │ └── wordpress-robots.txt ├── images │ ├── index.php │ └── sidebar_rate-plugin.gif └── index.php ├── inc ├── autoload-classes.php ├── classes │ ├── class-do-build-robotstxt.php │ ├── class-do-delete-settings.php │ ├── class-do-disable-website.php │ ├── class-do-member-robotstxt-build.php │ ├── class-do-network-robotstxt-build.php │ ├── class-do-robotstxt-cleaner.php │ ├── class-do-save-append-rules.php │ ├── class-do-save-network-robotstxt.php │ ├── class-do-save-preset-as-robotstxt.php │ ├── class-get-robotstxt-rules.php │ ├── class-msrobotstxtmanager.php │ ├── class-option-manager.php │ ├── class-plugin-activate.php │ ├── class-plugin-admin-notices.php │ ├── class-plugin-admin-post.php │ ├── class-plugin-admin.php │ ├── class-plugin-upgrade.php │ ├── class-robotstxt.php │ ├── class-trait-query-string.php │ ├── class-trait-security-check.php │ ├── class-translate.php │ └── index.php ├── index.php ├── instantiate-admin-classes.php ├── instantiate-network-classes.php ├── instantiate-public-classes.php └── templates │ ├── cleaner.php │ ├── footer.php │ ├── header.php │ ├── index.php │ ├── network.php │ ├── notice.php │ ├── settings.php │ ├── sidebar.php │ └── upgrade.php ├── index.php ├── lang ├── index.php └── multisite-robotstxt-manager.pot ├── multisite-robotstxt-manager.php └── readme.txt /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 3.1.0 4 | 5 | ### **2024-11-21- Feature** 6 | 7 | * Correct $output variable [#11](https://github.com/ChrisWinters/multisite-robotstxt-manager/pull/11) 8 | * Remove Freemius [#12](https://github.com/ChrisWinters/multisite-robotstxt-manager/pull/12) 9 | * Replace deprecated filter [#13](https://github.com/ChrisWinters/multisite-robotstxt-manager/issues/13) 10 | * WordPress 6.7.1 Tested 11 | 12 | ## 3.0.0 13 | 14 | ### **2020-04-11- Feature** 15 | 16 | * Freemius upgrade 17 | * Activation issue [#8](https://github.com/ChrisWinters/multisite-robotstxt-manager/issues/8) 18 | * WordPress 5.4 Tested 19 | 20 | ## 2.1.1 21 | 22 | ### **2020-01-11- Hotfix** 23 | 24 | * Modified how robots.txt file is generated within class-robotstxt.php 25 | 26 | ## 2.1.0 27 | 28 | ### **2019-10-06 - Feature** 29 | 30 | * Added website override option to ignore network robots.txt file 31 | 32 | ## 2.0.4 33 | 34 | ### **2019-08-28 - Hotfix** 35 | 36 | * Removed Freemius nag notice. 37 | 38 | ## 2.0.3 39 | 40 | ### **2019-08-22 - Hotfix** 41 | 42 | * Corrected class-do-build-robotstxt.php array pairs for class-option-manager.php 43 | * Corrected class-option-manager.php to correctly checking for array key before building the array 44 | * Moved robotstxt build call in class-do-save-append-rules.php to fire only if the setting was updated 45 | * Added {APPEND_WEBSITE_ROBOTSTXT} to open robots.txt file within class-do-save-preset-as-robotstxt.php 46 | 47 | ## 2.0.2 48 | 49 | ### **2019-08-07 - Hotfix** 50 | 51 | * Removed plugin-activation level upgrade in favor of manual upgrade 52 | * Moved admin/network/public class includes into plugins_loaded hook 53 | * Modified class-translate.php to use new translation call format 54 | * Modified sidebar hardcoded images to use plugin_dir_url() 55 | * Modified plugin settings upgrade message for new installs 56 | * Corrected network delete all settings to correctly delete all settings 57 | * Corrected function call in class-do-network-robotstxt-build.php 58 | * Corrected function call in class-do-robotstxt-cleaner.php 59 | * Corrected bump.js gulp task 60 | 61 | ## 2.0.1 62 | 63 | ### **2019-07-25 - Hotfix** 64 | 65 | * Created manual upgrade and delete old settings notice. 66 | 67 | ## 2.0.0 68 | 69 | ### **2019-07-22 - Release** 70 | 71 | * Tested: Wordpress Version 5.2.2 72 | * Major code base upgrade 73 | * Migrated settings to single option 74 | 75 | ## 1.0.12 76 | 77 | ### **2017-9-6 - Hotfix** 78 | 79 | * Tested: Wordpress Version 4.8 80 | * Changed: Network & Admin Area Plugin Update Notice Handler. 81 | * Fixed: Remove Rewrite Rule Flush After Correcting Rewrite Rules. 82 | 83 | ## 1.0.11 84 | 85 | ### **2017-24-4 - Hotfix** 86 | 87 | * Added: Added more Sitemap filenames to check/build for. 88 | * Changed: Sitemap check/build, added rewrite rule & physical file checks if fopen is not enabled. 89 | 90 | ## 1.0.10 91 | 92 | ### **2017-23-4 - Hotfix** 93 | 94 | * Tested: Wordpress Version 4.7.4 95 | * Changed: Review/Rating URL within templates/sidebar.php 96 | * Fixed: Cleaner option name checks, using previous version names. 97 | * Fixed: Cleaner rewrite_rule to delete/update the option when missing the robots.txt array. 98 | 99 | ## 1.0.9 100 | 101 | * Fixed: Bad method call in class-cleaner.php. 102 | * Fixed: Multiple incorrect update_option formats. 103 | * Fixed: Network Robots.txt now saves when published [#5](https://github.com/ChrisWinters/multisite-robotstxt-manager/issues/5) 104 | * Fixed: Removed append marker, if no append rules found. 105 | * Fixed: Wrapped is_writable() check to physical robots.txt removal. 106 | * Change: Option names for cleaner, appended cleaner_. 107 | * Change: Modified update success/fail messages. 108 | * Change: Deleted uninstall.php [#6](https://github.com/ChrisWinters/multisite-robotstxt-manager/issues/6) 109 | 110 | ## 1.0.8 111 | 112 | * New plugin structure/files, using the same option names. 113 | * Added: New tab "Cleaner" to the Network Admin area. 114 | * Added: Two stage cleaning process - check & clean. 115 | * Added: Check for a physical robots.txt file. 116 | * Added: Check for missing robots.txt file rewrite rule. 117 | * Added: Network tab to Websites for quick access to plugin admin within the Network. 118 | * Added: Option to disable network robots.txt file on websites, allowing for full customization of websites robots.txt file. 119 | * Change: Plugin admin areas to be more visually friendly. 120 | * Moved: Screenshots/header/thumbnail images into the svn/assets folder. 121 | 122 | ## 1.0.7 123 | 124 | * Bug: Fixed bad calls from helper class causing options not saving for each site. Thanks https://github.com/benjaminniess 125 | 126 | ## 1.0.6 127 | 128 | * Bug: Corrected class_helper->getSitemapUrl() - printing "No Sitemap Found" in robots.txt files 129 | * Bug: Moved class_admin->updateNetwork()->throwMessage() outside of foreach when updating the network 130 | * Change: templates/home.php to display No Sitemap Found within input field 131 | 132 | ## 1.0.5 133 | 134 | * Modified class_helper->getSitemapUrl(): added get_option( 'siteurl' ) check for sitemap url 135 | * Corrected commented out redirect action 136 | * Corrected marketup in robots.txt file, again. 137 | * Added final public to class_presets methods 138 | 139 | ## 1.0.4 140 | 141 | * Add options to update the full network or only blogs the admin is a user of 142 | * Added message for missing sitemap.xml files within website plugin admin 143 | * Added user notice & error message to all form actions 144 | * Corrected readme.txt file formating 145 | * Corrected notice locations for all 3 detection rules 146 | * Corrected network admin showing website admin status messages 147 | * Corrected message when updating network from disabled network 148 | * Corrected missing new line in the preset WordPress Limited option 149 | * Adjusted disable/delete input names to be code-reader friendly 150 | * Removed class_core.php, functions moved to plugin root 151 | * Commented out $rewrite_rule check/update, until new solution is found 152 | 153 | ## 1.0.3 154 | 155 | * Moved upgrade process outside of activation method, into unique class 156 | * Added message/method to detect and replace old plugin data with new data 157 | * Re-added old robots.txt plugin detection and cleaning option 158 | * Re-added bad rewrite rule detection and cleaning option 159 | 160 | ## 1.0.2 161 | 162 | * Upgrade Bug Corrected 163 | * Changed how Extention loads in 164 | * Adjusted Extension calls throughout plugin 165 | * Adjusted plugin activation order for detecting old plugin options 166 | * Corrected static function calls for register_activation_hook 167 | * Added feature to copy old sitemap url to new append option 168 | 169 | ## 1.0.1 170 | 171 | * Because SVN sucks! 172 | 173 | ## 1.0.0 174 | 175 | * Major rebuild, all files recreated, new code 176 | * Set network robots.txt file as global file 177 | * Created append rules for Websites 178 | * Improved Sitemap Detection 179 | * Added Theme & Upload Path Support 180 | * Adjusted admin area layout and look 181 | * Adjusted how Pro Extension adapts in 182 | * Expanded automation features 183 | 184 | ## 0.4.0 185 | 186 | * Major rebuild 187 | * Modified how and when the sitemap urls are created. 188 | * Created top-level domain array for sitemap url breakdown. 189 | * Removed network map checks due to alt setup methods. 190 | * Update preset robots.txt files and create 2 new styles. 191 | * Rebuilt all options to use array format. 192 | * Renamed classes and functions. 193 | * Added better sanitization and escaping throughout. 194 | * Adjusted how pro extension integrates in. 195 | * Modified admin html/css to work better for mobile. 196 | * Removed a few pounds of code. 197 | * Improved help text throughout. 198 | * Improved error checking. 199 | * Adjusted install/uninstall functions for non-network installs. 200 | * Merged network admin and website admin template. 201 | * Add old robots.txt plugin detection and cleaning option. 202 | 203 | ## 0.3.1 204 | 205 | * Created website admin areas. 206 | * Added is_user_member_of_blog function for super admins. 207 | 208 | ## 0.3.0 209 | 210 | * Modified add_submenu_page calls. 211 | * Modified DB prepare() statements. 212 | * Structure change to make room for automation feature. 213 | * Cleaned undefined index errors. 214 | * Ran PHP Debug and WP Debug and removed related errors. 215 | 216 | ## 0.2.2x 217 | 218 | * Modified add_submenu_page calls. 219 | * Modified DB prepare() statements. 220 | * Structure change to make room for automation feature. 221 | 222 | ## 0.2.1 223 | 224 | * Made robots.txt file display when a Website within a directory (domain.com/domain-path) is called. 225 | * Added is_network_admin() and $_SERVER script checks around extra links function. 226 | * Cleaned up activation & deactivation hook calls to only be called when executed. 227 | * Added do_action( 'do_robotstxt' ); call after header call of robots.txt display. 228 | * Adjusted robots.txt display to use public/private blog feature correctly. 229 | * Removed is_user_member_of_blog() check around add_submenu_page() calls. 230 | * Added $_GET['page'] :: "ms_robotstxt.php" wrap around tab display call. 231 | * Improved sitemap structure url output with various domain structures. 232 | * Added current_user_can() && is_super_admin() check to uninstall.php 233 | * Added / adjusted wp_nonce_field and check_admin_referer calls. 234 | * Created second set of tab links at the bottom of plugin admin. 235 | * Cleaned up robots.txt display class - add_filter call. 236 | * Setup better error handling on all form submits. 237 | * Added in version check and file check calls. 238 | * Improved sitemap structure function. 239 | * More comments. 240 | 241 | ## 0.2.0 242 | 243 | * Made the site dropdown list populate in a new way, and list site names insted of domains. 244 | * Added sitemap option, url, and structure to default robots.txt, per site, and pre-sets. 245 | * Adjusted all post types and preset values, and option arrays to use sitemap structure. 246 | * Adjusted default option for websites robots.txt to store data within an array. 247 | * Created a new sitemap option to store sitemap data at the Website level. 248 | * Adusted, cleaned html and corrected typos within admin area template. 249 | * Adjusted default robots.txt option to store data within an array. 250 | * Created instructions for the Sitemap URL Structure feature. 251 | * Adjusted robots.txt display to include sitemap urls. 252 | * Adjusted uninstall.php to use new option names. 253 | * Removed transient cache and related db calls. 254 | * New screenshot file and readme.txt updated. 255 | * Updated WordPress Function References. 256 | * Added non-network check on install. 257 | * Serialize proper option data. 258 | 259 | ## 0.1.1 260 | 261 | * Replaced action do_robots with filter robots_txt at call. 262 | * Removed ob_gzhandler 263 | 264 | ## 0.1 265 | 266 | * Created March 08, 2012 267 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /assets/css/index.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Register Classes 20 | * 21 | * @param string $class Loaded Classes. 22 | */ 23 | function ms_robotstxt_manager_register_classes( $class ) { 24 | // Namespace Prefix. 25 | $prefix = 'MsRobotstxtManager\\'; 26 | 27 | // Move To Next Rgistered autoloader. 28 | $len = strlen( $prefix ); 29 | if ( strncmp( $prefix, $class, $len ) !== 0 ) { 30 | return; 31 | } 32 | 33 | // Build Class Name. 34 | $relative_class = strtolower( str_replace( '_', '-', substr( $class, $len ) ) ); 35 | 36 | // Replace Dir Separators and Replace Namespace with Base Dir. 37 | $file = MS_ROBOTSTXT_MANAGER_DIR . '/inc/classes/class-' . str_replace( '\\', '/', $relative_class ) . '.php'; 38 | 39 | // Include File. 40 | if ( true === file_exists( $file ) ) { 41 | require $file; 42 | } 43 | }//end ms_robotstxt_manager_register_classes() 44 | 45 | spl_autoload_register( 'MsRobotstxtManager\ms_robotstxt_manager_register_classes' ); 46 | -------------------------------------------------------------------------------- /inc/classes/class-do-build-robotstxt.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Build Network Website Robots.txt File 20 | */ 21 | final class Do_Build_Robotstxt { 22 | /** 23 | * Option_Manager Class. 24 | * 25 | * @var object 26 | */ 27 | public $option_manager = []; 28 | 29 | 30 | /** 31 | * Setup Class 32 | * 33 | * @param object $option_manager Option_Manager. 34 | */ 35 | public function __construct( $option_manager = [] ) { 36 | if ( true === empty( $option_manager ) ) { 37 | return; 38 | } 39 | 40 | $this->option_manager = $option_manager; 41 | }//end __construct() 42 | 43 | 44 | /** 45 | * Build & Save Robots.txt File 46 | * 47 | * @param int $site_id Network Site ID. 48 | */ 49 | public function init( $site_id = '' ) { 50 | if ( true === empty( $this->option_manager ) ) { 51 | return; 52 | } 53 | 54 | $site_id = $this->get_site_id( $site_id ); 55 | 56 | if ( true !== empty( $site_id ) ) { 57 | /* 58 | * Switch the current blog. 59 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 60 | */ 61 | switch_to_blog( $site_id ); 62 | } 63 | 64 | $website_option = $this->option_manager->get_option(); 65 | 66 | $network_robotstxt_file = $this->option_manager->get_site_option(); 67 | 68 | // Return Default WordPress Robots.txt File. 69 | if ( true === empty( $network_robotstxt_file['robotstxt'] ) ) { 70 | return; 71 | } 72 | 73 | $append_rules = ( true !== empty( $website_option['append'] ) ) ? $website_option['append'] : ''; 74 | $robotstxt_file = $this->replace_append_rules( $network_robotstxt_file['robotstxt'], $append_rules ); 75 | 76 | $this->update_robotstxt( $website_option, $robotstxt_file ); 77 | 78 | if ( true !== empty( $site_id ) ) { 79 | /* 80 | * Restore the current blog, after calling switch_to_blog. 81 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 82 | */ 83 | restore_current_blog(); 84 | } 85 | }//end init() 86 | 87 | 88 | /** 89 | * Get Current Site ID 90 | * 91 | * @param int $site_id Network Site ID. 92 | * 93 | * @return int/empty 94 | */ 95 | private function get_site_id( $site_id = '' ) { 96 | /* 97 | * Whether the current request is for the network administrative interface. 98 | * https://developer.wordpress.org/reference/functions/is_network_admin/ 99 | */ 100 | if ( true === empty( $site_id ) && true !== is_network_admin() ) { 101 | /* 102 | * Retrieve the current site ID. 103 | * https://developer.wordpress.org/reference/functions/get_current_blog_id/ 104 | */ 105 | $site_id = get_current_blog_id(); 106 | } 107 | 108 | return $site_id; 109 | }//end get_site_id() 110 | 111 | 112 | /** 113 | * Maybe Replace Append Rules 114 | * 115 | * @param string $network_robotstxt Network Robots.txt File. 116 | * @param string $append_rules Website Append Rules. 117 | * 118 | * @return string 119 | */ 120 | private function replace_append_rules( $network_robotstxt, $append_rules = '' ) { 121 | if ( true !== empty( $append_rules ) ) { 122 | // Append Rules Found. 123 | $robotstxt_file = str_replace( '{APPEND_WEBSITE_ROBOTSTXT}', $append_rules, $network_robotstxt ); 124 | } else { 125 | // No Append Rules. 126 | $robotstxt_file = str_replace( '{APPEND_WEBSITE_ROBOTSTXT}', '', $network_robotstxt ); 127 | } 128 | 129 | return $robotstxt_file; 130 | }//end replace_append_rules() 131 | 132 | 133 | /** 134 | * Maybe Update Website Robots.txt File 135 | * 136 | * @param array $website_option Current Plugin Option Data. 137 | * @param string $robotstxt_file Robots.txt File To Save. 138 | */ 139 | private function update_robotstxt( $website_option = '', $robotstxt_file = '' ) { 140 | if ( true === empty( $website_option ) ) { 141 | $website_option = []; 142 | } 143 | 144 | if ( true === is_array( $website_option ) && true === array_key_exists( 'robotstxt', $website_option ) ) { 145 | unset( $website_option['robotstxt'] ); 146 | } 147 | 148 | $this->option_manager->update_option( array_merge( [ 'robotstxt' => $robotstxt_file ], $website_option ) ); 149 | }//end update_robotstxt() 150 | }//end class 151 | -------------------------------------------------------------------------------- /inc/classes/class-do-delete-settings.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Delete All Plugin Settings 24 | */ 25 | final class Do_Delete_Settings { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_object = $post_object; 68 | $this->post_action = $post_object['action']; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Set Disable Marker For Website. 103 | if ( 'delete' === $this->post_action ) { 104 | $this->do_delete(); 105 | } 106 | }//end update() 107 | 108 | 109 | /** 110 | * Init Delete 111 | */ 112 | private function do_delete() { 113 | /* 114 | * Retrieves a list of sites matching requested arguments. 115 | * https://developer.wordpress.org/reference/functions/get_sites/ 116 | */ 117 | foreach ( get_sites() as $website ) { 118 | /* 119 | * Switch the current blog. 120 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 121 | */ 122 | switch_to_blog( $website->blog_id ); 123 | 124 | $this->option_manager->delete_option(); 125 | 126 | /* 127 | * Restore the current blog, after calling switch_to_blog. 128 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 129 | */ 130 | restore_current_blog(); 131 | } 132 | 133 | $this->option_manager->delete_site_option(); 134 | 135 | if ( true === empty( $this->option_manager->get_option() ) && true === empty( $this->option_manager->get_site_option() ) ) { 136 | $this->admin_notices->add_notice( 'success', 'delete_success', 'network' ); 137 | } 138 | }//end do_delete() 139 | }//end class 140 | -------------------------------------------------------------------------------- /inc/classes/class-do-disable-website.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Set Disable Marker For Website 24 | */ 25 | final class Do_Disable_Website { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_object = $post_object; 68 | $this->post_action = $post_object['action']; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Set Disable Marker For Website. 103 | if ( 'disable' === $this->post_action ) { 104 | $this->disable_website(); 105 | } 106 | }//end update() 107 | 108 | 109 | /** 110 | * Set Disable Marker For Website 111 | */ 112 | private function disable_website() { 113 | $this->option_manager->update_setting( 'disable', true ); 114 | 115 | if ( true === $this->option_manager->get_setting( 'disable' ) ) { 116 | $this->admin_notices->add_notice( 'success', 'disable_success' ); 117 | } 118 | }//end disable_website() 119 | }//end class 120 | -------------------------------------------------------------------------------- /inc/classes/class-do-member-robotstxt-build.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Do_Build_Robotstxt as DoBuildRobotstxt; 21 | use MsRobotstxtManager\Option_Manager as OptionManager; 22 | 23 | /** 24 | * Build Robots.txt File Across All Member Sites. 25 | */ 26 | final class Do_Member_Robotstxt_Build { 27 | use TraitSecurityCheck; 28 | 29 | /** 30 | * Plugin Admin Post Object. 31 | * 32 | * @var array 33 | */ 34 | public $post_object = array(); 35 | 36 | /** 37 | * Post Action To Take. 38 | * 39 | * @var string 40 | */ 41 | public $post_action = array(); 42 | 43 | /** 44 | * Option_Manager Class. 45 | * 46 | * @var object 47 | */ 48 | public $option_manager = array(); 49 | 50 | /** 51 | * Plugin_Admin_Notices Class 52 | * 53 | * @var object 54 | */ 55 | public $admin_notices = array(); 56 | 57 | /** 58 | * Do_Build_Robotstxt Class 59 | * 60 | * @var object 61 | */ 62 | public $build_robotstxt = array(); 63 | 64 | 65 | /** 66 | * Setup Class 67 | * 68 | * @param array $post_object Cleaned Post Object. 69 | */ 70 | public function __construct( $post_object = array() ) { 71 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 72 | return; 73 | } 74 | 75 | $this->post_object = $post_object; 76 | $this->post_action = $post_object['action']; 77 | $this->option_manager = new OptionManager(); 78 | $this->admin_notices = new PluginAdminNotices(); 79 | $this->build_robotstxt = new DoBuildRobotstxt( $this->option_manager ); 80 | }//end __construct() 81 | 82 | 83 | /** 84 | * Init Update Action 85 | */ 86 | public function init() { 87 | if ( true === empty( $this->post_object ) ) { 88 | return; 89 | } 90 | 91 | /* 92 | * Fires as an admin screen or script is being initialized. 93 | * https://developer.wordpress.org/reference/hooks/admin_init/ 94 | */ 95 | add_action( 'admin_init', array( $this, 'update' ) ); 96 | }//end init() 97 | 98 | 99 | /** 100 | * Security Check & Update On Action 101 | */ 102 | public function update() { 103 | $this->security_check(); 104 | // Network Member Sites Robots.txt Build. 105 | if ( 'member' === $this->post_action ) { 106 | $this->member_robotstxt_build(); 107 | } 108 | }//end update() 109 | 110 | 111 | /** 112 | * Network Member Sites Robots.txt Build 113 | */ 114 | private function member_robotstxt_build() { 115 | if ( true === empty( $this->post_object ) || true === empty( $this->admin_notices ) ) { 116 | return; 117 | } 118 | $message = false; 119 | 120 | if ( true !== empty( $this->post_object ) && true !== empty( $this->post_object['robotstxt'] ) ) { 121 | $this->option_manager->update_site_option( 'robotstxt', $this->post_object['robotstxt'] ); 122 | $message = true; 123 | } 124 | 125 | if ( true !== empty( $this->post_object ) && true === empty( $this->post_object['robotstxt'] ) ) { 126 | $this->option_manager->delete_site_option(); 127 | $message = true; 128 | } 129 | 130 | // Current Admin User. 131 | $current_user = wp_get_current_user(); 132 | $this_admin_user = $current_user->ID; 133 | 134 | /* 135 | * Get the sites a user belongs to. 136 | * https://developer.wordpress.org/reference/functions/get_blogs_of_user/ 137 | */ 138 | $members_blogs = get_blogs_of_user( $this_admin_user ); 139 | 140 | // Update Allowed Blogs. 141 | foreach ( $members_blogs as $member ) { 142 | /* 143 | * Switch the current blog. 144 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 145 | */ 146 | switch_to_blog( $member->userblog_id ); 147 | // Build Robots.txt Files. 148 | $this->build_robotstxt->init( $member->userblog_id ); 149 | 150 | /* 151 | * Restore the current blog, after calling switch_to_blog. 152 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 153 | */ 154 | restore_current_blog(); 155 | } 156 | 157 | if ( true === $message ) { 158 | $this->admin_notices->add_notice( 'success', 'member_updated', 'network' ); 159 | } 160 | } 161 | }//end class 162 | -------------------------------------------------------------------------------- /inc/classes/class-do-network-robotstxt-build.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Do_Build_Robotstxt as DoBuildRobotstxt; 21 | use MsRobotstxtManager\Option_Manager as OptionManager; 22 | 23 | /** 24 | * Build Robots.txt File Across All Network Sites. 25 | */ 26 | final class Do_Network_Robotstxt_Build { 27 | use TraitSecurityCheck; 28 | 29 | /** 30 | * Plugin Admin Post Object. 31 | * 32 | * @var array 33 | */ 34 | public $post_object = array(); 35 | 36 | /** 37 | * Post Action To Take. 38 | * 39 | * @var string 40 | */ 41 | public $post_action = array(); 42 | 43 | /** 44 | * Option_Manager Class. 45 | * 46 | * @var object 47 | */ 48 | public $option_manager = array(); 49 | 50 | /** 51 | * Plugin_Admin_Notices Class 52 | * 53 | * @var object 54 | */ 55 | public $admin_notices = array(); 56 | 57 | /** 58 | * Do_Build_Robotstxt Class 59 | * 60 | * @var object 61 | */ 62 | public $build_robotstxt = array(); 63 | 64 | 65 | /** 66 | * Setup Class 67 | * 68 | * @param array $post_object Cleaned Post Object. 69 | */ 70 | public function __construct( $post_object = array() ) { 71 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 72 | return; 73 | } 74 | 75 | $this->post_object = $post_object; 76 | $this->post_action = $post_object['action']; 77 | $this->option_manager = new OptionManager(); 78 | $this->admin_notices = new PluginAdminNotices(); 79 | $this->build_robotstxt = new DoBuildRobotstxt( $this->option_manager ); 80 | }//end __construct() 81 | 82 | 83 | /** 84 | * Init Update Action 85 | */ 86 | public function init() { 87 | if ( true === empty( $this->post_object ) ) { 88 | return; 89 | } 90 | 91 | /* 92 | * Fires as an admin screen or script is being initialized. 93 | * https://developer.wordpress.org/reference/hooks/admin_init/ 94 | */ 95 | add_action( 'admin_init', array( $this, 'update' ) ); 96 | }//end init() 97 | 98 | 99 | /** 100 | * Security Check & Update On Action 101 | */ 102 | public function update() { 103 | $this->security_check(); 104 | 105 | // All Network Sites Robots.txt Builds. 106 | if ( 'network' === $this->post_action ) { 107 | $this->network_robosttxt_build(); 108 | } 109 | }//end update() 110 | 111 | 112 | /** 113 | * All Network Sites Robots.txt Builds 114 | */ 115 | private function network_robosttxt_build() { 116 | if ( true === empty( $this->post_object ) || true === empty( $this->admin_notices ) ) { 117 | return; 118 | } 119 | 120 | $message = false; 121 | 122 | if ( true !== empty( $this->post_object ) && true !== empty( $this->post_object['robotstxt'] ) ) { 123 | $this->option_manager->update_site_option( 'robotstxt', $this->post_object['robotstxt'] ); 124 | $message = true; 125 | } 126 | 127 | if ( true !== empty( $this->post_object ) && true === empty( $this->post_object['robotstxt'] ) ) { 128 | $this->option_manager->delete_site_option(); 129 | $message = true; 130 | } 131 | 132 | /* 133 | * Retrieves a list of sites matching requested arguments. 134 | * https://developer.wordpress.org/reference/functions/get_sites/ 135 | */ 136 | foreach ( get_sites() as $website ) { 137 | /* 138 | * Switch the current blog. 139 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 140 | */ 141 | switch_to_blog( $website->blog_id ); 142 | 143 | // Build Robots.txt Files. 144 | $this->build_robotstxt->init( $website->blog_id ); 145 | 146 | /* 147 | * Restore the current blog, after calling switch_to_blog. 148 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 149 | */ 150 | restore_current_blog(); 151 | } 152 | 153 | if ( true === $message ) { 154 | $this->admin_notices->add_notice( 'success', 'network_updated', 'network' ); 155 | } 156 | } 157 | }//end class 158 | -------------------------------------------------------------------------------- /inc/classes/class-do-robotstxt-cleaner.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Robots.txt Cleaner Rules & Actions 24 | */ 25 | final class Do_Robotstxt_Cleaner { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_object = $post_object; 68 | $this->post_action = $post_object['action']; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Init Cleaner. 103 | if ( 'cleaner' === $this->post_action ) { 104 | $this->cleaner(); 105 | } 106 | }//end update() 107 | 108 | 109 | /** 110 | * Init Cleaner 111 | */ 112 | private function cleaner() { 113 | if ( true === empty( $this->post_object ) || true === empty( $this->admin_notices ) ) { 114 | return; 115 | } 116 | 117 | if ( true !== empty( $this->post_object['check-data'] ) ) { 118 | $this->checkdata(); 119 | } 120 | 121 | if ( true !== empty( $this->post_object['clean-data'] ) ) { 122 | $this->cleandata(); 123 | } 124 | 125 | if ( true !== empty( $this->post_object['check-physical'] ) ) { 126 | $this->checkphysical(); 127 | } 128 | 129 | if ( true !== empty( $this->post_object['clean-physical'] ) ) { 130 | $this->cleanphysical(); 131 | } 132 | 133 | if ( true !== empty( $this->post_object['check-rewrite'] ) ) { 134 | $this->checkrewrite(); 135 | } 136 | 137 | if ( true !== empty( $this->post_object['add-rewrite'] ) ) { 138 | $this->addrewrite(); 139 | } 140 | }//end cleaner() 141 | 142 | 143 | /** 144 | * Check For Old Plugin Data 145 | */ 146 | private function checkdata() { 147 | $message = false; 148 | 149 | // Old Data Found, Set Marker. 150 | if ( get_option( 'pc_robotstxt' ) || get_option( 'kb_robotstxt' ) || get_option( 'cd_rdte_content' ) ) { 151 | $this->option_manager->update_option( [ 'checkdata' => 'error' ] ); 152 | $message = true; 153 | } else { 154 | $this->option_manager->delete_setting( 'checkdata' ); 155 | } 156 | 157 | if ( true === $message ) { 158 | $this->admin_notices->add_notice( 'success', 'checkdata_notice', 'network' ); 159 | } else { 160 | $this->admin_notices->add_notice( 'error', 'checkdata_done', 'network' ); 161 | } 162 | } 163 | 164 | 165 | /** 166 | * Remove Old Plugin Data 167 | */ 168 | private function cleandata() { 169 | // Remove Options. 170 | delete_option( 'pc_robotstxt' ); 171 | delete_option( 'kb_robotstxt' ); 172 | delete_option( 'cd_rdte_content' ); 173 | 174 | // Remove Filters. 175 | remove_filter( 'robots_txt', 'cd_rdte_filter_robots' ); 176 | remove_filter( 'robots_txt', 'ljpl_filter_robots_txt' ); 177 | remove_filter( 'robots_txt', 'robots_txt_filter' ); 178 | 179 | // Run Check Again. 180 | $this->checkData(); 181 | } 182 | 183 | 184 | /** 185 | * Check For Phsyical Robots.txt File 186 | */ 187 | private function checkphysical() { 188 | $message = false; 189 | 190 | // Robots.txt File Found. 191 | if ( true === file_exists( get_home_path() . 'robots.txt' ) ) { 192 | $this->option_manager->update_option( [ 'checkphysical' => 'error' ] ); 193 | $message = true; 194 | } else { 195 | $this->option_manager->delete_setting( 'checkphysical' ); 196 | } 197 | 198 | if ( true === $message ) { 199 | $this->admin_notices->add_notice( 'success', 'checkphysical_notice', 'network' ); 200 | } else { 201 | $this->admin_notices->add_notice( 'error', 'checkphysical_done', 'network' ); 202 | } 203 | } 204 | 205 | 206 | /** 207 | * Remove Physical Robots.txt File 208 | */ 209 | private function cleanphysical() { 210 | // Remove Robots.txt File. 211 | if ( true === file_exists( get_home_path() . 'robots.txt' ) && true === is_writable( get_home_path() . 'robots.txt' ) ) { 212 | unlink( realpath( get_home_path() . 'robots.txt' ) ); 213 | } 214 | 215 | // Robots.txt File Found. 216 | if ( true === file_exists( get_home_path() . 'robots.txt' ) ) { 217 | $this->option_manager->delete_setting( 'checkphysical' ); 218 | $this->admin_notices->add_notice( 'error', 'checkphysical_error', 'network' ); 219 | } else { 220 | $this->checkphysical(); 221 | } 222 | } 223 | 224 | 225 | /** 226 | * Check For Missing Rewrite Rules 227 | */ 228 | private function checkrewrite() { 229 | $message = false; 230 | 231 | // Get Rewrite Rules. 232 | $rules = get_option( 'rewrite_rules' ); 233 | 234 | // Flush Rules If Needed. 235 | if ( empty( $rules ) ) { 236 | flush_rewrite_rules(); 237 | } 238 | 239 | // Error No Rewrite Rule Found, Set Marker. 240 | if ( true !== in_array( 'index.php?robots=1', (array) $rules, true ) ) { 241 | $this->option_manager->update_option( [ 'checkrewrite' => 'error' ] ); 242 | $message = true; 243 | } else { 244 | $this->option_manager->delete_setting( 'checkrewrite' ); 245 | } 246 | 247 | if ( true === $message ) { 248 | $this->admin_notices->add_notice( 'success', 'checkrewrite_notice', 'network' ); 249 | } else { 250 | $this->admin_notices->add_notice( 'success', 'checkrewrite_done', 'network' ); 251 | } 252 | } 253 | 254 | 255 | /** 256 | * Add Missing Rewrite Rule 257 | */ 258 | private function addrewrite() { 259 | // Get Rewrite Rules. 260 | $rules = get_option( 'rewrite_rules' ); 261 | 262 | // Add Missing Rule. 263 | if ( true !== in_array( 'index.php?robots=1', (array) $rules, true ) ) { 264 | // Set Proper Keys. 265 | $rule_key = 'robots\.txt$'; 266 | $rules[ $rule_key ] = 'index.php?robots=1'; 267 | 268 | // Update Rules. 269 | update_option( 'rewrite_rules', $rules ); 270 | 271 | // Flush Rules. 272 | flush_rewrite_rules(); 273 | } 274 | 275 | // Recheck Rewrite Rules. 276 | $this->checkRewrite(); 277 | } 278 | }//end class 279 | -------------------------------------------------------------------------------- /inc/classes/class-do-save-append-rules.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Do_Build_Robotstxt as DoBuildRobotstxt; 21 | use MsRobotstxtManager\Option_Manager as OptionManager; 22 | 23 | /** 24 | * Update Website Append Rules 25 | */ 26 | final class Do_Save_Append_Rules { 27 | use TraitSecurityCheck; 28 | 29 | /** 30 | * Plugin Admin Post Object. 31 | * 32 | * @var array 33 | */ 34 | public $post_object = []; 35 | 36 | /** 37 | * Post Action To Take. 38 | * 39 | * @var string 40 | */ 41 | public $post_action = []; 42 | 43 | /** 44 | * Option_Manager Class. 45 | * 46 | * @var object 47 | */ 48 | public $option_manager = []; 49 | 50 | /** 51 | * Plugin_Admin_Notices Class 52 | * 53 | * @var object 54 | */ 55 | public $admin_notices = []; 56 | 57 | /** 58 | * Do_Build_Robotstx Object. 59 | * 60 | * @var object 61 | */ 62 | public $build_robotstxt = []; 63 | 64 | 65 | /** 66 | * Setup Class 67 | * 68 | * @param array $post_object Cleaned Post Object. 69 | */ 70 | public function __construct( $post_object = [] ) { 71 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 72 | return; 73 | } 74 | 75 | $this->post_object = $post_object; 76 | $this->post_action = $post_object['action']; 77 | $this->option_manager = new OptionManager(); 78 | $this->admin_notices = new PluginAdminNotices(); 79 | $this->build_robotstxt = new DoBuildRobotstxt( $this->option_manager ); 80 | }//end __construct() 81 | 82 | 83 | /** 84 | * Init Update Action 85 | */ 86 | public function init() { 87 | if ( true === empty( $this->post_object ) ) { 88 | return; 89 | } 90 | 91 | /* 92 | * Fires as an admin screen or script is being initialized. 93 | * https://developer.wordpress.org/reference/hooks/admin_init/ 94 | */ 95 | add_action( 96 | 'admin_init', 97 | [ 98 | $this, 99 | 'update', 100 | ] 101 | ); 102 | }//end init() 103 | 104 | 105 | /** 106 | * Security Check & Update On Action 107 | */ 108 | public function update() { 109 | $this->security_check(); 110 | 111 | // Website Append Rules. 112 | if ( 'append' === $this->post_action ) { 113 | $this->save_append_rules(); 114 | } 115 | }//end update() 116 | 117 | 118 | /** 119 | * Website Append Rules 120 | */ 121 | private function save_append_rules() { 122 | $message = false; 123 | 124 | if ( true !== empty( $this->post_object['append'] ) ) { 125 | $this->option_manager->update_setting( 'append', $this->post_object['append'] ); 126 | $message = true; 127 | } 128 | 129 | if ( true === empty( $this->post_object['append'] ) ) { 130 | $this->option_manager->delete_setting( 'append' ); 131 | $message = true; 132 | } 133 | 134 | if ( true !== empty( $this->post_object['override'] ) ) { 135 | $this->option_manager->update_setting( 'override', 1 ); 136 | } else { 137 | $this->option_manager->delete_setting( 'override' ); 138 | } 139 | 140 | // Remove Disable Marker. 141 | $this->option_manager->delete_setting( 'disable' ); 142 | 143 | if ( true === $message ) { 144 | // Build Robots.txt Files. 145 | $this->build_robotstxt->init(); 146 | 147 | $this->admin_notices->add_notice( 'success', 'append_success' ); 148 | } 149 | }//end save_append_rules() 150 | }//end class 151 | -------------------------------------------------------------------------------- /inc/classes/class-do-save-network-robotstxt.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Save Network Robots.txt File. 24 | */ 25 | final class Do_Save_Network_Robotstxt { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_action = $post_object['action']; 68 | $this->post_object = $post_object; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Save Network Robots.txt File. 103 | if ( 'save' === $this->post_action ) { 104 | $this->save_network_robotstxt(); 105 | } 106 | }//end update() 107 | 108 | 109 | /** 110 | * Save Network Robots.txt 111 | */ 112 | private function save_network_robotstxt() { 113 | $message = false; 114 | 115 | if ( true !== empty( $this->post_object ) && true !== empty( $this->post_object['robotstxt'] ) ) { 116 | $this->option_manager->update_site_setting( 'robotstxt', $this->post_object['robotstxt'] ); 117 | $message = true; 118 | } 119 | 120 | if ( true !== empty( $this->post_object ) && true === empty( $this->post_object['robotstxt'] ) ) { 121 | $this->option_manager->delete_site_option(); 122 | $message = true; 123 | } 124 | 125 | if ( true === $message ) { 126 | $this->admin_notices->add_notice( 'success', 'save_success', 'network' ); 127 | } 128 | }//end save_network_robotstxt() 129 | }//end class 130 | -------------------------------------------------------------------------------- /inc/classes/class-do-save-preset-as-robotstxt.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Save Network Robots.txt File With Preset. 24 | */ 25 | final class Do_Save_Preset_As_Robotstxt { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_object = $post_object; 68 | $this->post_action = $post_object['action']; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Save Preset Robots.txt as Network Robots.txt File. 103 | if ( 'presets' === $this->post_action ) { 104 | $this->save_preset_as_robotstxt(); 105 | } 106 | }//end update() 107 | 108 | 109 | /** 110 | * Save Preset Robots.txt as Network Robots.txt 111 | */ 112 | private function save_preset_as_robotstxt() { 113 | $message = false; 114 | $preset = ''; 115 | 116 | if ( true !== empty( $this->post_object['preset'] ) ) { 117 | $preset = $this->post_object['preset']; 118 | } 119 | 120 | switch ( $preset ) { 121 | case 'default-robotstxt': 122 | $this->option_manager->update_site_setting( 'robotstxt', $this->default_robotstxt() ); 123 | $message = true; 124 | break; 125 | 126 | case 'defaultalt-robotstxt': 127 | $this->option_manager->update_site_setting( 'robotstxt', $this->defaultalt_robotstxt() ); 128 | $message = true; 129 | break; 130 | 131 | case 'wordpress-robotstxt': 132 | $this->option_manager->update_site_setting( 'robotstxt', $this->wordpress_robotstxt() ); 133 | $message = true; 134 | break; 135 | 136 | case 'open-robotstxt': 137 | $this->option_manager->update_site_setting( 'robotstxt', $this->open_robotstxt() ); 138 | $message = true; 139 | break; 140 | 141 | case 'blogger-robotstxt': 142 | $this->option_manager->update_site_setting( 'robotstxt', $this->blogger_robotstxt() ); 143 | $message = true; 144 | break; 145 | 146 | case 'block-robotstxt': 147 | $this->option_manager->update_site_setting( 'robotstxt', $this->blocked_robotstxt() ); 148 | $message = true; 149 | break; 150 | 151 | case 'google-robotstxt': 152 | $this->option_manager->update_site_setting( 'robotstxt', $this->google_robotstxt() ); 153 | $message = true; 154 | break; 155 | } 156 | 157 | if ( true === $message ) { 158 | $this->admin_notices->add_notice( 'success', 'save_success', 'network' ); 159 | } 160 | }//end save_preset_as_robotstxt() 161 | 162 | 163 | /** 164 | * Default Robots.txt File 165 | */ 166 | private function default_robotstxt() { 167 | $txt = "# robots.txt\n"; 168 | $txt .= "User-agent: *\n"; 169 | $txt .= "Disallow: /feed\n"; 170 | $txt .= "Disallow: /feed/\n"; 171 | $txt .= "Disallow: /cgi-bin/\n"; 172 | $txt .= "Disallow: /comment\n"; 173 | $txt .= "Disallow: /comments\n"; 174 | $txt .= "Disallow: /trackback\n"; 175 | $txt .= "Disallow: /comment/\n"; 176 | $txt .= "Disallow: /comments/\n"; 177 | $txt .= "Disallow: /trackback/\n"; 178 | $txt .= "Disallow: /wp-admin/\n"; 179 | $txt .= "Disallow: /wp-content/\n"; 180 | $txt .= "Disallow: /wp-includes/\n"; 181 | $txt .= "Disallow: /wp-login.php\n"; 182 | $txt .= "Allow: /wp-admin/admin-ajax.php\n"; 183 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 184 | 185 | return $txt; 186 | } 187 | 188 | 189 | /** 190 | * Default-Alt Robots.txt File 191 | */ 192 | private function defaultalt_robotstxt() { 193 | $txt = "# robots.txt\n"; 194 | $txt .= "User-agent: *\n"; 195 | $txt .= "Disallow: */feed\n"; 196 | $txt .= "Disallow: */feed/\n"; 197 | $txt .= "Disallow: */comment/\n"; 198 | $txt .= "Disallow: */comments/\n"; 199 | $txt .= "Disallow: */trackback/\n"; 200 | $txt .= "Disallow: */comment\n"; 201 | $txt .= "Disallow: */comments\n"; 202 | $txt .= "Disallow: */trackback\n"; 203 | $txt .= "Disallow: /feed\n"; 204 | $txt .= "Disallow: /feed/\n"; 205 | $txt .= "Disallow: /cgi-bin/\n"; 206 | $txt .= "Disallow: /comment\n"; 207 | $txt .= "Disallow: /comment/\n"; 208 | $txt .= "Disallow: /comments\n"; 209 | $txt .= "Disallow: /comments/\n"; 210 | $txt .= "Disallow: /trackback\n"; 211 | $txt .= "Disallow: /trackback/\n"; 212 | $txt .= "Disallow: /wp-admin/\n"; 213 | $txt .= "Disallow: /wp-content/\n"; 214 | $txt .= "Disallow: /wp-includes/\n"; 215 | $txt .= "Disallow: /wp-login.php\n"; 216 | $txt .= "Allow: /wp-admin/admin-ajax.php\n"; 217 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 218 | 219 | return $txt; 220 | } 221 | 222 | 223 | /** 224 | * WordPress Only Robots.txt File 225 | */ 226 | private function wordpress_robotstxt() { 227 | $txt = "# robots.txt\n"; 228 | $txt .= "User-agent: *\n"; 229 | $txt .= "Disallow: /wp-admin/\n"; 230 | $txt .= "Disallow: /wp-includes/\n"; 231 | $txt .= "Allow: /wp-admin/admin-ajax.php\n"; 232 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 233 | 234 | return $txt; 235 | } 236 | 237 | 238 | /** 239 | * Open Robots.txt File 240 | */ 241 | private function open_robotstxt() { 242 | $txt = "# robots.txt\n"; 243 | $txt .= "User-agent: *\n"; 244 | $txt .= "Disallow:\n"; 245 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 246 | 247 | return $txt; 248 | } 249 | 250 | 251 | /** 252 | * Blogger Robots.txt File 253 | */ 254 | private function blogger_robotstxt() { 255 | $txt = "# robots.txt\n"; 256 | $txt .= "User-agent: *\n"; 257 | $txt .= "Disallow: *?\n"; 258 | $txt .= "Disallow: *.inc$\n"; 259 | $txt .= "Disallow: *.php$\n"; 260 | $txt .= "Disallow: */feed\n"; 261 | $txt .= "Disallow: */feed/\n"; 262 | $txt .= "Disallow: */author\n"; 263 | $txt .= "Disallow: */comment/\n"; 264 | $txt .= "Disallow: */comments/\n"; 265 | $txt .= "Disallow: */trackback/\n"; 266 | $txt .= "Disallow: */comment\n"; 267 | $txt .= "Disallow: */comments\n"; 268 | $txt .= "Disallow: */trackback\n"; 269 | $txt .= "Disallow: /wp-\n"; 270 | $txt .= "Disallow: /wp-*\n"; 271 | $txt .= "Disallow: /feed\n"; 272 | $txt .= "Disallow: /feed/\n"; 273 | $txt .= "Disallow: /author\n"; 274 | $txt .= "Disallow: /cgi-bin/\n"; 275 | $txt .= "Disallow: /wp-admin/\n"; 276 | $txt .= "Disallow: /comment/\n"; 277 | $txt .= "Disallow: /comments/\n"; 278 | $txt .= "Disallow: /trackback/\n"; 279 | $txt .= "Disallow: /comment\n"; 280 | $txt .= "Disallow: /comments\n"; 281 | $txt .= "Disallow: /trackback\n"; 282 | $txt .= "Disallow: /wp-admin/\n"; 283 | $txt .= "Disallow: /wp-content/\n"; 284 | $txt .= "Disallow: /wp-includes/\n"; 285 | $txt .= "Disallow: /wp-login.php\n"; 286 | $txt .= "Disallow: /wp-content/cache/\n"; 287 | $txt .= "Disallow: /wp-content/themes/\n"; 288 | $txt .= "Disallow: /wp-content/plugins/\n"; 289 | $txt .= "Allow: /wp-admin/admin-ajax.php\n"; 290 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 291 | 292 | return $txt; 293 | } 294 | 295 | 296 | /** 297 | * Disallow Website Robots.txt File 298 | */ 299 | private function blocked_robotstxt() { 300 | $txt = "# robots.txt\n"; 301 | $txt .= "User-agent: *\n"; 302 | $txt .= 'Disallow: /'; 303 | 304 | return $txt; 305 | } 306 | 307 | 308 | /** 309 | * Google Friendly Robots.txt File 310 | */ 311 | private function google_robotstxt() { 312 | $txt = "# robots.txt\n"; 313 | $txt .= "User-agent: *\n"; 314 | $txt .= "Disallow: /wp-\n"; 315 | $txt .= "Disallow: /feed\n"; 316 | $txt .= "Disallow: /feed/\n"; 317 | $txt .= "Disallow: /author\n"; 318 | $txt .= "Disallow: /cgi-bin/\n"; 319 | $txt .= "Disallow: /wp-admin/\n"; 320 | $txt .= "Disallow: /comment/\n"; 321 | $txt .= "Disallow: /comments/\n"; 322 | $txt .= "Disallow: /trackback/\n"; 323 | $txt .= "Disallow: /comment\n"; 324 | $txt .= "Disallow: /comments\n"; 325 | $txt .= "Disallow: /trackback\n"; 326 | $txt .= "Disallow: /wp-content/\n"; 327 | $txt .= "Disallow: /wp-includes/\n"; 328 | $txt .= "Disallow: /wp-login.php\n"; 329 | $txt .= "Disallow: /wp-content/cache/\n"; 330 | $txt .= "Disallow: /wp-content/themes/\n"; 331 | $txt .= "Disallow: /wp-content/plugins/\n"; 332 | $txt .= "Allow: /wp-content/uploads\n"; 333 | $txt .= "Allow: /wp-content/uploads/\n"; 334 | $txt .= "Allow: /wp-admin/admin-ajax.php\n"; 335 | $txt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 336 | $txt .= "\n"; 337 | $txt .= "# google bot\n"; 338 | $txt .= "User-agent: Googlebot\n"; 339 | $txt .= "Disallow: /wp-*\n"; 340 | $txt .= "Disallow: *?\n"; 341 | $txt .= "Disallow: *.inc$\n"; 342 | $txt .= "Disallow: *.php$\n"; 343 | $txt .= "Disallow: */feed\n"; 344 | $txt .= "Disallow: */feed/\n"; 345 | $txt .= "Disallow: */author\n"; 346 | $txt .= "Disallow: */comment/\n"; 347 | $txt .= "Disallow: */comments/\n"; 348 | $txt .= "Disallow: */trackback/\n"; 349 | $txt .= "Disallow: */comment\n"; 350 | $txt .= "Disallow: */comments\n"; 351 | $txt .= "Disallow: */trackback\n"; 352 | $txt .= "\n"; 353 | $txt .= "# google image bot\n"; 354 | $txt .= "User-agent: Googlebot-Image\n"; 355 | $txt .= "Allow: /*\n"; 356 | 357 | return $txt; 358 | } 359 | }//end class 360 | -------------------------------------------------------------------------------- /inc/classes/class-get-robotstxt-rules.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Build Robots.txt Rule Statements 20 | */ 21 | final class Get_Robotstxt_Rules { 22 | /** 23 | * Get the Upload Path Rule 24 | * 25 | * @return string 26 | */ 27 | public function get_uploadpath() { 28 | // Get Upload Dir For This Website. 29 | $upload_dir = wp_upload_dir( null, false, true ); 30 | 31 | if ( true === empty( $upload_dir['basedir'] ) ) { 32 | return esc_html__( 'Upload Path Not Set', 'multisite-robotstxt-manager' ); 33 | } 34 | 35 | // Split The Path. 36 | $contents = explode( 'uploads', $upload_dir['basedir'] ); 37 | 38 | // Return The Path. 39 | return 'Allow: /wp-content/uploads' . end( $contents ) . '/'; 40 | } 41 | 42 | 43 | /** 44 | * Get Theme Path Rule 45 | * 46 | * @return string 47 | */ 48 | public function get_themepath() { 49 | // Build Path For Theme. 50 | $path_to_themes = get_stylesheet_directory(); 51 | $theme_path = 'Allow: ' . strstr( $path_to_themes, '/wp-content/themes' ) . '/'; 52 | 53 | return $theme_path; 54 | } 55 | 56 | 57 | /** 58 | * Get Website Sitemap URL Rule 59 | * 60 | * @return string 61 | */ 62 | public function get_sitemapurl() { 63 | // Get Site URL. 64 | $sitemap_url_base = get_option( 'siteurl' ) ? get_option( 'siteurl' ) : MS_ROBOTSTXT_MANAGER_BASE_URL; 65 | 66 | if ( true === file_exists( $sitemap_url_base . '/sitemap.xml' ) ) { 67 | $root_xml_file_location = get_headers( $sitemap_url_base . '/sitemap.xml' ); 68 | } 69 | 70 | if ( true === file_exists( $sitemap_url_base . '/sitemaps/sitemap.xml' ) ) { 71 | $alt_xml_file_location = get_headers( $sitemap_url_base . '/sitemaps/sitemap.xml' ); 72 | } 73 | 74 | // Check if xml sitemap exists. 75 | if ( true === isset( $root_xml_file_location[0] ) && 'HTTP/1.1 200 OK' === $root_xml_file_location[0] ) { 76 | // http://domain.com/sitemap.xml. 77 | $url = $sitemap_url_base . '/sitemap.xml'; 78 | } elseif ( true === isset( $alt_xml_file_location[0] ) && 'HTTP/1.1 200 OK' === $alt_xml_file_location[0] ) { 79 | // http://domain.com/sitemaps/sitemap.xml. 80 | $url = $sitemap_url_base . '/sitemaps/sitemap.xml'; 81 | } else { 82 | $url = ''; 83 | } 84 | 85 | // Return the url or empty if no sitemap. 86 | return ( ! empty( $url ) ) ? 'Sitemap: ' . $url : ''; 87 | } 88 | }//end class 89 | -------------------------------------------------------------------------------- /inc/classes/class-msrobotstxtmanager.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Plugin Core 20 | */ 21 | final class MsRobotstxtManager { 22 | /** 23 | * Init Plugin 24 | */ 25 | public static function init() { 26 | require_once MS_ROBOTSTXT_MANAGER_PLUGIN_DIR . '/inc/instantiate-public-classes.php'; 27 | require_once MS_ROBOTSTXT_MANAGER_PLUGIN_DIR . '/inc/instantiate-admin-classes.php'; 28 | require_once MS_ROBOTSTXT_MANAGER_PLUGIN_DIR . '/inc/instantiate-network-classes.php'; 29 | }//end init() 30 | }//end class 31 | -------------------------------------------------------------------------------- /inc/classes/class-option-manager.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * WordPress Options Manager 20 | */ 21 | class Option_Manager { 22 | /** 23 | * Get Option Data 24 | * 25 | * @param string $str Option Name. 26 | * 27 | * @return array 28 | */ 29 | public function get_option( $str = '' ) { 30 | /* 31 | * Retrieves an option value based on an option name. 32 | * https://developer.wordpress.org/reference/functions/get_option/ 33 | */ 34 | $get_option = get_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str ); 35 | 36 | if ( true !== empty( $get_option ) ) { 37 | return $get_option; 38 | } 39 | 40 | return ''; 41 | }//end get_option() 42 | 43 | 44 | /** 45 | * Get Option Setting 46 | * 47 | * @param mixed $setting_name Name Of Option To Get. 48 | * @param string $str Option Name. 49 | * 50 | * @return string 51 | */ 52 | public function get_setting( $setting_name, $str = '' ) { 53 | $get_option = $this->get_option( $str ); 54 | 55 | if ( true === isset( $get_option[ $setting_name ] ) ) { 56 | return $get_option[ $setting_name ]; 57 | } 58 | 59 | return ''; 60 | }//end get_setting() 61 | 62 | 63 | /** 64 | * Get Network Site Option 65 | * 66 | * @param string $str Option Name. 67 | * 68 | * @return array 69 | */ 70 | public function get_site_option( $str = '' ) { 71 | /* 72 | * Retrieve an option value for the current network based on name of option. 73 | * https://developer.wordpress.org/reference/functions/get_site_option/ 74 | */ 75 | $get_option = get_site_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str ); 76 | 77 | if ( true !== empty( $get_option ) ) { 78 | return $get_option; 79 | } 80 | 81 | return ''; 82 | }//end get_site_option() 83 | 84 | 85 | /** 86 | * Get Network Option Setting 87 | * 88 | * @param mixed $setting_name Name Of Option To Get. 89 | * @param string $str Option Name. 90 | * 91 | * @return string 92 | */ 93 | public function get_site_setting( $setting_name, $str = '' ) { 94 | $get_option = $this->get_site_option( $str ); 95 | 96 | if ( true === isset( $get_option[ $setting_name ] ) ) { 97 | return $get_option[ $setting_name ]; 98 | } 99 | 100 | return ''; 101 | }//end get_site_setting() 102 | 103 | 104 | /** 105 | * Update Option Array 106 | * 107 | * @param mixed $option_array Prepared Option Array. 108 | * @param string $str Option Name. 109 | */ 110 | public function update_option( $option_array = [], $str = '' ) { 111 | if ( true === empty( $option_array ) ) { 112 | return; 113 | } 114 | 115 | /* 116 | * Update the value of an option that was already added. 117 | * https://developer.wordpress.org/reference/functions/update_option/ 118 | */ 119 | update_option( 120 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str, 121 | $option_array 122 | ); 123 | }//end update_option() 124 | 125 | 126 | /** 127 | * Update Option Array 128 | * 129 | * @param array $option_value Data To Save. 130 | * @param string $str Option Name. 131 | */ 132 | public function update_site_option( $option_value = [], $str = '' ) { 133 | if ( true === empty( $option_value ) ) { 134 | return; 135 | } 136 | 137 | /* 138 | * Update the value of an option that was already added for the current network. 139 | * https://developer.wordpress.org/reference/functions/update_site_option/ 140 | */ 141 | update_site_option( 142 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str, 143 | $option_value 144 | ); 145 | }//end update_site_option() 146 | 147 | 148 | /** 149 | * Update Setting Within Option 150 | * 151 | * @param mixed $setting_name Name Of Option To Save. 152 | * @param mixed $setting_value The Value To Save. 153 | * @param string $str Option Name. 154 | */ 155 | public function update_setting( $setting_name, $setting_value, $str = '' ) { 156 | $get_option = $this->get_option( $str ); 157 | 158 | if ( true === empty( $get_option ) ) { 159 | $get_option = []; 160 | } 161 | 162 | if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) { 163 | unset( $get_option[ $setting_name ] ); 164 | } 165 | 166 | $this->update_option( array_merge( $get_option, [ $setting_name => $setting_value ] ), $str ); 167 | }//end update_setting() 168 | 169 | 170 | /** 171 | * Update Setting Within Network Option 172 | * 173 | * @param mixed $setting_name Name Of Option To Save. 174 | * @param mixed $setting_value The Value To Save. 175 | * @param string $str Option Name. 176 | */ 177 | public function update_site_setting( $setting_name, $setting_value, $str = '' ) { 178 | $get_option = $this->get_site_option( $str ); 179 | 180 | if ( true === empty( $get_option ) ) { 181 | $get_option = []; 182 | } 183 | 184 | if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) { 185 | unset( $get_option[ $setting_name ] ); 186 | } 187 | 188 | $this->update_site_option( array_merge( $get_option, [ $setting_name => $setting_value ] ), $str ); 189 | }//end update_site_setting() 190 | 191 | 192 | /** 193 | * Delete Option 194 | * 195 | * @param string $str Option Name. 196 | * 197 | * @return void 198 | */ 199 | public function delete_option( $str = '' ) { 200 | $get_option = $this->get_option( $str ); 201 | 202 | if ( true === isset( $get_option ) ) { 203 | /* 204 | * Removes a option by name. 205 | * https://developer.wordpress.org/reference/functions/delete_option/ 206 | */ 207 | delete_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str ); 208 | } 209 | }//end delete_option() 210 | 211 | 212 | /** 213 | * Delete Network Site Option 214 | * 215 | * @param string $str Option Name. 216 | * 217 | * @return void 218 | */ 219 | public function delete_site_option( $str = '' ) { 220 | $get_option = $this->get_site_option( $str ); 221 | 222 | if ( true === isset( $get_option ) ) { 223 | /* 224 | * Removes a option by name for the current network. 225 | * https://developer.wordpress.org/reference/functions/delete_site_option/ 226 | */ 227 | delete_site_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str ); 228 | } 229 | }//end delete_site_option() 230 | 231 | 232 | /** 233 | * Delete Option Setting 234 | * 235 | * @param mixed $setting_name Name Of Option To Delete. 236 | * @param string $str Option Name. 237 | * 238 | * @return void 239 | */ 240 | public function delete_setting( $setting_name = '', $str = '' ) { 241 | if ( true === empty( $setting_name ) ) { 242 | return; 243 | } 244 | 245 | $get_option = $this->get_option( $str ); 246 | 247 | if ( true === is_array( $get_option ) && true === array_key_exists( $setting_name, $get_option ) ) { 248 | unset( $get_option[ $setting_name ] ); 249 | 250 | if ( true !== empty( $get_option ) ) { 251 | /* 252 | * Update the value of an option that was already added. 253 | * https://developer.wordpress.org/reference/functions/update_option/ 254 | */ 255 | update_option( 256 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME . $str, 257 | $get_option 258 | ); 259 | } 260 | } 261 | 262 | if ( true === empty( $get_option ) ) { 263 | $this->delete_option( $str ); 264 | } 265 | }//end delete_setting() 266 | }//end class 267 | -------------------------------------------------------------------------------- /inc/classes/class-plugin-activate.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Activation Rules 20 | */ 21 | final class Plugin_Activate { 22 | 23 | /** 24 | * Init Plugin Activation 25 | */ 26 | public static function init() { 27 | /* 28 | * Retrieves the current WordPress version 29 | * https://developer.wordpress.org/reference/functions/get_bloginfo/ 30 | */ 31 | $wp_version = get_bloginfo( 'version' ); 32 | 33 | if ( true === version_compare( $wp_version, 3.8, '<' ) ) { 34 | /* 35 | * Kill WordPress execution and display HTML message with error message. 36 | * https://developer.wordpress.org/reference/functions/wp_die/ 37 | * 38 | * Escaping for HTML blocks. 39 | * https://developer.wordpress.org/reference/functions/esc_html/ 40 | */ 41 | wp_die( esc_html__( 'WordPress 3.8 is required. Please upgrade WordPress and try again.', 'multisite-robotstxt-manager' ) ); 42 | } 43 | 44 | // Maybe Save Robots.txt As Plugin Robots.txt. 45 | self::set_robotstxt(); 46 | }//end init() 47 | 48 | 49 | /** 50 | * Maybe Set Plugin Robots.txt 51 | */ 52 | public static function set_robotstxt() { 53 | /* 54 | * Retrieve an option value for the current network based on name of option. 55 | * https://developer.wordpress.org/reference/functions/get_site_option/ 56 | */ 57 | $plugin_option = get_site_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME ); 58 | 59 | // Set Plugin Robots.txt From Website Robots.txt. 60 | if ( true === empty( $plugin_option ) && true !== empty( self::get_website_robotstxt() ) ) { 61 | /* 62 | * Update the value of an option that was already added for the current network. 63 | * https://developer.wordpress.org/reference/functions/update_site_option/ 64 | */ 65 | update_site_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, self::get_website_robotstxt() ); 66 | } 67 | 68 | // Set Plugin Robots.txt Based On Default WordPress robots.txt - Unable To Read Robots.txt. 69 | if ( true === empty( $plugin_option ) && true === empty( self::get_website_robotstxt() ) ) { 70 | $preset_robotstxt['robotstxt'] = "User-agent: *\n"; 71 | $preset_robotstxt['robotstxt'] .= "Disallow: /wp-admin/\n"; 72 | $preset_robotstxt['robotstxt'] .= "Allow: /wp-admin/admin-ajax.php\n"; 73 | $preset_robotstxt['robotstxt'] .= '{APPEND_WEBSITE_ROBOTSTXT}'; 74 | 75 | /* 76 | * Update the value of an option that was already added for the current network. 77 | * https://developer.wordpress.org/reference/functions/update_site_option/ 78 | */ 79 | update_site_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, $preset_robotstxt ); 80 | } 81 | }//end set_robotstxt() 82 | 83 | 84 | /** 85 | * Get Local Website Robots.txt File Body 86 | */ 87 | public static function get_website_robotstxt() { 88 | $robotstxt = ''; 89 | 90 | /* 91 | * Retrieve the raw response from the HTTP request using the GET method. 92 | * https://developer.wordpress.org/reference/functions/wp_remote_get/ 93 | */ 94 | $website_robotstxt = wp_remote_get( get_home_url() . '/robots.txt' ); 95 | 96 | /* 97 | * Check whether variable is a WordPress Error. 98 | * https://developer.wordpress.org/reference/functions/is_wp_error/ 99 | * 100 | * Issue: https://github.com/ChrisWinters/multisite-robotstxt-manager/issues/8 101 | */ 102 | if ( true === is_wp_error( $website_robotstxt ) ) { 103 | return $robotstxt; 104 | } 105 | 106 | if ( true !== empty( $website_robotstxt['response']['code'] ) && '200' === $website_robotstxt['response']['code'] && true !== empty( $website_robotstxt['body'] ) ) { 107 | $robotstxt = $website_robotstxt['body'] . "\n"; 108 | $robotstxt .= '{APPEND_WEBSITE_ROBOTSTXT}'; 109 | } 110 | 111 | return $robotstxt; 112 | }//end get_website_robotstxt() 113 | }//end class 114 | -------------------------------------------------------------------------------- /inc/classes/class-plugin-admin-notices.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Plugin Admin Area Notices 20 | */ 21 | final class Plugin_Admin_Notices { 22 | /** 23 | * Notice Messages. 24 | * 25 | * @var array 26 | */ 27 | public $message = []; 28 | 29 | 30 | /** 31 | * Set Class Params 32 | * 33 | * @return void 34 | */ 35 | public function __construct() { 36 | $this->notice = ''; 37 | }//end __construct() 38 | 39 | 40 | /** 41 | * Return Message Based On Key. 42 | * 43 | * @param string $message Message Key To Return. 44 | */ 45 | private function messages( $message = '' ) { 46 | $messages = [ 47 | 'update_success' => __( 48 | 'Rules Updated.', 49 | 'includes' 50 | ), 51 | 'robotstxt_success' => __( 52 | 'Robots.txt File Generated.', 53 | 'includes' 54 | ), 55 | 'network_updated' => __( 56 | 'Network Websites Updated.', 57 | 'includes' 58 | ), 59 | 'member_updated' => __( 60 | 'Network Member Websites Updated.', 61 | 'includes' 62 | ), 63 | 'update_error' => __( 64 | 'Settings Update Failed.', 65 | 'includes' 66 | ), 67 | 'save_success' => __( 68 | 'Network Robots.txt File Saved.', 69 | 'includes' 70 | ), 71 | 'append_success' => __( 72 | 'Append Rules Saved.', 73 | 'includes' 74 | ), 75 | 'input_error' => __( 76 | 'A Selection Is Required.', 77 | 'includes' 78 | ), 79 | 'delete_success' => __( 80 | 'All Plugin Settings Deleted.', 81 | 'includes' 82 | ), 83 | 'checkdata_notice' => __( 84 | 'Old robots.txt file data found! Click the "remove old data" button to remove the old data.', 85 | 'includes' 86 | ), 87 | 'checkdata_done' => __( 88 | 'No old robots.txt file data found.', 89 | 'includes' 90 | ), 91 | 'checkphysical_notice' => __( 92 | 'A real robots.txt file was found within the websites root directory. Click the "delete physical file" to delete the robots.txt file.', 93 | 'includes' 94 | ), 95 | 'checkphysical_done' => __( 96 | 'A physical robots.txt file was not found.', 97 | 'includes' 98 | ), 99 | 'checkphysical_error' => __( 100 | 'The plugin was unable to delete the robots.txt file due to file permissions. Manual deletion required.', 101 | 'includes' 102 | ), 103 | 'checkrewrite_notice' => __( 104 | 'This website is missing the robots.txt Rewrite Rule. Click the "correct missing rules" button to add the missing rule.', 105 | 'includes' 106 | ), 107 | 'checkrewrite_done' => __( 108 | 'Proper Rewrite Rule found.', 109 | 'includes' 110 | ), 111 | 'disable_success' => __( 112 | 'Default WordPress robots.txt file restored.', 113 | 'includes' 114 | ), 115 | 'upgraded_already' => __( 116 | 'Plugin has already been upgraded.', 117 | 'includes' 118 | ), 119 | 'upgrade_success' => __( 120 | 'Plugin upgraded. Please check the saved rules to ensure everything is correct.', 121 | 'includes' 122 | ), 123 | ]; 124 | 125 | if ( true !== empty( $messages[ $message ] ) ) { 126 | return $messages[ $message ]; 127 | } 128 | }//end messages() 129 | 130 | 131 | /** 132 | * Display Admin Notice 133 | * 134 | * @param string $type Message Type (success|error). 135 | * @param string $message Message Key To Get. 136 | * @param string $network Set to network to use network_admin_notices. 137 | */ 138 | public function add_notice( $type = '', $message = '', $network = '' ) { 139 | if ( false === method_exists( $this, $type ) ) { 140 | return; 141 | } 142 | 143 | if ( true === empty( $message ) ) { 144 | return; 145 | } 146 | 147 | if ( true === empty( $this->messages( $message ) ) ) { 148 | return; 149 | } 150 | 151 | $admin_notice_type = 'admin_notices'; 152 | 153 | if ( true !== empty( $network ) && 'network' === $network ) { 154 | $admin_notice_type = 'network_admin_notices'; 155 | } 156 | 157 | // Set Notice Message. 158 | $this->notice = $this->messages( $message ); 159 | 160 | /* 161 | * Prints admin screen notices. 162 | * https://developer.wordpress.org/reference/hooks/admin_notices/ 163 | */ 164 | add_action( 165 | $admin_notice_type, 166 | [ 167 | $this, 168 | $type, 169 | ] 170 | ); 171 | }//end add_notice() 172 | 173 | 174 | /** 175 | * Success Message HTML 176 | */ 177 | public function success() { 178 | if ( true === empty( $this->notice ) ) { 179 | return; 180 | } 181 | 182 | /* 183 | * Sanitizes content for allowed HTML tags for post content. 184 | * https://developer.wordpress.org/reference/functions/wp_kses_post/ 185 | */ 186 | echo wp_kses_post( '

' . $this->notice . '

' ); 187 | }//end success() 188 | 189 | 190 | /** 191 | * Error Message HTML 192 | */ 193 | public function error() { 194 | if ( true === empty( $this->notice ) ) { 195 | return; 196 | } 197 | 198 | /* 199 | * Sanitizes content for allowed HTML tags for post content. 200 | * https://developer.wordpress.org/reference/functions/wp_kses_post/ 201 | */ 202 | echo wp_kses_post( '

' . $this->notice . '

' ); 203 | }//end error() 204 | }//end class 205 | -------------------------------------------------------------------------------- /inc/classes/class-plugin-admin-post.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Query_String as TraitQueryString; 19 | 20 | 21 | /** 22 | * Save/Update Plugin Settings 23 | */ 24 | class Plugin_Admin_Post { 25 | use TraitQueryString; 26 | 27 | /** 28 | * Plugin Admin Post Object. 29 | * 30 | * @var array 31 | */ 32 | public $post_object = []; 33 | 34 | 35 | /** 36 | * Set Class Params 37 | */ 38 | public function __construct() { 39 | if ( $this->query_string( 'page' ) !== MS_ROBOTSTXT_MANAGER_PLUGIN_NAME ) { 40 | return; 41 | } 42 | 43 | $post_object_array = filter_input_array( INPUT_POST, FILTER_UNSAFE_RAW ); 44 | $post_object = $this->unset_post_items( $post_object_array ); 45 | 46 | if ( true === empty( $post_object ) ) { 47 | return; 48 | } 49 | 50 | $this->post_object = $post_object; 51 | }//end __construct() 52 | 53 | 54 | /** 55 | * Get Cleaned Post Object 56 | */ 57 | public function get_post_object() { 58 | return $this->post_object; 59 | }//end get_post_object() 60 | 61 | 62 | /** 63 | * Unset Post Objects 64 | * 65 | * @param array $post_array Form Post Object. 66 | * 67 | * @return array|void 68 | */ 69 | final public function unset_post_items( $post_array ) { 70 | unset( $post_array['submit'] ); 71 | unset( $post_array[ MS_ROBOTSTXT_MANAGER_SETTING_PREFIX . 'nonce' ] ); 72 | unset( $post_array['_wp_http_referer'] ); 73 | 74 | if ( true !== empty( $post_array ) ) { 75 | unset( $post_array['section'] ); 76 | 77 | return $post_array; 78 | } 79 | }//end unset_post_items() 80 | }//end class 81 | -------------------------------------------------------------------------------- /inc/classes/class-plugin-admin.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Query_String as TraitQueryString; 19 | use MsRobotstxtManager\Get_Robotstxt_Rules as GetRobotstxtRules; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Load WordPress Plugin Admin Area 24 | */ 25 | final class Plugin_Admin { 26 | use TraitQueryString; 27 | 28 | /** 29 | * Init Admin Display 30 | */ 31 | public function __construct() { 32 | /* 33 | * Fires before the administration menu loads in the admin. 34 | * https://developer.wordpress.org/reference/hooks/admin_menu/ 35 | */ 36 | add_action( 37 | 'admin_menu', 38 | [ 39 | $this, 40 | 'menu', 41 | ] 42 | ); 43 | 44 | /* 45 | * Fires before the administration menu loads in the Network Admin. 46 | * https://developer.wordpress.org/reference/hooks/network_admin_menu/ 47 | */ 48 | add_action( 49 | 'network_admin_menu', 50 | [ 51 | $this, 52 | 'menu', 53 | ] 54 | ); 55 | 56 | if ( $this->query_string( 'page' ) === MS_ROBOTSTXT_MANAGER_PLUGIN_NAME ) { 57 | /* 58 | * Enqueue Scripts For Plugin Admin 59 | * https://developer.wordpress.org/reference/hooks/admin_enqueue_scripts/ 60 | */ 61 | add_action( 62 | 'admin_enqueue_scripts', 63 | [ 64 | $this, 65 | 'enqueue', 66 | ] 67 | ); 68 | } 69 | }//end __construct() 70 | 71 | 72 | /** 73 | * Generate Settings Menu 74 | */ 75 | public function menu() { 76 | /* 77 | * Add Settings Page Options 78 | * https://developer.wordpress.org/reference/functions/add_submenu_page/ 79 | */ 80 | add_submenu_page( 81 | 'options-general.php', 82 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 83 | __( 'Robots.txt Manager', 'multisite-robotstxt-manager' ), 84 | 'manage_options', 85 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 86 | [ 87 | $this, 88 | 'templates', 89 | ] 90 | ); 91 | 92 | /* 93 | * Add Settings Page Options 94 | * https://developer.wordpress.org/reference/functions/add_submenu_page/ 95 | */ 96 | add_submenu_page( 97 | 'settings.php', 98 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 99 | __( 'Robots.txt Manager', 'multisite-robotstxt-manager' ), 100 | 'manage_options', 101 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 102 | [ 103 | $this, 104 | 'templates', 105 | ] 106 | ); 107 | }//end menu() 108 | 109 | 110 | /** 111 | * Enqueue Stylesheet and jQuery 112 | */ 113 | public function enqueue() { 114 | /* 115 | * Enqueue a CSS stylesheet. 116 | * https://developer.wordpress.org/reference/functions/wp_enqueue_style/ 117 | * 118 | * Retrieves a URL within the plugins directory. 119 | * https://developer.wordpress.org/reference/functions/plugins_url/ 120 | */ 121 | wp_enqueue_style( 122 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 123 | plugins_url( '/assets/css/style.min.css', MS_ROBOTSTXT_MANAGER_FILE ), 124 | '', 125 | date( 'YmdHis', time() ), 126 | 'all' 127 | ); 128 | }//end enqueue() 129 | 130 | 131 | /** 132 | * Display Admin Templates 133 | */ 134 | public function templates() { 135 | $dir = dirname( MS_ROBOTSTXT_MANAGER_FILE ); 136 | $tab = $this->query_string( 'tab' ); 137 | 138 | $option = new OptionManager(); 139 | 140 | if ( true !== is_network_admin() ) { 141 | $status = $option->get_setting( 'disable' ); 142 | $append_rules = $option->get_setting( 'append' ); 143 | $uploadpath = $option->get_setting( 'uploadpath' ); 144 | $themepath = $option->get_setting( 'themepath' ); 145 | $sitemapurl = $option->get_setting( 'sitemapurl' ); 146 | $override = $option->get_setting( 'override' ); 147 | 148 | $website_robotstxt = $option->get_setting( 'robotstxt' ); 149 | 150 | if ( true !== empty( $override ) ) { 151 | $website_robotstxt = $append_rules; 152 | } 153 | 154 | $rules = new GetRobotstxtRules(); 155 | $uploadpath = ( true === empty( $uploadpath ) ) ? $rules->get_uploadpath() : $uploadpath; 156 | $themepath = ( true === empty( $themepath ) ) ? $rules->get_themepath() : $themepath; 157 | $sitemapurl = ( true === empty( $sitemapurl ) ) ? $rules->get_sitemapurl() : $sitemapurl; 158 | } 159 | 160 | if ( true === is_network_admin() ) { 161 | if ( 'cleaner' === $tab ) { 162 | $checkdata = $option->get_setting( 'checkdata' ); 163 | $checkphysical = $option->get_setting( 'checkphysical' ); 164 | $checkrewrite = $option->get_setting( 'checkrewrite' ); 165 | } 166 | 167 | $network_upgrade = $option->get_site_setting( 'upgraded' ); 168 | 169 | $sdk = $option->get_site_setting( 'sdk_action' ); 170 | } 171 | 172 | $network_robotstxt = $option->get_site_setting( 'robotstxt' ); 173 | 174 | include_once $dir . '/inc/templates/header.php'; 175 | 176 | if ( true === file_exists( $dir . '/inc/templates/' . $tab . '.php' ) ) { 177 | include_once $dir . '/inc/templates/' . $tab . '.php'; 178 | 179 | /* 180 | * Whether the current request is for the network administrative interface. 181 | * https://developer.wordpress.org/reference/functions/is_network_admin/ 182 | */ 183 | } elseif ( true === is_network_admin() ) { 184 | include_once $dir . '/inc/templates/network.php'; 185 | } else { 186 | include_once $dir . '/inc/templates/settings.php'; 187 | } 188 | 189 | include_once $dir . '/inc/templates/footer.php'; 190 | }//end templates() 191 | 192 | 193 | /** 194 | * Display Admin Area Tabs 195 | * 196 | * @return string $html Tab Display 197 | */ 198 | public function tabs() { 199 | /* 200 | * Escaping for HTML blocks. 201 | * https://developer.wordpress.org/reference/functions/esc_html__/ 202 | */ 203 | $admin_tabs = [ 204 | 'settings' => esc_html__( 'Settings', 'multisite-robotstxt-manager' ), 205 | ]; 206 | 207 | /* 208 | * Whether the current request is for the network administrative interface. 209 | * https://developer.wordpress.org/reference/functions/is_network_admin/ 210 | * 211 | * Escaping for HTML blocks. 212 | * https://developer.wordpress.org/reference/functions/esc_html__/ 213 | */ 214 | if ( true === is_network_admin() ) { 215 | $admin_tabs = [ 216 | 'network' => esc_html__( 'Network', 'multisite-robotstxt-manager' ), 217 | 'cleaner' => esc_html__( 'Cleaner', 'multisite-robotstxt-manager' ), 218 | ]; 219 | } 220 | 221 | $html = '
'; 248 | 249 | return $html; 250 | }//end tabs() 251 | }//end class 252 | -------------------------------------------------------------------------------- /inc/classes/class-plugin-upgrade.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | use MsRobotstxtManager\Trait_Security_Check as TraitSecurityCheck; 19 | use MsRobotstxtManager\Plugin_Admin_Notices as PluginAdminNotices; 20 | use MsRobotstxtManager\Option_Manager as OptionManager; 21 | 22 | /** 23 | * Maybe Upgrade Plugin 24 | */ 25 | final class Plugin_Upgrade { 26 | use TraitSecurityCheck; 27 | 28 | /** 29 | * Plugin Admin Post Object. 30 | * 31 | * @var array 32 | */ 33 | public $post_object = []; 34 | 35 | /** 36 | * Post Action To Take. 37 | * 38 | * @var string 39 | */ 40 | public $post_action = []; 41 | 42 | /** 43 | * Option_Manager Class. 44 | * 45 | * @var object 46 | */ 47 | public $option_manager = []; 48 | 49 | /** 50 | * Plugin_Admin_Notices Class 51 | * 52 | * @var object 53 | */ 54 | public $admin_notices = []; 55 | 56 | 57 | /** 58 | * Setup Class 59 | * 60 | * @param array $post_object Cleaned Post Object. 61 | */ 62 | public function __construct( $post_object = [] ) { 63 | if ( true === empty( $post_object ) || true === empty( $post_object['action'] ) ) { 64 | return; 65 | } 66 | 67 | $this->post_object = $post_object; 68 | $this->post_action = $post_object['action']; 69 | $this->option_manager = new OptionManager(); 70 | $this->admin_notices = new PluginAdminNotices(); 71 | }//end __construct() 72 | 73 | 74 | /** 75 | * Init Update Action 76 | */ 77 | public function init() { 78 | if ( true === empty( $this->post_object ) ) { 79 | return; 80 | } 81 | 82 | /* 83 | * Fires as an admin screen or script is being initialized. 84 | * https://developer.wordpress.org/reference/hooks/admin_init/ 85 | */ 86 | add_action( 87 | 'admin_init', 88 | [ 89 | $this, 90 | 'update', 91 | ] 92 | ); 93 | }//end init() 94 | 95 | 96 | /** 97 | * Security Check & Update On Action 98 | */ 99 | public function update() { 100 | $this->security_check(); 101 | 102 | // Init Upgrade. 103 | if ( 'upgrade' === $this->post_action ) { 104 | if ( true !== empty( $this->post_object['migrate'] ) && '1' === $this->post_object['migrate'] ) { 105 | $this->upgrade(); 106 | } 107 | 108 | if ( true !== empty( $this->post_object['delete'] ) && '1' === $this->post_object['delete'] ) { 109 | $this->delete(); 110 | } 111 | 112 | if ( true !== empty( $this->post_object['dismiss'] ) && '1' === $this->post_object['dismiss'] ) { 113 | $this->dismiss(); 114 | } 115 | } 116 | }//end update() 117 | 118 | 119 | /** 120 | * Dismiss Upgrade 121 | */ 122 | private function dismiss() { 123 | $this->option_manager->update_site_setting( 'upgraded', true ); 124 | }//end dismiss() 125 | 126 | 127 | /** 128 | * Maybe Upgrade Plugin 129 | */ 130 | private function upgrade() { 131 | $new_network_option = $this->option_manager->get_site_option(); 132 | 133 | if ( true !== empty( $new_network_option['upgraded'] ) || true !== empty( $new_network_option['robotstxt'] ) ) { 134 | $this->option_manager->update_site_setting( 'upgraded', true ); 135 | $this->admin_notices->add_notice( 'success', 'upgraded_already', 'network' ); 136 | return; 137 | } 138 | 139 | $network_robotstxt = get_option( 'ms_robotstxt_manager_network_robotstxt' ); 140 | 141 | if ( true !== empty( $network_robotstxt['robotstxt'] ) ) { 142 | $this->option_manager->update_site_setting( 'robotstxt', $network_robotstxt['robotstxt'] ); 143 | 144 | $option_array = []; 145 | 146 | /* 147 | * Retrieves a list of sites matching requested arguments. 148 | * https://developer.wordpress.org/reference/functions/get_sites/ 149 | */ 150 | foreach ( get_sites() as $website ) { 151 | /* 152 | * Switch the current blog. 153 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 154 | */ 155 | switch_to_blog( $website->blog_id ); 156 | 157 | $website_robotstxt = get_option( 'ms_robotstxt_manager_robotstxt' ); 158 | $website_append_rules = get_option( 'ms_robotstxt_manager_append' ); 159 | 160 | if ( true !== empty( $website_robotstxt['robotstxt'] ) ) { 161 | $option_array['robotstxt'] = $website_robotstxt['robotstxt']; 162 | } 163 | 164 | if ( true !== empty( $website_append_rules['robotstxt'] ) ) { 165 | $option_array['append'] = $website_append_rules['robotstxt']; 166 | } 167 | 168 | if ( true === get_option( 'ms_robotstxt_manager_status' ) ) { 169 | $option_array['disable'] = true; 170 | } 171 | 172 | if ( true !== empty( $option_array ) ) { 173 | $this->option_manager->update_option( $option_array ); 174 | } 175 | 176 | /* 177 | * Restore the current blog, after calling switch_to_blog. 178 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 179 | */ 180 | restore_current_blog(); 181 | } 182 | 183 | // Set Upgrade Delte Marker & Send Notice. 184 | $this->option_manager->update_site_setting( 'upgraded', 'delete' ); 185 | $this->admin_notices->add_notice( 'success', 'upgrade_success', 'network' ); 186 | return; 187 | } 188 | 189 | if ( true === empty( $network_robotstxt['robotstxt'] ) ) { 190 | $this->option_manager->update_site_setting( 'upgraded', true ); 191 | $this->admin_notices->add_notice( 'success', 'upgraded_already', 'network' ); 192 | return; 193 | } 194 | }//end upgrade() 195 | 196 | 197 | /** 198 | * Maybe Delete Old Plugin Settings 199 | */ 200 | private function delete() { 201 | $network_robotstxt = get_option( 'ms_robotstxt_manager_network_robotstxt' ); 202 | 203 | if ( true !== empty( $network_robotstxt['robotstxt'] ) ) { 204 | delete_option( 'ms_robotstxt_manager_network_robotstxt' ); 205 | delete_option( 'ms_robotstxt_manager_network_preset' ); 206 | delete_option( 'ms_robotstxt_manager_network_status' ); 207 | delete_option( 'ms_robotstxt_manager_settings' ); 208 | delete_option( 'ms_robotstxt_manager_cleaner_old_data' ); 209 | delete_option( 'ms_robotstxt_manager_cleaner_physical' ); 210 | delete_option( 'ms_robotstxt_manager_cleaner_rewrite' ); 211 | delete_option( 'msrtm_settings' ); 212 | 213 | /* 214 | * Retrieves a list of sites matching requested arguments. 215 | * https://developer.wordpress.org/reference/functions/get_sites/ 216 | */ 217 | foreach ( get_sites() as $website ) { 218 | /* 219 | * Switch the current blog. 220 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 221 | */ 222 | switch_to_blog( $website->blog_id ); 223 | 224 | delete_option( 'ms_robotstxt_manager_robotstxt' ); 225 | delete_option( 'ms_robotstxt_manager_status' ); 226 | delete_option( 'ms_robotstxt_manager_append' ); 227 | delete_option( 'ms_robotstxt_manager_default' ); 228 | 229 | /* 230 | * Restore the current blog, after calling switch_to_blog. 231 | * https://developer.wordpress.org/reference/functions/restore_current_blog/ 232 | */ 233 | restore_current_blog(); 234 | } 235 | 236 | // Set Upgrade Delte Marker & Send Notice. 237 | $this->option_manager->update_site_setting( 'upgraded', true ); 238 | $this->admin_notices->add_notice( 'success', 'upgrade_success', 'network' ); 239 | } 240 | }//end delete() 241 | }//end class 242 | -------------------------------------------------------------------------------- /inc/classes/class-robotstxt.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Display Robots.txt File If Called 20 | */ 21 | final class Robotstxt { 22 | /** 23 | * Check File Being Called 24 | */ 25 | public function __construct() { 26 | if ( false !== strpos( filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL ), 'robots.txt' ) ) { 27 | $this->robotstxt(); 28 | } 29 | } 30 | 31 | 32 | /** 33 | * Display Robots.txt File 34 | */ 35 | private function robotstxt() { 36 | /* 37 | * If Multisite is enabled. 38 | * https://developer.wordpress.org/reference/functions/is_multisite/ 39 | */ 40 | if ( true === is_multisite() ) { 41 | /* 42 | * Retrieve the current site ID. 43 | * https://developer.wordpress.org/reference/functions/get_current_blog_id/ 44 | */ 45 | $site_id = get_current_blog_id(); 46 | 47 | /* 48 | * Switch the current blog. 49 | * https://developer.wordpress.org/reference/functions/switch_to_blog/ 50 | */ 51 | switch_to_blog( $site_id ); 52 | } 53 | 54 | /* 55 | * Retrieves an option value based on an option name. 56 | * https://developer.wordpress.org/reference/functions/get_option/ 57 | */ 58 | $website_option = get_option( MS_ROBOTSTXT_MANAGER_PLUGIN_NAME ); 59 | $robotstxt_file = ''; 60 | 61 | // Ignore If Disabled. 62 | if ( true !== empty( $website_option['disable'] ) ) { 63 | return; 64 | } 65 | 66 | // Robots.txt Set. 67 | if ( true !== empty( $website_option['robotstxt'] ) && true === empty( $robotstxt_file ) ) { 68 | $robotstxt_file = $website_option['robotstxt']; 69 | } 70 | 71 | // Override Robots.txt Set, Use Append As Robots.txt File. 72 | if ( true !== empty( $website_option['override'] ) ) { 73 | $robotstxt_file = $website_option['append']; 74 | } 75 | 76 | // Display Robots.txt File. 77 | if ( true !== empty( $robotstxt_file ) ) { 78 | header( 'Status: 200 OK', true, 200 ); 79 | header( 'Content-type: text/plain; charset=' . get_bloginfo( 'charset' ) ); 80 | 81 | /** 82 | * Fires when displaying the robots.txt file. 83 | * 84 | * @since 2.1.0 85 | */ 86 | do_action( 'do_robotstxt' ); 87 | 88 | // Get Status. 89 | $public = get_option( 'blog_public' ); 90 | $output = "Disallow: /\n"; 91 | 92 | if ( '0' !== $public ) { 93 | $output = $robotstxt_file; 94 | } 95 | 96 | /** 97 | * Filters the robots.txt output. 98 | * 99 | * @since 3.0.0 100 | * 101 | * @param string $output Robots.txt output. 102 | * @param bool $public Whether the site is considered "public". 103 | */ 104 | $display_robotstxt_file = apply_filters( 'robots_txt', $output, $public ); 105 | 106 | /* 107 | * Escaping for HTML blocks. 108 | * https://developer.wordpress.org/reference/functions/esc_html/ 109 | */ 110 | echo esc_html( $display_robotstxt_file ); 111 | exit; 112 | } 113 | } 114 | }//end class 115 | -------------------------------------------------------------------------------- /inc/classes/class-trait-query-string.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Process Plugin Admin Query String 20 | */ 21 | trait Trait_Query_String { 22 | /** 23 | * Get Query String Item & Sanitize 24 | * 25 | * @param string $get Query String Get Item. 26 | * 27 | * @return string Query String Item Sanitized 28 | */ 29 | final public function query_string( $get ) { 30 | $string = filter_input( 31 | INPUT_GET, 32 | $get, 33 | FILTER_SANITIZE_SPECIAL_CHARS, 34 | ( FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK ) 35 | ); 36 | 37 | if ( true !== isset( $string ) ) { 38 | return false; 39 | }; 40 | 41 | $string = strtolower( $string ); 42 | 43 | $string = preg_replace( '/\s/', '', $string ); 44 | 45 | /* 46 | * Sanitizes a string from user input or from the database. 47 | * https://developer.wordpress.org/reference/functions/sanitize_text_field/ 48 | */ 49 | return sanitize_text_field( $string ); 50 | }//end query_string() 51 | }//end trait 52 | -------------------------------------------------------------------------------- /inc/classes/class-trait-security-check.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Form Validation 20 | */ 21 | trait Trait_Security_Check { 22 | /** 23 | * Do Simple Security Checks 24 | */ 25 | final public function security_check() { 26 | $message = __( 'You are not authorized to perform this action.', 'multisite-robotstxt-manager' ); 27 | 28 | if ( filter_input( INPUT_GET, 'page' ) !== MS_ROBOTSTXT_MANAGER_PLUGIN_NAME ) { 29 | /* 30 | * Kill WordPress execution with message. 31 | * https://developer.wordpress.org/reference/functions/wp_die/ 32 | */ 33 | wp_die( esc_html( $message ) ); 34 | } 35 | 36 | /* 37 | * Whether the current user has a specific capability. 38 | * https://developer.wordpress.org/reference/functions/current_user_can/ 39 | */ 40 | if ( false === current_user_can( 'manage_options' ) ) { 41 | /* 42 | * Kill WordPress execution and display message. 43 | * https://developer.wordpress.org/reference/functions/wp_die/ 44 | */ 45 | wp_die( esc_html( $message ) ); 46 | } 47 | 48 | /* 49 | * Makes sure that a user was referred from another admin page. 50 | * https://developer.wordpress.org/reference/functions/check_admin_referer/ 51 | */ 52 | if ( false === check_admin_referer( 53 | MS_ROBOTSTXT_MANAGER_SETTING_PREFIX . 'action', 54 | MS_ROBOTSTXT_MANAGER_SETTING_PREFIX . 'nonce' 55 | ) 56 | ) { 57 | /* 58 | * Kill WordPress execution and display message. 59 | * https://developer.wordpress.org/reference/functions/wp_die/ 60 | */ 61 | wp_die( esc_html( $message ) ); 62 | } 63 | }//end security_check() 64 | }//end trait 65 | -------------------------------------------------------------------------------- /inc/classes/class-translate.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /** 19 | * Load Plugin Translation Strings & .mo File 20 | */ 21 | final class Translate { 22 | /** 23 | * Maybe Init Translate 24 | */ 25 | public static function init() { 26 | /* 27 | * Call the functions added to a filter hook. 28 | * https://developer.wordpress.org/reference/functions/apply_filters/ 29 | * 30 | * Retrieves the current locale. 31 | * https://developer.wordpress.org/reference/functions/get_locale/ 32 | */ 33 | $get_locale = apply_filters( 34 | 'plugin_locale', 35 | get_locale(), 36 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME 37 | ); 38 | 39 | $load_mo_file = MS_ROBOTSTXT_MANAGER_PLUGIN_DIR . '/lang/' . $get_locale . '.mo'; 40 | 41 | if ( true === file_exists( $load_mo_file ) ) { 42 | /* 43 | * Load a .mo file into the text domain $textdomain. 44 | * https://developer.wordpress.org/reference/functions/load_textdomain/ 45 | */ 46 | load_textdomain( 47 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 48 | $load_mo_file 49 | ); 50 | } 51 | 52 | /* 53 | * Loads a plugin’s translated strings. 54 | * https://developer.wordpress.org/reference/functions/load_plugin_textdomain/ 55 | */ 56 | load_plugin_textdomain( 57 | MS_ROBOTSTXT_MANAGER_PLUGIN_NAME, 58 | false, 59 | MS_ROBOTSTXT_MANAGER_FILE . '/lang/' 60 | ); 61 | } 62 | }//end class 63 | -------------------------------------------------------------------------------- /inc/classes/index.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Determines whether the current request is for an administrative interface page. 20 | * https://developer.wordpress.org/reference/functions/is_admin/ 21 | */ 22 | if ( true === is_admin() ) { 23 | // Display Plugin Admin. 24 | $plugin_admin = new \MsRobotstxtManager\Plugin_Admin(); 25 | 26 | // Manage Admin Updates. 27 | $plugin_admin_post = new \MsRobotstxtManager\Plugin_Admin_Post(); 28 | $post_object = $plugin_admin_post->get_post_object(); 29 | 30 | // Website: Save Append Rules. 31 | $save_append_rules = new \MsRobotstxtManager\Do_Save_Append_Rules( $post_object ); 32 | $save_append_rules->init(); 33 | 34 | // Website: Disable Website. 35 | $disable_website = new \MsRobotstxtManager\Do_Disable_Website( $post_object ); 36 | $disable_website->init(); 37 | 38 | // Network: Save Network Robots.txt File. 39 | $save_network_robotstxt = new \MsRobotstxtManager\Do_Save_Network_Robotstxt( $post_object ); 40 | $save_network_robotstxt->init(); 41 | 42 | // Network: Save Preset As Network Robots.txt File. 43 | $save_preset_robotstxt = new \MsRobotstxtManager\Do_Save_Preset_As_Robotstxt( $post_object ); 44 | $save_preset_robotstxt->init(); 45 | 46 | // Network: Build Robots.txt File For All Network Websites. 47 | $network_robotstxt_build = new \MsRobotstxtManager\Do_Network_Robotstxt_Build( $post_object ); 48 | $network_robotstxt_build->init(); 49 | 50 | // Network: Build Robots.txt File For All Member Websites. 51 | $member_robotstxt_build = new \MsRobotstxtManager\Do_Member_Robotstxt_Build( $post_object ); 52 | $member_robotstxt_build->init(); 53 | 54 | // Network: Delete All Plugin Settings Across Network. 55 | $delete_settings = new \MsRobotstxtManager\Do_Delete_Settings( $post_object ); 56 | $delete_settings->init(); 57 | 58 | // Network: Run Cleaner Tool. 59 | $cleaner = new \MsRobotstxtManager\Do_Robotstxt_Cleaner( $post_object ); 60 | $cleaner->init(); 61 | } 62 | -------------------------------------------------------------------------------- /inc/instantiate-network-classes.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Whether the current request is for the network administrative interface. 20 | * https://developer.wordpress.org/reference/functions/is_network_admin/ 21 | */ 22 | if ( true === is_network_admin() ) { 23 | // Maybe Upgrade Plugin. 24 | $maybe_upgrade_plugin = new \MsRobotstxtManager\Plugin_Upgrade( $post_object ); 25 | $maybe_upgrade_plugin->init(); 26 | } 27 | -------------------------------------------------------------------------------- /inc/instantiate-public-classes.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | // Loads Translated Strings. 19 | $translate = new \MsRobotstxtManager\Translate(); 20 | 21 | // Display Robots.txt File. 22 | $robotstxt = new \MsRobotstxtManager\Robotstxt(); 23 | -------------------------------------------------------------------------------- /inc/templates/cleaner.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Retrieve or display nonce hidden field for forms. 20 | * https://developer.wordpress.org/reference/functions/wp_nonce_field/ 21 | * 22 | * Retrieve the translation of $text and escapes it for safe use in HTML output. 23 | * https://developer.wordpress.org/reference/functions/esc_html__/ 24 | * 25 | * Escaping for HTML attributes. 26 | * https://developer.wordpress.org/reference/functions/esc_attr/ 27 | * 28 | * Checks and cleans a URL. 29 | * https://developer.wordpress.org/reference/functions/esc_url/ 30 | * 31 | * Display translated text. 32 | * https://developer.wordpress.org/reference/functions/esc_html_e/ 33 | * 34 | * Outputs the html checked attribute. 35 | * https://developer.wordpress.org/reference/functions/checked/ 36 | * 37 | * Echoes a submit button, with provided text and appropriate class( es ). 38 | * https://developer.wordpress.org/reference/functions/submit_button/ 39 | */ 40 | ?> 41 |
42 | 48 | 49 | 50 |

51 |

52 |
53 | 54 | 55 |
56 |

57 |

58 |
59 | 60 | 61 |
62 | 63 |

64 |

65 |
66 | 67 | 68 |
69 |

70 |

71 |
72 | 73 | 74 |
75 | 76 |

77 |

78 |
79 | 80 | 81 |
82 |

83 |

84 |
85 | 86 | 87 |
88 | -------------------------------------------------------------------------------- /inc/templates/footer.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Escaping for HTML blocks. 20 | * https://developer.wordpress.org/reference/functions/esc_html/ 21 | * 22 | * Checks and cleans a URL. 23 | * https://developer.wordpress.org/reference/functions/esc_url/ 24 | * 25 | * Display translated text. 26 | * https://developer.wordpress.org/reference/functions/_e/ 27 | */ 28 | 29 | ?> 30 | 31 | 32 | 33 |
34 | 35 |
36 | 37 |
38 |
39 |
40 |
41 | 42 | 43 |
44 | -------------------------------------------------------------------------------- /inc/templates/header.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Display translated text that has been escaped for safe use in HTML output. 20 | * https://developer.wordpress.org/reference/functions/esc_html_e/ 21 | */ 22 | ?> 23 |
24 |

25 | tabs() ); 34 | ?> 35 | 36 |
37 |
38 |
39 | -------------------------------------------------------------------------------- /inc/templates/index.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Retrieve the translation of $text and escapes it for safe use in HTML output. 20 | * https://developer.wordpress.org/reference/functions/esc_html__/ 21 | * 22 | * Checks and cleans a URL. 23 | * https://developer.wordpress.org/reference/functions/esc_url/ 24 | * 25 | * Display translated text. 26 | * https://developer.wordpress.org/reference/functions/esc_html_e/ 27 | * 28 | * Echoes a submit button, with provided text and appropriate class( es ). 29 | * https://developer.wordpress.org/reference/functions/submit_button/ 30 | */ 31 | ?> 32 |
33 | 44 | 45 |

46 |

47 | 48 | 49 | 50 | 51 | 57 | 58 | 59 |
52 | 53 |

54 |

55 |

56 |
60 | 61 | 62 |
63 | 64 |
65 | 66 | 71 | 72 |
73 | 84 | 85 | 86 | 87 | 88 | 89 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |
90 |
91 |

92 |
[view]
[view]
[view]
[view]
[view]
[view]
[view]
124 | 125 | 126 |
127 | 128 |


129 | 130 |
131 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
150 | 151 |

152 |
153 | -------------------------------------------------------------------------------- /inc/templates/notice.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | if ( true !== is_network_admin() ) { 19 | return; 20 | } 21 | 22 | if ( true !== empty( $sdk ) ) { 23 | return; 24 | } 25 | 26 | if ( true !== $network_upgrade || 'delete' === $network_upgrade ) { 27 | return; 28 | } 29 | 30 | /* 31 | * 32 | * Echoes a submit button, with provided text and appropriate class( es ). 33 | * https://developer.wordpress.org/reference/functions/submit_button/ 34 | */ 35 | 36 | ?> 37 |
38 |
39 | 40 | 56 | 57 |

58 |

59 | 60 | 61 | 62 |

63 |
64 |
65 | -------------------------------------------------------------------------------- /inc/templates/settings.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Retrieve the translation of $text and escapes it for safe use in HTML output. 20 | * https://developer.wordpress.org/reference/functions/esc_html__/ 21 | * 22 | * Checks and cleans a URL. 23 | * https://developer.wordpress.org/reference/functions/esc_url/ 24 | * 25 | * Display translated text. 26 | * https://developer.wordpress.org/reference/functions/esc_html_e/ 27 | * 28 | * Echoes a submit button, with provided text and appropriate class( es ). 29 | * https://developer.wordpress.org/reference/functions/submit_button/ 30 | */ 31 | ?> 32 |
33 | 44 | 45 | 46 | 47 |

48 | 49 | 50 | 51 | 52 | 53 | 57 | 58 | 59 | 62 | 63 | 64 | 65 | 68 | 69 | 70 | 71 |
54 |
55 |

56 |
60 | 61 |
66 |

/>

67 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |
79 |
80 |

81 |
97 |
98 | 99 | 100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 |
110 | 111 |
115 |
116 | 117 | 118 | 119 |
120 | 121 | 122 | 123 | 124 | 125 | 126 | 129 | 130 | 131 |
127 | 128 |
132 |
133 | 134 | 135 |


136 | 137 |
138 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 |
157 | 158 |

159 |
160 | 161 | -------------------------------------------------------------------------------- /inc/templates/sidebar.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | /* 19 | * Retrieve or display nonce hidden field for forms. 20 | * https://developer.wordpress.org/reference/functions/wp_nonce_field/ 21 | * 22 | * Display translated text. 23 | * https://developer.wordpress.org/reference/functions/esc_html_e/ 24 | * 25 | * Escaping for HTML attributes. 26 | * https://developer.wordpress.org/reference/functions/esc_attr/ 27 | * 28 | * Checks and cleans a URL. 29 | * https://developer.wordpress.org/reference/functions/esc_url/ 30 | */ 31 | ?> 32 |
33 |
34 |
35 |
    36 |
  • 37 |
  • 38 |
39 |
40 |
41 | 42 |

<?php esc_html_e( 'Please Rate This Plugin At Wordpress.org!', 'multisite-robotstxt-manager' ); ?>

43 | 44 |
45 |
46 |
47 | 48 |
    49 |
  • 50 |
  • 51 |
  • 52 |
  • 53 |
  • 54 |
55 | 56 |
57 |
58 | -------------------------------------------------------------------------------- /inc/templates/upgrade.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GNU GPLv3 9 | * @link /LICENSE 10 | */ 11 | 12 | namespace MsRobotstxtManager; 13 | 14 | if ( false === defined( 'ABSPATH' ) ) { 15 | exit; 16 | } 17 | 18 | if ( true !== is_network_admin() ) { 19 | return; 20 | } 21 | 22 | if ( true === $network_upgrade ) { 23 | return; 24 | } 25 | 26 | /* 27 | * 28 | * Echoes a submit button, with provided text and appropriate class( es ). 29 | * https://developer.wordpress.org/reference/functions/submit_button/ 30 | */ 31 | 32 | ?> 33 |
34 |
35 | 36 | 52 | 53 |

54 |

55 | 56 | 57 | 58 | 59 | 60 | 61 |

62 |
63 |
64 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | \n" 10 | "Last-Translator: ChrisW. \n" 11 | "Report-Msgid-Bugs-To: https://github.com/ChrisWinters/multisite-robotstxt-manager/issues\n" 12 | "X-Poedit-Basepath: ..\n" 13 | "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" 14 | "X-Poedit-SearchPath-0: .\n" 15 | "X-Poedit-SearchPathExcluded-0: *.js\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 18 | 19 | #: inc/classes/class-get-robotstxt-rules.php:32 20 | msgid "Upload Path Not Set" 21 | msgstr "" 22 | 23 | #: inc/classes/class-plugin-activate.php:41 24 | msgid "WordPress 3.8 is required. Please upgrade WordPress and try again." 25 | msgstr "" 26 | 27 | #: inc/classes/class-plugin-admin.php:83, inc/classes/class-plugin-admin.php:99, inc/templates/sidebar.php:33 28 | msgid "Robots.txt Manager" 29 | msgstr "" 30 | 31 | #: inc/classes/class-plugin-admin.php:200 32 | msgid "Settings" 33 | msgstr "" 34 | 35 | #: inc/classes/class-plugin-admin.php:212 36 | msgid "Network" 37 | msgstr "" 38 | 39 | #: inc/classes/class-plugin-admin.php:213 40 | msgid "Cleaner" 41 | msgstr "" 42 | 43 | #: inc/classes/class-trait-security-check.php:26 44 | msgid "You are not authorized to perform this action." 45 | msgstr "" 46 | 47 | #: inc/templates/automate.php:39 48 | msgid "Automation" 49 | msgstr "" 50 | 51 | #: inc/templates/automate.php:40 52 | msgid "Check to activate." 53 | msgstr "" 54 | 55 | #: inc/templates/automate.php:46 56 | msgid "Automatically build/save robots.txt files when new websites are added to the network." 57 | msgstr "" 58 | 59 | #: inc/templates/automate.php:47 60 | msgid "Automatically build/save robots.txt files that have not generated when the robots.txt file is viewed." 61 | msgstr "" 62 | 63 | #: inc/templates/automate.php:48 64 | msgid "Automatically add upload path to website append rules." 65 | msgstr "" 66 | 67 | #: inc/templates/automate.php:49 68 | msgid "Automatically add theme path to website append rules." 69 | msgstr "" 70 | 71 | #: inc/templates/automate.php:50 72 | msgid "Automatically add sitemap urls to website append rules." 73 | msgstr "" 74 | 75 | #: inc/templates/automate.php:56 76 | msgid " save rules " 77 | msgstr "" 78 | 79 | #: inc/templates/cleaner.php:50 80 | msgid "Check For Old Robots.txt File Settings" 81 | msgstr "" 82 | 83 | #: inc/templates/cleaner.php:51 84 | msgid "If you are having problems with a websites robots.txt file to displaying properly, it is possible that old robots.txt file data left over from other plugins is conflicting. Click the \"scan for old data\" button below to scan the network for left over data. If any is found, a notice will display with a new button to automatically clean out the left over data." 85 | msgstr "" 86 | 87 | #: inc/templates/cleaner.php:56 88 | msgid "Old Robots.txt File Settings Found" 89 | msgstr "" 90 | 91 | #: inc/templates/cleaner.php:57 92 | msgid "Click the \"remove old data\" button below to purge the old settings." 93 | msgstr "" 94 | 95 | #: inc/templates/cleaner.php:63 96 | msgid "Check For Real (physical) Robots.txt File" 97 | msgstr "" 98 | 99 | #: inc/templates/cleaner.php:64 100 | msgid "If network/website changes do not appear to override the robots.txt file or if the file is blank, it is possible that a plugin created a physical (hard) robots.txt file. Click the \"scan for physical file\" button below to check the website for a real robots.txt file. If one is found, a notice will display with a new button allowing you to delete the file." 101 | msgstr "" 102 | 103 | #: inc/templates/cleaner.php:69 104 | msgid "A Real Robots.txt File Was Found" 105 | msgstr "" 106 | 107 | #: inc/templates/cleaner.php:70 108 | msgid "Click the \"delete physical file\" button below to delete the real robots.txt file." 109 | msgstr "" 110 | 111 | #: inc/templates/cleaner.php:76 112 | msgid "Check For Robots.txt Rewrite Rule" 113 | msgstr "" 114 | 115 | #: inc/templates/cleaner.php:77 116 | msgid "If your robots.txt files are blank, it is possible the website is missing the rewrite rule index.php?robots=1. Click the \"scan for missing rule\" button below to scan the for the missing rule. If the rule is missing, a notice will display with a new button to automatically add the rule for you." 117 | msgstr "" 118 | 119 | #: inc/templates/cleaner.php:82 120 | msgid "Website Rewrite Rule Missing" 121 | msgstr "" 122 | 123 | #: inc/templates/cleaner.php:83 124 | msgid "Click the \"add missing rule\" button below to add the missing rule." 125 | msgstr "" 126 | 127 | #: inc/templates/footer.php:38, inc/templates/header.php:24 128 | msgid "Multisite Robots.txt Manager" 129 | msgstr "" 130 | 131 | #: inc/templates/footer.php:39 132 | msgid "top" 133 | msgstr "" 134 | 135 | #: inc/templates/header.php:24 136 | msgid "A Multisite Robots.txt Manager Plugin For WordPress." 137 | msgstr "" 138 | 139 | #: inc/templates/network.php:45 140 | msgid "Network Robots.txt File" 141 | msgstr "" 142 | 143 | #: inc/templates/network.php:46 144 | msgid "If used, the {APPEND_WEBSITE_ROBOTSTXT} marker will be replaced at the website level if the website has unique append rules. Saving and publishing an empty network robots.txt file will restore the default WordPress robots.txt file." 145 | msgstr "" 146 | 147 | #: inc/templates/network.php:53 148 | msgid "Rebuild all network websites robots.txt files." 149 | msgstr "" 150 | 151 | #: inc/templates/network.php:54 152 | msgid "Rebuild all robots.txt files only on network websites you are a member of." 153 | msgstr "" 154 | 155 | #: inc/templates/network.php:55 156 | msgid "Save the network robots.txt file / does not rebuild robots.txt files." 157 | msgstr "" 158 | 159 | #: inc/templates/network.php:61 160 | msgid " submit " 161 | msgstr "" 162 | 163 | #: inc/templates/network.php:90 164 | msgid "Robots.txt File Presets" 165 | msgstr "" 166 | 167 | #: inc/templates/network.php:91 168 | msgid "Select a preset robots.txt file to save as the network robots.txt file." 169 | msgstr "" 170 | 171 | #: inc/templates/network.php:95 172 | msgid "Plugin Default Robots.txt File" 173 | msgstr "" 174 | 175 | #: inc/templates/network.php:96 176 | msgid "The plugins default installed robots.txt file." 177 | msgstr "" 178 | 179 | #: inc/templates/network.php:99 180 | msgid "Alternative Robots.txt File" 181 | msgstr "" 182 | 183 | #: inc/templates/network.php:100 184 | msgid "Similar to the plugins default robots.txt file, with more disallows." 185 | msgstr "" 186 | 187 | #: inc/templates/network.php:103 188 | msgid "WordPress Limited Robots.txt File" 189 | msgstr "" 190 | 191 | #: inc/templates/network.php:104 192 | msgid "Only disallows wp-includes and wp-admin." 193 | msgstr "" 194 | 195 | #: inc/templates/network.php:107 196 | msgid "Open Robots.txt File" 197 | msgstr "" 198 | 199 | #: inc/templates/network.php:108 200 | msgid "Fully open robots.txt file, no disallows." 201 | msgstr "" 202 | 203 | #: inc/templates/network.php:111 204 | msgid "A Bloggers Robots.txt File" 205 | msgstr "" 206 | 207 | #: inc/templates/network.php:112 208 | msgid "Optimized for blog focused WordPress websites." 209 | msgstr "" 210 | 211 | #: inc/templates/network.php:115 212 | msgid "Google Robots.txt File" 213 | msgstr "" 214 | 215 | #: inc/templates/network.php:116 216 | msgid "A Google friendly robots.txt file." 217 | msgstr "" 218 | 219 | #: inc/templates/network.php:119 220 | msgid "Lockdown Robots.txt File" 221 | msgstr "" 222 | 223 | #: inc/templates/network.php:120 224 | msgid "Disallow everything, prevent spiders from indexing the website." 225 | msgstr "" 226 | 227 | #: inc/templates/network.php:125 228 | msgid "update robots.txt file" 229 | msgstr "" 230 | 231 | #: inc/templates/network.php:146 232 | msgid "WARNING: Delete all settings related to the Multisite Robots.txt Manager Plugin across the entire network." 233 | msgstr "" 234 | 235 | #: inc/templates/notice.php:57 236 | msgid "Never miss an important update! Opt-in to our security and feature update notifications, and non-sensitive diagnostic tracking with freemius." 237 | msgstr "" 238 | 239 | #: inc/templates/notice.php:59 240 | msgid "Opt-In" 241 | msgstr "" 242 | 243 | #: inc/templates/notice.php:60 244 | msgid "Learn More" 245 | msgstr "" 246 | 247 | #: inc/templates/notice.php:61, inc/templates/upgrade.php:60 248 | msgid "Dismiss" 249 | msgstr "" 250 | 251 | #: inc/templates/settings.php:47 252 | msgid "WARNING" 253 | msgstr "" 254 | 255 | #: inc/templates/settings.php:47 256 | msgid "The Default WordPress Robots.txt File Is Current Displaying! Update the append rules to enable the robots.txt manager for this website." 257 | msgstr "" 258 | 259 | #: inc/templates/settings.php:54 260 | msgid "Robots.txt Custom Append Rules" 261 | msgstr "" 262 | 263 | #: inc/templates/settings.php:55 264 | 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." 265 | msgstr "" 266 | 267 | #: inc/templates/settings.php:55 268 | msgid "View robots.txt file" 269 | msgstr "" 270 | 271 | #: inc/templates/settings.php:65 272 | msgid "Check to use the saved data (above) as this websites robots.txt file, overriding the network robots.txt file." 273 | msgstr "" 274 | 275 | #: inc/templates/settings.php:71 276 | msgid "update append rules" 277 | msgstr "" 278 | 279 | #: inc/templates/settings.php:77 280 | msgid "Manual Rule Suggestions" 281 | msgstr "" 282 | 283 | #: inc/templates/settings.php:78 284 | msgid "The rules below will need to be manually added to the end of the robots.txt file." 285 | msgstr "" 286 | 287 | #: inc/templates/settings.php:82 288 | msgid "Upload Path" 289 | msgstr "" 290 | 291 | #: inc/templates/settings.php:86 292 | msgid "Theme Path" 293 | msgstr "" 294 | 295 | #: inc/templates/settings.php:90 296 | msgid "Sitemap URL" 297 | msgstr "" 298 | 299 | #: inc/templates/settings.php:104 300 | msgid "Live Robots.txt File" 301 | msgstr "" 302 | 303 | #: inc/templates/settings.php:121 304 | msgid "Current Network Robots.txt File" 305 | msgstr "" 306 | 307 | #: inc/templates/settings.php:151 308 | msgid "Restore the default WordPress robots.txt file on this website." 309 | msgstr "" 310 | 311 | #: inc/templates/sidebar.php:45 312 | msgid "Connect To Plugin Services" 313 | msgstr "" 314 | 315 | #: inc/templates/sidebar.php:50 316 | msgid "Pro Plugin: Automation Upgrade" 317 | msgstr "" 318 | 319 | #: inc/templates/sidebar.php:52 320 | msgid "Affiliates Earn 50% Revshare" 321 | msgstr "" 322 | 323 | #: inc/templates/sidebar.php:53 324 | msgid "Contact Support" 325 | msgstr "" 326 | 327 | #: inc/templates/sidebar.php:54, inc/templates/sidebar.php:70 328 | msgid "WordPress Forum" 329 | msgstr "" 330 | 331 | #: inc/templates/sidebar.php:55 332 | msgid "Plugin Home Page" 333 | msgstr "" 334 | 335 | #: inc/templates/sidebar.php:56 336 | msgid "Bugs & Feature Requests" 337 | msgstr "" 338 | 339 | #: inc/templates/sidebar.php:62 340 | msgid "Notice" 341 | msgstr "" 342 | 343 | #: inc/templates/sidebar.php:65 344 | msgid "Please report any issues, bugs, or problems you have - your help is greatly appreciated." 345 | msgstr "" 346 | 347 | #: inc/templates/sidebar.php:68 348 | msgid "Direct Email" 349 | msgstr "" 350 | 351 | #: inc/templates/sidebar.php:69 352 | msgid "Github Issues" 353 | msgstr "" 354 | 355 | #: inc/templates/sidebar.php:77 356 | msgid "Pro Automation Plugin!" 357 | msgstr "" 358 | 359 | #: inc/templates/sidebar.php:80 360 | msgid "Please Rate This Plugin At Wordpress.org!" 361 | msgstr "" 362 | 363 | #: inc/templates/sidebar.php:83 364 | msgid "Robots.txt Help" 365 | msgstr "" 366 | 367 | #: inc/templates/sidebar.php:87 368 | msgid "Robots.txt Optimization Tips" 369 | msgstr "" 370 | 371 | #: inc/templates/sidebar.php:88 372 | msgid "AskAapche Robots.txt Example" 373 | msgstr "" 374 | 375 | #: inc/templates/sidebar.php:89 376 | msgid "Google Robots.txt F.A.Q." 377 | msgstr "" 378 | 379 | #: inc/templates/sidebar.php:90 380 | msgid "Robots.txt Specifications" 381 | msgstr "" 382 | 383 | #: inc/templates/sidebar.php:91 384 | msgid "Web Robots Database" 385 | msgstr "" 386 | 387 | #: inc/templates/upgrade.php:53 388 | 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.)" 389 | msgstr "" 390 | 391 | #: inc/templates/upgrade.php:56 392 | msgid "Delete Old Settings" 393 | msgstr "" 394 | 395 | #: inc/templates/upgrade.php:58 396 | msgid "Migrate" 397 | msgstr "" 398 | -------------------------------------------------------------------------------- /multisite-robotstxt-manager.php: -------------------------------------------------------------------------------- 1 | 17 | * @license GNU GPLv3 18 | * @link /LICENSE 19 | */ 20 | 21 | namespace MsRobotstxtManager; 22 | 23 | if ( false === defined( 'ABSPATH' ) ) { 24 | exit; 25 | } 26 | 27 | define( 'MS_ROBOTSTXT_MANAGER_DIR', __DIR__ ); 28 | define( 'MS_ROBOTSTXT_MANAGER_FILE', __FILE__ ); 29 | define( 'MS_ROBOTSTXT_MANAGER_VERSION', '3.1.0' ); 30 | define( 'MS_ROBOTSTXT_MANAGER_PLUGIN_DIR', dirname( __FILE__ ) ); 31 | define( 'MS_ROBOTSTXT_MANAGER_PLUGIN_NAME', 'multisite-robotstxt-manager' ); 32 | define( 'MS_ROBOTSTXT_MANAGER_SETTING_PREFIX', 'multisite-robotstxt_manager_' ); 33 | 34 | require_once dirname( __FILE__ ) . '/inc/autoload-classes.php'; 35 | 36 | /* 37 | * Hooks a function on to a specific action. 38 | * https://developer.wordpress.org/reference/functions/add_action/ 39 | * 40 | * Hooks a function on to a specific action. 41 | * https://developer.wordpress.org/reference/functions/add_action/ 42 | */ 43 | add_action( 44 | 'plugins_loaded', 45 | array( 46 | 'MsRobotstxtManager\Translate', 47 | 'init', 48 | ) 49 | ); 50 | 51 | add_action( 52 | 'plugins_loaded', 53 | array( 54 | 'MsRobotstxtManager\MsRobotstxtManager', 55 | 'init', 56 | ) 57 | ); 58 | 59 | /* 60 | * Set the activation hook for a plugin. 61 | * https://developer.wordpress.org/reference/functions/register_activation_hook/ 62 | */ 63 | register_activation_hook( 64 | __FILE__, 65 | array( 66 | 'MsRobotstxtManager\Plugin_Activate', 67 | 'init', 68 | ) 69 | ); 70 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Multisite Robots.txt Manager === 2 | Plugin Name: Multisite Robots.txt Manager | MS Robots.txt 3 | Contributors: Chris Winters 4 | Tags: robots.txt, seo, multisite 5 | Requires at least: 3.8 6 | Tested up to: 6.7.1 7 | Stable tag: 3.1.0 8 | License: GNU GPLv3 9 | License URI: https://github.com/ChrisWinters/multisite-robotstxt-manager/blob/master/LICENSE 10 | 11 | A Robots.txt Manager Plugin for WordPress Multisite Networks. Quickly and easily manage all robots.txt files on a WordPress Multisite Website Network. 12 | 13 | == Description == 14 | 15 | A Robots.txt Manager Plugin for WordPress Multisite Networks. Quickly and easily manage all robots.txt files on a WordPress Multisite Website Network. 16 | 17 | !!! Network Enabled Multisite Installs Only !!! 18 | 19 | This Plugin Was Created For Multisite Networks > Network Activations Only! 20 | 21 | == For Support & Bugs == 22 | 23 | Please [report issues](https://github.com/ChrisWinters/multisite-robotstxt-manager/issues) you may have found. 24 | 25 | == Features == 26 | 27 | * Network-wide robots.txt file shared across all sites. 28 | * Append extra robots.txt data per-site Admin. 29 | * Create unique robots.txt files for each network website. 30 | * Manage all websites from the Network Admin Area. 31 | * Manage a single website through individual Site Admins. 32 | * Auto-generate Sitemap URLs, Upload Paths, and Theme Paths. 33 | * Mass update all websites on the network in one click. 34 | * Quickly publish preset robots.txt files across the network. 35 | * Scan and clean old plugin data to avoid conflicts. 36 | 37 | == Quick Info == 38 | 39 | * The default "Network Wide" robots.txt file is NOT a live robots.txt file. 40 | * Deactivating the plugin keeps all options but stops showing robots.txt files. 41 | * Deleting the plugin removes all options/settings from the database for all websites. 42 | 43 | **How to Access:** 44 | 45 | - Get the Plugin: Download > Install > Network Activate 46 | - Network Admin: Settings Tab > MS Robots.txt Link 47 | - Website Admin: Settings Tab > MS Robots.txt Link 48 | 49 | **Steps to Publish:** 50 | 51 | 1. Network Admin: 52 | - Choose "Publish the network robots.txt file to all network websites" or "Publish to websites you are a member of." 53 | - Click "Update Settings" to publish. 54 | 2. Website Admin: 55 | - Modify the appended robots.txt file or create a unique file. 56 | - Click "Update Website Rules" to save changes. 57 | 58 | == Installation == 59 | 60 | **Install through WordPress Admin:** 61 | 62 | 1. Navigate to **Network Admin > Plugins > Add New**. 63 | 2. Search for "robots.txt". 64 | 3. Locate "Multisite Robots.txt Manager" and click **Install Now**. 65 | 4. Activate the plugin or Network Activate it. 66 | 67 | **Manual Upload and Install:** 68 | 69 | 1. Upload `/multisite-robotstxt-manager/` to `/wp-content/plugins/`. 70 | 2. Go to **Network Admin > Plugins**. 71 | 3. Find "Multisite Robots.txt Manager" (sort by inactive) and click **Activate**. 72 | 73 | == FAQs == 74 | 75 | **Q) Can the plugin update all websites at once?** 76 | A) Yes. 77 | 78 | **Q) Does this plugin work on non-multisite installs?** 79 | A) No, it requires Multisite/Network activation. 80 | 81 | **Q) Can every website have a different robots.txt file?** 82 | A) Yes, each site can append unique rules or fully customize its robots.txt file. 83 | 84 | **Q) Does this plugin handle Sitemap links?** 85 | A) Yes, the Pro version adds them automatically; the Free version requires manual addition. 86 | 87 | **Q) My robots.txt file is 404—what's wrong?** 88 | A) Missing rewrite rules. Use the plugin's Cleaner tab in the Network Admin to fix this. 89 | 90 | **Q) Does this plugin work with other robots.txt plugins?** 91 | A) No, multiple plugins managing robots.txt files can cause conflicts. 92 | 93 | **Q) Does the plugin clean up settings when deleted?** 94 | A) Yes, all settings and options are removed upon deletion. 95 | 96 | == Additional Info == 97 | 98 | **Markers in Network Robots.txt File:** 99 | - Use `{APPEND_WEBSITE_ROBOTSTXT}` in the network robots.txt file to insert unique rules from individual websites. 100 | 101 | **Robots.txt File Testing:** 102 | - Use [Google's Robots.txt Tester](https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt). 103 | 104 | == Changelog == 105 | 106 | **3.0.1** 107 | - Released: 2024-11-21 108 | - [Changelog Details](https://github.com/ChrisWinters/multisite-robotstxt-manager/blob/master/CHANGELOG.md#301) 109 | 110 | == Screenshots == 111 | 112 | 1. Network Admin - All Features Shown 113 | 2. Preset Robots.txt File Loaded & Published 114 | 3. Cleaner Tab 115 | 4. Website Admin - Features Overview 116 | 5. Robots.txt File Using Append Rules 117 | 6. Custom Robots.txt File Example 118 | --------------------------------------------------------------------------------