Skip to content
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.2 #7285

Merged
merged 43 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fd4048d
Set version to 3.2.2-a-1
sc0ttkclark Mar 29, 2024
d5ed5a6
Fix double quote usage in SQL queries so they use single quotes inste…
sc0ttkclark May 10, 2024
bfb496f
Normalize some query parts so they avoid extra double quote string co…
sc0ttkclark May 10, 2024
55ffa4c
Fix issue with slug not generating from label when adding new field
sc0ttkclark May 18, 2024
719415a
Auto rebuild assets
sc0ttkclark May 18, 2024
573ea2e
Fix phpcs issues
sc0ttkclark May 18, 2024
b35bd3b
Phpstan fixes
sc0ttkclark May 18, 2024
d7fe30e
Tweak version
sc0ttkclark May 20, 2024
47841fc
Update for rerun of CI
sc0ttkclark May 20, 2024
e5b9290
Add support for Taxonomy Filters for post list tables
sc0ttkclark May 31, 2024
c9f6360
Fix extra field info in filteres / table columns
sc0ttkclark May 31, 2024
49aadcc
phpstan tweaks
sc0ttkclark May 31, 2024
a2a413e
Fix for taxonomy filter should_use_filter calls
sc0ttkclark Jun 3, 2024
aec53c6
Auto redirect to ID based edit URL when ID is the slug of the corresp…
sc0ttkclark Jun 3, 2024
e91433c
Only redirect on edit screen
sc0ttkclark Jun 3, 2024
d2872a4
Don’t override the value with data row if using an object expanded re…
sc0ttkclark Jun 3, 2024
2042491
Prevent potential errors with entries
sc0ttkclark Jun 3, 2024
034babe
Phpstan fixes
sc0ttkclark Jun 3, 2024
32c4de8
More phpstan fixes
sc0ttkclark Jun 3, 2024
7b2322b
Add support for REST API logged in user check for read/write access
sc0ttkclark Jun 11, 2024
5f8cfe7
Hide rest write access option for now until we add role and/or cap ch…
sc0ttkclark Jun 11, 2024
c4028d9
Fix PHP issue with trim null function calls
sc0ttkclark Jun 17, 2024
a4ee67e
Wrap ColorPicker in BaseControl for label.
pdclark Jun 12, 2024
1024f1e
Auto rebuild assets
sc0ttkclark Jun 17, 2024
45460ef
Enhancement: Add copy button to field name
heybran Apr 13, 2024
616fa9c
Build files
heybran Apr 13, 2024
da82293
Removed unused styles from copy button scss
heybran Apr 13, 2024
07b4355
Additional sanitization for values when loading into input
sc0ttkclark Jun 17, 2024
719505e
Rebuild assets
sc0ttkclark Jun 17, 2024
c012c88
Fix issue with slug not generating from label when adding new field
sc0ttkclark May 18, 2024
2fb622d
Auto rebuild assets
sc0ttkclark May 18, 2024
3571023
Auto rebuild assets
sc0ttkclark Jun 17, 2024
2dd3bc5
Update nvm/npm
sc0ttkclark Jun 17, 2024
ec3db1e
Better support for small screens in Pods Admin > Edit Pod
sc0ttkclark Jun 17, 2024
c64b059
Rebuild assets
sc0ttkclark Jun 17, 2024
4e7bc55
Auto rebuild assets
sc0ttkclark Jun 17, 2024
b733ee1
Fix phpstan
sc0ttkclark Jun 17, 2024
992b367
Phpstan fixes and TBD replaces
sc0ttkclark Jun 17, 2024
7f6eef9
Update changelog
sc0ttkclark Jun 17, 2024
09cf92a
Update wporg version(s)
sc0ttkclark Jun 17, 2024
4f926fb
Pods 3.2.2
sc0ttkclark Jun 17, 2024
a184cf2
More phpstan fixes
sc0ttkclark Jun 18, 2024
b456eb9
Fix param usage
sc0ttkclark Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ $RECYCLE.BIN/
/vendor/*
!/vendor/vendor-prefixed/
npm-debug.log
pnpm-lock.yaml

# Source maps should just be built locally
ui/js/pods-ui-ready.min.js.map
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13.2
16.16.0
21 changes: 21 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ Found a bug? Have a great feature idea? Get on GitHub and tell us about it and w

Our GitHub has the full list of all prior releases of Pods: https://github.com/pods-framework/pods/releases

= 3.2.2 - June 18th, 2024 =

* Feature: You cna now turn on Taxonomy filters for a Custom Taxonomy so that you see a dropdown filter on the list of posts for any associated post types. (@sc0ttkclark)
* Added: Pods Templates > Support for comments on post types using Pods Templates using `[each comments]` and `[if comments]`. (@sc0ttkclark)
* Added: REST API > Add support for determining whether to require person to be logged in to read values for custom fields (default: login not required). (@sc0ttkclark)
* Added: Automatically redirect to the proper edit URL when going to the Pods Admin > Edit Pods page for a specific pod but `id=XX` is the slug. (@sc0ttkclark)
* Tweak: Accessibility > Make it easier to copy and paste field names for the Edit Pod screen with a new copy icon you can click. #7291 #7237 (@heybran, @sc0ttkclark)
* Tweak: Responsive UI > Improved appearance for the Edit Pod screen for smaller screens. (@sc0ttkclark)
* Fixed: Security hardening > Sanitize HTML before passing into Pods field inputs for paragraph/code/wysiwyg field types to cover additional cases where something could make it past the sanitization process on save. (@sc0ttkclark)
* Fixed: Accessibility > Add label for color fields in the Pods Blocks API so it shows the label and not just the color input itself. #7306 #7305 (@pdclark)
* Fixed: Group and field names now generate in the UI as expected. (@sc0ttkclark)
* Fixed: Compatibility > Date, Date/Time, and Time default values now use single quotes to ensure maximum compatibiltiy with various SQL engines. (@sc0ttkclark)
* Fixed: Compatibility > More PHP compatibility issues with `trim()` related function usage resolved. (@sc0ttkclark)
* Fixed: Code quality > Various phpstan/phpcs issues resolved. (@sc0ttkclark)

= 3.2.1.1 - May 8th, 2024 =

*Security Release*

* Security hardening: Enforce safe URLs for Pods form submission confirmation page URLs. Props to the wesley (wcraft) / Wordfence for responsibly reporting this. (@sc0ttkclark)

= 3.2.1 - March 29th, 2024 =

* Performance: The Advanced Filters popup now uses Autocomplete for relationship fields to improve performance for large itemsets. FYI filters are a feature in the Manage Content UI for Advanced Content Types only. (@sc0ttkclark)
Expand Down
66 changes: 41 additions & 25 deletions classes/Pods.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,9 @@ public function fields( $field_name = null, $option = null ) {
* @since unknown
*
* @param array|\Pods\Whatsit\Field|mixed $field_data The data to be returned for the field / option.
* @param array|\Pods\Whatsit\Field $field The field information.
* @param string|null $field_name The specific field that data is being return for, if set when method is called or null.
* @param string|null $option Value of option param when method was called. Can be used to get a list of available items from a relationship field.
* @param Pods|object $this The current Pods class instance.
* @param Pods|object $obj The current Pods class instance.
*/
return apply_filters( 'pods_pods_fields', $field_data, $field_name, $option, $this );

