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

PHP wp_get_single_post函数代码示例

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

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



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

示例1: tdomf_widget_getcat_post

function tdomf_widget_getcat_post($args, $params)
{
    global $tdomf_getcat_overwrite, $tdomf_getcat_var_name;
    extract($args);
    if (isset($args[$tdomf_getcat_var_name])) {
        // Overwrite existing post categories
        //
        if ($tdomf_getcat_overwrite) {
            $post_cats = array($args[$tdomf_getcat_var_name]);
        } else {
            // Append to existing categories
            //
            // Grab existing data
            $post = wp_get_single_post($post_ID, ARRAY_A);
            $current_cats = $post['post_category'];
            // Now merge existing categories with new category
            $post_cats = array_merge($current_cats, array($args[$tdomf_getcat_var_name]));
        }
        // Update categories on post
        $post = array("ID" => $post_ID, "post_category" => $post_cats);
        wp_update_post($post);
    }
    // no errors so return NULL
    return NULL;
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:25,代码来源:tdomf-getcat-widget.php


示例2: OnPrePageLoad

 function OnPrePageLoad()
 {
     $this->SetPageTitle(wp_title('', false) . ' – ' . get_bloginfo('name', 'display'));
     if (has_excerpt()) {
         $this->SetPageDescription(get_the_excerpt());
     } else {
         $description = wp_get_single_post(get_the_id())->post_content;
         $description = strip_tags($description);
         $break = strpos($description, "\n");
         if ($break !== false and $break > 0) {
             $description = substr($description, 0, $break - 1);
         }
         $this->SetPageDescription($description);
     }
     $this->SetContentConstraint($this->ConstrainColumns());
     $this->SetContentCssClass('hasLargeImage');
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:17,代码来源:single.php


示例3: excerpt_to_description

function excerpt_to_description()
{
    global $post;
    // get access to the $post object
    if (is_single() || is_page()) {
        // only run on posts or pages
        $all_post_content = wp_get_single_post($post->ID);
        // get all content from the post/page
        $excerpt = substr($all_post_content->post_content, 0, 100) . ' [...]';
        // get first 100 characters and append "[...]" to the end
        echo "<meta name='description' content='" . $excerpt . "' />\r\n";
        // add meta tag to <head>
    } else {
        // only run if not a post or page
        echo "<meta name='description' content='" . get_bloginfo('description') . "' />\r\n";
        // add meta tag to <head>
    }
}
开发者ID:nidaniel,项目名称:Hello-World,代码行数:18,代码来源:Untitled.php


示例4: post

 function post($args, $options, $postfix = '')
 {
     global $wpdb;
     extract($args);
     $form_data = tdomf_get_form_data($tdomf_form_id);
     $modifypost = false;
     if ($options['post-title'] || $options['a'] || $options['img'] || $options['attach-a'] || $options['attach-thumb-a'] || $options['thumb-a']) {
         // Grab existing data
         $post = wp_get_single_post($post_ID, ARRAY_A);
         if (!empty($post['post_content'])) {
             $post = add_magic_quotes($post);
         }
         $content = $post['post_content'];
         $title = $post['post_title'];
         $cats = $post['post_category'];
     }
     $filecount = 0;
     $theirfiles = $form_data['uploadfiles_' . $tdomf_form_id . '_' . $postfix];
     for ($i = 0; $i < $options['max']; $i++) {
         if (!file_exists($theirfiles[$i]['path'])) {
             unset($theirfiles[$i]);
         } else {
             $filecount++;
             // move file
             $postdir = $options['path'] . DIRECTORY_SEPARATOR . $post_ID;
             tdomf_recursive_mkdir($postdir, TDOMF_UPLOAD_PERMS);
             $newpath = $postdir . DIRECTORY_SEPARATOR . $theirfiles[$i]['name'];
             if (rename($theirfiles[$i]['path'], $newpath)) {
                 $newpath = realpath($newpath);
                 // to support multiple files, we have to avoid clashes without instances
                 $j = $this->getFreeIndexPostMeta($post_ID, TDOMF_KEY_DOWNLOAD_PATH, $i);
                 // store info about files on post
                 //
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_COUNT . $j, 0, true);
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_TYPE . $j, $theirfiles[$i]['type'], true);
                 // escape the "path" incase it contains '\' as WP will strip these out!
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_PATH . $j, $wpdb->escape($newpath), true);
                 add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_NAME . $j, $theirfiles[$i]['name'], true);
                 // keep a list of the uploaded/created files
                 //
                 $this->addToFileList($post_ID, $postfix, $newpath);
                 tdomf_log_message("File " . $theirfiles[$i]['name'] . " saved from tmp area to " . $newpath . " with type " . $theirfiles[$i]['type'] . " for post {$post_ID}");
                 // Execute user command
                 //
                 if ($options['cmd'] != "") {
                     $cmd_output = shell_exec($options['cmd'] . " " . $newpath);
                     tdomf_log_message("Executed user command on file {$newpath}<br/><pre>{$cmd_output}</pre>");
                     add_post_meta($post_ID, TDOMF_KEY_DOWNLOAD_CMD_OUTPUT . $i, $cmd_output, true);
                 }
                 // Use direct links or wrapper
                 //
                 if ($options['nohandler'] && trim($options['url']) != "") {
                     $uri = trailingslashit($options['url']) . "{$post_ID}/" . $theirfiles[$i]['name'];
                 } else {
                     $uri = trailingslashit(get_bloginfo('wpurl')) . '?tdomf_download=' . $post_ID . '&id=' . $i;
                 }
                 // Modify Post
                 //
                 // modify post title
                 if ($options['post-title']) {
                     $modifypost = true;
                     $title = $theirfiles[$i]['name'];
                 }
                 // add download link (inc name and file size)
                 if ($options['a']) {
                     $modifypost = true;
                     // $content .= "<p><a href=\"$uri\">".$theirfiles[$i]['name']." (".tdomf_filesize_format(filesize($newpath)).")</a></p>";
                 }
                 // add image link (inc name and file size)
                 if ($options['img']) {
                     $modifypost = true;
                     // Commented out image link in post by Alexander Rea 2/28/10
                     // $content .= "<p><img src=\"$uri\" /></p>";
                 }
                 // Use user-defined custom key
                 if ($options['custom'] && !empty($options['custom-key'])) {
                     add_post_meta($post_ID, $options['custom-key'], $uri);
                 }
                 // Insert upload as an attachment to post!
                 if ($options['attach']) {
                     // Create the attachment (not sure if these values are correct)
                     //
                     $attachment = array("post_content" => "", "post_title" => $theirfiles[$i]['name'], "post_name" => sanitize_title($theirfiles[$i]['name']), "post_status" => 'inherit', "post_parent" => $post_ID, "guid" => $uri, "post_type" => 'attachment', "post_mime_type" => $theirfiles[$i]['type'], "menu_order" => $i, "post_category" => $cats);
                     // I dont' know if this is a wp2.8 thing, but you have to
                     // URI for it to be properly handled as an attachment, yet...
                     // how does it know where to generate the thumbs?
                     $attachment_ID = wp_insert_attachment($attachment, $uri, $post_ID);
                     // Weirdly, I have to do this now to access the wp_generate_attachement_metadata
                     // functino from within the widget class
                     //
                     require_once ABSPATH . 'wp-admin/includes/image.php';
                     // Generate meta data (which includes thumbnail!)
                     //
                     $attachment_metadata = wp_generate_attachment_metadata($attachment_ID, $newpath);
                     // add link to attachment page
                     if ($options['attach-a']) {
                         $content .= "<p><a href=\"" . get_permalink($attachment_ID) . "\">" . $theirfiles[$i]['name'] . " (" . tdomf_filesize_format(filesize($newpath)) . ")</a></p>";
                     }
                     if (tdomf_wp23()) {
                         // Did Wordpress generate a thumbnail?
//.........这里部分代码省略.........
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:101,代码来源:tdomf-upload-functions.php


示例5: loadAdminPostFonts

 function loadAdminPostFonts($data = false)
 {
     global $wp_query;
     if ($data) {
         if (!$data['post_content']) {
             return;
         }
         $post_content = $data['post_content'];
     } else {
         if (is_object($wp_query) && is_object($wp_query->post) && $wp_query->post->ID) {
             $post = wp_get_single_post($wp_query->post->ID);
         } else {
             if (isset($_GET['post']) && is_numeric($_GET['post'])) {
                 $post = wp_get_single_post($_GET['post']);
             } else {
                 if (isset($_GET['page']) && is_numeric($_GET['page'])) {
                     $post = wp_get_single_post($_GET['page']);
                 } else {
                     if (isset($_GET['p']) && is_numeric($_GET['p'])) {
                         $post = wp_get_single_post($_GET['page']);
                     } else {
                         return;
                     }
                 }
             }
         }
         $post_content = $post->post_content;
     }
     preg_match_all('/fontplugin_fontid_([0-9]*)_([a-zA-Z0-9]*)/', $post_content, $searchResults);
     $fontsIds = array_values(array_unique($searchResults[1]));
     $fontsNames = array_values(array_unique($searchResults[2]));
     for ($i = 0; $i < count($fontsIds); $i++) {
         $fontPairs[$fontsIds[$i]] = $fontsNames[$i];
     }
     return $fontPairs;
 }
开发者ID:coollog,项目名称:theboola,代码行数:36,代码来源:Font.php


示例6: process_conditionals

 /**
  * Process conditionals for posts.
  *
  * @since 2.2.0
  */
 function process_conditionals()
 {
     if (empty($this->params)) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
         return;
     }
     switch ($this->params[0]) {
         case $this->ENTRY_PATH:
             global $post;
             $post = wp_get_single_post($this->params[1]);
             $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
             $post = NULL;
             break;
         case $this->ENTRIES_PATH:
             $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             break;
         default:
             return;
     }
     $wp_etag = md5($wp_last_modified);
     @header("Last-Modified: {$wp_last_modified}");
     @header("ETag: {$wp_etag}");
     // Support for Conditional GET
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     } else {
         $client_etag = false;
     }
     $client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     // If string is empty, return 0. If not, attempt to parse into a timestamp
     $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
     // Make a timestamp for our most recent modification...
     $wp_modified_timestamp = strtotime($wp_last_modified);
     if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
         status_header(304);
         exit;
     }
 }
开发者ID:thomashorta31,项目名称:BHS,代码行数:45,代码来源:wp-app.php


示例7: post

 /**
  * Process form input for widget
  * 
  * @access public
  * @return Mixed
  */
 function post($args, $options)
 {
     extract($args);
     // Grab existing data
     $post = wp_get_single_post($post_ID, ARRAY_A);
     if (!empty($post['post_excerpt'])) {
         $post = add_magic_quotes($post);
     }
     $post_excerpt = $post['post_excerpt'];
     // get user input
     $post_excerpt .= $this->textarea->post($args, $options, 'excerpt_excerpt');
     // Update actual post
     $post = array("ID" => $post_ID, "post_excerpt" => $post_excerpt);
     $post_ID = wp_update_post($post);
     return NULL;
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:22,代码来源:tdomf-excerpt-widget.php


示例8: debug_out_feedwordpress_update_post

 function debug_out_feedwordpress_update_post($id)
 {
     $post = wp_get_single_post($id);
     print "[" . date('Y-m-d H:i:s') . "][feedwordpress] updated " . "'{$post->post_title}' ({$post->post_date})" . " (as of {$post->post_modified})\n";
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:5,代码来源:feedwordpress.php


示例9: mt_publishPost

function mt_publishPost($params)
{
    global $xmlrpcusererr;
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    if (user_pass_ok($username, $password)) {
        $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;
        $result = wp_update_post($postdata);
        return new xmlrpcresp(new xmlrpcval($result, 'boolean'));
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:21,代码来源:xmlrpc.php


示例10: post

 /**
  * Process form input for widget
  * 
  * @access public
  * @return Mixed
  */
 function post($args, $options)
 {
     extract($args);
     // if sumbitting a new post (as opposed to editing)
     // make sure to *append* to post_content. For editing, overwrite.
     //
     if (TDOMF_Widget::isSubmitForm($mode)) {
         // Grab existing data
         $post = wp_get_single_post($post_ID, ARRAY_A);
         if (!empty($post['post_content'])) {
             $post = add_magic_quotes($post);
         }
         // Append
         $post_content = $post['post_content'];
         $post_content .= $this->textarea->post($args, $options, 'content_content');
     } else {
         // $mode startswith "edit-"
         // Overwrite
         $post_content = $this->textarea->post($args, $options, 'content_content');
     }
     // Title
     if ($options['title-enable']) {
         $content_title = tdomf_protect_input($this->textfield->post($args, $options, 'content_title'));
     }
     // Update actual post
     $post = array("ID" => $post_ID, "post_content" => $post_content);
     if ($options['title-enable']) {
         $post["post_title"] = $content_title;
         $post["post_name"] = sanitize_title($content_title);
     }
     $post_ID = wp_update_post($post);
     return NULL;
 }
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:39,代码来源:tdomf-content-widget.php


示例11: express_editPost

function express_editPost($args)
{
    global $wp_xmlrpc_server;
    $args = express_woo_taxonomy($args);
    $result = $wp_xmlrpc_server->mw_editPost($args);
    if ($result == false) {
        return false;
    }
    // Insert taxonomies
    if (isset($content_struct['taxonomy'])) {
        set_new_taxonomy_tag($post_ID, $content_struct['taxonomy']);
    }
    // TODO: Remove old attachments
    // Add new attachments
    $post_ID = (int) $args[0];
    $content_struct = $args[3];
    $attachments = $content_struct['attachments'];
    if (is_array($attachments)) {
        foreach ($attachments as $attachment_ID) {
            $attachment_post = wp_get_single_post($attachment_ID, ARRAY_A);
            extract($attachment_post, EXTR_SKIP);
            $post_parent = $post_ID;
            $postdata = compact('ID', 'post_parent', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');
            wp_update_post($postdata);
        }
    }
    return true;
}
开发者ID:juslee,项目名称:e27,代码行数:28,代码来源:admin-express-functions.php


示例12: post_settings_delete

 function post_settings_delete()
 {
     global $wpdb;
     extract($_POST);
     // check
     $post_id = $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id));
     // if post
     if ((int) $post_id > 0) {
         // update content
         // get content
         $wp_post = wp_get_single_post($post_id);
         // update
         wp_update_post(array('post_content' => preg_replace('/\\[\\/?private\\]/', '', $wp_post->post_content), 'ID' => $wp_post->ID));
         // remove other Issue #922
         // get object
         $post_obj = mgm_get_post($post_id);
         // set
         $post_obj->purchasable = 'N';
         $post_obj->purchase_cost = '0.00';
         $post_obj->access_membership_types = array();
         // save meta
         $post_obj->save();
         // unset
         unset($post_obj);
     }
     // sql
     $sql = $wpdb->prepare("DELETE FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id);
     // delete
     if ($wpdb->query($sql)) {
         $message = __('Successfully deleted post settings: ', 'mgm');
         $status = 'success';
     } else {
         $message = __('Error while deleting post settings: ', 'mgm');
         $status = 'error';
     }
     // return response
     echo json_encode(array('status' => $status, 'message' => $message));
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:38,代码来源:mgm_admin_settings.php


示例13: bbp_unspam_reply

/**
 * Unspams a reply
 *
 * @since bbPress (r2740)
 *
 * @param int $reply_id Reply id
 * @uses wp_get_single_post() To get the reply
 * @uses do_action() Calls 'bbp_unspam_reply' with the reply ID
 * @uses get_post_meta() To get the previous status meta
 * @uses delete_post_meta() To delete the previous status meta
 * @uses wp_insert_post() To insert the updated post
 * @uses do_action() Calls 'bbp_unspammed_reply' with the reply ID
 * @return mixed False or {@link WP_Error} on failure, reply id on success
 */
function bbp_unspam_reply($reply_id = 0)
{
    // Get reply
    $reply = wp_get_single_post($reply_id, ARRAY_A);
    if (empty($reply)) {
        return $reply;
    }
    // Bail if already not spam
    if (bbp_get_spam_status_id() != $reply['post_status']) {
        return false;
    }
    // Execute pre unspam code
    do_action('bbp_unspam_reply', $reply_id);
    // Get pre spam status
    $reply['post_status'] = get_post_meta($reply_id, '_bbp_spam_meta_status', true);
    // Delete pre spam meta
    delete_post_meta($reply_id, '_bbp_spam_meta_status');
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Update the reply
    $reply_id = wp_insert_post($reply);
    // Execute post unspam code
    do_action('bbp_unspammed_reply', $reply_id);
    // Return reply_id
    return $reply_id;
}
开发者ID:hscale,项目名称:webento,代码行数:40,代码来源:bbp-reply-functions.php


示例14: ac_notifier_remove_notification_for_blog_posts

function ac_notifier_remove_notification_for_blog_posts()
{
    if (!(is_user_logged_in() && is_singular())) {
        return;
    }
    global $bp, $wpdb;
    $blog_id = (int) $wpdb->blogid;
    $post = wp_get_single_post();
    $activity_id = bp_activity_get_activity_id(array('user_id' => $post->post_author, 'component' => $bp->blogs->id, 'type' => "new_blog_post", "item_id" => $blog_id, 'secondary_item_id' => $post->ID));
    //delete the notification for activity comment on new_blog_post
    if (!empty($activity_id)) {
        bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $activity_id, $bp->ac_notifier->id, 'new_activity_comment_' . $activity_id);
    }
    //for replies on blog comments in activity stream
    $comments = ac_notifier_get_all_blog_post_comment_ids($post->ID);
    //get all the comment ids as array
    //added in v 1.0.3 for better database performance, no more looping to get individual activity ids
    $activities = ac_notifier_get_activity_ids(array("type" => "new_blog_comment", "component" => $bp->blogs->id, "item_id" => $blog_id, "secondary_ids" => $comments));
    foreach ((array) $activities as $ac_id) {
        bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $ac_id, $bp->ac_notifier->id, 'new_activity_comment_' . $ac_id);
    }
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:22,代码来源:ac-notify.php


示例15: tdomf_widget_comments_adminemail

function tdomf_widget_comments_adminemail($args)
{
    $options = tdomf_widget_comments_get_options($args['tdomf_form_id']);
    extract($args);
    $output = "";
    $post = wp_get_single_post($post_ID, ARRAY_A);
    if ($post['comment_status'] == 'closed') {
        $output .= __("Comments off", "tdomf");
    } else {
        $output .= __("Comments on", "tdomf");
    }
    $output .= "\n";
    if ($post['ping_status'] == 'closed') {
        $output .= __("Pings and Trackbacks off", "tdomf");
    } else {
        $output .= __("Pings and Trackbacks on", "tdomf");
    }
    $output .= $after_widget;
    return $output;
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:20,代码来源:tdomf-comments-widget.php


示例16: getPost

 public function getPost($postId)
 {
     return wp_get_single_post($postId);
 }
开发者ID:elementgreen,项目名称:affiliates-manager-plugin,代码行数:4,代码来源:PostHelper.php


示例17: pfp_get_posts

function pfp_get_posts($pfp_opts)
{
    $params = array();
    if ($pfp_opts['post_id'] == '') {
        // for multiposts
        if ($pfp_opts['tag_slug'] != '') {
            $params['tag_slug__in'] = explode(",", $pfp_opts['tag_slug']);
        }
        if ($pfp_opts['cat'] != '') {
            $params['category__in'] = explode(",", $pfp_opts['cat']);
        }
        if ($pfp_opts['cat_slug'] != '') {
            $params['category_name'] = $pfp_opts['cat_slug'];
        }
        if ($pfp_opts['author'] != '') {
            $params['author'] = $pfp_opts['author'];
        }
        if ($pfp_opts['order_by'] != '') {
            $params['order_by'] = $pfp_opts['order_by'];
        }
        if ($pfp_opts['num'] != '') {
            //$params['numberposts'] = $pfp_opts['num'];
            $params['posts_per_page'] = $pfp_opts['num'];
            $params['paged'] = $pfp_opts['cur_page'];
            //if($pfp_opts['page_num'] != '') {
            // work out offset depending on page num
            //$offset = $pfp_opts['page_num'] * $pfp_opts['num'];
            //$params['offset'] = $offset;
            //}
        } else {
            $params['posts_per_page'] = -1;
            // gets them all
        }
        if ($pfp_opts['order'] != '') {
            $params['order'] = $pfp_opts['order'];
        }
        // apply whatever the case:
        $params['suppress_filters'] = false;
        // get the posts
        //$postslist = get_posts($params);
        $postslist = query_posts($params);
    } else {
        // for single posts
        $postslist[0] = wp_get_single_post($pfp_opts['post_id']);
    }
    return $postslist;
}
开发者ID:kevintrogers,项目名称:justbkause,代码行数:47,代码来源:posts-for-page.php


示例18: getPost

 public function getPost($attr)
 {
     if ($postID = $this->get($attr)) {
         return wp_get_single_post($postID);
     }
     return new stdClass();
 }
开发者ID:netacceleration,项目名称:accelpress,代码行数:7,代码来源:AP_User.php


示例19: tdomf_ham_post

function tdomf_ham_post($post_id)
{
    if (!get_option(TDOMF_OPTION_SPAM)) {
        return;
    }
    $akismet_key = get_option(TDOMF_OPTION_SPAM_AKISMET_KEY);
    if (empty($akismet_key)) {
        tdomf_log_message("No Akismet key set, cannot submit ham for {$post_id}!", TDOMF_LOG_ERROR);
        return;
    }
    if (!get_post($post_id)) {
        tdomf_log_message("Post with ID {$post_id} does not exist!", TDOMF_LOG_ERROR);
        return;
    }
    if (!get_post_meta($post_id, TDOMF_KEY_FLAG, true)) {
        tdomf_log_message("{$post_id} is not managed by TDOMF - will not submit as ham!", TDOMF_LOG_BAD);
        return;
    }
    if (!get_post_meta($post_id, TDOMF_KEY_SPAM, true)) {
        tdomf_log_message("{$post_id} is not set as spam!", TDOMF_LOG_BAD);
        return;
    }
    $query_data = array();
    $query_data['user_ip'] = get_post_meta($post_id, TDOMF_KEY_IP, true);
    $query_data['user_agent'] = get_post_meta($post_id, TDOMF_KEY_USER_AGENT, true);
    $query_data['referrer'] = get_post_meta($post_id, TDOMF_KEY_REFERRER, true);
    $query_data['blog'] = get_option('home');
    $query_data['comment_type'] = 'new-submission';
    if (get_post_meta($post_id, TDOMF_KEY_USER_ID, true)) {
        $user = get_userdata(get_post_meta($post_id, TDOMF_KEY_USER_ID, true));
        $query_data['comment_author_email'] = $user->user_email;
        if (!empty($user->user_url)) {
            $query_data['comment_author_url'] = $user->user_url;
        }
        $query_data['comment_author'] = $user->display_name;
    } else {
        if (get_post_meta($post_id, TDOMF_KEY_NAME, true)) {
            $query_data['comment_author'] = get_post_meta($post_id, TDOMF_KEY_NAME, true);
        }
        if (get_post_meta($post_id, TDOMF_KEY_EMAIL, true)) {
            $query_data['comment_author_email'] = get_post_meta($post_id, TDOMF_KEY_EMAIL, true);
        }
        if (get_post_meta($post_id, TDOMF_KEY_WEB, true)) {
            $query_data['comment_author_url'] = get_post_meta($post_id, TDOMF_KEY_WEB, true);
        }
    }
    # test - should trigger spam response
    #$query_data['comment_author'] = 'viagra-test-123';
    $post_data = wp_get_single_post($post_id, ARRAY_A);
    $query_data['comment_content'] = $post_data['post_content'];
    /*if($live) {
         $ignore = array( 'HTTP_COOKIE' );
    	   foreach ( $_SERVER as $key => $value )
    	   if ( !in_array( $key, $ignore ) ) {
              $post_data["$key"] = $value;
         }
      }*/
    $query_string = '';
    foreach ($query_data as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    tdomf_log_message_extra("{$akismet_key}.rest.akismet.com/1.1/comment-check<br/>{$query_string}");
    $response = tdomf_akismet_send($query_string, $akismet_key . ".rest.akismet.com", "/1.1/submit-ham", 80);
    // unflag spam
    //
    delete_post_meta($post_id, TDOMF_KEY_SPAM);
    $spam_count = get_option(TDOMF_STAT_SPAM);
    if ($spam_count == false) {
        add_option(TDOMF_STAT_SPAM, 0);
    } else {
        update_option(TDOMF_STAT_SPAM, $spam_count--);
    }
    $submitted_count = get_option(TDOMF_STAT_SUBMITTED);
    if ($submitted_count == false) {
        add_option(TDOMF_STAT_SUBMITTED, 1);
    } else {
        update_option(TDOMF_STAT_SUBMITTED, $submitted_count++);
    }
    tdomf_log_message("{$post_id} has been submitted as ham to Akismet<br/><pre>" . var_export($response, true) . "</pre>");
}
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:80,代码来源:tdomf-spam.php


示例20: anno_article_to_post

/**
 * Converts a post with the article post-type to the post post-type
 * 
 * @param int $post_id The ID of the post to convert
 * @return void
 */
function anno_article_to_post($post_id)
{
    $post = wp_get_single_post(absint($post_id), ARRAY_A);
    if ($post['post_type'] != 'article') {
        return;
    }
    // Convert the taxonomies before inserting so we don't get default categories assigned.
    $taxonomy_conversion = array('article_tag' => 'post_tag', 'article_category' => 'category');
    foreach ($taxonomy_conversion as $from_tax => $to_tax) {
        anno_convert_taxonomies($post['ID'], $from_tax, $to_tax);
    }
    $post['post_type'] = 'post';
    $post['post_category'] = wp_get_post_categories($post['ID']);
    $post['tags_input'] = wp_get_post_tags($post['ID'], array('fields' => 'names'));
    $post_id = wp_insert_post($post);
}
开发者ID:nameofname,项目名称:momo-wordpress-theme,代码行数:22,代码来源:article-post-type.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_sites函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_sidebars_widgets函数代码示例发布时间: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