Skip to content

Commit

Permalink
Merge pull request #7188 from pods-framework/release/3.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Oct 2, 2023
2 parents 9a02a93 + 0f25471 commit b0f29f3
Show file tree
Hide file tree
Showing 18 changed files with 367 additions and 213 deletions.
11 changes: 11 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ 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.5 - October 2nd, 2023 =

* Tweak: Added the "full" image size to the reference list in the Pods Template editor. #7183 #7184 (@JoryHogeveen)
* Fixed: PHP deprecated notices resolved for WYSIWYG field. #7182 (@sc0ttkclark)
* Fixed: Relationships with user capabilities filtered will now work as expected in more cases when using WP multisite. #7181 #7185 (@JoryHogeveen)
* Fixed: Enforce single value for inputs instead of arrays of values in single format for file/relationship field. This resolves issues with Conditional Logic not seeing the initial value on reload. (@sc0ttkclark)
* Fixed: Normalize numbers when doing conditional logic comparisons. (@sc0ttkclark)
* Fixed: Add new options to trim content of fields by removing empty p tags, trimming whitespace at the end of lines, and removing extra lines. Default those to off (previously they were just always on). (@sc0ttkclark)
* Fixed: Add `tribe()` backward compatibilty function for Pods add-ons that still call that function. This only gets included by Pods when Tribe Common is not detected on the site. (@sc0ttkclark)
* Fixed: Resolve file/relationship lookups for settings pages that are DB vs file-based configs. (@sc0ttkclark)

= 3.0.4 - September 25th, 2023 =

