-
-
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 59 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 ) ) { | ||
|
@@ -3526,7 +3539,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 +3721,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 +4645,7 @@ public function __get( $name ) { | |
'page_var', | ||
'search', | ||
'search_var', | ||
'filter_var', | ||
'search_mode', | ||
'api', | ||
'row_number', | ||
|
@@ -4695,6 +4711,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 |
---|---|---|
|
@@ -1745,16 +1745,12 @@ | |
if ( $load_params ) { | ||
$pod = $this->load_pod( $load_params ); | ||
|
||
if ( is_wp_error( $pod ) ) { | ||
$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 @@ | |
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 @@ | |
* | ||
* 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 @@ | |
* | ||
* @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 @@ | |
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 @@ | |
// 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 | ||
|
@@ -9785,7 +9769,7 @@ | |
|
||
$related = get_comments( $comment_args ); | ||
|
||
if ( ! is_wp_error( $related ) ) { | ||
if ( $related ) { | ||
$related_ids = $related; | ||
} | ||
} elseif ( | ||
|
@@ -10456,13 +10440,13 @@ | |
/** | ||
* 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 @@ | |
* | ||
* 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 @@ | |
*/ | ||
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 @@ | |
|
||
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 @@ | |
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 @@ | |
} else { | ||
// Do normal cache clear. | ||
pods_cache_clear( true ); | ||
|
||
wp_cache_flush(); | ||
} | ||
|
||
if ( $flush_rewrites ) { | ||
|
@@ -11681,7 +11660,7 @@ | |
$post = get_post( $post ); | ||
} | ||
|
||
if ( ! $post || is_wp_error( $post ) ) { | ||
if ( ! $post instanceof WP_Post ) { | ||
return false; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4375,37 +4375,37 @@ public function add_rest_settings_tab_fields( $options, $pod ) { | |
} | ||
|
||
$options['rest-api'] = [ | ||
'rest_enable' => [ | ||
'rest_enable' => [ | ||
'label' => __( 'Enable', 'pods' ), | ||
'help' => __( 'Add REST API support for this Pod.', 'pods' ), | ||
'type' => 'boolean', | ||
'default' => '', | ||
'dependency' => true, | ||
], | ||
'rest_base' => [ | ||
'rest_base' => [ | ||
'label' => __( 'REST Base (if any)', 'pods' ), | ||
'help' => __( 'This will form the url for the route. Default / empty value here will use the pod name.', 'pods' ), | ||
'type' => 'text', | ||
'default' => '', | ||
'depends-on' => [ 'rest_enable' => true ], | ||
], | ||
'rest_namespace' => [ | ||
'rest_namespace' => [ | ||
'label' => __( 'REST API namespace', 'pods' ), | ||
'help' => __( 'This will change the namespace URL of the REST API route to a different one from the default one that all normal route endpoints use.', 'pods' ), | ||
'type' => 'text', | ||
'default' => '', | ||
'placeholder' => 'wp/v2', | ||
'depends-on' => [ 'rest_enable' => true ], | ||
], | ||
'read_all' => [ | ||
'read_all' => [ | ||
'label' => __( 'Show All Fields (read-only)', 'pods' ), | ||
'help' => __( 'Show all fields in REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ), | ||
'type' => 'boolean', | ||
'default' => '', | ||
'depends-on' => [ 'rest_enable' => true ], | ||
'dependency' => true, | ||
], | ||
'read_all_access' => [ | ||
'read_all_access' => [ | ||
'label' => __( 'Read All Access', 'pods' ), | ||
'help' => __( 'By default the REST API will allow the fields to be returned for everyone who has access to that endpoint/object. You can also restrict the access of your field based on whether the person is logged in.', 'pods' ), | ||
'type' => 'boolean', | ||
|
@@ -4414,12 +4414,12 @@ public function add_rest_settings_tab_fields( $options, $pod ) { | |
'read_all' => true, | ||
], | ||
], | ||
'write_all' => [ | ||
'label' => __( 'Allow All Fields To Be Updated', 'pods' ), | ||
'help' => __( 'Allow all fields to be updated via the REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ), | ||
'type' => 'boolean', | ||
'default' => pods_v( 'name', $pod ), | ||
'depends-on' => [ 'rest_enable' => true, 'read_all' => true ], | ||
'write_all' => [ | ||
'label' => __( 'Allow All Fields To Be Updated', 'pods' ), | ||
'help' => __( 'Allow all fields to be updated via the REST API. If unchecked fields must be enabled on a field by field basis.', 'pods' ), | ||
'type' => 'boolean', | ||
'default' => '', | ||
'depends-on' => [ 'rest_enable' => true, 'read_all' => true ], | ||
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 🐶 |
||
], | ||
/*'write_all_access' => [ | ||
'label' => __( 'Write All Access', 'pods' ), | ||
|
@@ -4430,20 +4430,20 @@ public function add_rest_settings_tab_fields( $options, $pod ) { | |
'write_all' => true, | ||
], | ||
],*/ | ||
'rest_api_field_mode' => [ | ||
'label' => __( 'Field Mode', 'pods' ), | ||
'help' => __( 'Specify how you would like your values returned in the REST API responses. If you choose to show Both raw and rendered values then an object will be returned for each field that contains the value and rendered properties.', 'pods' ), | ||
'type' => 'pick', | ||
'rest_api_field_mode' => [ | ||
'label' => __( 'Field Mode', 'pods' ), | ||
'help' => __( 'Specify how you would like your values returned in the REST API responses. If you choose to show Both raw and rendered values then an object will be returned for each field that contains the value and rendered properties.', 'pods' ), | ||
'type' => 'pick', | ||
'pick_format_single' => 'radio', | ||
'default' => 'value', | ||
'depends-on' => [ 'rest_enable' => true ], | ||
'data' => [ | ||
'default' => 'value', | ||
'depends-on' => [ 'rest_enable' => true ], | ||
'data' => [ | ||
'value' => __( 'Raw values', 'pods' ), | ||
'render' => __( 'Rendered values', 'pods' ), | ||
'value_and_render' => __( 'Both raw and rendered values {value: raw_value, rendered: rendered_value}', 'pods' ), | ||
], | ||
], | ||
'rest_api_field_location' => [ | ||
'rest_api_field_location' => [ | ||
'label' => __( 'Field Location', 'pods' ), | ||
'help' => __( 'Specify where you would like your values returned in the REST API responses. To show in the "meta" object of the response, you must have Custom Fields enabled in the Post Type Supports features.', 'pods' ), | ||
'type' => 'pick', | ||
|
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