Skip to content

Commit 6c28192

Browse files
QWp6tretlehs
authored andcommitted
Initial commit
0 parents  commit 6c28192

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
13+
[*.php]
14+
indent_size = 4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
/vendor
3+

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Roots
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<p align="center">
2+
<a href="https://roots.io/bedrock/">
3+
<img alt="Bedrock" src="https://cdn.roots.io/app/uploads/logo-bedrock.svg" height="100">
4+
</a>
5+
</p>
6+
7+
<p align="center">
8+
<a href="LICENSE.md">
9+
<img alt="MIT License" src="https://img.shields.io/github/license/roots/bedrock-disallow-indexing?color=%23525ddc&style=flat-square" />
10+
</a>
11+
12+
<a href="https://packagist.org/packages/roots/bedrock-disallow-indexing">
13+
<img alt="Packagist" src="https://img.shields.io/packagist/v/roots/bedrock-disallow-indexing.svg?style=flat-square" />
14+
</a>
15+
16+
<a href="https://twitter.com/rootswp">
17+
<img alt="Follow Roots" src="https://img.shields.io/twitter/follow/rootswp.svg?style=flat-square&color=1da1f2" />
18+
</a>
19+
</p>
20+
21+
<p align="center">
22+
<strong>Bedrock Disallow Indexing</strong>
23+
</p>
24+
25+
<p align="center">
26+
<a href="https://roots.io/">Roots Website</a> | <a href="https://roots.io/docs/bedrock/master/installation/">Bedrock Documentation</a>
27+
</p>
28+
29+
## Overview
30+
31+
This plugin will prevent indexing of a site when `WP_ENV` is not set to `production`.

bedrock-disallow-indexing.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
Plugin Name: Disallow Indexing
4+
Plugin URI: https://roots.io/bedrock/
5+
Description: Disallow indexing of your site on non-production environments.
6+
Version: 2.0.0
7+
Author: Roots
8+
Author URI: https://roots.io/
9+
Text Domain: roots
10+
License: MIT License
11+
*/
12+
13+
if (!defined('DISALLOW_INDEXING') || DISALLOW_INDEXING !== true) {
14+
return;
15+
}
16+
17+
add_action('pre_option_blog_public', '__return_zero');
18+
19+
add_action('admin_init', function () {
20+
if (!apply_filters('roots/bedrock/disallow_indexing_admin_notice', true)) {
21+
return;
22+
}
23+
24+
add_action('admin_notices', function () {
25+
$message = sprintf(
26+
__('%1$s Search engine indexing has been discouraged because the current environment is %2$s.', 'roots'),
27+
'<strong>Bedrock:</strong>',
28+
'<code>'.WP_ENV.'</code>'
29+
);
30+
echo "<div class='notice notice-warning'><p>{$message}</p></div>";
31+
});
32+
});

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "roots/bedrock-disallow-indexing",
3+
"type": "wordpress-muplugin",
4+
"license": "MIT",
5+
"description": "Disallow indexing of your site on non-production environments",
6+
"authors": [
7+
{
8+
"name": "Ben Word",
9+
"email": "[email protected]",
10+
"homepage": "https://github.com/retlehs"
11+
},
12+
{
13+
"name": "Scott Walkinshaw",
14+
"email": "[email protected]",
15+
"homepage": "https://github.com/swalkinshaw"
16+
},
17+
{
18+
"name": "QWp6t",
19+
"email": "[email protected]",
20+
"homepage": "https://github.com/qwp6t"
21+
}
22+
],
23+
"keywords": [
24+
"wordpress"
25+
],
26+
"support": {
27+
"issues": "https://github.com/roots/bedrock-disallow-indexing/issues",
28+
"forum": "https://discourse.roots.io/"
29+
},
30+
"require": {
31+
"php": ">=7.1"
32+
}
33+
}

0 commit comments

Comments
 (0)