Skip to content

Commit a29b084

Browse files
authored
gppa-post-meta-datepicker-comparison.php: Deprecated.
1 parent 93d4938 commit a29b084

File tree

1 file changed

+3
-62
lines changed

1 file changed

+3
-62
lines changed
Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,6 @@
11
<?php
22
/**
3-
* Gravity Perks // Populate Anything // Use Post Meta Date Picker Fields for Comparison
4-
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
5-
*
6-
* The snippet will cast dates saved by Advanced Custom Fields or Pods into dates that are comparable using MySQL queries.
7-
*
8-
* Instructions:
9-
* 1. Install per https://gravitywiz.com/documentation/how-do-i-install-a-snippet/
10-
* 2. Replace DATEPICKERMETAKEYNAME with the appropriate ACF/Pods Date Picker Field meta key name.
11-
* 3. Uncomment/comment the appropriate $date_format variable depending on if you are using ACF or Pods.
12-
*
13-
*
14-
* Plugin Name: GP Populate Anything — Use Post Meta Date Picker Fields for Comparison
15-
* Plugin URI: https://gravitywiz.com/documentation/gravity-forms-populate-anything/
16-
* Description: Cast dates saved by Advanced Custom Fields or Pods into dates that are comparable using MySQL queries.
17-
* Author: Gravity Wiz
18-
* Version: 0.1
19-
* Author URI: https://gravitywiz.com
3+
* WARNING! THIS SNIPPET IS DEPRECATED. 🚧
4+
* This functionality is now possible without the snippet.
5+
* You can read more about it here: https://gravitywiz.com/documentation/gravity-forms-populate-anything/#how-can-i-return-only-posts-with-future-dates
206
*/
21-
add_filter( 'gppa_object_type_post_filter_meta_DATEPICKERMETAKEYNAME', 'process_filter_post_meta_date_picker', 10, 4 );
22-
function process_filter_post_meta_date_picker( $query_builder_args, $args ) {
23-
24-
// Uncomment/comment the appropriate lines below depending on if you are using ACF or Pods.
25-
$date_format = '%%Y%%m%%d'; // ACF
26-
//$date_format = '%%Y-%%m-%%d'; // Pods
27-
28-
global $wpdb;
29-
30-
/**
31-
* @var $filter_value
32-
* @var $filter
33-
* @var $filter_group
34-
* @var $filter_group_index
35-
* @var $property
36-
* @var $property_id
37-
*/
38-
// phpcs:ignore WordPress.PHP.DontExtract.extract_extract
39-
extract( $args );
40-
41-
$object_type = gp_populate_anything()->get_object_type( 'post' );
42-
$meta_operator = $object_type->get_sql_operator( $filter['operator'] );
43-
$meta_value = $object_type->get_sql_value( $filter['operator'], $filter_value );
44-
45-
if ( ! isset( $object_type->post_date_meta_counter ) ) {
46-
$object_type->post_date_meta_counter = 0;
47-
}
48-
49-
$object_type->post_date_meta_counter ++;
50-
$as_table = 'mq' . $object_type->post_date_meta_counter;
51-
52-
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
53-
$query_builder_args['where'][ $filter_group_index ][] = $wpdb->prepare( "(
54-
{$as_table}.meta_key = %s
55-
AND
56-
STR_TO_DATE({$as_table}.meta_value, )
57-
{$meta_operator}
58-
STR_TO_DATE(%s, $date_format)
59-
)", rgar( $property, 'value' ), $meta_value );
60-
61-
$query_builder_args['joins'][ $as_table ] = "LEFT JOIN {$wpdb->postmeta} AS {$as_table} ON ( {$wpdb->posts}.ID = {$as_table}.post_id )";
62-
63-
return $query_builder_args;
64-
65-
}

0 commit comments

Comments
 (0)