diff --git a/README.md b/README.md index 24fb1022..0abd9377 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Requires at least:** 4.6 **Requires PHP:** 7.1 **Tested up to:** 5.4 -**Stable tag:** 2.1.3 +**Stable tag:** 2.1.4 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -50,17 +50,15 @@ Alternatively, there are a couple of community-maintained Docker containers you In a local development environment, you can point Solr Power to a custom Solr instance by creating a MU plugin with: -``` -setField( 'displaymodified', $post_info->post_modified ); $post_time = strtotime( $post_info->post_date ); - $doc->setField( 'year_i', date( 'Y', $post_time ) ); - $doc->setField( 'month_i', date( 'm', $post_time ) ); - $doc->setField( 'day_i', date( 'd', $post_time ) ); - $doc->setField( 'week_i', date( 'W', $post_time ) ); - $doc->setField( 'dayofweek_i', ( date( 'w', $post_time ) + 1 ) ); - $doc->setField( 'dayofweek_iso_i', date( 'w', $post_time ) ); - $doc->setField( 'hour_i', date( 'H', $post_time ) ); - $doc->setField( 'minute_i', date( 'i', $post_time ) ); - $doc->setField( 'second_i', date( 's', $post_time ) ); + $doc->setField( 'year_i', gmdate( 'Y', $post_time ) ); + $doc->setField( 'month_i', gmdate( 'm', $post_time ) ); + $doc->setField( 'day_i', gmdate( 'd', $post_time ) ); + $doc->setField( 'week_i', gmdate( 'W', $post_time ) ); + $doc->setField( 'dayofweek_i', ( gmdate( 'w', $post_time ) + 1 ) ); + $doc->setField( 'dayofweek_iso_i', gmdate( 'w', $post_time ) ); + $doc->setField( 'hour_i', gmdate( 'H', $post_time ) ); + $doc->setField( 'minute_i', gmdate( 'i', $post_time ) ); + $doc->setField( 'second_i', gmdate( 's', $post_time ) ); $post_time = strtotime( $post_info->post_modified ); - $doc->setField( 'post_modified_year_i', date( 'Y', $post_time ) ); - $doc->setField( 'post_modified_month_i', date( 'm', $post_time ) ); - $doc->setField( 'post_modified_day_i', date( 'd', $post_time ) ); - $doc->setField( 'post_modified_week_i', date( 'W', $post_time ) ); - $doc->setField( 'post_modified_dayofweek_i', ( date( 'w', $post_time ) + 1 ) ); - $doc->setField( 'post_modified_dayofweek_iso_i', date( 'w', $post_time ) ); - $doc->setField( 'post_modified_hour_i', date( 'H', $post_time ) ); - $doc->setField( 'post_modified_minute_i', date( 'i', $post_time ) ); - $doc->setField( 'post_modified_second_i', date( 's', $post_time ) ); + $doc->setField( 'post_modified_year_i', gmdate( 'Y', $post_time ) ); + $doc->setField( 'post_modified_month_i', gmdate( 'm', $post_time ) ); + $doc->setField( 'post_modified_day_i', gmdate( 'd', $post_time ) ); + $doc->setField( 'post_modified_week_i', gmdate( 'W', $post_time ) ); + $doc->setField( 'post_modified_dayofweek_i', ( gmdate( 'w', $post_time ) + 1 ) ); + $doc->setField( 'post_modified_dayofweek_iso_i', gmdate( 'w', $post_time ) ); + $doc->setField( 'post_modified_hour_i', gmdate( 'H', $post_time ) ); + $doc->setField( 'post_modified_minute_i', gmdate( 'i', $post_time ) ); + $doc->setField( 'post_modified_second_i', gmdate( 's', $post_time ) ); $doc->setField( 'post_status', $post_info->post_status ); $doc->setField( 'post_parent', $post_info->post_parent ); diff --git a/includes/class-solrpower-wp-query.php b/includes/class-solrpower-wp-query.php index bfad4522..6c16647d 100644 --- a/includes/class-solrpower-wp-query.php +++ b/includes/class-solrpower-wp-query.php @@ -207,9 +207,9 @@ function posts_request( $request, $query ) { $this->facets = $search->getFacetSet()->getFacets(); } - $this->highlighting = $search->getHighlighting(); - - $search = $search->getData(); + $this->highlighting = $search->getHighlighting(); + + $search = $search->getData(); $search_header = $search['responseHeader']; $search = $search['response']; @@ -268,22 +268,22 @@ private function parse_results( $search ) { continue; } - if ( 'solr_id' === $key ) { - if ( $this->highlighting ) { - $highlighted_doc = $this->highlighting->getResult($value); + if ( 'solr_id' === $key ) { + if ( $this->highlighting ) { + $highlighted_doc = $this->highlighting->getResult( $value ); - if ( $highlighted_doc ) { - $snippet = ''; + if ( $highlighted_doc ) { + $snippet = ''; - foreach ( $highlighted_doc as $field => $highlight ) { - $snippet .= implode(' ... ', $highlight); - } + foreach ( $highlighted_doc as $field => $highlight ) { + $snippet .= implode( ' ... ', $highlight ); + } - $post->excerpt = $snippet; - continue; - } - } - } + $post->excerpt = $snippet; + continue; + } + } + } $post->$key = $value; } @@ -968,7 +968,7 @@ function parse_date_query( $date_query ) { } else { $the_date = strtotime( $the_date ); $the_date = ( ( isset( $dq['inclusive'] ) && $dq['inclusive'] ) || $inclusive ) ? $the_date : strtotime( '-1 second', $the_date ); - $the_date = date( 'Y-m-d H:i:s', $the_date ); + $the_date = gmdate( 'Y-m-d H:i:s', $the_date ); $the_date = SolrPower_Sync::get_instance()->format_date( $the_date ); $column = ( isset( $dq['column'] ) ) ? $dq['column'] : 'post_date'; @@ -990,7 +990,7 @@ function parse_date_query( $date_query ) { $the_date = strtotime( $the_date ); $the_date = ( ( isset( $dq['inclusive'] ) && $dq['inclusive'] ) || $inclusive ) ? $the_date : strtotime( '+1 second', $the_date ); - $the_date = date( 'Y-m-d H:i:s', $the_date ); + $the_date = gmdate( 'Y-m-d H:i:s', $the_date ); $the_date = SolrPower_Sync::get_instance()->format_date( $the_date ); $column = ( isset( $dq['column'] ) ) ? $dq['column'] : 'post_date'; @@ -1026,7 +1026,7 @@ function date_query( $dq, $inclusive = false, $type = false ) { && array_key_exists( 'day', $dq ) ) ) { - $the_date = date( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-' . $dq['day'] ) ); + $the_date = gmdate( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-' . $dq['day'] ) ); switch ( $type ) { case 'before': @@ -1052,11 +1052,11 @@ function date_query( $dq, $inclusive = false, $type = false ) { return '(year_i:[* TO ' . $year . '])'; } if ( ! isset( $dq['day'] ) ) { - $the_date = date( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); + $the_date = gmdate( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); if ( ( isset( $dq['inclusive'] ) && true === $dq['inclusive'] ) || true === $inclusive ) { - $the_date = date( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); + $the_date = gmdate( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); } return '(' . $column . ':' . '[* TO ' . $the_date . 'T00:00:00Z])'; @@ -1071,19 +1071,19 @@ function date_query( $dq, $inclusive = false, $type = false ) { return '(year_i:[' . $year . ' TO *])'; } if ( ! isset( $dq['day'] ) ) { - $the_date = date( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); + $the_date = gmdate( 'Y-m-d', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); if ( ( isset( $dq['inclusive'] ) && false === $dq['inclusive'] ) || false === $inclusive ) { - $the_date = date( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); - $the_date = date( 'Y-m-d', strtotime( '+1 Day', strtotime( $the_date ) ) ); + $the_date = gmdate( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-01' ) ); + $the_date = gmdate( 'Y-m-d', strtotime( '+1 Day', strtotime( $the_date ) ) ); } return '(' . $column . ':' . '[' . $the_date . 'T00:00:00Z TO *])'; } else { - $the_date = date( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-' . $dq['day'] ) ); + $the_date = gmdate( 'Y-m-t', strtotime( $dq['year'] . '-' . $dq['month'] . '-' . $dq['day'] ) ); if ( ( isset( $dq['inclusive'] ) && $dq['inclusive'] ) || $inclusive ) { - $the_date = date( 'Y-m-d', strtotime( '+1 Day', strtotime( $the_date ) ) ); + $the_date = gmdate( 'Y-m-d', strtotime( '+1 Day', strtotime( $the_date ) ) ); } return '(' . $column . ':' . '[' . $the_date . 'T00:00:00Z TO *])'; diff --git a/readme.txt b/readme.txt index 2286b3d5..81185dbb 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: search Requires at least: 4.6 Requires PHP: 7.1 Tested up to: 5.4 -Stable tag: 2.1.3 +Stable tag: 2.1.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -164,6 +164,9 @@ To support searching by author name (e.g. where "Pantheon" would return posts au == Changelog == += 2.1.4 (April 24, 2020) = +* Ensures highlighting is also applied to the post excerpt [[#446](https://github.com/pantheon-systems/solr-power/pull/446)]. + = 2.1.3 (November 16, 2019) = * Add `solr_power_ajax_search_query_args` filter to modify AJAX search query arguments [[#432](https://github.com/pantheon-systems/solr-power/pull/432)]. diff --git a/solr-power.php b/solr-power.php index 7ab5b388..ae81c9b6 100644 --- a/solr-power.php +++ b/solr-power.php @@ -2,7 +2,7 @@ /** * Plugin Name: Solr Power * Description: Allows WordPress sites to index and search content with ApacheSolr. - * Version: 2.1.3 + * Version: 2.1.4 * Author: Pantheon * Author URI: http://pantheon.io * Text Domain: solr-for-wordpress-on-pantheon @@ -10,10 +10,10 @@ * @package Solr_Power **/ -define( 'SOLR_POWER_VERSION', '2.1.3' ); +define( 'SOLR_POWER_VERSION', '2.1.4' ); /** - * Copyright (c) 2011-2019 Pantheon, Matt Weber, Solr Power contributors + * Copyright (c) 2011-2020 Pantheon, Matt Weber, Solr Power contributors * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights diff --git a/template/s4w_search.php b/template/s4w_search.php index fad3c698..11238568 100644 --- a/template/s4w_search.php +++ b/template/s4w_search.php @@ -107,7 +107,7 @@ $result['authorlink'], $result['author'], get_the_category_list( ', ', '', $result['id'] ), - date( 'm/d/Y', strtotime( $result['date'] ) ), + gmdate( 'm/d/Y', strtotime( $result['date'] ) ), $result['comment_link'], $result['numcomments'] ); diff --git a/template/s4wp_search.php b/template/s4wp_search.php index fad3c698..11238568 100644 --- a/template/s4wp_search.php +++ b/template/s4wp_search.php @@ -107,7 +107,7 @@ $result['authorlink'], $result['author'], get_the_category_list( ', ', '', $result['id'] ), - date( 'm/d/Y', strtotime( $result['date'] ) ), + gmdate( 'm/d/Y', strtotime( $result['date'] ) ), $result['comment_link'], $result['numcomments'] );