public function controls() { global $wpdb; $inc_obj = new q2w3_include_obj($this->plugin_id); // count number of sub filters $count_filters = $wpdb->get_results('SELECT count(DISTINCT ' . $inc_obj->status->col_name . ') FROM ' . $inc_obj->table(), ARRAY_N); if ($count_filters[0][0]) { $count_filters = $count_filters[0][0]; } else { return false; } // if no data to be filtered return false // Add additional 'Select All' sub filter $filters['all'] = __('All', $this->plugin_id); $filters += $inc_obj->status->input_values; $count_filters++; $i = 0; $res = ''; if (key_exists(self::VAR_NAME, $_GET)) { $cur_filter = $_GET[self::VAR_NAME]; } else { $cur_filter = false; } foreach ($filters as $filter_key => $filter_name) { // sub filter cycle $condition = 'WHERE ' . $inc_obj->status->col_name . ' = ' . $filter_key; if ($filter_key == 'all') { $condition = false; } // total records for sub filter $count = $wpdb->get_results('SELECT count(*) FROM ' . $inc_obj->table() . ' ' . $condition, ARRAY_N); if ($count[0][0] > 0) { $i++; if ($i < $count_filters) { $separator = '|'; } else { $separator = ''; } $link = q2w3_table_func::change_qstring(self::VAR_NAME, $filter_key); // change filter id $link = $_SERVER['PHP_SELF'] . '?' . q2w3_table_func::change_qstring(q2w3_table_page_filter::VAR_NAME, '', $link); // reset page to number 1 if ($cur_filter == $filter_key || !$cur_filter && $filter_key == 'all') { $selected = ' class="current"'; } else { $selected = false; } $res .= '<div style="float: left"><a href="' . $link . '"' . $selected . '>' . $filter_name . ' <span class="count">(' . $count[0][0] . ')</span></a>' . $separator . '</div>' . PHP_EOL; } } if ($res) { $ul = '<div class="subsubsub">' . PHP_EOL; $ul .= $res; $ul .= '</div>' . PHP_EOL; $ul .= '<div style="clear: left;"></div>' . PHP_EOL; $this->inc_obj = $inc_obj; $this->filters = $filters; } return $ul; }
public static function action($plugin_id, $object_name) { $checked = $_POST['checked']; if (is_array($checked)) { $object = new q2w3_include_obj($plugin_id); foreach ($checked as $id => $no_value) { $object->id->val = $id; $object->change_status(q2w3_include_obj::STATUS_ACTIVE); } } }
public static function page_selectors() { global $wp_post_types, $wp_taxonomies; $res = q2w3_include_obj::page_selectors(); foreach ($wp_post_types as $post_type) { if (!in_array($post_type->name, q2w3_inc_manager::$restricted_post_types)) { $res += array($post_type->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $post_type->labels->name); $res += array('post_type_archive_' . $post_type->name => __('Archive', q2w3_inc_manager::ID) . ': ' . $post_type->labels->name); $selectors = self::select_post_type($post_type->name); if (!empty($selectors)) { $res += $selectors; } } } foreach ($wp_taxonomies as $taxonomy) { if (!in_array($taxonomy->name, q2w3_inc_manager::$restricted_taxonomies)) { $res += array($taxonomy->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $taxonomy->labels->name); $selectors = self::select_taxonomy($taxonomy->name); if (!empty($selectors)) { $res += $selectors; } } } $formats_orig = get_post_format_strings(); foreach ($formats_orig as $fkey => $fname) { $res['post_format_' . $fkey] = __('PF', $plugin_id) . ': ' . $fname; } return $res; }
/** * Returns array of selectable pages * */ protected static function selectable_pages($plugin_id, $type) { // $type = [include] [exclude] global $wp_post_types, $wp_taxonomies; $values_to_select = q2w3_include_obj::page_selectors($plugin_id); if ($type == 'exclude') { array_shift($values_to_select); } $options = get_option(q2w3_inc_manager::ID); if (!$options) { $options = q2w3_inc_manager::$default_options; } if ($options['taxonomies']['post_format']['enable']) { $formats_orig = get_post_format_strings(); foreach ($formats_orig as $fkey => $fname) { $formats['post_format_' . $fkey] = __('PF', $plugin_id) . ': ' . $fname; } $values_to_select[__('Post Formats')] = $formats; } foreach ($options['post_types'] as $post_type => $params) { $pages = NULL; if ($params['enable'] == 'on' && !in_array($post_type, q2w3_inc_manager::$restricted_post_types)) { $post_type_name = $wp_post_types[$post_type]->labels->name; $selectors = array($post_type . '_all' => __('All', $plugin_id) . ' ' . $post_type_name); if (version_compare($GLOBALS['wp_version'], '3.1.0', '>=') && $post_type != 'page') { $selectors = array_merge($selectors, array('post_type_archive_' . $post_type => __('Archive', $plugin_id) . ': ' . $post_type_name)); } if ($params['expand'] == 'on') { $pages = q2w3_table_func::select_post_type($post_type); } if (!empty($pages)) { $selectors = array_merge($selectors, $pages); } $values_to_select[$post_type_name] = $selectors; } } foreach ($options['taxonomies'] as $taxonomy => $params) { $pages = NULL; if ($params['enable'] == 'on' && !in_array($taxonomy, q2w3_inc_manager::$restricted_taxonomies)) { $taxonomy_name = $wp_taxonomies[$taxonomy]->labels->name; $selectors = array($taxonomy . '_all' => __('All', $plugin_id) . ' ' . $taxonomy_name); if ($params['expand'] == 'on') { $pages = q2w3_table_func::select_taxonomy($taxonomy); } if (!empty($pages)) { $selectors = array_merge($selectors, $pages); } $values_to_select[$taxonomy_name] = $selectors; } } /*$pages = q2w3_table_func::wp_pages(); if (!empty($pages)) $values_to_select[__('Pages', $plugin_id)] = $pages; $pages = q2w3_table_func::wp_categories(); if (!empty($pages)) $values_to_select[__('Categories', $plugin_id)] = $pages; $pages = q2w3_table_func::wp_tags(); if (!empty($pages)) $values_to_select[__('Tags', $plugin_id)] = $pages; $pages = q2w3_table_func::wp_posts(); if (!empty($pages)) $values_to_select[__('Posts', $plugin_id)] = $pages;*/ return $values_to_select; }