Ejemplo n.º 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;
     }
 }
 /**
  * Get posts
  *
  * This can optionally be used by the template.
  * $this->instance is sanitized before being made available here.
  *
  * @since 0.9
  * @return array Posts for widget template
  */
 function ctfw_get_posts()
 {
     // Base arguments
     $args = array('post_type' => 'ctc_sermon', 'orderby' => $this->ctfw_instance['orderby'], 'order' => $this->ctfw_instance['order'], 'numberposts' => $this->ctfw_instance['limit'], 'suppress_filters' => false);
     // Topic argument
     if ('all' != $this->ctfw_instance['topic'] && ($topic_term = get_term($this->ctfw_instance['topic'], 'ctc_sermon_topic'))) {
         $args['ctc_sermon_topic'] = $topic_term->slug;
     }
     // Book argument
     if ('all' != $this->ctfw_instance['book'] && ($book_term = get_term($this->ctfw_instance['book'], 'ctc_sermon_book'))) {
         $args['ctc_sermon_book'] = $book_term->slug;
     }
     // Series argument
     if ('all' != $this->ctfw_instance['series'] && ($series_term = get_term($this->ctfw_instance['series'], 'ctc_sermon_series'))) {
         $args['ctc_sermon_series'] = $series_term->slug;
     }
     // Speaker argument
     if ('all' != $this->ctfw_instance['speaker'] && ($speaker_term = get_term($this->ctfw_instance['speaker'], 'ctc_sermon_speaker'))) {
         $args['ctc_sermon_speaker'] = $speaker_term->slug;
     }
     // Get posts
     $posts = get_posts($args);
     // Return filtered
     return apply_filters('ctfw_sermons_widget_get_posts', $posts);
 }
Ejemplo n.º 3
0
function dvteamtaxonomy_show_id($ver, $name, $id)
{
    $term = get_term($id, 'dvteamtaxonomy');
    $term_id = $term->term_id;
    $taxonomy = $term->name;
    return 'dvteamtaxonomyid' === $name ? $term_id : $ver;
}
Ejemplo n.º 4
0
/**
 * Build WP_Query object for the given slider
 * 
 * @see Hyyan_Slider_Shortcode::FILTER_SHORTCODE_QueryArgs
 * 
 * @param string $slider slider name
 * @param string $order slides order
 * @param string $orderBy order slides by ?
 * 
 * @return \WP_Query
 * @throws \RuntimeException if the slider does not exist
 */
function hyyan_slider_query($slider, $order = 'DESC', $orderBy = 'rand')
{
    $slider = esc_attr((string) $slider);
    /** check for term existance */
    if (!term_exists($slider, Hyyan_Slider::CUSTOM_TAXONOMY)) {
        throw new \RuntimeException(sprintf('Can not build query for %s slider - term does not exist', $slider));
    }
    if (function_exists('pll_get_term')) {
        // get slider object
        $term = get_term_by('slug', $slider, Hyyan_Slider::CUSTOM_TAXONOMY);
        $slider = $term->slug;
        if ($term) {
            // find the id of translated slider
            $id = pll_get_term($term->term_id);
            // get translated slider object
            $trans_term = get_term($id, Hyyan_Slider::CUSTOM_TAXONOMY);
            if ($trans_term && !$trans_term instanceof WP_Error) {
                $slider = $trans_term->slug;
            }
        }
    }
    /**
     * Query object
     * 
     * @see Hyyan_Slider_Shortcode::FILTER_SHORTCODE_QueryArgs
     * 
     * @var WP_Query 
     */
    $query = new WP_Query(apply_filters(Hyyan_Slider_Events::FILTER_SHORTCODE_QueryArgs, array('post_type' => Hyyan_Slider::CUSTOM_POST, 'taxonomy' => Hyyan_Slider::CUSTOM_TAXONOMY, 'term' => $slider, 'post_status' => 'publish', 'order' => esc_attr($order), 'orderby' => esc_attr($orderBy), 'posts_per_page' => -1, 'lang' => null)));
    return $query;
}
Ejemplo n.º 5
0
function bdn_browse_docs()
{
    global $wp_query;
    if (is_singular() || is_404() || is_admin()) {
        return false;
    }
    if (empty($wp_query->query_vars['post_type'])) {
        $wp_query->query_vars['post_type'] = array('doc');
        $wp_query->query_vars['orderby'] = 'modified';
    }
    if (is_home() && !isset($_GET['all']) && ($default_view = get_user_meta(get_current_user_id(), 'default_view', true))) {
        if ($default_view == 'default_desk') {
            $default_desk = (int) get_user_meta(get_current_user_id(), 'default_desk', true);
            $term = get_term($default_desk, 'desk');
            if (!empty($term) && !is_wp_error($term)) {
                $wp_query->query_vars['desk'] = $term->slug;
            }
        } elseif ($default_view == 'user_docs') {
            $user = wp_get_current_user();
            $wp_query->query_vars['author_name'] = $user->user_login;
        }
    }
    if (!empty($_GET['hide-final-published'])) {
        $wp_query->query_vars['tax_query'][] = array('taxonomy' => 'status', 'field' => 'slug', 'terms' => array('final-published'), 'operator' => 'NOT IN');
    }
}
Ejemplo n.º 6
0
 public function manage_rank_column($display, $column, $term_id)
 {
     if ('users' === $column) {
         $term = get_term($term_id, 'rank');
         echo $term->count ? $term->count : 0;
     }
 }
