From 40b3d2282067b2070ef996e23dcc272015b91a4d Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 20 Sep 2009 12:54:57 -0400 Subject: [PATCH] transcript search results integrated --- classes/WhatDidTheySayAdmin.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index f029cc8..bcf9b95 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -61,6 +61,9 @@ class WhatDidTheySayAdmin { add_filter('template_redirect', array(&$this, 'template_redirect')); + add_filter('posts_where', array(&$this, 'posts_where')); + add_filter('posts_join', array(&$this, 'posts_join')); + if (isset($_REQUEST['wdts'])) { if (isset($_REQUEST['wdts']['_nonce'])) { if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) { @@ -72,6 +75,30 @@ class WhatDidTheySayAdmin { } } + function posts_where($where) { + global $wpdb; + + $search = get_query_var('s'); + if (!empty($search)) { + $where .= $wpdb->prepare(" OR ($wpdb->postmeta.meta_key = %s ", 'approved_transcripts'); + $search = addslashes_gpc($search); + $where .= " AND $wpdb->postmeta.meta_value LIKE '%$search%') "; + } + + return $where; + } + + function posts_join($join) { + global $wpdb; + + $search = get_query_var('s'); + if (!empty($search)) { + $join .= " JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; + } + + return $join; + } + function template_redirect() { wp_enqueue_script('toggle-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/toggle-transcript.js', array('prototype'), false, true); if (current_user_can('submit_transcriptions')) { wp_enqueue_script('scriptaculous-effects'); }