search by acf fields
This commit is contained in:
parent
b2a31d8521
commit
1210809e43
61
acf-extensions/search-acf.php
Normal file
61
acf-extensions/search-acf.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend WordPress search to include custom fields
|
||||
*
|
||||
* https://adambalee.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* Join posts and postmeta tables
|
||||
*
|
||||
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join
|
||||
*/
|
||||
function cf_search_join( $join ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( is_search() ) {
|
||||
$join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
|
||||
}
|
||||
|
||||
return $join;
|
||||
}
|
||||
add_filter('posts_join', 'cf_search_join' );
|
||||
|
||||
/**
|
||||
* Modify the search query with posts_where
|
||||
*
|
||||
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
|
||||
*/
|
||||
function cf_search_where( $where ) {
|
||||
global $pagenow, $wpdb;
|
||||
|
||||
if ( is_search() ) {
|
||||
$where = preg_replace(
|
||||
"/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
|
||||
"(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
add_filter( 'posts_where', 'cf_search_where' );
|
||||
|
||||
/**
|
||||
* Prevent duplicates
|
||||
*
|
||||
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_distinct
|
||||
*/
|
||||
function cf_search_distinct( $where ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( is_search() ) {
|
||||
return "DISTINCT";
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
add_filter( 'posts_distinct', 'cf_search_distinct' );
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Plugin Name: Federated Computer E-Commerce
|
||||
* Description: This plugin contains customizations for Federated Computer.
|
||||
* Version: 1.0.5
|
||||
* Version: 1.1.0
|
||||
*/
|
||||
|
||||
|
||||
@ -17,5 +17,6 @@ include( plugin_dir_path( __FILE__ ) . 'rest-api/provisioner_rest_api_extensions
|
||||
include( plugin_dir_path( __FILE__ ) . 'woocommerce/new_subscription_set_to_needs_provision.php');
|
||||
include( plugin_dir_path( __FILE__ ) . 'woocommerce/processing_to_complete_order.php');
|
||||
include( plugin_dir_path( __FILE__ ) . 'shared/federated_woocommerce_shared_functions.php');
|
||||
include( plugin_dir_path( __FILE__ ) . 'acf-extensions/search-acf.php');
|
||||
|
||||
include( plugin_dir_path( __FILE__ ) . 'rest-api/get_dns_records_test.php');
|
||||
//include( plugin_dir_path( __FILE__ ) . 'rest-api/get_dns_records_test.php');
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action('rest_api_init', 'federated_route_get_dns');
|
||||
|
||||
function federated_route_get_dns(){
|
||||
|
@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
//Get needs provision, get needs removal
|
||||
add_action('rest_api_init', 'federated_route_update_provision_status_failed_register');
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
function get_subscription_tier($subscription){
|
||||
$tier = '';
|
||||
foreach ( $subscription->get_items() as $line_item ) {
|
||||
|
@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* @snippet WooCommerce Add Provision Info Tab
|
||||
* @author Ross Trottier
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
function federated_set_new_subscription_provision_status($subscription){
|
||||
update_field('provision_status', 'needs_provision', $subscription->ID);
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action('woocommerce_payment_complete', 'federated_set_new_order_to_complete');
|
||||
|
||||
function federated_set_new_order_to_complete($order_id)
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
if( ! defined( 'ABSPATH' ) ){
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_before_thankyou', 'federated_thank_you_page_message' );
|
||||
|
||||
function federated_thank_you_page_message( $order_id ) {
|
||||
|
Loading…
Reference in New Issue
Block a user