Plugin Directory

Changeset 2268150


Ignore:
Timestamp:
03/26/2020 12:51:28 PM (6 years ago)
Author:
kodeks
Message:

Added check for existing functions in search-all

Location:
kodeks-dashboard/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kodeks-dashboard/trunk/functions.php

    r2267202 r2268150  
    709709 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
    710710 */
    711 function cf_search_join( $join ) {
    712     global $wpdb;
    713 
    714     if ( is_search() ) {   
    715         $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
    716     }
    717 
    718     return $join;
    719 }
    720 add_filter('posts_join', 'cf_search_join' );
     711
     712if ( ! function_exists( 'cf_search_join' ) ) {
     713
     714    function cf_search_join( $join ) {
     715        global $wpdb;
     716
     717        if ( is_search() ) {   
     718            $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
     719        }
     720
     721        return $join;
     722    }
     723    add_filter('posts_join', 'cf_search_join' );
     724
     725}
    721726
    722727/**
     
    725730 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
    726731 */
    727 function cf_search_where( $where ) {
    728     global $pagenow, $wpdb;
    729 
    730     if ( is_search() ) {
    731         $where = preg_replace(
    732             "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
    733             "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
    734     }
    735 
    736     return $where;
    737 }
    738 add_filter( 'posts_where', 'cf_search_where' );
     732
     733if ( ! function_exists( 'cf_search_where' ) ) {
     734    function cf_search_where( $where ) {
     735        global $pagenow, $wpdb;
     736
     737        if ( is_search() ) {
     738            $where = preg_replace(
     739                "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
     740                "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
     741        }
     742
     743        return $where;
     744    }
     745    add_filter( 'posts_where', 'cf_search_where' );
     746}
    739747
    740748/**
     
    743751 * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
    744752 */
    745 function cf_search_distinct( $where ) {
    746     global $wpdb;
    747 
    748     if ( is_search() ) {
    749         return "DISTINCT";
    750     }
    751 
    752     return $where;
    753 }
    754 add_filter( 'posts_distinct', 'cf_search_distinct' );
    755 
     753if ( ! function_exists( 'cf_search_distinct' ) ) {
     754    function cf_search_distinct( $where ) {
     755        global $wpdb;
     756
     757        if ( is_search() ) {
     758            return "DISTINCT";
     759        }
     760
     761        return $where;
     762    }
     763    add_filter( 'posts_distinct', 'cf_search_distinct' );
     764}
    756765
    757766
  • kodeks-dashboard/trunk/kodeks-dashboard.php

    r2267203 r2268150  
    33Plugin Name: Kodeks Dashboard
    44Description: This plugin customizes WordPress for Kodeks customers.
    5 Version: 2.21
     5Version: 2.22
    66Author: Thomas Johannessen & Marius Kaase
    77Author URI: http://kodeks.no
  • kodeks-dashboard/trunk/readme.txt

    r2267204 r2268150  
    11=== Kodeks Dashboard ===
    2 Version: 2.21
     2Version: 2.22
    33Contributors: Kodeks AS
    44Tested up to: 5.3.2
Note: See TracChangeset for help on using the changeset viewer.