当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_get_single_post函数代码示例

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


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


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