/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } if (!class_exists('WP_Job_Manager_Job_Tags')) { return; } global $job_manager, $post; extract($args); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $icon = isset($instance['icon']) ? $instance['icon'] : null; if ($icon) { $before_title = sprintf($before_title, 'ion-' . $icon); } ob_start(); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } wp_terms_checklist($post->ID, array('taxonomy' => 'job_listing_tag', 'checked_ontop' => false, 'walker' => new Listify_Walker_Tags_Checklist())); echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }
function conditional_widgets_term_checkboxes($tax, $type, $selected = array()) { echo "<ul class='conditional-widget-selection-list'>"; $args = array('selected_cats' => $selected, 'checked_ontop' => false, 'taxonomy' => $tax, 'walker' => new Conditional_Widget_Walker_Category_Checklist($type, $tax)); wp_terms_checklist(0, $args); echo "</ul>"; }
static function add_attachment_fields_to_edit($form_fields, $post) { $terms = get_object_term_cache($post->ID, self::TAXONOMY); $field = array(); $taxonomy_obj = (array) get_taxonomy(self::TAXONOMY); if (!$taxonomy_obj['public'] || !$taxonomy_obj['show_ui']) { continue; } if (false === $terms) { $terms = wp_get_object_terms($post->ID, self::TAXONOMY); } $values = wp_list_pluck($terms, 'term_id'); ob_start(); wp_terms_checklist($post->ID, array('taxonomy' => self::TAXONOMY, 'checked_ontop' => false, 'walker' => new Walker_WP_Media_Taxonomy_Checklist($post->ID))); $output = ob_get_clean(); if (!empty($output)) { $output = '<ul class="term-list">' . $output . '</ul>'; $output .= wp_nonce_field('save_attachment_media_categories', 'media_category_nonce', false, false); } else { $output = '<ul class="term-list"><li>No ' . $taxonomy_obj['label'] . '</li></ul>'; } $field = array('label' => !empty($taxonomy_obj['label']) ? $taxonomy_obj['label'] : self::TAXONOMY, 'value' => join(', ', $values), 'show_in_edit' => false, 'input' => 'html', 'html' => $output); $form_fields[self::TAXONOMY] = $field; return $form_fields; }
function my_edit_user_profession_section($user) { if (!current_user_can('manage_options')) { return; } $privs = get_user_meta($user->ID, 'user_privelages', true); $args = array('taxonomy' => 'pages', 'selected_cats' => $privs, 'checked_ontop' => false); wp_terms_checklist($user->ID, $args); }
/** * Output an unordered list of checkbox <input> elements labelled * with category names. * * @see wp_terms_checklist() * @since 2.5.1 * * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array. * @param int $descendants_and_self ID of the category to output along with its descendents. * @param bool|array $selected_cats List of categories to mark as checked. * @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class. * @param object $walker Walker object to use to build the output. * @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list. */ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) { wp_terms_checklist( $post_id, array( 'taxonomy' => 'category', 'descendants_and_self' => $descendants_and_self, 'selected_cats' => $selected_cats, 'popular_cats' => $popular_cats, 'walker' => $walker, 'checked_ontop' => $checked_ontop ) ); }
/** * Add new variation set via AJAX. * * If the variation set name is the same as an existing variation set, * the children variant terms will be added inside that existing set. * @since 3.8.8 */ function wpsc_add_variation_set() { $new_variation_set = $_POST['variation_set']; $variants = preg_split('/\\s*,\\s*/', $_POST['variants']); $parent_term_exists = term_exists($new_variation_set, 'wpsc-variation'); // only use an existing parent ID if the term is not a child term if ($parent_term_exists) { $parent_term = get_term($parent_term_exists['term_id'], 'wpsc-variation'); if ($parent_term->parent == '0') { $variation_set_id = $parent_term_exists['term_id']; } } if (empty($variation_set_id)) { $results = wp_insert_term($new_variation_set, 'wpsc-variation'); if (is_wp_error($results)) { die('-1'); } $variation_set_id = $results['term_id']; } $inserted_variants = array(); if (!empty($variation_set_id)) { foreach ($variants as $variant) { $results = wp_insert_term($variant, 'wpsc-variation', array('parent' => $variation_set_id)); if (is_wp_error($results)) { die('-1'); } $inserted_variants[] = $results['term_id']; } require_once 'includes/walker-variation-checklist.php'; /* --- DIRTY HACK START --- */ /* There's a bug with term cache in WordPress core. See http://core.trac.wordpress.org/ticket/14485. The next 3 lines will delete children term cache for wpsc-variation. Without this hack, the new child variations won't be displayed on "Variations" page and also won't be displayed in wp_terms_checklist() call below. */ clean_term_cache($variation_set_id, 'wpsc-variation'); delete_option('wpsc-variation_children'); wp_cache_set('last_changed', 1, 'terms'); _get_term_hierarchy('wpsc-variation'); /* --- DIRTY HACK END --- */ wp_terms_checklist((int) $_POST['post_id'], array('taxonomy' => 'wpsc-variation', 'descendants_and_self' => $variation_set_id, 'walker' => new WPSC_Walker_Variation_Checklist($inserted_variants), 'checked_ontop' => false)); } exit; }
public static function metabox($post, $box) { if (!isset($box['args']) || !is_array($box['args'])) { $args = []; } else { $args = $box['args']; } extract(wp_parse_args($args), EXTR_SKIP); $tax_name = $taxonomy; $taxonomy = get_taxonomy($taxonomy); $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : ''; printf('<select name="tax_input[%s]" %s>', esc_attr($tax_name), $disabled); if (!isset($taxonomy->required) || !$taxonomy->required) { printf('<option value="">(%s)</option>', sprintf(__('no %s'), $taxonomy->labels->singular_name)); } wp_terms_checklist($post->ID, ['taxonomy' => $taxonomy->name, 'walker' => new Walker_Taxonomy_Select()]); echo '</select>'; }
/** * Display portfolio showcase settings meta box * * @since 1.0.0 * * @param object $post * * @return void */ public function showcase_meta_box($post) { $cats = get_post_meta($post->ID, '_portfolio_showcase_cat', true); $limit = get_post_meta($post->ID, '_portfolio_showcase_limit', true); $layout = get_post_meta($post->ID, '_portfolio_showcase_layout', true); $gutter = get_post_meta($post->ID, '_portfolio_showcase_gutter', true); $pagination = get_post_meta($post->ID, '_portfolio_showcase_pagination', true); $filter = get_post_meta($post->ID, '_portfolio_showcase_filter', true); $filter = $filter ? $filter : 'yes'; wp_nonce_field('ta_portfolio_showcase_' . $post->ID, '_tanonce'); ?> <table class="form-table"> <tr> <th scope="row"><?php _e('Category to display', 'ta-portfolio'); ?> </th> <td> <ul id="portfolio-category-checklist" class="categorychecklist"> <?php wp_terms_checklist(0, array('selected_cats' => $cats, 'taxonomy' => 'portfolio_category', 'checked_ontop' => false)); ?> </ul> </td> </tr> <tr> <th scope="row"><label for="portfolio-limit"><?php _e('Number of portfolio', 'ta-portfolio'); ?> </th> <td> <input type="number" name="_portfolio_showcase_limit" value="<?php echo $limit ? $limit : 8; ?> " id="portfolio-limit" size="3"> <p class="description"> <?php _e('With Metro layout, the value for the best view is 5, 6, 8 or a multiple of 8, eg: 8, 16, 24...', 'ta-portfolio'); ?> </p> </td> </tr> <tr> <th scope="row"><label for="portfolio-layout"><?php _e('Showcase Layout', 'ta-portfolio'); ?> </th> <td> <select name="_portfolio_showcase_layout" id="portfolio-layout"> <option value="fitRows" <?php selected('fitRows', $layout); ?> ><?php _e('Grid', 'ta-portfolio'); ?> </option> <option value="masonry" <?php selected('masonry', $layout); ?> ><?php _e('Masonry', 'ta-portfolio'); ?> </option> <option value="metro" <?php selected('metro', $layout); ?> ><?php _e('Metro', 'ta-portfolio'); ?> </option> </select> </td> </tr> <tr> <th scope="row"><label for="portfolio-gutter"><?php _e('Spacing', 'ta-portfolio'); ?> </th> <td> <input type="number" name="_portfolio_showcase_gutter" value="<?php echo $gutter ? $gutter : 0; ?> " id="portfolio-gutter" size="3"> px <p class="description"> <?php _e('This is spacing between portfolios', 'ta-portfolio'); ?> </p> </td> </tr> <tr> <th scope="row"><label for="portfolio-filter"><?php _e('Enable Filter', 'ta-portfolio'); ?> </th> <td> <input type="checkbox" name="_portfolio_showcase_filter" value="yes" <?php checked('yes', $filter); ?> id="portfolio-filter"> <p class="description"> <?php _e('Enable this feature to show the filter by category on top of portfolio showcase', 'ta-portfolio'); ?> </p> </td> </tr> <tr> <th scope="row"><label for="portfolio-pagination"><?php _e('Enable Pagination', 'ta-portfolio'); ?> </th> <td> <input type="checkbox" name="_portfolio_showcase_pagination" value="yes" <?php checked('yes', $pagination); ?> id="portfolio-pagination"> <p class="description"> <?php _e('Enable this feature to show the pagination at the bottom of portfolio showcase', 'ta-portfolio'); ?> </p> </td> </tr> <?php do_action('ta_portfolio_showcase_fields', $post); ?> </table> <?php }
?> </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)) { ?> <p><em><?php _e('You cannot modify this Taxonomy.'); ?> </em></p> <?php } ?> <?php
/** * Outputs the hidden row displayed when inline editing * * @since 3.1.0 */ function inline_edit() { global $mode; $screen = get_current_screen(); $post = get_default_post_to_edit($screen->post_type); $post_type_object = get_post_type_object($screen->post_type); $taxonomy_names = get_object_taxonomies($screen->post_type); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (!$taxonomy->show_ui) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } $m = isset($mode) && 'excerpt' == $mode ? 'excerpt' : 'list'; $can_publish = current_user_can($post_type_object->cap->publish_posts); $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); ?> <form method="get" action=""><table style="display: none"><tbody id="inlineedit"> <?php $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; $bulk = 0; while ($bulk < 2) { ?> <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?> " class="inline-edit-row inline-edit-row-<?php echo "{$hclass} inline-edit-{$screen->post_type} "; echo $bulk ? "bulk-edit-row bulk-edit-row-{$hclass} bulk-edit-{$screen->post_type}" : "quick-edit-row quick-edit-row-{$hclass} inline-edit-{$screen->post_type}"; ?> " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?> " class="colspanchange"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <h4><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?> </h4> <?php if (post_type_supports($screen->post_type, 'title')) { if ($bulk) { ?> <div id="bulk-title-div"> <div id="bulk-titles"></div> </div> <?php } else { // $bulk ?> <label> <span class="title"><?php _e('Title'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> </label> <label> <span class="title"><?php _e('Slug'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> </label> <?php } // $bulk } // post_type_supports title ?> <?php if (!$bulk) { ?> <label><span class="title"><?php _e('Date'); ?> </span></label> <div class="inline-edit-date"> <?php touch_time(1, 1, 4, 1); ?> </div> <br class="clear" /> <?php } // $bulk if (post_type_supports($screen->post_type, 'author')) { $authors_dropdown = ''; if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) { $users_opt = array('hide_if_only_one_author' => false, 'who' => 'authors', 'name' => 'post_author', 'class' => 'authors', 'multi' => 1, 'echo' => 0); if ($bulk) { $users_opt['show_option_none'] = __('— No Change —'); } if ($authors = wp_dropdown_users($users_opt)) { $authors_dropdown = '<label class="inline-edit-author">'; $authors_dropdown .= '<span class="title">' . __('Author') . '</span>'; $authors_dropdown .= $authors; $authors_dropdown .= '</label>'; } } // authors ?> <?php if (!$bulk) { echo $authors_dropdown; } } // post_type_supports author if (!$bulk) { ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e('Password'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> </label> <em style="margin:5px 10px 0 0" class="alignleft"> <?php /* translators: Between password field and private checkbox on post quick edit interface */ echo __('–OR–'); ?> </em> <label class="alignleft inline-edit-private"> <input type="checkbox" name="keep_private" value="private" /> <span class="checkbox-title"><?php echo __('Private'); ?> </span> </label> </div> <?php } ?> </div></fieldset> <?php if (count($hierarchical_taxonomies) && !$bulk) { ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <?php foreach ($hierarchical_taxonomies as $taxonomy) { ?> <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?> <span class="catshow"><?php _e('[more]'); ?> </span> <span class="cathide" style="display:none;"><?php _e('[less]'); ?> </span> </span> <input type="hidden" name="<?php echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?> " value="0" /> <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)); ?> </ul> <?php } //$hierarchical_taxonomies as $taxonomy ?> </div></fieldset> <?php } // count( $hierarchical_taxonomies ) && !$bulk ?> <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <?php if (post_type_supports($screen->post_type, 'author') && $bulk) { echo $authors_dropdown; } if (post_type_supports($screen->post_type, 'page-attributes')) { if ($post_type_object->hierarchical) { ?> <label> <span class="title"><?php _e('Parent'); ?> </span> <?php $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column' => 'menu_order, post_title'); if ($bulk) { $dropdown_args['show_option_no_change'] = __('— No Change —'); } $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); wp_dropdown_pages($dropdown_args); ?> </label> <?php } // hierarchical if (!$bulk) { ?> <label> <span class="title"><?php _e('Order'); ?> </span> <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?> " /></span> </label> <?php } // !$bulk if ('page' == $screen->post_type) { ?> <label> <span class="title"><?php _e('Template'); ?> </span> <select name="page_template"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <option value="default"><?php _e('Default Template'); ?> </option> <?php page_template_dropdown(); ?> </select> </label> <?php } // page post_type } // page-attributes ?> <?php if (count($flat_taxonomies) && !$bulk) { ?> <?php foreach ($flat_taxonomies as $taxonomy) { ?> <?php if (current_user_can($taxonomy->cap->assign_terms)) { ?> <label class="inline-edit-tags"> <span class="title"><?php echo esc_html($taxonomy->labels->name); ?> </span> <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name); ?> ]" class="tax_input_<?php echo esc_attr($taxonomy->name); ?> "></textarea> </label> <?php } ?> <?php } //$flat_taxonomies as $taxonomy ?> <?php } // count( $flat_taxonomies ) && !$bulk ?> <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) { if ($bulk) { ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <span class="title"><?php _e('Comments'); ?> </span> <select name="comment_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignright"> <span class="title"><?php _e('Pings'); ?> </span> <select name="ping_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } ?> </div> <?php } else { // $bulk ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <input type="checkbox" name="comment_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Comments'); ?> </span> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignleft"> <input type="checkbox" name="ping_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Pings'); ?> </span> </label> <?php } ?> </div> <?php } // $bulk } // post_type_supports comments or pings ?> <div class="inline-edit-group"> <label class="inline-edit-status alignleft"> <span class="title"><?php _e('Status'); ?> </span> <select name="_status"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php if ($can_publish) { // Contributors only get "Unpublished" and "Pending Review" ?> <option value="publish"><?php _e('Published'); ?> </option> <option value="future"><?php _e('Scheduled'); ?> </option> <?php if ($bulk) { ?> <option value="private"><?php _e('Private'); ?> </option> <?php } // $bulk ?> <?php } ?> <option value="pending"><?php _e('Pending Review'); ?> </option> <option value="draft"><?php _e('Draft'); ?> </option> </select> </label> <?php if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) { ?> <?php if ($bulk) { ?> <label class="alignright"> <span class="title"><?php _e('Sticky'); ?> </span> <select name="sticky"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="sticky"><?php _e('Sticky'); ?> </option> <option value="unsticky"><?php _e('Not Sticky'); ?> </option> </select> </label> <?php } else { // $bulk ?> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"><?php _e('Make this post sticky'); ?> </span> </label> <?php } // $bulk ?> <?php } // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?> </div> <?php if (post_type_supports($screen->post_type, 'post-formats') && current_theme_supports('post-formats')) { $post_formats = get_theme_support('post-formats'); if (isset($post_formats[0]) && is_array($post_formats[0])) { $all_post_formats = get_post_format_strings(); ?> <div class="inline-edit-group"> <label class="alignleft" for="post_format"> <span class="title"><?php _e('Post Format'); ?> </span> <select name="post_format"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } ?> <option value="0"><?php _ex('Standard', 'Post format'); ?> </option> <?php foreach ($all_post_formats as $slug => $format) { if ($slug != 'standard') { ?> <option value="<?php echo esc_attr($slug); ?> "<?php if (!in_array($slug, $post_formats[0])) { echo ' class="unsupported"'; } ?> ><?php echo esc_html($format); ?> </option> <?php } } ?> </select></label> </div> <?php } ?> <?php } // post-formats ?> </div></fieldset> <?php list($columns) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { if (isset($core_columns[$column_name])) { continue; } do_action($bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type); } ?> <p class="submit inline-edit-save"> <a accesskey="c" href="#inline-edit" title="<?php esc_attr_e('Cancel'); ?> " class="button-secondary cancel alignleft"><?php _e('Cancel'); ?> </a> <?php if (!$bulk) { wp_nonce_field('inlineeditnonce', '_inline_edit', false); $update_text = __('Update'); ?> <a accesskey="s" href="#inline-edit" title="<?php esc_attr_e('Update'); ?> " class="button-primary save alignright"><?php echo esc_attr($update_text); ?> </a> <img class="waiting" style="display:none;" src="<?php echo esc_url(admin_url('images/wpspin_light.gif')); ?> " alt="" /> <?php } else { submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false, array('accesskey' => 's')); } ?> <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?> " /> <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?> " /> <span class="error" style="display:none"></span> <br class="clear" /> </p> </td></tr> <?php $bulk++; } ?> </tbody></table></form> <?php }
/** * Displays checklist of a taxonomy * * @since 0.8 * @param int $post_id * @param array $selected_cats */ function wpuf_category_checklist($post_id = 0, $selected_cats = false, $tax = 'category') { require_once ABSPATH . '/wp-admin/includes/template.php'; $walker = new WPUF_Walker_Category_Checklist(); echo '<ul class="wpuf-category-checklist">'; wp_terms_checklist($post_id, array('taxonomy' => $tax, 'descendants_and_self' => 0, 'selected_cats' => $selected_cats, 'popular_cats' => false, 'walker' => $walker, 'checked_ontop' => false)); echo '</ul>'; }
/** * Display post categories form fields. * * @since 2.6.0 * * @todo Create taxonomy-agnostic wrapper for this. * * @param WP_Post $post Post object. * @param array $box { * Categories meta box arguments. * * @type string $id Meta box ID. * @type string $title Meta box title. * @type callable $callback Meta box display callback. * @type array $args { * Extra meta box arguments. * * @type string $taxonomy Taxonomy. Default 'category'. * } * } */ function 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 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"> <a id="<?php echo $tax_name; ?> -add-toggle" href="#<?php echo $tax_name; ?> -add" class="hide-if-no-js taxonomy-add-new"> <?php /* translators: %s: add new taxonomy label */ printf(__('+ %s'), $taxonomy->labels->add_new_item); ?> </a> <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 $parent_dropdown_args = array('taxonomy' => $tax_name, 'hide_empty' => 0, 'name' => 'new' . $tax_name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —'); /** * Filter the arguments for the taxonomy parent dropdown on the Post Edit page. * * @since 4.4.0 * * @param array $parent_dropdown_args { * Optional. Array of arguments to generate parent dropdown. * * @type string $taxonomy Name of the taxonomy to retrieve. * @type bool $hide_if_empty True to skip generating markup if no * categories are found. Default 0. * @type string $name Value for the 'name' attribute * of the select element. * Default "new{$tax_name}_parent". * @type string $orderby Which column to use for ordering * terms. Default 'name'. * @type bool|int $hierarchical Whether to traverse the taxonomy * hierarchy. Default 1. * @type string $show_option_none Text to display for the "none" option. * Default "— {$parent} —", * where `$parent` is 'parent_item' * taxonomy label. * } */ $parent_dropdown_args = apply_filters('post_edit_category_parent_dropdown_args', $parent_dropdown_args); wp_dropdown_categories($parent_dropdown_args); ?> <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 }
/** * Display post categories form fields. * * @since 2.6.0 * * @param object $post */ function 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"><?php echo $tax->labels->all_items; ?> </a></li> <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?> -pop"><?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($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"> <?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); ?> " 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 . ' —')); ?> <input type="button" id="<?php echo $taxonomy; ?> -add-submit" class="add:<?php echo $taxonomy; ?> checklist:<?php echo $taxonomy; ?> -add button category-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 $taxonomy; ?> -ajax-response"></span> </p> </div> <?php } ?> </div> <?php }
/** * Display a meta box on the post editing screen. * * @param object $post The post object * @param object $walker An optional term walker * @param bool $show_none Whether to include a 'none' item in the term list * @param string $type The taxonomy list type (checklist or dropdown) * @return null */ function do_meta_box(WP_Post $post, Walker $walker = null, $show_none = false, $type = 'checklist') { $taxonomy = $this->taxo->taxonomy; $tax = get_taxonomy($taxonomy); $selected = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids')); if ($show_none) { if (isset($tax->labels->no_item)) { $none = $tax->labels->no_item; } else { $none = __('Not Specified', 'ext_taxos'); } } else { $none = ''; } ?> <div id="taxonomy-<?php echo $taxonomy; ?> " class="categorydiv"> <?php switch ($type) { case 'dropdown': wp_dropdown_categories(array('show_option_none' => $none, 'hide_empty' => false, 'hierarchical' => true, 'show_count' => false, 'orderby' => 'name', 'selected' => $selected, 'id' => "{$taxonomy}dropdown", 'name' => "tax_input[{$taxonomy}]", 'taxonomy' => $taxonomy, 'walker' => $walker)); break; case 'checklist': default: ?> <style type="text/css"> /* Style for the 'none' item: */ #<?php echo $taxonomy; ?> -0 { color: #888; border-top: 1px solid #eee; margin-top: 5px; } </style> <input type="hidden" name="tax_input[<?php echo $taxonomy; ?> ][]" value="0" /> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php # Standard WP Walker_Category_Checklist does not cut it if (empty($walker) or !is_a($walker, 'Walker')) { $walker = new Walker_ExtendedTaxonomyCheckboxes(); } # Output the terms: wp_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $selected, 'checked_ontop' => $this->args['checked_ontop'])); # Output the 'none' item: if ($show_none) { $output = ''; $o = (object) array('term_id' => 0, 'name' => $none, 'slug' => 'none'); if (empty($selected)) { $_selected = array(0); } else { $_selected = $selected; } $args = array('taxonomy' => $taxonomy, 'selected_cats' => $_selected, 'disabled' => false); $walker->start_el($output, $o, 1, $args); $walker->end_el($output, $o, 1, $args); echo $output; } ?> </ul> <?php break; } ?> </div> <?php }
/** * Echoes bulk edit area HTML to the Media/Add New screen * * Fires on the post upload UI screen; legacy (pre-3.5.0) upload interface. * Anything echoed here goes below the "Maximum upload file size" message * and above the id="media-items" div. * * @since 2.02 * */ public static function mla_post_upload_ui() { /* * Only add our form to the Media/Add New screen. In particular, * do NOT add it to the Media Manager Modal Window */ if (function_exists('get_current_screen')) { $screen = get_current_screen(); } else { $screen = NULL; } if (is_object($screen) && ('add' != $screen->action || 'media' != $screen->base)) { return; } $taxonomies = get_object_taxonomies('attachment', 'objects'); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomies as $tax_name => $tax_object) { if ($tax_object->hierarchical && $tax_object->show_ui && MLACore::mla_taxonomy_support($tax_name, 'quick-edit')) { $hierarchical_taxonomies[$tax_name] = $tax_object; } elseif ($tax_object->show_ui && MLACore::mla_taxonomy_support($tax_name, 'quick-edit')) { $flat_taxonomies[$tax_name] = $tax_object; } } $page_template_array = MLACore::mla_load_template('mla-add-new-bulk-edit.tpl'); if (!is_array($page_template_array)) { /* translators: 1: ERROR tag 2: function name 3: non-array value */ error_log(sprintf(_x('%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'MLAEdit::mla_post_upload_ui', var_export($page_template_array, true)), 0); return; } /* * The left-hand column contains the hierarchical taxonomies, * e.g., Attachment Category */ $category_fieldset = ''; if (count($hierarchical_taxonomies)) { $bulk_category_blocks = ''; foreach ($hierarchical_taxonomies as $tax_name => $tax_object) { if (current_user_can($tax_object->cap->assign_terms)) { ob_start(); wp_terms_checklist(NULL, array('taxonomy' => $tax_name)); $tax_checklist = ob_get_contents(); ob_end_clean(); $page_values = array('tax_html' => esc_html($tax_object->labels->name), 'more' => __('more', 'media-library-assistant'), 'less' => __('less', 'media-library-assistant'), 'tax_attr' => esc_attr($tax_name), 'tax_checklist' => $tax_checklist, 'Add' => __('Add', 'media-library-assistant'), 'Remove' => __('Remove', 'media-library-assistant'), 'Replace' => __('Replace', 'media-library-assistant')); $category_block = MLAData::mla_parse_template($page_template_array['category_block'], $page_values); $taxonomy_options = MLAData::mla_parse_template($page_template_array['taxonomy_options'], $page_values); $bulk_category_blocks .= $category_block . $taxonomy_options; } // current_user_can } // foreach $hierarchical_taxonomies $page_values = array('category_blocks' => $bulk_category_blocks); $category_fieldset = MLAData::mla_parse_template($page_template_array['category_fieldset'], $page_values); } // count( $hierarchical_taxonomies ) /* * The middle column contains the flat taxonomies, * e.g., Attachment Tag */ $tag_fieldset = ''; if (count($flat_taxonomies)) { $bulk_tag_blocks = ''; foreach ($flat_taxonomies as $tax_name => $tax_object) { if (current_user_can($tax_object->cap->assign_terms)) { $page_values = array('tax_html' => esc_html($tax_object->labels->name), 'tax_attr' => esc_attr($tax_name), 'Add' => __('Add', 'media-library-assistant'), 'Remove' => __('Remove', 'media-library-assistant'), 'Replace' => __('Replace', 'media-library-assistant')); $tag_block = MLAData::mla_parse_template($page_template_array['tag_block'], $page_values); $taxonomy_options = MLAData::mla_parse_template($page_template_array['taxonomy_options'], $page_values); $bulk_tag_blocks .= $tag_block . $taxonomy_options; } // current_user_can } // foreach $flat_taxonomies $page_values = array('tag_blocks' => $bulk_tag_blocks); $tag_fieldset = MLAData::mla_parse_template($page_template_array['tag_fieldset'], $page_values); } // count( $flat_taxonomies ) /* * The right-hand column contains the standard and custom fields */ if ($authors = MLA::mla_authors_dropdown(-1)) { $authors_dropdown = ' <label class="inline-edit-author alignright">' . "\n"; $authors_dropdown .= ' <span class="title">' . __('Author', 'media-library-assistant') . '</span>' . "\n"; $authors_dropdown .= $authors . "\n"; $authors_dropdown .= ' </label>' . "\n"; } else { $authors_dropdown = ''; } $custom_fields = ''; foreach (MLACore::mla_custom_field_support('bulk_edit') as $slug => $details) { $page_values = array('slug' => $slug, 'label' => esc_attr($details['name'])); $custom_fields .= MLAData::mla_parse_template($page_template_array['custom_field'], $page_values); } $set_parent_form = MLA::mla_set_parent_form(false); $page_values = array('NOTE' => __('IMPORTANT: Make your entries BEFORE uploading new items. Pull down the Help menu for more information.', 'media-library-assistant'), 'Toggle' => __('Open Bulk Edit area', 'media-library-assistant'), 'Reset' => __('Reset', 'media-library-assistant'), 'category_fieldset' => $category_fieldset, 'tag_fieldset' => $tag_fieldset, 'authors' => $authors_dropdown, 'Comments' => __('Comments', 'media-library-assistant'), 'Pings' => __('Pings', 'media-library-assistant'), 'No Change' => __('No Change', 'media-library-assistant'), 'Allow' => __('Allow', 'media-library-assistant'), 'Do not allow' => __('Do not allow', 'media-library-assistant'), 'custom_fields' => $custom_fields, 'Title' => __('Title', 'media-library-assistant'), 'Name/Slug' => __('Name/Slug', 'media-library-assistant'), 'Caption' => __('Caption', 'media-library-assistant'), 'Description' => __('Description', 'media-library-assistant'), 'ALT Text' => __('ALT Text', 'media-library-assistant'), 'Parent ID' => __('Parent ID', 'media-library-assistant'), 'Select' => __('Select', 'media-library-assistant'), 'set_parent_form' => $set_parent_form); $page_values = apply_filters('mla_upload_bulk_edit_form_values', $page_values); $page_template = apply_filters('mla_upload_bulk_edit_form_template', $page_template_array['page']); $parse_value = MLAData::mla_parse_template($page_template, $page_values); echo apply_filters('mla_upload_bulk_edit_form_parse', $parse_value, $page_template, $page_values); }
/** * Quick edit form * * @since 1.1 */ function quick_edit_custom_box($column_name, $screen) { if (!is_array($this->tax_obj->object_type) || !in_array($screen, $this->tax_obj->object_type) || $column_name != 'radio-' . $this->taxonomy) { return false; } //needs the same name as metabox nonce wp_nonce_field("add-{$this->taxonomy}", "_ajax_nonce-add-{$this->taxonomy}", false); ?> <fieldset class="inline-edit-col-left inline-edit-categories"> <div class="inline-edit-col"> <span class="title inline-edit-categories-label"><?php echo esc_html($this->tax_obj->labels->name); ?> <span class="catshow"><?php _e('[more]'); ?> </span> <span class="cathide" style="display:none;"><?php _e('[less]'); ?> </span> </span> <input type="hidden" name="<?php echo 'radio_tax_input[' . esc_attr($this->taxonomy) . '][]'; ?> " value="0" /> <ul id="<?php echo $this->taxonomy; ?> " class="radio-checklist cat-checklist <?php echo esc_attr($this->tax_obj->labels->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $this->taxonomy)); ?> </ul> </div> </fieldset> <?php }
function woo_tumblog_dashboard_widget_output() { //security check if (current_user_can('publish_posts')) { $tumblog_items = array('articles' => get_option('woo_articles_term_id'), 'images' => get_option('woo_images_term_id'), 'audio' => get_option('woo_audio_term_id'), 'video' => get_option('woo_video_term_id'), 'quotes' => get_option('woo_quotes_term_id'), 'links' => get_option('woo_links_term_id')); ?> <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?> /functions/js/ajaxupload.js"></script> <script type="text/javascript"> //No Conflict Mode jQuery.noConflict(); //AJAX Functions jQuery(document).ready(function(){ //JQUERY DATEPICKER jQuery( '.date-picker').each(function (){ jQuery( '#' + jQuery(this).attr( 'id')).datepicker({showOn: 'button', buttonImage: '<?php echo get_template_directory_uri(); ?> /functions/images/calendar.gif', buttonImageOnly: true}); }); jQuery( '#advanced-options-toggle').click(function () { jQuery( '#meta-fields').toggle(); if ( jQuery(this).text() == 'View Advanced Options' ) { jQuery(this).text( 'Hide Advanced Options' ); } else { jQuery(this).text( 'View Advanced Options' ); } }); //MENU BUTTON CLICK EVENTS jQuery( '#articles-menu-button').click(function () { jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#image-fields').attr( 'class','hide-fields' ); jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#link-fields').attr( 'class','hide-fields' ); jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#audio-fields').attr( 'class','hide-fields' ); jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#video-fields').attr( 'class','hide-fields' ); jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#quote-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','article' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['articles'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['articles']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#note-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); jQuery( '#images-menu-button').click(function () { jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#article-fields').attr( 'class','hide-fields' ); jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#link-fields').attr( 'class','hide-fields' ); jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#audio-fields').attr( 'class','hide-fields' ); jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#video-fields').attr( 'class','hide-fields' ); jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#quote-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','image' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['images'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['images']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#image-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); jQuery( '#links-menu-button').click(function () { jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#image-fields').attr( 'class','hide-fields' ); jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#article-fields').attr( 'class','hide-fields' ); jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#audio-fields').attr( 'class','hide-fields' ); jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#video-fields').attr( 'class','hide-fields' ); jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#quote-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','link' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['links'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['links']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#link-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); jQuery( '#audio-menu-button').click(function () { jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#image-fields').attr( 'class','hide-fields' ); jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#link-fields').attr( 'class','hide-fields' ); jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#article-fields').attr( 'class','hide-fields' ); jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#video-fields').attr( 'class','hide-fields' ); jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#quote-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','audio' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['audio'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['audio']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#audio-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); jQuery( '#videos-menu-button').click(function () { jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#image-fields').attr( 'class','hide-fields' ); jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#link-fields').attr( 'class','hide-fields' ); jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#audio-fields').attr( 'class','hide-fields' ); jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#article-fields').attr( 'class','hide-fields' ); jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#quote-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','video' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['video'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['video']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#video-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); jQuery( '#quotes-menu-button').click(function () { jQuery( '#quote-fields').removeAttr( 'class' ); jQuery( '#image-fields').removeAttr( 'class' ); jQuery( '#image-fields').attr( 'class','hide-fields' ); jQuery( '#link-fields').removeAttr( 'class' ); jQuery( '#link-fields').attr( 'class','hide-fields' ); jQuery( '#audio-fields').removeAttr( 'class' ); jQuery( '#audio-fields').attr( 'class','hide-fields' ); jQuery( '#video-fields').removeAttr( 'class' ); jQuery( '#video-fields').attr( 'class','hide-fields' ); jQuery( '#article-fields').removeAttr( 'class' ); jQuery( '#article-fields').attr( 'class','hide-fields' ); jQuery( '#tumblog-submit-fields').removeAttr( 'class' ); jQuery( '#tumblog-type').attr( 'value','quote' ); jQuery( '#content-fields').removeAttr( 'class' ); jQuery( '#tag-fields').removeAttr( 'class' ); <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> //Additional Tumblogs Checks jQuery( '#additional-tumblogs input').each(function(){ var elementid = jQuery(this).val(); <?php $term_array =& get_term($tumblog_items['quotes'], 'tumblog'); ?> var catid = <?php echo $tumblog_items['quotes']; ?> ; if (elementid == catid) { //make invisible jQuery(this).addClass( 'hide-cat' ); jQuery(this).attr( 'checked', false); } else { //make visible jQuery(this).removeAttr( 'class' ); jQuery(this).attr( 'checked', false); } }); jQuery( '#additional-tumblogs li').each(function(){ var elementname = jQuery(this).text(); var catname = '<?php echo $term_array->name; ?> '; var elementnamesub = elementname.substring(1); if (elementnamesub == catname) { //make invisible jQuery(this).addClass( 'hide-cat' ); } else { //make visible jQuery(this).removeAttr( 'class' ); } }); <?php } ?> if (nicEditors.findEditor( 'test-content') == undefined) { myNicEditor = new nicEditor({ buttonList : ['bold','italic','underline','ol','ul','left','center','right','justify','link','unlink','strikeThrough','xhtml','image'], iconsPath : '<?php echo get_template_directory_uri(); ?> /functions/images/nicEditorIcons.gif'}).panelInstance( 'test-content' ); } else { myNicEditor = nicEditors.findEditor( 'test-content' ); } jQuery( '#quote-title').focus(); nicEditors.findEditor( 'test-content').setContent( '' ); jQuery( '#content-fields > div').addClass( 'editorwidth' ); }); //AJAX FORM POST jQuery( '#tumblog-form').ajaxForm( { name: 'formpost', data: { // Additional data to send action: 'woo_tumblog_post', type: 'upload', data: 'formpost' }, // handler function for success event success: function(responseText, statusText) { jQuery( '#test-response').html( '<span class="success">'+'Published!'+'</span>').fadeIn( '3000').animate({ opacity: 1.0 },2000).fadeOut(); jQuery( '#ajax-loader').hide(); resetTumblogQuickPress(); }, // handler function for errors error: function(request) { // parse it for WordPress error if (request.responseText.search(/<title>WordPress › Error<\/title>/) != -1) { var data = request.responseText.match(/<p>(.*)<\/p>/); jQuery( '#test-response').html( '<span class="error">'+ data[1] +'</span>' ); } else { jQuery( '#test-response').html( '<span class="error">An error occurred, please notify the administrator.</span>' ); } }, beforeSubmit: function(formData, jqForm, options) { jQuery( '#ajax-loader').show(); } }); //AJAX IMAGE UPLOAD new AjaxUpload( '#image_upload_button', { action: '<?php echo admin_url("admin-ajax.php"); ?> ', name: 'userfile', data: { // Additional data to send action: 'woo_tumblog_media_upload', type: 'upload', data: 'userfile' }, onSubmit : function(file , ext){ if (! (ext && /^(jpg|png|jpeg|gif|bmp|tiff|tif|ico|jpe)$/.test(ext))){ // extension is not allowed alert( 'Error: invalid file extension' ); // cancel upload return false; } else { jQuery( '#test-response').html( '<span class="success">'+'Image Uploading...'+'</span>').fadeIn( '3000').animate({ opacity: 1.0 },2000); } }, onComplete: function(file, response) { jQuery( '#test-response').html( '<span class="success">'+'Image Uploaded!'+'</span>').fadeIn( '3000').animate({ opacity: 1.0 },2000).fadeOut(); var splitResults = response.split( '|' ); jQuery( '#image-upload').attr( 'value',splitResults[0]); jQuery( '#image-id').attr( 'value',splitResults[1]); } }); //AJAX AUDIO UPLOAD new AjaxUpload( '#audio_upload_button', { action: '<?php echo admin_url("admin-ajax.php"); ?> ', name: 'userfile', data: { // Additional data to send action: 'woo_tumblog_media_upload', type: 'upload', data: 'userfile' }, onSubmit : function(file , ext){ if (! (ext && /^(mp3|mp4|ogg|wma|midi|mid|wav|wmx|wmv|avi|mov|qt|mpeg|mpg|asx|asf)$/.test(ext))){ // extension is not allowed alert( 'Error: invalid file extension' ); // cancel upload return false; } else { jQuery( '#test-response').html( '<span class="success">'+'Audio Uploading...'+'</span>').fadeIn( '3000').animate({ opacity: 1.0 },2000); } }, onComplete: function(file, response) { jQuery( '#test-response').html( '<span class="success">'+'Audio Uploaded!'+'</span>').fadeIn( '3000').animate({ opacity: 1.0 },2000).fadeOut(); var splitResults = response.split( '|' ); jQuery( '#audio-upload').attr( 'value',splitResults[0]); jQuery( '#audio-id').attr( 'value',splitResults[1]); } }); }); </script> <div id="tumblog-post"> <form name="tumblog-form" onsubmit="updateContent();" id="tumblog-form" method="post" action="<?php echo admin_url("admin-ajax.php"); ?> "> <img id="ajax-loader" src="<?php echo get_template_directory_uri(); ?> /functions/images/ajax-loader.gif" /> <div id="test-response"></div> <div id="tumblog-menu"> <a id="articles-menu-button" href="#" title="#">Article</a> <a id="images-menu-button" href="#" title="#">Image</a> <a id="links-menu-button" href="#" title="#">Link</a> <a id="audio-menu-button" href="#" title="#">Audio</a> <a id="videos-menu-button" href="#" title="#">Video</a> <a id="quotes-menu-button" href="#" title="#">Quote</a> </div> <div id="article-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="note-title">Title</label></h4> <div> <input name="note-title" id="note-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> </div> <div id="video-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="video-title">Title</label></h4> <div> <input name="video-title" id="video-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> <h4 id="quick-post-title"><label for="video-embed">Embed Video Code</label></h4> <textarea style="width:100%" id="video-embed" name="video-embed" tabindex="2"></textarea> </div> <div id="image-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="image-title">Title</label></h4> <div> <input name="image-title" id="image-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> <div id="image-option-upload" style="display:none;"> <h4 id="quick-post-title"><label for="image-upload">Upload Image</label> | <label id="image-url-button">Image URL instead</label></h4> <div> <input name="image-upload" id="image-upload" tabindex="2" autocomplete="off" value="" type="text"> </div> <input name="image_upload_button" type="button" id="image_upload_button" class="button" value="Upload Image" /> </div> <div id="image-option-url"> <h4 id="quick-post-title"><label for="image-url">Image URL</label> | <label id="image-upload-button">Upload Image instead</label></h4> <div> <input name="image-url" id="image-url" tabindex="2" autocomplete="off" value="" type="text"> </div> </div> <input type="hidden" id="image-id" name="image-id" value="" /> </div> <div id="link-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="link-title">Title</label></h4> <div> <input name="link-title" id="link-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> <h4 id="quick-post-title"><label for="link-url">Link URL</label></h4> <div> <input name="link-url" id="link-url" tabindex="2" autocomplete="off" value="" type="text"> </div> </div> <div id="quote-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="quote-title">Title</label></h4> <div> <input name="quote-title" id="quote-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> <h4 id="quick-post-title"><label for="quote-copy">Quote</label></h4> <textarea style="width:100%" id="quote-copy" name="quote-copy" tabindex="2"></textarea> <h4 id="quick-post-title"><label for="quote-url">Quote URL</label></h4> <div> <input name="quote-url" id="quote-url" tabindex="3" autocomplete="off" value="" type="text"> </div> <h4 id="quick-post-title"><label for="quote-quote">Quote Author</label></h4> <div> <input name="quote-author" id="quote-author" tabindex="4" autocomplete="off" value="" type="text"> </div> </div> <div id="audio-fields" class="hide-fields"> <h4 id="quick-post-title"><label for="audio-title">Title</label></h4> <div> <input name="audio-title" id="audio-title" tabindex="1" autocomplete="off" value="" type="text" class="tumblog-title"> </div> <div id="audio-option-upload" style="display:none;"> <h4 id="quick-post-title"><label for="audio-upload">Upload Audio</label> | <label id="audio-url-button">Audio URL instead</label></h4> <div> <input name="audio-upload" id="audio-upload" tabindex="2" autocomplete="off" value="" type="text"> </div> <input name="audio_upload_button" type="button" id="audio_upload_button" class="button" value="Upload Audio" /> </div> <div id="audio-option-url"> <h4 id="quick-post-title"><label for="audio-url">Audio URL</label> | <label id="audio-upload-button">Upload Audio instead</label></h4> <div> <input name="audio-url" id="audio-url" tabindex="2" autocomplete="off" value="" type="text"> </div> </div> <input type="hidden" id="audio-id" name="audio-id" value="" /> </div> <div id="content-fields" class="hide-fields"> <?php if (current_user_can('upload_files')) { ?> <?php //the_editor( '', $id = 'content', $prev_id = 'title', $media_buttons = false, $tab_index = 5); ?> <textarea tabindex="5" id="test-content" style="width:100%;height:100px;"></textarea> <?php } ?> <input type="hidden" id="tumblog-content" name="tumblog-content" value="" /> <input type="hidden" id="tumblog-type" name="tumblog-type" value="article" /> <p><a id="advanced-options-toggle" onclick="">View Advanced Options</a></p> </div> <div id="meta-fields" class="hide-fields"> <p> <?php // START - POST STATUS AND DATE TIME ?> <strong><label for="tumblog-status">Post Status : </label></strong> <select style="margin-left:10px;" id="tumblog-status" name="tumblog-status" tabindex="6"> <option value="publish">Published</option> <option value="draft">Draft</option> </select> </p> <p> <?php $date_formatted = date_i18n("m/d/Y"); ?> <?php $time_now_hours = date_i18n("H"); ?> <?php $time_now_mins = date_i18n("i"); ?> <?php $post_id = 0; ?> <strong><label for="tumblog-date">Post Date : </label></strong> <input name="tumblog-date" id="tumblog-date" tabindex="7" value="<?php echo esc_attr($date_formatted); ?> " type="text" class="date-picker" style="width:100px;margin-left:20px;"> @ <input class="tumblog-time" name="tumblog-hours" id="tumblog-hours" maxlength="2" size="2" value="<?php echo esc_attr($time_now_hours); ?> " type="text">:<input class="tumblog-time" name="tumblog-mins" id="tumblog-mins" maxlength="2" size="2" value="<?php echo esc_attr($time_now_mins); ?> " type="text"> <?php // END - POST STATUS AND DATE TIME ?> </p> <br /> <div id="additional-categories" style="width:<?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> 47%;float:left;<?php } else { ?> 94%;<?php } ?> "> <strong><label for="post_category[]">Additional Categories : </label></strong> <?php // START - MULTI CATEGORY DROP DOWN ?> <?php $taxonomy = 'category'; ?> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel" style="height:100px;overflow:auto;border: 1px solid #CCCCCC;margin-top:6px;margin-bottom:6px;"> <?php $name = $taxonomy == 'category' ? 'post_category' : 'tax_input[' . $taxonomy . ']'; ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php if (function_exists('wp_terms_checklist')) { wp_terms_checklist($post_id, array('taxonomy' => $taxonomy)); ?> <?php } else { wp_category_checklist(); } ?> </ul> <?php // END - MULTI CATEGORY DROP DOWN ?> </div> </div> <?php if (get_option('woo_tumblog_content_method') != 'post_format') { ?> <div id="additional-tumblogs" style="width:47%;float:right;"> <strong><label for="post_tumblog[]">Additional Tumblogs : </label></strong> <?php // START - MULTI TUMBLOG DROP DOWN ?> <?php $taxonomy = 'tumblog'; ?> <div id="<?php echo $taxonomy; ?> -all" class="tabs-panel" style="height:100px;overflow:auto;border: 1px solid #CCCCCC;margin-top:6px;margin-bottom:6px;"> <?php $name = $taxonomy == 'tumblog' ? 'post_tumblog' : 'tax_input[' . $taxonomy . ']'; ?> <ul id="<?php echo $taxonomy; ?> checklist" class="list:<?php echo $taxonomy; ?> categorychecklist form-no-clear"> <?php if (function_exists('wp_terms_checklist')) { wp_terms_checklist($post_id, array('taxonomy' => $taxonomy)); ?> <?php } else { wp_category_checklist(); } ?> </ul> <?php // END - MULTI TUMBLOG DROP DOWN ?> </div> </div> <?php } ?> </div> <div id="tag-fields" class="hide-fields" style="clear:both;padding-top:10px;"> <h4 id="tumblog-tags-title"><label for="tumblog-tags">Tags</label></h4> <div> <input name="tumblog-tags" id="tumblog-tags" tabindex="6" autocomplete="off" value="" type="text"> </div> </div> <div id="tumblog-submit-fields" class="hide-fields"> <input name="tumblogsubmit" type="submit" id="tumblogsubmit" class="button-primary" tabindex="7" value="Submit" onclick="return validateInput();" /> <input name="tumblogreset" type="reset" id="tumblogreset" class="button" tabindex="8" value="Reset" /> </div> </form> </div><div id="debug-tumblog"></div> <?php } }
/** * 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 mass_photo_posting() { global $box; // check user permission to use bulk photo posting if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.', MAX_SHORTNAME)); } // get the current user object $current_user = wp_get_current_user(); if (!empty($_POST) && !empty($_POST['post'])) { ksort($_POST['post']); foreach ($_POST['post'] as $key => $value) { $imageID = $key; $photos[$imageID]['id_photo'] = $imageID; $photos[$imageID]['post_name'] = $_POST['post_name'][$imageID]; foreach (@$_POST['galleries'] as $key => $value) { if ($key == $imageID) { foreach ($value as $key2 => $value2) { $photos[$imageID]['gal'] .= $key2 . ","; } } } $photos[$imageID]['photo_copyright_information_value'] = $_POST['photo_copyright_information_value'][$imageID]; $photos[$imageID]['photo_copyright_link_value'] = $_POST['photo_copyright_link_value'][$imageID]; $photos[$imageID]['photo_location_value'] = $_POST['photo_location_value'][$imageID]; $photos[$imageID]['photo_date_value'] = strtotime($_POST['photo_date_value'][$imageID]); $photos[$imageID]['photo_item_type_value'] = $_POST['photo_item_type_value'][$imageID]; $photos[$imageID]['photo_cropping_direction_value'] = $_POST['photo_cropping_direction_value'][$imageID]; $photos[$imageID]['photo_lightbox_type_value'] = "Photo"; // Get fullsize background if ($_POST['fullsize_background'][$imageID] == 'nofullsize') { $photos[$imageID]['show_post_fullsize_value'] = 'false'; } else { $photos[$imageID]['show_post_fullsize_value'] = 'true'; } if ($_POST['fullsize_background'][$imageID] == 'random') { $photos[$imageID]['show_random_fullsize_value'] = 'true'; } else { if ($_POST['fullsize_background'][$imageID] == 'featured') { $photos[$imageID]['show_random_fullsize_value'] = 'false'; } else { $photos[$imageID]['show_random_fullsize_value'] = 'false'; } } if ($_POST['fullsize_background_url'][$imageID] != '') { $photos[$imageID]['show_page_fullsize_url_value'] = $_POST['fullsize_background_url'][$imageID]; } // get the tags array $photos[$imageID]['post_tags'] = explode(",", trim($_POST['post_tags'][$imageID])); } if (!empty($photos)) { foreach ($photos as $photo) { $cat_array = explode(',', substr($photo['gal'], 0, -1)); // prepare the photo post values $post = array('post_title' => $photo['post_name'], 'post_content' => '', 'post_status' => 'publish', 'post_author' => $current_user->ID, 'post_type' => POST_TYPE_GALLERY, 'tax_input' => array(GALLERY_TAXONOMY => $cat_array)); // add the new post $post_id = wp_insert_post($post); // add the tags to the new post if (!empty($photo['post_tags'])) { wp_set_post_tags($post_id, $photo['post_tags']); unset($GLOBALS['tag_cache']); } // add the meta fields from $_POST values to the new post foreach ($photo as $index => $value) { add_post_meta($post_id, MAX_SHORTNAME . '_' . $index, $photo[$index]); } // Set featured post from media attachment set_post_thumbnail($post_id, $photo['id_photo']); $image_post = array(); $image_post['ID'] = $photo['id_photo']; $image_post['post_parent'] = $post_id; // update the post wp_update_post($image_post); // show update message $_saved = true; } } } else { $_saved = false; } // Get unassigned attachments $images_args = array('numberposts' => 99999, 'orderby' => 'post_date', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => 0, 'post_status' => 'inherit'); $images = get_posts($images_args); // Get Gallery Categories $gallery_args = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => GALLERY_TAXONOMY, 'pad_counts' => false); $galleries = get_categories($gallery_args); // get the custom post type for further use $post_types = max_get_custom_post_type(); // get galleries in hirachical order $taxonomy_names = get_object_taxonomies('gallery'); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); if (!$taxonomy->show_ui) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } ?> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/base/jquery-ui.css" rel="stylesheet" /> <style type="text/css"> #massPhotoUpload th { } #massPhotoUpload th.col-preview, #massPhotoUpload td.media-icon { width: 70px; padding: 8px 0; } #massPhotoUpload .col-gallery, #massPhotoUpload .col-gallery ul, #massPhotoUpload .col-gallery ul li { margin: 0; padding: 0; font-size: 11px; line-height: 20px; } #massPhotoUpload td.col-gallery { padding: 7px 13px 7px 0; white-space: nowrap; width: 15% } #massPhotoUpload ul.cat-checklist { background-color: white; border-color: #DDD; padding: 0 5px; } #massPhotoUpload .col-gallery ul.children { margin: 0 0 0 18px; } #massPhotoUpload .col-gallery input { margin-top: 0; } #massPhotoUpload th.col-meta { width: 10em; } #massPhotoUpload td { padding: 4px 7px 2px; } #massPhotoUpload td label { white-space: nowrap } #massPhotoUpload td.col-description .input-text-wrap, #massPhotoUpload th.col-description .input-text-wrap { color: #808387; font-size: 11px; } #massPhotoUpload td.col-description .input-text-wrap .text-description{ width: 90%; display: block; white-space: normal; padding-left: .65em; } #massPhotoUpload td.col-background { width: 160px; } #massPhotoUpload td.col-background label span.title { width: auto; float: none; } #massPhotoUpload td.col-background label span.input-text-wrap { margin: 0; float: left; width: 1.5em } #massPhotoUpload tr.front-row td, #massPhotoUpload tr.front-row th { background: #ECECEC; } #massPhotoUpload input.post_name, #massPhotoUpload textarea.post_tags { width: 90%; } #massPhotoUpload a.post_file { line-height: 22px; font-size: 11px; } #massPhotoUpload .file-ext { text-transform: uppercase; } #massPhotoUpload td.column-file label span.file-ext { font-size: 11px; } #massPhotoUpload input.button-primary { margin-bottom: 15px; } #massPhotoUpload input[type="radio"] { height: 17px; } #massPhotoUpload select, #massPhotoUpload textarea { font-size: 11px; } #massPhotoUpload .input-url { display: none; width: 90% } </style> <div class="wrap"> <div id="icon-upload" class="icon32"><br /></div> <h2>Bulk <?php echo $post_types[POST_TYPE_GALLERY]->labels->singular_name; ?> Posting <a href="media-new.php" class="add-new-h2">Add New Media</a></h2> <?php if ($_saved === true) { ?> <div id="message" class="updated below-h2"> <p> <?php echo $post_types[POST_TYPE_GALLERY]->labels->name; ?> saved and published. <a href="edit.php?post_type=gallery"><?php echo $post_types[POST_TYPE_GALLERY]->labels->name; ?> </a><br> </p> </div> <?php } ?> <form method="post" id="massPhotoUpload"> <p> <?php _e('This list shows all the images from your media library that are not attached to any post. You can create your posts easily from here with a few clicks.', MAX_SHORTNAME); ?> </p> <?php if ($images) { ?> <table class="wp-list-table widefat" cellpadding="0" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column column-cb check-column"> </th> <th scope="col" class="manage-column col-preview"> </th> <th scope="col" class="manage-column"><?php _e('File', MAX_SHORTNAME); ?> </th> <th scope="col" class="manage-column col-gallery"><?php _e('Galleries', MAX_SHORTNAME); ?> </th> <th scope="col" class="manage-column col-meta"><?php _e('Meta Information', MAX_SHORTNAME); ?> </th> <th scope="col" class="manage-column"><?php _e('Settings', MAX_SHORTNAME); ?> </th> <th scope="col" class="manage-column"><?php _e('Background Image ', MAX_SHORTNAME); ?> </th> </tr> </thead> <tbody> <?php // More than one image if (count($images) > 1) { ?> <tr class="front-row inline-edit-row"> <th scope="row" class="column-cb check-column"><input type="checkbox" id="post" disabled="disabled" /></th> <td> </td> <td class="col-description"> <fieldset> <label> <span class="title"><?php _e('Title', MAX_SHORTNAME); ?> </span> <span class="input-text-wrap"> <input type="text" id="post_name" class="post_name"> </span> </label> <label> <span class="title"><?php _e('Tags', MAX_SHORTNAME); ?> </span> <span class="input-text-wrap"> <textarea id="post_tags" class="post_tags tax_input_post_tag"></textarea> </span> </label> <label> <span class="input-text-wrap"><span class="text-description"><?php _e('Changes made in this line will be incorporated into other lines.', MAX_SHORTNAME); ?> </span></span> </label> </fieldset> </td> <td class="col-gallery"> <?php if (count($hierarchical_taxonomies)) { foreach ($hierarchical_taxonomies as $taxonomy) { $box = array('id' => $taxonomy->name, 'hideid' => 1); $output = '<input type="hidden" name="" value="0" />'; $output .= '<ul class="cat-checklist ' . esc_attr($taxonomy->name) . '-checklist">'; ob_start(); wp_terms_checklist(null, array('taxonomy' => $taxonomy->name, 'walker' => new max_category_checklist_walker(), 'selected_cats' => "", 'checked_ontop' => false)); $output .= ob_get_contents(); ob_end_clean(); $output .= '</ul>'; } //$hierarchical_taxonomies as $taxonomy } // count( $hierarchical_taxonomies ) && !$bulk echo $output; ?> </td> <td> <fieldset> <label> <span class="title">© Owner</span> <span class="input-text-wrap"> <input type="text" id="photo_copyright_information_value" /> </span> </label> <label> <span class="title">© Link</span> <span class="input-text-wrap"> <input type="text" id="photo_copyright_link_value" /> </span> </label> <label> <span class="title">Location</span> <span class="input-text-wrap"> <input type="text" id="photo_location_value"> </span> </label> <label> <span class="title">Date</span> <span class="input-text-wrap"> <input type="text" id="photo_date_value" class="photo_date_value"> </span> </label> </fieldset> </td> <td> <fieldset> <label> <span class="title"><?php _e('Link type', MAX_SHORTNAME); ?> </span> <span class="input-text-wrap"> <select id="photo_item_type_value"><option value="lightbox" selected="selected" >Lightbox</option><option value="projectpage">Project Page</option></select> </span> </label> <label> <span class="title"><?php _e('Cropping', MAX_SHORTNAME); ?> </span> <span class="input-text-wrap"> <select id="photo_cropping_direction_value"> <option value="c" selected="selected">Position in the Center (default)</option> <option value="t">Align top</option> <option value="tr">Align top right</option> <option value="tl">Align top left</option> <option value="b">Align bottom</option> <option value="br">Align bottom right</option> <option value="bl">Align bottom left</option> <option value="l">Align left</option> <option value="r">Align right</option> </select> </span> </label> </fieldset> </td> <td class="col-description col-background"> <fieldset> <label> <span class="input-text-wrap"> <input type="radio" id="fullsize_background_featured" name="fullsize_background" value="featured" checked="checked" /> </span> <span class="title"><?php _e('Post Featured Image', MAX_SHORTNAME); ?> </span> </label> <label> <span class="input-text-wrap"> <input type="radio" id="fullsize_background_random" name="fullsize_background" value="random" /> </span> <span class="title"><?php _e('Random Gallery Image', MAX_SHORTNAME); ?> </span> </label> <label> <span class="input-text-wrap"> <input type="radio" id="fullsize_background_url" name="fullsize_background" value="url" /> </span> <span class="title"><?php _e('Image from URL', MAX_SHORTNAME); ?> </span> <input type="text" id="fullsize_background_url_value" name="fullsize_background_url" class="input-url"/> </label> <label> <span class="input-text-wrap"> <input type="radio" id="fullsize_background_show" name="fullsize_background" value="nofullsize" /> </span> <span class="title"><?php _e('No Background', MAX_SHORTNAME); ?> </span> </label> </fieldset> </td> </tr> <?php } ?> <?php foreach ($images as $image) { $path_info = pathinfo(wp_get_attachment_url($image->ID, 'full')); echo '<tr class="inline-edit-row">'; echo '<th class="check-column"><input type="checkbox" class="post" name="post[' . $image->ID . ']" value="1" disabled="disabled" /></th>'; echo '<td class="column-icon media-icon"><a href="' . wp_get_attachment_url($image->ID, 'full') . '">' . wp_get_attachment_image($image->ID, array(64, 64)) . '</a></td>'; echo '<td class="column-file"> <fieldset> <label> <span class="title">' . __('Title', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <input type="text" name="post_name[' . $image->ID . ']" class="post_name" value="' . $image->post_title . '"> <input type="hidden" name="post_hidden_name[' . $image->ID . ']" value="' . $image->post_title . '"> </span> </label> <label> <span class="title">' . __('Tags', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <textarea name="post_tags[' . $image->ID . ']" class="post_tags">' . $image->post_tags . '</textarea> <input type="hidden" name="post_hidden_tags[' . $image->ID . ']" value="' . $image->post_tags . '"> </span> </label> <label> <span class="title">' . __('File', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <a href="media.php?attachment_id=' . $image->ID . '&action=edit" class="post_file">' . $image->post_title . '</a> - <span class="file-ext">' . $path_info['extension'] . '</span> </span> </label> <label class="gallery-error"> <span class="title"></span> <span class="input-text-wrap"> <small class="ui-state-error-text">' . __('You need to choose at least one gallery to save this photo.', MAX_SHORTNAME) . '</small> </span> </label> </fieldset> </td>'; echo '<td class="col-gallery">'; $output = ""; if (count($hierarchical_taxonomies)) { foreach ($hierarchical_taxonomies as $taxonomy) { $box = array('id' => 'galleries', 'imageID' => $image->ID); $output .= '<input type="hidden" name="" value="0" />'; $output .= '<ul class="cat-checklist ' . esc_attr($taxonomy->name) . '-checklist">'; ob_start(); wp_terms_checklist(null, array('taxonomy' => $taxonomy->name, 'walker' => new max_category_checklist_walker(), 'selected_cats' => get_post_meta($image->ID, $box['id'], true), 'checked_ontop' => false)); $output .= ob_get_contents(); ob_end_clean(); $output .= '</ul>'; } //$hierarchical_taxonomies as $taxonomy } // count( $hierarchical_taxonomies ) && !$bulk echo $output; echo '</td>'; echo '<td> <fieldset> <label> <span class="title">' . __('© Owner', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <input type="text" class="photo_copyright_information_value" name="photo_copyright_information_value[' . $image->ID . ']"> </span> </label> <label> <span class="title">' . __('© Link', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <input type="text" class="photo_copyright_link_value" name="photo_copyright_link_value[' . $image->ID . ']"> </span> </label> </fieldset> <fieldset> <label> <span class="title">' . __('Location', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <input type="text" class="photo_location_value" name="photo_location_value[' . $image->ID . ']"> </span> </label> <label> <span class="title">' . __('Date', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <input type="text" class="photo_date_value" name="photo_date_value[' . $image->ID . ']"> </span> </label> </fieldset> </td>'; echo '<td> <fieldset> <label> <span class="title">' . __('Link type', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <select name="photo_item_type_value[' . $image->ID . ']" class="photo_item_type_value"><option value="lightbox" selected="selected">Lightbox</option><option value="projectpage">Project Page</option></select> </span> </label> <label> <span class="title">' . __('Cropping', MAX_SHORTNAME) . '</span> <span class="input-text-wrap"> <select name="photo_cropping_direction_value[' . $image->ID . ']" class="photo_cropping_direction_value"> <option value="c" selected="selected">Position in the Center (default)</option> <option value="t">Align top</option> <option value="tr">Align top right</option> <option value="tl">Align top left</option> <option value="b">Align bottom</option> <option value="br">Align bottom right</option> <option value="bl">Align bottom left</option> <option value="l">Align left</option> <option value="r">Align right</option> </select> </span> </label> </fieldset> </td>'; echo '<td class="col-background"> <fieldset> <label> <span class="input-text-wrap"> <input type="radio" class="fullsize_background_featured" name="fullsize_background[' . $image->ID . ']" value="featured" checked="checked"> </span> <span class="title">' . __('Post Featured Image', MAX_SHORTNAME) . '</span> </label> <label> <span class="input-text-wrap"> <input type="radio" class="fullsize_background_random" name="fullsize_background[' . $image->ID . ']" value="random"> </span> <span class="title">' . __('Random Gallery Image', MAX_SHORTNAME) . '</span> </label> <label> <span class="input-text-wrap"> <input type="radio" class="fullsize_background_url" name="fullsize_background[' . $image->ID . ']" value="url" /> </span> <span class="title">' . __('Image from URL', MAX_SHORTNAME) . '</span> <input type="text" class="fullsize_background_url_value input-url" name="fullsize_background_url[' . $image->ID . ']" /> </label> <label> <span class="input-text-wrap"> <input type="radio" class="fullsize_background_show" name="fullsize_background[' . $image->ID . ']" value="nofullsize"> </span> <span class="title">' . __('No Background', MAX_SHORTNAME) . '</span> </label> </fieldset> </td>'; echo '</tr>'; } ?> </tbody> </table> <p class="submit"><input type="submit" disabled="disabled" value="<?php _e('Save and publish marked ' . $post_types[POST_TYPE_GALLERY]->labels->name, MAX_SHORTNAME); ?> " class="button-primary save"></p> <?php } else { // no unattached images in media library ?> <div id="message" class="updated below-h2"> <p> You don't have images in your media library that are not attached to any post. <a href="media-new.php">Add New Media</a> <br> </p> </div> <?php } ?> </form> </div> <script type="text/javascript"> jQuery(document).ready(function($) { jQuery(".photo_date_value").datepicker(); // odd/even for alternate rows jQuery('#massPhotoUpload tr:odd').addClass('alternate'); // Change action for all rows jQuery("#massPhotoUpload tr.front-row td input, #massPhotoUpload tr.front-row td textarea, #massPhotoUpload tr.front-row th input, #massPhotoUpload tr.front-row th textarea").change(function () { var gal = jQuery(this).attr('id'); // check for checkbox and cb value if(jQuery(this).is(':checkbox') || jQuery(this).is(':radio')){ if(jQuery(this).is(':checked')){ var $checkbox = jQuery("."+gal); $checkbox.attr('checked', true); $checkbox.change(); }else{ var $checkbox = jQuery("."+gal); $checkbox.attr('checked', false); $checkbox.change(); } } // if its the post title if(jQuery(this).hasClass('post_name')){ var ele = jQuery(this); var i = 1; jQuery("."+gal).not(ele).each(function(){ if(ele.attr('value') != ""){ jQuery(this).attr('value', ele.attr('value') + "-" + i); i++; }else{ jQuery(this).attr('value', jQuery(this).next().val() ); } }); }else{ jQuery("."+gal).attr('value', jQuery(this).attr('value')); } }); // change event of select jQuery("#massPhotoUpload tr.front-row td select").change(function () { var id = jQuery(this).attr('id'); var sel = jQuery(this).val(); jQuery("."+id).val(sel); }); // Show and hide URL input jQuery("#massPhotoUpload input[type='radio']").bind('change',function(){ if( jQuery(this).is("tr.front-row input[type='radio']") && jQuery(this).val() == 'url' ){ jQuery("#massPhotoUpload .input-url").show(); }else if ( jQuery(this).is("tr.front-row input[type='radio']") && jQuery(this).val() != 'url' ){ jQuery("#massPhotoUpload .input-url").hide().val(''); }else{ if(jQuery(this).val() == 'url'){ jQuery(this).parents('fieldset').find('.input-url').show(); }else{ jQuery(this).parents('fieldset').find('.input-url').hide(); } } }) // check for number of images to publish jQuery('th.check-column input[type=checkbox]').bind('change', function(){ var b = $('th.check-column input'); if( b.filter(':checked').length > 0) { jQuery('p.submit input.save').removeAttr('disabled'); }else{ jQuery('p.submit input.save').attr('disabled', 'disabled'); } }) // gallery checkbox action jQuery('ul.cat-checklist input').live('change', function (){ var ul = jQuery(this).parents('ul.cat-checklist') var checked = jQuery('input', ul).filter(':checked').length; if(checked > 0){ ul.parents('tr').find('th.check-column input').attr('disabled',false); ul.parents('tr').find('td.column-file .gallery-error').hide(); }else{ ul.parents('tr').find('th.check-column input').attr('disabled',true); ul.parents('tr').find('td.column-file .gallery-error').show(); } }) }); </script> <?php }
function _wpv_render_taxonomy_control($taxonomy, $type, $url_param, $default_label) { // We need to know what attribute url format are we using // to make the control filter use values of names or slugs for values. // If using names, $url_format=false and if using slugs, $url_format=true global $WP_Views; $view_settings = $WP_Views->get_view_settings(); $url_format = false; if (isset($view_settings['taxonomy-' . $taxonomy . '-attribute-url-format']) && 'slug' == $view_settings['taxonomy-' . $taxonomy . '-attribute-url-format'][0]) { $url_format = true; } if (!class_exists('Walker_Category_Checklist')) { // We need to include the taxonomy checkboxes as there not // available in the front end. class Walker_Category_Checklist extends Walker { var $tree_type = 'category'; var $db_fields = array('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this function __construct($slug_mode = false) { $this->slug_mode = $slug_mode; } function start_lvl(&$output, $depth, $args) { $indent = str_repeat("\t", $depth); $output .= "{$indent}<ul class='children'>\n"; //$output .= "$indent\n"; } function end_lvl(&$output, $depth, $args) { $indent = str_repeat("\t", $depth); $output .= "{$indent}</ul>\n"; //$output .= "$indent\n"; } function start_el(&$output, $category, $depth, $args) { extract($args); if (empty($taxonomy)) { $taxonomy = 'category'; } if ($taxonomy == 'category') { $name = 'post_category'; } else { $name = $taxonomy; } $class = in_array($category->term_id, $popular_cats) ? ' class="popular-category"' : ''; // NOTE: were outputing the "slug" and not the "term-id". // WP outputs the "term-id" if ($this->slug_mode) { $output .= "\n<li id='{$taxonomy}-{$category->term_id}'{$class}>" . '<label class="selectit"><input value="' . $category->slug . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' . checked(in_array($category->slug, $selected_cats), true, false) . disabled(empty($args['disabled']), false, false) . ' /> ' . esc_html(apply_filters('the_category', $category->name)) . '</label>'; } else { $output .= "\n<li id='{$taxonomy}-{$category->term_id}'{$class}>" . '<label class="selectit"><input value="' . $category->name . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' . checked(in_array($category->name, $selected_cats), true, false) . disabled(empty($args['disabled']), false, false) . ' /> ' . esc_html(apply_filters('the_category', $category->name)) . '</label>'; } } function end_el(&$output, $category, $depth, $args) { $output .= "</li>\n"; //$output .= "\n"; } } } /** * Taxonomy independent version of wp_category_checklist * * @since 3.0.0 * * @param int $post_id * @param array $args */ if (!function_exists('wp_terms_checklist')) { function wp_terms_checklist($post_id = 0, $args = array()) { $defaults = array('descendants_and_self' => 0, 'selected_cats' => false, 'popular_cats' => false, 'walker' => null, 'url_format' => false, 'taxonomy' => 'category', 'checked_ontop' => false); extract(wp_parse_args($args, $defaults), EXTR_SKIP); if (empty($walker) || !is_a($walker, 'Walker')) { $walker = new Walker_Category_Checklist($url_format); } $descendants_and_self = (int) $descendants_and_self; $args = array('taxonomy' => $taxonomy); $tax = get_taxonomy($taxonomy); $args['disabled'] = false; if (is_array($selected_cats)) { $args['selected_cats'] = $selected_cats; } elseif ($post_id) { $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); } else { $args['selected_cats'] = array(); } if (is_array($popular_cats)) { $args['popular_cats'] = $popular_cats; } else { $args['popular_cats'] = get_terms($taxonomy, array('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); } if ($descendants_and_self) { $categories = (array) get_terms($taxonomy, array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0)); $self = get_term($descendants_and_self, $taxonomy); array_unshift($categories, $self); } else { $categories = (array) get_terms($taxonomy, array('get' => 'all')); } if ($checked_ontop) { // 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) $checked_categories = array(); $keys = array_keys($categories); foreach ($keys as $k) { if (in_array($categories[$k]->term_id, $args['selected_cats'])) { $checked_categories[] = $categories[$k]; unset($categories[$k]); } } // Put checked cats on top echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); } // Then the rest of them echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); } } $terms = array(); if (isset($_GET[$url_param])) { if (is_array($_GET[$url_param])) { $terms = $_GET[$url_param]; } else { // support csv terms $terms = explode(',', $_GET[$url_param]); } } ob_start(); ?> <?php if ($type == 'select') { $name = $taxonomy; if ($name == 'category') { $name = 'post_category'; } echo '<select name="' . $name . '">'; echo "<option selected='selected' value='0'>{$default_label}</option>"; // set the label for the default option $temp_slug = '0'; if (count($terms)) { $temp_slug = $terms[0]; } $my_walker = new Walker_Category_select($temp_slug, $url_format); wp_terms_checklist(0, array('taxonomy' => $taxonomy, 'selected_cats' => $terms, 'walker' => $my_walker)); echo '</select>'; } else { echo '<ul class="categorychecklist form-no-clear">'; wp_terms_checklist(0, array('taxonomy' => $taxonomy, 'selected_cats' => $terms, 'url_format' => $url_format)); echo '</ul>'; } ?> <?php $taxonomy_check_list = ob_get_clean(); if ($taxonomy == 'category') { $taxonomy_check_list = str_replace('name="post_category', 'name="' . $url_param, $taxonomy_check_list); } else { $taxonomy_check_list = str_replace('name="' . $taxonomy, 'name="' . $url_param, $taxonomy_check_list); } return $taxonomy_check_list; }
/** * Used to display the categories in the add filter popup. * */ function wpv_add_category_checkboxes($args) { ?> <div id="taxonomy-<?php echo $args['taxonomy']; ?> " class="categorydiv" style="margin-left: 20px;"> <?php _e('Taxonomy is:', 'wpv-views'); ?> <select class="wpv_taxonomy_relationship" name="tax_<?php echo $args['taxonomy']; ?> _relationship"> <option value="IN"><?php _e('Any of the following', 'wpv-views'); ?> </option> <option value="NOT IN"><?php _e('NOT one of the following', 'wpv-views'); ?> </option> <option value="AND"><?php _e('All of the following', 'wpv-views'); ?> </option> <option value="FROM PAGE"><?php _e('Value set by the current page', 'wpv-views'); ?> </option> <option value="FROM ATTRIBUTE"><?php _e('Value set by View shortcode attribute', 'wpv-views'); ?> </option> <option value="FROM URL"><?php _e('Value set by URL parameter', 'wpv-views'); ?> </option> <option value="FROM PARENT VIEW"><?php _e('Value set by parent view', 'wpv-views'); ?> </option> </select> <div> <ul class="categorychecklist form-no-clear"> <?php wp_terms_checklist(0, array('taxonomy' => $args['taxonomy'])); ?> </ul> </div> <input type="text" class="wpv_taxonomy_param" name="tax_<?php echo $args['taxonomy']; ?> _attribute_url" style="display:none;" /> <span class="wpv_taxonomy_param_missing"><?php echo __('<- Please enter a value here', 'wpv-views'); ?> </span> <br /> <span class="wpv-taxonomy-help"><i> <?php echo sprintf(__('%sLearn about filtering by taxonomy%s', 'wpv-views'), '<a class="wpv-help-link" href="' . WPV_FILTER_BY_TAXONOMY_LINK . '" target="_blank">', ' »</a>'); ?> </i></span> </div> <?php }
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 }
?> /> <span class="description">Insert the author name as tag</span> </p> <br/> </p> <p> <b>Post category:</b><br/> <p class="dg_tw_horiz"> <ul class="list:category categorychecklist form-no-clear"> <?php $selected_cats = $dg_tw_cats; wp_terms_checklist(0, array('taxonomy' => 'category', 'descendants_and_self' => 0, 'selected_cats' => $selected_cats, 'popular_cats' => false, 'walker' => null, 'checked_ontop' => false)); ?> </ul> </p> <br/> </p> <p> <b>Content:</b><br/> <p class="dg_tw_horiz"> <input type="checkbox" name="dg_tw_link_hashtag" value="1" <?php if (!empty($dg_tw_ft['link_hashtag'])) { echo 'checked'; }
function wpuxss_eml_enqueue_media() { global $wpuxss_eml_version, $wpuxss_eml_dir, $wp_version; if (!is_admin()) { return; } $screen = get_current_screen(); $media_library_mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid'; // taxonomies for passing to media uploader's filter $wpuxss_eml_taxonomies = get_option('wpuxss_eml_taxonomies'); if (empty($wpuxss_eml_taxonomies)) { $wpuxss_eml_taxonomies = array(); } $taxonomies_array = array(); foreach (get_object_taxonomies('attachment', 'object') as $taxonomy) { $terms_array = array(); $terms = array(); if ($wpuxss_eml_taxonomies[$taxonomy->name]['media_uploader_filter']) { ob_start(); wp_terms_checklist(0, array('taxonomy' => $taxonomy->name, 'checked_ontop' => false, 'walker' => new Walker_Media_Taxonomy_Uploader_Filter())); $html = ''; if (ob_get_contents() != false) { $html = ob_get_contents(); } ob_end_clean(); $terms = array_filter(explode('|', $html)); if (!empty($terms)) { foreach ($terms as $term) { $term = explode('>', $term); array_push($terms_array, array('term_id' => $term[0], 'term_name' => $term[1])); } $taxonomies_array[$taxonomy->name] = array('list_title' => $taxonomy->labels->all_items, 'term_list' => $terms_array); } } } // generic scripts wp_enqueue_script('wpuxss-eml-media-models-script', $wpuxss_eml_dir . 'js/eml-media-models.js', array('media-models'), $wpuxss_eml_version, true); wp_enqueue_script('wpuxss-eml-media-views-script', $wpuxss_eml_dir . 'js/eml-media-views.js', array('media-views'), $wpuxss_eml_version, true); wp_localize_script('wpuxss-eml-media-views-script', 'wpuxss_eml_taxonomies', $taxonomies_array); wp_localize_script('wpuxss-eml-media-views-script', 'wp_version', $wp_version); // scripts for grid view :: /wp-admin/upload.php if (isset($screen) && 'upload' === $screen->base && 'grid' === $media_library_mode) { wp_enqueue_script('wpuxss-eml-media-grid-script', $wpuxss_eml_dir . 'js/eml-media-grid.js', array('media'), $wpuxss_eml_version, true); } // scripts for Appearance -> Header if (isset($screen) && 'appearance_page_custom-header' === $screen->base) { wp_enqueue_script('wpuxss-eml-custom-header-script', $wpuxss_eml_dir . 'js/eml-custom-header.js', array('custom-header'), $wpuxss_eml_version, true); } // scripts for Appearance -> Background if (isset($screen) && 'appearance_page_custom-background' === $screen->base) { wp_enqueue_script('wpuxss-eml-custom-background-script', $wpuxss_eml_dir . 'js/eml-custom-background.js', array('custom-background'), $wpuxss_eml_version, true); } // scripts for /wp-admin/customize.php if (isset($screen) && 'customize' === $screen->base) { wp_enqueue_script('wpuxss-eml-customize-controls-script', $wpuxss_eml_dir . 'js/eml-customize-controls.js', array('customize-controls'), $wpuxss_eml_version, true); } }
/** * Outputs the categories HTML. * * @since 4.2.0 * @access public * * @param WP_Post $post Post object. */ public function categories_html($post) { $taxonomy = get_taxonomy('category'); if (current_user_can($taxonomy->cap->edit_terms)) { ?> <button type="button" class="add-cat-toggle button-subtle" aria-expanded="false"> <span class="dashicons dashicons-plus"></span><span class="screen-reader-text"><?php _e('Toggle add category'); ?> </span> </button> <div class="add-category is-hidden"> <label class="screen-reader-text" for="new-category"><?php echo $taxonomy->labels->add_new_item; ?> </label> <input type="text" id="new-category" class="add-category-name" placeholder="<?php echo esc_attr($taxonomy->labels->new_item_name); ?> " value="" aria-required="true"> <label class="screen-reader-text" for="new-category-parent"><?php echo $taxonomy->labels->parent_item_colon; ?> </label> <div class="postform-wrapper"> <?php wp_dropdown_categories(array('taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'new-category-parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —')); ?> </div> <button type="button" class="add-cat-submit"><?php _e('Add'); ?> </button> </div> <?php } ?> <div class="categories-search-wrapper"> <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e('Search categories by name'); ?> "> <label for="categories-search"> <span class="dashicons dashicons-search"></span><span class="screen-reader-text"><?php _e('Search categories'); ?> </span> </label> </div> <div aria-label="<?php esc_attr_e('Categories'); ?> "> <ul class="categories-select"> <?php wp_terms_checklist($post->ID, array('taxonomy' => 'category', 'list_only' => true)); ?> </ul> </div> <?php }
/** * Display metabox for email taxonomy type. * * Shows the term description in a list, rather than the term name itself. * * @since 2.5.0 * * @param WP_Post $post Post object. * @param array $box { * Tags meta box arguments. * * @type string $id Meta box ID. * @type string $title Meta box title. * @type callable $callback Meta box display callback. * } */ function bp_email_tax_type_metabox($post, $box) { $r = array('taxonomy' => bp_get_email_tax_type()); $tax_name = esc_attr($r['taxonomy']); $taxonomy = get_taxonomy($r['taxonomy']); ?> <div id="taxonomy-<?php echo $tax_name; ?> " class="categorydiv"> <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, 'walker' => new BP_Walker_Category_Checklist())); ?> </ul> </div> <p><?php esc_html_e('Choose when this email will be sent.', 'buddypress'); ?> </p> </div> <?php }
/** * 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(); }
function fwp_category_checklist($post_id = 0, $descendents_and_self = 0, $selected_cats = false, $params = array()) { if (is_string($params)) { $prefix = $params; $taxonomy = 'category'; } elseif (is_array($params)) { $prefix = isset($params['prefix']) ? $params['prefix'] : ''; $taxonomy = isset($params['taxonomy']) ? $params['taxonomy'] : 'category'; } $walker = new FeedWordPress_Walker_Category_Checklist($params); $walker->set_prefix($prefix); $walker->set_taxonomy($taxonomy); wp_terms_checklist($post_id, array('taxonomy' => $taxonomy, 'descendents_and_self' => $descendents_and_self, 'selected_cats' => $selected_cats, 'popular_cats' => false, 'walker' => $walker, 'checked_ontop' => true)); }
/** * Outputs the hidden row displayed when inline editing * * @since 3.1.0 * * @global string $mode */ public function inline_edit() { global $mode; $screen = $this->screen; $post = get_default_post_to_edit($screen->post_type); $post_type_object = get_post_type_object($screen->post_type); $taxonomy_names = get_object_taxonomies($screen->post_type); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); foreach ($taxonomy_names as $taxonomy_name) { $taxonomy = get_taxonomy($taxonomy_name); $show_in_quick_edit = $taxonomy->show_in_quick_edit; /** * Filter whether the current taxonomy should be shown in the Quick Edit panel. * * @since 4.2.0 * * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. * @param string $taxonomy_name Taxonomy name. * @param string $post_type Post type of current Quick Edit post. */ if (!apply_filters('quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type)) { continue; } if ($taxonomy->hierarchical) { $hierarchical_taxonomies[] = $taxonomy; } else { $flat_taxonomies[] = $taxonomy; } } $m = isset($mode) && 'excerpt' == $mode ? 'excerpt' : 'list'; $can_publish = current_user_can($post_type_object->cap->publish_posts); $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true); ?> <form method="get"><table style="display: none"><tbody id="inlineedit"> <?php $hclass = count($hierarchical_taxonomies) ? 'post' : 'page'; $bulk = 0; while ($bulk < 2) { ?> <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?> " class="inline-edit-row inline-edit-row-<?php echo "{$hclass} inline-edit-" . $screen->post_type; echo $bulk ? " bulk-edit-row bulk-edit-row-{$hclass} bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-{$hclass} inline-edit-{$screen->post_type}"; ?> " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?> " class="colspanchange"> <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> <h4><?php echo $bulk ? __('Bulk Edit') : __('Quick Edit'); ?> </h4> <?php if (post_type_supports($screen->post_type, 'title')) { if ($bulk) { ?> <div id="bulk-title-div"> <div id="bulk-titles"></div> </div> <?php } else { // $bulk ?> <label> <span class="title"><?php _e('Title'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> </label> <label> <span class="title"><?php _e('Slug'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> </label> <?php } // $bulk } // post_type_supports title ?> <?php if (!$bulk) { ?> <fieldset class="inline-edit-date"> <legend><span class="title"><?php _e('Date'); ?> </span></legend> <?php touch_time(1, 1, 0, 1); ?> </fieldset> <br class="clear" /> <?php } // $bulk if (post_type_supports($screen->post_type, 'author')) { $authors_dropdown = ''; if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) { $users_opt = array('hide_if_only_one_author' => false, 'who' => 'authors', 'name' => 'post_author', 'class' => 'authors', 'multi' => 1, 'echo' => 0); if ($bulk) { $users_opt['show_option_none'] = __('— No Change —'); } if ($authors = wp_dropdown_users($users_opt)) { $authors_dropdown = '<label class="inline-edit-author">'; $authors_dropdown .= '<span class="title">' . __('Author') . '</span>'; $authors_dropdown .= $authors; $authors_dropdown .= '</label>'; } } // authors ?> <?php if (!$bulk) { echo $authors_dropdown; } } // post_type_supports author if (!$bulk && $can_publish) { ?> <div class="inline-edit-group"> <label class="alignleft"> <span class="title"><?php _e('Password'); ?> </span> <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> </label> <em class="alignleft inline-edit-or"> <?php /* translators: Between password field and private checkbox on post quick edit interface */ _e('–OR–'); ?> </em> <label class="alignleft inline-edit-private"> <input type="checkbox" name="keep_private" value="private" /> <span class="checkbox-title"><?php _e('Private'); ?> </span> </label> </div> <?php } ?> </div></fieldset> <?php if (count($hierarchical_taxonomies) && !$bulk) { ?> <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <?php foreach ($hierarchical_taxonomies as $taxonomy) { ?> <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name); ?> </span> <input type="hidden" name="<?php echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?> " value="0" /> <ul class="cat-checklist <?php echo esc_attr($taxonomy->name); ?> -checklist"> <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)); ?> </ul> <?php } //$hierarchical_taxonomies as $taxonomy ?> </div></fieldset> <?php } // count( $hierarchical_taxonomies ) && !$bulk ?> <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <?php if (post_type_supports($screen->post_type, 'author') && $bulk) { echo $authors_dropdown; } if (post_type_supports($screen->post_type, 'page-attributes')) { if ($post_type_object->hierarchical) { ?> <label> <span class="title"><?php _e('Parent'); ?> </span> <?php $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column' => 'menu_order, post_title'); if ($bulk) { $dropdown_args['show_option_no_change'] = __('— No Change —'); } /** * Filter the arguments used to generate the Quick Edit page-parent drop-down. * * @since 2.7.0 * * @see wp_dropdown_pages() * * @param array $dropdown_args An array of arguments. */ $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args); wp_dropdown_pages($dropdown_args); ?> </label> <?php } // hierarchical if (!$bulk) { ?> <label> <span class="title"><?php _e('Order'); ?> </span> <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?> " /></span> </label> <?php } // !$bulk if ('page' == $screen->post_type) { ?> <label> <span class="title"><?php _e('Template'); ?> </span> <select name="page_template"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php /** This filter is documented in wp-admin/includes/meta-boxes.php */ $default_title = apply_filters('default_page_template_title', __('Default Template'), 'quick-edit'); ?> <option value="default"><?php echo esc_html($default_title); ?> </option> <?php page_template_dropdown(); ?> </select> </label> <?php } // page post_type } // page-attributes ?> <?php if (count($flat_taxonomies) && !$bulk) { ?> <?php foreach ($flat_taxonomies as $taxonomy) { ?> <?php if (current_user_can($taxonomy->cap->assign_terms)) { ?> <label class="inline-edit-tags"> <span class="title"><?php echo esc_html($taxonomy->labels->name); ?> </span> <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name); ?> ]" class="tax_input_<?php echo esc_attr($taxonomy->name); ?> "></textarea> </label> <?php } ?> <?php } //$flat_taxonomies as $taxonomy ?> <?php } // count( $flat_taxonomies ) && !$bulk ?> <?php if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) { if ($bulk) { ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <span class="title"><?php _e('Comments'); ?> </span> <select name="comment_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignright"> <span class="title"><?php _e('Pings'); ?> </span> <select name="ping_status"> <option value=""><?php _e('— No Change —'); ?> </option> <option value="open"><?php _e('Allow'); ?> </option> <option value="closed"><?php _e('Do not allow'); ?> </option> </select> </label> <?php } ?> </div> <?php } else { // $bulk ?> <div class="inline-edit-group"> <?php if (post_type_supports($screen->post_type, 'comments')) { ?> <label class="alignleft"> <input type="checkbox" name="comment_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Comments'); ?> </span> </label> <?php } if (post_type_supports($screen->post_type, 'trackbacks')) { ?> <label class="alignleft"> <input type="checkbox" name="ping_status" value="open" /> <span class="checkbox-title"><?php _e('Allow Pings'); ?> </span> </label> <?php } ?> </div> <?php } // $bulk } // post_type_supports comments or pings ?> <div class="inline-edit-group"> <label class="inline-edit-status alignleft"> <span class="title"><?php _e('Status'); ?> </span> <select name="_status"> <?php if ($bulk) { ?> <option value="-1"><?php _e('— No Change —'); ?> </option> <?php } // $bulk ?> <?php if ($can_publish) { // Contributors only get "Unpublished" and "Pending Review" ?> <option value="publish"><?php _e('Published'); ?> </option> <option value="future"><?php _e('Scheduled'); ?> </option> <?php if ($bulk) { ?> <option value="private"><?php _e('Private'); ?> </option> <?php } // $bulk ?> <?php } ?> <option value="pending"><?php _e('Pending Review'); ?> </option> <option value="draft"><?php _e('Draft'); ?> </option> </select> </label> <?php if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) { ?> <?php if ($bulk) { ?> <label class="alignright"> <span class="title"><?php _e('Sticky'); ?> </span> <select name="sticky"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="sticky"><?php _e('Sticky'); ?> </option> <option value="unsticky"><?php _e('Not Sticky'); ?> </option> </select> </label> <?php } else { // $bulk ?> <label class="alignleft"> <input type="checkbox" name="sticky" value="sticky" /> <span class="checkbox-title"><?php _e('Make this post sticky'); ?> </span> </label> <?php } // $bulk ?> <?php } // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?> </div> <?php if ($bulk && current_theme_supports('post-formats') && post_type_supports($screen->post_type, 'post-formats')) { $post_formats = get_theme_support('post-formats'); ?> <label class="alignleft"> <span class="title"><?php _ex('Format', 'post format'); ?> </span> <select name="post_format"> <option value="-1"><?php _e('— No Change —'); ?> </option> <option value="0"><?php echo get_post_format_string('standard'); ?> </option> <?php if (is_array($post_formats[0])) { foreach ($post_formats[0] as $format) { ?> <option value="<?php echo esc_attr($format); ?> "><?php echo esc_html(get_post_format_string($format)); ?> </option> <?php } } ?> </select></label> <?php } ?> </div></fieldset> <?php list($columns) = $this->get_column_info(); foreach ($columns as $column_name => $column_display_name) { if (isset($core_columns[$column_name])) { continue; } if ($bulk) { /** * Fires once for each column in Bulk Edit mode. * * @since 2.7.0 * * @param string $column_name Name of the column to edit. * @param WP_Post $post_type The post type slug. */ do_action('bulk_edit_custom_box', $column_name, $screen->post_type); } else { /** * Fires once for each column in Quick Edit mode. * * @since 2.7.0 * * @param string $column_name Name of the column to edit. * @param string $post_type The post type slug. */ do_action('quick_edit_custom_box', $column_name, $screen->post_type); } } ?> <p class="submit inline-edit-save"> <button type="button" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?> </button> <?php if (!$bulk) { wp_nonce_field('inlineeditnonce', '_inline_edit', false); ?> <button type="button" class="button-primary save alignright"><?php _e('Update'); ?> </button> <span class="spinner"></span> <?php } else { submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false); } ?> <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?> " /> <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?> " /> <?php if (!$bulk && !post_type_supports($screen->post_type, 'author')) { ?> <input type="hidden" name="post_author" value="<?php echo esc_attr($post->post_author); ?> " /> <?php } ?> <span class="error" style="display:none"></span> <br class="clear" /> </p> </td></tr> <?php $bulk++; } ?> </tbody></table></form> <?php }
/** * Show the Expiration Date options page */ function postExpiratorMenuGeneral() { if (isset($_POST['expirationdateSave']) && $_POST['expirationdateSave']) { if (!isset($_POST['_postExpiratorMenuGeneral_nonce']) || !wp_verify_nonce($_POST['_postExpiratorMenuGeneral_nonce'], 'postExpiratorMenuGeneral')) { print 'Form Validation Failure: Sorry, your nonce did not verify.'; exit; } else { //Filter Content $_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING); update_option('expirationdateDefaultDateFormat', $_POST['expired-default-date-format']); update_option('expirationdateDefaultTimeFormat', $_POST['expired-default-time-format']); update_option('expirationdateDisplayFooter', $_POST['expired-display-footer']); update_option('expirationdateFooterContents', $_POST['expired-footer-contents']); update_option('expirationdateFooterStyle', $_POST['expired-footer-style']); if (isset($_POST['expirationdate_category'])) { update_option('expirationdateCategoryDefaults', $_POST['expirationdate_category']); } update_option('expirationdateDefaultDate', $_POST['expired-default-expiration-date']); if ($_POST['expired-custom-expiration-date']) { update_option('expirationdateDefaultDateCustom', $_POST['expired-custom-expiration-date']); } echo "<div id='message' class='updated fade'><p>"; _e('Saved Options!', 'post-expirator'); echo "</p></div>"; } } // Get Option $expirationdateDefaultDateFormat = get_option('expirationdateDefaultDateFormat', POSTEXPIRATOR_DATEFORMAT); $expirationdateDefaultTimeFormat = get_option('expirationdateDefaultTimeFormat', POSTEXPIRATOR_TIMEFORMAT); $expireddisplayfooter = get_option('expirationdateDisplayFooter', POSTEXPIRATOR_FOOTERDISPLAY); $expirationdateFooterContents = get_option('expirationdateFooterContents', POSTEXPIRATOR_FOOTERCONTENTS); $expirationdateFooterStyle = get_option('expirationdateFooterStyle', POSTEXPIRATOR_FOOTERSTYLE); $expirationdateDefaultDate = get_option('expirationdateDefaultDate', POSTEXPIRATOR_EXPIREDEFAULT); $expirationdateDefaultDateCustom = get_option('expirationdateDefaultDateCustom'); $categories = get_option('expirationdateCategoryDefaults'); $expireddisplayfooterenabled = ''; $expireddisplayfooterdisabled = ''; if ($expireddisplayfooter == 0) { $expireddisplayfooterdisabled = 'checked="checked"'; } else { if ($expireddisplayfooter == 1) { $expireddisplayfooterenabled = 'checked="checked"'; } } ?> <p> <?php _e('The post expirator plugin sets a custom meta value, and then optionally allows you to select if you want the post changed to a draft status or deleted when it expires.', 'post-expirator'); ?> </p> <p> <?php _e('Valid [postexpirator] attributes:', 'post-expirator'); ?> <ul> <li><?php _e('type - defaults to full - valid options are full,date,time', 'post-expirator'); ?> </li> <li><?php _e('dateformat - format set here will override the value set on the settings page', 'post-expirator'); ?> </li> <li><?php _e('timeformat - format set here will override the value set on the settings page', 'post-expirator'); ?> </li> </ul> </p> <form method="post" id="expirationdate_save_options"> <?php wp_nonce_field('postExpiratorMenuGeneral', '_postExpiratorMenuGeneral_nonce'); ?> <h3><?php _e('Defaults', 'post-expirator'); ?> </h3> <table class="form-table"> <tr valign-"top"> <th scope="row"><label for="expired-default-date-format"><?php _e('Date Format:', 'post-expirator'); ?> </label></th> <td> <input type="text" name="expired-default-date-format" id="expired-default-date-format" value="<?php echo $expirationdateDefaultDateFormat; ?> " size="25" /> (<?php echo date_i18n("{$expirationdateDefaultDateFormat}"); ?> ) <br/> <?php _e('The default format to use when displaying the expiration date within a post using the [postexpirator] shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.', 'post-expirator'); ?> </td> </tr> <tr valign-"top"> <th scope="row"><label for="expired-default-time-format"><?php _e('Time Format:', 'post-expirator'); ?> </label></th> <td> <input type="text" name="expired-default-time-format" id="expired-default-time-format" value="<?php echo $expirationdateDefaultTimeFormat; ?> " size="25" /> (<?php echo date_i18n("{$expirationdateDefaultTimeFormat}"); ?> ) <br/> <?php _e('The default format to use when displaying the expiration time within a post using the [postexpirator] shortcode or within the footer. For information on valid formatting options, see: <a href="http://us2.php.net/manual/en/function.date.php" target="_blank">PHP Date Function</a>.', 'post-expirator'); ?> </td> </tr> <tr valign-"top"> <th scope="row"><label for="expired-default-expiration-date"><?php _e('Default Date/Time Duration:', 'post-expirator'); ?> </label></th> <td> <select name="expired-default-expiration-date" id="expired-default-expiration-date" onchange="expirationdate_toggle_defaultdate(this)"> <option value="null" <?php echo $expirationdateDefaultDate == 'null' ? ' selected="selected"' : ''; ?> ><?php _e('None', 'post-expirator'); ?> </option> <option value="custom" <?php echo $expirationdateDefaultDate == 'custom' ? ' selected="selected"' : ''; ?> ><?php _e('Custom', 'post-expirator'); ?> </option> <option value="publish" <?php echo $expirationdateDefaultDate == 'publish' ? ' selected="selected"' : ''; ?> ><?php _e('Post/Page Publish Time', 'post-expirator'); ?> </option> </select> <br/> <?php _e('Set the default expiration date to be used when creating new posts and pages. Defaults to none.', 'post-expirator'); ?> <?php $show = $expirationdateDefaultDate == 'custom' ? 'block' : 'none'; ?> <div id="expired-custom-container" style="display: <?php echo $show; ?> ;"> <br/><label for="expired-custom-expiration-date">Custom:</label> <input type="text" value="<?php echo $expirationdateDefaultDateCustom; ?> " name="expired-custom-expiration-date" id="expired-custom-expiration-date" /> <br/> <?php _e('Set the custom value to use for the default expiration date. For information on formatting, see <a href="http://php.net/manual/en/function.strtotime.php">PHP strtotime function</a>. For example, you could enter "+1 month" or "+1 week 2 days 4 hours 2 seconds" or "next Thursday."', 'post-expirator'); ?> </div> </td> </tr> </table> <h3><?php _e('Category Expiration', 'post-expirator'); ?> </h3> <table class="form-table"> <tr valign-"top"> <th scope="row"><?php _e('Default Expiration Category', 'post-expirator'); ?> :</th> <td> <?php echo '<div class="wp-tab-panel" id="post-expirator-cat-list">'; echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">'; $walker = new Walker_PostExpirator_Category_Checklist(); wp_terms_checklist(0, array('taxonomy' => 'category', 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false)); echo '</ul>'; echo '</div>'; ?> <br/> <?php _e("Set's the default expiration category for the post.", 'post-expirator'); ?> </td> </tr> </table> <h3><?php _e('Post Footer Display', 'post-expirator'); ?> </h3> <p><?php _e('Enabling this below will display the expiration date automatically at the end of any post which is set to expire.', 'post-expirator'); ?> </p> <table class="form-table"> <tr valign-"top"> <th scope="row"><?php _e('Show in post footer?', 'post-expirator'); ?> </th> <td> <input type="radio" name="expired-display-footer" id="expired-display-footer-true" value="1" <?php echo $expireddisplayfooterenabled; ?> /> <label for="expired-display-footer-true"><?php _e('Enabled', 'post-expirator'); ?> </label> <input type="radio" name="expired-display-footer" id="expired-display-footer-false" value="0" <?php echo $expireddisplayfooterdisabled; ?> /> <label for="expired-display-footer-false"><?php _e('Disabled', 'post-expirator'); ?> </label> <br/> <?php _e('This will enable or disable displaying the post expiration date in the post footer.', 'post-expirator'); ?> </td> </tr> <tr valign-"top"> <th scope="row"><label for="expired-footer-contents"><?php _e('Footer Contents:', 'post-expirator'); ?> </label></th> <td> <textarea id="expired-footer-contents" name="expired-footer-contents" rows="3" cols="50"><?php echo $expirationdateFooterContents; ?> </textarea> <br/> <?php _e('Enter the text you would like to appear at the bottom of every post that will expire. The following placeholders will be replaced with the post expiration date in the following format:', 'post-expirator'); ?> <ul> <li>EXPIRATIONFULL -> <?php echo date_i18n("{$expirationdateDefaultDateFormat} {$expirationdateDefaultTimeFormat}"); ?> </li> <li>EXPIRATIONDATE -> <?php echo date_i18n("{$expirationdateDefaultDateFormat}"); ?> </li> <li>EXPIRATIONTIME -> <?php echo date_i18n("{$expirationdateDefaultTimeFormat}"); ?> </li> </ul> </td> </tr> <tr valign-"top"> <th scope="row"><label for="expired-footer-style"><?php _e('Footer Style:', 'post-expirator'); ?> </label></th> <td> <input type="text" name="expired-footer-style" id="expired-footer-style" value="<?php echo $expirationdateFooterStyle; ?> " size="25" /> (<span style="<?php echo $expirationdateFooterStyle; ?> "><?php _e('This post will expire on', 'post-expirator'); ?> <?php echo date_i18n("{$expirationdateDefaultDateFormat} {$expirationdateDefaultTimeFormat}"); ?> </span>) <br/> <?php _e('The inline css which will be used to style the footer text.', 'post-expirator'); ?> </td> </tr> </table> <p class="submit"> <input type="submit" name="expirationdateSave" class="button-primary" value="<?php _e('Save Changes', 'post-expirator'); ?> " /> </p> </form> <?php }