コード例 #1
0
 /**
  * @hook plugins_loaded
  */
 private function add_screen_options()
 {
     HW_HOANGWEB::load_class('HW_Screen_Option');
     if (class_exists('HW_HELP', false)) {
         $page_slug = HW_HELP::load_settings_page_hook_slug(self::PAGE_SLUG, '');
         $screen = HW_Screen_Option::get_instance('hw_module_setting_page', $page_slug);
         #HW_Screen_Option::get('modules-manager')->get_option('xx');
         $screen->add_options(array('per_page' => array('label' => 'Số lượng/trang', 'default' => '10')));
         $screen->addition_text('Dành cho trang cấu hình Module Hoangweb.');
     }
 }
コード例 #2
0
 /**
  * Prepare the table with different parameters, pagination, columns and table elements
  */
 function prepare_items()
 {
     $screen = get_current_screen();
     /* -- Preparing your query -- */
     //AWC_WidgetFeature_saveconfig::get_widgets_settings();
     $query = "SELECT * FROM " . HW_SKIN::SKINS_SETTINGS_DB;
     #$per_page = $this->get_items_per_page('per_page', 5);
     $per_page = HW_Screen_Option::get('hw_module_setting_page')->get_option('per_page', 5);
     if (!isset($_GET['orderby'])) {
         $_GET['orderby'] = 'id';
     }
     //if no specific order with column, get id column
     $query = $this->get_items_sql_orderby($query, 'DESC');
     $query = $this->get_items_sql_pagination($query, $per_page);
     $this->_prepare_items($query);
 }
 /**
  * Gathers and renames all of our plugin information to be used by
  * WP_List_Table to create our table.
  *
  * @since 2.2.0
  * @param $status
  * @param $search
  *
  * @return array $table_data Information for use in table.
  */
 protected function _gather_plugin_data($status = 'all', $search = '')
 {
     // Load thickbox for plugin links.
     #HW_TGM_Module_Activation::$instance->admin_init();
     #HW_TGM_Module_Activation::$instance->thickbox();
     $plugins_list = HW_TGM_Module_Activation::$instance->plugins;
     //plugins list
     // Prep variables for use and grab list of all installed plugins.
     $table_data = array();
     $i = 0;
     #$installed_plugins = get_plugins();
     $installed_plugins = hw_get_modules();
     //by hoang
     //pagination
     $per_page = HW_Screen_Option::get('modules_manager')->get_option('per_page', 5);
     #_print($per_page);
     if (!is_numeric($per_page)) {
         $per_page = 20;
     }
     $current_page = $this->get_pagenum();
     $total_items = count($plugins_list);
     // only ncessary because we have sample data
     $plugins_list = array_slice($plugins_list, ($current_page - 1) * $per_page, $per_page);
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
     foreach ($plugins_list as $plugin) {
         //search module
         if ($search && !HW_TGM_Module_Activation::match_module_search($plugin, $search)) {
             continue;
         }
         //check status
         $is_active = hw_is_active_module($plugin['file_path']);
         if ($status == 'inactive' && $is_active || $status == 'active' && !$is_active) {
             continue;
             // No need to display plugins if they are installed and activated.
         }
         $table_data[$i] = $plugin;
         //copy all information of the module
         $table_data[$i]['sanitized_plugin'] = $plugin['name'];
         $table_data[$i]['slug'] = $this->_get_plugin_data_from_name($plugin['name']);
         $external_url = $this->_get_plugin_data_from_name($plugin['name'], 'external_url');
         $source = $this->_get_plugin_data_from_name($plugin['name'], 'source');
         if ($external_url && preg_match('|^http(s)?://|', $external_url)) {
             $table_data[$i]['plugin'] = '<strong><a href="' . esc_url($external_url) . '" title="' . esc_attr($plugin['name']) . '" target="_blank">' . $plugin['name'] . '</a></strong>';
         } elseif (!$source || preg_match('|^http://hoangweb.vn/modules/|', $source)) {
             $url = add_query_arg(array('tab' => 'plugin-information', 'plugin' => urlencode($this->_get_plugin_data_from_name($plugin['name'])), 'TB_iframe' => 'true', 'width' => '640', 'height' => '500'), network_admin_url('plugin-install.php'));
             #$table_data[$i]['plugin'] = '<strong><a href="' . esc_url( $url ) . '" class="thickbox" title="' . esc_attr( $plugin['name'] ) . '">' . $plugin['name'] . '</a></strong>';
             $table_data[$i]['plugin'] = "<strong>{$plugin['name']}</strong>";
         } else {
             $table_data[$i]['plugin'] = '<strong>' . $plugin['name'] . '</strong>';
             // No hyperlink.
         }
         if (isset($table_data[$i]['plugin']) && (array) $table_data[$i]['plugin']) {
             $plugin['name'] = $table_data[$i]['plugin'];
         }
         if (!empty($plugin['source'])) {
             // The plugin must be from a private repository.
             if (preg_match('|^http(s)?://|', $plugin['source'])) {
                 $table_data[$i]['source'] = __('Private Repository', 'tgmpa');
                 // The plugin is pre-packaged with the theme.
             } else {
                 $table_data[$i]['source'] = __('Pre-Packaged', 'tgmpa');
             }
         }
         $table_data[$i]['source'] = 'Hoangweb';
         if (isset($plugin['desc'])) {
             $table_data[$i]['desc'] = $plugin['desc'];
         }
         // The plugin is from the WordPress repository.
         /*else {
               $table_data[$i]['source'] = __( 'WordPress Repository', 'tgmpa' );
           }*/
         $table_data[$i]['type'] = isset($plugin['required']) && $plugin['required'] ? __('Required', 'tgmpa') : __('Recommended', 'tgmpa');
         $status_class = array();
         if (isset($installed_plugins[$plugin['file_path']]) && isset($table_data[$i]['force_activation']) && $table_data[$i]['force_activation'] == true) {
             $status_class[] = 'hw-module-force-activation';
         }
         if (!isset($installed_plugins[$plugin['file_path']])) {
             $status_class[] = 'hw-module-inactive';
             $table_data[$i]['status'] = sprintf('%1$s', __('<span class="' . join(' ', $status_class) . '">Not Installed</span>', 'tgmpa'));
         } else {
             $status_class[] = 'hw-module-active';
             $table_data[$i]['status'] = sprintf('%1$s', __('<span style="color:blue" class="' . join(' ', $status_class) . '"><strong>Installed</strong></span>', 'tgmpa'));
         }
         $table_data[$i]['file_path'] = $plugin['file_path'];
         $table_data[$i]['url'] = isset($plugin['source']) ? $plugin['source'] : 'repo';
         $i++;
     }
     // Sort plugins by Required/Recommended type and by alphabetical listing within each type.
     $resort = array();
     $req = array();
     $rec = array();
     // Grab all the plugin types.
     foreach ($table_data as $plugin) {
         $resort[] = $plugin['type'];
     }
     // Sort each plugin by type.
     foreach ($resort as $type) {
         if ('Required' == $type) {
             $req[] = $type;
         } else {
             $rec[] = $type;
         }
     }
     // Sort alphabetically each plugin type array, merge them and then sort in reverse (lists Required plugins first).
     sort($req);
     sort($rec);
     array_merge($resort, $req, $rec);
     array_multisort($resort, SORT_DESC, $table_data);
     return $table_data;
 }
コード例 #4
0
 /**
  * Singleton instance
  * @param $page_slug
  * @param $options
  */
 public static function get_instance($options = null, $page_slug = '')
 {
     if (!isset(self::$instance)) {
         self::$instance = new self($options, $page_slug);
     }
     return self::$instance;
 }