Plugin Directory

Changeset 400579


Ignore:
Timestamp:
06/23/2011 09:17:58 PM (15 years ago)
Author:
dardna
Message:

fixed search feed using custom search base.

Location:
wp-htaccess-control/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-htaccess-control/trunk/readme.txt

    r400175 r400579  
    7373== Changelog ==
    7474
     75= 2.5.4 (23/06/2011) =
     76* *Fix:* fixed search feed using custom search base.
     77
    7578= 2.5.3 (23/06/2011) =
    7679* *Fix:* fixed special characters on query using custom search base as 2.5.2 did not solve it.
  • wp-htaccess-control/trunk/wp-htaccess-control.php

    r400175 r400579  
    44Plugin URI: http://dardna.com/wp-htaccess-control
    55Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by Wordpress.
    6 Version: 2.5.3
     6Version: 2.5.4
    77Author: António Andrade
    88Author URI: http://dardna.com
     
    4949                if(strpos($_SERVER["REQUEST_URI"], $WPhtc_data['custom_search_permalink'])){
    5050                    global $wp_query;
    51                     $query=split($WPhtc_data['custom_search_permalink']."/",$_SERVER["REQUEST_URI"]);
    52                     $query=urldecode($query[1]);
    53                     $wp_query=new WP_Query('s='.$query );
     51                    if(strpos($_SERVER["REQUEST_URI"], '/feed')){
     52                        preg_match("/feed\/(feed|rdf|rss|rss2|atom)?/",$_SERVER["REQUEST_URI"], $feed);
     53                        if($feed[1]){
     54                            $format="&feed=".$feed[1];
     55                            }
     56                        else{
     57                            $format="&feed=feed";
     58                            }
     59                        }
     60                        $page_base=($WPhtc_data['cpp']!='')?$WPhtc_data['cpp']:'page';
     61                        # in need of better regex
     62                        if(!strpos($_SERVER["REQUEST_URI"], '/feed')&&!strpos($_SERVER["REQUEST_URI"],$page_base)){
     63                            $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)/";
     64                            }
     65                        else{
     66                            $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)\/feed|".$page_base."?/";
     67                            }
     68                        preg_match($pattern,$_SERVER["REQUEST_URI"], $matches);
     69                        $wp_query=new WP_Query('s='.$matches[1].$format );
    5470                    }
    5571                }
     
    5975            $WPhtc_data=get_option('WPhtc_data');
    6076            if($WPhtc_data['custom_search_permalink']!=''&&strpos($_SERVER["REQUEST_URI"], $WPhtc_data['custom_search_permalink'])){
    61                 $query=split($WPhtc_data['custom_search_permalink']."/",$_SERVER["REQUEST_URI"]);
    62                 $query=urldecode($query[1]);
    63                 $query=$query;
     77                # in need of better regex
     78                if(!strpos($_SERVER["REQUEST_URI"], '/feed')&&!strpos($_SERVER["REQUEST_URI"],$page_base)){
     79                    $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)/";
     80                    }
     81                else{
     82                    $pattern="/\/".$WPhtc_data['custom_search_permalink']."\/(.+)\/feed|".$page_base."?/";
     83                    }
     84                preg_match($pattern,$_SERVER["REQUEST_URI"], $matches);
     85                return urldecode($matches[1]);
    6486                }
    6587            return $query;
     88            }
     89        function wphtc_search_feed_link($link){
     90            $WPhtc_data=get_option('WPhtc_data');
     91            if($WPhtc_data['custom_search_permalink']!=''){
     92                $link=str_replace("search",$WPhtc_data['custom_search_permalink'],$link);
     93                }
     94            return $link;
    6695            }
    6796        function wphtc_check_first_run(){
     
    565594    add_filter('redirect_canonical',array($WPhtc,'wphtc_filter_redirect_canonical'),10,10);
    566595    add_filter('get_search_query',array($WPhtc,'wphtc_get_search_query_filter'),10,10);
     596    add_filter('search_feed_link',array($WPhtc,'wphtc_search_feed_link'),10,10);
    567597    add_action('admin_menu', array($WPhtc,'configure_menu'));
    568598    add_action('sm_buildmap',array($WPhtc,'set_sm'));
Note: See TracChangeset for help on using the changeset viewer.