Viewing 3 Topics - 16 through 18 (of 18 total)
Author Posts
October 2, 2013 at 1:14 am 8634
strangerrj strangerrj This reply has been marked as private.
October 2, 2013 at 1:38 am 8636
Tareq Hasan Tareq Hasan

Ok, got the point here. As the plugin is using WP’s default tag search functionality, it doesn’t work for guests and I overlooked that. Paste this code in your themes functions.php and should work.

[php]
/**
* Non logged in users tag autocomplete
*
* @since 2.1.9
* @global object $wpdb
*/
function wpufe_ajax_tag_earch() {
global $wpdb;

$taxonomy = sanitize_key( $_GET[‘tax’] );
$tax = get_taxonomy( $taxonomy );
if ( !$tax ) {
wp_die( 0 );
}

$s = wp_unslash( $_GET[‘q’] );

$comma = _x( ‘,’, ‘tag delimiter’ );
if ( ‘,’ !== $comma )
$s = str_replace( $comma, ‘,’, $s );
if ( false !== strpos( $s, ‘,’ ) ) {
$s = explode( ‘,’, $s );
$s = $s[count( $s ) – 1];
}

$s = trim( $s );
if ( strlen( $s ) < 2 )
wp_die(); // require 2 chars for matching

$results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, ‘%’ . like_escape( $s ) . ‘%’ ) );

echo join( $results, "\n" );
wp_die();
}

add_action( ‘wp_ajax_nopriv_ajax-tag-search’, ‘wpufe_ajax_tag_earch’ );
[/php]

October 2, 2013 at 1:46 am 8638
strangerrj strangerrj

Hi Tareq, thank you. Greetings Rick

Viewing 3 Topics - 16 through 18 (of 18 total)