function prepare_items()
 {
     $all_categories = array();
     $taxonomies = get_taxonomies($args = array('public' => true, '_builtin' => false));
     $taxonomies['category'] = 'category';
     $all_terms = get_terms($taxonomies, 'orderby=count&hide_empty=0&order=DESC');
     $totalitems = count($all_terms);
     $perpage = 100;
     $paged = !empty($_GET["paged"]) ? sanitize_text_field($_GET["paged"]) : '';
     if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
         $paged = 1;
     }
     $totalpages = ceil($totalitems / $perpage);
     $offset = 0;
     if (!empty($paged) && !empty($perpage)) {
         $offset = ($paged - 1) * $perpage;
     }
     for ($i = $offset; $i < (int) $offset + (int) $perpage && !empty($all_terms[$i]); $i++) {
         $all_categories[] = $all_terms[$i];
     }
     $this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $perpage));
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $this->items = $all_categories;
 }
	function post_types($categoryId=false){

		$ret='';
		/*получаем все пользовательские типы записей*/
        $post_types=get_post_types(array(
			'public' => true,
			'_builtin' => false,
		), 'objects'); 
		foreach ($post_types as $post_type) {
		  $ret .= '<strong>'. $post_type->labels->singular_name. '</strong>';
		  $ret .= '<p class="news-yandex-ru-description">выберите рубрики посты из которых выводить в rss для яндекса. У выбранной рубрики в фид также будут включены все записи дочерних ей рубрик.</p>';
		  $ret .= '<p>';
		  /*получаем все иерархические taxonomies для типа записи*/
		  $taxonomies=get_taxonomies(array(
			'hierarchical' => true,
		    'public' => true,
			'_builtin' => false,
			'object_type' => array($post_type->name),
		  ), 'objects');
		  foreach ($taxonomies as $taxonomy) {
		    $ret .= $this->taxonomies(0, $taxonomy->name, $post_type->name);
		  }
		  $ret .= '</p>';
		}
    	return $ret;
		
    }
 /**
  *
  * @return array;
  */
 public function getPicklistOptions()
 {
     $tax_args = array('public' => true, '_builtin' => false);
     $taxonomies = get_taxonomies($tax_args);
     $taxonomies[] = 'category';
     $args = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => $taxonomies, 'pad_counts' => true);
     $categories = get_categories($args);
     $children = array();
     if ($categories) {
         foreach ($categories as $v) {
             $v->title = $v->cat_name;
             $v->parent_id = $v->category_parent;
             $v->id = $v->cat_ID;
             $pt = $v->category_parent;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     //treecurse function from functions.php
     $list = treerecurse($children);
     $mitems = array();
     foreach ($list as $item) {
         $mitems[$item->id] = $item->treename;
     }
     return $mitems;
 }
Example #4
0
 public function filter_content($content)
 {
     // Get Templates
     $templates = self::get_option('rwp_templates');
     $terms = wp_get_object_terms(get_the_ID(), array_keys(get_taxonomies()));
     $terms_keys = array();
     foreach ($terms as $term) {
         $terms_keys[$term->taxonomy][] = $term->term_id;
     }
     //self::pretty_print( $terms_keys );
     foreach ($templates as $template) {
         if (isset($template['template_auto_reviews']) && !empty($template['template_auto_reviews'])) {
             if (is_singular($template['template_auto_reviews']) && is_main_query()) {
                 if (isset($template['template_exclude_terms'])) {
                     $to_exclude = false;
                     foreach ($template['template_exclude_terms'] as $id) {
                         $i = explode('-', $id);
                         if (in_array($i[1], $terms_keys[$i[0]])) {
                             $to_exclude = true;
                             break;
                         }
                     }
                     if ($to_exclude) {
                         continue;
                     }
                 }
                 $new_content = '[rwp-review id="-1" template="' . $template['template_id'] . '"]';
                 $content .= $new_content;
             }
         }
     }
     return $content;
 }
Example #5
0
 protected function getTaxonomies($args = [])
 {
     $defaults = ['show_ui' => true];
     $args = wp_parse_args($args, $defaults);
     $taxonomies = get_taxonomies(apply_filters('g5_assignments_get_taxonomies_args', $args), 'object');
     return $taxonomies;
 }
Example #6
0
 /**
  * Get a definitive set of all taxonomies recognized by Types.
  *
  * Respects if some builtin taxonomy is overridden by Types.
  *
  * @return array
  * @since 1.9
  */
 public static function get_all_taxonomies()
 {
     // todo add simple caching
     $taxonomies = array();
     // Read Types taxonomies first.
     $types_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
     if (is_array($types_taxonomies)) {
         foreach ($types_taxonomies as $slug => $data) {
             $taxonomies[$slug] = $data;
         }
     }
     // Get all taxonomies and add them to the set, but avoid overwriting Types taxonomies
     $all_taxonomies = self::object_to_array_deep(get_taxonomies(array('public' => true), 'objects'));
     foreach ($all_taxonomies as $slug => $data) {
         // check if taxonomies are already saved as custom taxonomies
         if (isset($taxonomies[$slug])) {
             continue;
         }
         if (!isset($data['slug'])) {
             $data['slug'] = $slug;
         }
         $taxonomies[$slug] = $data;
     }
     return $taxonomies;
 }
Example #7
0
 public function column()
 {
     global $wp_version;
     $is_wp_v3_1 = version_compare($wp_version, '3.0.999', '>');
     add_filter('manage_media_columns', array($this, 'add'));
     add_action('manage_media_custom_column', array($this, 'value'), 10, 2);
     add_filter('manage_link-manager_columns', array($this, 'add'));
     add_action('manage_link_custom_column', array($this, 'value'), 10, 2);
     add_action('manage_edit-link-categories_columns', array($this, 'add'));
     add_filter('manage_link_categories_custom_column', array($this, 'returnvalue'), 10, 3);
     foreach (get_taxonomies() as $taxonomy) {
         add_action("manage_edit-{$taxonomy}_columns", array($this, 'add'));
         add_filter("manage_{$taxonomy}_custom_column", array($this, 'returnvalue'), 10, 3);
         if ($is_wp_v3_1) {
             add_filter("manage_edit-{$taxonomy}_sortable_columns", array($this, 'add'));
         }
     }
     foreach (get_post_types() as $post_type) {
         add_action("manage_edit-{$post_type}_columns", array($this, 'add'));
         add_filter("manage_{$post_type}_posts_custom_column", array($this, 'value'), 10, 3);
         if ($is_wp_v3_1) {
             add_filter("manage_edit-{$post_type}_sortable_columns", array($this, 'add'));
         }
     }
     add_action('manage_users_columns', array($this, 'add'));
     add_filter('manage_users_custom_column', array($this, 'returnvalue'), 10, 3);
     if ($is_wp_v3_1) {
         add_filter("manage_users_sortable_columns", array($this, 'add'));
     }
     add_action('manage_edit-comments_columns', array($this, 'add'));
     add_action('manage_comments_custom_column', array($this, 'value'), 10, 2);
     if ($is_wp_v3_1) {
         add_filter("manage_edit-comments_sortable_columns", array($this, 'add'));
     }
 }
Example #8
0
function wptouch_register_theme_custom_post_types()
{
    if (wptouch_is_mobile_theme_showing()) {
        $settings = foundation_get_settings();
        $post_types_to_preserve = get_option('wptouch_custom_post_types');
        $post_types_to_register = array();
        $registered_types = wptouch_custom_posts_get_list(true);
        if (is_array($post_types_to_preserve) && count($post_types_to_preserve) > 0) {
            foreach ($post_types_to_preserve as $type => $object) {
                if (!is_object($object)) {
                    $object = maybe_unserialize(urldecode($object));
                }
                if (!in_array($type, $registered_types)) {
                    $args = array('labels' => array('name' => $object->labels->name, 'singular_name' => $object->labels->singular_name), 'taxonomies' => $object->taxonomies, 'hierarchical' => $object->hierarchical, 'public' => $object->public, 'has_archive' => $object->has_archive, 'exclude_from_search' => $object->exclude_from_search, 'publicly_queryable' => $object->publicly_queryable, 'rewrite' => $object->rewrite, 'query_var' => $object->query_var);
                    register_post_type($type, $args);
                }
            }
        }
        $taxonomies_to_preserve = get_option('wptouch_custom_taxonomies');
        $taxonomies_to_register = array();
        $args = array('public' => true);
        $output = 'names';
        $registered_taxonomies = get_taxonomies($args, $output);
        if (is_array($taxonomies_to_preserve)) {
            foreach ($taxonomies_to_preserve as $taxonomy => $object) {
                if (!in_array($taxonomy, $registered_taxonomies)) {
                    $args = array('hierarchical' => $object->hierarchical, 'query_var' => $object->query_var, 'rewrite' => $object->rewrite);
                    register_taxonomy($taxonomy, $object->object_type, $args);
                }
            }
        }
    }
}
 public function display_field($field, $group_index = 1, $field_index = 1)
 {
     global $mf_domain;
     // If is not required this field be added a None value
     $notype = "";
     if (!$field['required_field']) {
         $notype = !empty($field['options']['notype']) ? $field['options']['notype'] : __("-- None --", $mf_domain);
     }
     $output = '';
     // Get the taxonomie as dropdownoption
     $select = array();
     $tax = get_taxonomies();
     foreach ($tax as $k => $v) {
         $select[] = $v;
     }
     $option_from_term_array = $field['options']['term'];
     $options = get_terms($select[$option_from_term_array], array('hide_empty' => false));
     $output = '<div class="mf-dropdown-box">';
     $value = $field['input_value'];
     $output .= sprintf('<select class="dropdown_mf" id="%s" name="%s" >', $field['input_id'], $field['input_name']);
     if ($notype != "") {
         $output .= "<option value=''>{$notype}</option>";
     }
     foreach ($options as $option) {
         $check = $option->slug == $value ? 'selected="selected"' : '';
         $output .= sprintf('<option value="%s" %s >%s</option>', esc_attr($option->slug), $check, esc_attr($option->name));
     }
     $output .= '</select>';
     $output .= '</div>';
     return $output;
 }
Example #10
0
 function easy_wp_pagenavigation_set_posts_per_page($query)
 {
     if (is_admin()) {
         return;
     }
     $options = get_option(EWPN_ST);
     // Get taxonomies custom posts per page
     $args = array('public' => true, 'show_ui' => true);
     $taxonomies = get_taxonomies($args);
     if (!empty($taxonomies)) {
         foreach ($taxonomies as $key => $val) {
             if (isset($options[$key]) && !empty($options[$key]) && is_numeric($options[$key])) {
                 if ($key == 'category') {
                     if (is_category() && $query->is_main_query()) {
                         $query->set('posts_per_page', $options[$key]);
                     }
                 } elseif ($key == 'post_tag') {
                     if (is_tag() && $query->is_main_query()) {
                         $query->set('posts_per_page', $options[$key]);
                     }
                 } else {
                     if (is_tax($key) && $query->is_main_query()) {
                         $query->set('posts_per_page', $options[$key]);
                     }
                 }
             }
         }
     }
 }
 /**
  * Initialization function, similar to __construct()
  *
  * @since 0.1
  */
 public static function initialize()
 {
     self::$wp_4dot0_plus = version_compare(get_bloginfo('version'), '4.0', '>=');
     /*
      * Set up the Media/Assistant submenu table column definitions
      */
     $taxonomies = get_taxonomies(array('show_ui' => true), 'names');
     foreach ($taxonomies as $tax_name) {
         if (MLACore::mla_taxonomy_support($tax_name)) {
             $tax_object = get_taxonomy($tax_name);
             self::$default_columns['t_' . $tax_name] = esc_html($tax_object->labels->name);
             self::$default_hidden_columns[] = 't_' . $tax_name;
             // self::$default_sortable_columns [] = none at this time
         }
         // supported taxonomy
     }
     // foreach $tax_name
     /*
      * For WP 4.3+ icon will be merged with the first visible preferred column
      */
     if (MLATest::$wp_4dot3_plus) {
         unset(self::$default_columns['icon']);
     }
     self::$default_columns = array_merge(self::$default_columns, MLACore::mla_custom_field_support('default_columns'));
     self::$default_hidden_columns = array_merge(self::$default_hidden_columns, MLACore::mla_custom_field_support('default_hidden_columns'));
     self::$default_sortable_columns = array_merge(self::$default_sortable_columns, MLACore::mla_custom_field_support('default_sortable_columns'));
 }
 /**
  * Adds Custom Field support to the Edit Media screen.
  * Declared public because it is an action.
  *
  * @since 0.80
  *
  * @return	void	echoes the HTML markup for the label and value
  */
 public static function mla_admin_init_action()
 {
     static $mc_att_category_metabox = array();
     /*
      * Enable the enhanced "Media Categories" searchable metaboxes for hiearchical taxonomies
      */
     if (class_exists('Media_Categories') && ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX) || 'checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX))) {
         $taxonomies = get_taxonomies(array('show_ui' => true), 'objects');
         foreach ($taxonomies as $key => $value) {
             if (MLAOptions::mla_taxonomy_support($key)) {
                 if ($value->hierarchical) {
                     if ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_CATEGORY_METABOX)) {
                         $mc_att_category_metabox[] = new Media_Categories($key);
                     }
                 } else {
                     if ('checked' == MLAOptions::mla_get_option(MLAOptions::MLA_MEDIA_MODAL_DETAILS_TAG_METABOX)) {
                         $mc_att_category_metabox[] = new Media_Categories($key);
                     }
                 }
                 // flat
             }
             // is supported
         }
         // foreach
     }
     // class_exists
     add_post_type_support('attachment', 'custom-fields');
 }
