-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8aae6ae
Showing
7 changed files
with
287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
sftp-config.json | ||
|
||
# Third-party dependencies | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Changelog for Redirect Unattached Images ## | ||
|
||
### 0.1.1 | ||
|
||
Made a minor improvement to the way attachments are checked before being redirected. | ||
|
||
### 0.1.0 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Redirect Unattached Images # | ||
|
||
Redirect WordPress attachment pages for all unattached images to the current site's home page. | ||
|
||
__Contributors:__ [Robert Neu](https://github.com/robneu), [Ozzy Rodriguez](https://github.com/ozzyrod) | ||
__Requires:__ 4.1.2 | ||
__Tested up to:__ 4.9.8 | ||
__License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html) | ||
|
||
## Description ## | ||
|
||
The default behavior in WordPress is to generate attachment pages for all of the images in your media library. While this can sometimes be useful, it can also cause problems. | ||
|
||
When you upload an image to your media library without inserting it into a post or page, it becomes an unattached image. By default, these images generate attachment pages with no pretty permalink structure. This isn't very useful for anyone, including search engines. | ||
|
||
This plugin takes all of these unattached images and safely redirects them using a 301 redirect to your site's home page. If you're using WordPress multisite, it redirects to the current site's home page. There are no options or settings, just install, activate, and enjoy better SEO and fewer useless pages on your website! | ||
|
||
## Installation ## | ||
|
||
### Upload ### | ||
|
||
1. Download the [latest release](https://github.com/wpsitecare/redirect-unattached-images/archive/master.zip) from GitHub. | ||
2. Go to the __Plugins → Add New__ screen in your WordPress admin panel and click the __Upload__ tab at the top. | ||
3. Upload the zipped archive. | ||
4. Click the __Activate Plugin__ link after installation completes. | ||
|
||
### Manual ### | ||
|
||
1. Download the [latest release](https://github.com/wpsitecare/redirect-unattached-images/archive/master.zip) from GitHub. | ||
2. Unzip the archive. | ||
3. Copy the folder to `/wp-content/plugins/`. | ||
4. Go to the __Plugins__ screen in your WordPress admin panel and click the __Activate__ link under Redirect Unattached Images. | ||
|
||
Read the Codex for more information about [installing plugins manually](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). | ||
|
||
### Git ### | ||
|
||
Clone this repository in `/wp-content/plugins/`: | ||
|
||
`git clone https://github.com/wpsitecare/redirect-unattached-images.git` | ||
|
||
Then go to the __Plugins__ screen in your WordPress admin panel and click the __Activate__ link under Redirect Unattached Images. | ||
|
||
## Updating ## | ||
|
||
Although it's not likely that this plugin will need updated, there is always the possibility that a change will be required. Fortunately, there are a couple of options you can install to manage updates from GitHub-hosted plugins: | ||
|
||
* [Git Plugin Updates](https://github.com/brainstormmedia/git-plugin-updates) | ||
* [GitHub Updater](https://github.com/afragen/github-updater) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "cipherdevelopment/redirect-unattached-images", | ||
"description": "Redirect attachment pages for all unattached images to the current site's home page.", | ||
"type": "wordpress-plugin", | ||
"homepage": "https://cipherdevelopment.com", | ||
"authors": [ | ||
{ | ||
"name": "Robert Neu", | ||
"email": "rob@cipherdevelopment.com", | ||
"homepage": "https://cipherdevelopment.com" | ||
}, | ||
{ | ||
"name": "Ozzy Rodriguez", | ||
"email": "ozzy@cipherdevelopment.com", | ||
"homepage": "https://cipherdevelopment.com" | ||
} | ||
], | ||
"require": { | ||
"composer/installers": "~1.0" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
=== Redirect Unattached Images === | ||
Contributors: fatmedia, ozzyr, cipherdevgroup | ||
Donate link: https://cipherdevelopment.com | ||
Tags: images, galleries, 301, redirect, SEO, search engine optimization | ||
Requires at least: 4.1.2 | ||
Tested up to: 4.9.8 | ||
Stable tag: 0.1.2 | ||
License: GPLv2 or later | ||
License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
Redirect attachment pages for all unattached images to the current site's home page. | ||
|
||
== Description == | ||
|
||
The default behavior in WordPress is to generate attachment pages for all of the images in your media library. While this can sometimes be useful, it can also cause problems. | ||
|
||
When you upload an image to your media library without inserting it into a post or page, it becomes an unattached image. By default, these images generate attachment pages with no pretty permalink structure. This isn't very useful for anyone, including search engines. | ||
|
||
This plugin takes all of these unattached images and safely redirects them using a 301 redirect to your site's home page. If you're using WordPress multisite, it redirects to the current site's home page. There are no options or settings, just install, activate, and enjoy better SEO and less useless pages on your website! | ||
|
||
== Installation == | ||
|
||
The easiest way to install this plugin is to download directly form the WordPress admin panel and active the plugin. Alternatively, you can download it and install it manually by doing the following: | ||
|
||
1. Upload the `redirect-unattached-images` directory to the `/wp-content/plugins/` directory | ||
2. Activate the plugin through the 'Plugins' menu in WordPress | ||
3. Sit back and relax. You're done! | ||
|
||
== Frequently Asked Questions == | ||
|
||
None yet! | ||
|
||
== Changelog == | ||
|
||
= 0.1.2 = | ||
Change of ownership. | ||
|
||
= 0.1.1 = | ||
Made a minor improvement to the way attachments are checked before being redirected. | ||
|
||
= 0.1.0 = | ||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Redirect Unattached Images | ||
* Plugin URI: https://cipherdevelopment.com/redirect-unattached-images/ | ||
* Description: Redirect attachment pages for all unattached images to the current site's home page. | ||
* Version: 0.1.2 | ||
* Author: Cipher | ||
* Author URI: https://cipherdevelopment.com | ||
* License: GPL-2.0+ | ||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
* | ||
* Git URI: https://github.com/cipherdevgroup/redirect-unattached-images | ||
* GitHub Plugin URI: https://github.com/cipherdevgroup/redirect-unattached-images | ||
* GitHub Branch: master | ||
* | ||
* @package RedirectUnattachedImages | ||
* @category Core | ||
* @author Robert Neu | ||
* @version 0.1.0 | ||
*/ | ||
|
||
// Exit if accessed directly. | ||
defined( 'ABSPATH' ) || exit; | ||
|
||
add_action( 'template_redirect', 'cipher_redirect_unattached_images' ); | ||
/** | ||
* Redirects the attachment page for any image which has not been attached to a | ||
* post, page, or custom post type to the current site's home URL. | ||
* | ||
* @since 0.1.0 | ||
* @uses is_attachment() | ||
* @uses get_queried_object() | ||
* @return void | ||
*/ | ||
function cipher_redirect_unattached_images() { | ||
if ( ! is_attachment() ) { | ||
return; | ||
} | ||
$parent = get_queried_object()->post_parent; | ||
if ( ! empty( $parent ) ) { | ||
return; | ||
} | ||
wp_safe_redirect( | ||
esc_url_raw( apply_filters( 'cipher_redirect_unattached_images', get_home_url() ) ), | ||
301 | ||
); | ||
exit; | ||
} |