Redirect - Version 4.0.1

Version Description

Download this release

Release Info

Developer willshouse
Plugin Icon wp plugin Redirect
Version 4.0.1
Comparing to
See all releases

Code changes from version 3.0.1 to 4.0.1

Files changed (2) hide show
  1. readme.txt +5 -7
  2. simple-redirect.php +27 -7
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
- === Simple Redirect ===
2
  Contributors: Get on Social
3
- Tags: redirect, headers, posts, redirection, simple, easy, SEO, 301
4
  Requires at least: 2.5
5
- Tested up to: 3.6
6
- Stable tag: /trunk/
7
 
8
  Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. Check out the screenshots. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
9
 
10
- == Description ==
11
 
12
  Simple redirection from pages or posts with an easy to use menu.
13
 
@@ -23,5 +23,3 @@ Simple redirection from pages or posts with an easy to use menu.
23
  == Screenshots ==
24
 
25
  1. Use the meta box to add or edit permalinks
26
- 2. Easily choose existing content with a popup menu
27
- 3. Link to a custom URL, existing content, or disable redirection
1
+ === Redirect ===
2
  Contributors: Get on Social
3
+ Tags: redirect, redirects, headers, posts, redirection, simple, easy, SEO, 301
4
  Requires at least: 2.5
5
+ Tested up to: 4.0
6
+ Stable tag: 4.0.1
7
 
8
  Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. Check out the screenshots. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
9
 
10
+ == Description and Use ==
11
 
12
  Simple redirection from pages or posts with an easy to use menu.
13
 
23
  == Screenshots ==
24
 
25
  1. Use the meta box to add or edit permalinks
 
 
simple-redirect.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
2
  /*
3
  * Plugin Name: Simple Redirect
4
- * Version: 3.0.1
5
  * Description: Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
6
  * Author: Get on Social
 
7
  * Author URI: http://www.getonsocial.com/?simpleredirect
8
  * License: GPL v3
9
 
@@ -16,31 +17,46 @@ class GosSimpleRedirect
16
 
17
  var $namespace = 'gos_simple_redirect';
18
  var $title = 'Simple Redirect';
19
- var $postTypes = array();
20
  var $context = 'side';
21
  var $priority = 'default';
22
 
23
  function __construct()
24
  {
25
 
26
- $this->postTypes = get_post_types();
 
 
 
 
 
 
 
 
 
27
  add_action( 'load-post.php', array($this,'load_post') );
28
  add_action( 'load-post-new.php', array($this,'load_post') );
29
 
 
30
  add_action( 'admin_footer-post-new.php', array($this,'footerjs'), 9999 );
31
  add_action( 'admin_footer-post.php', array($this,'footerjs'), 9999 );
32
 
33
-
34
  add_action( 'wp_ajax_'.$this->namespace, array($this,'wp_ajax'), 9999 );
35
- add_action('template_redirect',array($this,'template_redirect'), 10 );
36
 
 
 
37
 
 
38
  add_filter('post_link',array($this,'post_link'),20,2);
39
  add_filter('post_type_link',array($this,'post_link'),20,2);
40
 
 
 
 
 
 
41
  add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
42
 
43
-
44
  }
45
 
46
 
@@ -163,7 +179,11 @@ class GosSimpleRedirect
163
  function add_meta_boxes()
164
  {
165
 
166
- foreach($this->postTypes as $postType)
 
 
 
 
167
  {
168
  add_meta_box(
169
  $this->namespace,
1
  <?php
2
  /*
3
  * Plugin Name: Simple Redirect
4
+ * Version: 4.0.1
5
  * Description: Easily redirect any post or page to another page with a dropdown menu or by manually typing in a URL. This plugin also changes permalinks and menus to point directly to the new location of the redirect - this prevents bots from getting a redirect and helps boost your SEO.
6
  * Author: Get on Social
7
+ * Contributors: Get on Social, khromov
8
  * Author URI: http://www.getonsocial.com/?simpleredirect
9
  * License: GPL v3
10
 
17
 
18
  var $namespace = 'gos_simple_redirect';
19
  var $title = 'Simple Redirect';
 
20
  var $context = 'side';
21
  var $priority = 'default';
22
 
23
  function __construct()
24
  {
25
 
26
+ // special thanks to @khromov for the register_hooks improvement
27
+ add_action('init', array($this, 'register_hooks'));
28
+
29
+ }
30
+
31
+ function register_hooks()
32
+ {
33
+
34
+
35
+ // hooks for loading the meta boxes on the post page
36
  add_action( 'load-post.php', array($this,'load_post') );
37
  add_action( 'load-post-new.php', array($this,'load_post') );
38
 
39
+ // javascript for the footer of creating new posts and editing posts
40
  add_action( 'admin_footer-post-new.php', array($this,'footerjs'), 9999 );
41
  add_action( 'admin_footer-post.php', array($this,'footerjs'), 9999 );
42
 
43
+ // ajax calls
44
  add_action( 'wp_ajax_'.$this->namespace, array($this,'wp_ajax'), 9999 );
 
45
 
46
+ // for the actual redirect
47
+ add_action('template_redirect',array($this,'template_redirect'), 10 );
48
 
49
+ // rewrite links to 301'd pages preemptively
50
  add_filter('post_link',array($this,'post_link'),20,2);
51
  add_filter('post_type_link',array($this,'post_link'),20,2);
52
 
53
+ // rewrite nav menu links to 301'd pages preemptively.
54
+ // i.e. when people create a top-level menu item to go to a subpage, such
55
+ // as when you have a structure like /about/ and /about/about-us/ and /about/contact/
56
+ // but /about/ just redirects to /about/about-us/ - the menu link is rewritten to
57
+ // prevent an extra 301 "hop"
58
  add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
59
 
 
60
  }
61
 
62
 
179
  function add_meta_boxes()
180
  {
181
 
182
+ // allow use of a filter to modify the enabled post types
183
+ // eg: add_filter('gos_simple_redirect_enabled_post_types', ... )
184
+ $enabledPostTypes = apply_filters( 'gos_simple_redirect_enabled_post_types', get_post_types() );
185
+
186
+ foreach($enabledPostTypes as $postType)
187
  {
188
  add_meta_box(
189
  $this->namespace,