/**
     * 
     *
     * @param 
     * @return 
     * @version 1.0.1
     */
    private static function get_cat_checkbox_list($name, $id, $selected_cat_ids = [])
    {
        $cats = theme_cache::get_categories(array('hide_empty' => false));
        if ($cats) {
            foreach ($cats as $cat) {
                if (in_array($cat->term_id, (array) $selected_cat_ids)) {
                    $checked = ' checked="checked" ';
                    $selected_class = ' button-primary ';
                } else {
                    $checked = null;
                    $selected_class = null;
                }
                ?>
			<label for="<?php 
                echo $id;
                ?>
-<?php 
                echo $cat->term_id;
                ?>
" class="item button <?php 
                echo $selected_class;
                ?>
">
				<input 
					type="checkbox" 
					id="<?php 
                echo $id;
                ?>
-<?php 
                echo $cat->term_id;
                ?>
" 
					name="<?php 
                echo esc_attr($name);
                ?>
[]" 
					value="<?php 
                echo $cat->term_id;
                ?>
"
					<?php 
                echo $checked;
                ?>
				/>
					<?php 
                echo esc_html($cat->name);
                ?>
			</label>
			<?php 
            }
            unset($cats);
        } else {
            ?>
			<p><?php 
            echo ___('No category, pleass go to add some categories.');
            ?>
</p>
		<?php 
        }
    }
Пример #2
0
 public static function get_cats($array = false)
 {
     static $cache = null;
     if ($cache === null) {
         $cache = theme_cache::get_categories(['include' => self::get_cat_ids(), 'hide_empty' => false]);
     }
     if ($array) {
         $cats = [];
         foreach ($cache as $cat) {
             $cats[$cat->term_id] = ['term_id' => $cat->term_id, 'parent' => $cat->parent, 'name' => $cat->name, 'description' => $cat->description];
         }
         return $cats;
     }
     return $cache;
 }
Пример #3
0
    private static function cat_checkbox_tpl($placeholder)
    {
        $opt = self::get_options();
        $exists_cats = isset($opt[$placeholder]['cats']) ? (array) $opt[$placeholder]['cats'] : [];
        $cats = theme_cache::get_categories(array('hide_empty' => false));
        foreach ($cats as $cat) {
            $checked = !empty($exists_cats) && in_array($cat->term_id, $exists_cats) ? ' checked ' : null;
            ?>
			<label for="<?php 
            echo __CLASS__;
            ?>
-cats-<?php 
            echo $placeholder;
            ?>
-<?php 
            echo $cat->term_id;
            ?>
" class="button <?php 
            echo empty($checked) ? null : 'button-primary';
            ?>
">
				<input 
					type="checkbox" 
					name="<?php 
            echo __CLASS__;
            ?>
[<?php 
            echo $placeholder;
            ?>
][cats][]"
					id="<?php 
            echo __CLASS__;
            ?>
-cats-<?php 
            echo $placeholder;
            ?>
-<?php 
            echo $cat->term_id;
            ?>
"
					value="<?php 
            echo $cat->term_id;
            ?>
"
					<?php 
            echo $checked;
            ?>
				/>
				<?php 
            echo esc_html($cat->name);
            ?>
 - <a href="<?php 
            echo esc_url(get_category_link($cat->term_id));
            ?>
" target="<?php 
            echo theme_functions::$link_target;
            ?>
"><?php 
            echo urldecode($cat->slug);
            ?>
</a>
			</label>
			<?php 
        }
        unset($cats);
    }
Пример #4
0
    public static function display_backend()
    {
        $color_cats = (array) self::get_options();
        /** 
         * get all categories
         */
        $cats = theme_cache::get_categories(array('orderby' => 'id', 'hide_empty' => false));
        ?>
		<fieldset>
			<legend><i class="fa fa-fw fa-adjust"></i> <?php 
        echo ___('Colorful category');
        ?>
</legend>
			<p class="description">
				<?php 
        echo ___('You can select the category and set color for category. Preset is random color.');
        ?>
			</p>
			<table class="form-table">
				<tbody>
					<tr>
						<th scope="row">
							<?php 
        echo ___('Select category and select color to set');
        ?>
						</th>
						<td id="colorful-cats">
							<?php 
        if (!$cats) {
            echo status_tip('info', ___('Empty category.'));
        } else {
            wp_dropdown_categories(['show_option_none' => ___('Select category'), 'show_count' => 1, 'id' => __CLASS__ . '-cat-ids', 'name' => '', 'hierarchical' => 1]);
        }
        ?>
							<span id="<?php 
        echo __CLASS__;
        ?>
-preset-colors">
								<?php 
        self::the_preset_colors();
        ?>
							</span>
							
							<?php 
        self::hidden_inputs($cats);
        ?>
						</td>
					</tr>
				</tbody>
			</table>
		</fieldset>
	<?php 
    }