* Fixed: Resolve bidirectional removal issue from Pods 2.x where bidirectional relationships would not have the current item removed when you removed that related item. (@sc0ttkclark)
Expand Down
37 changes: 24 additions & 13 deletions classes/PodsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -9612,13 +9612,36 @@ public function lookup_related_items( $field_id, $pod_id, $ids, $field = null, $

$params = (object) $params;

$meta_type = null;

if ( ! $params->pod && $params->field instanceof Field ) {
$related_pod = $params->field->get_parent_object();

if ( $related_pod ) {
$params->pod = $related_pod;
}
}

if ( $params->pod ) {
$meta_type = $params->pod['type'];

if ( in_array( $meta_type, [ 'post_type', 'media' ], true ) ) {
$meta_type = 'post';
} elseif ( 'taxonomy' === $meta_type ) {
$meta_type = 'term';
}
}

$related_ids = array();

if ( ! is_array( $params->ids ) ) {
$params->ids = explode( ',', $params->ids );
}

$params->ids = array_map( 'absint', $params->ids );
if ( 'settings' !== $meta_type ) {
$params->ids = array_map( 'absint', $params->ids );
}

$params->ids = array_unique( array_filter( $params->ids ) );

if ( empty( $params->ids ) ) {
Expand Down Expand Up @@ -9689,18 +9712,6 @@ public function lookup_related_items( $field_id, $pod_id, $ids, $field = null, $
$related_pick_limit *= count( $params->ids );
}

$meta_type = null;

if ( $params->pod ) {
$meta_type = $params->pod['type'];

if ( in_array( $meta_type, [ 'post_type', 'media' ], true ) ) {
$meta_type = 'post';
} elseif ( 'taxonomy' === $meta_type ) {
$meta_type = 'term';
}
}

$meta_types_with_object_pick_data_storage = [
'post' => true,
'term' => true,
Expand Down
40 changes: 31 additions & 9 deletions classes/PodsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,22 +981,44 @@ public function trim_whitespace( $value, $options = null ) {
return $value;
}

$trim = true;
$trim_p_brs = false;
$trim_lines = false;

if ( $options ) {
$options = ( is_array( $options ) || is_object( $options ) ) ? $options : (array) $options;

// Check if we should trim the content.
if ( 0 === (int) pods_v( static::$type . '_trim', $options, 1 ) ) {
return $value;
}
$trim = 1 === (int) pods_v( static::$type . '_trim', $options, 0 );

// Check if we should remove the "p" tags that are empty or that only contain whitespace and "br" tags.
$trim_p_brs = 1 === (int) pods_v( static::$type . '_trim_p_brs', $options, 0 );

// Check if we should remove whitespace at the end of lines.
$trim_lines = 1 === (int) pods_v( static::$type . '_trim_lines', $options, 0 );
}

if ( $trim_p_brs ) {
// Remove the "p" tags that are empty or that only contain whitespace and "br" tags.
$value = preg_replace( '/(<p[^>]*>\s*(\s|&nbsp;|<br\s*?\/?>)*\s*<\/?p>)/Umi', '', $value );

// Remove 3+ consecutive blank lines.
$value = preg_replace( '/([\n\r]\s*[\n\r]\s*[\n\r])+/', "\n", $value );
}

// Maybe trim empty p tags.
$value = preg_replace( '/^\s*<p[^>]*>(\s|&nbsp;|<\/?\s?br\s?\/?>)*<\/?p>(.*)$/Umis', '$2', $value );
$value = preg_replace( '/^\s*(\s|&nbsp;|<\/?\s?br\s?\/?>)*(.*)$/Umis', '$2', $value );
$value = preg_replace( '/^(.*)<p[^>]*>(\s|&nbsp;|<\/?\s?br\s?\/?>)*<\/?p>\s*$/Umis', '$1', $value );
$value = preg_replace( '/^(.*)(\s|&nbsp;|<\/?\s?br\s?\/?>)*\s*$/Umis', '$1', $value );
if ( $trim_lines ) {
// Trim whitespace at the end of lines.
$value = preg_replace( '/\h+$/m', '', $value );

// Remove 3+ consecutive blank lines.
$value = preg_replace( '/([\n\r]\s*[\n\r]\s*[\n\r])+/', "\n", $value );
}

return trim( $value );
if ( $trim ) {
$value = trim( $value );
}

return $value;
}

/**
Expand Down
55 changes: 33 additions & 22 deletions classes/fields/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,46 @@ public function setup() {
* {@inheritdoc}
*/
public function options() {

$options = array(
'output_options' => array(
'label' => __( 'Output Options', 'pods' ),
'type' => 'boolean_group',
'boolean_group' => array(
static::$type . '_trim' => array(
'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
'default' => 1,
'type' => 'boolean',
'dependency' => true,
),
static::$type . '_allow_shortcode' => array(
return [
'output_options' => [
'label' => __( 'Output Options', 'pods' ),
'type' => 'boolean_group',
'boolean_group' => [
static::$type . '_trim' => [
'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
'default' => 1,
'type' => 'boolean',
],
static::$type . '_trim_lines' => [
'label' => __( 'Trim whitespace at the end of lines', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_trim_p_brs' => [
'label' => __( 'Remove blank lines including empty "p" tags and "br" tags', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_trim_extra_lines' => [
'label' => __( 'Remove extra blank lines (when there are 3+ blank lines, replace with a maximum of 2)', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_allow_shortcode' => [
'label' => __( 'Allow Shortcodes', 'pods' ),
'default' => 0,
'type' => 'boolean',
'dependency' => true,
),
),
),
static::$type . '_max_length' => array(
],
],
],
static::$type . '_max_length' => [
'label' => __( 'Maximum Length', 'pods' ),
'default' => -1,
'default' => - 1,
'type' => 'number',
'help' => __( 'Set to -1 for no limit', 'pods' ),
),
);

return $options;
],
];
}

/**
Expand Down
8 changes: 7 additions & 1 deletion classes/fields/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,13 @@ public function build_dfv_field_options( $options, $args ) {
// Enforce limit.
$file_limit = 1;

if ( 'multi' === pods_v( $args->type . '_format_type', $options, 'single' ) ) {
$format_type = pods_v( $args->type . '_format_type', $options, 'single', true );

if ( 'single' === $format_type ) {
if ( ! empty( $args->value ) && is_array( $args->value ) ) {
$args->value = reset( $args->value );
}
} elseif ( 'multi' === $format_type ) {
$file_limit = (int) pods_v( $args->type . '_limit', $options, 0 );

if ( $file_limit < 0 ) {
Expand Down
44 changes: 29 additions & 15 deletions classes/fields/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setup() {
*/
public function options() {
return [
static::$type . '_content' => [
static::$type . '_content' => [
'label' => __( 'HTML Content', 'pods' ),
'type' => 'code',
],
Expand All @@ -50,17 +50,31 @@ public function options() {
'type' => 'boolean',
'help' => __( 'By disabling the form label, the HTML will show as full width without the label text. Only the HTML content will be displayed in the form.', 'pods' ),
],
'output_options' => [
'label' => __( 'Output Options', 'pods' ),
'type' => 'boolean_group',
'output_options' => [
'label' => __( 'Output Options', 'pods' ),
'type' => 'boolean_group',
'boolean_group' => [
static::$type . '_trim' => array(
'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
'default' => 1,
'type' => 'boolean',
'dependency' => true,
),
static::$type . '_oembed' => [
static::$type . '_trim' => [
'label' => __( 'Trim extra whitespace before/after contents', 'pods' ),
'default' => 1,
'type' => 'boolean',
],
static::$type . '_trim_lines' => [
'label' => __( 'Trim whitespace at the end of lines', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_trim_p_brs' => [
'label' => __( 'Remove blank lines including empty "p" tags and "br" tags', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_trim_extra_lines' => [
'label' => __( 'Remove extra blank lines (when there are 3+ blank lines, replace with a maximum of 2)', 'pods' ),
'default' => 0,
'type' => 'boolean',
],
static::$type . '_oembed' => [
'label' => __( 'Enable oEmbed', 'pods' ),
'default' => 0,
'type' => 'boolean',
Expand All @@ -69,7 +83,7 @@ public function options() {
'http://codex.wordpress.org/Embeds',
],
],
static::$type . '_wptexturize' => [
static::$type . '_wptexturize' => [
'label' => __( 'Enable wptexturize', 'pods' ),
'default' => 1,
'type' => 'boolean',
Expand All @@ -78,7 +92,7 @@ public function options() {
'http://codex.wordpress.org/Function_Reference/wptexturize',
],
],
static::$type . '_convert_chars' => [
static::$type . '_convert_chars' => [
'label' => __( 'Enable convert_chars', 'pods' ),
'default' => 1,
'type' => 'boolean',
Expand All @@ -87,7 +101,7 @@ public function options() {
'http://codex.wordpress.org/Function_Reference/convert_chars',
],
],
static::$type . '_wpautop' => [
static::$type . '_wpautop' => [
'label' => __( 'Enable wpautop', 'pods' ),
'default' => 1,
'type' => 'boolean',
Expand All @@ -96,7 +110,7 @@ public function options() {
'http://codex.wordpress.org/Function_Reference/wpautop',
],
],
static::$type . '_allow_shortcode' => [
static::$type . '_allow_shortcode' => [
'label' => __( 'Allow Shortcodes', 'pods' ),
'default' => 0,
'type' => 'boolean',
Expand Down
Loading

0 comments on commit b0f29f3

Please sign in to comment.