Plugin Directory

Changeset 3263809


Ignore:
Timestamp:
03/29/2025 11:53:24 AM (12 months ago)
Author:
jidaikobo
Message:

Update to version 3.2.2

Location:
dashi
Files:
2 added
1 deleted
6 edited
23 copied

Legend:

Unmodified
Added
Removed
  • dashi/tags/3.2.2/classes/Posttype/Base.php

    r3146734 r3263809  
    196196        if (property_exists($instance, $name))
    197197        {
     198            if ($name == 'description') {
     199                return __($instance->$name, 'dashi');
     200            }
    198201            return $instance->$name;
    199202        }
  • dashi/tags/3.2.2/classes/Posttype/Posttype.php

    r3262809 r3263809  
    4040
    4141        // load posttypes
    42         add_action('init', array('\\Dashi\\Core\\Posttype\\Posttype', 'load'));
     42        add_action('widgets_init', array('\\Dashi\\Core\\Posttype\\Posttype', 'load'));
    4343
    4444        // add_meta_box is must be invoke by admin_menu
     
    356356    private static function loadPostTypeFiles()
    357357    {
    358         $posttypes_files = array();
    359         foreach (glob(get_stylesheet_directory()."/posttype/*.php") as $filename)
    360         {
    361             include($filename);
    362             $posttypes_files[] = $filename;
    363         }
    364 
    365 /*
    366 require PHP7:
    367         foreach (glob(get_stylesheet_directory()."/posttype/*.php") as $filename)
    368         {
    369             try {
    370                 require_once($filename);
    371             } catch (\ParseError $e) {
    372                 trigger_error("cannot include posttype file. '$e'", E_USER_ERROR);
    373             }
    374             $posttypes_files[] = $filename;
    375         }
    376 */
     358        $dir = get_stylesheet_directory() . '/posttype';
     359        $posttypes_files = [];
     360        foreach (glob($dir . "/*.php") as $filepath)
     361        {
     362            $filename = basename($filepath);
     363            if (!preg_match('/^[A-Za-z0-9_]+\.php$/', $filename)) {
     364                continue;
     365            }
     366            $real = realpath($filepath);
     367            if ($real === false || strpos($real, realpath($dir)) !== 0) {
     368                continue;
     369            }
     370            include_once $real;
     371
     372            $posttypes_files[] = $real;
     373        }
    377374
    378375        // 子テーマを使っているなら、親テーマを読む
     
    380377        if (get_stylesheet_directory() != get_template_directory())
    381378        {
    382             foreach (glob(get_template_directory()."/posttype/*.php") as $filename)
    383             {
    384                 if (in_array(basename($filename), $pt_check)) continue;
    385                 include($filename);
    386                 $posttypes_files[] = $filename;
    387             }
    388         }
    389         return $posttypes_files;
    390     }
     379            $dir = get_template_directory() . '/posttype';
     380            foreach (glob($dir . "/*.php") as $filepath)
     381            {
     382                $filename = basename($filepath);
     383                if (in_array($filename, $pt_check)) continue;
     384                if (!preg_match('/^[A-Za-z0-9_]+\.php$/', $filename)) {
     385                    continue;
     386                }
     387                $real = realpath($filepath);
     388                if ($real === false || strpos($real, realpath($dir)) !== 0) {
     389                    continue;
     390                }
     391                include_once $real;
     392
     393                $posttypes_files[] = $real;
     394            }
     395        }
     396        return $posttypes_files;
     397    }
    391398
    392399    /**
     
    397404    private static function definePostTypes($posttypes_files)
    398405    {
    399         $posttypes = array();
    400 
    401         foreach ($posttypes_files as $filename)
    402         {
    403             $class = '\\Dashi\\Posttype\\'.ucfirst(substr(basename($filename), 0, -4));
    404             if (is_callable($class, '__init'))
    405             {
    406                 $posttypes[] = $class;
    407             }
     406        $posttypes = [];
     407
     408        foreach ($posttypes_files as $filepath)
     409        {
     410            $filename = basename($filepath, '.php');
     411
     412            // クラス名組み立て(明示的に制限)
     413            if (!preg_match('/^[A-Za-z0-9_]+$/', $filename)) {
     414                continue; // ファイル名不正
     415            }
     416            $class = '\\Dashi\\Posttype\\' . ucfirst($filename);
     417
     418            // クラス存在& __init メソッドが明示的に定義されているか確認
     419            if (!class_exists($class)) {
     420                continue;
     421            }
     422
     423            // Reflectionで __init が実際にそのクラスで定義されているかを確認
     424            try {
     425                $ref = new \ReflectionClass($class);
     426                if ($ref->hasMethod('__init')) {
     427                    $posttypes[] = $class;
     428                }
     429            } catch (\ReflectionException $e) {
     430                continue; // 不正なクラスがあったらスキップ
     431            }
    408432        }
    409433
     
    596620    }
    597621
    598     /**
    599      * virtual
    600      *
    601      * @return  void
    602      */
    603     private static function virtual($posttype)
    604     {
    605         // 投稿タイプ名に使える文字を制限(a〜z, A〜Z, 0〜9, _)
    606         if (!preg_match('/^[A-Za-z0-9_]+$/', $posttype)) {
    607             return;
    608         }
    609         $posttype = ucfirst($posttype);
    610         eval("namespace Dashi\\Posttype;class {$posttype} extends \\Dashi\\Core\\Posttype\\Base {public static function __init (){ static::set('is_dashi', false); } }");
    611     }
     622    /**
     623     * virtual
     624     *
     625     * @return  void
     626     */
     627    private static function virtual($posttype)
     628    {
     629        // 投稿タイプ名に使える文字を制限(a〜z, A〜Z, 0〜9, _)
     630        if (!preg_match('/^[A-Za-z0-9_]+$/', $posttype)) {
     631            return;
     632        }
     633
     634        $virtual_class = 'Dashi\\Posttype\\' . ucfirst($posttype);
     635        $base_class = 'Dashi\\Core\\Posttype\\Virtual';
     636
     637        if (!class_exists($virtual_class)) {
     638            class_alias($base_class, $virtual_class);
     639        }
     640    }
    612641
    613642    /**
     
    759788        }
    760789
     790        $name = __($posttype::get('name'), 'dashi');
     791
    761792        $labels = array(
    762             'name'              => $posttype::get('name'),
    763             'singular_name'     => $posttype::get('singular_name') ?: $posttype::get('name'),
    764             'menu_name'         => $posttype::get('menu_name') ?: $posttype::get('name'),
    765             'add_new'           => sprintf(__('add %s', 'dashi'), $posttype::get('name')),
    766             'add_new_item'      => sprintf(__('add %s', 'dashi'), $posttype::get('name')),
    767             'edit_item'         => sprintf(__('edit %s', 'dashi'), $posttype::get('name')),
    768             'new_item'          => sprintf(__('new %s', 'dashi'), $posttype::get('name')),
    769             'view_item'         => sprintf(__('view %s', 'dashi'), $posttype::get('name')),
     793            'name'              => $name,
     794            'singular_name'     => $posttype::get('singular_name') ?: $name,
     795            'menu_name'         => $posttype::get('menu_name') ?: $name,
     796            'add_new'           => sprintf(__('add %s', 'dashi'), $name),
     797            'add_new_item'      => sprintf(__('add %s', 'dashi'), $name),
     798            'edit_item'         => sprintf(__('edit %s', 'dashi'), $name),
     799            'new_item'          => sprintf(__('new %s', 'dashi'), $name),
     800            'view_item'         => sprintf(__('view %s', 'dashi'), $name),
    770801            'parent_item_colon' => '',
    771802        );
  • dashi/tags/3.2.2/dashi.php

    r3263423 r3263809  
    77Text Domain: dashi
    88Domain Path: /languages/
    9 Version: 3.2.1
     9Version: 3.2.2
    1010Author URI: http://www.jidaikobo.com/
    1111thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src
     
    2828*/
    2929
    30 // WP_INSTALLING
    31 if (defined('WP_INSTALLING') && WP_INSTALLING)
    32 {
    33     return;
    34 }
     30// Do nothing
     31
     32if (defined('WP_INSTALLING') && WP_INSTALLING) return;
     33if (defined('REST_REQUEST') && REST_REQUEST) return;
     34if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) return;
    3535
    3636// language
     
    4343            plugin_basename(__DIR__).'/languages'
    4444        );
    45     }
     45    },
     46    0
    4647);
    4748
  • dashi/tags/3.2.2/posttype/Crawlsearch.php

    r3263423 r3263809  
    99    public static function __init ()
    1010    {
    11         static::set('name', __('Crawlsearch'));
     11        static::set('name', 'Crawlsearch');
    1212        static::set('is_searchable', true);
    1313        static::set('is_redirect', true);
  • dashi/tags/3.2.2/posttype/Pagepart.php

    r3263423 r3263809  
    1010    {
    1111        // settings
    12         static::set('name', __('Page Part', 'dashi'));
    13         static::set('description', __('Page Part can not be displayed by itself.<br />If you describe <code>[get_pagepart slug=slug_name]</code>, page part is called to that place.<br />you can not change the slug created from the shortcode.', 'dashi'));
     12        static::set('name', 'Page Part');
     13        static::set('description', 'Page Part can not be displayed by itself.<br />If you describe <code>[get_pagepart slug=slug_name]</code>, page part is called to that place.<br />you can not change the slug created from the shortcode.');
    1414        static::set('order', 2);
    1515        static::set('is_searchable', true);
  • dashi/tags/3.2.2/readme.txt

    r3263423 r3263809  
    55Requires at least: 4.9.7
    66Tested up to: 6.7.1
    7 Stable tag: 3.2.1
     7Stable tag: 3.2.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4444== Changelog ==
    4545
     46= 3.2.2 =
     47security review "Posttype::class"
     48
    4649= 3.2.1 =
    4750secure search logic
  • dashi/trunk/classes/Posttype/Base.php

    r3146734 r3263809  
    196196        if (property_exists($instance, $name))
    197197        {
     198            if ($name == 'description') {
     199                return __($instance->$name, 'dashi');
     200            }
    198201            return $instance->$name;
    199202        }
  • dashi/trunk/classes/Posttype/Posttype.php

    r3262809 r3263809  
    4040
    4141        // load posttypes
    42         add_action('init', array('\\Dashi\\Core\\Posttype\\Posttype', 'load'));
     42        add_action('widgets_init', array('\\Dashi\\Core\\Posttype\\Posttype', 'load'));
    4343
    4444        // add_meta_box is must be invoke by admin_menu
     
    356356    private static function loadPostTypeFiles()
    357357    {
    358         $posttypes_files = array();
    359         foreach (glob(get_stylesheet_directory()."/posttype/*.php") as $filename)
    360         {
    361             include($filename);
    362             $posttypes_files[] = $filename;
    363         }
    364 
    365 /*
    366 require PHP7:
    367         foreach (glob(get_stylesheet_directory()."/posttype/*.php") as $filename)
    368         {
    369             try {
    370                 require_once($filename);
    371             } catch (\ParseError $e) {
    372                 trigger_error("cannot include posttype file. '$e'", E_USER_ERROR);
    373             }
    374             $posttypes_files[] = $filename;
    375         }
    376 */
     358        $dir = get_stylesheet_directory() . '/posttype';
     359        $posttypes_files = [];
     360        foreach (glob($dir . "/*.php") as $filepath)
     361        {
     362            $filename = basename($filepath);
     363            if (!preg_match('/^[A-Za-z0-9_]+\.php$/', $filename)) {
     364                continue;
     365            }
     366            $real = realpath($filepath);
     367            if ($real === false || strpos($real, realpath($dir)) !== 0) {
     368                continue;
     369            }
     370            include_once $real;
     371
     372            $posttypes_files[] = $real;
     373        }
    377374
    378375        // 子テーマを使っているなら、親テーマを読む
     
    380377        if (get_stylesheet_directory() != get_template_directory())
    381378        {
    382             foreach (glob(get_template_directory()."/posttype/*.php") as $filename)
    383             {
    384                 if (in_array(basename($filename), $pt_check)) continue;
    385                 include($filename);
    386                 $posttypes_files[] = $filename;
    387             }
    388         }
    389         return $posttypes_files;
    390     }
     379            $dir = get_template_directory() . '/posttype';
     380            foreach (glob($dir . "/*.php") as $filepath)
     381            {
     382                $filename = basename($filepath);
     383                if (in_array($filename, $pt_check)) continue;
     384                if (!preg_match('/^[A-Za-z0-9_]+\.php$/', $filename)) {
     385                    continue;
     386                }
     387                $real = realpath($filepath);
     388                if ($real === false || strpos($real, realpath($dir)) !== 0) {
     389                    continue;
     390                }
     391                include_once $real;
     392
     393                $posttypes_files[] = $real;
     394            }
     395        }
     396        return $posttypes_files;
     397    }
    391398
    392399    /**
     
    397404    private static function definePostTypes($posttypes_files)
    398405    {
    399         $posttypes = array();
    400 
    401         foreach ($posttypes_files as $filename)
    402         {
    403             $class = '\\Dashi\\Posttype\\'.ucfirst(substr(basename($filename), 0, -4));
    404             if (is_callable($class, '__init'))
    405             {
    406                 $posttypes[] = $class;
    407             }
     406        $posttypes = [];
     407
     408        foreach ($posttypes_files as $filepath)
     409        {
     410            $filename = basename($filepath, '.php');
     411
     412            // クラス名組み立て(明示的に制限)
     413            if (!preg_match('/^[A-Za-z0-9_]+$/', $filename)) {
     414                continue; // ファイル名不正
     415            }
     416            $class = '\\Dashi\\Posttype\\' . ucfirst($filename);
     417
     418            // クラス存在& __init メソッドが明示的に定義されているか確認
     419            if (!class_exists($class)) {
     420                continue;
     421            }
     422
     423            // Reflectionで __init が実際にそのクラスで定義されているかを確認
     424            try {
     425                $ref = new \ReflectionClass($class);
     426                if ($ref->hasMethod('__init')) {
     427                    $posttypes[] = $class;
     428                }
     429            } catch (\ReflectionException $e) {
     430                continue; // 不正なクラスがあったらスキップ
     431            }
    408432        }
    409433
     
    596620    }
    597621
    598     /**
    599      * virtual
    600      *
    601      * @return  void
    602      */
    603     private static function virtual($posttype)
    604     {
    605         // 投稿タイプ名に使える文字を制限(a〜z, A〜Z, 0〜9, _)
    606         if (!preg_match('/^[A-Za-z0-9_]+$/', $posttype)) {
    607             return;
    608         }
    609         $posttype = ucfirst($posttype);
    610         eval("namespace Dashi\\Posttype;class {$posttype} extends \\Dashi\\Core\\Posttype\\Base {public static function __init (){ static::set('is_dashi', false); } }");
    611     }
     622    /**
     623     * virtual
     624     *
     625     * @return  void
     626     */
     627    private static function virtual($posttype)
     628    {
     629        // 投稿タイプ名に使える文字を制限(a〜z, A〜Z, 0〜9, _)
     630        if (!preg_match('/^[A-Za-z0-9_]+$/', $posttype)) {
     631            return;
     632        }
     633
     634        $virtual_class = 'Dashi\\Posttype\\' . ucfirst($posttype);
     635        $base_class = 'Dashi\\Core\\Posttype\\Virtual';
     636
     637        if (!class_exists($virtual_class)) {
     638            class_alias($base_class, $virtual_class);
     639        }
     640    }
    612641
    613642    /**
     
    759788        }
    760789
     790        $name = __($posttype::get('name'), 'dashi');
     791
    761792        $labels = array(
    762             'name'              => $posttype::get('name'),
    763             'singular_name'     => $posttype::get('singular_name') ?: $posttype::get('name'),
    764             'menu_name'         => $posttype::get('menu_name') ?: $posttype::get('name'),
    765             'add_new'           => sprintf(__('add %s', 'dashi'), $posttype::get('name')),
    766             'add_new_item'      => sprintf(__('add %s', 'dashi'), $posttype::get('name')),
    767             'edit_item'         => sprintf(__('edit %s', 'dashi'), $posttype::get('name')),
    768             'new_item'          => sprintf(__('new %s', 'dashi'), $posttype::get('name')),
    769             'view_item'         => sprintf(__('view %s', 'dashi'), $posttype::get('name')),
     793            'name'              => $name,
     794            'singular_name'     => $posttype::get('singular_name') ?: $name,
     795            'menu_name'         => $posttype::get('menu_name') ?: $name,
     796            'add_new'           => sprintf(__('add %s', 'dashi'), $name),
     797            'add_new_item'      => sprintf(__('add %s', 'dashi'), $name),
     798            'edit_item'         => sprintf(__('edit %s', 'dashi'), $name),
     799            'new_item'          => sprintf(__('new %s', 'dashi'), $name),
     800            'view_item'         => sprintf(__('view %s', 'dashi'), $name),
    770801            'parent_item_colon' => '',
    771802        );
  • dashi/trunk/dashi.php

    r3263423 r3263809  
    77Text Domain: dashi
    88Domain Path: /languages/
    9 Version: 3.2.1
     9Version: 3.2.2
    1010Author URI: http://www.jidaikobo.com/
    1111thx: https://github.com/trentrichardson/jQuery-Timepicker-Addon/tree/master/src
     
    2828*/
    2929
    30 // WP_INSTALLING
    31 if (defined('WP_INSTALLING') && WP_INSTALLING)
    32 {
    33     return;
    34 }
     30// Do nothing
     31
     32if (defined('WP_INSTALLING') && WP_INSTALLING) return;
     33if (defined('REST_REQUEST') && REST_REQUEST) return;
     34if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) return;
    3535
    3636// language
     
    4343            plugin_basename(__DIR__).'/languages'
    4444        );
    45     }
     45    },
     46    0
    4647);
    4748
  • dashi/trunk/posttype/Crawlsearch.php

    r3263423 r3263809  
    99    public static function __init ()
    1010    {
    11         static::set('name', __('Crawlsearch'));
     11        static::set('name', 'Crawlsearch');
    1212        static::set('is_searchable', true);
    1313        static::set('is_redirect', true);
  • dashi/trunk/posttype/Pagepart.php

    r3263423 r3263809  
    1010    {
    1111        // settings
    12         static::set('name', __('Page Part', 'dashi'));
    13         static::set('description', __('Page Part can not be displayed by itself.<br />If you describe <code>[get_pagepart slug=slug_name]</code>, page part is called to that place.<br />you can not change the slug created from the shortcode.', 'dashi'));
     12        static::set('name', 'Page Part');
     13        static::set('description', 'Page Part can not be displayed by itself.<br />If you describe <code>[get_pagepart slug=slug_name]</code>, page part is called to that place.<br />you can not change the slug created from the shortcode.');
    1414        static::set('order', 2);
    1515        static::set('is_searchable', true);
  • dashi/trunk/readme.txt

    r3263423 r3263809  
    55Requires at least: 4.9.7
    66Tested up to: 6.7.1
    7 Stable tag: 3.2.1
     7Stable tag: 3.2.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4444== Changelog ==
    4545
     46= 3.2.2 =
     47security review "Posttype::class"
     48
    4649= 3.2.1 =
    4750secure search logic
Note: See TracChangeset for help on using the changeset viewer.