Index: trunk/redirection-filters.php =================================================================== --- trunk/redirection-filters.php (revision 0) +++ trunk/redirection-filters.php (revision 0) @@ -0,0 +1,13 @@ + Index: trunk/redirection.php =================================================================== --- trunk/redirection.php (revision 565774) +++ trunk/redirection.php (working copy) @@ -29,6 +29,8 @@ include dirname( __FILE__ ).'/models/monitor.php'; include dirname( __FILE__ ).'/modules/wordpress.php'; +include dirname( __FILE__ ).'/redirection-filters.php'; + define( 'REDIRECTION_VERSION', '2.3.1' ); if ( class_exists( 'Redirection' ) ) Index: trunk/models/redirect.php =================================================================== --- trunk/models/redirect.php (revision 565774) +++ trunk/models/redirect.php (working copy) @@ -94,6 +94,8 @@ $sql = str_replace( '@', $wpdb->prefix, $sql); $rows = $wpdb->get_results( $sql ) ; + $rows = apply_filters( 'redirection_get_for_url_rows', $rows, $url, $type ); + $items = array(); if ( count( $rows ) > 0 ) { foreach ( $rows AS $row ) { @@ -104,7 +106,7 @@ // Sort it in PHP ksort( $items ); $items = array_values( $items ); - return $items; + return apply_filters( 'redirection_get_for_url_items', $items, $url, $type ); } function get_by_module( &$pager, $module ) { @@ -197,7 +199,7 @@ $action_code = intval( $details['action_code'] ); $data = array( - 'url' => Red_Item::sanitize_url( $details['source'], $regex), + 'url' => apply_filters( 'redirection_sanitize_source_url', $details['source'], $regex ), 'action_type' => $details['red_action'], 'regex' => $regex, 'position' => $position, @@ -208,11 +210,14 @@ 'group_id' => $group_id ); + $data = apply_filters( 'redirection_filter_new_item', $data, $details ); $wpdb->insert( $wpdb->prefix.'redirection_items', $data ); $group = Red_Group::get( $group_id ); Red_Module::flush( $group->module_id ); + do_action( 'redirection_new_item_added', $wpdb->insert_id ); + return Red_Item::get_by_id( $wpdb->insert_id ); } @@ -303,7 +308,7 @@ $matches = false; // Check if we match the URL - if ( ( $this->regex == false && ( $this->url == $url || $this->url == rtrim( $url, '/' ) || $this->url == urldecode( $url ) ) ) ||( $this->regex == true && @preg_match( '@'.str_replace( '@', '\\@', $this->url).'@', $url, $matches) > 0) ||( $this->regex == true && @preg_match( '@'.str_replace( '@', '\\@', $this->url).'@', urldecode( $url ), $matches) > 0) ) { + if ( ( $this->regex == false && ( $this->url == $url || $this->url == rtrim( $url, '/' ) || $this->url == urldecode( $url ) ) || apply_filters( 'redirection_matches_url', false, $this, $url ) ) ||( $this->regex == true && @preg_match( '@'.str_replace( '@', '\\@', $this->url).'@', $url, $matches) > 0) ||( $this->regex == true && @preg_match( '@'.str_replace( '@', '\\@', $this->url).'@', urldecode( $url ), $matches) > 0) ) { // Check if our match wants this URL $target = $this->match->get_target( $url, $this->url, $this->regex);