当前位置: 首页>>代码示例>>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;未经允许,请勿转载。