Пример #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;
     }
 }
Пример #2
0
/**
 * Get all terms archives urls associated to a specific post
 *
 * @since 1.0
 *
 * @param int $post_ID The post ID
 * @return array $urls List of taxonomies URLs
 */
function get_rocket_post_terms_urls($post_ID)
{
    $urls = array();
    $taxonomies = get_object_taxonomies(get_post_type($post_ID), 'objects');
    foreach ($taxonomies as $taxonomy) {
        if (!$taxonomy->public) {
            continue;
        }
        // Get the terms related to post
        $terms = get_the_terms($post_ID, $taxonomy->name);
        if (!empty($terms)) {
            foreach ($terms as $term) {
                $term_url = get_term_link($term->slug, $taxonomy->name);
                if (!is_wp_error($term_url)) {
                    $urls[] = $term_url;
                }
            }
        }
    }
    /**
     * Filter the list of taxonomies URLs
     *
     * @since 1.1.0
     *
     * @param array $urls List of taxonomies URLs
     */
    $urls = apply_filters('rocket_post_terms_urls', $urls);
    return $urls;
}
Пример #3
0
function enlightenment_project_types_filter($args = null)
{
    $args = array('container' => 'ul', 'container_class' => 'project-types-filter', 'term_tag' => 'li', 'term_class' => 'project-type', 'current_term_class' => 'current-project-type', 'sep' => '', 'echo' => true);
    $args = apply_filters('enlightenment_project_types_filter_args', $args);
    $terms = get_terms('jetpack-portfolio-type');
    $output = '';
    if (!empty($terms)) {
        $output .= enlightenment_open_tag($args['container'], $args['container_class']);
        if (is_tax('jetpack-portfolio-type')) {
            $output .= enlightenment_open_tag($args['term_tag'], $args['term_class']);
            $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', get_post_type_archive_link('jetpack-portfolio'), 'jetpack-portfolio-type', __('All', 'enlightenment'));
            $output .= enlightenment_close_tag($args['term_tag']);
        }
        foreach ($terms as $term) {
            $class = $args['term_class'];
            $link = get_term_link($term, $term->taxonomy);
            $current_url = sprintf('%1$s%2$s%3$s', is_ssl() ? 'https://' : 'http://', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
            if ($link == $current_url) {
                $class .= ' ' . $args['current_term_class'];
            }
            $output .= enlightenment_open_tag($args['term_tag'], $class);
            $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', $link, $term->taxonomy, $term->name);
            $output .= enlightenment_close_tag($args['term_tag']);
        }
        $output .= enlightenment_close_tag($args['container']);
    }
    $output = apply_filters('enlightenment_project_types_filter', $output);
    if (!$args['echo']) {
        return $output;
    }
    echo $output;
}
Пример #4
0
    function portfolioTypes()
    {
        $portfolioTypes = get_terms('portfolio-type', 'orderby=id&order=ASC');
        if (count($portfolioTypes) > 0) {
            //current term
            $currentTermId = is_tax('portfolio-type') ? get_queried_object()->term_id : "";
            ?>
<ol class="breadcrumb">
                  <?php 
            foreach ($portfolioTypes as $types) {
                $activeClass = $currentTermId == $types->term_id ? " active " : "";
                ?>
                     <li class="gallery-type term-<?php 
                echo esc_attr($types->slug);
                echo esc_attr($activeClass);
                ?>
 term-id-<?php 
                echo esc_attr($types->term_id);
                ?>
">
                     <a href="<?php 
                echo esc_url(get_term_link($types));
                ?>
"><?php 
                echo esc_html($types->name);
                ?>
</a>
                     </li>
                 <?php 
            }
            ?>
                </ol><?php 
        }
    }
 protected function prepare_data($data)
 {
     $term_id = intval($data[0]);
     $taxonomy = $data[1];
     $url = get_term_link($term_id, $taxonomy);
     return array('url' => $url);
 }
 /**
  * @see Walker::start_el()
  * @since 2.1.0
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $category Category data object.
  * @param int $depth Depth of category in reference to parents.
  * @param integer $current_object_id
  */
 function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0)
 {
     $term_meta = get_option("taxonomy_{$cat->term_id}");
     $output .= '<li class="list-group-item cat-item cat-item-' . $cat->term_id;
     if ($args['current_category'] == $cat->term_id) {
         $output .= ' current-cat';
     }
     if ($args['has_children'] && $args['hierarchical']) {
         $output .= ' cat-parent';
     }
     if ($args['current_category_ancestors'] && $args['current_category'] && in_array($cat->term_id, $args['current_category_ancestors'])) {
         $output .= ' current-cat-parent';
     }
     $output .= '"><a href="' . get_term_link((int) $cat->term_id, 'product_cat') . '">';
     if (isset($term_meta['icon']) && $term_meta['icon'] != '') {
         $output .= '<i class="fa ' . $term_meta['icon'] . '"></i>';
     } else {
         //$output .=	'<i class="fa fa-star"></i>';
     }
     $output .= '<span class="heading">';
     $output .= '<span class="menu-title">' . __($cat->name, 'woocommerce') . '</span>';
     if ($cat->category_description != '') {
         $output .= '<span class="menu-desc">' . wpo_string_limit_words($cat->category_description, 5) . '</span>';
     }
     $output .= '</span>';
     $output .= '</a>';
     if ($args['show_count']) {
         $output .= ' <span class="badge count">(' . $cat->count . ')</span>';
     }
 }
