Edit File by line
/home/barbar84/public_h.../wp-inclu.../SimplePi...
File: Item.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* SimplePie
[2] Fix | Delete
*
[3] Fix | Delete
* A PHP-Based RSS and Atom Feed Framework.
[4] Fix | Delete
* Takes the hard work out of managing a complete RSS/Atom solution.
[5] Fix | Delete
*
[6] Fix | Delete
* Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
[7] Fix | Delete
* All rights reserved.
[8] Fix | Delete
*
[9] Fix | Delete
* Redistribution and use in source and binary forms, with or without modification, are
[10] Fix | Delete
* permitted provided that the following conditions are met:
[11] Fix | Delete
*
[12] Fix | Delete
* * Redistributions of source code must retain the above copyright notice, this list of
[13] Fix | Delete
* conditions and the following disclaimer.
[14] Fix | Delete
*
[15] Fix | Delete
* * Redistributions in binary form must reproduce the above copyright notice, this list
[16] Fix | Delete
* of conditions and the following disclaimer in the documentation and/or other materials
[17] Fix | Delete
* provided with the distribution.
[18] Fix | Delete
*
[19] Fix | Delete
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
[20] Fix | Delete
* to endorse or promote products derived from this software without specific prior
[21] Fix | Delete
* written permission.
[22] Fix | Delete
*
[23] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
[24] Fix | Delete
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
[25] Fix | Delete
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
[26] Fix | Delete
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
[27] Fix | Delete
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
[28] Fix | Delete
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[29] Fix | Delete
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
[30] Fix | Delete
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
[31] Fix | Delete
* POSSIBILITY OF SUCH DAMAGE.
[32] Fix | Delete
*
[33] Fix | Delete
* @package SimplePie
[34] Fix | Delete
* @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
[35] Fix | Delete
* @author Ryan Parman
[36] Fix | Delete
* @author Sam Sneddon
[37] Fix | Delete
* @author Ryan McCue
[38] Fix | Delete
* @link http://simplepie.org/ SimplePie
[39] Fix | Delete
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
[40] Fix | Delete
*/
[41] Fix | Delete
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Manages all item-related data
[45] Fix | Delete
*
[46] Fix | Delete
* Used by {@see SimplePie::get_item()} and {@see SimplePie::get_items()}
[47] Fix | Delete
*
[48] Fix | Delete
* This class can be overloaded with {@see SimplePie::set_item_class()}
[49] Fix | Delete
*
[50] Fix | Delete
* @package SimplePie
[51] Fix | Delete
* @subpackage API
[52] Fix | Delete
*/
[53] Fix | Delete
class SimplePie_Item
[54] Fix | Delete
{
[55] Fix | Delete
/**
[56] Fix | Delete
* Parent feed
[57] Fix | Delete
*
[58] Fix | Delete
* @access private
[59] Fix | Delete
* @var SimplePie
[60] Fix | Delete
*/
[61] Fix | Delete
var $feed;
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Raw data
[65] Fix | Delete
*
[66] Fix | Delete
* @access private
[67] Fix | Delete
* @var array
[68] Fix | Delete
*/
[69] Fix | Delete
var $data = array();
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Registry object
[73] Fix | Delete
*
[74] Fix | Delete
* @see set_registry
[75] Fix | Delete
* @var SimplePie_Registry
[76] Fix | Delete
*/
[77] Fix | Delete
protected $registry;
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* Create a new item object
[81] Fix | Delete
*
[82] Fix | Delete
* This is usually used by {@see SimplePie::get_items} and
[83] Fix | Delete
* {@see SimplePie::get_item}. Avoid creating this manually.
[84] Fix | Delete
*
[85] Fix | Delete
* @param SimplePie $feed Parent feed
[86] Fix | Delete
* @param array $data Raw data
[87] Fix | Delete
*/
[88] Fix | Delete
public function __construct($feed, $data)
[89] Fix | Delete
{
[90] Fix | Delete
$this->feed = $feed;
[91] Fix | Delete
$this->data = $data;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Set the registry handler
[96] Fix | Delete
*
[97] Fix | Delete
* This is usually used by {@see SimplePie_Registry::create}
[98] Fix | Delete
*
[99] Fix | Delete
* @since 1.3
[100] Fix | Delete
* @param SimplePie_Registry $registry
[101] Fix | Delete
*/
[102] Fix | Delete
public function set_registry(SimplePie_Registry $registry)
[103] Fix | Delete
{
[104] Fix | Delete
$this->registry = $registry;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* Get a string representation of the item
[109] Fix | Delete
*
[110] Fix | Delete
* @return string
[111] Fix | Delete
*/
[112] Fix | Delete
public function __toString()
[113] Fix | Delete
{
[114] Fix | Delete
return md5(serialize($this->data));
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Remove items that link back to this before destroying this object
[119] Fix | Delete
*/
[120] Fix | Delete
public function __destruct()
[121] Fix | Delete
{
[122] Fix | Delete
if (!gc_enabled())
[123] Fix | Delete
{
[124] Fix | Delete
unset($this->feed);
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Get data for an item-level element
[130] Fix | Delete
*
[131] Fix | Delete
* This method allows you to get access to ANY element/attribute that is a
[132] Fix | Delete
* sub-element of the item/entry tag.
[133] Fix | Delete
*
[134] Fix | Delete
* See {@see SimplePie::get_feed_tags()} for a description of the return value
[135] Fix | Delete
*
[136] Fix | Delete
* @since 1.0
[137] Fix | Delete
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
[138] Fix | Delete
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
[139] Fix | Delete
* @param string $tag Tag name
[140] Fix | Delete
* @return array
[141] Fix | Delete
*/
[142] Fix | Delete
public function get_item_tags($namespace, $tag)
[143] Fix | Delete
{
[144] Fix | Delete
if (isset($this->data['child'][$namespace][$tag]))
[145] Fix | Delete
{
[146] Fix | Delete
return $this->data['child'][$namespace][$tag];
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
return null;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Get the base URL value from the parent feed
[154] Fix | Delete
*
[155] Fix | Delete
* Uses `<xml:base>`
[156] Fix | Delete
*
[157] Fix | Delete
* @param array $element
[158] Fix | Delete
* @return string
[159] Fix | Delete
*/
[160] Fix | Delete
public function get_base($element = array())
[161] Fix | Delete
{
[162] Fix | Delete
return $this->feed->get_base($element);
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
/**
[166] Fix | Delete
* Sanitize feed data
[167] Fix | Delete
*
[168] Fix | Delete
* @access private
[169] Fix | Delete
* @see SimplePie::sanitize()
[170] Fix | Delete
* @param string $data Data to sanitize
[171] Fix | Delete
* @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
[172] Fix | Delete
* @param string $base Base URL to resolve URLs against
[173] Fix | Delete
* @return string Sanitized data
[174] Fix | Delete
*/
[175] Fix | Delete
public function sanitize($data, $type, $base = '')
[176] Fix | Delete
{
[177] Fix | Delete
return $this->feed->sanitize($data, $type, $base);
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Get the parent feed
[182] Fix | Delete
*
[183] Fix | Delete
* Note: this may not work as you think for multifeeds!
[184] Fix | Delete
*
[185] Fix | Delete
* @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed
[186] Fix | Delete
* @since 1.0
[187] Fix | Delete
* @return SimplePie
[188] Fix | Delete
*/
[189] Fix | Delete
public function get_feed()
[190] Fix | Delete
{
[191] Fix | Delete
return $this->feed;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Get the unique identifier for the item
[196] Fix | Delete
*
[197] Fix | Delete
* This is usually used when writing code to check for new items in a feed.
[198] Fix | Delete
*
[199] Fix | Delete
* Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
[200] Fix | Delete
* for RDF. If none of these are supplied (or `$hash` is true), creates an
[201] Fix | Delete
* MD5 hash based on the permalink, title and content.
[202] Fix | Delete
*
[203] Fix | Delete
* @since Beta 2
[204] Fix | Delete
* @param boolean $hash Should we force using a hash instead of the supplied ID?
[205] Fix | Delete
* @param string|false $fn User-supplied function to generate an hash
[206] Fix | Delete
* @return string|null
[207] Fix | Delete
*/
[208] Fix | Delete
public function get_id($hash = false, $fn = 'md5')
[209] Fix | Delete
{
[210] Fix | Delete
if (!$hash)
[211] Fix | Delete
{
[212] Fix | Delete
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id'))
[213] Fix | Delete
{
[214] Fix | Delete
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[215] Fix | Delete
}
[216] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id'))
[217] Fix | Delete
{
[218] Fix | Delete
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[219] Fix | Delete
}
[220] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid'))
[221] Fix | Delete
{
[222] Fix | Delete
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[223] Fix | Delete
}
[224] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier'))
[225] Fix | Delete
{
[226] Fix | Delete
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[227] Fix | Delete
}
[228] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier'))
[229] Fix | Delete
{
[230] Fix | Delete
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[231] Fix | Delete
}
[232] Fix | Delete
elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about']))
[233] Fix | Delete
{
[234] Fix | Delete
return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
if ($fn === false)
[238] Fix | Delete
{
[239] Fix | Delete
return null;
[240] Fix | Delete
}
[241] Fix | Delete
elseif (!is_callable($fn))
[242] Fix | Delete
{
[243] Fix | Delete
trigger_error('User-supplied function $fn must be callable', E_USER_WARNING);
[244] Fix | Delete
$fn = 'md5';
[245] Fix | Delete
}
[246] Fix | Delete
return call_user_func($fn,
[247] Fix | Delete
$this->get_permalink().$this->get_title().$this->get_content());
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
/**
[251] Fix | Delete
* Get the title of the item
[252] Fix | Delete
*
[253] Fix | Delete
* Uses `<atom:title>`, `<title>` or `<dc:title>`
[254] Fix | Delete
*
[255] Fix | Delete
* @since Beta 2 (previously called `get_item_title` since 0.8)
[256] Fix | Delete
* @return string|null
[257] Fix | Delete
*/
[258] Fix | Delete
public function get_title()
[259] Fix | Delete
{
[260] Fix | Delete
if (!isset($this->data['title']))
[261] Fix | Delete
{
[262] Fix | Delete
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title'))
[263] Fix | Delete
{
[264] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
[265] Fix | Delete
}
[266] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title'))
[267] Fix | Delete
{
[268] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0]));
[269] Fix | Delete
}
[270] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title'))
[271] Fix | Delete
{
[272] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[273] Fix | Delete
}
[274] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title'))
[275] Fix | Delete
{
[276] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[277] Fix | Delete
}
[278] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title'))
[279] Fix | Delete
{
[280] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[281] Fix | Delete
}
[282] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title'))
[283] Fix | Delete
{
[284] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[285] Fix | Delete
}
[286] Fix | Delete
elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title'))
[287] Fix | Delete
{
[288] Fix | Delete
$this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[289] Fix | Delete
}
[290] Fix | Delete
else
[291] Fix | Delete
{
[292] Fix | Delete
$this->data['title'] = null;
[293] Fix | Delete
}
[294] Fix | Delete
}
[295] Fix | Delete
return $this->data['title'];
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Get the content for the item
[300] Fix | Delete
*
[301] Fix | Delete
* Prefers summaries over full content , but will return full content if a
[302] Fix | Delete
* summary does not exist.
[303] Fix | Delete
*
[304] Fix | Delete
* To prefer full content instead, use {@see get_content}
[305] Fix | Delete
*
[306] Fix | Delete
* Uses `<atom:summary>`, `<description>`, `<dc:description>` or
[307] Fix | Delete
* `<itunes:subtitle>`
[308] Fix | Delete
*
[309] Fix | Delete
* @since 0.8
[310] Fix | Delete
* @param boolean $description_only Should we avoid falling back to the content?
[311] Fix | Delete
* @return string|null
[312] Fix | Delete
*/
[313] Fix | Delete
public function get_description($description_only = false)
[314] Fix | Delete
{
[315] Fix | Delete
if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) &&
[316] Fix | Delete
($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
[317] Fix | Delete
{
[318] Fix | Delete
return $return;
[319] Fix | Delete
}
[320] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) &&
[321] Fix | Delete
($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
[322] Fix | Delete
{
[323] Fix | Delete
return $return;
[324] Fix | Delete
}
[325] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) &&
[326] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0]))))
[327] Fix | Delete
{
[328] Fix | Delete
return $return;
[329] Fix | Delete
}
[330] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) &&
[331] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
[332] Fix | Delete
{
[333] Fix | Delete
return $return;
[334] Fix | Delete
}
[335] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) &&
[336] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
[337] Fix | Delete
{
[338] Fix | Delete
return $return;
[339] Fix | Delete
}
[340] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) &&
[341] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
[342] Fix | Delete
{
[343] Fix | Delete
return $return;
[344] Fix | Delete
}
[345] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) &&
[346] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
[347] Fix | Delete
{
[348] Fix | Delete
return $return;
[349] Fix | Delete
}
[350] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) &&
[351] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
[352] Fix | Delete
{
[353] Fix | Delete
return $return;
[354] Fix | Delete
}
[355] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) &&
[356] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)))
[357] Fix | Delete
{
[358] Fix | Delete
return $return;
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
elseif (!$description_only)
[362] Fix | Delete
{
[363] Fix | Delete
return $this->get_content(true);
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
return null;
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
/**
[370] Fix | Delete
* Get the content for the item
[371] Fix | Delete
*
[372] Fix | Delete
* Prefers full content over summaries, but will return a summary if full
[373] Fix | Delete
* content does not exist.
[374] Fix | Delete
*
[375] Fix | Delete
* To prefer summaries instead, use {@see get_description}
[376] Fix | Delete
*
[377] Fix | Delete
* Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module)
[378] Fix | Delete
*
[379] Fix | Delete
* @since 1.0
[380] Fix | Delete
* @param boolean $content_only Should we avoid falling back to the description?
[381] Fix | Delete
* @return string|null
[382] Fix | Delete
*/
[383] Fix | Delete
public function get_content($content_only = false)
[384] Fix | Delete
{
[385] Fix | Delete
if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) &&
[386] Fix | Delete
($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
[387] Fix | Delete
{
[388] Fix | Delete
return $return;
[389] Fix | Delete
}
[390] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) &&
[391] Fix | Delete
($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
[392] Fix | Delete
{
[393] Fix | Delete
return $return;
[394] Fix | Delete
}
[395] Fix | Delete
elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) &&
[396] Fix | Delete
($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
[397] Fix | Delete
{
[398] Fix | Delete
return $return;
[399] Fix | Delete
}
[400] Fix | Delete
elseif (!$content_only)
[401] Fix | Delete
{
[402] Fix | Delete
return $this->get_description(true);
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
return null;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
/**
[409] Fix | Delete
* Get the media:thumbnail of the item
[410] Fix | Delete
*
[411] Fix | Delete
* Uses `<media:thumbnail>`
[412] Fix | Delete
*
[413] Fix | Delete
*
[414] Fix | Delete
* @return array|null
[415] Fix | Delete
*/
[416] Fix | Delete
public function get_thumbnail()
[417] Fix | Delete
{
[418] Fix | Delete
if (!isset($this->data['thumbnail']))
[419] Fix | Delete
{
[420] Fix | Delete
if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail'))
[421] Fix | Delete
{
[422] Fix | Delete
$this->data['thumbnail'] = $return[0]['attribs'][''];
[423] Fix | Delete
}
[424] Fix | Delete
else
[425] Fix | Delete
{
[426] Fix | Delete
$this->data['thumbnail'] = null;
[427] Fix | Delete
}
[428] Fix | Delete
}
[429] Fix | Delete
return $this->data['thumbnail'];
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
/**
[433] Fix | Delete
* Get a category for the item
[434] Fix | Delete
*
[435] Fix | Delete
* @since Beta 3 (previously called `get_categories()` since Beta 2)
[436] Fix | Delete
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
[437] Fix | Delete
* @return SimplePie_Category|null
[438] Fix | Delete
*/
[439] Fix | Delete
public function get_category($key = 0)
[440] Fix | Delete
{
[441] Fix | Delete
$categories = $this->get_categories();
[442] Fix | Delete
if (isset($categories[$key]))
[443] Fix | Delete
{
[444] Fix | Delete
return $categories[$key];
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
return null;
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
/**
[451] Fix | Delete
* Get all categories for the item
[452] Fix | Delete
*
[453] Fix | Delete
* Uses `<atom:category>`, `<category>` or `<dc:subject>`
[454] Fix | Delete
*
[455] Fix | Delete
* @since Beta 3
[456] Fix | Delete
* @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects
[457] Fix | Delete
*/
[458] Fix | Delete
public function get_categories()
[459] Fix | Delete
{
[460] Fix | Delete
$categories = array();
[461] Fix | Delete
[462] Fix | Delete
$type = 'category';
[463] Fix | Delete
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, $type) as $category)
[464] Fix | Delete
{
[465] Fix | Delete
$term = null;
[466] Fix | Delete
$scheme = null;
[467] Fix | Delete
$label = null;
[468] Fix | Delete
if (isset($category['attribs']['']['term']))
[469] Fix | Delete
{
[470] Fix | Delete
$term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT);
[471] Fix | Delete
}
[472] Fix | Delete
if (isset($category['attribs']['']['scheme']))
[473] Fix | Delete
{
[474] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT);
[475] Fix | Delete
}
[476] Fix | Delete
if (isset($category['attribs']['']['label']))
[477] Fix | Delete
{
[478] Fix | Delete
$label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
[479] Fix | Delete
}
[480] Fix | Delete
$categories[] = $this->registry->create('Category', array($term, $scheme, $label, $type));
[481] Fix | Delete
}
[482] Fix | Delete
foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $type) as $category)
[483] Fix | Delete
{
[484] Fix | Delete
// This is really the label, but keep this as the term also for BC.
[485] Fix | Delete
// Label will also work on retrieving because that falls back to term.
[486] Fix | Delete
$term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT);
[487] Fix | Delete
if (isset($category['attribs']['']['domain']))
[488] Fix | Delete
{
[489] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT);
[490] Fix | Delete
}
[491] Fix | Delete
else
[492] Fix | Delete
{
[493] Fix | Delete
$scheme = null;
[494] Fix | Delete
}
[495] Fix | Delete
$categories[] = $this->registry->create('Category', array($term, $scheme, null, $type));
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
$type = 'subject';
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function