Skip to content

Commit 294c94d

Browse files
authored
Pods 3.2.4 (#7324)
2 parents 2f8ab65 + 6f908bf commit 294c94d

File tree

13 files changed

+168
-48
lines changed

13 files changed

+168
-48
lines changed

changelog.txt

Lines changed: 34 additions & 19 deletions
Large diffs are not rendered by default.

classes/PodsRESTFields.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ public static function field_allowed_to_extend( $field, $pod, $mode ) {
216216
return false;
217217
}
218218

219-
$pod_mode_arg = 'rest_' . $mode . '_all';
220-
$pod_mode_access_arg = 'rest_' . $mode . '_all_access';
219+
$pod_mode_arg = $mode . '_all';
221220

222221
$all_fields_can_use_mode = filter_var( $pod->get_arg( $pod_mode_arg, false ), FILTER_VALIDATE_BOOLEAN );
223-
$all_fields_access = filter_var( $pod->get_arg( $pod_mode_access_arg, false ), FILTER_VALIDATE_BOOLEAN );
222+
$all_fields_access = 'read' === $mode && filter_var( $pod->get_arg( 'read_all_access', false ), FILTER_VALIDATE_BOOLEAN );
224223

225224
// Check if user must be logged in to access all fields and override whether they can use it.
226225
if ( $all_fields_can_use_mode && $all_fields_access ) {

classes/fields/file.php

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ public function options() {
154154
'pick_format_single' => 'dropdown',
155155
'pick_show_select_text' => 0,
156156
),
157+
static::$type . '_attachment_current_post_only' => array(
158+
'label' => __( 'Restrict Media Library to Current Post ID', 'pods' ),
159+
'help' => __( 'The media library will be restricted to only showing attachments that are attached to the current post ID if this field is on a Pod that is a Post Type.', 'pods' ),
160+
'depends-on' => array( static::$type . '_uploader' => 'attachment' ),
161+
'default' => 0,
162+
'type' => 'boolean',
163+
),
157164
static::$type . '_upload_dir' => array(
158165
'label' => __( 'Upload Directory', 'pods' ),
159166
'default' => 'wp',
@@ -182,7 +189,7 @@ public function options() {
182189
*
183190
* @since 2.7.28
184191
*
185-
* @param string @default_directory The custom upload directory to use by default for new fields.
192+
* @param string $default_directory The custom upload directory to use by default for new fields.
186193
*/
187194
'default' => apply_filters( "pods_form_ui_field_{$type}_upload_dir_custom", '' ),
188195
'type' => 'text',
@@ -314,6 +321,12 @@ public function options() {
314321
'pick_format_single' => 'dropdown',
315322
'pick_show_select_text' => 0,
316323
),
324+
static::$type . '_auto_set_featured_image' => array(
325+
'label' => __( 'Automatically set first image as Featured Image for the Current Post', 'pods' ),
326+
'help' => __( 'On save, the first image of this field will update the featured image for the current post if this field is on a Pod that is a Post Type.', 'pods' ),
327+
'default' => 0,
328+
'type' => 'boolean',
329+
),
317330
);
318331

319332
return $options;
@@ -384,6 +397,26 @@ public function input( $name, $value = null, $options = null, $pod = null, $id =
384397
$args = compact( array_keys( get_defined_vars() ) );
385398
$args = (object) $args;
386399

400+
$pod_data = null;
401+
402+
if ( $pod instanceof Pods ) {
403+
$pod_data = $pod->pod_data;
404+
} elseif ( $pod instanceof Pod ) {
405+
$pod_data = $pod;
406+
} elseif ( is_array( $pod ) ) {
407+
$pod_data = $pod;
408+
}
409+
410+
// Get pod type.
411+
$pod_type = $pod_data ? $pod_data['type'] : null;
412+
413+
$args->options['file_post_id'] = null;
414+
415+
// Maybe set post_id based on current post context.
416+
if ( 'post_type' === $pod_type && ! empty( $options[ static::$type . '_attachment_current_post_only' ] ) ) {
417+
$args->options['file_post_id'] = $id;
418+
}
419+
387420
/**
388421
* Access Checking
389422
*/
@@ -680,6 +713,21 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
680713

681714
$value = array_unique( array_filter( $value ), SORT_REGULAR );
682715

716+
$pod_data = null;
717+
718+
if ( $pod instanceof Pods ) {
719+
$pod_data = $pod->pod_data;
720+
} elseif ( $pod instanceof Pod ) {
721+
$pod_data = $pod;
722+
} elseif ( is_array( $pod ) ) {
723+
$pod_data = $pod;
724+
}
725+
726+
// Get pod type.
727+
$pod_type = $pod_data ? $pod_data['type'] : null;
728+
729+
$first_attachment_id = null;
730+
683731
// Handle File title saving.
684732
foreach ( $value as $attachment_id ) {
685733
$title = false;
@@ -709,6 +757,10 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
709757
continue;
710758
}
711759

760+
if ( null === $first_attachment_id ) {
761+
$first_attachment_id = $attachment_id;
762+
}
763+
712764
// Update the title if set.
713765
if (
714766
false !== $title
@@ -719,7 +771,7 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
719771
}
720772

721773
// Update attachment parent if it's not set yet and we're updating a post.
722-
if ( ! empty( $params->id ) && ! empty( $pod['type'] ) && 'post_type' === $pod['type'] ) {
774+
if ( 'post_type' === $pod_type && ! empty( $params->id ) ) {
723775
$attachment = get_post( $attachment_id );
724776

725777
if ( isset( $attachment->post_parent ) && 0 === (int) $attachment->post_parent ) {
@@ -740,6 +792,10 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
740792
}
741793
}//end foreach
742794

795+
// Set the first image as the featured image if the option is set.
796+
if ( 'post_type' === $pod_type && ! empty( $options[ static::$type . '_auto_set_featured_image' ] ) && ! empty( $first_attachment_id ) ) {
797+
set_post_thumbnail( $id, $first_attachment_id );
798+
}
743799
}
744800

745801
/**
@@ -1225,10 +1281,10 @@ public function admin_ajax_upload() {
12251281
*
12261282
* @since 2.7.28
12271283
*
1228-
* @param Pods $context_pod The Pods object of the associated pod for the post type.
1229-
* @param array $params The POSTed parameters for the request.
1230-
* @param array $field The field configuration associated to the upload field.
1231-
* @param array $pod The pod configuration associated to the upload field.
1284+
* @param Pods $context_pod The Pods object of the associated pod for the post type.
1285+
* @param object $params The POSTed parameters for the request.
1286+
* @param array $field The field configuration associated to the upload field.
1287+
* @param array $pod The pod configuration associated to the upload field.
12321288
*/
12331289
$context_pod = apply_filters( 'pods_upload_dir_custom_context_pod', $context_pod, $params, $field, $pod );
12341290

@@ -1240,7 +1296,7 @@ public function admin_ajax_upload() {
12401296
* @since 2.7.28
12411297
*
12421298
* @param string $custom_dir The directory to use for the uploaded file.
1243-
* @param array $params The POSTed parameters for the request.
1299+
* @param object $params The POSTed parameters for the request.
12441300
* @param Pods $context_pod The Pods object of the associated pod for the post type.
12451301
* @param array $field The field configuration associated to the upload field.
12461302
* @param array $pod The pod configuration associated to the upload field.

classes/fields/pick.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,15 @@ public function options() {
441441
'default' => '',
442442
'type' => 'text',
443443
],
444+
static::$type . '_sync_taxonomy' => [
445+
'label' => __( 'Sync associated taxonomy with this relationship', 'pods' ),
446+
'help' => __( 'This will automatically sync the associated taxonomy terms with the value of this relationship if this field is on a Pod that is a Post Type. If the associated taxonomy terms are different, they will be overridden on save.', 'pods' ),
447+
'wildcard-on' => [
448+
static::$type . '_object' => [
449+
'^taxonomy-.*$',
450+
],
451+
],
452+
]
444453
];
445454

446455
$post_type_pick_objects = array();
@@ -2015,6 +2024,34 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
20152024
self::$api->delete_relationships( $remove_ids, $id, $related_pod, $related_field );
20162025
}
20172026

2027+
// Handle syncing of taxonomy terms.
2028+
if ( ! empty( $pod['type'] ) && 'post_type' === $pod['type'] && ! empty( $options[ static::$type . '_sync_taxonomy' ] ) ) {
2029+
// Check if post type has the same attached taxonomy.
2030+
$taxonomies_available = get_object_taxonomies( $pod['name'] );
2031+
$taxonomies_available = array_flip( $taxonomies_available );
2032+
2033+
if ( $options instanceof Field || $options instanceof Value_Field ) {
2034+
$taxonomy_name = $options->get_related_object_name();
2035+
2036+
if ( isset( $taxonomies_available[ $taxonomy_name ] ) ) {
2037+
/**
2038+
* Allow filtering the list of term IDs that will be synced for a field.
2039+
*
2040+
* @since 3.2.4
2041+
*
2042+
* @param array $term_ids_to_sync The list of term IDs to sync.
2043+
* @param Field $field The field object.
2044+
* @param int $id The post ID.
2045+
* @param string $taxonomy_name The taxonomy name being synced.
2046+
*/
2047+
$term_ids_to_sync = apply_filters( 'pods_field_pick_save_sync_taxonomy_term_ids', $value_ids, $options, $id, $taxonomy_name );
2048+
2049+
// Update the taxonomy terms for the current post.
2050+
wp_set_post_terms( $id, $term_ids_to_sync, $taxonomy_name );
2051+
}
2052+
}
2053+
}
2054+
20182055
if ( ! $no_conflict ) {
20192056
pods_no_conflict_off( $related_pod['type'] );
20202057
}

init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: Pods - Custom Content Types and Fields
1111
* Plugin URI: https://pods.io/
1212
* Description: Pods is a framework for creating, managing, and deploying customized content types and fields
13-
* Version: 3.2.2
13+
* Version: 3.2.4
1414
* Author: Pods Framework Team
1515
* Author URI: https://pods.io/about/
1616
* Text Domain: pods
@@ -43,7 +43,7 @@
4343
add_action( 'init', 'pods_deactivate_pods_ui' );
4444
} else {
4545
// Current version.
46-
define( 'PODS_VERSION', '3.2.2' );
46+
define( 'PODS_VERSION', '3.2.4' );
4747

4848
// Current database version, this is the last version the database changed.
4949
define( 'PODS_DB_VERSION', '2.3.5' );

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pods",
3-
"version": "3.2.2",
3+
"version": "3.2.4",
44
"description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.",
55
"author": "Pods Foundation, Inc",
66
"homepage": "https://pods.io/",

readme.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: sc0ttkclark, zrothauser, keraweb, jimtrue, quasel, nicdford, james
33
Donate link: https://friends.pods.io/
44
Tags: pods, custom post types, custom taxonomies, content types, custom fields
55
Requires at least: 6.0
6-
Tested up to: 6.5
6+
Tested up to: 6.6
77
Requires PHP: 7.2
8-
Stable tag: 3.2.2
8+
Stable tag: 3.2.4
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -182,6 +182,21 @@ Pods really wouldn't be where it is without all the contributions from our [dono
182182

183183
== Changelog ==
184184

185+
= 3.2.4 - July 15th, 2024 =
186+
187+
* Feature: Allow restricting media library for File fields to only showing attachments associated to the current post ID. (@sc0ttkclark)
188+
* Feature: Allow File field to automatically use the first file saved as the featured image for the post. (@sc0ttkclark)
189+
* Feature: Add support for Post Types that have associated Taxonomies to have a Relationship field which will automatically sync to the corresponding taxonomy on save. (@sc0ttkclark)
190+
* Fixed: Register meta handling now properly loads when enabled. (@sc0ttkclark)
191+
* Fixed: Remove always visible scrollbar from Settings modal panel container since it does not scroll. (@sc0ttkclark)
192+
* Fixed: REST API Show All Fields setting for a Pod now works as expected again. (@sc0ttkclark)
193+
194+
= 3.2.3 - July 15th, 2024 =
195+
196+
The Pods 3.2.3 release turned into Pods 3.2.4 after an failed attempt at hijacking our plugin on WordPress.org was accidentally documented by online security vulnerability databases as successful.
197+
198+
To be safe and sure that those who are using Pods do not mistake Pods 3.2.3 as a vulnerable release, we will instead release the next version as Pods 3.2.4.
199+
185200
= 3.2.2 - June 18th, 2024 =
186201

187202
* Feature: You can 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)
@@ -201,30 +216,30 @@ Pods really wouldn't be where it is without all the contributions from our [dono
201216

202217
*Security Release*
203218

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

206221
= 3.2.1 - March 29th, 2024 =
207222

208223
* 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)
209-
* Fixed: Conditional logic for display callbacks 'allowed' field now showing when choosing the Customized option. (@sc0ttkclark)
224+
* Fixed: Conditional logic for display callbacks 'allowed' field now showing when choosing the Customized option. (@sc0ttkclark)
210225
* Fixed: PHP 8.1 compatibility fix for null values passed to esc_* functions in WP. (@sc0ttkclark)
211226
* Fixed: PHP 8.1 compatibility fix for html_entity_decode. (@sc0ttkclark)
212227

213228
= 3.2.0 - March 25th, 2024 =
214229

215230
* Feature: New support for Custom Field revisions in Pods that are Post Types that use Meta storage. You can optionally enable the feature per-pod or per-field. #7265 (@sc0ttkclark)
216231
* Feature: New support for WordPress `register_meta()` for all Pods fields on meta-based Pods. You can enable this feature in Pods Admin > Settings > "Register meta fields". (@sc0ttkclark)
217-
* Feature: New support for specifying where your Custom Fields show in REST API responses for Pods that support that. You can choose from Object (response.field_name) or Meta (response.meta.field_name). (@sc0ttkclark)
232+
* Feature: New support for specifying where your Custom Fields show in REST API responses for Pods that support that. You can choose from Object (response.field_name) or Meta (response.meta.field_name). (@sc0ttkclark)
218233
* Feature: New support for Custom Fields in the new [WordPress 6.5 Block Bindings API](https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/) for the `core/post-meta` source. To use your custom fields there, you will need to enable "Register meta fields" in your Pods Admin > Settings and set your Pod to show it's REST API fields in the "Meta" location instead of Object. (@sc0ttkclark)
219-
* Feature: New custom binding source support for the [WordPress 6.5 Block Bindings API](https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/). Specify your source as `pods/bindings-field` and then just pass the same arguments you would pass for a normal `[pods]` shortcode or block. This will bind that dynamic output to the block you are working with. (@sc0ttkclark)
234+
* Feature: New custom binding source support for the [WordPress 6.5 Block Bindings API](https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/). Specify your source as `pods/bindings-field` and then just pass the same arguments you would pass for a normal `[pods]` shortcode or block. This will bind that dynamic output to the block you are working with. (@sc0ttkclark)
220235
* Feature: Now you can specify whether to default values for a Pods field when the field is empty. This works great for when you add a new field to a Pod and you want to edit an existing item that did not have a field value set. The default value will be used in that circumstance. (@sc0ttkclark)
221236
* Feature: Support for multiple default values when working with a multi-select field. Now you can just separate your values with a comma and they will be set as the default values. (@sc0ttkclark)
222237
* Feature: Now you can specify whether to evaluate magic tags for default values like `{@user.ID}`. (@sc0ttkclark)
223238
* Tweak: New option for Pods shortcodes when used in plugins like Elementor to bypass detecting the loop and to just use whatever ID/post type is available. Use the `bypass_detect_loop="1"` attribute. #7269 (@sc0ttkclark)
224239
* Tweak: Added first used and last installed Pods versions to the Site Health information to be more helpful with debugging. (@sc0ttkclark)
225240
* Tweak: Improved the field label/description for Additional User Capabilities field in the CPT settings. (@sc0ttkclark)
226241
* Fixed: Resolved an annoying issue when adding a new group or field where it would reset the Pod label to the name (slug) of the pod. (@sc0ttkclark)
227-
* Fixed: Updated logic for default value handling when using magic tags for internal field configs to ensure the magic tags get evaluated. (@sc0ttkclark)
242+
* Fixed: Updated logic for default value handling when using magic tags for internal field configs to ensure the magic tags get evaluated. (@sc0ttkclark)
228243
* Fixed: Resolve issue with `pods_register_block_type()` not clearing the known blocks cache when registering them. #7167 (@sc0ttkclark)
229244
* Fixed: PHP fatal errors resolved with `array_combine()` usage from changes in WP 6.5. #7266 (@sc0ttkclark)
230245
* Fixed: Custom capability fallbacks when the option is empty now properly fallback to the default capability using that post type name. #7250 (@JoryHogeveen)

src/Pods/Service_Provider.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Pods/WP/Meta.php

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/js/dfv/pods-dfv.min.asset.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"dependencies":["lodash","moment","react","react-dom","wp-api-fetch","wp-autop","wp-components","wp-compose","wp-data","wp-element","wp-hooks","wp-i18n","wp-keycodes","wp-plugins","wp-polyfill","wp-primitives","wp-url"],"version":"53d30a6869567568bafc"}
1+
{"dependencies":["lodash","moment","react","react-dom","wp-api-fetch","wp-autop","wp-components","wp-compose","wp-data","wp-element","wp-hooks","wp-i18n","wp-keycodes","wp-plugins","wp-polyfill","wp-primitives","wp-url"],"version":"a8de38fe9fd9869753b1"}

ui/js/dfv/pods-dfv.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/js/dfv/src/admin/edit-pod/main-tabs/settings-modal.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@
123123
flex: 1 1 auto;
124124
}
125125

126-
@media screen and (max-width: 850px) {
127-
overflow-y: scroll;
128-
}
129-
130126
.pods-field-option {
131127
margin-bottom: 1em;
132128
}

ui/js/dfv/src/fields/file/uploaders/media-modal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const MediaModal = PodsFileUploader.extend( {
2828
multiple: ( 1 !== parseInt( this.fieldConfig.file_limit, 10 ) ),
2929
library: {
3030
type: this.fieldConfig.limit_types,
31+
uploadedTo: this.fieldConfig?.file_post_id,
3132
},
3233
// Customize the submit button.
3334
button: {
@@ -80,7 +81,7 @@ export const MediaModal = PodsFileUploader.extend( {
8081
name: attachment.attributes.title,
8182
edit_link: attachment.attributes.editLink,
8283
link: attachment.attributes.link,
83-
download: attachment.attributes.url
84+
download: attachment.attributes.url,
8485
} );
8586
} );
8687

0 commit comments

Comments
 (0)