Plugin Directory

Changeset 3238453


Ignore:
Timestamp:
02/11/2025 09:38:07 AM (14 months ago)
Author:
denishua
Message:

version 6.7.4

Location:
wpjam-basic/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wpjam-basic/trunk/includes/class-wpjam-admin.php

    r3236921 r3238453  
    851851
    852852    public function render(){
    853         $tag    = wpjam_tag(($this->tab_page ? 'h2' : 'h1'), ['wp-heading-inline'], ($this->page_title ?? $this->title));
    854         $tag    = $tag->after([
    855             $this->function == 'list_table' ? "\n".wpjam_tag('a', ['page-title-action'], '') : '',
    856             "\n".wpjam_tag('hr', ['wp-header-end'])
    857         ]);
    858 
    859         $summary    = $this->summary;
    860 
    861         if($summary){
     853        $tag    = wpjam_tag('h1', ['wp-heading-inline'], ($this->page_title ?? $this->title))->after('hr', ['wp-header-end']);
     854
     855        if($summary = $this->summary){
    862856            if(is_callable($summary)){
    863857                $summary    = $summary(...$this->cb_args);
     
    888882
    889883        if($this->tab_page){
    890             return $tag;
     884            return $tag->tag('h2');
    891885        }
    892886
  • wpjam-basic/trunk/includes/class-wpjam-list-table.php

    r3238028 r3238453  
    7777
    7878        wpjam_add_item('page_setting', 'list_table', fn()=> $this->get_setting());
     79        wpjam_add_item('page_setting', 'page_title_action', fn()=> $this->get_row_action('add', ['class'=>'page-title-action']) ?: '');
    7980
    8081        wpjam_map([
     
    8384            'sortable_columns'  => 'manage_'.$screen->id.'_sortable_columns'
    8485        ], fn($filter, $key)=> add_filter($filter, fn($value)=> array_merge($value, $this->$key ?: [])));
    85 
    86         if(!wp_doing_ajax()){
    87             $page_title_action  = $this->layout == 'left' ? '' : $this->get_row_action('add', ['class'=>'page-title-action']);
    88 
    89             if($page_title_action || !$this->builtin){
    90                 add_filter('wpjam_html', fn($html)=> preg_replace('/<a[^>]*class="page-title-action">[^>]*<\/a>/i', ($page_title_action ?: ''), $html));
    91             }
    92         }
    9386
    9487        $this->_args    = array_merge($this->_args, $args);
     
    739732        }elseif($key == 'response'){
    740733            return ($this->overall && $this->name != 'add') ? 'list' : $this->name;
    741         }elseif($key == 'overall'){
    742             return $this->name == 'add' && $this->layout == 'left';
    743734        }elseif($key == 'row_action'){
    744735            return ($this->bulk !== 'only' && $this->name != 'add');
     
    12981289        wpjam_map(wpjam_slice($args, ['data_type', 'meta_type']), fn($v, $k)=> $screen->add_option($k, $v));
    12991290
    1300         if(!wp_is_json_request()){
    1301             add_filter('wpjam_html', [$this, 'filter_display']);
    1302         }
    1303 
    13041291        add_filter('manage_'.$screen->id.'_columns', fn($columns)=> wpjam_add_at($columns, -1, $this->get_columns()));
    13051292
     
    13161303        }
    13171304
     1305        if(!wp_is_json_request()){
     1306            add_filter('wpjam_html', [$this, 'filter_display']);
     1307        }
     1308
    13181309        parent::__construct($args);
    13191310    }
     
    13471338            $this->prepare_items_by_builtin();
    13481339        }
    1349     }
    1350 
    1351     public function filter_custom_column(...$args){
    1352         $value  = $this->get_column_value(...array_reverse($args));
    1353 
    1354         return count($args) == 2 ? wpjam_echo($value) : $value;
    1355     }
    1356 
    1357     public function on_parse_query($query){
    1358         if(array_any(debug_backtrace(), fn($v)=> wpjam_get($v, 'class') == $this->builtin)){
    1359             $vars   = &$query->query_vars;
    1360             $by     = $vars['orderby'] ?? '';
    1361             $object = ($by && is_string($by)) ? $this->get_object($by, 'column') : null;
    1362             $type   = $object ? ($object->sortable === true ? 'meta_value' : $object->sortable) : '';
    1363             $vars   = array_merge($vars, ['list_table_query'=>true], in_array($type, ['meta_value_num', 'meta_value']) ? ['orderby'=>$type, 'meta_key'=>$by] : []);
    1364         }
    1365     }
    1366 
    1367     public function filter_row_actions($actions, $item){
    1368         $id         = $item->{$this->primary_key};
    1369         $actions    = wpjam_except($actions, $this->get_removed('action'));
    1370         $actions    += wpjam_filter($this->get_row_actions($id), fn($v, $k)=> $v && $this->filter_row_action($this->get_object($k), $item));
    1371         $actions    += wpjam_pull($actions, ['delete', 'trash', 'spam', 'remove', 'view'])+['id'=>'ID: '.$id];
    1372 
    1373         return $actions;
    1374     }
    1375 
    1376     protected function filter_row_action($object, $item){
    1377         if($this->data_type == 'post_type'){
    1378             return wpjam_compare(get_post_status($item), ...($object->post_status ? [$object->post_status] : ['!=', 'trash']));
    1379         }elseif($this->data_type == 'user'){
    1380             return (is_null($object->roles) || array_intersect($user->roles, (array)$object->roles));
    1381         }
    1382 
    1383         return true;
    13841340    }
    13851341
     
    14151371    }
    14161372
     1373    public function filter_custom_column(...$args){
     1374        $value  = $this->get_column_value(...array_reverse($args));
     1375
     1376        return count($args) == 2 ? wpjam_echo($value) : $value;
     1377    }
     1378
     1379    public function on_parse_query($query){
     1380        if(array_any(debug_backtrace(), fn($v)=> wpjam_get($v, 'class') == $this->builtin)){
     1381            $vars   = &$query->query_vars;
     1382            $by     = $vars['orderby'] ?? '';
     1383            $object = ($by && is_string($by)) ? $this->get_object($by, 'column') : null;
     1384            $type   = $object ? ($object->sortable === true ? 'meta_value' : $object->sortable) : '';
     1385            $vars   = array_merge($vars, ['list_table_query'=>true], in_array($type, ['meta_value_num', 'meta_value']) ? ['orderby'=>$type, 'meta_key'=>$by] : []);
     1386        }
     1387    }
     1388
     1389    public function filter_row_actions($actions, $item){
     1390        $id         = $item->{$this->primary_key};
     1391        $actions    = wpjam_except($actions, $this->get_removed('action'));
     1392        $actions    += wpjam_filter($this->get_row_actions($id), fn($v, $k)=> $v && $this->filter_row_action($this->get_object($k), $item));
     1393        $actions    += wpjam_pull($actions, ['delete', 'trash', 'spam', 'remove', 'view'])+['id'=>'ID: '.$id];
     1394
     1395        return $actions;
     1396    }
     1397
     1398    protected function filter_row_action($object, $item){
     1399        if($this->data_type == 'post_type'){
     1400            return wpjam_compare(get_post_status($item), ...($object->post_status ? [$object->post_status] : ['!=', 'trash']));
     1401        }elseif($this->data_type == 'user'){
     1402            return (is_null($object->roles) || array_intersect($user->roles, (array)$object->roles));
     1403        }
     1404
     1405        return true;
     1406    }
     1407
    14171408    public static function load($screen){
    14181409        return new static($screen);
  • wpjam-basic/trunk/static/script.js

    r3236921 r3238453  
    483483                if($('#notice_modal').length){
    484484                    this.add_modal('notice_modal');
     485                }
     486
     487                if(this.page_title_action){
     488                    $('a.page-title-action').remove();
     489
     490                    $('.wp-heading-inline').last().after(this.page_title_action || '');
    485491                }
    486492
     
    910916                        let id  = $el.attr('id');
    911917
    912                         if(['doaction', 'doaction2', 'bulk-action-selector-top', 'bulk-action-selector-bottom'].includes(id)){
    913                             let $select = $el.is('select') ? $el : $el.prev('select');
     918                        if(['doaction', 'doaction2'].includes(id)){
     919                            let $select = $el.prev('select');
    914920                            let name    = $select.val();
    915921                            let ids     = $form.find('th.check-column input[type="checkbox"]:checked').toArray().map(cb => cb.value);
     
    926932                            }
    927933                        }else if(wpjam.ajax_list_action !== false){
    928                             if($form.wpjam_validity()){
    929                                 $form.wpjam_query(id == 'current-page-selector' ? _.extend(wpjam.params, {paged: parseInt($el.val())}) : '');
    930                             }
    931 
    932                             return false;
     934                            if($el.is('[name=filter_action]') || id == 'search-submit'){
     935                                if($form.wpjam_validity()){
     936                                    $form.wpjam_query();
     937                                }
     938
     939                                return false;
     940                            }
     941                        }
     942                    }).on('keydown', '.tablenav :input', function(e){
     943                        if(e.key === 'Enter' && wpjam.ajax_list_action !== false){
     944                            let $input  = $(this);
     945
     946                            if($input.is('#current-page-selector')){
     947                                if($form.wpjam_validity()){
     948                                    $form.wpjam_query(_.extend(wpjam.params, {paged: parseInt($input.val())}));
     949                                }
     950
     951                                return false;
     952                            }else{
     953                                let $el = $input.closest(':has(:submit)').find(':submit');
     954
     955                                if($el.length){
     956                                    $el.first().focus().click();
     957
     958                                    return false;
     959                                }
     960                            }
    933961                        }
    934962                    }).on('click', '.tablenav .prev-day, .tablenav .next-day', function(e){
     
    9861014                        $left.prop('novalidate', true).on('init', function(){
    9871015                            $left_paged = $left.find('input.current-page').addClass('expandable');
     1016
    9881017                            let paged   = parseInt($left_paged.val());
    9891018                            let total   = parseInt($left_paged.attr('max'));
     
    11051134
    11061135                if(update.table || update.tablenav){
    1107                     let $nav        = $form.find('.tablenav.top').find('.overall-action').remove().end();           
    1108                     let $actions    = $nav.find('div.actions');
    1109 
    1110                     if($actions.length){
    1111                         $actions.last().append(this.overall_actions || '');
     1136                    if($left.length && $('a.page-title-action').length){
     1137                        this.overall_actions.unshift($('a.page-title-action').hide().clone().show().toggleClass('page-title-action button').prop('outerHTML'));
     1138                    }
     1139
     1140                    let $nav    = $form.find('.tablenav.top').find('.overall-action').remove().end();
     1141
     1142                    if($nav.find('div.actions').length){
     1143                        $nav.find('div.actions').last().append(this.overall_actions || '');
    11121144                    }else{
    11131145                        $nav.prepend(this.overall_actions || '');
  • wpjam-basic/trunk/wpjam-basic.php

    r3238028 r3238453  
    44Plugin URI: https://blog.wpjam.com/project/wpjam-basic/
    55Description: WPJAM 常用的函数和接口,屏蔽所有 WordPress 不常用的功能。
    6 Version: 6.7.4
     6Version: 6.7.4.1
    77Requires at least: 6.4
    88Tested up to: 6.5
Note: See TracChangeset for help on using the changeset viewer.