<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[11606] sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php: WordPress.TV: Remove the search functions.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/11606">11606</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/11606","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-02-25 04:23:33 +0000 (Fri, 25 Feb 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordPress.TV: Remove the search functions.

This sync's meta with WordPress.TV trunk.

See <a href="http://meta.trac.wordpress.org/ticket/3387">#3387</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpresstvpublic_htmlwpcontentthemeswptv2functionsphp">sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpresstvpublic_htmlwpcontentthemeswptv2functionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php        2022-02-25 03:29:02 UTC (rev 11605)
+++ sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php  2022-02-25 04:23:33 UTC (rev 11606)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,7 +29,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'widgets_init', array( $this, 'widgets_init' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'init', array( $this, 'register_taxonomies' ), 0 );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'pre_get_posts', array( $this, 'posts_per_page' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_action( 'init', array( $this, 'improve_search' ) );
</del><span class="cx" style="display: block; padding: 0 10px">                 add_action( 'publish_post', array( $this, 'publish_post' ), 10, 1 );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'save_post', array( $this, 'save_meta_box_fields' ), 10, 2);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,7 +221,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                        */
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $data[] = array_filter( $video_data, function( $item ) { 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $data[] = array_filter( $video_data, function( $item ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 return '' !== $item && [] !== $item;
</span><span class="cx" style="display: block; padding: 0 10px">                        } );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -413,180 +412,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        /**
-        * Activates the improved search, but not in admin.
-        */
-       function improve_search() {
-               if ( is_admin() ) {
-                       return;
-               }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_filter( 'posts_search', array( $this, 'search_posts_search' ), 10, 2 );
-               add_action( 'pre_get_posts', array( $this, 'search_pre_get_posts' ) );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Sort the search results by the number of views each post has
-        *
-        * @param WP_Query $query
-        */
-       function search_pre_get_posts( $query ) {
-               /*
-                * @todo Optimize this before re-enabling
-                *
-                * This method was disabled because it caused 504 errors on large result sets
-                * (e.g., https://wordpress.tv/?s=keynote). Sorting by a meta value is not performant.
-                *
-                * Maybe look at ways to do the sorting in PHP, or just use Elasticsearch instead.
-                */
-               return;
-
-               if ( ! $query->is_main_query() || ! $query->is_search ) {
-                       return;
-               }
-
-               // Set custom sorting
-               $query->set( 'meta_key', 'wptv_post_views' );
-               $query->set( 'orderby', 'meta_value_num' );
-               $query->set( 'order', 'DESC' );
-       }
-
-       /**
-        * Improved Search: posts_search filter
-        *
-        * Recreates the search SQL by including a taxonomy search.
-        * Relies on various other filters used once.
-        * @todo optimize the get_tax_query part.
-        *
-        * @global wpdb $wpdb WordPress database abstraction object.
-        *
-        * @param string   $search
-        * @param WP_Query $query
-        * @return string
-        */
-       function search_posts_search( $search, $query ) {
-               global $wpdb;
-               if ( ! $query->is_main_query() || ! $query->is_search || is_admin() ) {
-                       return $search;
-               }
-
-               // Get the tax query and replace the leading AND with an OR
-               $tax_query = get_tax_sql( $this->get_tax_query( get_query_var( 's' ) ), $wpdb->posts, 'ID' );
-               if ( 'and' == substr( trim( strtolower( $tax_query['where'] ) ), 0, 3 ) ) {
-                       $tax_query['where'] = ' OR ' . substr( trim( $tax_query['where'] ), 3 );
-               }
-
-               // Mostly taken from query.php
-               if ( isset( $query->query_vars['search_terms'] ) ) {
-                       $search = $searchand = '';
-                       $n      = empty( $query->query_vars['exact'] ) ? '%' : '';
-
-                       foreach ( (array) $query->query_vars['search_terms'] as $term ) {
-                               $term = esc_sql( $wpdb->esc_like( $term ) );
-                               $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
-                               $searchand = ' AND ';
-                       }
-
-                       // Combine the search and tax queries.
-                       if ( ! empty( $search ) ) {
-                               // Add the tax search to the query
-                               if ( ! empty( $tax_query['where'] ) ) {
-                                       $search .= $tax_query['where'];
-                               }
-
-                               $search = " AND ({$search}) ";
-                               if ( ! is_user_logged_in() ) {
-                                       $search .= " AND ($wpdb->posts.post_password = '') ";
-                               }
-                       }
-               }
-
-               // These are single-use filters, they delete themselves right after they're used.
-               add_filter( 'posts_join', array( $this, 'search_posts_join' ), 10, 2 );
-               add_filter( 'posts_groupby', array( $this, 'search_posts_groupby' ), 10, 2 );
-
-               return $search;
-       }
-
-       /**
-        * Improved Search: posts_join filter
-        *
-        * This adds the JOIN clause resulting from the taxonomy
-        * search. Make sure this filter runs only once per WP_Query request.
-        *
-        * @global wpdb $wpdb WordPress database abstraction object.
-        *
-        * @param string   $join
-        * @param WP_Query $query
-        * @return string
-        */
-       function search_posts_join( $join, &$query ) {
-               // Make sure this filter doesn't run again.
-               remove_filter( 'posts_join', array( $this, 'search_posts_join' ), 10, 2 );
-
-               if ( $query->is_main_query() ) {
-                       global $wpdb;
-                       $tax_query = get_tax_sql( $this->get_tax_query( get_query_var( 's' ) ), $wpdb->posts, 'ID' );
-                       $join .= $tax_query['join'];
-               }
-
-               return $join;
-       }
-
-       /**
-        * Improved Search: posts_groupby filter
-        *
-        * Searching with taxonomies may include duplicates when
-        * search query matches content and one or more taxonomies.
-        * This filter glues all duplicates. Use only once per WP_Query.
-        *
-        * @global wpdb $wpdb WordPress database abstraction object.
-        *
-        * @param string   $group_by
-        * @param WP_Query $query
-        * @return string
-        */
-       function search_posts_groupby( $group_by, &$query ) {
-               // Never run this again
-               remove_filter( 'posts_groupby', array( $this, 'search_posts_groupby' ), 10, 2 );
-
-               global $wpdb;
-               $group_by = "$wpdb->posts.ID";
-
-               return $group_by;
-       }
-
-       /**
-        * Returns a $tax_query array for an improved search.
-        *
-        * @param string $search
-        * @return array
-        */
-       function get_tax_query( $search ) {
-               $taxonomies = array(
-                       'producer',
-                       'speakers', /*'flavor', 'language',*/
-                       'event'
-               );
-
-               $terms    = get_terms( $taxonomies, array(
-                       'search' => $search,
-               ) );
-               $term_ids = wp_list_pluck( $terms, 'term_id' );
-
-               $tax_query = array();
-               foreach ( $taxonomies as $taxonomy ) {
-                       $tax_query[] = array(
-                               'taxonomy' => $taxonomy,
-                               'terms'    => $term_ids,
-                       );
-               }
-               $tax_query['relation'] = 'OR';
-
-               return $tax_query;
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * Change VideoPress Params, runs during wp_footer
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        function videopress_flash_params() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -874,9 +701,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Convert a WPTV Locale to a WP Locale code.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *
</ins><span class="cx" style="display: block; padding: 0 10px">          * This isn't all correct, and many of these need to be combined.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * 
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *
</ins><span class="cx" style="display: block; padding: 0 10px">          * See https://meta.trac.wordpress.org/ticket/1156
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        function locale_to_wp_locale( $locale ) {
</span></span></pre>
</div>
</div>

</body>
</html>