예제 #1
0
function themerex_media_view_compat($form_fields, $post = null)
{
    static $terms = null, $id = 0;
    if (isset($form_fields['media_folder'])) {
        $field = $form_fields['media_folder'];
        if (!$terms) {
            //$terms = get_terms('media_folder');
            $terms = getTermsByTaxonomy(array('media_folder'));
            $terms = getTermsHierarchicalList($terms, array('prefix_key' => 'media_folder.', 'prefix_level' => '-'));
        }
        $values = array_map('trim', explode(',', $field['value']));
        $readonly = '';
        //! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : '';
        $required = !empty($field['required']) ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : '';
        $aria_required = !empty($field['required']) ? " aria-required='true' " : '';
        $html = '';
        if (count($terms) > 0) {
            foreach ($terms as $slug => $name) {
                $id++;
                $slug = themerex_substr($slug, 13);
                $html .= ($html ? '<br />' : '') . '<input type="checkbox" class="text" id="media_folder_' . $id . '" name="media_folder_' . esc_attr($slug) . '" value="' . esc_attr($slug) . '"' . (in_array($slug, $values) ? ' checked="checked"' : '') . ' ' . $readonly . ' ' . $aria_required . ' /><label for="media_folder_' . $id . '"> ' . $name . '</label>';
            }
        }
        $form_fields['media_folder']['input'] = 'media_folder_input';
        $form_fields['media_folder']['media_folder_input'] = '<div class="media_folder_selector">' . $html . '</div>';
    }
    return $form_fields;
}
예제 #2
0
 function getTermsFilters($taxes)
 {
     $output = '';
     foreach ($taxes as $tax) {
         $list = get_transient("themerex_terms_filter_" . $tax);
         if (!$list) {
             $list = '';
             $tax_obj = get_taxonomy($tax);
             $terms = getTermsHierarchicalList(getTermsByTaxonomy(array($tax)));
             if (count($terms) > 0) {
                 $tax_slug = str_replace(array('post_tag'), array('tag'), $tax);
                 $list .= "<select name='{$tax_slug}' id='{$tax_slug}' class='postform'>" . "<option value=''>" . $tax_obj->labels->all_items . "</option>";
                 foreach ($terms as $slug => $name) {
                     $list .= '<option value=' . $slug . (isset($_REQUEST[$tax_slug]) && $_REQUEST[$tax_slug] == $slug || isset($_REQUEST['taxonomy']) && $_REQUEST['taxonomy'] == $tax_slug && isset($_REQUEST['term']) && $_REQUEST['term'] == $slug ? ' selected="selected"' : '') . '>' . $name . '</option>';
                 }
                 $list .= "</select>";
             }
         }
         set_transient("themerex_terms_filter_" . $tax, $list, 0);
         $output .= $list;
     }
     return $output;
 }