Plugin Directory

Changeset 3495157


Ignore:
Timestamp:
03/31/2026 05:59:38 AM (3 days ago)
Author:
jidaikobo
Message:

Release 3.4.8

Location:
dashi
Files:
4 edited
23 copied

Legend:

Unmodified
Added
Removed
  • dashi/tags/3.4.8/classes/Posttype/Preview.php

    r3477375 r3495157  
    66class Preview
    77{
     8    /**
     9     * プレビュー保存時の値をフィールド型に応じて整形
     10     *
     11     * @param string $post_meta
     12     * @param mixed $value
     13     * @param string|bool $class
     14     * @return mixed
     15     */
     16    private static function sanitizePreviewMetaValue($post_meta, $value, $class)
     17    {
     18        if (is_array($value))
     19        {
     20            return array_map(
     21                static function ($item) use ($post_meta, $class)
     22                {
     23                    return self::sanitizePreviewMetaValue($post_meta, $item, $class);
     24                },
     25                $value
     26            );
     27        }
     28
     29        if (! is_string($value))
     30        {
     31            return $value;
     32        }
     33
     34        $value = wp_unslash($value);
     35
     36        if (! $class || ! method_exists($class, 'getFlatCustomFields'))
     37        {
     38            return sanitize_text_field($value);
     39        }
     40
     41        $flat_fields = $class::getFlatCustomFields();
     42        $field = isset($flat_fields[$post_meta]) && is_array($flat_fields[$post_meta])
     43            ? $flat_fields[$post_meta]
     44            : [];
     45        $field_type = isset($field['type']) ? (string) $field['type'] : '';
     46
     47        if (in_array($field_type, ['textarea', 'wysiwyg'], true))
     48        {
     49            return $value;
     50        }
     51
     52        return sanitize_text_field($value);
     53    }
     54
    855    /**
    956     * forge
     
    99146    {
    100147        global $wpdb;
    101 
    102148        if (wp_is_post_revision($post_id))
    103149        {
     
    128174                    $vals = is_array($post_val) ? $post_val : $post_scalar;
    129175                    if ($vals === null || $vals === false || $vals === '') continue;
    130                     if (is_string($vals))
    131                     {
    132                         $vals = sanitize_text_field(wp_unslash($vals));
    133                     }
     176                    $vals = self::sanitizePreviewMetaValue($post_meta, $vals, $class);
    134177                    if (is_array($vals) && $post_meta != 'google_map')
    135178                    {
    136179                        foreach ($vals as $v)
    137180                        {
    138                             add_metadata('post', $post_id, $post_meta, sanitize_text_field(wp_unslash((string) $v)));
     181                            add_metadata('post', $post_id, $post_meta, $v);
    139182                        }
    140183                    }
     
    146189            // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- 既存互換のカスタムフック名。
    147190            do_action('save_preview_postmeta', $post_id);
     191
    148192        }
    149193    }
  • dashi/tags/3.4.8/dashi.php

    r3486974 r3495157  
    77Text Domain: dashi
    88Domain Path: /languages/
    9 Version: 3.4.7
     9Version: 3.4.8
    1010Author URI: http://www.jidaikobo.com/
    1111thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src
  • dashi/tags/3.4.8/readme.txt

    r3486974 r3495157  
    44Tags: custom field, custom post type
    55Tested up to: 6.9
    6 Stable tag: 3.4.7
     6Stable tag: 3.4.8
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4242
    4343== Changelog ==
     44
     45= 3.4.8 =
     46fix: preserve textarea and wysiwyg values in preview revisions
    4447
    4548= 3.4.7 =
  • dashi/trunk/classes/Posttype/Preview.php

    r3477375 r3495157  
    66class Preview
    77{
     8    /**
     9     * プレビュー保存時の値をフィールド型に応じて整形
     10     *
     11     * @param string $post_meta
     12     * @param mixed $value
     13     * @param string|bool $class
     14     * @return mixed
     15     */
     16    private static function sanitizePreviewMetaValue($post_meta, $value, $class)
     17    {
     18        if (is_array($value))
     19        {
     20            return array_map(
     21                static function ($item) use ($post_meta, $class)
     22                {
     23                    return self::sanitizePreviewMetaValue($post_meta, $item, $class);
     24                },
     25                $value
     26            );
     27        }
     28
     29        if (! is_string($value))
     30        {
     31            return $value;
     32        }
     33
     34        $value = wp_unslash($value);
     35
     36        if (! $class || ! method_exists($class, 'getFlatCustomFields'))
     37        {
     38            return sanitize_text_field($value);
     39        }
     40
     41        $flat_fields = $class::getFlatCustomFields();
     42        $field = isset($flat_fields[$post_meta]) && is_array($flat_fields[$post_meta])
     43            ? $flat_fields[$post_meta]
     44            : [];
     45        $field_type = isset($field['type']) ? (string) $field['type'] : '';
     46
     47        if (in_array($field_type, ['textarea', 'wysiwyg'], true))
     48        {
     49            return $value;
     50        }
     51
     52        return sanitize_text_field($value);
     53    }
     54
    855    /**
    956     * forge
     
    99146    {
    100147        global $wpdb;
    101 
    102148        if (wp_is_post_revision($post_id))
    103149        {
     
    128174                    $vals = is_array($post_val) ? $post_val : $post_scalar;
    129175                    if ($vals === null || $vals === false || $vals === '') continue;
    130                     if (is_string($vals))
    131                     {
    132                         $vals = sanitize_text_field(wp_unslash($vals));
    133                     }
     176                    $vals = self::sanitizePreviewMetaValue($post_meta, $vals, $class);
    134177                    if (is_array($vals) && $post_meta != 'google_map')
    135178                    {
    136179                        foreach ($vals as $v)
    137180                        {
    138                             add_metadata('post', $post_id, $post_meta, sanitize_text_field(wp_unslash((string) $v)));
     181                            add_metadata('post', $post_id, $post_meta, $v);
    139182                        }
    140183                    }
     
    146189            // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- 既存互換のカスタムフック名。
    147190            do_action('save_preview_postmeta', $post_id);
     191
    148192        }
    149193    }
  • dashi/trunk/dashi.php

    r3486974 r3495157  
    77Text Domain: dashi
    88Domain Path: /languages/
    9 Version: 3.4.7
     9Version: 3.4.8
    1010Author URI: http://www.jidaikobo.com/
    1111thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src
  • dashi/trunk/readme.txt

    r3486974 r3495157  
    44Tags: custom field, custom post type
    55Tested up to: 6.9
    6 Stable tag: 3.4.7
     6Stable tag: 3.4.8
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4242
    4343== Changelog ==
     44
     45= 3.4.8 =
     46fix: preserve textarea and wysiwyg values in preview revisions
    4447
    4548= 3.4.7 =
Note: See TracChangeset for help on using the changeset viewer.