Ejemplo n.º 7
0
function link_cat_row($category)
{
    global $class;
    if (!($category = get_term($category, 'link_category'))) {
        return false;
    }
    if (is_wp_error($category)) {
        return $category;
    }
    $name = $name_override ? $name_override : $category->name;
    if (current_user_can('manage_categories')) {
        $edit = "<a class='row-title' href='link-category.php?action=edit&amp;cat_ID={$category->term_id}' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "' class='edit'>{$name}</a>";
        $default_cat_id = (int) get_option('default_link_category');
    } else {
        $edit = $name;
    }
    $class = " class='alternate'" == $class ? '' : " class='alternate'";
    $category->count = number_format_i18n($category->count);
    $count = $category->count > 0 ? "<a href='link-manager.php?cat_id={$category->term_id}'>{$category->count}</a>" : $category->count;
    $output = "<tr id='link-cat-{$category->term_id}'{$class}>\n\t\t\t   <th scope='row' class='check-column'>";
    if (absint(get_option('default_link_category')) != $category->term_id) {
        $output .= "<input type='checkbox' name='delete[]' value='{$category->term_id}' />";
    } else {
        $output .= "&nbsp;";
    }
    $output .= "</th>\n\t\t\t\t<td>{$edit}</td>\n\t\t\t\t<td>{$category->description}</td>\n\t\t\t\t<td class='num'>{$count}</td></tr>";
    return apply_filters('link_cat_row', $output);
}
Ejemplo n.º 8
0
/**
 * Misc functions
 *
 * @since     1.0.0
 * @updated   1.0.8
 */
function mark_posts_misc_functions()
{
    // mark all posts
    if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET['mark-all-posts-term-id'])) {
        $term_id = $_GET['mark-all-posts-term-id'];
        /* TODO:: SECURITY */
        // set color only for selected post types
        $get_mark_posts_settings = get_option('mark_posts_settings');
        foreach ($get_mark_posts_settings['mark_posts_posttypes'] as $post_type) {
            $args = array('posts_per_page' => -1, 'post_type' => $post_type);
            // get all posts
            $all_posts = get_posts($args);
            foreach ($all_posts as $post) {
                // Sanitize the user input.
                $mydata = sanitize_text_field($term_id);
                $myterm = get_term($term_id, 'marker');
                // Update the meta field.
                update_post_meta($post->ID, 'mark_posts_term_id', $mydata);
                // Update taxonomy count
                wp_set_object_terms($post->ID, $myterm->name, 'marker');
            }
        }
        echo mark_posts_display_settings_updated();
    }
}
 function load_apple_news_section($field)
 {
     $post = new TimberPost();
     $post_cat = $post->get_terms('category')[0];
     $post_cat = $post_cat->parent ? get_term($post_cat->parent) : $post_cat;
     $api = $this->get_api_instance();
     $channel = get_field('apple_news_channel_id', 'option');
     $sections_response = $api->get_sections($channel);
     if (!isset($sections_response->data)) {
         echo "<pre>";
         print_r($sections_response);
         die;
     }
     $sections = $sections_response->data;
     $choices = array();
     foreach ($sections as $section) {
         $choices[$section->links->self] = $section->name;
         if ($section->name === $post_cat->name) {
             $default = $section->id;
         }
     }
     $field['choices'] = $choices;
     $field['default_value'] = array(isset($default) ? $default : null);
     return $field;
 }
