Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
QWp6t authored and retlehs committed May 20, 2020
0 parents commit 6c28192
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_size = 4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
/vendor

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Roots

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<p align="center">
<a href="https://roots.io/bedrock/">
<img alt="Bedrock" src="https://cdn.roots.io/app/uploads/logo-bedrock.svg" height="100">
</a>
</p>

<p align="center">
<a href="LICENSE.md">
<img alt="MIT License" src="https://img.shields.io/github/license/roots/bedrock-disallow-indexing?color=%23525ddc&style=flat-square" />
</a>

<a href="https://packagist.org/packages/roots/bedrock-disallow-indexing">
<img alt="Packagist" src="https://img.shields.io/packagist/v/roots/bedrock-disallow-indexing.svg?style=flat-square" />
</a>

<a href="https://twitter.com/rootswp">
<img alt="Follow Roots" src="https://img.shields.io/twitter/follow/rootswp.svg?style=flat-square&color=1da1f2" />
</a>
</p>

<p align="center">
<strong>Bedrock Disallow Indexing</strong>
</p>

<p align="center">
<a href="https://roots.io/">Roots Website</a> | <a href="https://roots.io/docs/bedrock/master/installation/">Bedrock Documentation</a>
</p>

## Overview

This plugin will prevent indexing of a site when `WP_ENV` is not set to `production`.
32 changes: 32 additions & 0 deletions bedrock-disallow-indexing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/*
Plugin Name: Disallow Indexing
Plugin URI: https://roots.io/bedrock/
Description: Disallow indexing of your site on non-production environments.
Version: 2.0.0
Author: Roots
Author URI: https://roots.io/
Text Domain: roots
License: MIT License
*/

if (!defined('DISALLOW_INDEXING') || DISALLOW_INDEXING !== true) {
return;
}

add_action('pre_option_blog_public', '__return_zero');

add_action('admin_init', function () {
if (!apply_filters('roots/bedrock/disallow_indexing_admin_notice', true)) {
return;
}

add_action('admin_notices', function () {
$message = sprintf(
__('%1$s Search engine indexing has been discouraged because the current environment is %2$s.', 'roots'),
'<strong>Bedrock:</strong>',
'<code>'.WP_ENV.'</code>'
);
echo "<div class='notice notice-warning'><p>{$message}</p></div>";
});
});
33 changes: 33 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "roots/bedrock-disallow-indexing",
"type": "wordpress-muplugin",
"license": "MIT",
"description": "Disallow indexing of your site on non-production environments",
"authors": [
{
"name": "Ben Word",
"email": "ben@benword.com",
"homepage": "https://github.com/retlehs"
},
{
"name": "Scott Walkinshaw",
"email": "scott.walkinshaw@gmail.com",
"homepage": "https://github.com/swalkinshaw"
},
{
"name": "QWp6t",
"email": "hi@qwp6t.me",
"homepage": "https://github.com/qwp6t"
}
],
"keywords": [
"wordpress"
],
"support": {
"issues": "https://github.com/roots/bedrock-disallow-indexing/issues",
"forum": "https://discourse.roots.io/"
},
"require": {
"php": ">=7.1"
}
}

0 comments on commit 6c28192

Please sign in to comment.