Skip to content

Commit

Permalink
(fix): meta-query with multiple arguments not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinsiebel committed Jul 14, 2021
1 parent fa87abf commit bd5ac8b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version [2.0.11]

### Fix

- Meta-query with multiple arguments not working correctly.

## Version [2.0.10]

### Feat
Expand Down
2 changes: 1 addition & 1 deletion openpub-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Yard | OpenPub Base
* Plugin URI: https://www.openwebconcept.nl/
* Description: Acts as foundation for other OpenPub related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations.
* Version: 2.0.10
* Version: 2.0.11
* Author: Yard | Digital Agency
* Author URI: https://www.yard.nl/
* License: GPL-3.0
Expand Down
4 changes: 2 additions & 2 deletions src/Base/Admin/AdminServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function register()
public function filterPostLink($link, \WP_Post $post): string
{
$itemModel = Item::makeFrom($post);
$url = $itemModel->getPortalURL();
$url = $itemModel->getPortalURL();
return $url . "?preview=true";
}

Expand All @@ -30,7 +30,7 @@ public function filterPostLink($link, \WP_Post $post): string
*/
public function restPrepareResponseLink(\WP_REST_Response $response, \WP_Post $post): \WP_REST_Response
{
$itemModel = Item::makeFrom($post);
$itemModel = Item::makeFrom($post);
$response->data['link'] = $itemModel->getPortalURL() ?? '';

return $response;
Expand Down
2 changes: 1 addition & 1 deletion src/Base/Foundation/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Plugin
*
* @var string VERSION
*/
const VERSION = '2.0.10';
const VERSION = '2.0.11';

/**
* Path to the root of the plugin.
Expand Down
42 changes: 18 additions & 24 deletions src/Base/Repositories/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ class Item extends AbstractRepository

protected static $globalFields = [];

/**
* Add additional query arguments.
*/
public function query(array $args): AbstractRepository
{
$this->queryArgs = array_merge($this->queryArgs, $args);

return $this;
}

/**
* Add parameters to meta_query to remove items with expired date.
*
Expand All @@ -31,17 +21,19 @@ public static function addExpirationParameters(): array

return [
'meta_query' => [
'relation' => 'OR',
[
'key' => '_owc_openpub_expirationdate',
'value' => $dateNow,
'compare' => '>=',
'type' => 'DATETIME',
],
[
'key' => '_owc_openpub_expirationdate',
'compare' => 'NOT EXISTS',
],
'relation' => 'OR',
[
'key' => '_owc_openpub_expirationdate',
'value' => $dateNow,
'compare' => '>=',
'type' => 'DATETIME',
],
[
'key' => '_owc_openpub_expirationdate',
'compare' => 'NOT EXISTS',
],
]
],
];
}
Expand All @@ -58,10 +50,12 @@ public static function addHighlightedParameters(bool $highlighted): array
return [
'meta_query' => [
[
'key' => '_owc_openpub_highlighted_item',
'value' => $highlighted ? 1 : 0,
'compare' => '=',
],
[
'key' => '_owc_openpub_highlighted_item',
'value' => $highlighted ? 1 : 0,
'compare' => '=',
],
]
],
];
}
Expand Down
4 changes: 2 additions & 2 deletions src/Base/Varnish/VarnishServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function register(): void

public function purgeVarnishCache(int $postID, \WP_Post $post): void
{
if ( ! function_exists('curl_init')){
if (! function_exists('curl_init')) {
return;
}

Expand All @@ -23,7 +23,7 @@ public function purgeVarnishCache(int $postID, \WP_Post $post): void
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PURGE');

$headers = [];
$headers = [];
$headers[] = 'Host: '. \parse_url(get_site_url(), PHP_URL_HOST);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

Expand Down

0 comments on commit bd5ac8b

Please sign in to comment.