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

PHP wp_get_post_cats函数代码示例

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

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



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

示例1: mt_getpost

function mt_getpost($params)
{
    // ($postid, $user, $pass)
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    // Check login
    if (user_pass_ok(addslashes($username), $password)) {
        $postdata = get_postdata($post_ID);
        if ($postdata['Date'] != '') {
            // why were we converting to GMT here? spec doesn't call for that.
            //$post_date = mysql2date('U', $postdata['Date']);
            //$post_date = gmdate('Ymd', $post_date).'T'.gmdate('H:i:s', $post_date);
            $post_date = strtotime($postdata['Date']);
            $post_date = date('Ymd', $post_date) . 'T' . date('H:i:s', $post_date);
            $catids = wp_get_post_cats('1', $post_ID);
            logIO('O', 'Category No:' . count($catids));
            foreach ($catids as $catid) {
                $catname = get_cat_name($catid);
                logIO('O', 'Category:' . $catname);
                $catnameenc = new xmlrpcval(mb_conv($catname, 'UTF-8', $GLOBALS['blog_charset']));
                $catlist[] = $catnameenc;
            }
            $post = get_extended($postdata['Content']);
            $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0;
            $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0;
            $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata['Title'], 'UTF-8', $GLOBALS['blog_charset'])), 'description' => new xmlrpcval(mb_conv($post['main'], 'UTF-8', $GLOBALS['blog_charset'])), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata['Author_ID']), 'postid' => new xmlrpcval($postdata['ID']), 'content' => new xmlrpcval(mb_conv($postdata['Content'], 'UTF-8', $GLOBALS['blog_charset'])), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], 'UTF-8', $GLOBALS['blog_charset'])), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], 'UTF-8', $GLOBALS['blog_charset'])));
            $resp = new xmlrpcval($resp, 'struct');
            return new xmlrpcresp($resp);
        } else {
            return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, "No such post #{$post_ID}");
        }
    } else {
        return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:39,代码来源:xmlrpc.php


示例2: wp_get_single_post

function wp_get_single_post($postid = 0, $mode = OBJECT)
{
    global $wpdb;
    $sql = "SELECT * FROM {$wpdb->posts} WHERE ID={$postid}";
    $result = $wpdb->get_row($sql, $mode);
    // Set categories
    if ($mode == OBJECT) {
        $result->post_category = wp_get_post_cats('', $postid);
    } else {
        $result['post_category'] = wp_get_post_cats('', $postid);
    }
    return $result;
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:13,代码来源:functions-post.php


示例3: wp_delete_post

function wp_delete_post($postid = 0) {
	global $wpdb, $wp_rewrite;
	$postid = (int) $postid;

	if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
		return $post;

	if ( 'attachment' == $post->post_status )
		return wp_delete_attachment($postid);

	do_action('delete_post', $postid);

	if ( 'publish' == $post->post_status) {
		$categories = wp_get_post_cats('', $post->ID);
		if( is_array( $categories ) ) {
			foreach ( $categories as $cat_id ) {
				$wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
				wp_cache_delete($cat_id, 'category');
			}
		}
	}

	if ( 'static' == $post->post_status )
		$wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'");

	$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
	
	$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");

	$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid");

	$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");

	if ( 'static' == $post->post_status ) {
		wp_cache_delete('all_page_ids', 'pages');
		$wp_rewrite->flush_rules();
	}

	return $post;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:40,代码来源:functions-post.php


示例4: mt_getpost

function mt_getpost($params)
{
    // ($postid, $user, $pass)
    global $xmlrpcerruser;
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    // Check login
    if (user_pass_ok($username, $password)) {
        $postdata = get_postdata($post_ID);
        if ($postdata["Date"] != "") {
            // why were we converting to GMT here? spec doesn't call for that.
            //$post_date = mysql2date("U", $postdata["Date"]);
            //$post_date = gmdate("Ymd", $post_date)."T".gmdate("H:i:s", $post_date);
            $post_date = strtotime($postdata['Date']);
            $post_date = date("Ymd", $post_date) . "T" . date("H:i:s", $post_date);
            $catids = wp_get_post_cats('1', $post_ID);
            logIO("O", "CateGory No:" . count($catids));
            foreach ($catids as $catid) {
                $catname = get_cat_name($catid);
                logIO("O", "CateGory:" . $catname);
                $catnameenc = new xmlrpcval(mb_conv($catname, "UTF-8", "auto"));
                $catlist[] = $catnameenc;
            }
            $post = get_extended($postdata['Content']);
            $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0;
            $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0;
            $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata["Title"], "UTF-8", "auto")), 'description' => new xmlrpcval(mb_conv($post['main'], "UTF-8", "auto")), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata["Author_ID"]), 'postid' => new xmlrpcval($postdata["ID"]), 'content' => new xmlrpcval(mb_conv($postdata["Content"], "UTF-8", "auto")), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], "UTF-8", "auto")), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], "UTF-8", "auto")));
            $resp = new xmlrpcval($resp, 'struct');
            return new xmlrpcresp($resp);
        } else {
            return new xmlrpcresp(0, $xmlrpcerruser + 3, "No such post #{$post_ID}");
        }
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:40,代码来源:xmlrpc.php