Ejemplo n.º 10
0
 /**
  * The constructor.
  *
  * @param int $id
  */
 public function __construct($id = 0)
 {
     $this->id = papi_get_term_id($id);
     $this->term = get_term($this->id, '');
     $id = papi_get_taxonomy_type_id($this->id);
     $this->type_class = papi_get_entry_type_by_id($id);
 }
 /**
  * Customize the sql query statements.
  * Add a join with the current indexing language
  *
  * @param $sql_statements
  *
  * @return mixed
  */
 function set_sql_query_statement($sql_statements, $parameters)
 {
     global $wpdb;
     // Get the index indexing language
     $language = $this->get_solr_index_indexing_language($parameters['index_indice']);
     // Get the languages
     $languages = $this->get_languages();
     // Retrieve the term_id used for this language code
     if (!isset($languages[$language]['term_id'])) {
         throw new ErrorException(sprintf("The language '%s' is undefined in %s (not in the taxonomy terms).", $language, static::_PLUGIN_NAME_IN_MESSAGES));
     }
     $language_term_id = $languages[$language]['term_id'];
     $term = get_term($language_term_id, 'language');
     if (!isset($term)) {
         throw new ErrorException(sprintf("The language '%s' term_id '%s' is undefined in %s (not in the taxonomy terms).", $language, $language_term_id, static::_PLUGIN_NAME_IN_MESSAGES));
     }
     $term_taxonomy_id = $term->term_taxonomy_id;
     if (isset($language)) {
         // Join statement
         $sql_joint_statement = ' JOIN ';
         $sql_joint_statement .= $wpdb->prefix . self::TABLE_TERM_RELATION_SHIPS . ' AS ' . 'wp_term_relationships';
         $sql_joint_statement .= " ON posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = '%s' ";
         $sql_statements['JOIN'] = sprintf($sql_joint_statement, $term_taxonomy_id);
     }
     return $sql_statements;
 }
Ejemplo n.º 12
0
 function test_the_taxonomy_argument_overrules_the_factory_taxonomy()
 {
     $term_factory = new WP_UnitTest_Factory_For_term(null, 'category');
     $id = $term_factory->create(array('taxonomy' => 'post_tag'));
     $term = get_term($id, 'post_tag');
     $this->assertEquals($id, $term->term_id);
 }
Ejemplo n.º 13
0
 function test_valid_term()
 {
     $this->make_user_by_role('editor');
     $term = get_term($this->term['term_id'], 'category', ARRAY_A);
     $result = $this->myxmlrpcserver->wp_getTerm(array(1, 'editor', 'editor', 'category', $this->term['term_id']));
     $this->assertNotInstanceOf('IXR_Error', $result);
     $this->assertEquals($result, $term);
     // Check DataTypes
     $this->assertInternalType('string', $result['name']);
     $this->assertInternalType('string', $result['slug']);
     $this->assertInternalType('string', $result['taxonomy']);
     $this->assertInternalType('string', $result['description']);
     $this->assertInternalType('int', $result['count']);
     // We expect all ID's to be strings not integers so we don't return something larger than an XMLRPC integer can describe.
     $this->assertStringMatchesFormat('%d', $result['term_id']);
     $this->assertStringMatchesFormat('%d', $result['term_group']);
     $this->assertStringMatchesFormat('%d', $result['term_taxonomy_id']);
     $this->assertStringMatchesFormat('%d', $result['parent']);
     // Check Data
     $this->assertEquals(0, $result['count']);
     $this->assertEquals($term['name'], $result['name']);
     $this->assertEquals($term['slug'], $result['slug']);
     $this->assertEquals('category', $result['taxonomy']);
     $this->assertEquals($term['description'], $result['description']);
 }
