Plugin Directory

Changeset 1920489


Ignore:
Timestamp:
08/06/2018 03:51:33 PM (8 years ago)
Author:
8bitsinarow
Message:

Fixed search when KB is in a sub-page

Location:
basepress/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • basepress/trunk/basepress.php

    r1920390 r1920489  
    55 * Plug URI: http://www.8bitsinarow.com
    66 * Description: The perfect Knowledge Base plugin for WordPress
    7  * Version: 1.8.6
     7 * Version: 1.8.7
    88 * Author: 8Bits in a row
    99 * Author URI: http://www.8bitsinarow.com
     
    7373             * @var string
    7474             */
    75             public  $ver = '1.8.6' ;
     75            public  $ver = '1.8.7' ;
    7676            /**
    7777             * Database version
  • basepress/trunk/includes/class-basepress-cpt.php

    r1920390 r1920489  
    1919        public function __construct()
    2020        {
     21            global  $basepress_utils ;
    2122            //Add rewrite rules to handle links properly
    2223            add_filter( 'rewrite_rules_array', array( $this, 'rewrite_rules' ) );
     
    5758            add_action( 'admin_notices', array( $this, 'missing_data_notice' ) );
    5859            $this->options = get_option( 'basepress_settings' );
    59             $this->kb_slug = $this->get_kb_slug();
     60            $this->kb_slug = $basepress_utils->get_kb_slug();
    6061            $this->register_taxonomy();
    6162            $this->register_post_type();
     
    6364       
    6465        /**
    65          * Gets the KB slug including parents pages if exists
    66          *
    67          * @since 1.7.9
    68          *
    69          * @return string
    70          */
    71         public function get_kb_slug()
    72         {
    73             $entry_page = ( isset( $this->options['entry_page'] ) ? $this->options['entry_page'] : 0 );
    74             /**
    75              * Filters the entry page ID before use
    76              */
    77             $entry_page = apply_filters( 'basepress_entry_page', $entry_page );
    78             $parents = get_ancestors( $entry_page, 'page' );
    79             $kb_slug = get_post_field( 'post_name', $entry_page );
    80             foreach ( $parents as $parent ) {
    81                 $parent_slug = get_post_field( 'post_name', $parent );
    82                 $kb_slug = $parent_slug . '/' . $kb_slug;
    83             }
    84             $this->kb_slug = $kb_slug;
    85             return $kb_slug;
    86         }
    87        
    88         /**
    8966         * Adds rewrite rules for Basepress post type
    9067         * Called by flush_rewrite rules
     
    9875        public function rewrite_rules( $rules )
    9976        {
    100             global  $wp_rewrite ;
     77            global  $wp_rewrite, $basepress_utils ;
    10178            $options = get_option( 'basepress_settings' );
    10279            //If the entry page has not been set skip the rewrite rules
     
    10481                return $rules;
    10582            }
    106             $kb_slug = $this->get_kb_slug();
     83            $kb_slug = $basepress_utils->get_kb_slug();
    10784            /**
    10885             * Filter the kb_slug before generating the rewrite rules
  • basepress/trunk/includes/class-basepress-utils.php

    r1886888 r1920489  
    1313    class Basepress_Utils {
    1414
     15        private $kb_slug = null;
    1516        private $product = null;
    1617        private $sections = null;
     
    326327        }
    327328
     329
     330        /**
     331         * Gets the KB slug including parents pages if exists
     332         *
     333         * @since 1.7.9
     334         *
     335         * @return string
     336         */
     337        public function get_kb_slug(){
     338
     339            if( $this->kb_slug ){
     340                return $this->kb_slug;
     341            }
     342
     343            $entry_page = isset( $this->options['entry_page'] ) ? $this->options['entry_page'] : 0;
     344
     345            /**
     346             * Filters the entry page ID before use
     347             */
     348            $entry_page = apply_filters( 'basepress_entry_page', $entry_page );
     349
     350            $parents = get_ancestors( $entry_page, 'page' );
     351            $kb_slug = get_post_field( 'post_name', $entry_page );
     352
     353            foreach( $parents as $parent ){
     354                $parent_slug = get_post_field( 'post_name', $parent );
     355                $kb_slug = $parent_slug . '/' . $kb_slug;
     356            }
     357            $this->kb_slug = $kb_slug;
     358            return $kb_slug;
     359        }
    328360
    329361
  • basepress/trunk/public/class-basepress-search.php

    r1920390 r1920489  
    9191         */
    9292        public function render_searchbar( $product = '' ) {
    93             global $wp;
    94             global $basepress_utils;
     93            global $wp, $basepress_utils;
    9594
    9695            if ( ! $product ) {
     
    101100            $placeholder = isset( $options['search_field_placeholder'] ) ? $options['search_field_placeholder'] : '';
    102101            $search_terms = isset( $wp->query_vars['s'] ) ? urldecode( $wp->query_vars['s'] ) : '';
    103             $kb_slug = isset( $options['entry_page'] ) ? get_post_field( 'post_name', $options['entry_page'] ) : '';
     102            $kb_slug = $basepress_utils->get_kb_slug();
    104103
    105104            /**
  • basepress/trunk/readme.txt

    r1920390 r1920489  
    55Requires at least: 4.5
    66Tested up to: 4.9
    7 Stable tag: 1.8.6
     7Stable tag: 1.8.7
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    138138== Changelog ==
    139139
     140= 1.8.7 =
     141* Fixed bug for searches when the KB is in sub-page
     142
    140143= 1.8.6 =
    141144* Improved search results to move exact matches on top
Note: See TracChangeset for help on using the changeset viewer.