Skip to content

Commit

Permalink
Merge pull request #7174 from pods-framework/release/3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Sep 21, 2023
2 parents 4eefaca + c8c7d1f commit 5e18c27
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 81 deletions.
17 changes: 17 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ 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.0.2 - September 21st, 2023 =

* Feature: You can now disable the Add New forms for a Post Type pod under the Advanced tab. (@sc0ttkclark)
* Fixed: Bi-directional field saving has been restored after breaking in Pods 2.9.x. #7172 (@sc0ttkclark)
* Fixed: More PHP notices/warnings/errors with PHP 8+ addressed. #7170 #7171 (@sc0ttkclark)
* Fixed: Settings saving for simple relationships fixed when using a setting pod registered by code/file. #7169 (@sc0ttkclark)
* Fixed: Settings forms would sometimes say the save failed when it was successful. (@sc0ttkclark)
* Fixed: Fix relationship rendering in tables for Advanced Content Types. #7173 (@sc0ttkclark)
* Fixed: Potential SQL errors when a Pod does not exist but it's still set a relationship object for a field. (@sc0ttkclark)
* Fixed: Pod config data is now correctly passed in all instances of `pods_meta_default_box_title` filter so it's uniform in usage. (@sc0ttkclark)
* Fixed: Bypass "@" prefixed items from being processed in file-based configs. (@sc0ttkclark)
* Fixed: Removed extra line in array for post type definition where `can_export` was set two times. (@sc0ttkclark)
* Fixed: Resolved some cases where boolean return types were treated as filters in `Store::find()`` calls. (@sc0ttkclark)
* Fixed: The `Pods\Blocks\Types\Base::in_editor_mode()` method resolves PHP issue with current screen reference. (@sc0ttkclark)
* Fixed: Ensure code/file based configs do not overwrite DB configs to avoid potential issues where duplicate configs get pulled up in lookups. (@sc0ttkclark)
* Fixed: Some relationship field options were not showing their available options to select from when editing a field on the Edit Pod screen. #7176 (@sc0ttkclark)

= 3.0.1 - September 13th, 2023 =

* Fixed: Custom Settings Pages no longer have the error when saving that was introduced by changes made in Pods 3.0. (@sc0ttkclark)
Expand Down
6 changes: 5 additions & 1 deletion classes/Pods.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,11 @@ public function field( $name, $single = null, $raw = false ) {
$use_meta_fallback = apply_filters( 'pods_field_wp_object_use_meta_fallback', $use_meta_fallback, $pod_type );

if ( in_array( $params->name, $permalink_fields, true ) ) {
if ( 0 < strlen( $this->detail_page ) && false === strpos( $params->name, 'permalink' ) ) {
if (
is_string( $this->detail_page )
&& 0 < strlen( $this->detail_page )
&& false === strpos( $params->name, 'permalink' )
) {
// ACT Pods. Prevent tag loop by not parsing `permalink`.
$value = get_home_url() . '/' . $this->do_magic_tags( $this->detail_page );
} else {
Expand Down
21 changes: 15 additions & 6 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -4753,7 +4753,7 @@ public function save_helper( $params, $sanitized = false ) {
*
* @param array|object $params An associative array of parameters
*
* @return int|array The item ID, or an array of item IDs (if `id` is an array if IDs)
* @return int|string|array The item ID, slug, or an array of item IDs (if `id` is an array if IDs)
*
* @throws Exception
*
Expand Down Expand Up @@ -5328,9 +5328,10 @@ public function save_pod_item( $params ) {
// Maybe flatten the array for files.
if (
'file' === $object_fields[ $field ]['type']
&& array_key_exists( 'id', (array) current( $value ) )
&& ! is_int( $value )
&& array_key_exists( 'id', (array) current( (array) $value ) )
) {
$value = array_values( wp_list_pluck( $value, 'id' ) );
$value = array_values( wp_list_pluck( (array) $value, 'id' ) );

// Maybe handle thumbnail as a single value.
if ( '_thumbnail_id' === $field ) {
Expand Down Expand Up @@ -5637,7 +5638,7 @@ public function save_pod_item( $params ) {
}

if ( 'settings' === $pod['type'] ) {
$params->id = $pod['id'];
$params->id = $pod['name'];
}
}

Expand All @@ -5664,7 +5665,9 @@ public function save_pod_item( $params ) {
}
}

$params->id = (int) $params->id;
if ( is_numeric( $params->id ) ) {
$params->id = (int) $params->id;
}

// Save terms for taxonomies associated to a post type
if ( 0 < $params->id && 'post_type' === $pod['type'] && ! empty( $post_term_data ) ) {
Expand Down Expand Up @@ -5747,8 +5750,14 @@ public function save_pod_item( $params ) {
$this->save_relationships( $params->id, $value_ids, $pod, $field_data );
}

$pick_save_params = $params;

$pick_save_params->current_ids = $related_ids;
$pick_save_params->value_ids = $value_ids;
$pick_save_params->remove_ids = $remove_ids;

// Run save function for field type (where needed).
PodsForm::save( $type, $field_save_values, $params->id, $field_name, $field_data, $all_fields, $pod, $params );
PodsForm::save( $type, $field_save_values, $params->id, $field_name, $field_data, $all_fields, $pod, $pick_save_params );
}

// Unset data no longer needed
Expand Down
17 changes: 9 additions & 8 deletions classes/PodsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,10 @@ public function admin_content_settings() {
$page_title = pods_v( 'label', $pod->pod_data, ucwords( str_replace( '_', ' ', $pod->pod_data['name'] ) ), true );
$page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod->pod_data );

$pod_pod_name = $pod->pod;

$ui = array(
'id' => $pod_pod_name,
'pod' => $pod,
'fields' => array(
'edit' => $pod->pod_data->get_fields(),
Expand All @@ -783,8 +786,6 @@ public function admin_content_settings() {
'actions_disabled' => $actions_disabled,
);

$pod_pod_name = $pod->pod;

$ui = apply_filters( "pods_admin_ui_{$pod_pod_name}", apply_filters( 'pods_admin_ui', $ui, $pod->pod, $pod ), $pod->pod, $pod );

// Force disabled actions, do not pass go, do not collect $two_hundred
Expand Down Expand Up @@ -2730,13 +2731,13 @@ public function admin_ajax() {
$params = (object) $params;

$methods = array(
'add_pod' => array( 'priv' => true ),
'save_pod' => array( 'priv' => true ),
'load_sister_fields' => array( 'priv' => true ),
'process_form' => array( 'custom_nonce' => true ),
'add_pod' => array( 'priv' => true ),
'save_pod' => array( 'priv' => true ),
'load_sister_fields' => array( 'priv' => true ),
'process_form' => array( 'custom_nonce' => true ),
// priv handled through nonce
'upgrade' => array( 'priv' => true ),
'migrate' => array( 'priv' => true ),
'upgrade' => array( 'priv' => true ),
'migrate' => array( 'priv' => true ),
);

/**
Expand Down
29 changes: 17 additions & 12 deletions classes/PodsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function __construct( $pod = null, $id = 0, $strict = false ) {
}

if ( $this->pod_data && 'settings' === $this->pod_data['type'] ) {
$this->id = $this->pod_data['id'];
$this->id = $this->pod_data['name'];

$this->fetch( $this->id );
} elseif ( null !== $id && ! is_array( $id ) && ! is_object( $id ) ) {
Expand Down Expand Up @@ -2028,8 +2028,8 @@ public function fetch( $row = null, $explicit_set = true ) {

$current_row_id = false;

if ( $this->pod_data && 'settings' === $this->pod_data['type'] ) {
$current_row_id = $this->pod_data['id'];
if ( $this->pod_data && 'settings' === $this->pod_data->get_type() ) {
$current_row_id = $this->pod_data->get_name();

$is_settings_pod = true;
} else {
Expand Down Expand Up @@ -2067,7 +2067,8 @@ public function fetch( $row = null, $explicit_set = true ) {
$id = pods_absint( $row );

if ( $is_settings_pod ) {
$id = $this->pod_data->get_id();
$mode = 'slug';
$id = $this->pod_data->get_name();
}

if (
Expand Down Expand Up @@ -2145,7 +2146,7 @@ public function fetch( $row = null, $explicit_set = true ) {
if ( empty( $this->row ) || is_wp_error( $this->row ) ) {
$this->row = false;
} else {
$current_row_id = $this->row['ID'];
$current_row_id = (int) $this->row['ID'];
}

$get_table_data = true;
Expand Down Expand Up @@ -2196,7 +2197,7 @@ public function fetch( $row = null, $explicit_set = true ) {
if ( empty( $this->row ) || is_wp_error( $this->row ) ) {
$this->row = false;
} else {
$current_row_id = $this->row['term_id'];
$current_row_id = (int) $this->row['term_id'];
}

$get_table_data = true;
Expand Down Expand Up @@ -2224,7 +2225,7 @@ public function fetch( $row = null, $explicit_set = true ) {

unset( $this->row['user_pass'] );

$current_row_id = $this->row['ID'];
$current_row_id = (int) $this->row['ID'];
}

$get_table_data = true;
Expand All @@ -2235,7 +2236,7 @@ public function fetch( $row = null, $explicit_set = true ) {
if ( empty( $this->row ) || is_wp_error( $this->row ) ) {
$this->row = false;
} else {
$current_row_id = $this->row['comment_ID'];
$current_row_id = (int) $this->row['comment_ID'];
}

$get_table_data = true;
Expand All @@ -2245,14 +2246,18 @@ public function fetch( $row = null, $explicit_set = true ) {
if ( empty( $this->fields ) || ! $this->pod_data ) {
$this->row = false;
} else {
/** @var Field $field */
foreach ( $this->fields as $field ) {
if ( ! in_array( $field['type'], $tableless_field_types, true ) ) {
$this->row[ $field['name'] ] = get_option( $this->pod_data['name'] . '_' . $field['name'], null );
if (
! in_array( $field['type'], $tableless_field_types, true )
|| $field->is_simple_relationship()
) {
$this->row[ $field['name'] ] = get_option( $this->pod_data->get_name() . '_' . $field['name'], null );
}
}

// Force ID.
$this->id = $this->pod_data['id'];
// Force the pod name as the ID.
$this->id = $this->pod_data->get_name();
$this->row['option_id'] = $this->id;
}
} else {
Expand Down
7 changes: 6 additions & 1 deletion classes/PodsInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,16 @@ public function setup_content_types( $force = false ) {
'has_archive' => ( (boolean) pods_v( 'has_archive', $post_type, false ) ) ? pods_v( 'has_archive_slug', $post_type, true, true ) : false,
'rewrite' => $cpt_rewrite,
'query_var' => ( false !== (boolean) pods_v( 'query_var', $post_type, true ) ? pods_v( 'query_var_string', $post_type, $post_type_name, true ) : false ),
'can_export' => (boolean) pods_v( 'can_export', $post_type, true ),
'delete_with_user' => (boolean) pods_v( 'delete_with_user', $post_type, true ),
'_provider' => 'pods',
);

if ( (boolean) pods_v( 'disable_create_posts', $post_type, false ) ) {
$pods_post_types[ $post_type_name ]['capabilities'] = [
'create_posts' => false,
];
}

// Check if we have a custom archive page slug.
if ( is_string( $pods_post_types[ $post_type_name ]['has_archive'] ) ) {
// Only allow specific characters.
Expand Down
15 changes: 14 additions & 1 deletion classes/PodsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3725,6 +3725,9 @@ public function table( $reorder = false ) {
<?php
return false;
}

$tableless_field_types = PodsForm::tableless_field_types();

if ( true === $reorder && ! in_array( 'reorder', $this->actions_disabled ) && false !== $this->reorder['on'] ) {

?>
Expand Down Expand Up @@ -3999,6 +4002,16 @@ public function table( $reorder = false ) {
$row_value_is_array = is_array( $row_value );
$row_values = (array) $row_value;

if (
$row_values
&& ! isset( $row_values[0] )
&& in_array( $attributes['type'], $tableless_field_types, true )
) {
$row_values = [
$row_values,
];
}

foreach ( $row_values as $row_value_key => $row_value_item ) {
ob_start();

Expand All @@ -4020,7 +4033,7 @@ public function table( $reorder = false ) {
if ( ! $row_value_is_array ) {
$row_value = $row_value ? current( $row_value ) : null;
}
}//end if
}

if ( false !== $attributes['custom_relate'] ) {
global $wpdb;
Expand Down
Loading

0 comments on commit 5e18c27

Please sign in to comment.