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


PHP WP_Error::get_items方法代码示例

本文整理汇总了PHP中WP_Error::get_items方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_items方法的具体用法?PHP WP_Error::get_items怎么用?PHP WP_Error::get_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Error的用法示例。


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

示例1: array

$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] : '';
        // if {hidden} is found, exclude it
        if (strpos($description_pre_split, '{hidden}')) {
            continue;
开发者ID:misfist,项目名称:missdrepants-network,代码行数:31,代码来源:add-ons.php

示例2: array

    $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));
            $kb_article_title = $kb_article->get_title();
            // store the content sans image tag
            $description = $kb_article->get_description();
开发者ID:misfist,项目名称:missdrepants-network,代码行数:31,代码来源:knowledge-base-articles-RSS.php


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