Example #1
1
 /**
  * get_url - Returns a url based on a string that holds either post type and id or taxonomy and id
  */
 static function get_url($link, $post_id = false)
 {
     $link = explode(',', $link);
     if ($link[0] == 'lightbox') {
         $link = wp_get_attachment_image_src($post_id, apply_filters('avf_avia_builder_helper_lightbox_size', 'large'));
         return $link[0];
     }
     if (empty($link[1])) {
         return $link[0];
     }
     if ($link[0] == 'manually') {
         return $link[1];
     }
     if (post_type_exists($link[0])) {
         return get_permalink($link[1]);
     }
     if (taxonomy_exists($link[0])) {
         $return = get_term_link(get_term($link[1], $link[0]));
         if (is_object($return)) {
             $return = "";
         }
         //if an object is returned it is a WP_Error object and something was not found
         return $return;
     }
 }
 /**
  * Display a javascript collection for autocompletion script !
  *
  * @return void
  * @author Amaury Balmer
  */
 public static function ajax_local_tags()
 {
     status_header(200);
     // Send good header HTTP
     header("Content-Type: application/json; charset=" . get_bloginfo('charset'));
     $taxonomy = 'post_tag';
     if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
         $taxonomy = $_REQUEST['taxonomy'];
     }
     if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) {
         // No tags to suggest
         json_encode(array());
         exit;
     }
     // Prepare search
     $search = isset($_GET['term']) ? trim(stripslashes($_GET['term'])) : '';
     // Get all terms, or filter with search
     $terms = SimpleTags_Admin::getTermsForAjax($taxonomy, $search);
     if (empty($terms) || $terms == false) {
         json_encode(array());
         exit;
     }
     // Format terms
     $results = array();
     foreach ((array) $terms as $term) {
         $term->name = stripslashes($term->name);
         $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name);
         $results[] = array('id' => $term->term_id, 'label' => $term->name, 'value' => $term->name);
     }
     echo json_encode($results);
     exit;
 }
 public static function attribute_taxonomies()
 {
     global $woocommerce;
     if (!isset($woocommerce)) {
         return array();
     }
     $attributes = array();
     if (function_exists('wc_get_attribute_taxonomies')) {
         $attribute_taxonomies = wc_get_attribute_taxonomies();
     } else {
         $attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
     }
     if (empty($attribute_taxonomies)) {
         return array();
     }
     foreach ($attribute_taxonomies as $attribute) {
         /* FIX TO WOOCOMMERCE 2.1 */
         if (function_exists('wc_attribute_taxonomy_name')) {
             $taxonomy = wc_attribute_taxonomy_name($attribute->attribute_name);
         } else {
             $taxonomy = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
         }
         if (taxonomy_exists($taxonomy)) {
             $attributes[] = $attribute->attribute_name;
         }
     }
     return $attributes;
 }
 /**
  * Register custom post status taxonomy - used by workflows.
  *
  * @since 2.0
  */
 public function register_custom_taxonomy()
 {
     if (!taxonomy_exists($this->taxonomy_key)) {
         $args = array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => false, 'query_var' => false, 'rewrite' => false, 'show_ui' => false);
         register_taxonomy($this->taxonomy_key, 'post', $args);
     }
 }
Example #5
0
/**
 * Display a list categories
 * @param array $args
 * @return bool
 */
