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


PHP wp_trash_post函数代码示例

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


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

示例1: trashposts

function trashposts()
{
    $today = date('Ymd', current_time('timestamp', 0));
    $args = array('posts_per_page' => -1, 'post_type' => 'post');
    $the_query = new WP_Query($args);
    // The Loop
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            if (get_field('date')) {
                // if it has a start date i.e a single show/event
                if (get_field('end_date')) {
                    // if it has multiday shows
                    if (get_field('end_date') < $today) {
                        // and last one has past
                        wp_trash_post($post->ID);
                    }
                } else {
                    // if it has no end date ie single day show
                    if (get_field('date') < $today) {
                        // if it's past
                        wp_trash_post($post->ID);
                    }
                }
            }
        }
    }
    /* Restore original Post Data */
    wp_reset_postdata();
}
开发者ID:planktonWD,项目名称:Parkside-Quarry,代码行数:30,代码来源:trashposts.php

示例2: test_bbp_forum_trashed_untrashed_topic_counts

 /**
  * Generic function to test the forum counts on a trashed/untrashed topic
  */
 public function test_bbp_forum_trashed_untrashed_topic_counts()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create_many(3, array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r1 = $this->factory->reply->create_many(2, array('post_parent' => $t[1], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t[1])));
     $r2 = $this->factory->reply->create_many(2, array('post_parent' => $t[2], 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t[2])));
     $count = bbp_update_forum_topic_count($f);
     $this->assertSame(3, $count);
     $count = bbp_update_forum_topic_count_hidden($f);
     $this->assertSame(0, $count);
     $count = bbp_update_forum_reply_count($f);
     $this->assertSame(4, $count);
     // ToDo: Update this to use bbp_trash_topic().
     wp_trash_post($t[2]);
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(2, $count);
     $count = bbp_get_forum_topic_count_hidden($f, true, true);
     $this->assertSame(1, $count);
     $count = bbp_get_forum_reply_count($f, true, true);
     $this->assertSame(2, $count);
     // ToDo: Update this to use bbp_untrash_topic().
     wp_untrash_post($t[2]);
     $count = bbp_get_forum_topic_count($f, true, true);
     $this->assertSame(3, $count);
     $count = bbp_get_forum_topic_count_hidden($f, true, true);
     $this->assertSame(0, $count);
     $count = bbp_get_forum_reply_count($f, true, true);
     $this->assertSame(4, $count);
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:32,代码来源:counts.php

示例3: motopressCERemoveTemporaryPost

function motopressCERemoveTemporaryPost()
{
    require_once dirname(__FILE__) . '/../verifyNonce.php';
    require_once dirname(__FILE__) . '/../settings.php';
    require_once dirname(__FILE__) . '/../access.php';
    require_once dirname(__FILE__) . '/../Requirements.php';
    require_once dirname(__FILE__) . '/../functions.php';
    require_once dirname(__FILE__) . '/../getLanguageDict.php';
    require_once dirname(__FILE__) . '/ThemeFix.php';
    global $motopressCESettings;
    $motopressCELang = motopressCEGetLanguageDict();
    $errors = array();
    $post_id = $_POST['post_id'];
    $post = get_post($post_id);
    if (!is_null($post)) {
        $delete = wp_trash_post($post_id);
        new MPCEThemeFix(MPCEThemeFix::ACTIVATE);
        if ($delete === false) {
            $errors[] = $motopressCELang->CERemoveTemporaryPostError;
        }
    }
    if (!empty($errors)) {
        if ($motopressCESettings['debug']) {
            print_r($errors);
        } else {
            motopressCESetError($motopressCELang->CERemoveTemporaryPostError);
        }
    }
    exit;
}
开发者ID:umang11,项目名称:glotech,代码行数:30,代码来源:removeTemporaryPost.php

示例4: unlinkTranslationFor

 public function unlinkTranslationFor($objectId, $objectKind)
 {
     // Trash the translations' WP_Post first
     global $wpdb;
     $this->logger->logQueryStart();
     $locales = Strata::i18n()->getLocales();
     $app = Strata::app();
     foreach ($locales as $locale) {
         if ($objectKind === "WP_Post" && $locale->isTranslationOfPost($objectId)) {
             $translation = $locale->getTranslatedPost($objectId);
             if (!is_null($translation)) {
                 wp_trash_post($translation->ID);
             }
         } elseif ($objectKind === "Term" && $locale->hasTermTranslation($objectId)) {
             $translation = $locale->getTranslatedTerm($objectId);
             if (!is_null($translation)) {
                 wp_delete_term($translation->term_id);
             }
         }
     }
     // Then delete all the polyglot references
     // to that original post.
     $result = $wpdb->delete($wpdb->prefix . 'polyglot', array("translation_of" => $objectId, "obj_kind" => $objectKind));
     $this->logger->logQueryCompletion($wpdb->last_query);
     return $result;
 }