Ejemplo n.º 14
0
function ninja_annc_display_group($group_id)
{
    $group = get_term($group_id, 'ninja_annc_groups');
    $widget = false;
    $plugin_settings = get_option('ninja_annc_settings');
    $group_settings = $plugin_settings['groups'][$group_id];
    if ($group_settings['override'] == 1) {
        if ($group_settings['location'] == 'function') {
            $num = $group_settings['show_number'];
            $order = $group_settings['show_order'];
            switch ($order) {
                case 'random':
                    $orderby = 'rand';
                    $order = '';
                    break;
                case 'date_asc':
                    $orderby = 'post_date';
                    $order = 'ASC';
                    break;
                case 'date_desc':
                    $orderby = 'post_date';
                    $order = 'DESC';
                    break;
            }
            $args = array('numberposts' => $num, 'orderby' => $orderby, 'post_type' => 'ninja_annc', 'tax_query' => array(array('taxonomy' => 'ninja_annc_groups', 'field' => 'slug', 'terms' => $group->slug)));
            if ($order != '') {
                $args['order'] = $order;
            }
            $posts_array = get_posts($args);
            foreach ($posts_array as $post) {
                echo ninja_annc_check($post->ID, $widget, $group->term_id);
            }
        }
    }
}
Ejemplo n.º 15
0
 public function __construct($menu_term_slug)
 {
     parent::__construct();
     $menu = wp_get_nav_menu_object($menu_term_slug);
     if (!empty($menu)) {
         $this->menu = $menu;
         $nav_menu_items = wp_get_nav_menu_items($this->menu->term_id);
         cfd_tmp_dbg('nav_menu_items_raw.txt', $nav_menu_items, 'print');
         foreach ($nav_menu_items as $item) {
             $menu_item = wp_setup_nav_menu_item($item);
             $menu_item->metadata = get_metadata('post', $item->ID);
             foreach ($menu_item->metadata as $key => &$value) {
                 $value[0] = maybe_unserialize($value[0]);
             }
             if ($menu_item->type == 'post_type') {
                 $menu_item->parent = get_post($menu_item->metadata['_menu_item_object_id'][0]);
             } elseif ($menu_item->type == 'taxonomy' && (!property_exists($menu, 'object') || $menu->object != 'custom')) {
                 $menu_item->term = get_term($menu_item->metadata['_menu_item_object_id'][0], $menu_item->metadata['_menu_item_object'][0]);
             }
             $this->items[] = $menu_item;
         }
     } else {
         throw new Exception(__('Invalid menu id', 'cf-deploy') . ': ' . esc_attr($menu_term_slug));
     }
 }
 /**
  * Return the terms for the given type.
  *
  * @param int $site_id Blog ID.
  *
  * @return array
  */
 public function get_terms_for_site($site_id)
 {
     $out = [];
     switch_to_blog($site_id);
     $taxonomy_object = get_taxonomy($this->taxonomy_name);
     if (!current_user_can($taxonomy_object->cap->edit_terms)) {
         $terms = [];
     } else {
         $terms = get_terms($this->taxonomy_name, ['hide_empty' => FALSE]);
     }
     foreach ($terms as $term) {
         if (is_taxonomy_hierarchical($this->taxonomy_name)) {
             $ancestors = get_ancestors($term->term_id, $this->taxonomy_name);
             if (!empty($ancestors)) {
                 foreach ($ancestors as $ancestor) {
                     $parent_term = get_term($ancestor, $this->taxonomy_name);
                     $term->name = $parent_term->name . '/' . $term->name;
                 }
             }
         }
         $out[$term->term_taxonomy_id] = esc_html($term->name);
     }
     restore_current_blog();
     uasort($out, 'strcasecmp');
     return $out;
 }
Ejemplo n.º 17
0
function add_mediatags_alternate_link()
{
    global $wp_version;
    $mediatag_rss_feed = get_option('mediatag_rss_feed', 'yes');
    if (!$mediatag_rss_feed || $mediatag_rss_feed != "yes") {
        return;
    }
    $mediatag_var = get_query_var(MEDIA_TAGS_QUERYVAR);
    //echo "mediatag_var<pre>"; print_r($mediatag_var); echo "</pre>";
    if ($mediatag_var) {
        if (version_compare($wp_version, '3.0', '<')) {
            $mediatag_term = is_term($mediatag_var, MEDIA_TAGS_TAXONOMY);
        } else {
            $mediatag_term = term_exists($mediatag_var, MEDIA_TAGS_TAXONOMY);
        }
        if ($mediatag_term) {
            $mediatag_term = get_term($mediatag_term['term_id'], MEDIA_TAGS_TAXONOMY);
            $feed_title = get_bloginfo('name') . " &raquo; " . __('Media-Tags RSS Feed', MEDIA_TAGS_I18N_DOMAIN) . " &raquo; " . $mediatag_term->name;
            $feed_link = get_mediatag_link($mediatag_term->term_id, true);
            if ($feed_link) {
                ?>
<link id="MediaTagsRSS" rel="alternate" type="application/rss+xml"
					title="<?php 
                echo $feed_title;
                ?>
" 
					href="<?php 
                echo $feed_link;
                ?>
" />
				<?php 
            }
        }
    }
}
 /**
  * @return array|null|WP_Error|WP_Term
  */
 function get_wp_object()
 {
     remove_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1);
     $term = get_term($this->id, $this->taxonomy, OBJECT);
     add_filter('get_term', array($this->sitepress, 'get_term_adjust_id'), 1, 1);
     return $term;
 }
