Changeset 841255
- Timestamp:
- 01/19/2014 11:38:49 AM (12 years ago)
- Location:
- anylink/trunk
- Files:
-
- 5 edited
-
anyLink.php (modified) (5 diffs)
-
classes/al_filter.php (modified) (1 diff)
-
classes/al_option.php (modified) (1 diff)
-
functions.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
anylink/trunk/anyLink.php
r836042 r841255 4 4 Plugin URI: http://dudo.org/anylink 5 5 Description: anyLink is an external links management tool. It help you to covert all the external links in your posts into internal links automatically. It can prevent the website weight flow outside to others. It's absolutely SEO friendly. 6 Version: 0.1. 56 Version: 0.1.6 7 7 Author: dudo 8 8 Author URI: http://dudo.org/about … … 14 14 require_once( ANYLNK_PATH . '/classes/al_filter.php' ); 15 15 require_once( ANYLNK_PATH . '/classes/al_slug.php' ); 16 require_once( 'functions.php' );16 require_once( ANYLNK_PATH . '/functions.php' ); 17 17 require_once( ANYLNK_PATH . '/classes/al_option.php' ); 18 register_activation_hook( __FILE__, 'anylnkInstall' ); 18 19 19 $filter = new al_filter(); 20 20 $alOption = new al_option(); 21 22 register_activation_hook( __FILE__, 'anylnkInstall' ); 21 23 add_action( 'transition_post_status', 'post_published', 10, 3 ); 22 24 add_action( 'wp_loaded','checkFlush' ); 25 add_filter( 'query_vars', array( $filter, 'addQueryVars' ) ); 26 add_action( 'parse_request', array( &$filter, 'alter_the_query' ) ); 27 add_action( 'plugins_loaded', 'al_load_textdomain' ); 28 add_filter( 'the_content', 'filterByType' ); 29 add_filter( 'rewrite_rules_array','anylink_rewrite_rules' ); 23 30 24 31 /** … … 30 37 * @since version 0.1.5 31 38 */ 32 function checkFlush() {39 function checkFlush() { 33 40 $rules = get_option( 'rewrite_rules' ); 34 41 $alOption = get_option( 'anylink_options' ); 35 42 $cat = $alOption['redirectCat']; 36 37 if( ! isset( $rules[$cat . '/([0-9a-z]{4,})'] ) ){ 43 if( ! isset( $rules[$cat . '/([0-9a-z]{4,})/?$'] ) ){ 38 44 global $wp_rewrite; 39 45 $wp_rewrite -> flush_rules(); 40 46 } 41 47 } 48 49 //add rewrite rules 50 function anylink_rewrite_rules( $rules ) { 51 $alOption = get_option( 'anylink_options' ); 52 $cat = $alOption['redirectCat']; 53 $newrules = array(); 54 $newrules[$cat . '/([0-9a-z]{4,})/?$'] = 'index.php?' . $cat . '=$matches[1]'; 55 return $newrules + $rules; 56 } 57 42 58 /** 43 59 * This function is to replace old ACTTION hook 'publish_post' … … 58 74 } 59 75 } 60 61 add_filter( 'the_content', 'filterByType' );62 76 63 77 /** … … 88 102 } 89 103 } 90 91 add_filter('query_vars', array( &$filter, 'addQueryVars' ) );92 add_action( 'parse_request', array( &$filter, 'alter_the_query' ) );93 add_action( 'plugins_loaded', 'al_load_textdomain' );94 104 ?> -
anylink/trunk/classes/al_filter.php
r836042 r841255 57 57 } 58 58 public function addQueryVars( $qvars ) { 59 $qvars[] = $this -> redirectCat;59 array_push( $qvars, $this -> redirectCat ); 60 60 return $qvars; 61 61 } -
anylink/trunk/classes/al_option.php
r834848 r841255 145 145 $redirectFile = substr( plugins_url(), strlen( home_url() ) + 1 ) . '/' . ANYLNK_PLUGIN . '/redirect.php'; 146 146 /* add an external rewrite rule which will be written into .htaccess file */ 147 $wp_rewrite -> add_external_rule( "$cat/([0-9a-z]{4,}) ", $redirectFile . '?slug=$1' );147 $wp_rewrite -> add_external_rule( "$cat/([0-9a-z]{4,})/?$", $redirectFile . '?slug=$1' ); 148 148 flush_rewrite_rules(); 149 149 } else { 150 150 $wp_rewrite -> flush_rules( true ); 151 add_rewrite_rule( "$cat/([0-9a-z]{4,}) ", 'index.php?' . $cat . '=$matches[1]', 'top' );151 add_rewrite_rule( "$cat/([0-9a-z]{4,})/?$", 'index.php?' . $cat . '=$matches[1]', 'top' ); 152 152 flush_rewrite_rules(); 153 153 } -
anylink/trunk/functions.php
r836042 r841255 1 1 <?php 2 2 defined( 'ABSPATH' ) OR exit; 3 if(!function_exists('_log')){ 4 function _log( $str = '', $message ) { 5 if( WP_DEBUG === true ){ 6 if( is_array( $message ) || is_object( $message ) ){ 7 error_log( $str ); 8 error_log( print_r( $message, true ) ); 9 } else { 10 error_log( $str ); 11 error_log( $message ); 12 } 13 } 14 } 15 } 3 16 function indexOf( $substr, $str ) { 4 17 if( strpos( $str, $substr ) === 0 ) … … 108 121 '', 'no' ); 109 122 //add and flush rewrite rule 110 add_rewrite_rule( "goto/([0-9a-z]{4,}) ", 'index.php?goto=$matches[1]', 'top' );123 add_rewrite_rule( "goto/([0-9a-z]{4,})/?$", 'index.php?goto=$matches[1]', 'top' ); 111 124 flush_rewrite_rules(); 112 125 } else { -
anylink/trunk/readme.txt
r836042 r841255 5 5 Requires at least: 3.4 6 6 Tested up to: 3.8 7 Stable tag: 0.1. 57 Stable tag: 0.1.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 41 41 42 42 == Changelog == 43 44 = 0.1.6 = 45 * Fixed some bugs cause 404 error 46 * Fixed a bug which may cause collison with other plugins 47 * 修复了一些可能会引起插件造成404错误的bug 48 * 修复了与其他插件存在潜在冲突的bug 43 49 44 50 = 0.1.5 =
Note: See TracChangeset
for help on using the changeset viewer.