Пример #7
0
function add_new_category()
{
    if (is_user_logged_in()) {
        if (isset($_POST['cat_name']) && !empty($_POST['cat_name']) && isset($_POST['parent_id']) && !empty($_POST['parent_id'])) {
            $cat_name = esc_html($_POST['cat_name']);
            $parent_id = esc_html($_POST['parent_id']);
            $new_cat_args = array($cat_name, 'bookmark-category');
            if ($parent_id == -1) {
                // Add Term to Bookmark Category
                $new_category = wp_insert_term($cat_name, 'bookmark-category');
            } else {
                // Add Term to Bookmark Category
                $new_category = wp_insert_term($cat_name, 'bookmark-category', array('parent' => $parent_id));
            }
            if (!is_wp_error($new_category)) {
                $term = get_term_by('id', $new_category['term_id'], 'bookmark-category');
                // Add Term to User
                wp_set_object_terms($current_user->ID, array($term->slug), 'bookmark-category', true);
                $returner = array('success' => true, 'cat_id' => $new_category['term_id'], 'cat_slug' => $term->slug, 'cat_link' => get_term_link($term, 'bookmark-category'));
            } else {
                $returner = array('success' => false, 'reason' => 'WP Error on term creation.');
            }
        } else {
            $returner = array('success' => false, 'reason' => 'Post values not set.');
        }
    } else {
        $returner = array('success' => false, 'reason' => 'User not logged in.');
    }
    echo json_encode($returner);
    exit;
}
Пример #8
0
 /**
  * will redirect old links to new link structures.
  */
 public static function redirection()
 {
     global $wpdb, $wp_query;
     if (is_object($wp_query) && $wp_query->get('em_redirect')) {
         //is this a querystring url?
         if ($wp_query->get('event_slug')) {
             $event = $wpdb->get_row('SELECT event_id, post_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get('event_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
             if (!empty($event)) {
                 $EM_Event = em_get_event($event['event_id']);
                 $url = get_permalink($EM_Event->post_id);
             }
         } elseif ($wp_query->get('location_slug')) {
             $location = $wpdb->get_row('SELECT location_id, post_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get('location_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
             if (!empty($location)) {
                 $EM_Location = em_get_location($location['location_id']);
                 $url = get_permalink($EM_Location->post_id);
             }
         } elseif ($wp_query->get('category_slug')) {
             $url = get_term_link($wp_query->get('category_slug'), EM_TAXONOMY_CATEGORY);
         }
         if (!empty($url)) {
             wp_redirect($url, 301);
             exit;
         }
     }
 }
Пример #9
0
function ubik_places_ancestors($taxonomy = 'places', $depth = 2, $sep = ', ')
{
    // Initialize
    $output = '';
    $places = array();
    // Get term ID; we only need one
    global $post;
    $terms = get_the_terms($post->ID, $taxonomy);
    $term = $terms[0];
    // Only proceed if this term shows inheritance
    if (!empty($term->parent)) {
        // The grunt work
        $ancestors = ubik_terms_ancestors($term->term_id, $taxonomy);
        // Ready to roll
        if (!empty($ancestors) && count($ancestors) > 1) {
            // Remove basal term, limit depth, and reverse (as is the custom for displaying places)
            $ancestors = array_reverse(array_slice(array_slice($ancestors, 0, -1), 0, $depth));
            // Loop through all ancestors and create links
            if (!empty($ancestors)) {
                foreach ($ancestors as $ancestor) {
                    $place = get_term_by('id', $ancestor, $taxonomy);
                    $places[] = '<a href="' . get_term_link($place->term_id, $taxonomy) . '" rel="tag">' . $place->name . '</a>';
                }
                // Assemble output
                if (!empty($places)) {
                    $output = implode($sep, $places);
                }
            }
        }
    }
    return $output;
}
/**
 * Output question categories
 * @param  array $args
 * @return string
 */
function ap_question_categories_html($args = array())
{
    $defaults = array('question_id' => get_the_ID(), 'list' => false, 'tag' => 'span', 'class' => 'question-categories', 'label' => __('Categories', 'categories-for-anspress'), 'echo' => false);
    if (!is_array($args)) {
        $defaults['question_id'] = $args;
        $args = $defaults;
    } else {
        $args = wp_parse_args($args, $defaults);
    }
    $cats = get_the_terms($args['question_id'], 'question_category');
    if ($cats) {
        $o = '';
        if ($args['list']) {
            $o = '<ul class="' . $args['class'] . '">';
            foreach ($cats as $c) {
                $o .= '<li><a href="' . esc_url(get_term_link($c)) . '" title="' . $c->description . '">' . $c->name . '</a></li>';
            }
            $o .= '</ul>';
        } else {
            $o = $args['label'];
            $o .= '<' . $args['tag'] . ' class="' . $args['class'] . '">';
            foreach ($cats as $c) {
                $o .= '<a href="' . esc_url(get_term_link($c)) . '" title="' . $c->description . '">' . $c->name . '</a>';
            }
            $o .= '</' . $args['tag'] . '>';
        }
        if ($args['echo']) {
            echo $o;
        }
        return $o;
    }
}
Пример #11
0
 public function tags()
 {
     if (!did_action('pre_get_posts')) {
         return array();
     }
     $queried_object = get_queried_object();
     $tags = array();
     $default_tags = array('og:type' => 'website', 'og:locale' => get_locale(), 'og:site_name' => get_bloginfo('name'), 'og:image' => $this->get_image_url());
     if (is_front_page()) {
         $tags = array('og:url' => home_url('/'), 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description'));
     } else {
         if (is_singular()) {
             $tags = array('og:type' => 'article', 'og:url' => get_permalink($queried_object), 'og:title' => get_the_title($queried_object), 'og:description' => $this->generate_preview($queried_object->post_content), 'article:published_time' => date('c', strtotime($queried_object->post_date_gmt)), 'article:modified_time' => date('c', strtotime($queried_object->post_modified_gmt)), 'article:author' => get_author_posts_url($queried_object->post_author));
         } else {
             if (is_tax() || is_category() || is_tag()) {
                 $tags = array('og:url' => get_term_link($queried_object), 'og:title' => $queried_object->name, 'og:description' => $this->generate_preview($queried_object->description));
             } else {
                 if (is_author()) {
                     $tags = array('og:type' => 'profile', 'og:url' => get_author_posts_url($queried_object->ID), 'og:title' => $queried_object->display_name, 'og:description' => $this->generate_preview($queried_object->user_description), 'profile:first_name' => get_the_author_meta('first_name', $queried_object->ID), 'profile:last_name' => get_the_author_meta('last_name', $queried_object->ID));
                 }
             }
         }
     }
     $tags = array_merge($default_tags, $tags);
     return apply_filters('appthemes_open_graph_meta_tags', $tags);
 }
/**
 * Shortcode terms index
 */
function pronamic_framework_shortcode_terms_index($atts)
{
    extract(shortcode_atts(array('taxonomy' => null, 'parent' => 0), $atts));
    $result = '';
    if ($taxonomy) {
        $terms = get_terms($taxonomy);
        $alphabet = array();
        foreach ($terms as $term) {
            $letter = strtoupper(substr($term->name, 0, 1));
            if (!isset($alphabet[$letter])) {
                $alphabet[$letter] = array();
            }
            $alphabet[$letter][] = $term;
        }
        if (!empty($alphabet)) {
            $result .= '<ul class="pronamic-terms-index-list">';
            foreach ($alphabet as $letter => $terms) {
                $result .= '<li>';
                $result .= $letter;
                if (!empty($terms)) {
                    $result .= '<ul>';
                    foreach ($terms as $term) {
                        $result .= '<li>';
                        $result .= sprintf('<a href="%s">%s</a>', get_term_link($term), $term->name);
                        $result .= '</li>';
                    }
                    $result .= '</ul>';
                }
                $result .= '</li>';
            }
            $result .= '</ul>';
        }
    }
    return $result;
}
Пример #13
0
 public function permalink()
 {
     $permalink = get_term_link($this->term_id, $this->taxonomy);
     if (!is_wp_error($permalink)) {
         return $this->permalink = $permalink;
     }
 }
Пример #14
0
function browse_displays()
{
    $custom_taxonomy = 'gallery-wing';
    $custom_terms = get_terms($custom_taxonomy);
    $str_return = '<ul>';
    foreach ($custom_terms as $custom_term) {
        wp_reset_query();
        $args = array('post_type' => 'display', 'tax_query' => array(array('taxonomy' => $custom_taxonomy, 'field' => 'slug', 'terms' => $custom_term->slug, 'include_children' => false)));
        $loop = new WP_Query($args);
        $term_name = $custom_term->name;
        $term_slug = $custom_term->slug;
        $term_link = get_term_link($term_slug, $custom_taxonomy);
        $str_return .= '<li><a href="' . $term_link . '">' . $term_name . '</a>';
        if ($loop->have_posts()) {
            $str_return .= '<ol>';
            while ($loop->have_posts()) {
                $loop->the_post();
                $str_return .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li> ';
            }
            $str_return .= '</ol>';
        }
        $str_return .= '</li>';
    }
    $str_return .= '</ul>';
    return $str_return;
}
Пример #15
0
 /**
  * Generate the form configuration array for this tab
  *
  * @since  0.1
  * @access private
  */
 private function populate_form_array()
 {
     // define the sections
     $this->sections = array('locations' => array('title' => _x('Page Slugs', 'page locations section title', 'wpsc'), 'fields' => array('store_slug', 'store_as_front_page', 'category_base_slug', 'product_base_slug', 'cart_page_slug', 'checkout_page_slug', 'customer_account_page_slug', 'login_page_slug', 'password_reminder_page_slug', 'register_page_slug', 'prefix_product_slug', 'hierarchical_product_category_url')), 'titles' => array('title' => _x('Page Titles', 'page titles section title', 'wpsc'), 'fields' => array('store_title', 'cart_page_title', 'checkout_page_title', 'customer_account_page_title', 'login_page_title', 'password_reminder_page_title', 'register_page_title')));
     // Shortcut variables for buttons and messages
     $view_button = '<a class="button button-secondary button-view-page" href="%1$s">%2$s</a>';
     $view_message = _x('View', 'view page', 'wpsc');
     $view_category_message = _x('Sample Category', 'view page', 'wpsc');
     $view_product_message = _x('Sample Product', 'view page', 'wpsc');
     // generate sample URLs for single product and product category
     $base_shop_url = '<small>' . esc_url(wpsc_get_store_url('/')) . '</small>';
     $sample_category = get_terms('wpsc_product_category', array('number' => 1));
     $sample_product = get_posts(array('post_type' => 'wpsc-product', 'numberposts' => 1));
     // generate form fields
     $this->form_array = array('store_slug' => array('type' => 'textfield', 'prepend' => '<small>' . esc_url(home_url('/')) . '</small>', 'title' => _x('Main store', 'page slug setting', 'wpsc'), 'append' => sprintf($view_button, wpsc_get_store_url(), $view_message), 'validation' => 'required', 'class' => 'regular-text'), 'store_as_front_page' => array('type' => 'radios', 'title' => _x('Display main store on front page', 'page settings', 'wpsc'), 'options' => array(1 => _x('Yes', 'settings', 'wpsc'), 0 => _x('No', 'settings', 'wpsc'))), 'store_title' => array('type' => 'textfield', 'title' => _x('Main store title', 'page slug title', 'wpsc'), 'validation' => 'required'), 'category_base_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => empty($sample_category) ? '' : sprintf($view_button, get_term_link($sample_category[0]), $view_category_message), 'title' => _x('Product category base slug', 'permalinks setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'product_base_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => empty($sample_product) ? '' : sprintf($view_button, get_permalink($sample_product[0]), $view_product_message), 'title' => _x('Single product base slug', 'permalinks setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'prefix_product_slug' => array('type' => 'checkboxes', 'title' => _x('Product prefix', 'permalinks setting', 'wpsc'), 'options' => array(1 => __('Include category slug in product URL.', 'wpsc'))), 'hierarchical_product_category_url' => array('type' => 'radios', 'title' => _x('Hierarchical product category URL', 'permalinks setting', 'wpsc'), 'options' => array(1 => _x('Yes', 'settings', 'wpsc'), 0 => _x('No', 'settings', 'wpsc')), 'description' => __('When hierarchical product category URL is enabled, parent product categories are also included in the product URL.', 'wpsc')), 'cart_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => sprintf($view_button, wpsc_get_cart_url(), $view_message), 'title' => _x('Cart page', 'page settings', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'cart_page_title' => array('type' => 'textfield', 'title' => _x('Cart page', 'page settings', 'wpsc'), 'validation' => 'required'), 'checkout_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Checkout page', 'page setting', 'wpsc'), 'validation' => 'required', 'class' => 'regular-text'), 'checkout_page_title' => array('type' => 'textfield', 'title' => _x('Checkout page', 'page settings', 'wpsc'), 'validation' => 'required'), 'customer_account_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'append' => sprintf($view_button, wpsc_get_customer_account_url(), $view_message), 'title' => _x('Customer account page', 'permalinks setting', 'wpsc'), 'validation' => 'required|slug_not_conflicted', 'class' => 'regular-text'), 'customer_account_page_title' => array('type' => 'textfield', 'title' => _x('Customer account page', 'page settings', 'wpsc'), 'validation' => 'required'), 'login_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Login page', 'permalinks setting', 'wpsc'), 'description' => __('Leaving this field blank will disable the page.', 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'login_page_title' => array('type' => 'textfield', 'title' => _x('Login page', 'page settings', 'wpsc'), 'validation' => 'required'), 'password_reminder_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Password reminder page', 'permalinks setting', 'wpsc'), 'description' => __("Leaving this field blank will disable the page.", 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'password_reminder_page_title' => array('type' => 'textfield', 'title' => _x('Password reminder page', 'page settings', 'wpsc'), 'validation' => 'required'), 'register_page_slug' => array('type' => 'textfield', 'prepend' => $base_shop_url, 'title' => _x('Register page', 'permalinks setting', 'wpsc'), 'description' => __("Leaving this field blank will disable the page.", 'wpsc'), 'validation' => 'slug_not_conflicted', 'class' => 'regular-text'), 'register_page_title' => array('type' => 'textfield', 'title' => _x('Register page', 'page settings', 'wpsc'), 'validation' => 'required'));
     // display warnings for login, register and password reminder pages when
     // "Anyone can register" is disabled.
     if (!get_option('users_can_register')) {
         $additional_description = '<br /> ' . __('<strong>Note:</strong> Enable "Anyone can register" in <a href="%s">Settings -> General</a> first if you want to use this page.', 'wpsc');
         $additional_description = sprintf($additional_description, admin_url('options-general.php'));
         $this->form_array['login_page_slug']['description'] .= $additional_description;
         $this->form_array['password_reminder_page_slug']['description'] .= $additional_description;
         $this->form_array['register_page_slug']['description'] .= $additional_description;
     }
 }
Пример #16
0
 /**
  * Get the URL to the term and returns it's path
  *
  * @param string $tag
  * @param string $taxonomy
  *
  * @return string
  */
 protected function get_target_url($tag, $taxonomy)
 {
     // Use the correct URL path
     $url = parse_url(get_term_link($tag, $taxonomy));
     $url = $url['path'];
     return $url;
 }
Пример #17
0
function ap_question_categories_html($post_id = false, $list = true)
{
    if (!ap_opt('enable_categories')) {
        return;
    }
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    $cats = get_the_terms($post_id, 'question_category');
    if ($cats) {
        if ($list) {
            $o = '<ul class="question-categories">';
            foreach ($cats as $c) {
                $o .= '<li><a href="' . esc_url(get_term_link($c)) . '" title="' . $c->description . '">' . $c->name . '</a></li>';
            }
            $o .= '</ul>';
            echo $o;
        } else {
            $o = 'Categories:';
            $o .= ' <span class="question-categories-list">';
            foreach ($cats as $c) {
                $o .= '<a href="' . esc_url(get_term_link($c)) . '" title="' . $c->description . '">' . $c->name . '</a>';
            }
            $o .= '</span>';
            echo $o;
        }
    }
}
Пример #18
0
function road_popular_categories_shortcode($atts)
{
    $atts = shortcode_atts(array('category' => '', 'image' => ''), $atts, 'popular_categories');
    $html = '';
    $html .= '<div class="category-wrapper">';
    $pcategory = get_term_by('slug', $atts['category'], 'product_cat', 'ARRAY_A');
    if ($pcategory) {
        $html .= '<div class="category-list">';
        $html .= '<h3><a href="' . get_term_link($pcategory['slug'], 'product_cat') . '">' . $pcategory['name'] . '</a></h3>';
        $html .= '<ul>';
        $args2 = array('taxonomy' => 'product_cat', 'child_of' => 0, 'parent' => $pcategory['term_id'], 'orderby' => 'name', 'show_count' => 0, 'pad_counts' => 0, 'hierarchical' => 0, 'title_li' => '', 'hide_empty' => 0);
        $sub_cats = get_categories($args2);
        if ($sub_cats) {
            foreach ($sub_cats as $sub_category) {
                $html .= '<li><a href="' . get_term_link($sub_category->slug, 'product_cat') . '">' . $sub_category->name . '</a></li>';
            }
        }
        $html .= '</ul>';
        $html .= '</div>';
        if ($atts['image'] != '') {
            $html .= '<div class="cat-img">';
            $html .= '<a href="' . get_term_link($pcategory['slug'], 'product_cat') . '"><img class="category-image" src="' . esc_attr($atts['image']) . '" alt="" /></a>';
            $html .= '</div>';
        }
    }
    $html .= '</div>';
    return $html;
}
 /**
  * @see Walker::start_el()
  * @since 2.1.0
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $category Category data object.
  * @param int $depth Depth of category in reference to parents.
  * @param array $args
  */
 function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0)
 {
     if (!empty($args['hierarchical'])) {
         $pad = str_repeat('&nbsp;', $depth * 3);
     } else {
         $pad = '';
     }
     if ($args['show_portfolio'] == 'yes') {
         $font_weight = 'style="font-weight:bold" ';
     } else {
         $font_weight = '';
     }
     $current_cat_name = '';
     $output .= '<option ' . $font_weight . 'class="level-' . $depth . '" data-id="' . $cat->term_id . '" value="' . get_term_link((int) $cat->term_id, 'portfolio_cat') . '" ';
     if ($args['current_category'] == $cat->term_id) {
         $output .= ' selected="selected"';
     }
     $output .= '>' . $pad . '<strong>' . $cat->name . '</strong>';
     if ($args['show_count']) {
         $output .= ' <span class="count">&nbsp;(' . $cat->count . ')</span>';
     }
     if ($args['show_portfolio'] == 'yes') {
         $output .= $this->get_portfolio($args['current_portfolio'], $cat->term_id, $cat->slug, $args['portfolio_orderby'], $args['hierarchical'], $depth, $pad);
     }
 }
Пример #20
0
function _zn_documentation($options)
{
    $categories = get_terms('documentation_category', array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'show_count ' => 1));
    $limit = '6';
    if (!empty($options['doc_num_items'])) {
        $limit = $options['doc_num_items'];
    }
    $count = count($categories);
    $i = 1;
    foreach ($categories as $category) {
        if ($i % 2 == 1) {
            echo '<div class="row-fluid zn_photo_gallery">';
        }
        echo '<div class="span6">';
        echo '<h3><a href="' . get_term_link($category->slug, 'documentation_category') . '">' . $category->name . ' (' . $category->count . ')</a></h3>';
        $args = array('post_type' => 'documentation', 'post_status' => 'publish', 'posts_per_page' => $limit, 'documentation_category' => $category->slug);
        $zn_doc = new WP_Query($args);
        echo '<ol>';
        while ($zn_doc->have_posts()) {
            $zn_doc->the_post();
            global $post;
            echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
        }
        // end loop
        echo "</ol>";
        echo '</div>';
        if ($i % 2 == 0 || $i == $count) {
            echo '</div>';
        }
        $i++;
    }
}
Пример #21
0
 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