Ejemplo n.º 19
0
function my_add_cat_description($category)
{
    $cat_id = $category->term_id;
    $prod_term = get_term($cat_id, 'product_cat');
    $description = $prod_term->description;
    echo '<div class="shop_cat_desc">' . $description . '</div>';
}
    public static function get_admin_page()
    {
        $products = get_term(2, 'product_type');
        ?>
        <div class="wrap">
            <h2>Import WooCommerce product attributes from VirtueMart</h2>
            <p>Product count: <b><?php 
        echo $products->count;
        ?>
 pcs</b></p>
            <ol>
                <li>
                    <form action="<?php 
        echo admin_url('admin.php');
        ?>
">
                        <input type="hidden" name="page" id="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
"/>
                        <input type="hidden" name="action" id="action" value="import"/>
                        <p class="submit"><input type="submit" value="Start import" class="button button-primary" id="submit" name="submit"></p>
                    </form>
                </li>
            </ol>
        </div>
        <?php 
    }
Ejemplo n.º 21
0
function get_all_fieldtaxo($term_id = null, $taxonomy = null)
{
    global $custom_fields;
    if ($term_id == null || $taxonomy == null) {
        return false;
    }
    $term = get_term($term_id, $taxonomy);
    if (is_wp_error($term)) {
        return false;
    }
    $ar = get_term_custom($taxonomy, $term_id);
    if (is_wp_error($ar) || $ar == false) {
        return false;
    }
    $metas = array();
    $cf_pt =& $custom_fields['admin-base']->taxo_nav[$taxonomy];
    foreach ($ar as $key => $value) {
        $key = explode('__', $key);
        if (count($key) <= 1) {
            continue;
        }
        $value = current($value);
        $value = maybe_unserialize($value);
        if (isset($cf_pt->option_fields[$key[0]][$key[1]]['title'])) {
            $metas[strtolower($cf_pt->option_fields[$key[0]][$key[1]]['title'])] = $value;
        }
    }
    return $metas;
}
Ejemplo n.º 22
0
function link_cat_row( $category ) {
	global $class;

	if ( !$category = get_term( $category, 'link_category' ) )
		return false;
	if ( is_wp_error( $category ) )
		return $category;

	$name = ( $name_override ? $name_override : $category->name );
	if ( current_user_can( 'manage_categories' ) ) {
		$edit = "<a class='row-title' href='link-category.php?action=edit&amp;cat_ID=$category->term_id' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "' class='edit'>$name</a>";
		$default_cat_id = (int) get_option( 'default_link_category' );
	} else {
		$edit = $name;
	}

	$class = " class='alternate'" == $class ? '' : " class='alternate'";

	$category->count = number_format_i18n( $category->count );
	$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
	$output = "<tr id='link-cat-$category->term_id'$class>" .
		'<th scope="row" class="check-column"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></th>' .
		"<td>$edit</td>
		<td>$category->description</td>
		<td class='num'>$count</td></tr>";

	return apply_filters( 'link_cat_row', $output );
}
 public function __construct($term, $taxonomies, $post)
 {
     $catTax = 'category';
     $this->post = $post;
     // Default to these
     $this->term = NULL;
     $this->tax = NULL;
     $this->exists = NULL;
     $this->exists_in = NULL;
     if (preg_match('/^{([^#}]*)#([0-9]+)}$/', $term, $backref)) {
         $cat_id = (int) $backref[2];
         $tax = $backref[1];
         if (strlen($tax) < 1) {
             $tax = $catTax;
         }
         $aTerm = get_term($cat_id, $tax);
         if (!is_wp_error($aTerm) and !!$aTerm) {
             $this->exists = (array) $aTerm;
             $this->exists_in = $this->exists['taxonomy'];
             $this->term = $this->exists['name'];
             $this->tax = array($this->exists['taxonomy']);
         }
     } else {
         $this->term = $term;
         $this->tax = $taxonomies;
         // Leave exists/exists_in empty until we search()
     }
     if (is_null($this->tax)) {
         $this->tax = array($catTax);
     }
 }
