Plugin Directory

Changeset 990782


Ignore:
Timestamp:
09/16/2014 04:51:08 AM (11 years ago)
Author:
willshouse
Message:

updates for 4.0, hook improvements (thanks to khromov), added a post_type filter, added comments

Location:
simple-redirect/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-redirect/trunk/readme.txt

    r757451 r990782  
    1 === Simple Redirect ===
     1=== Redirect ===
    22Contributors: Get on Social
    3 Tags: redirect, headers, posts, redirection, simple, easy, SEO, 301
     3Tags: redirect, redirects, headers, posts, redirection, simple, easy, SEO, 301
    44Requires at least: 2.5
    5 Tested up to: 3.6
    6 Stable tag: /trunk/
     5Tested up to: 4.0
     6Stable tag: 4.0.1
    77
    88Easily 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.
    99
    10 == Description ==
     10== Description and Use ==
    1111
    1212Simple redirection from pages or posts with an easy to use menu.
     
    2424
    25251. 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
  • simple-redirect/trunk/simple-redirect.php

    r757440 r990782  
    22/*
    33 * Plugin Name: Simple Redirect
    4  * Version: 3.0.1
     4 * Version: 4.0.1
    55 * 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.
    66 * Author: Get on Social
     7 * Contributors: Get on Social, khromov
    78 * Author URI: http://www.getonsocial.com/?simpleredirect
    89 * License: GPL v3
     
    1718        var $namespace = 'gos_simple_redirect';
    1819        var $title = 'Simple Redirect';
    19         var $postTypes = array();
    2020        var $context = 'side';
    2121        var $priority = 'default';
     
    2424        {
    2525
    26             $this->postTypes = get_post_types();
     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
    2736            add_action( 'load-post.php', array($this,'load_post') );
    2837            add_action( 'load-post-new.php', array($this,'load_post') );
    2938
     39            // javascript for the footer of creating new posts and editing posts
    3040            add_action( 'admin_footer-post-new.php', array($this,'footerjs'), 9999 );
    3141            add_action( 'admin_footer-post.php',     array($this,'footerjs'), 9999 );
    3242
    33 
     43            // ajax calls
    3444            add_action( 'wp_ajax_'.$this->namespace, array($this,'wp_ajax'), 9999 );
     45
     46            // for the actual redirect
    3547            add_action('template_redirect',array($this,'template_redirect'), 10 );
    3648
    37 
     49            // rewrite links to 301'd pages preemptively
    3850            add_filter('post_link',array($this,'post_link'),20,2);
    3951            add_filter('post_type_link',array($this,'post_link'),20,2);
    4052
     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"
    4158            add_filter('wp_nav_menu_objects',array($this,'wp_nav_menu_objects'));
    42 
    4359
    4460        }
     
    164180        {
    165181
    166             foreach($this->postTypes as $postType)
     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)
    167187            {
    168188                add_meta_box(
Note: See TracChangeset for help on using the changeset viewer.