Version Description
Download this release
Release Info
Developer | petervanderdoes |
Plugin | AVH Extended Categories Widgets |
Version | 3.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.3
- 2.8/class/avh-ec.admin.php +47 -77
- 2.8/class/avh-ec.category-group.php +84 -83
- 2.8/class/avh-ec.core.php +24 -16
- 2.8/class/avh-ec.widgets.php +99 -7
- readme.txt +42 -4
- widget-pre2.8.php +1 -1
- widget_extended_categories.php +1 -1
2.8/class/avh-ec.admin.php
CHANGED
@@ -36,7 +36,6 @@ class AVH_EC_Admin
|
|
36 |
// Actions used for editing posts
|
37 |
add_action( 'load-post.php', array (&$this, 'actionLoadPostPage' ) );
|
38 |
add_action( 'load-page.php', array (&$this, 'actionLoadPostPage' ) );
|
39 |
-
add_action( 'save_post', array (&$this, 'actionSaveCategoryGroupTaxonomy' ) );
|
40 |
|
41 |
// Actions related to adding and deletes categories
|
42 |
add_action( "created_category", array ($this, 'actionCreatedCategory' ), 10, 2 );
|
@@ -57,75 +56,6 @@ class AVH_EC_Admin
|
|
57 |
$this->__construct();
|
58 |
}
|
59 |
|
60 |
-
/**
|
61 |
-
* Shows a metabox on the page post.php and page.php
|
62 |
-
* This function gets called in edit-form-advanced.php
|
63 |
-
*
|
64 |
-
* @param $post
|
65 |
-
*/
|
66 |
-
function metaboxPostCategoryGroup ( $post )
|
67 |
-
{
|
68 |
-
$options = $this->core->getOptions();
|
69 |
-
echo '<p id=\'avhec-cat-group\'>';
|
70 |
-
|
71 |
-
echo '<input type="hidden" name="avhec_category_group_nonce" id="avhec_category_group_nonce" value="' . wp_create_nonce( 'avhec_category_group_nonce' ) . '" />';
|
72 |
-
|
73 |
-
// Get all the taxonomy terms
|
74 |
-
$category_groups = get_terms( $this->catgrp->taxonomy_name, array ('hide_empty' => FALSE ) );
|
75 |
-
|
76 |
-
echo ' <select name=\'post_avhec_category_group\' id=\'post_avhec_category_group\' class=\'postform\'>';
|
77 |
-
$current_category_group = wp_get_object_terms( $post->ID, $this->catgrp->taxonomy_name );
|
78 |
-
|
79 |
-
foreach ( $category_groups as $group ) {
|
80 |
-
if ( ! is_wp_error( $current_category_group ) && ! empty( $current_category_group ) && ! strcmp( $group->term_id, $current_category_group[0]->term_id ) ) {
|
81 |
-
echo '<option value="' . $group->term_id . '" selected=\'selected\'>' . $group->name . "</option>\n";
|
82 |
-
} else {
|
83 |
-
if ( empty( $current_category_group ) && $options['cat_group']['default_group'] == $group->term_id ) {
|
84 |
-
echo '<option value="' . $group->term_id . '" selected=\'selected\'>' . $group->name . "</option>\n";
|
85 |
-
} else {
|
86 |
-
echo '<option value="' . $group->term_id . '">' . $group->name . "</option>\n";
|
87 |
-
}
|
88 |
-
}
|
89 |
-
}
|
90 |
-
echo '</select>';
|
91 |
-
echo '<em>Selecting the group \'none\' will not show the widget on the page.</em>';
|
92 |
-
echo '</p>';
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Called when the post/page is saved. It associates the selected Category Group with the post
|
97 |
-
*
|
98 |
-
* @param $post_id
|
99 |
-
* @return
|
100 |
-
*/
|
101 |
-
function actionSaveCategoryGroupTaxonomy ( $post_id )
|
102 |
-
{
|
103 |
-
|
104 |
-
if ( ! wp_verify_nonce( $_POST['avhec_category_group_nonce'], 'avhec_category_group_nonce' ) ) {
|
105 |
-
return $post_id;
|
106 |
-
}
|
107 |
-
|
108 |
-
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
|
109 |
-
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
|
110 |
-
return $post_id;
|
111 |
-
|
112 |
-
// Check permissions
|
113 |
-
if ( 'page' == $_POST['post_type'] ) {
|
114 |
-
if ( ! current_user_can( 'edit_page', $post_id ) )
|
115 |
-
return $post_id;
|
116 |
-
} else {
|
117 |
-
if ( ! current_user_can( 'edit_post', $post_id ) )
|
118 |
-
return $post_id;
|
119 |
-
}
|
120 |
-
|
121 |
-
// OK, we're authenticated: we need to find and save the data
|
122 |
-
$group_term_id = ( int ) $_POST['post_avhec_category_group'];
|
123 |
-
wp_set_object_terms( $post_id, $group_term_id, $this->catgrp->taxonomy_name );
|
124 |
-
|
125 |
-
return $post_id;
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
/**
|
130 |
* When a category is created this function is called to add the new category to the group all
|
131 |
* @param $term_id
|
@@ -172,10 +102,6 @@ class AVH_EC_Admin
|
|
172 |
wp_register_script( 'avhec-categorygroup-js', AVHEC_PLUGIN_URL . '/js/avh-ec.categorygroup' . $suffix . '.js', array ('jquery' ), $this->core->version, true );
|
173 |
wp_register_style( 'avhec-admin-css', AVHEC_PLUGIN_URL . '/css/avh-ec.admin.css', array ('wp-admin' ), $this->core->version, 'screen' );
|
174 |
|
175 |
-
// Metaboxes for the Category Group on the post and page pages
|
176 |
-
add_meta_box( 'avhec_category_group_box_ID', __( 'Category Group', 'avh-ec' ), array (&$this, 'metaboxPostCategoryGroup' ), 'post', 'side', 'core' );
|
177 |
-
add_meta_box( 'avhec_category_group_box_ID', __( 'Category Group', 'avh-ec' ), array (&$this, 'metaboxPostCategoryGroup' ), 'page', 'side', 'core' );
|
178 |
-
|
179 |
// Add menu system
|
180 |
$folder = $this->core->getBaseDirectory( AVHEC_PLUGIN_DIR );
|
181 |
add_menu_page( 'AVH Extended Categories', 'AVH Extended Categories', 'manage_options', $folder, array (&$this, 'doMenuOverview' ) );
|
@@ -392,8 +318,7 @@ class AVH_EC_Admin
|
|
392 |
echo '<div class="wrap avhec-wrap">';
|
393 |
echo $this->displayIcon( 'index' );
|
394 |
echo '<h2>' . 'AVH Extended Categories - ' . __( 'General Options', 'avh-ec' ) . '</h2>';
|
395 |
-
|
396 |
-
echo '<form name="avhec-generaloptions" id="avhec-generaloptions" method="POST" action="' . $admin_base_url . 'avhec-general' . '" accept-charset="utf-8" >';
|
397 |
wp_nonce_field( 'avh_ec_generaloptions' );
|
398 |
|
399 |
echo ' <div id="dashboard-widgets-wrap">';
|
@@ -438,6 +363,7 @@ class AVH_EC_Admin
|
|
438 |
// Add metaboxes
|
439 |
add_meta_box( 'avhecBoxCategoryGroupAdd', __( 'Add Group', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupAdd' ), $this->hooks['menu_category_groups'], 'normal', 'core' );
|
440 |
add_meta_box( 'avhecBoxCategoryGroupList', __( 'Group Overview', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupList' ), $this->hooks['menu_category_groups'], 'side', 'core' );
|
|
|
441 |
|
442 |
add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
|
443 |
// WordPress core Scripts
|
@@ -479,6 +405,7 @@ class AVH_EC_Admin
|
|
479 |
$options_edit_group[] = array ('avhec_edit_group[edit][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
|
480 |
$options_edit_group[] = array ('avhec_edit_group[edit][categories]', ' Categories', 'catlist', 0, 'Select categories to be included in the group.' );
|
481 |
|
|
|
482 |
if ( isset( $_POST['addgroup'] ) ) {
|
483 |
check_admin_referer( 'avh_ec_addgroup' );
|
484 |
|
@@ -583,6 +510,38 @@ class AVH_EC_Admin
|
|
583 |
$hide2 = 'display:none;';
|
584 |
}
|
585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
// This box can't be unselectd in the the Screen Options
|
587 |
//add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_category_groups'], 'side', 'core' );
|
588 |
|
@@ -590,7 +549,6 @@ class AVH_EC_Admin
|
|
590 |
echo '<div class="wrap avhec-wrap">';
|
591 |
echo $this->displayIcon( 'index' );
|
592 |
echo '<h2>' . 'AVH Extended Categories - ' . __( 'Category Groups', 'avh-ec' ) . '</h2>';
|
593 |
-
$admin_base_url = $this->core->info['siteurl'] . '/wp-admin/admin.php?page=';
|
594 |
|
595 |
echo ' <div id="dashboard-widgets-wrap">';
|
596 |
echo ' <div id="dashboard-widgets" class="metabox-holder">';
|
@@ -676,6 +634,18 @@ class AVH_EC_Admin
|
|
676 |
echo '</form>';
|
677 |
}
|
678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
/**
|
680 |
* Setup everything needed for the FAQ page
|
681 |
*
|
36 |
// Actions used for editing posts
|
37 |
add_action( 'load-post.php', array (&$this, 'actionLoadPostPage' ) );
|
38 |
add_action( 'load-page.php', array (&$this, 'actionLoadPostPage' ) );
|
|
|
39 |
|
40 |
// Actions related to adding and deletes categories
|
41 |
add_action( "created_category", array ($this, 'actionCreatedCategory' ), 10, 2 );
|
56 |
$this->__construct();
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
/**
|
60 |
* When a category is created this function is called to add the new category to the group all
|
61 |
* @param $term_id
|
102 |
wp_register_script( 'avhec-categorygroup-js', AVHEC_PLUGIN_URL . '/js/avh-ec.categorygroup' . $suffix . '.js', array ('jquery' ), $this->core->version, true );
|
103 |
wp_register_style( 'avhec-admin-css', AVHEC_PLUGIN_URL . '/css/avh-ec.admin.css', array ('wp-admin' ), $this->core->version, 'screen' );
|
104 |
|
|
|
|
|
|
|
|
|
105 |
// Add menu system
|
106 |
$folder = $this->core->getBaseDirectory( AVHEC_PLUGIN_DIR );
|
107 |
add_menu_page( 'AVH Extended Categories', 'AVH Extended Categories', 'manage_options', $folder, array (&$this, 'doMenuOverview' ) );
|
318 |
echo '<div class="wrap avhec-wrap">';
|
319 |
echo $this->displayIcon( 'index' );
|
320 |
echo '<h2>' . 'AVH Extended Categories - ' . __( 'General Options', 'avh-ec' ) . '</h2>';
|
321 |
+
echo '<form name="avhec-generaloptions" id="avhec-generaloptions" method="POST" action="' . admin_url('admin.php?page=avhec-general') . '" accept-charset="utf-8" >';
|
|
|
322 |
wp_nonce_field( 'avh_ec_generaloptions' );
|
323 |
|
324 |
echo ' <div id="dashboard-widgets-wrap">';
|
363 |
// Add metaboxes
|
364 |
add_meta_box( 'avhecBoxCategoryGroupAdd', __( 'Add Group', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupAdd' ), $this->hooks['menu_category_groups'], 'normal', 'core' );
|
365 |
add_meta_box( 'avhecBoxCategoryGroupList', __( 'Group Overview', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupList' ), $this->hooks['menu_category_groups'], 'side', 'core' );
|
366 |
+
add_meta_box( 'avhecBoxCategoryGroupSpecialPages', __( 'Special Pages', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupSpecialPages' ), $this->hooks['menu_category_groups'], 'normal', 'core' );
|
367 |
|
368 |
add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
|
369 |
// WordPress core Scripts
|
405 |
$options_edit_group[] = array ('avhec_edit_group[edit][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
|
406 |
$options_edit_group[] = array ('avhec_edit_group[edit][categories]', ' Categories', 'catlist', 0, 'Select categories to be included in the group.' );
|
407 |
|
408 |
+
|
409 |
if ( isset( $_POST['addgroup'] ) ) {
|
410 |
check_admin_referer( 'avh_ec_addgroup' );
|
411 |
|
510 |
$hide2 = 'display:none;';
|
511 |
}
|
512 |
|
513 |
+
$data_special_pages_old=$this->core->options['sp_cat_group'];
|
514 |
+
$data_special_pages_new=$data_special_pages_old;
|
515 |
+
if ( isset( $_POST['avhec_special_pages'] ) ) {
|
516 |
+
check_admin_referer( 'avh_ec_specialpagesgroup' );
|
517 |
+
|
518 |
+
$formoptions = $_POST['avhec_special_pages'];
|
519 |
+
$formdata = $formoptions['sp'];
|
520 |
+
foreach ($formdata as $key => $value) {
|
521 |
+
$data_special_pages_new[$key] = $value;
|
522 |
+
}
|
523 |
+
$this->core->options['sp_cat_group']=$data_special_pages_new;
|
524 |
+
$this->core->saveOptions($this->core->options);
|
525 |
+
|
526 |
+
}
|
527 |
+
$data_special_pages['sp']=$data_special_pages_new;
|
528 |
+
$cat_groups = get_terms( $this->catgrp->taxonomy_name, array ('hide_empty' => FALSE ) );
|
529 |
+
|
530 |
+
foreach ( $cat_groups as $group ) {
|
531 |
+
$temp_cat = get_term( $group->term_id, $this->catgrp->taxonomy_name, OBJECT, 'edit' );
|
532 |
+
$dropdown_value[]= $group->term_id;
|
533 |
+
$dropdown_text[]= $temp_cat->name;
|
534 |
+
}
|
535 |
+
$options_special_pages[] = array('avhec_special_pages[sp][home_group]','Home page','dropdown',$dropdown_value,$dropdown_text,'');
|
536 |
+
$options_special_pages[] = array('avhec_special_pages[sp][category_group]','Category Archive','dropdown',$dropdown_value,$dropdown_text,'');
|
537 |
+
$options_special_pages[] = array('avhec_special_pages[sp][day_group]','Daily Archive','dropdown',$dropdown_value,$dropdown_text,'');
|
538 |
+
$options_special_pages[] = array('avhec_special_pages[sp][month_group]','Monthly Archive','dropdown',$dropdown_value,$dropdown_text,'');
|
539 |
+
$options_special_pages[] = array('avhec_special_pages[sp][year_group]','Yearly Archive','dropdown',$dropdown_value,$dropdown_text,'');
|
540 |
+
$options_special_pages[] = array('avhec_special_pages[sp][author_group]','Author Archive','dropdown',$dropdown_value,$dropdown_text,'');
|
541 |
+
$options_special_pages[] = array('avhec_special_pages[sp][search_group]','Search Page','dropdown',$dropdown_value,$dropdown_text,'');
|
542 |
+
|
543 |
+
$data['sp']=array ('form' => $options_special_pages, 'data' => $data_special_pages );
|
544 |
+
|
545 |
// This box can't be unselectd in the the Screen Options
|
546 |
//add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_category_groups'], 'side', 'core' );
|
547 |
|
549 |
echo '<div class="wrap avhec-wrap">';
|
550 |
echo $this->displayIcon( 'index' );
|
551 |
echo '<h2>' . 'AVH Extended Categories - ' . __( 'Category Groups', 'avh-ec' ) . '</h2>';
|
|
|
552 |
|
553 |
echo ' <div id="dashboard-widgets-wrap">';
|
554 |
echo ' <div id="dashboard-widgets" class="metabox-holder">';
|
634 |
echo '</form>';
|
635 |
}
|
636 |
|
637 |
+
/**
|
638 |
+
* Metabox Category Group Special pages
|
639 |
+
*
|
640 |
+
*/
|
641 |
+
function metaboxCategoryGroupSpecialPages ( $data )
|
642 |
+
{
|
643 |
+
echo '<form name="avhec-specialpagesgroup" id="avhec-specialpagesgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
|
644 |
+
wp_nonce_field( 'avh_ec_specialpagesgroup' );
|
645 |
+
echo $this->printOptions( $data['sp']['form'], $data['sp']['data'] );
|
646 |
+
echo '<p class="submit"><input class="button" type="submit" name="spgroup" value="' . __( 'Save settings', 'avh-ec' ) . '" /></p>';
|
647 |
+
echo '</form>';
|
648 |
+
}
|
649 |
/**
|
650 |
* Setup everything needed for the FAQ page
|
651 |
*
|
2.8/class/avh-ec.category-group.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* AVH Extended Categorie Category Group Class
|
4 |
*
|
@@ -17,6 +18,8 @@ class AVH_EC_Category_Group
|
|
17 |
|
18 |
var $options_widget_titles;
|
19 |
|
|
|
|
|
20 |
/**
|
21 |
* PHP4 constructor.
|
22 |
*
|
@@ -35,7 +38,7 @@ class AVH_EC_Category_Group
|
|
35 |
{
|
36 |
global $wpdb;
|
37 |
|
38 |
-
register_shutdown_function(
|
39 |
|
40 |
/**
|
41 |
* Taxonomy name
|
@@ -51,11 +54,11 @@ class AVH_EC_Category_Group
|
|
51 |
* Create the table if it doesn't exist.
|
52 |
*
|
53 |
*/
|
54 |
-
if (
|
55 |
-
add_action(
|
56 |
}
|
57 |
-
add_action(
|
58 |
-
add_action(
|
59 |
|
60 |
}
|
61 |
|
@@ -79,23 +82,21 @@ class AVH_EC_Category_Group
|
|
79 |
/**
|
80 |
* Setup Group Categories Taxonomy
|
81 |
*/
|
82 |
-
|
83 |
-
|
84 |
-
register_taxonomy( $this->taxonomy_name, 'page', array ('hierarchical' => false, 'label' => __( 'Category Groups', 'avh-ec' ), 'query_var' => true, 'rewrite' => true, 'show_ui'=>false ) );
|
85 |
-
}
|
86 |
|
87 |
// Setup the standard groups if the none group does not exists.
|
88 |
-
if (
|
89 |
-
$none_group_id = wp_insert_term(
|
90 |
-
$all_group_id = wp_insert_term(
|
91 |
-
$home_group_id = wp_insert_term(
|
92 |
|
93 |
// Fill the standard groups with all categories
|
94 |
$all_categories = $this->getAllCategoriesTermID();
|
95 |
-
$this->setCategoriesForGroup(
|
96 |
-
$this->setCategoriesForGroup(
|
97 |
-
$this->setWidgetTitleForGroup(
|
98 |
-
$this->setWidgetTitleForGroup(
|
99 |
}
|
100 |
}
|
101 |
|
@@ -106,14 +107,14 @@ class AVH_EC_Category_Group
|
|
106 |
*/
|
107 |
function doSetupOptions ()
|
108 |
{
|
109 |
-
$options = get_option(
|
110 |
-
if (
|
111 |
-
$options = array
|
112 |
-
$id = $this->getTermIDBy(
|
113 |
$options[$id] = '';
|
114 |
-
$id = $this->getTermIDBy(
|
115 |
$options[$id] = '';
|
116 |
-
update_option(
|
117 |
}
|
118 |
$this->options_widget_titles = $options;
|
119 |
}
|
@@ -130,16 +131,16 @@ class AVH_EC_Category_Group
|
|
130 |
// Setup the DB Tables
|
131 |
$charset_collate = '';
|
132 |
|
133 |
-
if (
|
134 |
-
if (
|
135 |
$charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset;
|
136 |
-
if (
|
137 |
$charset_collate .= ' COLLATE ' . $wpdb->collate;
|
138 |
}
|
139 |
|
140 |
$sql = 'CREATE TABLE `' . $wpdb->avhec_cat_group . '` ( `group_term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`group_term_id`, `term_id`) )' . $charset_collate . ';';
|
141 |
|
142 |
-
$result = $wpdb->query(
|
143 |
}
|
144 |
|
145 |
/**
|
@@ -150,7 +151,7 @@ class AVH_EC_Category_Group
|
|
150 |
function getAllCategoriesTermID ()
|
151 |
{
|
152 |
$categories = get_categories();
|
153 |
-
foreach (
|
154 |
$all_cat_id[] = $category->term_id;
|
155 |
}
|
156 |
return ($all_cat_id);
|
@@ -163,18 +164,18 @@ class AVH_EC_Category_Group
|
|
163 |
* @return Array|False categories. Will return FALSE, if the row does not exists.
|
164 |
*
|
165 |
*/
|
166 |
-
function getCategoriesFromGroup (
|
167 |
{
|
168 |
global $wpdb;
|
169 |
|
170 |
// Query database
|
171 |
-
$result = $wpdb->get_results(
|
172 |
|
173 |
-
if (
|
174 |
-
if (
|
175 |
-
$return = array
|
176 |
} else {
|
177 |
-
foreach (
|
178 |
$return[] = $row->term_id;
|
179 |
}
|
180 |
}
|
@@ -192,40 +193,40 @@ class AVH_EC_Category_Group
|
|
192 |
* @return Object (false if not found)
|
193 |
*
|
194 |
*/
|
195 |
-
function setCategoriesForGroup (
|
196 |
{
|
197 |
global $wpdb;
|
198 |
|
199 |
-
$old_categories = $this->getCategoriesFromGroup(
|
200 |
|
201 |
-
if (
|
202 |
-
$categories = array
|
203 |
}
|
204 |
$new_categories = $categories;
|
205 |
-
sort(
|
206 |
-
sort(
|
207 |
// If the new and old values are the same, no need to update.
|
208 |
-
if (
|
209 |
return false;
|
210 |
}
|
211 |
|
212 |
-
$new = array_diff(
|
213 |
-
$removed = array_diff(
|
214 |
|
215 |
-
if (
|
216 |
-
foreach (
|
217 |
$insert[] = '(' . $group_id . ',' . $cat_term_id . ')';
|
218 |
}
|
219 |
-
$value = implode(
|
220 |
$sql = 'INSERT INTO ' . $wpdb->avhec_cat_group . ' (group_term_id, term_id) VALUES ' . $value;
|
221 |
-
$result = $wpdb->query(
|
222 |
|
223 |
}
|
224 |
|
225 |
-
if (
|
226 |
-
$delete = implode(
|
227 |
-
$sql = $wpdb->prepare(
|
228 |
-
$result = $wpdb->query(
|
229 |
|
230 |
}
|
231 |
|
@@ -238,10 +239,10 @@ class AVH_EC_Category_Group
|
|
238 |
* @param string $widget_title
|
239 |
*
|
240 |
*/
|
241 |
-
function setWidgetTitleForGroup (
|
242 |
{
|
243 |
$this->options_widget_titles[$group_id] = $widget_title;
|
244 |
-
update_option(
|
245 |
}
|
246 |
|
247 |
/**
|
@@ -249,9 +250,9 @@ class AVH_EC_Category_Group
|
|
249 |
* @param $group_id
|
250 |
*
|
251 |
*/
|
252 |
-
function getWidgetTitleForGroup (
|
253 |
{
|
254 |
-
if (
|
255 |
return ($this->options_widget_titles[$group_id]);
|
256 |
}
|
257 |
return false;
|
@@ -262,12 +263,12 @@ class AVH_EC_Category_Group
|
|
262 |
*
|
263 |
* @param $group_id
|
264 |
*/
|
265 |
-
function doDeleteWidgetTitle (
|
266 |
{
|
267 |
-
if (
|
268 |
-
unset(
|
269 |
}
|
270 |
-
update_option(
|
271 |
}
|
272 |
|
273 |
/**
|
@@ -276,13 +277,13 @@ class AVH_EC_Category_Group
|
|
276 |
* @param string $value
|
277 |
* @return int|boolean
|
278 |
*/
|
279 |
-
function getTermIDBy (
|
280 |
{
|
281 |
-
$row = get_term_by(
|
282 |
-
if (
|
283 |
$return = false;
|
284 |
} else {
|
285 |
-
$return = (
|
286 |
}
|
287 |
return ($return);
|
288 |
}
|
@@ -293,12 +294,12 @@ class AVH_EC_Category_Group
|
|
293 |
* @param $group_id
|
294 |
* @return Object|False Returns False when the group doesn't exists.
|
295 |
*/
|
296 |
-
function getGroup (
|
297 |
{
|
298 |
global $wpdb;
|
299 |
|
300 |
-
$result = get_term(
|
301 |
-
if (
|
302 |
$result = false;
|
303 |
}
|
304 |
return ($result);
|
@@ -310,10 +311,10 @@ class AVH_EC_Category_Group
|
|
310 |
* @param $term
|
311 |
* @param array $args
|
312 |
*/
|
313 |
-
function doInsertGroup (
|
314 |
{
|
315 |
-
$row = wp_insert_term(
|
316 |
-
$this->setWidgetTitleForGroup(
|
317 |
return ($row['term_id']);
|
318 |
}
|
319 |
|
@@ -322,15 +323,15 @@ class AVH_EC_Category_Group
|
|
322 |
*
|
323 |
* @param $group_id
|
324 |
*/
|
325 |
-
function doDeleteGroup (
|
326 |
{
|
327 |
|
328 |
global $wpdb;
|
329 |
|
330 |
-
$group = $this->getGroup(
|
331 |
-
$result = $wpdb->query(
|
332 |
-
$this->doDeleteWidgetTitle(
|
333 |
-
$return = wp_delete_term(
|
334 |
|
335 |
return ($return);
|
336 |
}
|
@@ -344,15 +345,15 @@ class AVH_EC_Category_Group
|
|
344 |
*
|
345 |
* return -1,0,1 Unknown Group, Duplicate Slug, Succesfull
|
346 |
*/
|
347 |
-
function doUpdateGroup (
|
348 |
{
|
349 |
|
350 |
-
$group = $this->getGroup(
|
351 |
-
if (
|
352 |
-
$id = wp_update_term(
|
353 |
-
if (
|
354 |
-
$this->setWidgetTitleForGroup(
|
355 |
-
$this->setCategoriesForGroup(
|
356 |
$return = 1; // Succesful
|
357 |
} else {
|
358 |
$return = 0; // Duplicate Slug
|
@@ -368,10 +369,10 @@ class AVH_EC_Category_Group
|
|
368 |
*
|
369 |
* @param $category_id
|
370 |
*/
|
371 |
-
function doDeleteCategoryFromGroup (
|
372 |
{
|
373 |
global $wpdb;
|
374 |
-
$result = $wpdb->query(
|
375 |
}
|
376 |
}
|
377 |
?>
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* AVH Extended Categorie Category Group Class
|
5 |
*
|
18 |
|
19 |
var $options_widget_titles;
|
20 |
|
21 |
+
var $widget_done_catgroup;
|
22 |
+
|
23 |
/**
|
24 |
* PHP4 constructor.
|
25 |
*
|
38 |
{
|
39 |
global $wpdb;
|
40 |
|
41 |
+
register_shutdown_function(array(&$this, '__destruct'));
|
42 |
|
43 |
/**
|
44 |
* Taxonomy name
|
54 |
* Create the table if it doesn't exist.
|
55 |
*
|
56 |
*/
|
57 |
+
if ($wpdb->get_var('show tables like \'' . $wpdb->avhec_cat_group . '\'') != $wpdb->avhec_cat_group) {
|
58 |
+
add_action('init', array(&$this, 'doCreateTable') ,2); // Priority needs to be the same as the Register Taxonomy
|
59 |
}
|
60 |
+
add_action('init', array(&$this, 'doRegisterTaxonomy'), 2); // Priority for registering custom taxonomies is +1 over the creation of the initial taxonomies
|
61 |
+
add_action('init', array(&$this, 'doSetupOptions'));
|
62 |
|
63 |
}
|
64 |
|
82 |
/**
|
83 |
* Setup Group Categories Taxonomy
|
84 |
*/
|
85 |
+
$labels = array('name'=>__('Category Groups', 'avh-ec'), 'singular_name'=>__('Category Group', 'avh-ec'), 'search_items'=>__('Search Category Groups', 'avh-ec'), 'popular_items'=>__('Popular Category Groups'), 'all_items'=>__('All Category Groups'), 'parent_item'=>__('Parent Category Group'), 'parent_item_colon'=>__('Parent Category Group:'), 'edit_item'=>__('Edit Category Group'), 'update_item'=>__('Update Category Group'), 'add_new_item'=>__('Add New Category Group'), 'new_item_name'=>__('New Category Group Name'));
|
86 |
+
register_taxonomy($this->taxonomy_name, array('post', 'page'), array('hierarchical'=>FALSE, 'labels'=> $labels, 'query_var'=>TRUE, 'rewrite'=>TRUE, 'show_in_nav_menus'=>FALSE));
|
|
|
|
|
87 |
|
88 |
// Setup the standard groups if the none group does not exists.
|
89 |
+
if (false === $this->getTermIDBy('slug', 'none')) {
|
90 |
+
$none_group_id = wp_insert_term('none', $this->taxonomy_name, array('description'=>'This group will not show the widget.'));
|
91 |
+
$all_group_id = wp_insert_term('All', $this->taxonomy_name, array('description'=>'Holds all the categories.'));
|
92 |
+
$home_group_id = wp_insert_term('Home', $this->taxonomy_name, array('description'=>'This group will be shown on the front page.'));
|
93 |
|
94 |
// Fill the standard groups with all categories
|
95 |
$all_categories = $this->getAllCategoriesTermID();
|
96 |
+
$this->setCategoriesForGroup($all_group_id['term_id'], $all_categories);
|
97 |
+
$this->setCategoriesForGroup($home_group_id['term_id'], $all_categories);
|
98 |
+
$this->setWidgetTitleForGroup($all_group_id['term_id'], '');
|
99 |
+
$this->setWidgetTitleForGroup($home_group_id['term_id'], '');
|
100 |
}
|
101 |
}
|
102 |
|
107 |
*/
|
108 |
function doSetupOptions ()
|
109 |
{
|
110 |
+
$options = get_option($this->db_options_widget_titles);
|
111 |
+
if (! $options) {
|
112 |
+
$options = array();
|
113 |
+
$id = $this->getTermIDBy('slug', 'all');
|
114 |
$options[$id] = '';
|
115 |
+
$id = $this->getTermIDBy('slug', 'home');
|
116 |
$options[$id] = '';
|
117 |
+
update_option($this->db_options_widget_titles, $options);
|
118 |
}
|
119 |
$this->options_widget_titles = $options;
|
120 |
}
|
131 |
// Setup the DB Tables
|
132 |
$charset_collate = '';
|
133 |
|
134 |
+
if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
|
135 |
+
if (! empty($wpdb->charset))
|
136 |
$charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset;
|
137 |
+
if (! empty($wpdb->collate))
|
138 |
$charset_collate .= ' COLLATE ' . $wpdb->collate;
|
139 |
}
|
140 |
|
141 |
$sql = 'CREATE TABLE `' . $wpdb->avhec_cat_group . '` ( `group_term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`group_term_id`, `term_id`) )' . $charset_collate . ';';
|
142 |
|
143 |
+
$result = $wpdb->query($sql);
|
144 |
}
|
145 |
|
146 |
/**
|
151 |
function getAllCategoriesTermID ()
|
152 |
{
|
153 |
$categories = get_categories();
|
154 |
+
foreach ($categories as $category) {
|
155 |
$all_cat_id[] = $category->term_id;
|
156 |
}
|
157 |
return ($all_cat_id);
|
164 |
* @return Array|False categories. Will return FALSE, if the row does not exists.
|
165 |
*
|
166 |
*/
|
167 |
+
function getCategoriesFromGroup ($group_id)
|
168 |
{
|
169 |
global $wpdb;
|
170 |
|
171 |
// Query database
|
172 |
+
$result = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->terms . ' t, ' . $wpdb->avhec_cat_group . ' cg WHERE t.term_id = cg.term_id AND cg.group_term_id = %d', $group_id));
|
173 |
|
174 |
+
if (is_array($result)) { // Call succeeded
|
175 |
+
if (empty($result)) { // No rows found
|
176 |
+
$return = array();
|
177 |
} else {
|
178 |
+
foreach ($result as $row) {
|
179 |
$return[] = $row->term_id;
|
180 |
}
|
181 |
}
|
193 |
* @return Object (false if not found)
|
194 |
*
|
195 |
*/
|
196 |
+
function setCategoriesForGroup ($group_id, $categories = array())
|
197 |
{
|
198 |
global $wpdb;
|
199 |
|
200 |
+
$old_categories = $this->getCategoriesFromGroup($group_id);
|
201 |
|
202 |
+
if (! is_array($categories)) {
|
203 |
+
$categories = array();
|
204 |
}
|
205 |
$new_categories = $categories;
|
206 |
+
sort($old_categories);
|
207 |
+
sort($new_categories);
|
208 |
// If the new and old values are the same, no need to update.
|
209 |
+
if ($new_categories === $old_categories) {
|
210 |
return false;
|
211 |
}
|
212 |
|
213 |
+
$new = array_diff($new_categories, $old_categories);
|
214 |
+
$removed = array_diff($old_categories, $new_categories);
|
215 |
|
216 |
+
if (! empty($new)) {
|
217 |
+
foreach ($new as $cat_term_id) {
|
218 |
$insert[] = '(' . $group_id . ',' . $cat_term_id . ')';
|
219 |
}
|
220 |
+
$value = implode(',', $insert);
|
221 |
$sql = 'INSERT INTO ' . $wpdb->avhec_cat_group . ' (group_term_id, term_id) VALUES ' . $value;
|
222 |
+
$result = $wpdb->query($sql);
|
223 |
|
224 |
}
|
225 |
|
226 |
+
if (! empty($removed)) {
|
227 |
+
$delete = implode(',', $removed);
|
228 |
+
$sql = $wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d and term_id IN (' . $delete . ')', $group_id);
|
229 |
+
$result = $wpdb->query($sql);
|
230 |
|
231 |
}
|
232 |
|
239 |
* @param string $widget_title
|
240 |
*
|
241 |
*/
|
242 |
+
function setWidgetTitleForGroup ($group_id, $widget_title = '')
|
243 |
{
|
244 |
$this->options_widget_titles[$group_id] = $widget_title;
|
245 |
+
update_option($this->db_options_widget_titles, $this->options_widget_titles);
|
246 |
}
|
247 |
|
248 |
/**
|
250 |
* @param $group_id
|
251 |
*
|
252 |
*/
|
253 |
+
function getWidgetTitleForGroup ($group_id)
|
254 |
{
|
255 |
+
if (isset($this->options_widget_titles[$group_id])) {
|
256 |
return ($this->options_widget_titles[$group_id]);
|
257 |
}
|
258 |
return false;
|
263 |
*
|
264 |
* @param $group_id
|
265 |
*/
|
266 |
+
function doDeleteWidgetTitle ($group_id)
|
267 |
{
|
268 |
+
if (isset($this->db_options_widget_titles[$group_id])) {
|
269 |
+
unset($this->db_options_widget_titles[$group_id]);
|
270 |
}
|
271 |
+
update_option($this->db_options_widget_titles, $this->options_widget_titles);
|
272 |
}
|
273 |
|
274 |
/**
|
277 |
* @param string $value
|
278 |
* @return int|boolean
|
279 |
*/
|
280 |
+
function getTermIDBy ($field, $value)
|
281 |
{
|
282 |
+
$row = get_term_by($field, $value, $this->taxonomy_name);
|
283 |
+
if (false === $row) {
|
284 |
$return = false;
|
285 |
} else {
|
286 |
+
$return = (int) $row->term_id;
|
287 |
}
|
288 |
return ($return);
|
289 |
}
|
294 |
* @param $group_id
|
295 |
* @return Object|False Returns False when the group doesn't exists.
|
296 |
*/
|
297 |
+
function getGroup ($group_id)
|
298 |
{
|
299 |
global $wpdb;
|
300 |
|
301 |
+
$result = get_term((int) $group_id, $this->taxonomy_name);
|
302 |
+
if (null === $result) {
|
303 |
$result = false;
|
304 |
}
|
305 |
return ($result);
|
311 |
* @param $term
|
312 |
* @param array $args
|
313 |
*/
|
314 |
+
function doInsertGroup ($term, $args = array(), $widget_title = '')
|
315 |
{
|
316 |
+
$row = wp_insert_term($term, $this->taxonomy_name, $args);
|
317 |
+
$this->setWidgetTitleForGroup($term, $widget_title);
|
318 |
return ($row['term_id']);
|
319 |
}
|
320 |
|
323 |
*
|
324 |
* @param $group_id
|
325 |
*/
|
326 |
+
function doDeleteGroup ($group_id)
|
327 |
{
|
328 |
|
329 |
global $wpdb;
|
330 |
|
331 |
+
$group = $this->getGroup($group_id);
|
332 |
+
$result = $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d', $group_id));
|
333 |
+
$this->doDeleteWidgetTitle($group_id);
|
334 |
+
$return = wp_delete_term($group->term_id, $this->taxonomy_name);
|
335 |
|
336 |
return ($return);
|
337 |
}
|
345 |
*
|
346 |
* return -1,0,1 Unknown Group, Duplicate Slug, Succesfull
|
347 |
*/
|
348 |
+
function doUpdateGroup ($group_id, $args = array(), $selected_categories, $widget_title = '')
|
349 |
{
|
350 |
|
351 |
+
$group = $this->getGroup($group_id);
|
352 |
+
if (is_object($group)) {
|
353 |
+
$id = wp_update_term($group->term_id, $this->taxonomy_name, $args);
|
354 |
+
if (! is_wp_error($id)) {
|
355 |
+
$this->setWidgetTitleForGroup($group_id, $widget_title);
|
356 |
+
$this->setCategoriesForGroup($group_id, $selected_categories);
|
357 |
$return = 1; // Succesful
|
358 |
} else {
|
359 |
$return = 0; // Duplicate Slug
|
369 |
*
|
370 |
* @param $category_id
|
371 |
*/
|
372 |
+
function doDeleteCategoryFromGroup ($category_id)
|
373 |
{
|
374 |
global $wpdb;
|
375 |
+
$result = $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE term_id=%d', $category_id));
|
376 |
}
|
377 |
}
|
378 |
?>
|
2.8/class/avh-ec.core.php
CHANGED
@@ -8,6 +8,7 @@ class AVH_EC_Core
|
|
8 |
var $default_options;
|
9 |
var $default_options_general;
|
10 |
var $default_options_category_group;
|
|
|
11 |
|
12 |
var $options;
|
13 |
|
@@ -23,11 +24,28 @@ class AVH_EC_Core
|
|
23 |
*/
|
24 |
$catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
|
25 |
|
26 |
-
$this->version = '3.
|
27 |
$this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
|
28 |
-
$db_version = 2;
|
29 |
$this->db_options_core = 'avhec';
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
$info['siteurl'] = get_option( 'siteurl' );
|
32 |
$info['plugin_dir'] = AVHEC_PLUGIN_DIR;
|
33 |
$info['lang_dir'] = AVHEC_WORKING_DIR . '/lang';
|
@@ -45,7 +63,9 @@ class AVH_EC_Core
|
|
45 |
$default_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
|
46 |
$this->default_options_category_group = array ('no_group' => $no_group_id, 'home_group' => $home_group_id, 'default_group' => $default_group_id );
|
47 |
|
48 |
-
$this->
|
|
|
|
|
49 |
|
50 |
/**
|
51 |
* Set the options for the program
|
@@ -58,19 +78,7 @@ class AVH_EC_Core
|
|
58 |
$this->doUpdateOptions( $db_version );
|
59 |
}
|
60 |
|
61 |
-
$this->handleTextdomain();
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* PHP4 Constructor
|
66 |
-
*
|
67 |
-
* @return AVHExtendedCategoriesCore
|
68 |
-
*/
|
69 |
-
function AVH_EC_Core ()
|
70 |
-
{
|
71 |
-
$this->__construct();
|
72 |
}
|
73 |
-
|
74 |
/**
|
75 |
* Loads the i18n
|
76 |
*
|
@@ -309,7 +317,7 @@ class AVH_EC_Core
|
|
309 |
$output .= "\t" . '<option value="-1"' . $selected . '>' . $show_option_none . '</option>' . "\n";
|
310 |
}
|
311 |
|
312 |
-
if ( $hierarchical
|
313 |
$depth = $r['depth']; // Walk the full depth.
|
314 |
} else {
|
315 |
$depth = - 1; // Flat
|
8 |
var $default_options;
|
9 |
var $default_options_general;
|
10 |
var $default_options_category_group;
|
11 |
+
var $default_options_sp_category_group;
|
12 |
|
13 |
var $options;
|
14 |
|
24 |
*/
|
25 |
$catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
|
26 |
|
27 |
+
$this->version = '3.3';
|
28 |
$this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
|
|
|
29 |
$this->db_options_core = 'avhec';
|
30 |
|
31 |
+
$this->handleTextdomain();
|
32 |
+
add_action('init', array(&$this,'handleInitializePlugin'),10);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* PHP4 Constructor
|
37 |
+
*
|
38 |
+
* @return AVHExtendedCategoriesCore
|
39 |
+
*/
|
40 |
+
function AVH_EC_Core ()
|
41 |
+
{
|
42 |
+
$this->__construct();
|
43 |
+
}
|
44 |
+
|
45 |
+
function handleInitializePlugin() {
|
46 |
+
$catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
|
47 |
+
$db_version = 4;
|
48 |
+
|
49 |
$info['siteurl'] = get_option( 'siteurl' );
|
50 |
$info['plugin_dir'] = AVHEC_PLUGIN_DIR;
|
51 |
$info['lang_dir'] = AVHEC_WORKING_DIR . '/lang';
|
63 |
$default_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
|
64 |
$this->default_options_category_group = array ('no_group' => $no_group_id, 'home_group' => $home_group_id, 'default_group' => $default_group_id );
|
65 |
|
66 |
+
$this->default_options_sp_category_group = array('home_group' => $home_group_id,'category_group' => $default_group_id,'day_group'=>$default_group_id,'month_group'=>$default_group_id,'year_group'=>$default_group_id,'author_group'=>$default_group_id,'search_group'=>$default_group_id);
|
67 |
+
|
68 |
+
$this->default_options = array ('general' => $this->default_options_general, 'cat_group' => $this->default_options_category_group, 'widget_titles'=>array(),'sp_cat_group'=>$this->default_options_sp_category_group );
|
69 |
|
70 |
/**
|
71 |
* Set the options for the program
|
78 |
$this->doUpdateOptions( $db_version );
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
|
|
82 |
/**
|
83 |
* Loads the i18n
|
84 |
*
|
317 |
$output .= "\t" . '<option value="-1"' . $selected . '>' . $show_option_none . '</option>' . "\n";
|
318 |
}
|
319 |
|
320 |
+
if ( $hierarchical ) {
|
321 |
$depth = $r['depth']; // Walk the full depth.
|
322 |
} else {
|
323 |
$depth = - 1; // Flat
|
2.8/class/avh-ec.widgets.php
CHANGED
@@ -359,7 +359,6 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
|
|
359 |
*/
|
360 |
function widget ( $args, $instance )
|
361 |
{
|
362 |
-
|
363 |
extract( $args );
|
364 |
|
365 |
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories', 'avh-ec' ) : $instance['title'] );
|
@@ -512,7 +511,6 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
|
|
512 |
|
513 |
echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
|
514 |
}
|
515 |
-
|
516 |
}
|
517 |
|
518 |
/**
|
@@ -568,12 +566,37 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
568 |
$options = $this->core->getOptions();
|
569 |
|
570 |
$row = array ();
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
} else {
|
574 |
$terms = wp_get_object_terms( $post->ID, $catgrp->taxonomy_name );
|
575 |
if ( ! empty( $terms ) ) {
|
576 |
-
$
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
}
|
579 |
|
@@ -621,7 +644,6 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
621 |
|
622 |
$cat_args = array ('include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-group-' . $this->number );
|
623 |
echo $before_widget;
|
624 |
-
echo '<div id="avhec-categorygroup-' . $row->slug . '">';
|
625 |
echo $this->core->comment;
|
626 |
echo $before_title . $title . $after_title;
|
627 |
|
@@ -643,7 +665,6 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
643 |
echo '/* ]]> */' . "\n";
|
644 |
echo '</script>' . "\n";
|
645 |
}
|
646 |
-
echo '</div>';
|
647 |
echo $after_widget;
|
648 |
}
|
649 |
}
|
@@ -674,6 +695,11 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
674 |
$instance['style'] = strip_tags( stripslashes( $new_instance['style'] ) );
|
675 |
$instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
|
676 |
$instance['rssimage'] = strip_tags( stripslashes( $new_instance['rssimage'] ) );
|
|
|
|
|
|
|
|
|
|
|
677 |
return $instance;
|
678 |
}
|
679 |
|
@@ -703,6 +729,8 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
703 |
$rssfeed = ( bool ) $instance['rssfeed'];
|
704 |
$rssimage = esc_attr( $instance['rssimage'] );
|
705 |
|
|
|
|
|
706 |
echo '<p>';
|
707 |
avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
|
708 |
echo '</p>';
|
@@ -742,10 +770,74 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
|
|
742 |
avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
|
743 |
|
744 |
avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
745 |
echo '</p>';
|
746 |
|
747 |
echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
|
748 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
}
|
750 |
|
751 |
/**
|
359 |
*/
|
360 |
function widget ( $args, $instance )
|
361 |
{
|
|
|
362 |
extract( $args );
|
363 |
|
364 |
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories', 'avh-ec' ) : $instance['title'] );
|
511 |
|
512 |
echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
|
513 |
}
|
|
|
514 |
}
|
515 |
|
516 |
/**
|
566 |
$options = $this->core->getOptions();
|
567 |
|
568 |
$row = array ();
|
569 |
+
|
570 |
+
if (is_home () ) {
|
571 |
+
$special_page='home_group';
|
572 |
+
} elseif (is_category()) {
|
573 |
+
$special_page='category_group';
|
574 |
+
} elseif (is_day()) {
|
575 |
+
$special_page='day_group';
|
576 |
+
} elseif (is_month()) {
|
577 |
+
$special_page='month_group';
|
578 |
+
}elseif (is_year()) {
|
579 |
+
$special_page='year_group';
|
580 |
+
} elseif (is_author()) {
|
581 |
+
$special_page='author_group';
|
582 |
+
} elseif (is_search()) {
|
583 |
+
$special_page='search_group';
|
584 |
+
} else {
|
585 |
+
$special_page='none';
|
586 |
+
}
|
587 |
+
|
588 |
+
if ( $special_page != 'none' ) {
|
589 |
+
$sp_category_group = $options['sp_cat_group'][$special_page];
|
590 |
+
$row = get_term_by( 'id', $sp_category_group, $catgrp->taxonomy_name ); // Returns FALSE when non-existance. (empty(FALSE)=TRUE)
|
591 |
} else {
|
592 |
$terms = wp_get_object_terms( $post->ID, $catgrp->taxonomy_name );
|
593 |
if ( ! empty( $terms ) ) {
|
594 |
+
foreach ($terms as $key => $value){
|
595 |
+
if (!($this->getWidgetDoneCatGroup($value->term_id))) {
|
596 |
+
$row=$value;
|
597 |
+
break;
|
598 |
+
}
|
599 |
+
}
|
600 |
}
|
601 |
}
|
602 |
|
644 |
|
645 |
$cat_args = array ('include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-group-' . $this->number );
|
646 |
echo $before_widget;
|
|
|
647 |
echo $this->core->comment;
|
648 |
echo $before_title . $title . $after_title;
|
649 |
|
665 |
echo '/* ]]> */' . "\n";
|
666 |
echo '</script>' . "\n";
|
667 |
}
|
|
|
668 |
echo $after_widget;
|
669 |
}
|
670 |
}
|
695 |
$instance['style'] = strip_tags( stripslashes( $new_instance['style'] ) );
|
696 |
$instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
|
697 |
$instance['rssimage'] = strip_tags( stripslashes( $new_instance['rssimage'] ) );
|
698 |
+
if ( array_key_exists( 'all', $new_instance['post_group_category'] ) ) {
|
699 |
+
$instance['post_group_category'] = FALSE;
|
700 |
+
} else {
|
701 |
+
$instance['post_group_category'] = serialize( $new_instance['post_group_category'] );
|
702 |
+
}
|
703 |
return $instance;
|
704 |
}
|
705 |
|
729 |
$rssfeed = ( bool ) $instance['rssfeed'];
|
730 |
$rssimage = esc_attr( $instance['rssimage'] );
|
731 |
|
732 |
+
$selected_cats = ($instance['post_group_category'] != '') ? unserialize( $instance['post_group_category'] ) : FALSE;
|
733 |
+
|
734 |
echo '<p>';
|
735 |
avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
|
736 |
echo '</p>';
|
770 |
avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
|
771 |
|
772 |
avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
|
773 |
+
echo '</p>';
|
774 |
+
|
775 |
+
echo '<p>';
|
776 |
+
echo '<b>' . __( 'Select Groups', 'avh-ec' ) . '</b><hr />';
|
777 |
+
echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
|
778 |
+
echo '<li id="' . $this->get_field_id( 'group_category--1' ) . '" class="popular-group_category">';
|
779 |
+
echo '<label for="' . $this->get_field_id( 'group_post_category' ) . '" class="selectit">';
|
780 |
+
echo '<input value="all" id="' . $this->get_field_id( 'group_post_category' ) . '" name="' . $this->get_field_name( 'post_group_category' ) . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
|
781 |
+
_e( 'Any Group', 'avh-ec' );
|
782 |
+
echo '</label>';
|
783 |
+
echo '</li>';
|
784 |
+
ob_start();
|
785 |
+
$this->avh_wp_group_category_checklist($selected_cats,$this->number );
|
786 |
+
ob_end_flush();
|
787 |
+
echo '</ul>';
|
788 |
echo '</p>';
|
789 |
|
790 |
echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
|
791 |
}
|
792 |
+
|
793 |
+
function avh_wp_group_category_checklist ( $selected_cats, $number)
|
794 |
+
{
|
795 |
+
|
796 |
+
$walker = new AVH_Walker_Category_Checklist();
|
797 |
+
$walker->number = $number;
|
798 |
+
$walker->input_id = $this->get_field_id( 'post_group_category' );
|
799 |
+
$walker->input_name = $this->get_field_name( 'post_group_category' );
|
800 |
+
$walker->li_id = $this->get_field_id( 'group_category--1' );
|
801 |
+
|
802 |
+
$args = array ('taxonomy' => 'avhec_catgroup',
|
803 |
+
'descendants_and_self' => 0,
|
804 |
+
'selected_cats' => array(),
|
805 |
+
'popular_cats' => array(),
|
806 |
+
'walker' => $walker,
|
807 |
+
'checked_ontop' => true);
|
808 |
+
|
809 |
+
if ( is_array( $selected_cats ) )
|
810 |
+
$args['selected_cats'] = $selected_cats;
|
811 |
+
else
|
812 |
+
$args['selected_cats'] = array ();
|
813 |
+
|
814 |
+
$categories = (array) get_terms($args['taxonomy'], array('get' => 'all'));
|
815 |
+
|
816 |
+
// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
|
817 |
+
$checked_categories = array ();
|
818 |
+
$keys = array_keys( $categories );
|
819 |
+
|
820 |
+
foreach( $keys as $k ) {
|
821 |
+
if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
|
822 |
+
$checked_categories[] = $categories[$k];
|
823 |
+
unset( $categories[$k] );
|
824 |
+
}
|
825 |
+
}
|
826 |
+
|
827 |
+
// Put checked cats on top
|
828 |
+
echo call_user_func_array( array (&$walker, 'walk' ), array ($checked_categories, 0, $args ) );
|
829 |
+
// Then the rest of them
|
830 |
+
echo call_user_func_array( array (&$walker, 'walk' ), array ($categories, 0, $args ) );
|
831 |
+
}
|
832 |
+
|
833 |
+
function getWidgetDoneCatGroup($id) {
|
834 |
+
$catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
|
835 |
+
if (key_exists($id, $catgrp->widget_done_catgroup)) {
|
836 |
+
return TRUE;
|
837 |
+
}
|
838 |
+
$catgrp->widget_done_catgroup[$id]=TRUE;
|
839 |
+
return FALSE;
|
840 |
+
}
|
841 |
}
|
842 |
|
843 |
/**
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: petervanderdoes
|
|
3 |
Donate link: http://blog.avirtualhome.com/wordpress-plugins/
|
4 |
Tags: extended, categories, widget, top categories
|
5 |
Requires at least: 2.3
|
6 |
-
Tested up to: 3.0.
|
7 |
-
Stable tag: 3.
|
8 |
|
9 |
The AVH Extended Categories Widgets gives you three widgets for displaying categories.
|
10 |
== Description ==
|
@@ -53,7 +53,7 @@ The Category Group widget gives you the following customizable options:
|
|
53 |
|
54 |
You can set the following options for the Category Group Widget:
|
55 |
|
56 |
-
* Which group to show on the
|
57 |
* Which group to show when no group is associated with a post. Useful for older posts that don't have the association.
|
58 |
* Set the default group when editing or creating a post.
|
59 |
|
@@ -77,7 +77,7 @@ The AVH Extended Categories Widgets can be installed in 3 easy steps:
|
|
77 |
1. Go to the Presentation/Appearance->Widgets page and drag the widget into the sidebar of your choice. Configuration of the widget is done like all other widgets.
|
78 |
|
79 |
|
80 |
-
==
|
81 |
|
82 |
= What about support? =
|
83 |
I created a support site at http://forums.avirtualhome.com where you can ask questions or request features.
|
@@ -95,10 +95,48 @@ I'll keep a list of translators and their websites here in the readme.txt and on
|
|
95 |
|
96 |
I have also setup a project in Launchpad for translating the plug-in. Just visit http://bit.ly/95WyJ
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
== Screen shots ==
|
99 |
None
|
100 |
|
101 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
= Version 3.2.2 =
|
103 |
* Bugfix: Problem with Chrome and saving the category group.
|
104 |
* Bugfix: Extra metabox displayed. The plugin uses it's own metabox for Category Group selection.
|
3 |
Donate link: http://blog.avirtualhome.com/wordpress-plugins/
|
4 |
Tags: extended, categories, widget, top categories
|
5 |
Requires at least: 2.3
|
6 |
+
Tested up to: 3.0.5
|
7 |
+
Stable tag: 3.3
|
8 |
|
9 |
The AVH Extended Categories Widgets gives you three widgets for displaying categories.
|
10 |
== Description ==
|
53 |
|
54 |
You can set the following options for the Category Group Widget:
|
55 |
|
56 |
+
* Which group to show on the 'special' pages. The 'special' pages are: Home, Category archive, Tag archive, Daily/Monthly/Yearly archive, Author archive, Search results page.
|
57 |
* Which group to show when no group is associated with a post. Useful for older posts that don't have the association.
|
58 |
* Set the default group when editing or creating a post.
|
59 |
|
77 |
1. Go to the Presentation/Appearance->Widgets page and drag the widget into the sidebar of your choice. Configuration of the widget is done like all other widgets.
|
78 |
|
79 |
|
80 |
+
== Support ==
|
81 |
|
82 |
= What about support? =
|
83 |
I created a support site at http://forums.avirtualhome.com where you can ask questions or request features.
|
95 |
|
96 |
I have also setup a project in Launchpad for translating the plug-in. Just visit http://bit.ly/95WyJ
|
97 |
|
98 |
+
= Multiple Category Groups =
|
99 |
+
The following is an explanation how assigning multiple groups to page/post works.
|
100 |
+
|
101 |
+
Lets say you have the following groups:
|
102 |
+
Free Time
|
103 |
+
Theater
|
104 |
+
Movie
|
105 |
+
Music
|
106 |
+
|
107 |
+
Setup several Category Group widgets and associated each widget with one or more groups.
|
108 |
+
Widget 1 has association with Free Time
|
109 |
+
Widget 2 has association with Theater, Movie and Music
|
110 |
+
Widget 3 has association with Theater, Movie and Music
|
111 |
+
|
112 |
+
Page has associations the groups Free Time and Theater
|
113 |
+
* Widget 1: Shows categories of the Free Time group
|
114 |
+
* Widget 2 :Shows categories of the Theater group.
|
115 |
+
* Widget 3: Not displayed
|
116 |
+
|
117 |
+
Page has associations the group Movie.
|
118 |
+
* Widget 1: Not displayed
|
119 |
+
* Widget 2 :Shows categories of the Movie group.
|
120 |
+
* Widget 3: Not displayed
|
121 |
+
|
122 |
+
|
123 |
+
Page has associations the groups Free Time, Movie and Music
|
124 |
+
* Widget 1: Shows categories of the Free Time group
|
125 |
+
* Widget 2 :Shows categories of the Movie or Music group.
|
126 |
+
* Widget 3: Shows categories of the Music or Movie group.
|
127 |
+
Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie.
|
128 |
+
|
129 |
== Screen shots ==
|
130 |
None
|
131 |
|
132 |
== Changelog ==
|
133 |
+
= Version 3.3 =
|
134 |
+
* Ability to assign multiple Category Groups to a post/page.
|
135 |
+
* A Category Group can be assigned to 'special' pages. The 'special' pages are: Home, Category archive, Tag archive, Daily/Monthly/Yearly archive, Author archive, Search results page.
|
136 |
+
* Bugfix: When using SSL in the admin section save would redirect to non-SSL and not saving the options.
|
137 |
+
* Bugfix: Hierarchy in the dropdown with selected categories didn't work properly.
|
138 |
+
* Bugfix: The widget for the Groups was a different setup as the others breaking certain theme layouts.
|
139 |
+
|
140 |
= Version 3.2.2 =
|
141 |
* Bugfix: Problem with Chrome and saving the category group.
|
142 |
* Bugfix: Extra metabox displayed. The plugin uses it's own metabox for Category Group selection.
|
widget-pre2.8.php
CHANGED
@@ -7,7 +7,7 @@ function widget_extended_categories_init() {
|
|
7 |
}
|
8 |
|
9 |
function widget_extended_categories($args, $number = 1) {
|
10 |
-
$version = '3.
|
11 |
// Check for version
|
12 |
require (ABSPATH . WPINC . '/version.php');
|
13 |
if ( version_compare($wp_version, '2.5.1', '<') ) {
|
7 |
}
|
8 |
|
9 |
function widget_extended_categories($args, $number = 1) {
|
10 |
+
$version = '3.3';
|
11 |
// Check for version
|
12 |
require (ABSPATH . WPINC . '/version.php');
|
13 |
if ( version_compare($wp_version, '2.5.1', '<') ) {
|
widget_extended_categories.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: AVH Extended Categories Widgets
|
4 |
Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
|
5 |
Description: Replacement of the category widget to allow for greater customization of the category widget.
|
6 |
-
Version: 3.
|
7 |
Author: Peter van der Does
|
8 |
Author URI: http://blog.avirtualhome.com/
|
9 |
|
3 |
Plugin Name: AVH Extended Categories Widgets
|
4 |
Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
|
5 |
Description: Replacement of the category widget to allow for greater customization of the category widget.
|
6 |
+
Version: 3.3
|
7 |
Author: Peter van der Does
|
8 |
Author URI: http://blog.avirtualhome.com/
|
9 |
|