當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Error::error方法代碼示例

本文整理匯總了PHP中WP_Error::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Error::error方法的具體用法?PHP WP_Error::error怎麽用?PHP WP_Error::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Error的用法示例。


在下文中一共展示了WP_Error::error方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate_edit_forms_upsell_ad

    public function generate_edit_forms_upsell_ad()
    {
        /*
         *	SimplePie strips out all query strings
         * 	we had to implement a workaround
         *	https://github.com/simplepie/simplepie/issues/317
         */
        include_once ABSPATH . WPINC . '/feed.php';
        $rss = fetch_feed(esc_url('http://yikesplugins.com/feed/?post_type=product_ads&genre=easy-forms-for-mailchimp'));
        $maxitems = 0;
        if (!is_wp_error($rss)) {
            // Checks that the object is created correctly
            // Figure out how many total items there are, but limit it to 1.
            $maxitems = $rss->get_item_quantity(1);
            // Build an array of all the items, starting with element 0 (first element).
            $rss_items = $rss->get_items(0, $maxitems);
        } else {
            return $feed = new WP_Error('Simple Pie RSS Error', $feed->error());
        }
        // loop over returned results
        foreach ($rss_items as $add_on) {
            $add_on_desc = $add_on->get_content();
            ?>
					<h3><?php 
            echo $add_on->get_title();
            ?>
</h3>
					<div class="inside">
					<?php 
            echo $add_on_desc;
            ?>
					</div>
				<?php 
        }
    }
開發者ID:annbransom,項目名稱:techishowl-wp,代碼行數:35,代碼來源:class-yikes-inc-easy-mailchimp-extender-admin.php

示例2: array

/* Tell SimplePie to cache the feed using WordPress' cache class */
$feed->set_cache_class('WP_Feed_Cache');
/* Tell SimplePie to use the WordPress class for retrieving feed files */
$feed->set_file_class('WP_SimplePie_File');
$feed->enable_cache(true);
// temporary
/* Tell SimplePie how long to cache the feed data in the WordPress database */
$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $feed_url));
/* Run any other functions or filters that WordPress normally runs on feeds */
do_action_ref_array('wp_feed_options', array($feed, $feed_url));
/* Initiate the SimplePie instance */
$feed->init();
/* Tell SimplePie to send the feed MIME headers */
$feed->handle_content_type();
if ($feed->error()) {
    return $feed = new WP_Error('simplepie-error', $feed->error());
}
// print_r( $feed->get_items() );
foreach ($feed->get_items() as $add_on) {
    // store the description
    $description_pre_split = $add_on->get_description();
    $permalink = esc_url($add_on->get_permalink());
    $add_on_title = $add_on->get_title();
    // If the returned add-on is this base plugin, skip it
    if ($add_on_title != 'Easy Forms for MailChimp') {
        // extract the image
        preg_match('/<img[^>]+\\>/i', $description_pre_split, $split_string);
        // store the content sans image tag
        $description = preg_replace("/<img[^>]+\\>/i", "", $add_on->get_description());
        // store the image
        $image = count($split_string) > 0 ? $split_string[0] : '';
開發者ID:misfist,項目名稱:missdrepants-network,代碼行數:31,代碼來源:add-ons.php

示例3: array

    /* Set the URL of the feed you're retrieving */
    $article_feed->set_feed_url($rss_feed_url);
    /* Tell SimplePie to cache the feed using WordPress' cache class */
    $article_feed->set_cache_class('WP_Feed_Cache');
    /* Tell SimplePie to use the WordPress class for retrieving feed files */
    $article_feed->set_file_class('WP_SimplePie_File');
    /* Tell SimplePie how long to cache the feed data in the WordPress database - Cached for 8 hours */
    $article_feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 28800, $rss_feed_url));
    /* Run any other functions or filters that WordPress normally runs on feeds */
    do_action_ref_array('wp_feed_options', array($article_feed, $rss_feed_url));
    /* Initiate the SimplePie instance */
    $article_feed->init();
    /* Tell SimplePie to send the feed MIME headers */
    $article_feed->handle_content_type();
    if ($article_feed->error()) {
        return $article_feed = new WP_Error('simplepie-error', $article_feed->error());
    }
    // loop over latest items
    if ($article_feed->get_items()) {
        ?>
<ul class="knowledge-base-listing">
					<li class="list-title"><?php 
        echo $article_title;
        ?>
</li>
				<?php 
        foreach ($article_feed->get_items(0, 5) as $kb_article) {
            // store the description
            $description_pre_split = $kb_article->get_description();
            $kb_article_permalink = esc_url_raw($kb_article->get_permalink());
            $kb_article_permalink = add_query_arg(array('utm_source' => $page, 'utm_medium' => 'link', 'utm_campaign' => 'easy_forms_for_mailchimp'), esc_url_raw($kb_article_permalink));
開發者ID:misfist,項目名稱:missdrepants-network,代碼行數:31,代碼來源:knowledge-base-articles-RSS.php


注:本文中的WP_Error::error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。