This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
forked from gambitph/Titan-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-option-multicheck-categories.php
64 lines (53 loc) · 1.86 KB
/
class-option-multicheck-categories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class TitanFrameworkOptionMulticheckCategories extends TitanFrameworkOptionMulticheck {
public $defaultSecondarySettings = array(
'options' => array(),
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => 'category',
'hide_empty' => false,
'show_count' => false,
);
/*
* Display for options and meta
*/
public function display() {
$args = array(
'orderby' => $this->settings['orderby'],
'order' => $this->settings['order'],
'taxonomy' => $this->settings['taxonomy'],
'hide_empty' => $this->settings['hide_empty'] ? '1' : '0',
);
$categories = get_categories( $args );
$this->settings['options'] = array();
foreach ( $categories as $category ) {
$this->settings['options'][$category->term_id] = $category->name . ( $this->settings['show_count'] ? " (" . $category->count . ")" : '' );
}
parent::display();
}
/*
* Display for theme customizer
*/
public function registerCustomizerControl( $wp_customize, $section, $priority = 1 ) {
$args = array(
'orderby' => $this->settings['orderby'],
'order' => $this->settings['order'],
'taxonomy' => $this->settings['taxonomy'],
'hide_empty' => $this->settings['hide_empty'] ? '1' : '0',
);
$categories = get_categories( $args );
$this->settings['options'] = array();
foreach ( $categories as $category ) {
$this->settings['options'][$category->term_id] = $category->name . ( $this->settings['show_count'] ? " (" . $category->count . ")" : '' );
}
$wp_customize->add_control( new TitanFrameworkOptionMulticheckControl( $wp_customize, $this->getID(), array(
'label' => $this->settings['name'],
'section' => $section->settings['id'],
'settings' => $this->getID(),
'description' => $this->settings['desc'],
'options' => $this->settings['options'],
'priority' => $priority,
) ) );
}
}