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.3 #7309

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 57 additions & 1 deletion classes/fields/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@
'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 @@ -184,7 +191,7 @@
*
* @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", '' ),

Check failure on line 194 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.1)

One or more @param tags has an invalid name or invalid syntax.

Check failure on line 194 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.0)

One or more @param tags has an invalid name or invalid syntax.

Check failure on line 194 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

One or more @param tags has an invalid name or invalid syntax.

Check failure on line 194 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (7.4)

One or more @param tags has an invalid name or invalid syntax.

Check failure on line 194 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

One or more @param tags has an invalid name or invalid syntax.
'type' => 'text',
),
static::$type . '_edit_title' => array(
Expand Down Expand Up @@ -314,6 +321,12 @@
'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 @@
$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 @@

$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 @@
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 @@
}

// 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 @@
}
}//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 @@ -1230,7 +1286,7 @@
* @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 );

Check failure on line 1289 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.1)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1289 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.0)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1289 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1289 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (7.4)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1289 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

@param array $params does not accept actual type of parameter: stdClass.

$custom_dir = pods_evaluate_tags( $custom_dir, array( 'pod' => $context_pod ) );

Expand All @@ -1245,7 +1301,7 @@
* @param array $field The field configuration associated to the upload field.
* @param array $pod The pod configuration associated to the upload field.
*/
$custom_dir = apply_filters( 'pods_upload_dir_custom', $custom_dir, $params, $context_pod, $field, $pod );

Check failure on line 1304 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.1)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1304 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.0)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1304 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.2)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1304 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (7.4)

@param array $params does not accept actual type of parameter: stdClass.

Check failure on line 1304 in classes/fields/file.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan (8.3)

@param array $params does not accept actual type of parameter: stdClass.

self::$tmp_upload_dir = $custom_dir;

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 TBD
*
* @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.3-a-1
* 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.3-a-1' );

// 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.3-a-1",
"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
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.2
Stable tag: 3.2.2
Stable tag: 3.2.3-a-1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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
Loading