diff --git a/classes/WDTSTranscript.php b/classes/WDTSTranscript.php index 4709b39..6f841e1 100644 --- a/classes/WDTSTranscript.php +++ b/classes/WDTSTranscript.php @@ -80,11 +80,20 @@ class WDTSTranscriptManager { function _update_search_field($transcripts) { if (!empty($this->search_key)) { $search_lines = array(); - foreach ($transcripts as $transcript) { $search_lines[] = preg_replace('#\[[^\]]+\]#', '', $transcript['transcript']); } + foreach ($transcripts as $transcript) { + $search_lines[] = preg_replace_callback('#\[[^\]]+\]#', array(&$this, '_update_search_field_callback'), $transcript['transcript']); + } update_post_meta($this->post_id, $this->search_key, implode(" ", $search_lines)); } } + function _update_search_field_callback($result) { + $properties = preg_match_all('#[a-z]+="([^\"]+)"#', reset($result), $matches); + $return = ""; + foreach ($matches[1] as $match) { $return .= $match . " "; } + return $return; + } + function delete_transcript($language = null) { return $this->_delete_transcript_by_field('language', $language); } diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index ea86bab..4c9561d 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -19,6 +19,7 @@ class WhatDidTheySayAdmin { ), 'load_default_styles' => true, 'automatic_embedding' => true, + 'search_integration' => true, 'excerpt_distance' => 30 ); @@ -63,9 +64,11 @@ class WhatDidTheySayAdmin { add_filter('the_matching_transcript_excerpts', array(&$this, 'the_matching_transcript_excerpts'), 10, 3); 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 ($options['search_integration']) { + add_filter('posts_where', array(&$this, 'posts_where')); + add_filter('posts_join', array(&$this, 'posts_join')); + } if ($options['automatic_embedding']) { add_filter('the_content', array(&$this, 'the_content_automatic_embedding'), 15); @@ -230,38 +233,41 @@ class WhatDidTheySayAdmin { * Handle the_matching_transcript_excerpts. */ function the_matching_transcript_excerpts($transcripts, $search_string = '', $content = "") { + $options = get_option('what-did-they-say-options'); ob_start(); - if (!empty($search_string)) { - $language_options = new WDTSLanguageOptions(); - $options = get_option('what-did-they-say-options'); - - foreach ($transcripts as $transcript) { - if (($pos = strpos($transcript['transcript'], $search_string)) !== false) { - $l = strlen($transcript['transcript']) - 1; - echo '
'; - $start_ellipsis = $end_ellipsis = true; - foreach (array( - 'start' => -1, - 'end' => 1 - ) as $variable => $direction) { - ${$variable} = $pos + ($options['excerpt_distance'] * $direction); + if ($options['search_integration']) { + if (!empty($search_string)) { + $language_options = new WDTSLanguageOptions(); + $options = get_option('what-did-they-say-options'); - if ($variable == "end") { ${$variable} += strlen($search_string); } + foreach ($transcripts as $transcript) { + if (($pos = strpos($transcript['transcript'], $search_string)) !== false) { + $l = strlen($transcript['transcript']) - 1; + echo '
'; + $start_ellipsis = $end_ellipsis = true; + foreach (array( + 'start' => -1, + 'end' => 1 + ) as $variable => $direction) { + ${$variable} = $pos + ($options['excerpt_distance'] * $direction); - if (${$variable} < 0) { ${$variable} = 0; $start_ellipsis = false; } - if (${$variable} > $l) { ${$variable} = $l; $end_ellipsis = false; } - } + if ($variable == "end") { ${$variable} += strlen($search_string); } - $output = ""; - if ($start_ellipsis) { $output .= "..."; } - $output .= str_replace($search_string, "" . $search_string . "", trim(substr($transcript['transcript'], $start, $end - $start))); - if ($end_ellipsis) { $output .= "..."; } + if (${$variable} < 0) { ${$variable} = 0; $start_ellipsis = false; } + if (${$variable} > $l) { ${$variable} = $l; $end_ellipsis = false; } + } - echo $output; - echo '
'; - echo '- What Did They Say?!? can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?> -
+ /> + + + + + + + What Did They Say?!? is set to attempt to embed excerpts into your posts automatically.', 'what-did-they-say') ?> + + What Did They Say?!? will not attempt to embed excerpts into your posts automatically.', 'what-did-they-say') ?> + +- +
@@ -38,7 +49,32 @@+ + + What Did They Say?!? is set to search transcripts when your site is searched.', 'what-did-they-say') ?> + + What Did They Say?!? will not search transcripts when your site is searched.', 'what-did-they-say') ?> + + + diff --git a/classes/partials/admin.inc b/classes/partials/admin.inc index 8d40809..a5e13ea 100644 --- a/classes/partials/admin.inc +++ b/classes/partials/admin.inc @@ -1,11 +1,11 @@ __('Introduction', 'what-did-they-say'), - 'capabilities' => __('Capabilities', 'what-did-they-say'), - 'default-styles' => __('Styles', 'what-did-they-say'), - 'change-languages' => __('Languages', 'what-did-they-say'), - 'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say'), - 'misc-options' => __('Misc. Options', 'what-did-they-say'), + 'capabilities' => array(__('Capabilities', 'what-did-they-say'), 'edit_users'), + 'default-styles' => array(__('Styles', 'what-did-they-say'), 'edit_themes'), + 'change-languages' => array(__('Languages', 'what-did-they-say'), 'change_languages'), + 'shortcodes-info' => array(__('Shortcodes Info', 'what-did-they-say'), 'submit_transcriptions'), + 'misc-options' => array(__('Misc. Options', 'what-did-they-say'), 'manage_options'), ); extract($this->plugin_data); @@ -14,7 +14,17 @@- What Did They Say?!? will search your transcripts, too.', 'what-did-they-say') ?> + What Did They Say?!? can search your transcripts, too.', 'what-did-they-say') ?> + + +