function zfwca_list_categories($args = array())
{
    $defaults = array('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'exclude_tree' => '', 'current_category' => 0, 'taxonomy' => 'category');
    $r = wp_parse_args($args, $defaults);
    $r['walker'] = new ZFWCA_Post_Category_Walker();
    if (!isset($r['class'])) {
        $r['class'] = 'category' == $r['taxonomy'] ? 'categories' : $r['taxonomy'];
    }
    extract($r);
    if (!taxonomy_exists($taxonomy)) {
        return false;
    }
    $categories = get_categories($r);
    $output = '';
    if (empty($categories)) {
        $output .= 'No categories';
    } else {
        if (empty($r['current_category']) && (is_category() || is_tax() || is_tag())) {
            $current_term_object = get_queried_object();
            if ($current_term_object && $r['taxonomy'] === $current_term_object->taxonomy) {
                $r['current_category'] = get_queried_object_id();
            }
        }
        $output .= walk_category_tree($categories, 0, $r);
    }
    $output = apply_filters('zfwca_wp_list_categories', $output, $args);
    return $output;
}
 /**
  * Register core taxonomies.
  */
 public static function register_taxonomies()
 {
     if (taxonomy_exists('product_type')) {
         return;
     }
     do_action('woocommerce_register_taxonomy');
     $permalinks = get_option('woocommerce_permalinks');
     register_taxonomy('product_type', apply_filters('woocommerce_taxonomy_objects_product_type', array('product')), apply_filters('woocommerce_taxonomy_args_product_type', array('hierarchical' => false, 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'rewrite' => false, 'public' => false)));
     register_taxonomy('product_cat', apply_filters('woocommerce_taxonomy_objects_product_cat', array('product')), apply_filters('woocommerce_taxonomy_args_product_cat', array('hierarchical' => true, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Categories', 'woocommerce'), 'labels' => array('name' => __('Product Categories', 'woocommerce'), 'singular_name' => __('Product Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Categories', 'woocommerce'), 'all_items' => __('All Product Categories', 'woocommerce'), 'parent_item' => __('Parent Product Category', 'woocommerce'), 'parent_item_colon' => __('Parent Product Category:', 'woocommerce'), 'edit_item' => __('Edit Product Category', 'woocommerce'), 'update_item' => __('Update Product Category', 'woocommerce'), 'add_new_item' => __('Add New Product Category', 'woocommerce'), 'new_item_name' => __('New Product Category Name', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['category_base']) ? _x('product-category', 'slug', 'woocommerce') : $permalinks['category_base'], 'with_front' => false, 'hierarchical' => true))));
     register_taxonomy('product_tag', apply_filters('woocommerce_taxonomy_objects_product_tag', array('product')), apply_filters('woocommerce_taxonomy_args_product_tag', array('hierarchical' => false, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Tags', 'woocommerce'), 'labels' => array('name' => __('Product Tags', 'woocommerce'), 'singular_name' => __('Product Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Tags', 'woocommerce'), 'all_items' => __('All Product Tags', 'woocommerce'), 'edit_item' => __('Edit Product Tag', 'woocommerce'), 'update_item' => __('Update Product Tag', 'woocommerce'), 'add_new_item' => __('Add New Product Tag', 'woocommerce'), 'new_item_name' => __('New Product Tag Name', 'woocommerce'), 'popular_items' => __('Popular Product Tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate Product Tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove Product Tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used Product tags', 'woocommerce'), 'not_found' => __('No Product Tags found', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['tag_base']) ? _x('product-tag', 'slug', 'woocommerce') : $permalinks['tag_base'], 'with_front' => false))));
     register_taxonomy('product_shipping_class', apply_filters('woocommerce_taxonomy_objects_product_shipping_class', array('product', 'product_variation')), apply_filters('woocommerce_taxonomy_args_product_shipping_class', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping Classes', 'woocommerce'), 'labels' => array('name' => __('Shipping Classes', 'woocommerce'), 'singular_name' => __('Shipping Class', 'woocommerce'), 'menu_name' => _x('Shipping Classes', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Shipping Classes', 'woocommerce'), 'all_items' => __('All Shipping Classes', 'woocommerce'), 'parent_item' => __('Parent Shipping Class', 'woocommerce'), 'parent_item_colon' => __('Parent Shipping Class:', 'woocommerce'), 'edit_item' => __('Edit Shipping Class', 'woocommerce'), 'update_item' => __('Update Shipping Class', 'woocommerce'), 'add_new_item' => __('Add New Shipping Class', 'woocommerce'), 'new_item_name' => __('New Shipping Class Name', 'woocommerce')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => false)));
     global $wc_product_attributes;
     $wc_product_attributes = array();
     if ($attribute_taxonomies = wc_get_attribute_taxonomies()) {
         foreach ($attribute_taxonomies as $tax) {
             if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
                 $tax->attribute_public = absint(isset($tax->attribute_public) ? $tax->attribute_public : 1);
                 $label = !empty($tax->attribute_label) ? $tax->attribute_label : $tax->attribute_name;
                 $wc_product_attributes[$name] = $tax;
                 $taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => false, 'query_var' => 1 === $tax->attribute_public, 'rewrite' => false, 'sort' => false, 'public' => 1 === $tax->attribute_public, 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
                 if (1 === $tax->attribute_public) {
                     $taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($tax->attribute_name), 'with_front' => false, 'hierarchical' => true);
                 }
                 register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
             }
         }
         do_action('woocommerce_after_register_taxonomy');
     }
 }
 public function init_attribute_image_selector()
 {
     global $woocommerce, $_wp_additional_image_sizes;
     $screen = get_current_screen();
     if (strpos($screen->id, 'pa_') !== false) {
         $this->taxonomy = $_REQUEST['taxonomy'];
         if (taxonomy_exists($_REQUEST['taxonomy'])) {
             $term_id = term_exists(isset($_REQUEST['tag_ID']) ? $_REQUEST['tag_ID'] : 0, $_REQUEST['taxonomy']);
             $term = 0;
             if ($term_id) {
                 $term = get_term($term_id, $_REQUEST['taxonomy']);
             }
             $this->image_size = apply_filters('woocommerce_get_swatches_image_size', $this->image_size, $_REQUEST['taxonomy'], $term_id);
         }
         $the_size = isset($_wp_additional_image_sizes[$this->image_size]) ? $_wp_additional_image_sizes[$this->image_size] : $_wp_additional_image_sizes['shop_thumbnail'];
         if (isset($the_size['width']) && isset($the_size['height'])) {
             $this->image_width = $the_size['width'];
             $this->image_height = $the_size['height'];
         } else {
             $this->image_width = 32;
             $this->image_height = 32;
         }
         $attribute_taxonomies = WC_Swatches_Compatibility::wc_get_attribute_taxonomies();
         if ($attribute_taxonomies) {
             foreach ($attribute_taxonomies as $tax) {
                 add_action('pa_' . $tax->attribute_name . '_add_form_fields', array(&$this, 'woocommerce_add_attribute_thumbnail_field'));
                 add_action('pa_' . $tax->attribute_name . '_edit_form_fields', array(&$this, 'woocommerce_edit_attributre_thumbnail_field'), 10, 2);
                 add_filter('manage_edit-pa_' . $tax->attribute_name . '_columns', array(&$this, 'woocommerce_product_attribute_columns'));
                 add_filter('manage_pa_' . $tax->attribute_name . '_custom_column', array(&$this, 'woocommerce_product_attribute_column'), 10, 3);
             }
         }
     }
 }
 public function __construct($name = null, $post_types = array(), $args = array(), $capabilities = array(), $labels = array())
 {
     $this->taxonomy_name = Custom_Post_Type::uglify($name);
     $this->taxonomy_post_types = $post_types;
     $this->taxonomy_args = $args;
     $this->taxonomy_capabilities = $capabilities;
     $this->taxonomy_labels = $labels;
     if (!taxonomy_exists($this->taxonomy_name)) {
         $name = Custom_Post_Type::beautify($name);
         $plural = Custom_Post_Type::pluralize($name);
         $labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $this->taxonomy_labels);
         $capabilities = $this->merge_caps($this->taxonomy_args, $this->taxonomy_capabilities);
         // Default arguments, overwritten with the given arguments
         $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, '_builtin' => false, 'capabilities' => $capabilities), $this->taxonomy_args);
         // Add the taxonomy to the post types
         add_action('init', function () use($args) {
             register_taxonomy($this->taxonomy_name, $this->taxonomy_post_types, $args);
         });
     } else {
         /* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */
         add_action('init', function () {
             foreach ($this->taxonomy_post_types as $type) {
                 register_taxonomy_for_object_type($this->taxonomy_name, $type);
             }
         });
     }
 }
/**
 * Functions for handling WordPress import to make it compatable with WooCommerce
 *
 * WordPress import should work - however, it fails to import custom product attribute taxonomies.
 * This code grabs the file before it is imported and ensures the taxonomies are created.
 *
 * @author 		WooThemes
 * @category 	Admin
 * @package 	WooCommerce
 */
