-
-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pods 3.2.7 #7331
Pods 3.2.7 #7331
Changes from all commits
6d74f29
7ef89e5
e25db13
5e7b3cb
c347208
fe2671d
21cd97b
2d8c301
4a167c2
47b46f3
696f5a0
2fd7434
4bc165d
f9b84e1
247e180
bb596e5
efaa10c
4c8f25e
f76a670
013ea67
31d72b0
670079f
0ff135e
32d62a7
9357c2d
ff55e29
c9095f0
54e0020
0bace07
5aac0c6
a061600
c0f0663
2913b34
78c9a2f
d5c5c1b
76caf18
fea6f2d
4e5b0b1
db52c94
4a80b15
371a07b
b4f492c
5766add
8219d6e
69d4c3a
24f6bc1
f9f92d7
35e9f52
9171ecb
7e07a50
efa97df
68fc2bc
8b2b87c
32af949
b7c0a0f
7a35076
9f71c66
55fa1a1
9a16ab9
44e1cb0
c7d542d
5d26a32
3a5cf0a
6b3d4c5
2cf5a70
64e8dff
a749bce
6274a8e
091c677
a4c3365
3a45454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
* @property null|string $search Whether search is enabled. | ||
* @property null|string $search_var The query variable used for search. | ||
* @property null|string $search_mode The search mode to use. | ||
* @property null|string $params The last find() params. | ||
* @property null|string $filter_var The query variable used for filters. | ||
* @property null|array $params The last find() params. | ||
* @property null|string $sql The last find() SQL query. | ||
*/ | ||
class Pods implements Iterator { | ||
|
@@ -1349,11 +1350,19 @@ public function field( $name, $single = null, $raw = false ) { | |
|
||
$item_data = array(); | ||
|
||
// Debug purposes | ||
if ( 1 == pods_v( 'pods_debug_params_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
pods_debug( __METHOD__ . ':' . __LINE__ ); | ||
pods_debug( $sql ); | ||
} | ||
|
||
if ( ! $related_obj || ! $related_obj->valid() ) { | ||
if ( ! is_object( $this->alt_data ) ) { | ||
$this->alt_data = pods_data(); | ||
} | ||
|
||
pods_debug_log_data( [ 'field_name' => $params->name, 'sql' => $sql ], 'related-field-params', __METHOD__, __LINE__ ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
|
||
$item_data = $this->alt_data->select( $sql ); | ||
} else { | ||
// Support 'find' output ordering. | ||
|
@@ -1364,6 +1373,8 @@ public function field( $name, $single = null, $raw = false ) { | |
$sql['orderby'] = 'FIELD( `t`.`' . $table['field_id'] . '`, ' . $order_ids . ' )'; | ||
} | ||
|
||
pods_debug_log_data( [ 'field_name' => $params->name, 'sql' => $sql ], 'related-field-params', __METHOD__, __LINE__ ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
|
||
$related_obj->find( $sql ); | ||
|
||
// Support 'find' output. | ||
|
@@ -2391,6 +2402,7 @@ public function find( $params = null, $limit = 15, $where = null, $sql = null ) | |
'search_across_picks' => false, | ||
'search_across_files' => false, | ||
// Advanced parameters. | ||
'filter_var' => $this->filter_var, | ||
'filters' => $this->filters, | ||
'sql' => $sql, | ||
// Caching parameters. | ||
|
@@ -2428,6 +2440,7 @@ public function find( $params = null, $limit = 15, $where = null, $sql = null ) | |
$this->pagination = (boolean) $params->pagination; | ||
$this->search = (boolean) $params->search; | ||
$this->search_var = $params->search_var; | ||
$this->filter_var = $params->filter_var; | ||
$params->join = (array) $params->join; | ||
|
||
if ( empty( $params->search_query ) ) { | ||
|
@@ -3367,28 +3380,29 @@ public function pagination( $params = null ) { | |
$append = '&'; | ||
} | ||
|
||
$defaults = array( | ||
'type' => 'advanced', | ||
'label' => __( 'Go to page:', 'pods' ), | ||
'show_label' => true, | ||
'first_text' => __( '« First', 'pods' ), | ||
'prev_text' => __( '‹ Previous', 'pods' ), | ||
'next_text' => __( 'Next ›', 'pods' ), | ||
'last_text' => __( 'Last »', 'pods' ), | ||
'prev_next' => true, | ||
'first_last' => true, | ||
'limit' => (int) $this->limit, | ||
'offset' => (int) $this->offset, | ||
'page' => max( 1, (int) $this->page ), | ||
'mid_size' => 2, | ||
'end_size' => 1, | ||
'total_found' => $this->total_found(), | ||
'page_var' => $this->page_var, | ||
'base' => "{$url}{$append}%_%", | ||
'format' => "{$this->page_var}=%#%", | ||
'class' => '', | ||
'link_class' => '', | ||
); | ||
$defaults = [ | ||
'type' => 'advanced', | ||
'label' => __( 'Go to page:', 'pods' ), | ||
'show_label' => true, | ||
'first_text' => __( '« First', 'pods' ), | ||
'prev_text' => __( '‹ Previous', 'pods' ), | ||
'next_text' => __( 'Next ›', 'pods' ), | ||
'last_text' => __( 'Last »', 'pods' ), | ||
'prev_next' => true, | ||
'first_last' => true, | ||
'limit' => (int) $this->limit, | ||
'offset' => (int) $this->offset, | ||
'page' => max( 1, (int) $this->page ), | ||
'mid_size' => 2, | ||
'end_size' => 1, | ||
'total_found' => $this->total_found(), | ||
'page_var' => $this->page_var, | ||
'base' => "{$url}{$append}%_%", | ||
'format' => "{$this->page_var}=%#%", | ||
'class' => '', | ||
'link_class' => '', | ||
'wrap_pagination' => false, | ||
]; | ||
|
||
if ( is_object( $params ) ) { | ||
$params = get_object_vars( $params ); | ||
|
@@ -3408,6 +3422,8 @@ public function pagination( $params = null ) { | |
$pagination = 'advanced'; | ||
} | ||
|
||
$wrap_pagination = (bool) $params->wrap_pagination; | ||
|
||
ob_start(); | ||
|
||
pods_view( PODS_DIR . 'ui/front/pagination/' . $pagination . '.php', compact( array_keys( get_defined_vars() ) ) ); | ||
|
@@ -3526,7 +3542,7 @@ public function filters( $params = null ) { | |
$search = trim( $params['search'] ); | ||
|
||
if ( '' === $search ) { | ||
$search = pods_v_sanitized( $pod->search_var, 'get', '' ); | ||
$search = sanitize_text_field( pods_v( $pod->search_var, 'get', '' ) ); | ||
} | ||
|
||
ob_start(); | ||
|
@@ -3708,6 +3724,8 @@ public function template( $template_name, $code = null, $deprecated = false, $ch | |
if ( ! empty( $code ) ) { | ||
// Only detail templates need $this->id. | ||
if ( empty( $this->id ) ) { | ||
$this->reset(); | ||
|
||
while ( $this->fetch() ) { | ||
$info['item_id'] = $this->id(); | ||
|
||
|
@@ -4630,6 +4648,7 @@ public function __get( $name ) { | |
'page_var', | ||
'search', | ||
'search_var', | ||
'filter_var', | ||
'search_mode', | ||
'api', | ||
'row_number', | ||
|
@@ -4695,6 +4714,7 @@ public function __set( $name, $value ): void { | |
'page_var' => 'string', | ||
'search' => 'boolean', | ||
'search_var' => 'string', | ||
'filter_var' => 'string', | ||
'search_mode' => 'string', | ||
'id' => 'int', | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1749,12 +1749,8 @@ public function save_pod( $params, $sanitized = false, $db = true ) { | |
$pod = null; | ||
} | ||
|
||
if ( $fail_on_load ) { | ||
if ( is_wp_error( $pod ) ) { | ||
return $pod; | ||
} elseif ( empty( $pod ) ) { | ||
return pods_error( __( 'Pod not found', 'pods' ), $this ); | ||
} | ||
if ( $fail_on_load && ! $pod instanceof Pod ) { | ||
return pods_error( __( 'Pod not found', 'pods' ), $this ); | ||
} | ||
} | ||
} | ||
|
@@ -3285,7 +3281,7 @@ public function save_field( $params, $table_operation = true, $sanitized = false | |
if ( $load_params ) { | ||
$field_obj = $this->load_field( $load_params ); | ||
|
||
if ( $fail_on_load && ( empty( $field_obj ) || is_wp_error( $field_obj ) ) ) { | ||
if ( $fail_on_load && ! $field_obj instanceof Field ) { | ||
return $field_obj; | ||
} | ||
} | ||
|
@@ -4830,11 +4826,12 @@ public function save_pod_item( $params ) { | |
* | ||
* Use for globally setting field change tracking. | ||
* | ||
* @param bool | ||
* @param bool $track_changed_fields Whether to track changed fields or not. | ||
* @param object $params The parameters passed to save_pod_item. | ||
* | ||
* @since 2.3.19 | ||
*/ | ||
$track_changed_fields = apply_filters( "pods_api_save_pod_item_track_changed_fields_{$pod_name}", (boolean) $params->track_changed_fields, $params ); | ||
$track_changed_fields = (bool) apply_filters( "pods_api_save_pod_item_track_changed_fields_{$pod_name}", (bool) $params->track_changed_fields, $params ); | ||
|
||
$changed_fields = array(); | ||
|
||
|
@@ -5083,10 +5080,10 @@ public function save_pod_item( $params ) { | |
* | ||
* @since 3.0 | ||
* | ||
* @param bool $is_visible Whether the field is visible from conditional logic. | ||
* @param Field $field The field object. | ||
* @param array $field_values The field values referenced. | ||
* @param object $params The save_pod_item parameters. | ||
* @param bool $is_visible Whether the field is visible from conditional logic. | ||
* @param Field|Value_Field $field The field object. | ||
* @param array $field_values The field values referenced. | ||
* @param object $params The save_pod_item parameters. | ||
*/ | ||
$is_visible = (bool) apply_filters( | ||
'pods_api_save_pod_item_conditional_logic_field_is_visible', | ||
|
@@ -6192,17 +6189,17 @@ public static function handle_changed_fields( $pod, $id, $mode = 'set' ) { | |
return []; | ||
} | ||
|
||
$changed_pods_cache = pods_static_cache_get( 'changed_pods_cache', __CLASS__ ) ?: []; | ||
$old_fields_cache = pods_static_cache_get( 'old_fields_cache', __CLASS__ ) ?: []; | ||
$changed_fields_cache = pods_static_cache_get( 'changed_fields_cache', __CLASS__ ) ?: []; | ||
$changed_pods_cache = (array) ( pods_static_cache_get( 'changed_pods_cache', __CLASS__ ) ?: [] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
$old_fields_cache = (array) ( pods_static_cache_get( 'old_fields_cache', __CLASS__ ) ?: [] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
$changed_fields_cache = (array) ( pods_static_cache_get( 'changed_fields_cache', __CLASS__ ) ?: [] ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [phpcs] reported by reviewdog 🐶 |
||
|
||
$cache_key = $pod . '|' . $id; | ||
|
||
$export_params = array( | ||
'depth' => 1, | ||
); | ||
|
||
if ( in_array( $mode, array( 'set', 'reset' ), true ) ) { | ||
if ( in_array( $mode, [ 'set', 'reset' ], true ) ) { | ||
if ( isset( $changed_fields_cache[ $cache_key ] ) ) { | ||
unset( $changed_fields_cache[ $cache_key ] ); | ||
} | ||
|
@@ -7957,19 +7954,6 @@ public function delete_pod_item( $params, $wp = true ) { | |
// Plugin hook | ||
$this->do_hook( 'pre_delete_pod_item', $params, $pod ); | ||
$this->do_hook( "pre_delete_pod_item_{$params->pod}", $params, $pod ); | ||
|
||
// Call any pre-save helpers (if not bypassed) | ||
if ( ! defined( 'PODS_DISABLE_EVAL' ) || ! PODS_DISABLE_EVAL ) { | ||
if ( ! empty( $pod ) ) { | ||
$helpers = array( 'pre_delete_helpers', 'post_delete_helpers' ); | ||
|
||
foreach ( $helpers as $helper ) { | ||
if ( isset( $pod[ $helper ] ) && ! empty( $pod[ $helper ] ) ) { | ||
${$helper} = explode( ',', $pod[ $helper ] ); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Delete object from relationship fields | ||
|
@@ -8349,7 +8333,7 @@ public function get_pod_type_count( $type ) { | |
* | ||
* @param bool $strict Makes sure the pod exists, throws an error if it doesn't work. | ||
* | ||
* @return Pods\Whatsit\Pod|false Pod object or false if not found. | ||
* @return Pods\Whatsit\Pod|false|WP_Error Pod object or false if not found. | ||
* | ||
* @throws Exception | ||
* @since 1.7.9 | ||
|
@@ -9785,7 +9769,7 @@ public function lookup_related_items( $field_id, $pod_id, $ids, $field = null, $ | |
|
||
$related = get_comments( $comment_args ); | ||
|
||
if ( ! is_wp_error( $related ) ) { | ||
if ( $related ) { | ||
$related_ids = $related; | ||
} | ||
} elseif ( | ||
|
@@ -10456,13 +10440,13 @@ public function get_table_info( $object_type, $object, $name = null, $pod = null | |
/** | ||
* Allow filtering the table information for an object. | ||
* | ||
* @param array $info The table information. | ||
* @param string $object_type The object type. | ||
* @param string $object The object name. | ||
* @param string $name The pod name. | ||
* @param array|Pod $pod The pod config (if found). | ||
* @param array|Field $field The field config (if found). | ||
* @param self $obj The PodsAPI object. | ||
* @param array $info The table information. | ||
* @param string $object_type The object type. | ||
* @param string $object The object name. | ||
* @param string|null $name The pod name. | ||
* @param array|Pod|null $pod The pod config (if found). | ||
* @param array|Field|null $field The field config (if found). | ||
* @param self $obj The PodsAPI object. | ||
*/ | ||
return apply_filters( 'pods_api_get_table_info', $info, $object_type, $object, $name, $pod, $field, $this ); | ||
} else { | ||
|
@@ -10570,13 +10554,14 @@ public function get_table_info( $object_type, $object, $name = null, $pod = null | |
* | ||
* Use to change "default" post status from publish to any other status or statuses. | ||
* | ||
* @param array $post_status List of post statuses. Default is 'publish' or field setting (if available). | ||
* @param string $post_type Post type of current object. | ||
* @param array $info Array of information about the object. | ||
* @param string $object Type of object. | ||
* @param string $name Name of pod to load. | ||
* @param array $pod Array with Pod information. Result of PodsAPI::load_pod(). | ||
* @param array $field Array with field information. | ||
* @param array $post_status List of post statuses. Default is 'publish' or field setting (if available). | ||
* @param string $post_type Post type of current object. | ||
* @param array $info Array of information about the object. | ||
* @param string $object_type Type of object. | ||
* @param string $object Object name if provided. | ||
* @param string|null $name Name of pod to load. | ||
* @param array|Pod|null $pod The pod config (if found). | ||
* @param array|Field|null $field The field config (if found). | ||
* | ||
* @since unknown | ||
*/ | ||
|
@@ -10993,10 +10978,6 @@ public function import( $import_data, $numeric_mode = false, $format = null ) { | |
*/ | ||
global $wpdb; | ||
|
||
if ( null === $format && null !== $this->format ) { | ||
$format = $this->format; | ||
} | ||
|
||
if ( 'csv' === $format && ! is_array( $import_data ) ) { | ||
$data = pods_migrate( 'sv', ',' )->parse( $import_data ); | ||
|
||
|
@@ -11016,8 +10997,6 @@ public function import( $import_data, $numeric_mode = false, $format = null ) { | |
|
||
if ( ! empty( $this->pod_data ) ) { | ||
$pod = $this->pod_data; | ||
} elseif ( ! empty( $this->pod ) ) { | ||
$pod = $this->load_pod( [ 'name' => $this->pod ], false ); | ||
} | ||
|
||
if ( false === $pod ) { | ||
|
@@ -11183,8 +11162,6 @@ public function export( $pod = null, $params = null ) { | |
if ( empty( $pod ) ) { | ||
if ( ! empty( $this->pod_data ) ) { | ||
$pod = $this->pod_data; | ||
} elseif ( ! empty( $this->pod ) ) { | ||
$pod = $this->load_pod( [ 'name' => $this->pod ], false ); | ||
} | ||
} | ||
|
||
|
@@ -11341,6 +11318,8 @@ public function cache_flush_pods( | |
} else { | ||
// Do normal cache clear. | ||
pods_cache_clear( true ); | ||
|
||
wp_cache_flush(); | ||
} | ||
|
||
if ( $flush_rewrites ) { | ||
|
@@ -11681,7 +11660,7 @@ public function get_pods_object_from_wp_post( $post ) { | |
$post = get_post( $post ); | ||
} | ||
|
||
if ( ! $post || is_wp_error( $post ) ) { | ||
if ( ! $post instanceof WP_Post ) { | ||
return false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[phpcs] reported by reviewdog 🐶
Squiz.Commenting.InlineComment.InvalidEndChar
Inline comments must end in full-stops, exclamation marks, or question marks