Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<? /* Add sku to product search */ function search_by_sku( $search, $query_vars ) { ..
Decoded Output download
<? /* Add sku to product search */
function search_by_sku( $search, $query_vars ) {
global $wpdb;
if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){
$args = array('posts_per_page' => -1,'post_type'=>'product','meta_query' => array( array( 'key' => '_sku', 'value' => $query_vars->query['s'], 'compare' => 'LIKE' ) ) ); $posts = get_posts($args); if(empty($posts)) return $search; $get_post_ids = array(); foreach($posts as $post){ $get_post_ids[] = $post->ID; } if(sizeof( $get_post_ids ) > 0 ) { $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $get_post_ids ) . ")) OR (", $search); } } return $search; }
add_filter( 'posts_search', 'search_by_sku', 999, 2 ?>
Did this file decode correctly?
Original Code
<? /* Add sku to product search */
function search_by_sku( $search, $query_vars ) {
global $wpdb;
if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){
$args = array('posts_per_page' => -1,'post_type'=>'product','meta_query' => array( array( 'key' => '_sku', 'value' => $query_vars->query['s'], 'compare' => 'LIKE' ) ) ); $posts = get_posts($args); if(empty($posts)) return $search; $get_post_ids = array(); foreach($posts as $post){ $get_post_ids[] = $post->ID; } if(sizeof( $get_post_ids ) > 0 ) { $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $get_post_ids ) . ")) OR (", $search); } } return $search; }
add_filter( 'posts_search', 'search_by_sku', 999, 2 ?>
Function Calls
None |
Stats
MD5 | 07146111dc187bc2b474348c3cda00e7 |
Eval Count | 0 |
Decode Time | 62 ms |