Ejemplo n.º 24
0
 function ut_prepare_front_query()
 {
     /* needed variables and arrays */
     $ut_query_pages = array();
     /* check if primary navigation has been created and set */
     if (has_nav_menu('primary')) {
         /* get primary navigation ID */
         $ut_theme_locations = get_nav_menu_locations();
         $ut_menu_objects = get_term($ut_theme_locations['primary'], 'nav_menu');
         $ut_menu_id = $ut_menu_objects->term_id;
         /* now we get all menu items from primary navigation  */
         $menu_args = array('orderby' => 'menu_order');
         $ut_menu_items = wp_get_nav_menu_items($ut_menu_id, $menu_args);
         /* create an array of page ID's for query_posts() */
         foreach ((array) $ut_menu_items as $key => $ut_menu_item) {
             $blog_page_id = get_option('page_for_posts');
             $frontpage_id = get_option('page_on_front');
             if ($ut_menu_item->menutype == 'section' && $blog_page_id != $ut_menu_item->object_id && $frontpage_id != $ut_menu_item->object_id) {
                 $ut_query_pages[] = $ut_menu_item->object_id;
                 /* get child pages */
                 $children = ut_get_posts_children_ids($ut_menu_item->object_id);
                 $ut_query_pages = array_merge($ut_query_pages, $children);
             }
         }
         /* return query arguements */
         if (!empty($ut_query_pages)) {
             /* query args for main query  */
             $pagequery = array('posts_per_page' => count($ut_query_pages), 'post_type' => 'page', 'post__in' => $ut_query_pages, 'orderby' => 'post__in');
             return $pagequery;
         } else {
             /* return empty arguments */
             return array();
         }
     }
 }
Ejemplo n.º 25
0
 function testTermInitObject()
 {
     $term_id = $this->factory->term->create();
     $term = get_term($term_id, 'post_tag');
     $term = new TimberTerm($term);
     $this->assertEquals($term->ID, $term_id);
 }
 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);
             }
         }
     }
 }
Ejemplo n.º 27
0
 function _output($value)
 {
     if (!isset($this->options) || !isset($this->options['meta_field']) || empty($this->options['meta_field'])) {
         // no value to show
         return '';
     }
     global $post;
     $metaValue = get_post_meta($post->ID, $this->options['meta_field'], true);
     $value = $metaValue . ' <input type="hidden" name="cuztom[' . $this->name . ']" id="' . $this->id . '" value="' . $metaValue . '" />';
     if (empty($metaValue)) {
         return '';
     }
     if (isset($this->options) || isset($this->options['type']) && !empty($this->options['type'])) {
         // Deal with special types
         switch (strtolower($this->options['type'])) {
             case 'encrypted':
                 $encKey = pack('H*', NM_ENCRYPTION_KEY);
                 $ciphertext_dec = base64_decode($metaValue);
                 $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
                 $iv_dec = substr($ciphertext_dec, 0, $iv_size);
                 $ciphertext_dec = substr($ciphertext_dec, $iv_size);
                 $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $encKey, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
                 $value = $plaintext_dec;
                 break;
             case 'currency':
                 $value = '$' . number_format((double) $metaValue, 2);
                 break;
             case 'payment_option':
                 $value = get_term($metaValue, 'payment_options')->name;
                 break;
         }
     }
     return $value;
 }
Ejemplo n.º 28
0
/**
 * Returns a navigation menu object.
 *
 * @since 3.0.0
 *
 * @param string $menu Menu ID, slug, or name - or the menu object.
 * @return object|false False if $menu param isn't supplied or term does not exist, menu object if successful.
 */
function wp_get_nav_menu_object($menu)
{
    $menu_obj = false;
    if (is_object($menu)) {
        $menu_obj = $menu;
    }
    if ($menu && !$menu_obj) {
        $menu_obj = get_term($menu, 'nav_menu');
        if (!$menu_obj) {
            $menu_obj = get_term_by('slug', $menu, 'nav_menu');
        }
        if (!$menu_obj) {
            $menu_obj = get_term_by('name', $menu, 'nav_menu');
        }
    }
    if (!$menu_obj || is_wp_error($menu_obj)) {
        $menu_obj = false;
    }
    /**
     * Filter the nav_menu term retrieved for wp_get_nav_menu_object().
     *
     * @since 4.3.0
     *
     * @param object|false $menu_obj Term from nav_menu taxonomy, or false if nothing had been found.
     * @param string       $menu     The menu ID, slug, or name passed to wp_get_nav_menu_object().
     */
    return apply_filters('wp_get_nav_menu_object', $menu_obj, $menu);
}
 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";
     }
 }
Ejemplo n.º 30
-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";
 }