Skip to content

Commit

Permalink
Pods 3.2.4 (#7324)
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Jul 15, 2024
2 parents 2f8ab65 + 6f908bf commit 294c94d
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 48 deletions.
53 changes: 34 additions & 19 deletions changelog.txt

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions classes/PodsRESTFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,10 @@ public static function field_allowed_to_extend( $field, $pod, $mode ) {
return false;
}

$pod_mode_arg = 'rest_' . $mode . '_all';
$pod_mode_access_arg = 'rest_' . $mode . '_all_access';
$pod_mode_arg = $mode . '_all';

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

// Check if user must be logged in to access all fields and override whether they can use it.
if ( $all_fields_can_use_mode && $all_fields_access ) {
Expand Down
70 changes: 63 additions & 7 deletions classes/fields/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ public function options() {
'pick_format_single' => 'dropdown',
'pick_show_select_text' => 0,
),
static::$type . '_attachment_current_post_only' => array(
'label' => __( 'Restrict Media Library to Current Post ID', 'pods' ),
'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' ),
'depends-on' => array( static::$type . '_uploader' => 'attachment' ),
'default' => 0,
'type' => 'boolean',
),
static::$type . '_upload_dir' => array(
'label' => __( 'Upload Directory', 'pods' ),
'default' => 'wp',
Expand Down Expand Up @@ -182,7 +189,7 @@ public function options() {
*
* @since 2.7.28
*
* @param string @default_directory The custom upload directory to use by default for new fields.
* @param string $default_directory The custom upload directory to use by default for new fields.
*/
'default' => apply_filters( "pods_form_ui_field_{$type}_upload_dir_custom", '' ),
'type' => 'text',
Expand Down Expand Up @@ -314,6 +321,12 @@ public function options() {
'pick_format_single' => 'dropdown',
'pick_show_select_text' => 0,
),
static::$type . '_auto_set_featured_image' => array(
'label' => __( 'Automatically set first image as Featured Image for the Current Post', 'pods' ),
'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' ),
'default' => 0,
'type' => 'boolean',
),
);

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

$pod_data = null;

if ( $pod instanceof Pods ) {
$pod_data = $pod->pod_data;
} elseif ( $pod instanceof Pod ) {
$pod_data = $pod;
} elseif ( is_array( $pod ) ) {
$pod_data = $pod;
}

// Get pod type.
$pod_type = $pod_data ? $pod_data['type'] : null;

$args->options['file_post_id'] = null;

// Maybe set post_id based on current post context.
if ( 'post_type' === $pod_type && ! empty( $options[ static::$type . '_attachment_current_post_only' ] ) ) {
$args->options['file_post_id'] = $id;
}

/**
* Access Checking
*/
Expand Down Expand Up @@ -680,6 +713,21 @@ public function save( $value, $id = null, $name = null, $options = null, $fields

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

$pod_data = null;

if ( $pod instanceof Pods ) {
$pod_data = $pod->pod_data;
} elseif ( $pod instanceof Pod ) {
$pod_data = $pod;
} elseif ( is_array( $pod ) ) {
$pod_data = $pod;
}

// Get pod type.
$pod_type = $pod_data ? $pod_data['type'] : null;

$first_attachment_id = null;

// Handle File title saving.
foreach ( $value as $attachment_id ) {
$title = false;
Expand Down Expand Up @@ -709,6 +757,10 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
continue;
}

if ( null === $first_attachment_id ) {
$first_attachment_id = $attachment_id;
}

// Update the title if set.
if (
false !== $title
Expand All @@ -719,7 +771,7 @@ public function save( $value, $id = null, $name = null, $options = null, $fields
}

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

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

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

/**
Expand Down Expand Up @@ -1225,10 +1281,10 @@ public function admin_ajax_upload() {
*
* @since 2.7.28
*
* @param Pods $context_pod The Pods object of the associated pod for the post type.
* @param array $params The POSTed parameters for the request.
* @param array $field The field configuration associated to the upload field.
* @param array $pod The pod configuration associated to the upload field.
* @param Pods $context_pod The Pods object of the associated pod for the post type.
* @param object $params The POSTed parameters for the request.
* @param array $field The field configuration associated to the upload field.
* @param array $pod The pod configuration associated to the upload field.
*/
$context_pod = apply_filters( 'pods_upload_dir_custom_context_pod', $context_pod, $params, $field, $pod );

Expand All @@ -1240,7 +1296,7 @@ public function admin_ajax_upload() {
* @since 2.7.28
*
* @param string $custom_dir The directory to use for the uploaded file.
* @param array $params The POSTed parameters for the request.
* @param object $params The POSTed parameters for the request.
* @param Pods $context_pod The Pods object of the associated pod for the post type.
* @param array $field The field configuration associated to the upload field.
* @param array $pod The pod configuration associated to the upload field.
Expand Down
37 changes: 37 additions & 0 deletions classes/fields/pick.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ public function options() {
'default' => '',
'type' => 'text',
],
static::$type . '_sync_taxonomy' => [
'label' => __( 'Sync associated taxonomy with this relationship', 'pods' ),
'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' ),
'wildcard-on' => [
static::$type . '_object' => [
'^taxonomy-.*$',
],
],
]
];

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

// Handle syncing of taxonomy terms.
if ( ! empty( $pod['type'] ) && 'post_type' === $pod['type'] && ! empty( $options[ static::$type . '_sync_taxonomy' ] ) ) {
// Check if post type has the same attached taxonomy.
$taxonomies_available = get_object_taxonomies( $pod['name'] );
$taxonomies_available = array_flip( $taxonomies_available );

if ( $options instanceof Field || $options instanceof Value_Field ) {
$taxonomy_name = $options->get_related_object_name();

if ( isset( $taxonomies_available[ $taxonomy_name ] ) ) {
/**
* Allow filtering the list of term IDs that will be synced for a field.
*
* @since 3.2.4
*
* @param array $term_ids_to_sync The list of term IDs to sync.
* @param Field $field The field object.
* @param int $id The post ID.
* @param string $taxonomy_name The taxonomy name being synced.
*/
$term_ids_to_sync = apply_filters( 'pods_field_pick_save_sync_taxonomy_term_ids', $value_ids, $options, $id, $taxonomy_name );

// Update the taxonomy terms for the current post.
wp_set_post_terms( $id, $term_ids_to_sync, $taxonomy_name );
}
}
}

if ( ! $no_conflict ) {
pods_no_conflict_off( $related_pod['type'] );
}
Expand Down
4 changes: 2 additions & 2 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Pods - Custom Content Types and Fields
* Plugin URI: https://pods.io/
* Description: Pods is a framework for creating, managing, and deploying customized content types and fields
* Version: 3.2.2
* Version: 3.2.4
* Author: Pods Framework Team
* Author URI: https://pods.io/about/
* Text Domain: pods
Expand Down Expand Up @@ -43,7 +43,7 @@
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version.
define( 'PODS_VERSION', '3.2.2' );
define( 'PODS_VERSION', '3.2.4' );

// Current database version, this is the last version the database changed.
define( 'PODS_DB_VERSION', '2.3.5' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pods",
"version": "3.2.2",
"version": "3.2.4",
"description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.",
"author": "Pods Foundation, Inc",
"homepage": "https://pods.io/",
Expand Down
29 changes: 22 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: sc0ttkclark, zrothauser, keraweb, jimtrue, quasel, nicdford, james
Donate link: https://friends.pods.io/
Tags: pods, custom post types, custom taxonomies, content types, custom fields
Requires at least: 6.0
Tested up to: 6.5
Tested up to: 6.6
Requires PHP: 7.2
Stable tag: 3.2.2
Stable tag: 3.2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 3.2.4 - July 15th, 2024 =

* Feature: Allow restricting media library for File fields to only showing attachments associated to the current post ID. (@sc0ttkclark)
* Feature: Allow File field to automatically use the first file saved as the featured image for the post. (@sc0ttkclark)
* 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)
* Fixed: Register meta handling now properly loads when enabled. (@sc0ttkclark)
* Fixed: Remove always visible scrollbar from Settings modal panel container since it does not scroll. (@sc0ttkclark)
* Fixed: REST API Show All Fields setting for a Pod now works as expected again. (@sc0ttkclark)

= 3.2.3 - July 15th, 2024 =

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.

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.

= 3.2.2 - June 18th, 2024 =

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

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

= 3.2.0 - March 25th, 2024 =

* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* Feature: Now you can specify whether to evaluate magic tags for default values like `{@user.ID}`. (@sc0ttkclark)
* 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)
* Tweak: Added first used and last installed Pods versions to the Site Health information to be more helpful with debugging. (@sc0ttkclark)
* Tweak: Improved the field label/description for Additional User Capabilities field in the CPT settings. (@sc0ttkclark)
* 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)
* Fixed: Updated logic for default value handling when using magic tags for internal field configs to ensure the magic tags get evaluated. (@sc0ttkclark)
* Fixed: Updated logic for default value handling when using magic tags for internal field configs to ensure the magic tags get evaluated. (@sc0ttkclark)
* Fixed: Resolve issue with `pods_register_block_type()` not clearing the known blocks cache when registering them. #7167 (@sc0ttkclark)
* Fixed: PHP fatal errors resolved with `array_combine()` usage from changes in WP 6.5. #7266 (@sc0ttkclark)
* Fixed: Custom capability fallbacks when the option is empty now properly fallback to the default capability using that post type name. #7250 (@JoryHogeveen)
Expand Down
1 change: 1 addition & 0 deletions src/Pods/Service_Provider.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Pods/WP/Meta.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui/js/dfv/pods-dfv.min.asset.json
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
2 changes: 1 addition & 1 deletion ui/js/dfv/pods-dfv.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions ui/js/dfv/src/admin/edit-pod/main-tabs/settings-modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@
flex: 1 1 auto;
}

@media screen and (max-width: 850px) {
overflow-y: scroll;
}

.pods-field-option {
margin-bottom: 1em;
}
Expand Down
3 changes: 2 additions & 1 deletion ui/js/dfv/src/fields/file/uploaders/media-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const MediaModal = PodsFileUploader.extend( {
multiple: ( 1 !== parseInt( this.fieldConfig.file_limit, 10 ) ),
library: {
type: this.fieldConfig.limit_types,
uploadedTo: this.fieldConfig?.file_post_id,
},
// Customize the submit button.
button: {
Expand Down Expand Up @@ -80,7 +81,7 @@ export const MediaModal = PodsFileUploader.extend( {
name: attachment.attributes.title,
edit_link: attachment.attributes.editLink,
link: attachment.attributes.link,
download: attachment.attributes.url
download: attachment.attributes.url,
} );
} );

Expand Down

0 comments on commit 294c94d

Please sign in to comment.