示例5: mt_publishPost

 function mt_publishPost($args)
 {
     $this->escape($args);
     $post_ID = $args[0];
     $user_login = $args[1];
     $user_pass = $args[2];
     if (!$this->login_pass_ok($user_login, $user_pass)) {
         return $this->error;
     }
     $user = new WP_User(0, $user_login);
     if (!$user->has_cap('edit_post', $post_ID)) {
         return new IXR_Error(401, 'Sorry, you can not edit this post.');
     }
     $postdata = wp_get_single_post($post_ID, ARRAY_A);
     $postdata['post_status'] = 'publish';
     // retain old cats
     $cats = wp_get_post_cats('', $post_ID);
     $postdata['post_category'] = $cats;
     $this->escape($postdata);
     $result = wp_update_post($postdata);
     return $result;
 }
开发者ID:robertlange81,项目名称:Website,代码行数:22,代码来源:xmlrpc.php


示例6: wpadp_check_and_add_cats

 /**
  *
  */
 function wpadp_check_and_add_cats()
 {
     global $wpdb;
     $this->get_settings();
     $expiration = $this->settings['PostAge'];
     $newCat = array($this->settings['AddCategory']);
     /*
      * Create a query that will give us all the post ID's that predate the
      * interval we are given, that is, NOW - expiration date.
      */
     $query = "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' AND\n    post_date < '{$date}' - INTERVAL " . $expiration . " DAY";
     $ids = $wpdb->get_results($query);
     foreach ($ids as $id) {
         if ('' == $id->ID) {
             continue;
         }
         $curCat = wp_get_post_cats('', $id->ID);
         // Merge the contents of the newCat array with the curCat array, each of these can contain
         // multiple values
         $curCat = array_merge($curCat, $newCat);
         wp_set_post_cats('', $id->ID, $curCat);
     }
 }
开发者ID:alphaomegahost,项目名称:FIN,代码行数:26,代码来源:auto-delete-posts.php