function ubik_terms_tag_shortcode($atts, $content = '')
{
    // Setup variables
    $args = shortcode_atts(array('slug' => ''), $atts);
    $slug = (string) $args['slug'];
    $taxonomy = 'post_tag';
    $term = $link = '';
    // If the slug is not empty try to fetch the term and generate a link
    if (!empty($slug)) {
        $term = get_term_by('slug', $slug, $taxonomy);
    } elseif (empty($slug) && !empty($content)) {
        $term = get_term_by('slug', strtolower($content), $taxonomy);
    }
    // Try to generate a link
    if (!empty($term)) {
        $link = get_term_link($term);
    }
    // Assemble the HTML
    if (!empty($link)) {
        if (!empty($content)) {
            $content = '<a href="' . $link . '" rel="tag">' . $content . '</a>';
        } elseif (empty($content)) {
            $content = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
            // Allows for [tag slug=example/] to fill content
        }
    }
    return apply_filters('ubik_terms_tag_shortcode', $content);
}
 /**
  * List multiple brands shortcode
  *
  * @access public
  * @param array $atts
  * @return string
  */
 public static function brands($atts)
 {
     global $woocommerce_loop;
     if (empty($atts)) {
         return '';
     }
     extract(shortcode_atts(array('orderby' => 'title', 'columns' => '6', 'order' => 'asc', 'per_page' => '6', 'carousel' => 'true'), $atts));
     $brands = get_categories(array('hide_empty' => 0, 'taxonomy' => 'product_brand', 'orderby' => $orderby, 'order' => $order, 'number' => $per_page));
     $output = '';
     $columns = intval($columns);
     $columns = 12 / $columns;
     foreach ($brands as $brand) {
         $thumbnail_id = get_woocommerce_term_meta($brand->term_id, 'thumbnail_id');
         $image_src = wp_get_attachment_image_src($thumbnail_id, 'full');
         $brand_link = get_term_link($brand, 'product_brand');
         $brand_item = '<div class="brand-item">';
         $brand_item .= "\t" . '<a href="' . $brand_link . '"><img alt="' . $brand->cat_name . '" src="' . $image_src[0] . '" width="144" height="36" /></a>';
         $brand_item .= '</div>';
         if ($carousel === 'false') {
             $output .= '<div class="col-xs-12 col-sm-' . $columns . '">' . $brand_item . '</div>';
         } else {
             $output .= $brand_item;
         }
     }
     return $output;
 }
