Skip to content

Commit

Permalink
Merge pull request #447 from pantheon-systems/update-readme-2-1-4
Browse files Browse the repository at this point in the history
Update README for v2.1.4
  • Loading branch information
danielbachhuber authored Apr 24, 2020
2 parents c73fe53 + 9d6b885 commit 458cd5b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 62 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

```
<?php
/**
* Define Solr host IP, port, scheme and path
* Update these as necessary if your configuration differs
*/
putenv( 'PANTHEON_INDEX_HOST=192.168.50.4' );
putenv( 'PANTHEON_INDEX_PORT=8983' );
add_filter( 'solr_scheme', function(){ return 'http'; });
define( 'SOLR_PATH', '/solr/wordpress/' );
```
<?php
/**
* Define Solr host IP, port, scheme and path
* Update these as necessary if your configuration differs
*/
putenv( 'PANTHEON_INDEX_HOST=192.168.50.4' );
putenv( 'PANTHEON_INDEX_PORT=8983' );
add_filter( 'solr_scheme', function(){ return 'http'; });
define( 'SOLR_PATH', '/solr/wordpress/' );

## Development ##

Expand Down Expand Up @@ -166,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)].

Expand Down
36 changes: 18 additions & 18 deletions includes/class-solrpower-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,26 +288,26 @@ function build_document(
$doc->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 );
Expand Down
52 changes: 26 additions & 26 deletions includes/class-solrpower-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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';

Expand All @@ -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';

Expand Down Expand Up @@ -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':
Expand All @@ -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])';
Expand All @@ -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 *])';
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)].

Expand Down
6 changes: 3 additions & 3 deletions solr-power.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
/**
* 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
*
* @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
Expand Down
2 changes: 1 addition & 1 deletion template/s4w_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
Expand Down
2 changes: 1 addition & 1 deletion template/s4wp_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']
);
Expand Down

0 comments on commit 458cd5b

Please sign in to comment.