示例7: user_can_access

 /**
  * Gives TRUE/FALSE for users rights for spezific request
  *
  * @uses $post
  * @uses $access_pag_anonymous
  * @uses $access_pag_default
  * @uses $access_cat_anonymous
  * @uses $access_cat_default
  *
  * @uses get_option()
  * @uses wp_get_post_cats()
  *
  * @param string $val_id
  * @param array object $user
  * @param string $kind Select between 'pag' / 'cat'
  * @param string $parent_id
  *
  * @return bool
  */
 function user_can_access($val_id, $user, $kind, $parent_id = '')
 {
     global $post;
     if ($user && isset($user->allcaps['manage_categories']) && !isset($user->caps['editor'])) {
         return true;
     }
     global $access_pag_anonymous, $access_pag_default, $access_cat_anonymous, $access_cat_default;
     switch ($kind) {
         case 'pag':
         case 'page':
             if ($user->id == 0) {
                 $user_access_page_check = $access_pag_anonymous;
             } else {
                 $user_access_page_check = get_option("capa_protect_pag_user_{$user->id}");
             }
             if (empty($user_access_page_check)) {
                 // Group Settings
                 $tmp_caps = implode('', array_keys($user->caps));
                 $user_access_page_check = get_option("capa_protect_pag_role_{$tmp_caps}");
             }
             // Default Setting
             if (empty($user_access_page_check)) {
                 $user_access_page_check = $access_pag_default;
             }
             if (isset($user_access_page_check[$val_id])) {
                 return true;
             } else {
                 return false;
             }
             $user_access_pag_check = "";
             break 1;
         case 'cat':
         case 'category':
             // parent id check for attachment
             if (is_attachment()) {
                 $access_post = wp_get_post_cats(1, $parent_id);
                 $val_id = $access_post[0];
             }
             if ($user->id == 0) {
                 $user_access_category_check = $access_cat_anonymous;
             } else {
                 $user_access_category_check = get_option("capa_protect_cat_user_{$user->id}");
             }
             // User Settings
             if (empty($user_access_category_check)) {
                 // Group Settings
                 $tmp_caps = implode('', array_keys($user->caps));
                 $user_access_category_check = get_option("capa_protect_cat_role_{$tmp_caps}");
             }
             // Default Setting
             if (empty($user_access_category_check)) {
                 $user_access_category_check = $access_cat_default;
             }
             $return = FALSE;
             if ($user_access_category_check !== FALSE) {
                 if (is_array($val_id)) {
                     foreach ($val_id as $key => $id) {
                         if (array_key_exists($id, $user_access_category_check)) {
                             $return = TRUE;
                         }
                     }
                 } else {
                     if (array_key_exists($val_id, $user_access_category_check)) {
                         $return = TRUE;
                     }
                 }
             }
             return $return;
             $user_access_category_check = "";
             break 1;
     }
 }
开发者ID:DarussalamTech,项目名称:aims_prj,代码行数:91,代码来源:capa.php