Пример #24
0
 function widget($args, $instance)
 {
     extract($args);
     $warrior_category_list_title = apply_filters('widget_title', empty($instance['warrior_category_list_title']) ? esc_html__('Categories', 'newmagz') : $instance['warrior_category_list_title'], $instance, $this->id_base);
     echo $before_widget;
     echo '<div class="category-widget">';
     echo $before_title . esc_attr($warrior_category_list_title) . $after_title;
     echo '<div class="categories">';
     echo '<ul>';
     $taxonomy = 'category';
     $a = 1;
     $tax_terms = get_categories();
     foreach ($tax_terms as $tax_term) {
         echo '<li>';
         echo '<div class="number">' . $a++ . '</div>';
         echo '<div class="summary">';
         echo '<a href="' . esc_url(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf(esc_html__("View all posts in %s", "newmagz"), $tax_term->name) . '" ' . '>' . $tax_term->name . '<small>' . $tax_term->category_count . esc_html__(' Articles', 'newmagz') . '</small></a>';
         echo '</div>';
         echo '</li>';
     }
     echo '</ul>';
     echo '</div>';
     echo '</div>';
     echo $after_widget;
 }
Пример #25
-1
    function kmw__faq_sort_categories($taxtype)
    {
        $args = array('parent' => 0, 'orderby' => 'name', 'ord' => 'ASC', 'style' => 'list', 'hide_empty' => 0, 'title_li' => '', 'number' => null, 'taxonomy' => $taxtype);
        $get_tax_name = get_taxonomy($taxtype);
        $cats = get_categories($args);
        ob_start();
        ?>
			<div class="dropdown-sorter">
				<span class="button dropdown-button">
					<?php 
        echo $get_tax_name->label;
        ?>
					<ul>
					<?php 
        foreach ($cats as $category) {
            ?>
						<li><a href="<?php 
            echo get_term_link($category);
            ?>
"><?php 
            echo $category->name;
            ?>
</a></li>
					<?php 
        }
        ?>
					</ul>
				</span>
			</div>		
		<?php 
        $return = ob_get_clean();
        return $return;
    }
Пример #26
-1
 /**
  * Start the element output.
  * @param string $output            Passed by reference. Used to append additional content.
  * @param object $object            The data object.
  * @param int    $depth             Depth of the item.
  * @param array  $args              An array of additional arguments.
  * @param int    $current_object_id ID of the current item.
  */
 function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     extract($args);
     $cat_name = esc_attr($category->name);
     $cat_name = apply_filters('list_cats', $cat_name, $category);
     $link = '<a href="' . esc_url(get_term_link($category)) . '" ';
     if ($use_desc_for_title == 0 || empty($category->description)) {
         $link .= 'title="' . esc_attr(sprintf(__('View all posts filed under %s', ZF_WORDPRESS_CATEGORY_ACCORDION_LANG), $cat_name)) . '"';
     } else {
         $link .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"';
     }
     $link .= ' class="item-link"';
     $link .= '>';
     $link .= $cat_name;
     if ($show_count) {
         $link .= ' <span class="count">(' . number_format_i18n($category->count) . ')</span>';
     }
     $link .= '</a>';
     $output .= "\t<li";
     $class = 'cat-item cat-item-' . $category->term_id . ' level-' . $depth;
     if ($has_children) {
         $class .= ' has-sub';
     }
     if (!empty($current_category)) {
         $_current_category = get_term($current_category, $category->taxonomy);
         if ($category->term_id == $current_category) {
             $class .= ' current-cat';
         } elseif ($category->term_id == $_current_category->parent) {
             $class .= ' current-cat-parent';
         }
     }
     $output .= ' class="' . $class . '"';
     $output .= ">{$link}\n";
 }