function woocommerce_import_start()
{
    global $wpdb;
    $id = (int) $_POST['import_id'];
    $file = get_attached_file($id);
    $parser = new WXR_Parser();
    $import_data = $parser->parse($file);
    if (isset($import_data['posts'])) {
        $posts = $import_data['posts'];
        if ($posts && sizeof($posts) > 0) {
            foreach ($posts as $post) {
                if ($post['post_type'] == 'product') {
                    if ($post['terms'] && sizeof($post['terms']) > 0) {
                        foreach ($post['terms'] as $term) {
                            $domain = $term['domain'];
                            if (strstr($domain, 'pa_')) {
                                // Make sure it exists!
                                if (!taxonomy_exists($domain)) {
                                    $nicename = strtolower(sanitize_title(str_replace('pa_', '', $domain)));
                                    $exists_in_db = $wpdb->get_var("SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';");
                                    if (!$exists_in_db) {
                                        // Create the taxonomy
                                        $wpdb->insert($wpdb->prefix . "woocommerce_attribute_taxonomies", array('attribute_name' => $nicename, 'attribute_type' => 'select'), array('%s', '%s'));
                                    }
                                    // Register the taxonomy now so that the import works!
                                    register_taxonomy($domain, array('product'), array('hierarchical' => true, 'labels' => array('name' => $nicename, 'singular_name' => $nicename, 'search_items' => __('Search', 'woothemes') . ' ' . $nicename, 'all_items' => __('All', 'woothemes') . ' ' . $nicename, 'parent_item' => __('Parent', 'woothemes') . ' ' . $nicename, 'parent_item_colon' => __('Parent', 'woothemes') . ' ' . $nicename . ':', 'edit_item' => __('Edit', 'woothemes') . ' ' . $nicename, 'update_item' => __('Update', 'woothemes') . ' ' . $nicename, 'add_new_item' => __('Add New', 'woothemes') . ' ' . $nicename, 'new_item_name' => __('New', 'woothemes') . ' ' . $nicename), 'show_ui' => false, 'query_var' => true, 'rewrite' => array('slug' => strtolower(sanitize_title($nicename)), 'with_front' => false, 'hierarchical' => true)));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 /**
  * Display a javascript collection for autocompletion script !
  *
  * @return void
  * @author Amaury Balmer
  */
 function ajaxLocalTags()
 {
     status_header(200);
     // Send good header HTTP
     header("Content-Type: text/plain; charset=" . get_bloginfo('charset'));
     $taxonomy = 'post_tag';
     if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
         $taxonomy = $_REQUEST['taxonomy'];
     }
     if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) {
         // No tags to suggest
         exit;
     }
     // Prepare search
     $search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : '';
     // Get all terms, or filter with search
     $terms = $this->getTermsForAjax($taxonomy, $search);
     if (empty($terms) || $terms == false) {
         exit;
     }
     // Format terms
     foreach ((array) $terms as $term) {
         $term->name = stripslashes($term->name);
         $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name);
         echo "{$term->term_id}|{$term->name}\n";
     }
     exit;
 }
 function woocommerce_ultimatum_layered_nav_init()
 {
     global $_chosen_attributes, $woocommerce, $_attributes_array;
     $_chosen_attributes = $_attributes_array = array();
     $attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
     if ($attribute_taxonomies) {
         foreach ($attribute_taxonomies as $tax) {
             $attribute = sanitize_title($tax->attribute_name);
             $taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
             // create an array of product attribute taxonomies
             $_attributes_array[] = $taxonomy;
             $name = 'filter_' . $attribute;
             $query_type_name = 'query_type_' . $attribute;
             if (!empty($_GET[$name]) && taxonomy_exists($taxonomy)) {
                 $_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name]);
                 if (!empty($_GET[$query_type_name]) && $_GET[$query_type_name] == 'or') {
                     $_chosen_attributes[$taxonomy]['query_type'] = 'or';
                 } else {
                     $_chosen_attributes[$taxonomy]['query_type'] = 'and';
                 }
             }
         }
     }
     add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
 }
Example #12
0
function avia_temp_products()
{
    if (post_type_exists('product')) {
        return false;
    }
    $product_base = $base_slug = $category_base = "";
    register_taxonomy('product_cat', array('product'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories', 'woothemes'), 'labels' => array('name' => __('Categories', 'woothemes'), 'singular_name' => __('Product Category', 'woothemes'), 'search_items' => __('Search Product Categories', 'woothemes'), 'all_items' => __('All Product Categories', 'woothemes'), 'parent_item' => __('Parent Product Category', 'woothemes'), 'parent_item_colon' => __('Parent Product Category:', 'woothemes'), 'edit_item' => __('Edit Product Category', 'woothemes'), 'update_item' => __('Update Product Category', 'woothemes'), 'add_new_item' => __('Add New Product Category', 'woothemes'), 'new_item_name' => __('New Product Category Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-category', 'slug', 'woothemes'), 'with_front' => false)));
    register_taxonomy('product_tag', array('product'), array('hierarchical' => false, 'label' => __('Tags', 'woothemes'), 'labels' => array('name' => __('Tags', 'woothemes'), 'singular_name' => __('Product Tag', 'woothemes'), 'search_items' => __('Search Product Tags', 'woothemes'), 'all_items' => __('All Product Tags', 'woothemes'), 'parent_item' => __('Parent Product Tag', 'woothemes'), 'parent_item_colon' => __('Parent Product Tag:', 'woothemes'), 'edit_item' => __('Edit Product Tag', 'woothemes'), 'update_item' => __('Update Product Tag', 'woothemes'), 'add_new_item' => __('Add New Product Tag', 'woothemes'), 'new_item_name' => __('New Product Tag Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-tag', 'slug', 'woothemes'), 'with_front' => false)));
    register_post_type("product", array('labels' => array('name' => __('Products', 'woothemes'), 'singular_name' => __('Product', 'woothemes'), 'add_new' => __('Add Product', 'woothemes'), 'add_new_item' => __('Add New Product', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Product', 'woothemes'), 'new_item' => __('New Product', 'woothemes'), 'view' => __('View Product', 'woothemes'), 'view_item' => __('View Product', 'woothemes'), 'search_items' => __('Search Products', 'woothemes'), 'not_found' => __('No Products found', 'woothemes'), 'not_found_in_trash' => __('No Products found in trash', 'woothemes'), 'parent' => __('Parent Product', 'woothemes')), 'description' => __('This is where you can add new products to your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => true, 'rewrite' => array('slug' => $product_base, 'with_front' => false), 'query_var' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments'), 'has_archive' => $base_slug, 'show_in_nav_menus' => false));
    register_post_type("product_variation", array('labels' => array('name' => __('Variations', 'woothemes'), 'singular_name' => __('Variation', 'woothemes'), 'add_new' => __('Add Variation', 'woothemes'), 'add_new_item' => __('Add New Variation', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Variation', 'woothemes'), 'new_item' => __('New Variation', 'woothemes'), 'view' => __('View Variation', 'woothemes'), 'view_item' => __('View Variation', 'woothemes'), 'search_items' => __('Search Variations', 'woothemes'), 'not_found' => __('No Variations found', 'woothemes'), 'not_found_in_trash' => __('No Variations found in trash', 'woothemes'), 'parent' => __('Parent Variation', 'woothemes')), 'public' => true, 'show_ui' => false, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => true, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail'), 'show_in_nav_menus' => false));
    register_taxonomy('product_type', array('product'), array('hierarchical' => false, 'show_ui' => false, 'query_var' => true, 'show_in_nav_menus' => false));
    register_post_type("shop_order", array('labels' => array('name' => __('Orders', 'woothemes'), 'singular_name' => __('Order', 'woothemes'), 'add_new' => __('Add Order', 'woothemes'), 'add_new_item' => __('Add New Order', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Order', 'woothemes'), 'new_item' => __('New Order', 'woothemes'), 'view' => __('View Order', 'woothemes'), 'view_item' => __('View Order', 'woothemes'), 'search_items' => __('Search Orders', 'woothemes'), 'not_found' => __('No Orders found', 'woothemes'), 'not_found_in_trash' => __('No Orders found in trash', 'woothemes'), 'parent' => __('Parent Orders', 'woothemes')), 'description' => __('This is where store orders are stored.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'comments', 'custom-fields'), 'has_archive' => false));
    register_taxonomy('shop_order_status', array('shop_order'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => __('Order statuses', 'woothemes'), 'singular_name' => __('Order status', 'woothemes'), 'search_items' => __('Search Order statuses', 'woothemes'), 'all_items' => __('All  Order statuses', 'woothemes'), 'parent_item' => __('Parent Order status', 'woothemes'), 'parent_item_colon' => __('Parent Order status:', 'woothemes'), 'edit_item' => __('Edit Order status', 'woothemes'), 'update_item' => __('Update Order status', 'woothemes'), 'add_new_item' => __('Add New Order status', 'woothemes'), 'new_item_name' => __('New Order status Name', 'woothemes')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => true, 'rewrite' => false));
    register_post_type("shop_coupon", array('labels' => array('name' => __('Coupons', 'woothemes'), 'singular_name' => __('Coupon', 'woothemes'), 'add_new' => __('Add Coupon', 'woothemes'), 'add_new_item' => __('Add New Coupon', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Coupon', 'woothemes'), 'new_item' => __('New Coupon', 'woothemes'), 'view' => __('View Coupons', 'woothemes'), 'view_item' => __('View Coupon', 'woothemes'), 'search_items' => __('Search Coupons', 'woothemes'), 'not_found' => __('No Coupons found', 'woothemes'), 'not_found_in_trash' => __('No Coupons found in trash', 'woothemes'), 'parent' => __('Parent Coupon', 'woothemes')), 'description' => __('This is where you can add new coupons that customers can use in your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title'), 'show_in_nav_menus' => false));
    if (!taxonomy_exists('product_type')) {
        register_taxonomy('product_type', array('post'));
        register_taxonomy('shop_order_status', array('post'));
    }
    $product_types = array('simple', 'grouped', 'variable', 'downloadable', 'virtual');
    foreach ($product_types as $type) {
        if (!get_term_by('slug', sanitize_title($type), 'product_type')) {
            wp_insert_term($type, 'product_type');
        }
    }
    $order_status = array('pending', 'failed', 'on-hold', 'processing', 'completed', 'refunded', 'cancelled');
    foreach ($order_status as $status) {
        if (!get_term_by('slug', sanitize_title($status), 'shop_order_status')) {
            wp_insert_term($status, 'shop_order_status');
        }
    }
}
 public function register_tree_taxonomy()
 {
     /*
      * The Tree Shapes
      */
     if (!taxonomy_exists('tree_shapes')) {
         $labels = array('name' => _tt('Shapes'), 'singular_name' => _tt('Shape'), 'menu_name' => _tt('Shapes'), 'all_items' => _tt('All Shapes'), 'parent_item' => _tt('Parent Shape'), 'parent_item_colon' => _tt('Parent Shape:'), 'new_item_name' => _tt('New Tree Shape'), 'add_new_item' => _tt('Add New Tree Shape'), 'edit_item' => _tt('Edit Shape'), 'update_item' => _tt('Update Shape'), 'separate_items_with_commas' => _tt('Separate Shapes with commas'), 'search_items' => _tt('Search Shapes'), 'add_or_remove_items' => _tt('Add or remove Shape'), 'choose_from_most_used' => _tt('Choose from the most used Shapes'), 'not_found' => _tt('Shape Not Found'));
         $args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
         register_taxonomy('tree_shapes', 'tree_species', $args);
     }
     /*
      * The Flower Colors
      */
     if (!taxonomy_exists('tree_flower_colors')) {
         $labels = array('name' => _tt('Flower Colors'), 'singular_name' => _tt('Flower Color'), 'menu_name' => _tt('Colors'), 'all_items' => _tt('All Flower Colors'), 'parent_item' => _tt('Parent Color'), 'parent_item_colon' => _tt('Parent Color:'), 'new_item_name' => _tt('New Flower Color'), 'add_new_item' => _tt('Add New Flower Color'), 'edit_item' => _tt('Edit Flower Color'), 'update_item' => _tt('Update Flower Color'), 'separate_items_with_commas' => _tt('Separate Flower Color with commas'), 'search_items' => _tt('Search Flower Color'), 'add_or_remove_items' => _tt('Add or remove Flower Color'), 'choose_from_most_used' => _tt('Choose from the most used colors'), 'not_found' => _tt('Color Not Found'));
         $args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
         register_taxonomy('tree_flower_colors', 'tree_species', $args);
     }
     /*
      * The Flower Colors
      */
     if (!taxonomy_exists('tree_category')) {
         $labels = array('name' => _tt('Tree Categories'), 'singular_name' => _tt('Tree Category'), 'menu_name' => _tt('Categories'), 'all_items' => _tt('All Tree Category'), 'parent_item' => _tt('Parent Tree Category'), 'parent_item_colon' => _tt('Parent Tree Category:'), 'new_item_name' => _tt('New Tree Category'), 'add_new_item' => _tt('Add New Tree Category'), 'edit_item' => _tt('Edit Tree Category'), 'update_item' => _tt('Update Tree Category'), 'separate_items_with_commas' => _tt('Separate Tree Category with commas'), 'search_items' => _tt('Search Tree Category'), 'add_or_remove_items' => _tt('Add or remove Tree Category'), 'choose_from_most_used' => _tt('Choose from the most used Tree Category'), 'not_found' => _tt('Category Not Found'));
         $args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => false);
         register_taxonomy('tree_category', 'tree_species', $args);
     }
 }
/**
 * Function for retriving taxonomy icons configured using taxonomy edit screens
 *
 *
 * @since   1.1.0
 *
 * @param string $field Either 'slug', 'name' or 'id' (term_id)
 * @param string|int $value Search for this term value
 * @param string $taxonomy Taxonomy Name
 * @param boolean $format return html markup or array? Either 'html' or 'array'
 * @param string $after_icon
 *
 * @return string  $icon_html, array of settings or empty string on failure
 */
function iconize_get_term_icon_by($field = 'id', $value, $taxonomy, $format = 'html', $after_icon = '  ')
{
    $fields = array('name', 'slug', 'id');
    $after = !is_string($after_icon) ? '  ' : $after_icon;
    $format = !is_string($format) ? 'html' : $format;
    if (!taxonomy_exists($taxonomy) || !in_array($field, $fields)) {
        return '';
    }
    // get term object
    $term = get_term_by($field, $value, $taxonomy);
    if (!$term || is_wp_error($term)) {
        return '';
    }
    $term_id = $term->term_id;
    $icon_args = array();
    $icon_html = '';
    $opt_array = get_option('iconize_taxonomy_icons');
    if ($opt_array && array_key_exists($taxonomy, $opt_array) && array_key_exists($term_id, $opt_array[$taxonomy])) {
        $icon_args['icon_name'] = isset($opt_array[$taxonomy][$term_id]['icon_name']) ? $opt_array[$taxonomy][$term_id]['icon_name'] : '';
        $icon_args['icon_set'] = isset($opt_array[$taxonomy][$term_id]['icon_set']) ? $opt_array[$taxonomy][$term_id]['icon_set'] : '';
        $icon_args['icon_transform'] = isset($opt_array[$taxonomy][$term_id]['icon_transform']) ? $opt_array[$taxonomy][$term_id]['icon_transform'] : '';
        $icon_args['icon_size'] = isset($opt_array[$taxonomy][$term_id]['icon_size']) ? $opt_array[$taxonomy][$term_id]['icon_size'] : '';
        $icon_args['icon_align'] = isset($opt_array[$taxonomy][$term_id]['icon_align']) ? $opt_array[$taxonomy][$term_id]['icon_align'] : '';
        $icon_args['icon_custom_classes'] = isset($opt_array[$taxonomy][$term_id]['icon_custom_classes']) ? $opt_array[$taxonomy][$term_id]['icon_custom_classes'] : '';
        $icon_args['icon_color'] = isset($opt_array[$taxonomy][$term_id]['icon_color']) ? $opt_array[$taxonomy][$term_id]['icon_color'] : '';
        // Generate icon html
        $icon_html = iconize_get_icon($icon_args, $taxonomy, $after);
    }
    if ('array' === $format) {
        return $icon_args;
    } else {
        return $icon_html;
    }
}
 public static function init()
 {
     global $ClevernessToDoList, $CTDL_Frontend_Checklist, $CTDL_Frontend_Admin, $CTDL_templates, $CTDL_Dashboard_Widget;
     if (is_admin()) {
         self::check_for_upgrade();
     }
     $general_options = get_option('CTDL_general') ? get_option('CTDL_general') : array();
     $advanced_options = get_option('CTDL_advanced') ? get_option('CTDL_advanced') : array();
     $permissions_options = get_option('CTDL_permissions') ? get_option('CTDL_permissions') : array();
     self::$settings = array_merge($general_options, $advanced_options, $permissions_options);
     self::$dashboard_settings = get_option('CTDL_dashboard_settings');
     self::include_files();
     if (!post_type_exists('todo')) {
         self::setup_custom_post_type();
     }
     if (!taxonomy_exists('todocategories')) {
         self::create_taxonomies();
     }
     self::call_wp_hooks();
     $ClevernessToDoList = new ClevernessToDoList();
     $CTDL_templates = new CTDL_Template_Loader();
     if (is_admin()) {
         new CTDL_Settings();
         $CTDL_Dashboard_Widget = new CTDL_Dashboard_Widget();
     }
     $CTDL_Frontend_Admin = new CTDL_Frontend_Admin();
     $CTDL_Frontend_Checklist = new CTDL_Frontend_Checklist();
     new CTDL_Frontend_List();
 }
Example #16
0
 public function add_taxonomy($name, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         // We need to know the post type name, so the new taxonomy can be attached to it.
         $post_type_name = $this->post_type_name;
         // Taxonomy properties
         $taxonomy_name = strtolower(str_replace(' ', '_', $name));
         $taxonomy_labels = $labels;
         $taxonomy_args = $args;
         if (!taxonomy_exists($taxonomy_name)) {
             //Capitilize the words and make it plural
             $name = ucwords(str_replace('_', ' ', $name));
             $plural = $name . 's';
             // Default labels, overwrite them with the given labels.
             $labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $taxonomy_labels);
             // Default arguments, overwitten with the given arguments
             $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false), $taxonomy_args);
             // Add the taxonomy to the post type
             add_action('init', function () use($taxonomy_name, $post_type_name, $args) {
                 register_taxonomy($taxonomy_name, $post_type_name, $args);
             });
         } else {
             add_action('init', function () use($taxonomy_name, $post_type_name) {
                 register_taxonomy_for_object_type($taxonomy_name, $post_type_name);
             });
         }
     }
 }
Example #17
0
 /**
  * Add activity after inserting new question.
  * @param  integer $question_id Post ID.
  */
 public function new_question($question_id)
 {
     $question = get_post($question_id);
     $question_title = '<a class="ap-q-link" href="' . wp_get_shortlink($question_id) . '">' . get_the_title($question_id) . '</a>';
     $txo_type = '';
     if (taxonomy_exists('question_category')) {
         $txo_type = 'question_category';
     }
     if (taxonomy_exists('question_tag')) {
         $txo_type = 'question_tag';
     }
     $term_ids = array();
     if (!empty($txo_type)) {
         $terms = get_the_terms($question_id, $txo_type);
         if ($terms) {
             foreach ($terms as $t) {
                 $term_ids[] = $t->term_id;
             }
             $term_ids = implode(',', $term_ids);
         }
     }
     $activity_arr = array('user_id' => $question->post_author, 'type' => 'new_question', 'question_id' => $question_id, 'permalink' => wp_get_shortlink($question_id), 'content' => sprintf(__('%s asked question %s', 'anspress-question-answer'), ap_activity_user_name($question->post_author), $question_title), 'term_ids' => $term_ids);
     $activity_id = ap_new_activity($activity_arr);
     // Add question activity meta.
     update_post_meta($question_id, '__ap_activity', array('type' => 'new_question', 'user_id' => $question->post_author, 'date' => current_time('mysql')));
     $this->check_mentions($question_id, $question->post_content, $question_title, $question->post_author, __('question', 'anspress-question-answer'));
     // Notify users.
     // ap_new_notification($activity_id, $question->post_author);
 }
Example #18
0
function custom_taxonomies_callback()
{
    // CARACTERÍSTICA PLATILLO
    if (!taxonomy_exists('caracteristica-platillo')) {
        $labels = array('name' => 'Caracterísiticas platillo', 'singular_name' => 'Caracterísiticas platillo', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar característica', 'update_item' => 'Actualizar característica', 'add_new_item' => 'Nueva característica', 'menu_name' => 'Caracterísiticas platillo');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'caracteristica-platillo'));
        register_taxonomy('caracteristica-platillo', 'product', $args);
    }
    // TIPO DE COMIDA
    if (!taxonomy_exists('comida-del-dia')) {
        $labels = array('name' => 'Comida del día', 'singular_name' => 'Comida del día', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar comida del día', 'update_item' => 'Actualizar comida del día', 'add_new_item' => 'Nueva comida del día', 'menu_name' => 'Comida del día');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'comida-del-dia'));
        register_taxonomy('comida-del-dia', 'product', $args);
    }
    // Disponibilidad
    if (!taxonomy_exists('disponibilidad')) {
        $labels = array('name' => 'Disponibilidad', 'singular_name' => 'Disponibilidad', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar disponibilidad', 'update_item' => 'Actualizar disponibilidad', 'add_new_item' => 'Nueva disponibilidad', 'menu_name' => 'Disponibilidad');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'disponibilidad'));
        register_taxonomy('disponibilidad', 'product', $args);
    }
    // Tipo de platillo
    if (!taxonomy_exists('tipo-de-platillo')) {
        $labels = array('name' => 'Tipo de platillo', 'singular_name' => 'Tipo de platillo', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar tipo de platillo', 'update_item' => 'Actualizar tipo de platillo', 'add_new_item' => 'Nueva tipo de platillo', 'menu_name' => 'Tipo de platillo');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'tipo-de-platillo'));
        register_taxonomy('tipo-de-platillo', 'product', $args);
    }
    // Taxonomy terms
    insert_platillo_taxonomy_terms();
    insert_comida_dia_taxonomy_terms();
    insert_disponibilidad_taxonomy_terms();
    insert_tipo_de_platillo_taxonomy_terms();
}
Example #19
0
function store_seo_info()
{
    if (get_post_type() == 'store' && !is_singular()) {
        $id = get_queried_object_id();
        if ((taxonomy_exists('products_category') || taxonomy_exists('products_tag')) && $id != 0) {
            $term_name = get_term_field('name', $id, 'products_category');
            $title = $term_name;
            $paged = get_query_var('paged');
            if ($paged > 1) {
                $title .= sprintf(__(' - 第 %s 页 ', 'tinection'), $paged);
            }
            $title .= ' - ' . get_bloginfo('name') . '商城';
            $keywords = $term_name . ",商城";
            $description = strip_tags(term_description());
        } elseif (is_archive() && $id == 0) {
            $title = ot_get_option('shop_archives_title', 'WordPress商店');
            $paged = get_query_var('paged');
            if ($paged > 1) {
                $title .= sprintf(__(' - 第 %s 页 ', 'tinection'), $paged);
            }
            $title .= ' - ' . get_bloginfo('name');
            $keywords = '商品归档,商城,归档';
            $description = get_bloginfo('name') . '商城';
        }
        $seo_text = '<title>' . $title . '</title><meta name="description" content="' . $description . '" /><meta name="keywords" content="' . $keywords . '" />';
    } else {
        $seo_text = '';
    }
    return $seo_text;
}
Example #20
0
function custom_taxonomies_callback()
{
    // AÑO
    if (!taxonomy_exists('ano')) {
        $labels = array('name' => 'Año', 'singular_name' => 'Año', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar año', 'update_item' => 'Actualizar año', 'add_new_item' => 'Nuevo año', 'new_item_name' => 'Nombre nuevo año', 'menu_name' => 'Año');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'ano'));
        register_taxonomy('ano', array('archivo', 'videos'), $args);
    }
    // LUGAR
    if (!taxonomy_exists('lugar')) {
        $labels = array('name' => 'Lugar', 'singular_name' => 'Lugar', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar lugar', 'update_item' => 'Actualizar lugar', 'add_new_item' => 'Nuevo lugar', 'new_item_name' => 'Nombre nuevo lugar', 'menu_name' => 'Lugar');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'lugar'));
        register_taxonomy('lugar', array('archivo', 'videos'), $args);
    }
    // ARQUITECTO / DESPACHO
    if (!taxonomy_exists('arquitecto-despacho')) {
        $labels = array('name' => 'Arquitecto / Despacho', 'singular_name' => 'Arquitecto / Despacho', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar Arquitecto / Despacho', 'update_item' => 'Actualizar Arquitecto / Despacho', 'add_new_item' => 'Nuevo Arquitecto / Despacho', 'new_item_name' => 'Nombre nuevo Arquitecto / Despacho', 'menu_name' => 'Arquitecto / Despacho');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'arquitecto-despacho'));
        register_taxonomy('arquitecto-despacho', array('archivo', 'videos'), $args);
    }
    // TIPOLOGÍA
    if (!taxonomy_exists('tipologia')) {
        $labels = array('name' => 'Tipología', 'singular_name' => 'Tipología', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar Tipología', 'update_item' => 'Actualizar Tipología', 'add_new_item' => 'Nuevo Tipología', 'new_item_name' => 'Nombre nuevo Tipología', 'menu_name' => 'Tipología');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'tipologia'));
        register_taxonomy('tipologia', array('archivo', 'videos'), $args);
    }
    // IMPORTANCIA
    if (!taxonomy_exists('mostrar-home')) {
        $labels = array('name' => 'Mostar home', 'singular_name' => 'Mostar home', 'search_items' => 'Buscar', 'all_items' => 'Todos', 'edit_item' => 'Editar Mostar home', 'update_item' => 'Actualizar Mostar home', 'add_new_item' => 'Nuevo Mostar home', 'new_item_name' => 'Nombre nuevo Mostar home', 'menu_name' => 'Mostar home');
        $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'query_var' => true, 'rewrite' => array('slug' => 'mostrar-home'));
        register_taxonomy('mostrar-home', array('archivo'), $args);
    }
}
Example #21
0
 /**
  * Check if taxonomy exist and return it, otherwise return default post tags.
  *
  * @param array $instance
  *
  * @return string
  * @author Amaury Balmer
  */
 public static function _get_current_taxonomy($instance)
 {
     if (!empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy'])) {
         return $instance['taxonomy'];
     }
     return 'post_tag';
 }
Example #22
0
/**
 * Get taxonomy label.
 *
 * @param  string $taxonomy
 * @param  string $label
 * @param  string $default
 *
 * @return string
 */
function papi_get_taxonomy_label($taxonomy, $label, $default = '')
{
    if (!taxonomy_exists($taxonomy)) {
        return $default;
    }
    return get_taxonomy($taxonomy)->labels->{$label};
}
Example #23
0
/**
 * Output the tag cloud as configured
 *
 * @param array $option the plugin config
 *
 * @return string the tag cloud
 *
 * @since 0.8.1
 */
function nktagcloud_the_cloud($config)
{
    $smallest = $config['smallest'];
    $largest = $config['largest'];
    $unit = $config['unit'];
    $number = $config['number'];
    $format = $config['format'];
    $order = $config['order'];
    $orderby = $config['orderby'];
    $exclude = $config['exclude'];
    $include = $config['include'];
    $categories = $config['categories'];
    $replace = $config['replace'];
    /*
     * The 'single' and 'post_id' settings are not configurable through the
     * options page and only intended for the shortcodes.
     */
    $single = 'No';
    $post_id = null;
    $mincount = $config['mincount'];
    $separator = $config['separator'];
    $hidelastseparator = $config['hidelastseparator'];
    $inject_count = $config['inject_count'];
    $inject_count_outside = $config['inject_count_outside'];
    $taxonomy = $config['taxonomy'];
    if (function_exists(taxonomy_exists)) {
        if (!taxonomy_exists($taxonomy)) {
            $taxonomy = 'post_tag';
        }
    } else {
        $taxonomy = 'post_tag';
    }
    // force tags for < 3.0
    return nk_wp_tag_cloud("largest={$largest}&smallest={$smallest}&unit={$unit}&number={$number}&format={$format}&order={$order}&orderby={$orderby}&exclude={$exclude}&include={$include}&categories={$categories}&single={$single}&replace={$replace}&separator={$separator}&hidelastseparator={$hidelastseparator}&inject_count={$inject_count}&inject_count_outside={$inject_count_outside}&post_id={$post_id}&mincount={$mincount}&nofollow={$nofollow}&taxonomy={$taxonomy}");
}
 /**
  * Plugin Loader init
  * @static
  * @since 1.0
  */
 public static function init()
 {
     global $PostPlannerSettings;
     self::check_for_upgrade();
     $general_options = get_option('PostPlanner_general') ? get_option('PostPlanner_general') : array();
     $advanced_options = get_option('PostPlanner_advanced') ? get_option('PostPlanner_advanced') : array();
     self::$settings = array_merge($general_options, $advanced_options);
     self::$statuses = self::setup_statuses();
     if (PostPlanner_Loader::check_plugin_access() == false) {
         return;
     }
     if (PostPlanner_Loader::$settings['checklist'] == 1) {
         self::$checklist = get_option('PostPlanner_checklist');
     }
     self::include_files();
     if (!post_type_exists('planner')) {
         self::setup_custom_post_type();
     }
     if (!taxonomy_exists('plannercategories')) {
         self::create_taxonomies();
     }
     $PostPlannerSettings = new PostPlanner_Settings();
     if (!defined('PP_CTDL')) {
         if (in_array('cleverness-to-do-list/cleverness-to-do-list.php', apply_filters('active_plugins', get_option('active_plugins'))) && PostPlanner_Loader::$settings['ctdl'] == 1) {
             define('PP_CTDL', true);
         } else {
             define('PP_CTDL', false);
         }
     }
     self::setup_metaboxes();
     self::call_wp_hooks();
     new PostPlanner_Dashboard_Widget();
 }
 function hooks_init()
 {
     if (taxonomy_exists('event-venue')) {
         add_action('admin_init', array($this, 'admin_init_actions'));
         add_action('admin_menu', array($this, 'add_page'));
     }
 }
 public function add_taxonomy($name, $plural, $args = array(), $labels = array())
 {
     if (!empty($name) && !empty($plural)) {
         // We need to need to know the post type name so we can attach the taxonomy to it
         $post_type_name = $this->post_type_name;
         // Taxonomy properties
         $taxonomy_name = self::uglify($name);
         $tax_plural = self::uglify($plural);
         $taxonomy_args = $args;
         $taxonomy_labels = $labels;
         if (!taxonomy_exists($taxonomy_name)) {
             /* Create taxonomy and attach it to the object type (post type) */
             // Capitalize words and it plural
             $name = self::beautify($name);
             $plural = self::beautify($plural);
             // Default labels, overwrite them with the given labels
             $labels = array_merge(array('name' => $plural, 'singular_name' => $name, 'search_items' => 'Search ' . $plural, 'all_items' => 'All ' . $plural, 'parent_item' => 'Parent ' . $name, 'parent_item_colon' => 'Parent ' . $name . ':', 'edit_item' => 'Edit ' . $name, 'update_item' => 'Update ' . $name, 'add_new_item' => 'Add New ' . $name, 'new_item_name' => 'New ' . $name . ' Name', 'menu_name' => $name), $taxonomy_labels);
             // Default args, overwrite them with the given labels
             $args = array_merge(array('labels' => $labels, 'hierarchical' => true, 'query_var' => true, 'rewrite' => true), $taxonomy_args);
             // Registers taxonomy
             add_action('init', function () use($taxonomy_name, $post_type_name, $args) {
                 register_taxonomy($taxonomy_name, $post_type_name, $args);
             });
         } else {
             /* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */
             add_action('init', function () use($taxonomy_name, $post_type_name) {
                 register_taxonomy_for_object_type($taxonomy_name, $post_type_name);
             });
         }
     }
 }
 public static function attribute_taxonomies()
 {
     global $woocommerce;
     if (!isset($woocommerce)) {
         return array();
     }
     $attributes = array();
     if (function_exists('wc_get_attribute_taxonomies') && function_exists('wc_attribute_taxonomy_name')) {
         $attribute_taxonomies = wc_get_attribute_taxonomies();
         if (empty($attribute_taxonomies)) {
             return array();
         }
         foreach ($attribute_taxonomies as $attribute) {
             $tax = wc_attribute_taxonomy_name($attribute->attribute_name);
             if (taxonomy_exists($tax)) {
                 $attributes[$tax] = ucfirst($attribute->attribute_name);
             }
         }
     } else {
         $attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
         if (empty($attribute_taxonomies)) {
             return array();
         }
         foreach ($attribute_taxonomies as $attribute) {
             $tax = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
             if (taxonomy_exists($tax)) {
                 $attributes[$tax] = ucfirst($attribute->attribute_name);
             }
         }
     }
     return $attributes;
 }
/**
 * Wrapper for wp_get_post_terms which supports ordering by parent.
 *
 * NOTE: At this point in time, ordering by menu_order for example isn't possible with this function. wp_get_post_terms has no
 *   filters which we can utilise to modify it's query. https://core.trac.wordpress.org/ticket/19094
 * 
 * @param  int $product_id
 * @param  string $taxonomy
 * @param  array  $args
 * @return array
 */
function wc_get_product_terms($product_id, $taxonomy, $args = array())
{
    if (!taxonomy_exists($taxonomy)) {
        return array();
    }
    if (empty($args['orderby']) && taxonomy_is_product_attribute($taxonomy)) {
        $args['orderby'] = wc_attribute_orderby($taxonomy);
    }
    // Support ordering by parent
    if (!empty($args['orderby']) && $args['orderby'] == 'parent') {
        $fields = isset($args['fields']) ? $args['fields'] : 'all';
        // Unset for wp_get_post_terms
        unset($args['orderby']);
        unset($args['fields']);
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
        usort($terms, '_wc_get_product_terms_parent_usort_callback');
        switch ($fields) {
            case 'names':
                $terms = wp_list_pluck($terms, 'name');
                break;
            case 'ids':
                $terms = wp_list_pluck($terms, 'term_id');
                break;
            case 'slugs':
                $terms = wp_list_pluck($terms, 'slug');
                break;
        }
    } else {
        $terms = wp_get_post_terms($product_id, $taxonomy, $args);
    }
    return $terms;
}
Example #29
0
 private function get_current_edit_taxonomy()
 {
     static $cache_current_taxonomy_data = null;
     if ($cache_current_taxonomy_data !== null) {
         return $cache_current_taxonomy_data;
     }
     $result = array('taxonomy' => null, 'term_id' => 0);
     do {
         if (!is_admin()) {
             break;
         }
         if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
             $taxnow = $_REQUEST['taxonomy'];
         } else {
             $taxnow = '';
         }
         if (empty($taxnow)) {
             break;
         }
         $result['taxonomy'] = $taxnow;
         if (empty($_REQUEST['tag_ID'])) {
             return $result;
         }
         $tag_ID = (int) $_REQUEST['tag_ID'];
         $result['term_id'] = $tag_ID;
     } while (false);
     $cache_current_taxonomy_data = $result;
     return $cache_current_taxonomy_data;
 }
 function init()
 {
     // Create the taxonomy if Media Folder doesn't create it (basically it doesn't create it if we are not in the admin)
     if (!taxonomy_exists('wpmf-category')) {
         register_taxonomy('wpmf-category', 'attachment', array('hierarchical' => true, 'show_in_nav_menus' => false, 'show_ui' => false));
     }
 }