示例8: publish

 /**
 Sends an email notification of a new post
 */
 function publish($id = 0)
 {
     if (!$id) {
         return $id;
     }
     // if this is an edit, we don't need to do anything
     if ('post' !== $_POST['action']) {
         return $id;
     }
     $post_cats = wp_get_post_cats('1', $id);
     $post_cats_string = implode(',', $post_cats);
     $check = false;
     // is the current post assigned to any categories
     // which should not generate a notification email?
     foreach (explode(',', $this->get_excluded_cats()) as $cat) {
         if (in_array($cat, $post_cats)) {
             $check = true;
         }
     }
     // if so, bail out
     if ($check) {
         // hang on -- can registered users subscribe to
         // excluded categories?
         if ('0' == get_option('s2_reg_override')) {
             // nope?  okay, let's leave
             return $id;
         }
     }
     global $wpdb;
     $post =& get_post($id);
     // is this post set in the future?
     if ($post->post_date > current_time('mysql')) {
         // if so, bail out
         // we really should make a cron action here
         return $id;
     }
     // lets collect our public subscribers
     // and all our registered subscribers for these categories
     $public = array();
     $registered = array();
     if (!$check) {
         // if this post is assigned to an excluded
         // category, then this test will prevent
         // the public from receiving notification
         $public = $this->get_public();
     }
     $registered = $this->get_registered("cats={$post_cats_string}");
     // do we have subscribers?
     if (empty($public) && empty($registered)) {
         // if not, no sense doing anything else
         return $id;
     }
     // we set these class variables so that we can avoid
     // passing them in function calls a little later
     $this->post_title = $post->post_title;
     $this->permalink = get_permalink($id);
     // do we send as admin, or post author?
     if ('author' == get_option('s2_sender')) {
         // get author details
         $user = get_userdata($post->post_author);
     } else {
         // get admin detailts
         $user = get_userdata(1);
     }
     $this->myemail = $user->user_email;
     $this->myname = $user->display_name;
     // Get email subject
     $subject = $this->substitute($this->s2_subject);
     // Get the message template
     $mailtext = $this->substitute(stripslashes(get_option('s2_mailtext')));
     $plaintext = $post->post_content;
     $content = apply_filters('the_content', $post->post_content);
     $content = str_replace(']]>', ']]&gt', $content);
     $excerpt = $post->post_excerpt;
     if ('' == $excerpt) {
         // no excerpt, is there a <!--more--> ?
         if (false !== strpos($content, '<!--more-->')) {
             list($excerpt, $more) = explode('<!--more-->', $plaintext, 2);
             // strip leading and trailing whitespace
             $excerpt = trim($excerpt);
         } else {
             $excerpt = strip_tags($plaintext);
             $excerpt_length = 55;
             $words = explode(' ', $plaintext, $excerpt_length + 1);
             if (count($words) > $excerpt_length) {
                 array_pop($words);
                 array_push($words, '[...]');
                 $excerpt = implode(' ', $words);
             }
         }
     }
     // first we send plaintext summary emails
     $body = str_replace('POST', $excerpt, $mailtext);
     $this->mail(array_merge($this->get_public(), $this->get_registered("cats={$post_cats}&format=text&amount=excerpt")), $subject, $body);
     // next we send plaintext full content emails
     $body = str_replace('POST', $content, $mailtext);
     $this->mail($this->get_registered("cats={$post_cats_string}&format=text&amount=post"), $subject, $body);
//.........这里部分代码省略.........
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:101,代码来源:subscribe2.php


示例9: wp_delete_post

function wp_delete_post($postid = 0)
{
    global $wpdb;
    $postid = (int) $postid;
    if (!($post = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = {$postid}"))) {
        return $post;
    }
    if ('attachment' == $post->post_status) {
        return wp_delete_attachment($postid);
    }
    do_action('delete_post', $postid);
    if ('publish' == $post->post_status) {
        $categories = wp_get_post_cats('', $post->ID);
        if (is_array($categories)) {
            foreach ($categories as $cat_id) {
                $wpdb->query("UPDATE {$wpdb->categories} SET category_count = category_count - 1 WHERE cat_ID = '{$cat_id}'");
                wp_cache_delete($cat_id, 'category');
            }
        }
    }
    if ('static' == $post->post_status) {
        $wpdb->query("UPDATE {$wpdb->posts} SET post_parent = {$post->post_parent} WHERE post_parent = {$postid} AND post_status = 'static'");
    }
    $wpdb->query("DELETE FROM {$wpdb->posts} WHERE ID = {$postid}");
    $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_post_ID = {$postid}");
    $wpdb->query("DELETE FROM {$wpdb->post2cat} WHERE post_id = {$postid}");
    $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$postid}");
    if ('static' == $post->post_status) {
        generate_page_rewrite_rules();
    }
    return $post;
}
开发者ID:robertlange81,项目名称:Website,代码行数:32,代码来源:functions-post.php


示例10: Get_DefaultCategory

 function Get_DefaultCategory()
 {
     if (get_bloginfo('version') >= '2.1') {
         $myposts = wp_get_post_categories($this->post->ID);
     } else {
         $myposts = wp_get_post_cats('1', $this->post->ID);
     }
     $array_def = pt_pathinfo($this->def_url);
     $filename = $array_def['filename'];
     foreach ($myposts as $mypost) {
         $new_def = $array_def['dirname'] . '/' . $filename . 'cat-' . $mypost . '.' . $array_def['extension'];
         if (remote_file_exists($new_def)) {
             $this->def_url = $new_def;
             break;
         }
     }
 }
开发者ID:emoksha,项目名称:VoteReport-Lebanon,代码行数:17,代码来源:post-thumb-classes.php



注:本文中的wp_get_post_cats函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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