function sandwich_tag_cloud_widget_shortcode($attr, $content)
{
    $default = '';
    foreach (get_taxonomies() as $taxonomy) {
        $tax = get_taxonomy($taxonomy);
        if (!$tax->show_tagcloud || empty($tax->labels->name)) {
            continue;
        }
        $default = esc_attr($taxonomy);
        break;
    }
    $attr = wp_parse_args($attr, array('title' => __('Tag Cloud', 'pbsandwich'), 'taxonomy' => $default, 'hide_title' => false));
    $hideTitleClass = '';
    if ($attr['hide_title']) {
        $hideTitleClass = 'hide_title';
    }
    ob_start();
    ?>
	<div class="sandwich <?php 
    echo $hideTitleClass;
    ?>
">
		<?php 
    the_widget('WP_Widget_Tag_Cloud', $attr);
    ?>
	</div>
	
	<?php 
    return ob_get_clean();
}
function taxonomy_slug_rewrite($wp_rewrite)
{
    $rules = array();
    // get all custom taxonomies
    $taxonomies = get_taxonomies(array('_builtin' => false), 'objects');
    // get all custom post types
    $post_types = get_post_types(array('public' => true, '_builtin' => false), 'objects');
    foreach ($post_types as $post_type) {
        foreach ($taxonomies as $taxonomy) {
            // go through all post types which this taxonomy is assigned to
            foreach ($taxonomy->object_type as $object_type) {
                // check if taxonomy is registered for this custom type
                if ($object_type == $post_type->rewrite['slug']) {
                    // get category objects
                    $terms = get_categories(array('type' => $object_type, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
                    // make rules
                    foreach ($terms as $term) {
                        $rules[$object_type . '/' . $term->slug . '/?$'] = 'index.php?' . $term->taxonomy . '=' . $term->slug;
                    }
                }
            }
        }
    }
    // merge with global rules
    $wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
Example #15
0
 public function parse_request($qty, $request = array())
 {
     if (is_null($qty)) {
         $qty = Utils::instance()->get_qty_from_range(Variable::super(INPUT_POST, array(Plugin::$slug, 'qty'), FILTER_UNSAFE_RAW));
     }
     if (0 === $qty) {
         return esc_attr__('Zero is not a good number of terms to fake...', 'fakerpress');
     }
     $name_size = Variable::super(INPUT_POST, array(Plugin::$slug, 'size'), FILTER_UNSAFE_RAW);
     // Fetch taxomies
     $taxonomies = Variable::super($request, array('taxonomies'), FILTER_SANITIZE_STRING);
     $taxonomies = array_map('trim', explode(',', $taxonomies));
     $taxonomies = array_intersect(get_taxonomies(array('public' => true)), $taxonomies);
     // Only has meta after 4.4-beta
     $has_metas = version_compare($GLOBALS['wp_version'], '4.4-beta', '>=');
     if ($has_metas) {
         $metas = Variable::super($request, array('meta'), FILTER_UNSAFE_RAW);
     }
     for ($i = 0; $i < $qty; $i++) {
         $this->set('taxonomy', $taxonomies);
         $this->set('name', $name_size);
         $this->set('description');
         $this->set('parent_term');
         $term_id = $this->generate()->save();
         if ($has_metas && $term_id && is_numeric($term_id)) {
             foreach ($metas as $meta_index => $meta) {
                 Meta::instance()->object($term_id, 'term')->generate($meta['type'], $meta['name'], $meta)->save();
             }
         }
         $results[] = $term_id;
     }
     $results = array_filter((array) $results, 'absint');
     return $results;
 }
 function wp_dropdown_taxonomies($args = '')
 {
     $defaults = array('selected' => 0, 'echo' => 1, 'name' => 'taxonomy', 'id' => '', 'class' => '', 'show_option_none' => '', 'show_option_no_change' => '', 'option_none_value' => '');
     $r = wp_parse_args($args, $defaults);
     extract($r, EXTR_SKIP);
     $taxonomies = get_taxonomies(array('public' => true, 'show_ui' => true), 'objects');
     $output = '';
     // Back-compat with old system where both id and name were based on $name argument
     if (empty($id)) {
         $id = $name;
     }
     if (!empty($taxonomies)) {
         $output = "<select name='" . esc_attr($name) . "' id='" . esc_attr($id) . "' class='" . esc_attr($class) . "'>\n";
         if ($show_option_no_change) {
             $output .= "\t<option value=\"-1\">{$show_option_no_change}</option>";
         }
         if ($show_option_none) {
             $output .= "\t<option value=\"" . esc_attr($option_none_value) . "\">{$show_option_none}</option>\n";
         }
         foreach ($taxonomies as $tax_name => $taxonomy) {
             $output .= sprintf("\t" . '<option value="%s" %s>%s</option>' . "\n", esc_attr($tax_name), selected($r['selected'], $tax_name, false), $taxonomy->label);
         }
         $output .= "</select>\n";
     }
     $output = apply_filters('wp_dropdown_taxonomies', $output);
     if ($echo) {
         echo $output;
     }
     return $output;
 }
 /**
  * Registers Attachment Categories and Attachment Tags custom taxonomies, adds taxonomy-related filters
  *
  * @since 0.1
  *
  * @return	void
  */
 private static function _build_taxonomies()
 {
     if (MLAOptions::mla_taxonomy_support('attachment_category')) {
         $labels = array('name' => _x('Att. Categories', 'taxonomy general name'), 'singular_name' => _x('Att. Category', 'taxonomy singular name'), 'search_items' => __('Search Att. Categories'), 'all_items' => __('All Att. Categories'), 'parent_item' => __('Parent Att. Category'), 'parent_item_colon' => __('Parent Att. Category:'), 'edit_item' => __('Edit Att. Category'), 'update_item' => __('Update Att. Category'), 'add_new_item' => __('Add New Att. Category'), 'new_item_name' => __('New Att. Category Name'), 'menu_name' => __('Att. Category'));
         register_taxonomy('attachment_category', array('attachment'), array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => true));
     }
     if (MLAOptions::mla_taxonomy_support('attachment_tag')) {
         $labels = array('name' => _x('Att. Tags', 'taxonomy general name'), 'singular_name' => _x('Att. Tag', 'taxonomy singular name'), 'search_items' => __('Search Att. Tags'), 'all_items' => __('All Att. Tags'), 'parent_item' => __('Parent Att. Tag'), 'parent_item_colon' => __('Parent Att. Tag:'), 'edit_item' => __('Edit Att. Tag'), 'update_item' => __('Update Att. Tag'), 'add_new_item' => __('Add New Att. Tag'), 'new_item_name' => __('New Att. Tag Name'), 'menu_name' => __('Att. Tag'));
         register_taxonomy('attachment_tag', array('attachment'), array('hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => true));
     }
     $taxonomies = get_taxonomies(array('show_ui' => true), 'names');
     foreach ($taxonomies as $tax_name) {
         if (MLAOptions::mla_taxonomy_support($tax_name)) {
             register_taxonomy_for_object_type($tax_name, 'attachment');
             if ('checked' == MLAOptions::mla_get_option('attachments_column')) {
                 add_filter("manage_edit-{$tax_name}_columns", 'MLAObjects::mla_taxonomy_get_columns_filter', 10, 1);
                 // $columns
                 add_filter("manage_{$tax_name}_custom_column", 'MLAObjects::mla_taxonomy_column_filter', 10, 3);
                 // $place_holder, $column_name, $tag->term_id
             }
             // option is checked
         }
         // taxonomy support
     }
     // foreach
 }
    /**
     * @param array $instance
     */
    public function form($instance)
    {
        $current_taxonomy = $this->_get_current_taxonomy($instance);
        $title_id = $this->get_field_id('title');
        $instance['title'] = !empty($instance['title']) ? esc_attr($instance['title']) : '';
        echo '<p><label for="' . $title_id . '">' . __('Title:') . '</label>
			<input type="text" class="widefat" id="' . $title_id . '" name="' . $this->get_field_name('title') . '" value="' . $instance['title'] . '" />
		</p>';
        $taxonomies = get_taxonomies(array('show_tagcloud' => true), 'object');
        $id = $this->get_field_id('taxonomy');
        $name = $this->get_field_name('taxonomy');
        $input = '<input type="hidden" id="' . $id . '" name="' . $name . '" value="%s" />';
        switch (count($taxonomies)) {
            // No tag cloud supporting taxonomies found, display error message
            case 0:
                echo '<p>' . __('The tag cloud will not be displayed since their are no taxonomies that support the tag cloud widget.') . '</p>';
                printf($input, '');
                break;
                // Just a single tag cloud supporting taxonomy found, no need to display options
            // Just a single tag cloud supporting taxonomy found, no need to display options
            case 1:
                $keys = array_keys($taxonomies);
                $taxonomy = reset($keys);
                printf($input, esc_attr($taxonomy));
                break;
                // More than one tag cloud supporting taxonomy found, display options
            // More than one tag cloud supporting taxonomy found, display options
            default:
                printf('<p><label for="%1$s">%2$s</label>' . '<select class="widefat" id="%1$s" name="%3$s">', $id, __('Taxonomy:'), $name);
                foreach ($taxonomies as $taxonomy => $tax) {
                    printf('<option value="%s"%s>%s</option>', esc_attr($taxonomy), selected($taxonomy, $current_taxonomy, false), $tax->labels->name);
                }
                echo '</select></p>';
        }
    }
Example #19
0
function tf_get_taxonomies()
{
    $args = array('hierarchical' => TRUE, 'public' => TRUE, 'show_ui' => TRUE, '_builtin' => FALSE);
    $args = apply_filters('tf_get_taxonomies', $args);
    $taxonomies = get_taxonomies($args);
    return $taxonomies;
}
Example #20
0
 public static function getTaxonomyNames()
 {
     if (empty(static::$__taxonomyNames)) {
         static::$__taxonomyNames = get_taxonomies(null, 'names', 'and');
     }
     return static::$__taxonomyNames;
 }
Example #21
0
 public function __construct()
 {
     if (is_admin()) {
         // we need it for all data flexor taxonomies
         $ay_df_taxonomies = array();
         $taxonomies = get_taxonomies();
         foreach ($taxonomies as $taxonomy) {
             if ($this->endswith($taxonomy, '_dftype')) {
                 $ay_df_taxonomies[] = $taxonomy;
             }
         }
         /* 
          * configure your meta box
          */
         $config = array('id' => 'df_meta_box', 'title' => 'Data Flexor', 'pages' => $ay_df_taxonomies, 'context' => 'normal', 'fields' => array(), 'local_images' => false, 'use_with_theme' => false);
         /*
          * Initiate your meta box
          */
         $my_meta = new Tax_Meta_Class($config);
         //text field
         $my_meta->addText('df_custom_class', array('name' => __('Custom Class Name ', 'tax-meta'), 'desc' => 'Complete if using a dataflexor custom class for display'));
         //checkbox field
         $my_meta->addCheckbox('df_bp_post_activity', array('name' => 'Post in activity stream '));
         /*
          * Don't Forget to Close up the meta box decleration
          */
         //Finish Meta Box Decleration
         $my_meta->Finish();
     }
 }
 public static function get_term_query_from_array_of_ids($args)
 {
     $ret = new stdClass();
     $ret->taxonomies = get_taxonomies();
     $ret->args['include'] = $args;
     return $ret;
 }
Example #23
0
/**
 * Add Custom Post Types and Taxonomies to "At a Glance" Dashboard Widget
 *
 * Ref Link: http://wpsnipp.com/index.php/functions-php/include-custom-post-types-in-right-now-admin-dashboard-widget/
 * http://wordpress.org/support/topic/dashboard-at-a-glance-custom-post-types
 * http://halfelf.org/2012/my-custom-posttypes-live-in-mu/
 */
function seventeen_right_now_content_table_end()
{
    $args = array('public' => true, '_builtin' => false);
    $output = 'object';
    $operator = 'and';
    $post_types = get_post_types($args, $output, $operator);
    foreach ($post_types as $post_type) {
        $num_posts = wp_count_posts($post_type->name);
        $num = number_format_i18n($num_posts->publish);
        $text = _n($post_type->labels->name, $post_type->labels->name, intval($num_posts->publish));
        if (current_user_can('edit_posts')) {
            $cpt_name = $post_type->name;
        }
        echo '<li class="post-count ' . $post_type->name . '-count"><tr><a href="edit.php?post_type=' . $cpt_name . '"><td class="first b b-' . $post_type->name . '"></td>' . $num . '&nbsp;<td class="t ' . $post_type->name . '">' . $text . '</td></a></tr></li>';
    }
    $taxonomies = get_taxonomies($args, $output, $operator);
    foreach ($taxonomies as $taxonomy) {
        $num_terms = wp_count_terms($taxonomy->name);
        $num = number_format_i18n($num_terms);
        $text = _n($taxonomy->labels->name, $taxonomy->labels->name, intval($num_terms));
        if (current_user_can('manage_categories')) {
            $cpt_tax = $taxonomy->name;
        }
        echo '<li class="taxonomy-count ' . $taxonomy->name . '-count"><tr><a href="edit-tags.php?taxonomy=' . $cpt_tax . '"><td class="first b b-' . $taxonomy->name . '"></td>' . $num . '&nbsp;<td class="t ' . $taxonomy->name . '">' . $text . '</td></a></tr></li>';
    }
}
Example #24
0
function taxonomy_slug_rewrite($wp_rewrite)
{
    /* Initialize array to hold rules */
    $rules = array();
    /* Get all custom taxonomies */
    $taxonomies = get_taxonomies(array('_builtin' => false), 'objects');
    /* Get all custom post types */
    $post_types = getDivisionPostTypes();
    /* Loop through custom post types */
    foreach ($post_types as $post_type) {
        /* Loop through custom taxonomies */
        foreach ($taxonomies as $taxonomy) {
            /* Loop through objects this taxonomy is assigned to */
            foreach ($taxonomy->object_type as $object_type) {
                /* Replace underscores with hyphens */
                $regex_object_type = preg_replace('/_/i', '-', $object_type);
                /* If the object type (with hyphens) is equal to the slug for a post type, do stuff */
                if ($regex_object_type == $post_type->rewrite['slug']) {
                    /* Get all terms for this taxonomy */
                    $terms = get_categories(array('type' => $object_type, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
                    /* For each term, do stuff */
                    foreach ($terms as $term) {
                        /* Add a rewrite rule for each term that uses the post type slug */
                        $rules[$regex_object_type . '/category/' . $term->slug . '/?$'] = 'index.php?' . 'taxonomy=' . $term->taxonomy . '&term=' . $term->slug;
                    }
                }
            }
        }
    }
    /* Add custom rules to WordPress rewrite rules */
    $wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
 public static function wpml_get_table_taxonomies()
 {
     global $sitepress;
     remove_all_filters('gettext_with_context', -1000);
     remove_all_filters('gettext', -1000);
     $taxonomies = get_taxonomies(array(), 'objects');
     $result = array("taxonomies" => array(), "activeLanguages" => array());
     $sitepress->set_admin_language();
     $active_langs = $sitepress->get_active_languages();
     $default_lang = $sitepress->get_default_language();
     foreach ($active_langs as $code => $lang) {
         if (is_array($lang) && isset($lang['display_name'])) {
             $result["activeLanguages"][$code] = array("label" => $lang['display_name']);
         }
     }
     if (isset($active_langs[$default_lang])) {
         $def_lang = $active_langs[$default_lang];
         $result["activeLanguages"] = array($default_lang => array("label" => $def_lang['display_name'])) + $result["activeLanguages"];
     }
     foreach ($taxonomies as $key => $tax) {
         if ($sitepress->is_translated_taxonomy($key)) {
             $result["taxonomies"][$key] = array("label" => $tax->label, "singularLabel" => $tax->labels->singular_name, "hierarchical" => $tax->hierarchical, "name" => $key);
         }
     }
     wp_send_json($result);
 }
 public static function add_rewrite_rules($rules)
 {
     //Get taxonomies
     $taxonomies = get_taxonomies();
     $blog_prefix = '';
     $endpoint = Slash_Edit::get_instance()->get_endpoint();
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         /* stolen from /wp-admin/options-permalink.php */
         $blog_prefix = 'blog/';
     }
     $exclude = array('category', 'post_tag', 'nav_menu', 'link_category', 'post_format');
     foreach ($taxonomies as $key => $taxonomy) {
         if (in_array($key, $exclude)) {
             continue;
         }
         $rules["{$blog_prefix}{$key}/([^/]+)/{$endpoint}(/(.*))?/?\$"] = 'index.php?' . $key . '=$matches[1]&' . $endpoint . '=$matches[3]';
     }
     //Add home_url/edit to rewrites
     $add_frontpage_edit_rules = false;
     if (!get_page_by_path($endpoint)) {
         $add_frontpage_edit_rules = true;
     } else {
         $page = get_page_by_path($endpoint);
         if (is_a($page, 'WP_Post') && $page->post_status != 'publish') {
             $add_frontpage_edit_rules = true;
         }
     }
     if ($add_frontpage_edit_rules) {
         $edit_array_rule = array("{$endpoint}/?\$" => 'index.php?' . $endpoint . '=frontpage');
         $rules = $edit_array_rule + $rules;
     }
     return $rules;
 }
Example #27
0
function enlightenment_templates()
{
    $templates = array('error404' => array('name' => __('404', 'enlightenment'), 'conditional' => 'is_404', 'type' => 'special'), 'search' => array('name' => __('Search', 'enlightenment'), 'conditional' => 'is_search', 'type' => 'archive'), 'blog' => array('name' => __('Blog', 'enlightenment'), 'conditional' => 'is_home', 'type' => 'post_type_archive'), 'post' => array('name' => __('Post', 'enlightenment'), 'conditional' => 'is_single', 'type' => 'post_type'), 'page' => array('name' => __('Page', 'enlightenment'), 'conditional' => 'is_page', 'type' => 'post_type'), 'author' => array('name' => __('Author', 'enlightenment'), 'conditional' => 'is_author', 'type' => 'archive'), 'date' => array('name' => __('Date', 'enlightenment'), 'conditional' => 'is_date', 'type' => 'archive'), 'category' => array('name' => __('Category', 'enlightenment'), 'conditional' => 'is_category', 'type' => 'archive'), 'post_tag' => array('name' => __('Tag', 'enlightenment'), 'conditional' => 'is_tag', 'type' => 'archive'), 'comments' => array('name' => __('Comments', 'enlightenment'), 'conditional' => 'is_singular', 'hooks' => array_keys(enlightenment_comments_hooks()), 'type' => 'special'));
    $post_types = get_post_types(array('has_archive' => true), 'objects');
    foreach ($post_types as $name => $post_type) {
        $templates[$name . '-archive'] = array('name' => sprintf(__('%1$s Archive', 'enlightenment'), $post_type->labels->name), 'conditional' => array('is_post_type_archive', $name), 'type' => 'post_type_archive');
    }
    $post_types = get_post_types(array('publicly_queryable' => true), 'objects');
    foreach ($post_types as $name => $post_type) {
        $templates[$name] = array('name' => $post_type->labels->singular_name, 'conditional' => array('is_singular', $name), 'type' => 'post_type');
    }
    $taxonomies = get_taxonomies(array('public' => true), 'objects');
    unset($taxonomies['post_format']);
    unset($taxonomies['category']);
    unset($taxonomies['post_tag']);
    foreach ($taxonomies as $name => $taxonomy) {
        $templates[$name] = array('name' => $taxonomy->labels->singular_name, 'conditional' => array('is_tax', $name), 'type' => 'taxonomy');
    }
    $default_hooks = array_keys(enlightenment_template_hooks());
    foreach ($templates as $name => $template) {
        if (!isset($template['hooks']) || empty($template['hooks'])) {
            $templates[$name]['hooks'] = $default_hooks;
        }
    }
    return apply_filters('enlightenment_templates', $templates);
}
Example #28
0
function wph_right_now_content_table_end()
{
    $args = array('public' => true, '_builtin' => false);
    $output = 'object';
    $operator = 'and';
    $post_types = get_post_types($args, $output, $operator);
    foreach ($post_types as $post_type) {
        $num_posts = wp_count_posts($post_type->name);
        $num = number_format_i18n($num_posts->publish);
        $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish));
        if (current_user_can('edit_posts')) {
            $num = "<a href='edit.php?post_type={$post_type->name}'>{$num}</a>";
            $text = "<a href='edit.php?post_type={$post_type->name}'>{$text}</a>";
        }
        echo '<tr><td class="first num b b-' . $post_type->name . '">' . $num . '</td>';
        echo '<td class="text t ' . $post_type->name . '">' . $text . '</td></tr>';
    }
    $taxonomies = get_taxonomies($args, $output, $operator);
    foreach ($taxonomies as $taxonomy) {
        $num_terms = wp_count_terms($taxonomy->name);
        $num = number_format_i18n($num_terms);
        $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms));
        if (current_user_can('manage_categories')) {
            $num = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$num}</a>";
            $text = "<a href='edit-tags.php?taxonomy={$taxonomy->name}'>{$text}</a>";
        }
        echo '<tr><td class="first b b-' . $taxonomy->name . '">' . $num . '</td>';
        echo '<td class="t ' . $taxonomy->name . '">' . $text . '</td></tr>';
    }
}
function wds_autolinks_settings()
{
    $name = 'wds_autolinks';
    $title = __('Automatic Links', 'wds');
    $description = __('<p>Sometimes you want to always link certain key words to a page on your blog or even a whole new site all together.</p>
	<p>For example, maybe anytime you write the words \'WordPress news\' you want to automatically create a link to the WordPress news blog, wpmu.org. Without this plugin, you would have to manually create these links each time you write the text in your pages and posts - which can be no fun at all.</p>
	<p>This section lets you set those key words and links. First, choose if you want to automatically link key words in posts, pages, or any custom post types you might be using. Usually when you are using automatic links, you will want to check all of the options here.</p>', 'wds');
    $fields = array();
    foreach (get_post_types() as $post_type) {
        if (!in_array($post_type, array('revision', 'nav_menu_item', 'attachment'))) {
            $pt = get_post_type_object($post_type);
            $key = strtolower($pt->name);
            $post_types["l{$key}"] = $pt->labels->name;
            $insert["{$key}"] = $pt->labels->name;
        }
    }
    foreach (get_taxonomies() as $taxonomy) {
        if (!in_array($taxonomy, array('nav_menu', 'link_category', 'post_format'))) {
            $tax = get_taxonomy($taxonomy);
            $key = strtolower($tax->labels->name);
            $taxonomies["l{$key}"] = $tax->labels->name;
        }
    }
    $linkto = array_merge($post_types, $taxonomies);
    $insert['comment'] = __('Comments', 'wds');
    $fields['internal'] = array('title' => '', 'intro' => '', 'options' => array(array('type' => 'checkbox', 'name' => 'insert', 'title' => __('Insert links in', 'wds'), 'items' => $insert), array('type' => 'checkbox', 'name' => 'linkto', 'title' => __('Link to', 'wds'), 'items' => $linkto), array('type' => 'dropdown', 'name' => 'cpt_char_limit', 'title' => __('Minimum post title length', 'wds'), 'description' => __('This is the minimum number of characters your post title has to have to be considered for insertion as auto-link.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 25)), array_merge(array(__('Default', 'wds')), range(1, 25)))), array('type' => 'dropdown', 'name' => 'tax_char_limit', 'title' => __('Minimum taxonomy title length', 'wds'), 'description' => __('This is the minimum number of characters your taxonomy title has to have to be considered for insertion as auto-link.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 25)), array_merge(array(__('Default', 'wds')), range(1, 25)))), array('type' => 'checkbox', 'name' => 'allow_empty_tax', 'title' => __('Empty taxonomies', 'wds'), 'items' => array('allow_empty_tax' => __('Allow autolinks to empty taxonomies', 'wds'))), array('type' => 'checkbox', 'name' => 'excludeheading', 'title' => __('Exclude Headings', 'wds'), 'items' => array('excludeheading' => __('Prevent linking in heading tags', 'wds'))), array('type' => 'text', 'name' => 'ignorepost', 'title' => __('Ignore posts and pages', 'wds'), 'description' => __('Paste in the IDs, slugs or titles for the post/pages you wish to exclude and separate them by commas', 'wds')), array('type' => 'text', 'name' => 'ignore', 'title' => __('Ignore keywords', 'wds'), 'description' => __('Paste in the keywords you wish to exclude and separate them by commas', 'wds')), array('type' => 'dropdown', 'name' => 'link_limit', 'title' => __('Maximum autolinks number limit', 'wds'), 'description' => __('This is the maximum number of autolinks that will be added to your posts.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 20)), array_merge(array(__('Unlimited', 'wds')), range(1, 20)))), array('type' => 'dropdown', 'name' => 'single_link_limit', 'title' => __('Maximum single autolink occurrence', 'wds'), 'description' => __('This is a number of single link replacement occurrences.', 'wds'), 'items' => array_combine(array_merge(array(0), range(1, 10)), array_merge(array(__('Unlimited', 'wds')), range(1, 10)))), array('type' => 'textarea', 'name' => 'customkey', 'title' => __('Custom Keywords', 'wds'), 'description' => __('Paste in the extra keywords you want to automaticaly link. Use comma to seperate keywords and add target url at the end. Use a new line for new url and set of keywords.
				<br />Example:<br />
				<code>WPMU DEV, plugins, themes, http://premium.wpmudev.org/<br />
				WordPress News, http://wpmu.org/<br /></code>', 'wds')), array('type' => 'checkbox', 'name' => 'reduceload', 'title' => __('Other settings', 'wds'), 'items' => array('onlysingle' => __('Process only single posts and pages', 'wds'), 'allowfeed' => __('Process RSS feeds', 'wds'), 'casesens' => __('Case sensitive matching', 'wds'), 'customkey_preventduplicatelink' => __('Prevent duplicate links', 'wds'), 'target_blank' => __('Open links in new tab/window', 'wds'), 'rel_nofollow' => __('Autolinks <code>nofollow</code>', 'wds')))));
    $contextual_help = '';
    if (wds_is_wizard_step('5')) {
        $settings = new WDS_Core_Admin_Tab($name, $title, $description, $fields, 'wds', $contextual_help);
    }
}
 function __construct($args = array())
 {
     $defaults = array('post_types' => 'all', 'taxes' => 'all');
     $r = wp_parse_args($args, $defaults);
     if ('all' == $r['post_types']) {
         $this->post_types = get_post_types();
     } else {
         $this->post_types = (array) $r['post_types'];
     }
     foreach ($this->post_types as $ptkey => $pt) {
         $pto = get_post_type_object($pt);
         if ($pt->_builtin) {
             unset($this->post_types[$ptkey]);
         }
     }
     if ('all' == $r['taxes']) {
         $this->taxes = get_taxonomies();
     } else {
         $this->taxes = (array) $r['taxes'];
     }
     add_action('admin_init', array(&$this, 'add_meta_boxes'), 5);
     add_action('save_post', array(&$this, 'save'));
     add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'), 10, 1);
     add_action('do_meta_boxes', array(&$this, 'remove_meta_boxes'), 10, 3);
 }