Expand Down Expand Up @@ -643,8 +642,8 @@ public function field( $name, $single = null, $raw = false ) {
*
* @param string $output How to output related fields. Default is 'arrays'. Options: ids|names|objects|arrays|pods|find
* @param array|object $row Current row being outputted.
* @param array $params Params array passed to field().
* @param Pods $this Current Pods object.
* @param object $params Params array passed to field().
* @param Pods $obj Current Pods object.
*/
$params->output = apply_filters( 'pods_pods_field_related_output_type', 'arrays', $this->data->row, $params, $this );
}
Expand All @@ -659,7 +658,7 @@ public function field( $name, $single = null, $raw = false ) {

// Support old $orderby variable.
if ( null !== $params->single && is_string( $params->single ) && empty( $params->orderby ) ) {
if ( ! class_exists( 'Deprecated_Pod' ) || Deprecated_Pod::$deprecated_notice ) {
if ( pods_is_debug_display() ) {
pods_deprecated( 'Pods::field', '2.0', 'Use $params[ \'orderby\' ] instead' );
}

Expand Down Expand Up @@ -844,11 +843,20 @@ public function field( $name, $single = null, $raw = false ) {
$is_relationship_field_and_not_simple = (
! $is_traversal
&& $field_data
&& ! $field_data instanceof Object_Field
&& (
! $field_data instanceof Object_Field
|| 'comments' === $field_data->get_name()
)
&& $is_relationship_field
&& ! $is_simple_relationship_field
);

$is_object_expanded_relationship_field = (
$is_relationship_field
&& $field_data instanceof Object_Field
&& 'comments' === $field_data->get_name()
);

// If a relationship is returned from the table as an ID but the parameter is not traversal, we need to run traversal logic.
if ( $is_relationship_field_and_not_simple && isset( $this->data->row[ $params->name ] ) && ! is_array( $this->data->row[ $params->name ] ) ) {
unset( $this->data->row[ $params->name ] );
Expand Down Expand Up @@ -903,7 +911,14 @@ public function field( $name, $single = null, $raw = false ) {
} elseif ( empty( $value ) ) {
$object_field_found = false;

if ( 'object_field' === $field_source && ! $is_traversal ) {
if (
'object_field' === $field_source
&& ! $is_traversal
&& (
! $is_object_expanded_relationship_field
|| 'arrays' === $params->output
)
) {
$object_field_found = true;

if ( isset( $this->data->row[ $first_field ] ) ) {
Expand Down Expand Up @@ -948,8 +963,8 @@ public function field( $name, $single = null, $raw = false ) {
* @param array|string|null $value Value retrieved.
* @param array $field_data Current field object.
* @param array|object $row Current row being outputted.
* @param array $params Params array passed to field().
* @param object|Pods $this Current Pods object.
* @param object $params Params array passed to field().
* @param Pods $obj Current Pods object.
*/
$v = apply_filters( "pods_pods_field_{$field_type}", null, $field_data, $this->row(), $params, $this );

Expand Down Expand Up @@ -1010,8 +1025,8 @@ public function field( $name, $single = null, $raw = false ) {
*
* @param int $id The object ID.
* @param string $metadata_type The object metadata type.
* @param array $params Field params
* @param \Pods $pod Pods object.
* @param object $params Field params.
* @param Pods $obj Pods object.
*/
$id = apply_filters( 'pods_pods_field_get_metadata_object_id', $this->id(), $metadata_type, $params, $this );

Expand Down Expand Up @@ -1798,8 +1813,8 @@ public function field( $name, $single = null, $raw = false ) {
*
* @param array|string|null $value Value to be returned.
* @param array|object $row Current row being outputted.
* @param array $params Params array passed to field().
* @param object|Pods $this Current Pods object.
* @param object $params Params array passed to field().
* @param Pods $obj Current Pods object.
*/
$value = apply_filters( 'pods_pods_field', $value, $this->row(), $params, $this );

Expand Down Expand Up @@ -2536,8 +2551,8 @@ public function fetch( $id = null, $explicit_set = true ) {
*
* @since unknown
*
* @param int|string|null $id Item ID being fetched or null.
* @param object|Pods $this Current Pods object.
* @param int|string|null $id Item ID being fetched or null.
* @param Pods $obj Current Pods object.
*/
do_action( 'pods_pods_fetch', $id, $this );

Expand Down Expand Up @@ -2569,8 +2584,8 @@ public function reset( $row = null ) {
*
* @since unknown
*
* @param int|string|null The ID of the row being reset to or null if being reset to the beginning.
* @param object|Pods $this Current Pods object.
* @param int|string|null $row The ID of the row being reset to or null if being reset to the beginning.
* @param Pods $obj Current Pods object.
*/
do_action( 'pods_pods_reset', $row, $this );

Expand Down Expand Up @@ -2625,7 +2640,7 @@ public function total_found( $params = null ) {
*
* @since unknown
*
* @param object|Pods $this Current Pods object.
* @param Pods $obj Current Pods object.
*/
do_action( 'pods_pods_total_found', $this );

Expand Down Expand Up @@ -3525,9 +3540,9 @@ public function filters( $params = null ) {
*
* @since unknown
*
* @param string $output Filter output.
* @param array $params Params array passed to filters().
* @param object|Pods $this Current Pods object.
* @param string $output Filter output.
* @param array $params Params array passed to filters().
* @param Pods $obj Current Pods object.
*/
return apply_filters( 'pods_pods_filters', $output, $params, $this );
}
Expand Down Expand Up @@ -4281,10 +4296,11 @@ private function process_magic_tags( $tag ) {
/**
* Filter the magic tag output for a value.
*
* @param string $value Magic tag output for value.
* @param string $field_name Magic tag field name.
* @param string $before Before content.
* @param string $after After content.
* @param string $value Magic tag output for value.
* @param string $field_name Magic tag field name.
* @param string $helper_name The helper name.
* @param string $before Before content.
* @param string $after After content.
*/
$value = apply_filters( 'pods_do_magic_tags', $value, $field_name, $helper_name, $before, $after );

Expand Down
75 changes: 62 additions & 13 deletions classes/PodsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,17 +809,15 @@ public function admin_content_settings() {
* Add media button for Pods shortcode
*
* @param string $context Media button context.
*
* @return string
*/
public function media_button( $context = null ) {
if ( ! empty( $_GET['action'] ) && 'elementor' === $_GET['action'] ) {
return '';
return;
}

// If shortcodes are disabled don't show the button
if ( defined( 'PODS_DISABLE_SHORTCODE' ) && PODS_DISABLE_SHORTCODE ) {
return '';
return;
}

/**
Expand All @@ -831,7 +829,7 @@ public function media_button( $context = null ) {
* @since 2.3.19
*/
if ( ! apply_filters( 'pods_admin_media_button', true, $context ) ) {
return '';
return;
}

$current_page = basename( $_SERVER['PHP_SELF'] );
Expand All @@ -846,7 +844,7 @@ public function media_button( $context = null ) {
'post.php',
), true
) ) {
return '';
return;
}

add_action( 'admin_footer', array( $this, 'mce_popup' ) );
Expand Down Expand Up @@ -880,7 +878,9 @@ public function admin_setup() {

$pods = $api->load_pods( array( 'fields' => false ) );

$view = pods_v( 'view', 'get', 'all', true );
$id = pods_v( 'id' );
$action = pods_v( 'action' );
$view = pods_v( 'view', 'get', 'all', true );

// @codingStandardsIgnoreLine
if ( empty( $pods ) && ! isset( $_GET['action'] ) ) {
Expand Down Expand Up @@ -1395,6 +1395,17 @@ public function admin_setup() {
}
}

// Maybe auto-map the slugs to ID when editing.
if ( 'edit' === $action && $id && ! is_numeric( $id ) ) {
foreach ( $ui['data'] as $check_pod ) {
if ( $check_pod['name'] === $id && $check_pod['id'] && is_numeric( $check_pod['id'] ) ) {
pods_redirect( pods_query_arg( [ 'id' => (int) $check_pod['id'] ] ) );

break;
}
}
}

// Add our custom callouts.
$this->handle_callouts_updates();

Expand Down Expand Up @@ -2034,7 +2045,7 @@ public function get_callouts() {
*
* @since 2.7.17
*
* @param array List of callouts to enable.
* @param array $callouts List of callouts to enable.
*/
$callouts = apply_filters( 'pods_admin_callouts', $callouts );

Expand Down Expand Up @@ -3762,13 +3773,9 @@ public function admin_components() {
* Toggle a component on or off
*
* @param PodsUI $ui PodsUI object.
*
* @return bool
*/
public function admin_components_toggle( $ui ) {

// @codingStandardsIgnoreLine
$component = $_GET['id'];
$component = pods_v( 'id' );

if ( ! empty( PodsInit::$components->components[ $component ]['PluginDependency'] ) ) {
$dependency = explode( '|', PodsInit::$components->components[ $component ]['PluginDependency'] );
Expand Down Expand Up @@ -4398,13 +4405,31 @@ public function add_rest_settings_tab_fields( $options, $pod ) {
'depends-on' => [ 'rest_enable' => true ],
'dependency' => true,
],
'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',
'boolean_yes_label' => __( 'Require being logged in to read all field values via REST', 'pods' ),
'depends-on' => [
'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_access' => [
'label' => __( 'Write All Access', 'pods' ),
'help' => __( 'By default the REST API will allow the fields to be written by everyone who has access to edit that object. You can also restrict the access of your field based on whether the person is logged in.', 'pods' ),
'type' => 'boolean',
'boolean_yes_label' => __( 'Require being logged in to write to all field values via REST', 'pods' ),
'depends-on' => [
'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' ),
Expand Down Expand Up @@ -4476,6 +4501,18 @@ public function add_rest_fields_to_field_editor( $options, $pod ) {
'type' => $layout_non_input_field_types,
],
],
'rest_read_access' => [
'label' => __( 'Read 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',
'boolean_yes_label' => __( 'Require being logged in to read this field value via REST', 'pods' ),
'depends-on' => [
'rest_read' => true,
],
'excludes-on' => [
'type' => $layout_non_input_field_types,
],
],
'rest_write' => [
'label' => __( 'Write via REST API', 'pods' ),
'help' => __( 'Should this field be writeable via the REST API? You must enable REST API support for this Pod.', 'pods' ),
Expand All @@ -4485,6 +4522,18 @@ public function add_rest_fields_to_field_editor( $options, $pod ) {
'type' => $layout_non_input_field_types,
],
],
/*'rest_write_access' => [
'label' => __( 'Write Access', 'pods' ),
'help' => __( 'By default the REST API will allow the fields to be written by everyone who has access to edit that object. You can also restrict the access of your field based on whether the person is logged in.', 'pods' ),
'type' => 'boolean',
'boolean_yes_label' => __( 'Require being logged in to write to this field value via REST', 'pods' ),
'depends-on' => [
'rest_write' => true,
],
'excludes-on' => [
'type' => $layout_non_input_field_types,
],
],*/
'rest_field_options' => [
'name' => 'rest_field_options',
'label' => __( 'Relationship Field Options', 'pods' ),
Expand Down
Loading
Loading