WP Robots Txt - Version 1.2

Version Description

  • Update the default robots.txt content
  • Include sitemap reference
  • Resolve code warnings/errors
  • WP Coding Standards compliant
  • Ensure Compatibility with WP v6
Download this release

Release Info

Developer pattihis
Plugin Icon 128x128 WP Robots Txt
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

inc/class-robtxt-admin-page.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Robots Txt
4
+ *
5
+ * Copyright 2013 Christopher Davis <http://christopherdavis.me>
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License, version 2, as
9
+ * published by the Free Software Foundation.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ *
20
+ * Copyright 2022 George Pattihis (gpattihis@gmail.com)
21
+ *
22
+ * "WP Robots Txt" is free software: you can redistribute it and/or modify
23
+ * it under the terms of the GNU General Public License as published by
24
+ * the Free Software Foundation, either version 2 of the License, or
25
+ * any later version.
26
+ *
27
+ * "WP Robots Txt" is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU General Public License for more details.
31
+ *
32
+ * You should have received a copy of the GNU General Public License
33
+ * "along with WP Robots Txt". If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
34
+ *
35
+ * @category WordPress
36
+ * @package WPRobotsTxt
37
+ * @author George Pattihis
38
+ * @copyright 2022 George Pattihis
39
+ * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
40
+ */
41
+
42
+ /**
43
+ * Wrapper for all our admin area functionality.
44
+ *
45
+ * @since 0.1
46
+ */
47
+ class ROBTXT_Admin_Page {
48
+
49
+ /**
50
+ * The contents of the text-area.
51
+ *
52
+ * @since 1.2
53
+ * @access private
54
+ * @var string $ins
55
+ */
56
+ private static $ins = null;
57
+
58
+ /**
59
+ * The name of our option.
60
+ *
61
+ * @since 1.2
62
+ * @access protected
63
+ * @var string $setting
64
+ */
65
+ protected $setting = 'robtxt_content';
66
+
67
+ /**
68
+ * Get an instance of the class.
69
+ *
70
+ * @since 1.2
71
+ * @access public
72
+ */
73
+ public static function instance() {
74
+ if ( null === self::$ins ) {
75
+ self::$ins = new self();
76
+ }
77
+
78
+ return self::$ins;
79
+ }
80
+
81
+ /**
82
+ * Initialize our plugin.
83
+ *
84
+ * @since 1.2
85
+ * @access public
86
+ * @uses add_action
87
+ * @return void
88
+ */
89
+ public static function init() {
90
+ add_action( 'admin_init', array( self::instance(), 'settings' ) );
91
+
92
+ // Backwards compatibility.
93
+ $old = get_option( 'cd_rdte_content' );
94
+ if ( false !== $old ) {
95
+ update_option( self::instance()->setting, $old );
96
+ delete_option( 'cd_rdte_content' );
97
+ }
98
+
99
+ add_filter( 'plugin_action_links', array( self::instance(), 'robtxt_action_links' ), 10, 2 );
100
+ }
101
+
102
+ /**
103
+ * Registers our setting and takes care of adding the settings field
104
+ * we need to edit our robots.txt file
105
+ *
106
+ * @since 1.2
107
+ * @access public
108
+ * @uses register_setting
109
+ * @uses add_settings_field
110
+ * @return void
111
+ */
112
+ public function settings() {
113
+ register_setting(
114
+ 'reading',
115
+ $this->setting,
116
+ array( $this, 'robtxt_clean_setting' )
117
+ );
118
+
119
+ add_settings_section(
120
+ 'robots-txt',
121
+ __( 'Robots.txt Content', 'wp-robots-txt' ),
122
+ '__return_false',
123
+ 'reading'
124
+ );
125
+
126
+ add_settings_field(
127
+ 'robtxt_robots_content',
128
+ __( 'Robots.txt Content', 'wp-robots-txt' ),
129
+ array( $this, 'field' ),
130
+ 'reading',
131
+ 'robots-txt',
132
+ array( 'label_for' => $this->setting )
133
+ );
134
+ }
135
+
136
+ /**
137
+ * Callback for the settings field.
138
+ *
139
+ * @since 1.2
140
+ * @access public
141
+ * @uses get_option
142
+ * @uses esc_attr
143
+ * @return void
144
+ */
145
+ public function field() {
146
+ $content = get_option( $this->setting );
147
+ if ( ! $content ) {
148
+ $content = $this->robtxt_get_default_robots();
149
+ }
150
+
151
+ printf(
152
+ '<textarea name="%1$s" id="%1$s" rows="10" class="large-text">%2$s</textarea>',
153
+ esc_attr( $this->setting ),
154
+ esc_textarea( $content )
155
+ );
156
+
157
+ $robots_link = '<a href="' . site_url() . '/robots.txt" target="_blank">robots.txt</a>';
158
+ echo '<p class="description">';
159
+ /* translators: %s is the link to see your robots.txt file */
160
+ echo wp_kses( sprintf( __( 'The content of your %s file. Delete the above and save to restore the default.', 'wp-robots-txt' ), ( $robots_link ) ), 'post' );
161
+ echo '</p>';
162
+ }
163
+
164
+ /**
165
+ * Strips tags and escapes any html entities that goes into the
166
+ * robots.txt field
167
+ *
168
+ * @since 1.2
169
+ * @param string $contents The contents of the text-area.
170
+ * @uses esc_html
171
+ * @uses add_settings_error
172
+ */
173
+ public function robtxt_clean_setting( $contents ) {
174
+ if ( empty( $contents ) ) {
175
+ add_settings_error(
176
+ $this->setting,
177
+ 'robtxt-restored',
178
+ __( 'Robots.txt restored to default.', 'wp-robots-txt' ),
179
+ 'success'
180
+ );
181
+ }
182
+
183
+ return esc_html( wp_strip_all_tags( $contents ) );
184
+ }
185
+
186
+ /**
187
+ * Get the default robots.txt content.
188
+ *
189
+ * @since 1.2
190
+ * @access protected
191
+ * @uses get_option
192
+ * @return string The default robots.txt content
193
+ */
194
+ protected function robtxt_get_default_robots() {
195
+ $public = get_option( 'blog_public' );
196
+
197
+ $output = "User-agent: *\n";
198
+ if ( '0' === $public ) {
199
+ $output .= "Disallow: /\n";
200
+ } else {
201
+ $site_url = wp_parse_url( site_url(), PHP_URL_PATH );
202
+ $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';
203
+ $output .= "Disallow: $path/wp-admin/\n";
204
+ $output .= "Allow: $path/wp-admin/admin-ajax.php\n";
205
+ $output .= "\nSitemap: " . esc_url( ( new WP_Sitemaps() )->index->get_index_url() ) . "\n";
206
+ }
207
+
208
+ return $output;
209
+ }
210
+
211
+ /**
212
+ * Show custom links in Plugins Page
213
+ *
214
+ * @since 1.2
215
+ * @access public
216
+ * @param array $links Default Links.
217
+ * @param array $file Plugin's root filepath.
218
+ * @return array Links list to display in plugins page.
219
+ */
220
+ public function robtxt_action_links( $links, $file ) {
221
+
222
+ if ( WP_ROBOTS_TXT_BASENAME === $file ) {
223
+ $spf_links = '<a href="' . get_admin_url() . 'options-reading.php" title="Edit your robots.txt">' . __( 'Settings', 'wp-robots-txt' ) . '</a>';
224
+ $spf_visit = '<a href="https://gp-web.dev/" title="Contact" target="_blank" >' . __( 'Contact', 'wp-robots-txt' ) . '</a>';
225
+ array_unshift( $links, $spf_visit );
226
+ array_unshift( $links, $spf_links );
227
+ }
228
+
229
+ return $links;
230
+ }
231
+ }
inc/core-functionality.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Robots Txt
4
+ *
5
+ * Copyright 2013 Christopher Davis <http://christopherdavis.me>
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License, version 2, as
9
+ * published by the Free Software Foundation.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ *
20
+ * Copyright 2022 George Pattihis (gpattihis@gmail.com)
21
+ *
22
+ * "WP Robots Txt" is free software: you can redistribute it and/or modify
23
+ * it under the terms of the GNU General Public License as published by
24
+ * the Free Software Foundation, either version 2 of the License, or
25
+ * any later version.
26
+ *
27
+ * "WP Robots Txt" is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU General Public License for more details.
31
+ *
32
+ * You should have received a copy of the GNU General Public License
33
+ * "along with WP Robots Txt". If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
34
+ *
35
+ * @category WordPress
36
+ * @package WPRobotsTxt
37
+ * @author George Pattihis
38
+ * @copyright 2022 George Pattihis
39
+ * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
40
+ */
41
+
42
+ /**
43
+ * Dynamically create the robots.txt file with our saved content.
44
+ *
45
+ * @since 1.2
46
+ * @uses get_option
47
+ * @uses esc_attr
48
+ * @param string $output The contents of robots.txt filtered.
49
+ * @param string $public The visibility option.
50
+ * @return string
51
+ */
52
+ function robtxt_filter_robots( $output, $public ) {
53
+ $content = get_option( 'robtxt_content' );
54
+ if ( $content ) {
55
+ $output = esc_attr( wp_strip_all_tags( $content ) );
56
+ }
57
+
58
+ return $output;
59
+ }
60
+
61
+ /**
62
+ * Deactivation hook. Deletes our option containing the robots.txt content.
63
+ *
64
+ * @since 1.2
65
+ * @uses delete_option
66
+ * @return void
67
+ */
68
+ function robtxt_deactivation() {
69
+ delete_option( 'robtxt_content' );
70
+ }
71
+
72
+ /**
73
+ * Activation hook. Adds the option we'll be using.
74
+ *
75
+ * @since 1.2
76
+ * @uses add_option
77
+ * @return void
78
+ */
79
+ function robtxt_activation() {
80
+ add_option( 'robtxt_content', false );
81
+
82
+ // Backwards compatibility.
83
+ $old = get_option( 'cd_rdte_content' );
84
+ if ( false !== $old ) {
85
+ update_option( 'robtxt_content', $old );
86
+ delete_option( 'cd_rdte_content' );
87
+ }
88
+ }
inc/core.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- /**
3
- * WP Robots Txt
4
- *
5
- * Copyright 2013 Christopher Davis <http://christopherdavis.me>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License, version 2, as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
- *
20
- * @category WordPress
21
- * @package WPRobotsTxt
22
- * @copyright 2013 Christopher Davis
23
- * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
24
- */
25
-
26
- /**
27
- * Makes the magic happen. Get our saved robots.txt file and, if there's
28
- * something there replace WP's default robots file.
29
- *
30
- * @since 1.0
31
- * @uses get_option
32
- * @uses esc_attr
33
- * @return string
34
- */
35
- function cd_rdte_filter_robots($rv, $public)
36
- {
37
- $content = get_option('cd_rdte_content');
38
- if ($content) {
39
- $rv = esc_attr(strip_tags($content));
40
- }
41
-
42
- return $rv;
43
- }
44
-
45
- /**
46
- * Deactivation hook. Deletes our option containing the robots.txt content
47
- *
48
- * @since 1.0
49
- * @uses delete_option
50
- * @return void
51
- */
52
- function cd_rdte_deactivation()
53
- {
54
- delete_option('cd_rdte_content');
55
- }
56
-
57
- /**
58
- * Activation hook. Adds the option we'll be uses
59
- *
60
- * @since 1.0
61
- * @uses add_option
62
- * @return void
63
- */
64
- function cd_rdte_activation()
65
- {
66
- add_option('cd_rdte_content', false);
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/options-page.php DELETED
@@ -1,168 +0,0 @@
1
- <?php
2
- /**
3
- * WP Robots Txt
4
- *
5
- * Copyright 2013 Christopher Davis <http://christopherdavis.me>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License, version 2, as
9
- * published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
- *
20
- * @category WordPress
21
- * @package WPRobotsTxt
22
- * @copyright 2013 Christopher Davis
23
- * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
24
- */
25
-
26
- /**
27
- * Wrapper for all our admin area functionality.
28
- *
29
- * @since 0.1
30
- */
31
- class CD_RDTE_Admin_Page
32
- {
33
- private static $ins = null;
34
-
35
- protected $setting = 'cd_rdte_content';
36
-
37
- public static function instance()
38
- {
39
- if (null === self::$ins) {
40
- self::$ins = new self();
41
- }
42
-
43
- return self::$ins;
44
- }
45
-
46
- /**
47
- * Kick everything off.
48
- *
49
- * @since 1.0
50
- * @access public
51
- * @uses add_action
52
- * @return void
53
- */
54
- public static function init()
55
- {
56
- add_action('admin_init', array(self::instance(), 'settings'));
57
- }
58
-
59
- /**
60
- * Registers our setting and takes care of adding the settings field
61
- * we need to edit our robots.txt file
62
- *
63
- * @since 1.0
64
- * @access public
65
- * @uses register_setting
66
- * @uses add_settings_field
67
- * @return void
68
- */
69
- public function settings()
70
- {
71
- register_setting(
72
- 'reading',
73
- $this->setting,
74
- array($this, 'cleanSetting')
75
- );
76
-
77
- add_settings_section(
78
- 'robots-txt',
79
- __('Robots.txt Content', 'wp-robots-txt'),
80
- '__return_false',
81
- 'reading'
82
- );
83
-
84
- add_settings_field(
85
- 'cd_rdte_robots_content',
86
- __('Robots.txt Content', 'wp-robots-txt'),
87
- array($this, 'field'),
88
- 'reading',
89
- 'robots-txt',
90
- array('label_for' => $this->setting)
91
- );
92
- }
93
-
94
- /**
95
- * Callback for the settings field.
96
- *
97
- * @since 1.0
98
- * @access public
99
- * @uses get_option
100
- * @uses esc_attr
101
- * @return void
102
- */
103
- public function field()
104
- {
105
- $content = get_option($this->setting);
106
- if (!$content) {
107
- $content = $this->getDefaultRobots();
108
- }
109
-
110
- printf(
111
- '<textarea name="%1$s" id="%1$s" rows="10" class="large-text">%2$s</textarea>',
112
- esc_attr($this->setting),
113
- esc_textarea($content)
114
- );
115
-
116
- echo '<p class="description">';
117
- _e('The content of your robots.txt file. Delete the above and save to restore the default.', 'wp-robots-txt');
118
- echo '</p>';
119
- }
120
-
121
- /**
122
- * Strips tags and escapes any html entities that goes into the
123
- * robots.txt field
124
- *
125
- * @since 1.0
126
- * @uses esc_html
127
- * @uses add_settings_error
128
- */
129
- public function cleanSetting($in)
130
- {
131
- if(empty($in)) {
132
- // TODO: why does this kill the default settings message?
133
- add_settings_error(
134
- $this->setting,
135
- 'cd-rdte-restored',
136
- __('Robots.txt restored to default.', 'wp-robots-txt'),
137
- 'updated'
138
- );
139
- }
140
-
141
- return esc_html(strip_tags($in));
142
- }
143
-
144
- /**
145
- * Get the default robots.txt content. This is copied straight from
146
- * WP's `do_robots` function
147
- *
148
- * @since 1.0
149
- * @access protected
150
- * @uses get_option
151
- * @return string The default robots.txt content
152
- */
153
- protected function getDefaultRobots()
154
- {
155
- $public = get_option('blog_public');
156
-
157
- $output = "User-agent: *\n";
158
- if ('0' == $public) {
159
- $output .= "Disallow: /\n";
160
- } else {
161
- $path = parse_url(site_url(), PHP_URL_PATH);
162
- $output .= "Disallow: $path/wp-admin/\n";
163
- $output .= "Disallow: $path/wp-includes/\n";
164
- }
165
-
166
- return $output;
167
- }
168
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,13 @@
1
  === WP Robots Txt ===
2
- Contributors: chrisguitarguy
3
- Donate link: http://www.pwsausa.org/give.htm
4
  Tags: robots.txt, robots, seo
5
- Requires at least: 3.3
6
- Tested up to: 3.6
7
- Stable tag: 1.1
 
 
 
8
 
9
  WP Robots Txt Allows you to edit the content of your robots.txt file.
10
 
@@ -14,6 +17,12 @@ WordPress, by default, includes a simple robots.txt file that's dynamically gene
14
 
15
  Enter WP Robots Txt, a plugin that adds an additional field to the "Reading" admin page where you can do just that.
16
 
 
 
 
 
 
 
17
  == Installation ==
18
 
19
  1. Download the plugin
@@ -39,21 +48,28 @@ Yes. Be careful! That said, `robots.txt` files are suggestions. They don't real
39
 
40
  = Where can I learn more about `robots.txt` files? =
41
 
42
- [Here](https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt).
43
 
44
  == Changelog ==
45
 
46
- = 1.0 =
47
- * Initial version
 
 
 
 
48
 
49
  = 1.1 =
50
  * Moved the settings field "officially" to the reading page
51
  * General code clean up
52
 
53
- == Upgrade Notice ==
54
-
55
  = 1.0 =
56
- * Everyone wants to edit their `robots.txt` files.
 
 
57
 
58
  = 1.1 =
59
  * Should actually work in 3.5+ now
 
 
 
1
  === WP Robots Txt ===
2
+ Contributors: chrisguitarguy, pattihis
3
+ Donate link: https://profiles.wordpress.org/pattihis/
4
  Tags: robots.txt, robots, seo
5
+ Requires at least: 5.3.0
6
+ Tested up to: 6.0.1
7
+ Requires PHP: 5.6
8
+ Stable tag: 1.2
9
+ License: GPL2
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
  WP Robots Txt Allows you to edit the content of your robots.txt file.
13
 
17
 
18
  Enter WP Robots Txt, a plugin that adds an additional field to the "Reading" admin page where you can do just that.
19
 
20
+ Simply visit https://your-site.com/wp-admin/options-reading.php and you can control the contents of your https://your-site.com/robots.txt
21
+
22
+ [Changelog](https://wordpress.org/plugins/wp-robots-txt/#developers)
23
+
24
+ *WP Robots Txt* was originally developed by [chrisguitarguy](https://profiles.wordpress.org/chrisguitarguy/). The plugin has been adopted and updated by [George Pattihis](https://profiles.wordpress.org/pattihis/) who will continue development.
25
+
26
  == Installation ==
27
 
28
  1. Download the plugin
48
 
49
  = Where can I learn more about `robots.txt` files? =
50
 
51
+ [Here](https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt) is a general guide by Google and [here](https://wordpress.org/support/article/search-engine-optimization/) is the WordPress SEO documentation.
52
 
53
  == Changelog ==
54
 
55
+ = 1.2 =
56
+ * Update the default robots.txt content
57
+ * Include sitemap reference
58
+ * Resolve code warnings/errors
59
+ * WP Coding Standards compliant
60
+ * Ensure Compatibility with WP v6
61
 
62
  = 1.1 =
63
  * Moved the settings field "officially" to the reading page
64
  * General code clean up
65
 
 
 
66
  = 1.0 =
67
+ * Initial version
68
+
69
+ == Upgrade Notice ==
70
 
71
  = 1.1 =
72
  * Should actually work in 3.5+ now
73
+
74
+ = 1.0 =
75
+ * Everyone wants to edit their `robots.txt` files.
robots-txt.php CHANGED
@@ -1,18 +1,33 @@
1
  <?php
2
  /**
 
 
 
 
 
 
 
 
 
3
  * Plugin Name: WP Robots Txt
4
- * Plugin URI: https://github.com/chrisguitarguy/WP-Robots-Txt
5
  * Description: Edit your robots.txt file from the WordPress admin
6
- * Version: 1.1
7
- * Text Domain: wp-robots-txt
8
- * Author: Christopher Davis
9
- * Author URI: http://christopherdavis.me
 
 
10
  * License: GPL-2.0+
11
- *
 
 
 
 
12
  * Copyright 2013 Christopher Davis <http://christopherdavis.me>
13
  *
14
  * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License, version 2, as
16
  * published by the Free Software Foundation.
17
  *
18
  * This program is distributed in the hope that it will be useful,
@@ -23,23 +38,66 @@
23
  * You should have received a copy of the GNU General Public License
24
  * along with this program; if not, write to the Free Software
25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 
 
 
26
  *
27
- * @category WordPress
28
- * @package WPRobotsTxt
29
- * @copyright 2013 Christopher Davis
30
- * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  */
 
32
 
33
- !defined('ABSPATH') && exit;
34
 
35
- define('WP_ROBOTS_TXT_DIR', plugin_dir_path(__FILE__));
 
 
 
 
 
 
 
 
36
 
37
- require_once WP_ROBOTS_TXT_DIR . 'inc/core.php';
38
- if (is_admin()) {
39
- require_once WP_ROBOTS_TXT_DIR . 'inc/options-page.php';
40
- CD_RDTE_Admin_Page::init();
 
 
41
  }
42
 
43
- add_filter('robots_txt', 'cd_rdte_filter_robots', 10, 2);
44
- register_activation_hook(__FILE__, 'cd_rdte_activation');
45
- register_deactivation_hook(__FILE__, 'cd_rdte_deactivation');
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
+ * WP Robots Txt
4
+ *
5
+ * @category WordPress
6
+ * @package WPRobotsTxt
7
+ * @author George Pattihis
8
+ * @copyright 2022 George Pattihis
9
+ * @license http://opensource.org/licenses/GPL-2.0 GPL-2.0+
10
+ * @link https://profiles.wordpress.org/pattihis/
11
+ *
12
  * Plugin Name: WP Robots Txt
13
+ * Plugin URI: https://github.com/pattihis/wp-robots.txt
14
  * Description: Edit your robots.txt file from the WordPress admin
15
+ * Version: 1.2
16
+ * Requires at least: 5.3.0
17
+ * Tested up to: 6.0.1
18
+ * Requires PHP: 5.6
19
+ * Author: George Pattihis
20
+ * Author URI: https://profiles.wordpress.org/pattihis/
21
  * License: GPL-2.0+
22
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
23
+ * Text Domain: wp-robots-txt
24
+ */
25
+
26
+ /**
27
  * Copyright 2013 Christopher Davis <http://christopherdavis.me>
28
  *
29
  * This program is free software; you can redistribute it and/or modify
30
+ * it under the terms of the GNU General Public License, version 2, as
31
  * published by the Free Software Foundation.
32
  *
33
  * This program is distributed in the hope that it will be useful,
38
  * You should have received a copy of the GNU General Public License
39
  * along with this program; if not, write to the Free Software
40
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
41
+ */
42
+
43
+ /**
44
+ * Copyright 2022 George Pattihis (gpattihis@gmail.com)
45
  *
46
+ * "WP Robots Txt" is free software: you can redistribute it and/or modify
47
+ * it under the terms of the GNU General Public License as published by
48
+ * the Free Software Foundation, either version 2 of the License, or
49
+ * any later version.
50
+ *
51
+ * "WP Robots Txt" is distributed in the hope that it will be useful,
52
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
53
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54
+ * GNU General Public License for more details.
55
+ *
56
+ * You should have received a copy of the GNU General Public License
57
+ * "along with WP Robots Txt". If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
58
+ */
59
+
60
+ // Exit if accessed directly.
61
+ if ( ! defined( 'ABSPATH' ) ) {
62
+ exit;
63
+ }
64
+
65
+ /**
66
+ * Current plugin version.
67
  */
68
+ define( 'WP_ROBOTS_TXT_VERSION', '1.2.0' );
69
 
70
+ define( 'WP_ROBOTS_TXT_DIR', plugin_dir_path( __FILE__ ) );
71
 
72
+ /**
73
+ * Plugin's basename
74
+ */
75
+ define( 'WP_ROBOTS_TXT_BASENAME', plugin_basename( __FILE__ ) );
76
+
77
+ /**
78
+ * The core plugin file that is used to run our functionality.
79
+ */
80
+ require_once WP_ROBOTS_TXT_DIR . 'inc/core-functionality.php';
81
 
82
+ /**
83
+ * The core plugin class that is used to define admin options and hooks.
84
+ */
85
+ if ( is_admin() ) {
86
+ require_once WP_ROBOTS_TXT_DIR . 'inc/class-robtxt-admin-page.php';
87
+ ROBTXT_Admin_Page::init();
88
  }
89
 
90
+ /**
91
+ * The main hook that filters the contents of the generated file.
92
+ */
93
+ add_filter( 'robots_txt', 'robtxt_filter_robots', 10, 2 );
94
+
95
+ /**
96
+ * The code that runs during plugin activation.
97
+ */
98
+ register_activation_hook( __FILE__, 'robtxt_activation' );
99
+
100
+ /**
101
+ * The code that runs during plugin deactivation.
102
+ */
103
+ register_deactivation_hook( __FILE__, 'robtxt_deactivation' );
screenshot-1.png DELETED
Binary file