开发者ID:francoisfaubert,项目名称:strata-polyglot,代码行数:26,代码来源:Query.php

示例5: delete_discount

 function delete_discount($force_delete = false)
 {
     if ($force_delete) {
         wp_delete_post($this->id);
     } else {
         wp_trash_post($this->id);
     }
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:8,代码来源:class.discount.php

示例6: idx_ajax_delete_dynamic_page

 public function idx_ajax_delete_dynamic_page()
 {
     if ($_POST['wrapper_page_id']) {
         wp_delete_post($_POST['wrapper_page_id'], true);
         wp_trash_post($_POST['wrapper_page_id']);
     }
     die;
 }
开发者ID:jdelia,项目名称:wordpress-plugin,代码行数:8,代码来源:wrappers.php

示例7: cron

 function cron()
 {
     global $wpdb;
     $result = $wpdb->get_results($wpdb->prepare('SELECT post_id FROM ' . $wpdb->postmeta . ' WHERE meta_key = "_expiration_date" AND meta_value < %s', time()));
     foreach ($result as $a) {
         wp_trash_post($a->post_id);
     }
 }
开发者ID:rtgibbons,项目名称:bya.org,代码行数:8,代码来源:Hetjens_Expiration_Date.php

示例8: trash_translation

 public function trash_translation($trans_id)
 {
     if (WPML_WordPress_Actions::is_bulk_trash($trans_id)) {
         // Do nothing as the translation is part of the bulk trash.
     } else {
         wp_trash_post($trans_id);
     }
 }
开发者ID:edgarter,项目名称:wecare,代码行数:8,代码来源:wpml-post-translation.class.php

示例9: delete_template

 function delete_template($force_delete = false)
 {
     if ($force_delete) {
         wp_delete_post($this->id);
     } else {
         wp_trash_post($this->id);
     }
 }
开发者ID:gabriel-dehan,项目名称:erdf-sessions,代码行数:8,代码来源:class.ticket_template.php

示例10: delete_ticket_instance

 function delete_ticket_instance($force_delete = true)
 {
     if ($force_delete) {
         wp_delete_post($this->id);
     } else {
         wp_trash_post($this->id);
     }
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:8,代码来源:class.ticket_instance.php

示例11: delete_api_key

 function delete_api_key($force_delete = true)
 {
     if ($force_delete) {
         wp_delete_post($this->id);
     } else {
         wp_trash_post($this->id);
     }
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:8,代码来源:class.api_key.php

示例12: test_trashed_post

 function test_trashed_post()
 {
     $post_id = $this->factory->post->create(array('post_title' => 'test post'));
     SP_API()->post('_refresh');
     $this->assertEquals(array('test-post'), $this->search_and_get_field(array('query' => 'test post')));
     wp_trash_post($post_id);
     SP_API()->post('_refresh');
     $this->assertEmpty($this->search_and_get_field(array('query' => 'test post')));
 }
开发者ID:dfmedia,项目名称:searchpress,代码行数:9,代码来源:test-indexing.php

示例13: wp_trash_post

 /**
  * @ticket 11863
  */
 function test_untrashing_a_post_with_a_stored_desired_post_name_should_get_its_post_name_suffixed_if_another_post_has_taken_the_desired_post_name()
 {
     $about_page_id = self::factory()->post->create(array('post_type' => 'page', 'post_title' => 'About', 'post_status' => 'publish'));
     wp_trash_post($about_page_id);
     $another_about_page_id = self::factory()->post->create(array('post_type' => 'page', 'post_title' => 'About', 'post_status' => 'publish'));
     wp_untrash_post($about_page_id);
     $this->assertEquals('about', get_post($another_about_page_id)->post_name);
     $this->assertEquals('about-2', get_post($about_page_id)->post_name);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:wpInsertPost.php

示例14: stage_post_trash_callback

function stage_post_trash_callback()
{
    global $wpdb;
    // this is how you get access to the database
    $id = intval($_POST['post_id']);
    wp_trash_post($id);
    echo 'successfully deleted ' . $id;
    die;
    // this is required to return a proper result
}
开发者ID:thetmkay,项目名称:stage-craft,代码行数:10,代码来源:trash-posts-controller.php

示例15: apply_age_limit

 private function apply_age_limit(WP_Post $post)
 {
     $this->meta->set_post_id($post->ID);
     if ($this->meta->get_cron_id() == $this->cron_id) {
         $post_date = strtotime($this->meta->get_post_date());
         if ($post_date < $this->age_limit) {
             wp_trash_post($post->ID);
         }
     }
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:10,代码来源:class-fw-backup-process-apply-age-limit.php


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