Plugin Directory

Changeset 2839607


Ignore:
Timestamp:
12/27/2022 03:07:39 AM (3 years ago)
Author:
serviceslbk
Message:

init 1.2.0

Location:
lbk-faqs-schema
Files:
15 added
3 edited

Legend:

Unmodified
Added
Removed
  • lbk-faqs-schema/trunk/includes/class.admin.php

    r2837759 r2839607  
    3131            add_action( 'save_post', array( $this, 'lbk_custom_faq_save' ) );
    3232            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_script' ) );
     33            add_action( 'restrict_manage_posts', array( $this, 'post_has_faqs_filter' ) );
     34            add_filter( 'parse_query', array( $this, 'post_has_faqs_filter_results' ) );
    3335        }
    3436
     
    139141        }
    140142
     143        public function post_has_faqs_filter() {
     144          $values = array(
     145            'Bài viết có FAQs' => 'posts_have_faqs'
     146          );
     147          ?>
     148          <select name="faqs_post_filter">
     149          <option value=""><?php _e('Tất cả bài viết ', 'lbk-faqs'); ?></option>
     150          <?php
     151            $current_v = isset($_GET['faqs_post_filter'])? $_GET['faqs_post_filter']:'';
     152            foreach ($values as $label => $value) {
     153              printf(
     154                '<option value="%s" %s>%s</option>',
     155                $value,
     156                $value == $current_v? ' selected="selected"':'',
     157                $label
     158              );
     159            }
     160          ?>
     161          </select>
     162          <?php
     163        }
     164
     165        public function post_has_faqs_filter_results($query){
     166          global $pagenow;
     167          if ( is_admin() && $pagenow=='edit.php' && isset($_GET['faqs_post_filter']) && $_GET['faqs_post_filter'] == 'posts_have_faqs' ) {
     168            $query->query_vars['meta_key'] = '_lbk_custom_faqs';
     169          }
     170        }
     171
    141172        /**
    142173         * Enqueue scripts
Note: See TracChangeset for help on using the changeset viewer.