Usage in another plugin
-
Hi,
thank you for the great plugin. From what I figure those last hours it is really nicely written and documented. Still, my wordpress insight and php skill seems not sufficient to understand it perfectly.
I use another plugin, wp-search-suggest. That did, unlike what I expected, not make use of your plugin. That is, in the suggestions, findings from custom fields could not be found.
I have a solution for that in the other problem. So all I want from you folk, is maybe some help to understand (1) why exactly my solution works and (2) how this could have been solved more elegantly, either on the search-everything side or on the wp-search-suggest side.
Thanks!
// Here is what I added, with minor changes just copied from your plugin $is_query = !empty($s); $result = array(); if ($is_query) { $result = array( 'own' => array(), 'external' => array() ); $params = array( 's' => $s ); $zemanta_response = se_api(array( 'method' => 'zemanta.suggest', 'return_images' => 0, 'return_rich_objects' => 0, 'return_articles' => 1, 'return_markup' => 0, 'return_rdf_links' => 0, 'return_keywords' => 0, 'careful_pc' => 1, 'interface' => 'wordpress-se', 'format' => 'json', 'emphasis' => $_GET['s'], 'text' => $_GET['text'] )); if (!is_wp_error($zemanta_response) && $zemanta_response['response']['code'] == 200) { $result['external'] = json_decode($zemanta_response['body'])->articles; } $SE = new SearchEverything(true); if (!empty($_GET['exact'])) { $params['exact'] = true; } $params["showposts"] = 5; $post_query = new WP_query($params); $results = array(); if ( $post_query->posts ) { $results = apply_filters( 'wpss_search_results', wp_list_pluck( $post_query->posts, 'post_title' ), $post_query ); echo join( $results, "\n" ); } } echo join($results, "\n"); wp_die(); // Below this line you find the original action. It is still in place, though obviously inactive due to wp_die() $query = new WP_Query( $query_args ); if ( $query->posts ) { $results = apply_filters( 'wpss_search_results', wp_list_pluck( $query->posts, 'post_title' ), $query ); echo join( $results, "\n" ); } wp_die();
- The topic ‘Usage in another plugin’ is closed to new replies.