Пример #27
-1
 function WIPTakeTaxonomyParent($id, $taxName = 'category', $separator)
 {
     if ($id == '') {
         $id = 0;
     }
     if (!is_object($id)) {
         $id = (int) $id;
     }
     if ($taxName == '') {
         return $id;
     }
     $parents = get_term_by('id', $id, $taxName);
     $parent = '';
     if ($parents->parent && $parents->parent != $id) {
         $par = get_term_by('id', $parents->parent, $taxName);
         if (WIPTakeTaxonomyParent($par->term_id, $taxName, '')) {
             $parent = WIPTakeTaxonomyParent($par->term_id, $taxName, $separator);
         }
         $parent .= '<a href="' . get_term_link((int) $parents->parent, $taxName) . '">' . $par->name . '</a> ';
         if ($separator) {
             $parent .= $separator;
         }
         return $parent;
     }
     return false;
 }
Пример #28
-1
function getTermFamily($termId, $taxonomy = 'category', $childArgs = array(), $level = 0)
{
    //get this items first then recurse into children
    $current = new Dion\TaxonomyHierarchy($termId, $taxonomy, $childArgs);
    ?>
    <p style="padding-left:<?php 
    echo ($level + 1) * 10;
    ?>
px;"  >
        <a href="<?php 
    echo get_term_link($current->tree['current']);
    ?>
"><?php 
    echo $current->tree['current']->name;
    ?>
</a>
    </p>
        <?php 
    //get child term list
    if ($current->hasChildren) {
        $newLevel = $level + 1;
        foreach ($current->tree['children'] as $childTerm) {
            getTermFamily($childTerm->term_id, $childTerm->taxonomy, array(), $newLevel);
        }
    }
    ?>

    <?php 
}
 function start_el(&$output, $category, $depth, $args)
 {
     extract($args);
     $cat_name = esc_attr($category->name);
     $cat_name = apply_filters('list_cats', $cat_name, $category);
     $link = '<a href="' . esc_attr(get_term_link($category->slug, 'portfolio_category')) . ' " ';
     //$link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
     //$link .= 'rel="'.$category->slug.'" ';
     $dataoption = $category->slug;
     $class = '';
     if (!empty($current_category)) {
         $_current_category = get_term($current_category, $category->taxonomy);
         if ($category->term_id == $current_category) {
             $class .= ' selected';
         } elseif ($category->term_id == $_current_category->parent) {
             $class .= ' current-cat-parent';
         }
     }
     $link .= ' class="' . $class . '"';
     $link .= '>';
     $link .= $cat_name . '</a>';
     if ('list' == $args['style']) {
         $output .= "\t<li";
         $output .= ">{$link}\n";
     } else {
         $output .= "\t{$link}<br />\n";
     }
 }
 /**
  * Get current page URL for layered nav items.
  * @return string
  */
 protected function get_page_base_url()
 {
     if (defined('SHOP_IS_ON_FRONT')) {
         $link = home_url();
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $link = get_post_type_archive_link('product');
     } else {
         $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
     }
     // Min/Max
     if (isset($_GET['min_price'])) {
         $link = add_query_arg('min_price', wc_clean($_GET['min_price']), $link);
     }
     if (isset($_GET['max_price'])) {
         $link = add_query_arg('max_price', wc_clean($_GET['max_price']), $link);
     }
     // Orderby
     if (isset($_GET['orderby'])) {
         $link = add_query_arg('orderby', wc_clean($_GET['orderby']), $link);
     }
     // Search Arg
     if (get_search_query()) {
         $link = add_query_arg('s', get_search_query(), $link);
     }
     // Post Type Arg
     if (isset($_GET['post_type'])) {
         $link = add_query_arg('post_type', wc_clean($_GET['post_type']), $link);
     }
     return $link;
 }