Advertisement
valuser

Simplepie-wp-onp.php

Jan 21st, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 84.64 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: SimplePie Plugin for WordPress
  4. Version: 2.2.1
  5. Plugin URI: http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress
  6. Description: A fast and easy way to add RSS and Atom feeds to your WordPress blog. Go to <a href="options-general.php?page=simplepie_wordpress_2">Settings&rarr;SimplePie for WP</a> to adjust default settings.
  7. Author: Ryan Parman
  8. Author URI: http://simplepie.org/
  9. */
  10.  
  11.  
  12. /*********************************************************************************/
  13.  
  14.  
  15. /**
  16. * Define version for the plugin.
  17. */
  18. define('SIMPLEPIE_PLUGIN', '2.2.1');
  19.  
  20. /**
  21. * Expected minimum SimplePie build number.
  22. */
  23. define('EXPECTED_SIMPLEPIE_VERSION', '1.1.1');
  24.  
  25. /**
  26. * Expected minimum SimplePie build number.
  27. */
  28. define('EXPECTED_SIMPLEPIE_BUILD', 20080315205903);
  29.  
  30. /**
  31. * WordPress version.
  32. */
  33. define('WP_VERSION', get_bloginfo('version'));
  34.  
  35. /**
  36. * Web-accessible wp-content directory.
  37. */
  38. define('WP_CONTENT_WEB', get_bloginfo('wpurl') . '/wp-content');
  39.  
  40. /**
  41. * Web-accessible control panel page.
  42. */
  43. define('WP_CPANEL', get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=simplepie_wordpress_2');
  44.  
  45. /**
  46. * Set absolute SimplePie plugin directory.
  47. */
  48. define('SIMPLEPIE_PLUGINDIR', dirname(__FILE__));
  49.  
  50. /**
  51. * Get only the name of the plugin directory.
  52. */
  53. define('SIMPLEPIE_PLUGINDIR_NAME', pathinfo(dirname(__FILE__), PATHINFO_BASENAME));
  54.  
  55. /**
  56. * Web-accessible URL for the plugin directory.
  57. */
  58. define('SIMPLEPIE_PLUGINDIR_WEB', get_template_directory_uri() . '/' . SIMPLEPIE_PLUGINDIR_NAME); //edited: change path to themes-> define('SIMPLEPIE_PLUGINDIR_WEB', WP_CONTENT_WEB . '/plugins/' . SIMPLEPIE_PLUGINDIR_NAME);
  59.  
  60. /**
  61. * Default cache directory.
  62. */
  63. define('SIMPLEPIE_CACHEDIR', SIMPLEPIE_PLUGINDIR . '/cache');
  64.  
  65.  
  66. /*********************************************************************************/
  67.  
  68.  
  69. /**
  70. * Wrapper class for static functions
  71. */
  72. class SimplePie_WordPress
  73. {
  74. /**
  75. * Shortens path names based on the location of /wp-content/.
  76. */
  77. function clean_wp_path($path)
  78. {
  79. if ($wp_path = stristr($path, 'wp-content'))
  80. {
  81. return '[WP Install]/' . $wp_path;
  82. }
  83. else
  84. {
  85. return $path;
  86. }
  87. }
  88.  
  89. /**
  90. * Re-implement str_split() in PHP 4.x
  91. * Written by dacmeaux at gmail dot com, posted to http://us3.php.net/str_split
  92. * Modified by Ryan Parman, http://simplepie.org
  93. */
  94. function str_split($text)
  95. {
  96. // If str_split() exists in PHP, use it.
  97. if (function_exists('str_split'))
  98. {
  99. return str_split($text);
  100. }
  101.  
  102. // Otherwise, emulate it.
  103. else
  104. {
  105. $array = array();
  106. $text_len = strlen($text);
  107. for ($i = 0; $i < $text_len; $i++)
  108. {
  109. $key = NULL;
  110. for ($j = 0; $j < 1; $j++)
  111. {
  112. $key .= $text[$i];
  113. }
  114. array_push($array, $key);
  115. }
  116. return $array;
  117. }
  118. }
  119.  
  120. /**
  121. * version_compare() is being stupid, so let's work around it.
  122. */
  123. function convert_to_version($s)
  124. {
  125. $s = strval($s);
  126. $s = SimplePie_WordPress::str_split($s);
  127. $s = implode('.', $s);
  128. return $s;
  129. }
  130.  
  131. /**
  132. * Get a list of files from a given directory.
  133. */
  134. function get_files($dir, $extension)
  135. {
  136. $temp = array();
  137.  
  138. if (is_dir($dir))
  139. {
  140. if ($dh = opendir($dir))
  141. {
  142. while (($file = readdir($dh)) !== false)
  143. {
  144. if (!is_dir($file))
  145. {
  146. // Determine location of the file
  147. $location = $dir . $file;
  148.  
  149. // Determine label for the template file
  150. $label = explode($extension, $file);
  151. $label = str_replace('_', ' ', $label[0]);
  152. $label = str_replace('-', ' ', $label);
  153. $label = str_replace('.', ' ', $label);
  154. $label = ucwords($label);
  155.  
  156. // Add them to the array.
  157. $temp[] = array('location' => $location, 'label' => $label);
  158. }
  159. }
  160. closedir($dh);
  161. }
  162. }
  163.  
  164. return $temp;
  165. }
  166.  
  167. /**
  168. * Handles the post-processing of data.
  169. */
  170. function post_process($swap, $s)
  171. {
  172. if (class_exists('SimplePie_PostProcess'))
  173. {
  174. $swap = strtolower($swap);
  175. $post = new SimplePie_PostProcess;
  176.  
  177. if (method_exists($post, $swap))
  178. {
  179. $s = SimplePie_PostProcess::$swap($s);
  180. }
  181. }
  182.  
  183. return $s;
  184. }
  185.  
  186. /**
  187. * Delete all related values in the database.
  188. */
  189. function delete_values()
  190. {
  191. // General settings
  192. delete_option('simplepie_template');
  193. delete_option('simplepie_items');
  194. delete_option('simplepie_items_per_feed');
  195. delete_option('simplepie_date_format');
  196. delete_option('simplepie_enable_cache');
  197. delete_option('simplepie_set_cache_location');
  198. delete_option('simplepie_set_cache_duration');
  199. delete_option('simplepie_enable_order_by_date');
  200. delete_option('simplepie_set_timeout');
  201.  
  202. // Text-shortening settings
  203. delete_option('simplepie_truncate_feed_title');
  204. delete_option('simplepie_truncate_feed_description');
  205. delete_option('simplepie_truncate_item_title');
  206. delete_option('simplepie_truncate_item_description');
  207.  
  208. // Advanced settings
  209. delete_option('simplepie_processing');
  210. delete_option('simplepie_locale');
  211. delete_option('simplepie_local_date_format');
  212. delete_option('simplepie_strip_htmltags');
  213. delete_option('simplepie_strip_attributes');
  214. delete_option('simplepie_set_max_checked_feeds');
  215. delete_option('simplepie_plugin_installed');
  216. }
  217. }
  218.  
  219.  
  220. /**
  221. * Set if this we're asked to reset the settings.
  222. */
  223. if (isset($_POST['reset_all_settings']))
  224. {
  225. SimplePie_WordPress::delete_values();
  226. }
  227.  
  228. /**
  229. * Set default options if they're not already set.
  230. */
  231. if (!get_option('simplepie_template'))
  232. {
  233. update_option('simplepie_template', SIMPLEPIE_PLUGINDIR . '/templates/textrss.tmpl', 'The template to use for displaying feeds.');
  234. }
  235.  
  236. if (!get_option('simplepie_items'))
  237. {
  238. update_option('simplepie_items', '0', 'The number of feed items to display by default.');
  239. }
  240.  
  241. if (!get_option('simplepie_items_per_feed'))
  242. {
  243. update_option('simplepie_items_per_feed', '0', 'The number of feed items to display per feed when using Multifeeds.');
  244. }
  245.  
  246. if (!get_option('simplepie_date_format'))
  247. {
  248. update_option('simplepie_date_format', 'j M y, g:ia', 'The default format for English dates.');
  249. }
  250.  
  251. if (!get_option('simplepie_enable_cache'))
  252. {
  253. update_option('simplepie_enable_cache', 'true', 'Whether the feeds should be cached or not.');
  254. }
  255.  
  256. if (!get_option('simplepie_set_cache_location'))
  257. {
  258. update_option('simplepie_set_cache_location', SIMPLEPIE_CACHEDIR, 'The file system location for the cache.');
  259. }
  260.  
  261. if (!get_option('simplepie_set_cache_duration'))
  262. {
  263. update_option('simplepie_set_cache_duration', '3600', 'The number of seconds that feed data should be cached for before asking the feed if it\'s been changed.');
  264. }
  265.  
  266. if (!get_option('simplepie_enable_order_by_date'))
  267. {
  268. update_option('simplepie_enable_order_by_date', 'false', 'Feeds items aren\'t always in chronological order. This fixes that.');
  269. }
  270.  
  271. if (!get_option('simplepie_set_timeout'))
  272. {
  273. update_option('simplepie_set_timeout', '4', 'Number of seconds to wait for a remote feed to respond before giving up.'); //edited: was 10 seconds
  274. }
  275.  
  276. if (!get_option('simplepie_truncate_feed_title'))
  277. {
  278. update_option('simplepie_truncate_feed_title', '0', 'Number of characters to shorten the text to.');
  279. }
  280.  
  281. if (!get_option('simplepie_truncate_feed_description'))
  282. {
  283. update_option('simplepie_truncate_feed_description', '300', 'Number of characters to shorten the text to.');
  284. }
  285.  
  286. if (!get_option('simplepie_truncate_item_title'))
  287. {
  288. update_option('simplepie_truncate_item_title', '50', 'Number of characters to shorten the text to.');
  289. }
  290.  
  291. if (!get_option('simplepie_truncate_item_description'))
  292. {
  293. update_option('simplepie_truncate_item_description', '250', 'Number of characters to shorten the text to.');
  294. }
  295.  
  296. if (!get_option('simplepie_processing'))
  297. {
  298. update_option('simplepie_processing', SIMPLEPIE_PLUGINDIR . '/processing/none.php', 'The rules to use for post-processing feeds.');
  299. }
  300.  
  301. if (!get_option('simplepie_locale'))
  302. {
  303. update_option('simplepie_locale', 'auto', 'The locale for the website.');
  304. }
  305.  
  306. if (!get_option('simplepie_local_date_format'))
  307. {
  308. update_option('simplepie_local_date_format', '%A, %e %B %Y, %H:%M', 'The default format for localized dates.');
  309. }
  310.  
  311. if (!get_option('simplepie_strip_htmltags'))
  312. {
  313. update_option('simplepie_strip_htmltags', 'base blink body doctype embed font form frame frameset html iframe input marquee meta noscript object param script style', 'The HTML tags to be stripped by default.');
  314. }
  315.  
  316. if (!get_option('simplepie_strip_attributes'))
  317. {
  318. update_option('simplepie_strip_attributes', 'bgsound class expr id style onclick onerror onfinish onmouseover onmouseout onfocus onblur lowsrc dynsrc', 'The HTML attributes to be stripped by default.');
  319. }
  320.  
  321. if (!get_option('simplepie_set_max_checked_feeds'))
  322. {
  323. update_option('simplepie_set_max_checked_feeds', '10', 'The number of links in the document to check for feeds.');
  324. }
  325.  
  326.  
  327. /*********************************************************************************/
  328.  
  329.  
  330. /**
  331. * Add menu item to Options menu.
  332. */
  333. function simplepie_options()
  334. {
  335. if (function_exists('add_options_page'))
  336. {
  337. add_options_page('SimplePie for WP', 'SimplePie for WP', 8, 'simplepie_wordpress_2', 'simplepie_options_page');
  338. }
  339. }
  340.  
  341. /**
  342. * Trigger the adding of the menu option.
  343. */
  344. //edited: don't show options page->
  345. //add_action('admin_menu', 'simplepie_options');
  346.  
  347. /**
  348. * Draw normal options page.
  349. */
  350. function simplepie_options_page()
  351. {
  352. if (isset($_POST['reset_all_settings']) && !empty($_POST['reset_all_settings']))
  353. {
  354. // Display the reset message.
  355. echo '<div id="message" class="updated fade"><p><strong>All of your options for this plugin have been reset to their default values.</strong></p></div>';
  356. }
  357. else if (isset($_POST['submitted']) && !empty($_POST['submitted']))
  358. {
  359. /**
  360. * Get form data
  361. */
  362.  
  363. // General settings
  364. $simplepie_template = (string) $_POST['simplepie_template'];
  365. $simplepie_items = (integer) $_POST['simplepie_items'];
  366. $simplepie_items_per_feed = (integer) $_POST['simplepie_items_per_feed'];
  367. $simplepie_date_format = (string) $_POST['simplepie_date_format'];
  368. $simplepie_enable_cache = (bool) $_POST['simplepie_enable_cache'];
  369. $simplepie_set_cache_location = (string) $_POST['simplepie_set_cache_location'];
  370. $simplepie_set_cache_duration = (integer) $_POST['simplepie_set_cache_duration'];
  371. $simplepie_enable_order_by_date = (bool) $_POST['simplepie_enable_order_by_date'];
  372. $simplepie_set_timeout = (integer) $_POST['simplepie_set_timeout'];
  373.  
  374. // Text-shortening settings
  375. $simplepie_truncate_feed_title = (integer) $_POST['simplepie_truncate_feed_title'];
  376. $simplepie_truncate_feed_description = (integer) $_POST['simplepie_truncate_feed_description'];
  377. $simplepie_truncate_item_title = (integer) $_POST['simplepie_truncate_item_title'];
  378. $simplepie_truncate_item_description = (integer) $_POST['simplepie_truncate_item_description'];
  379.  
  380. // Advanced settings
  381. $simplepie_processing = (string) $_POST['simplepie_processing'];
  382. $simplepie_locale = (string) $_POST['simplepie_locale'];
  383. $simplepie_local_date_format = (string) $_POST['simplepie_local_date_format'];
  384. $simplepie_strip_htmltags = (string) $_POST['simplepie_strip_htmltags'];
  385. $simplepie_strip_attributes = (string) $_POST['simplepie_strip_attributes'];
  386. $simplepie_set_max_checked_feeds = (integer) $_POST['simplepie_set_max_checked_feeds'];
  387.  
  388. /**
  389. * Update plugin options
  390. */
  391.  
  392. // General settings
  393. update_option("simplepie_template", $simplepie_template);
  394. update_option("simplepie_items", $simplepie_items);
  395. update_option("simplepie_items_per_feed", $simplepie_items_per_feed);
  396. update_option("simplepie_date_format", $simplepie_date_format);
  397. update_option("simplepie_enable_cache", $simplepie_enable_cache);
  398. update_option("simplepie_set_cache_location", $simplepie_set_cache_location);
  399. update_option("simplepie_set_cache_duration", $simplepie_set_cache_duration);
  400. update_option("simplepie_enable_order_by_date", $simplepie_enable_order_by_date);
  401. update_option("simplepie_set_timeout", $simplepie_set_timeout);
  402.  
  403. // Text-shortening settings
  404. update_option("simplepie_truncate_feed_title", $simplepie_truncate_feed_title);
  405. update_option("simplepie_truncate_feed_description", $simplepie_truncate_feed_description);
  406. update_option("simplepie_truncate_item_title", $simplepie_truncate_item_title);
  407. update_option("simplepie_truncate_item_description", $simplepie_truncate_item_description);
  408.  
  409. // Advanced settings
  410. update_option("simplepie_processing", $simplepie_processing);
  411. update_option("simplepie_locale", $simplepie_locale);
  412. update_option("simplepie_local_date_format", $simplepie_local_date_format);
  413. update_option("simplepie_strip_htmltags", $simplepie_strip_htmltags);
  414. update_option("simplepie_strip_attributes", $simplepie_strip_attributes);
  415. update_option("simplepie_set_max_checked_feeds", $simplepie_set_max_checked_feeds);
  416.  
  417. // Display the updated message.
  418. echo '<div id="message" class="updated fade"><p><strong>Your options were saved successfully!</strong></p></div>';
  419. }
  420.  
  421. if (get_option('simplepie_locale') && get_option('simplepie_locale') != 'auto')
  422. {
  423. setlocale(LC_TIME, get_option('simplepie_locale'));
  424. }
  425. ?>
  426. <style type="text/css">
  427. .submit input.warning {
  428. background-color:#c00;
  429. background-image:none;
  430. border-color:#f00 #900 #900 #f00;
  431. color:#fff;
  432. }
  433.  
  434. .submit {
  435. text-align:right;
  436. background-color:#e9f5ff;
  437. margin:0;
  438. padding:15px;
  439. }
  440.  
  441. .submit input {
  442. font-size:115%;
  443. padding:5px 10px;
  444. border:1px solid #999;
  445. }
  446.  
  447. .warning {
  448. background-color:#c00;
  449. color:#fff;
  450. padding:1px 2px;
  451. }
  452.  
  453. div.wrap h3 {
  454. font-size:20px;
  455. padding-top:10px;
  456. border-bottom:1px solid #000;
  457. }
  458.  
  459. code {
  460. color:#000080;
  461. background-color:#eef;
  462. font-size:0.95em;
  463. }
  464.  
  465. input.text {
  466. background-color:#e9f5ff;
  467. color:#333;
  468. border:1px solid #ccc;
  469. }
  470.  
  471. input.text:focus {
  472. background-color:#ffc;
  473. color:#000;
  474. border:1px solid #f90;
  475. }
  476.  
  477. input#simplepie_set_cache_location {
  478. width:90%;
  479. }
  480.  
  481. td.break,
  482. td.break-noborder {
  483. padding:15px 0;
  484. }
  485.  
  486. td.break {
  487. border-bottom:1px solid #999;
  488. }
  489.  
  490. .footnote,
  491. .footnote a {
  492. font-size:12px;
  493. line-height:1.3em;
  494. color:#aaa;
  495. }
  496.  
  497. .footnote em {
  498. background-color:transparent;
  499. font-style:italic;
  500. }
  501.  
  502. .footnote code {
  503. background-color:transparent;
  504. font:11px/14px monospace;
  505. color:#fff;
  506. background-color:#ccc;
  507. padding:0 1px;
  508. }
  509. </style>
  510.  
  511. <form method="post" action="" name="simplepie" onsubmit="document.forms['simplepie'].simplepie_set_cache_duration.value = parseFloat(document.forms['simplepie'].simplepie_set_cache_duration.value) * parseInt(document.forms['simplepie'].simplepie_cache_duration_units[document.forms['simplepie'].simplepie_cache_duration_units.selectedIndex].value);document.forms['simplepie'].simplepie_cache_duration_units.selectedIndex=0;">
  512. <?php wp_nonce_field('update-options') ?>
  513.  
  514. <div class="wrap">
  515. <h2>SimplePie Plugin for WordPress</h2>
  516.  
  517. <h3>Installation Status</h3>
  518. <p>This information will help with debugging in case something goes wrong.</p>
  519.  
  520. <fieldset class="options">
  521. <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
  522. <tr>
  523. <th width="33%" scope="row" valign="top">Version of WordPress:</th>
  524. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/ok.png" /> <?php echo WP_VERSION; ?></td>
  525. </tr>
  526.  
  527. <tr>
  528. <th width="33%" scope="row" valign="top">Version of <a href="http://wordpress.org/extend/plugins/simplepie-plugin-for-wordpress/">SimplePie Plugin for WordPress</a>:</th>
  529. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/ok.png" /> <?php echo SIMPLEPIE_PLUGIN; ?></td>
  530. </tr>
  531.  
  532. <tr>
  533. <th width="33%" scope="row" valign="top">Version of <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core</a>:</th>
  534. <?php if ($e = version_compare(SimplePie_WordPress::convert_to_version(SIMPLEPIE_BUILD), SimplePie_WordPress::convert_to_version(EXPECTED_SIMPLEPIE_BUILD)) > -1): ?>
  535. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/ok.png" /> <?php echo SIMPLEPIE_VERSION; ?> (<a href="options-general.php?page=simplepie_core">Details</a>)</td>
  536. <?php elseif (!defined('SIMPLEPIE_BUILD')): ?>
  537. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/error.png" /> <span class="warning">None</span> &mdash; Please download and install <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core</a>.<p class="footnote">This plugin requires <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core</a> (version <?php echo EXPECTED_SIMPLEPIE_VERSION; ?>) to be installed. Check out the <a href="http://codex.wordpress.org/Managing_Plugins#Installing_Plugins">"Installing Plugins"</a> documentation at the WordPress site for help.</p></td>
  538. <?php else: ?>
  539. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/error.png" /> <span class="warning"><?php echo SIMPLEPIE_VERSION; ?></span> &mdash; This version is out-of-date. Please update <a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core</a> to the latest version.<p class="footnote"><a href="http://wordpress.org/extend/plugins/simplepie-core/">SimplePie Core</a> (version <?php echo EXPECTED_SIMPLEPIE_VERSION; ?> or newer) is required. If you already have the latest version, you might have a situation where another plugin has bundled SimplePie and that plugin has loaded before SimplePie Core, causing strange things to happen. If so, try either disabling the other plugin or checking for an updated version that has been updated to utilize SimplePie Core for best compatibility.</p></td>
  540. <?php endif; ?>
  541. </tr>
  542.  
  543. <tr>
  544. <th width="33%" scope="row" valign="top">Plugin install location:</th>
  545. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/ok.png" /> <code><?php echo SimplePie_WordPress::clean_wp_path(SIMPLEPIE_PLUGINDIR); ?>/</code>.</td>
  546. </tr>
  547.  
  548. <tr>
  549. <th width="33%" scope="row" valign="top">Cache directory writable?:</th>
  550. <?php if (!get_option('simplepie_enable_cache')): ?>
  551. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/error.png" /> <span class="warning">Cache disabled!</span>
  552. <p class="footnote">You have chosen to disable caching. Be aware that this will negatively impact performance.</p></td>
  553. <?php elseif (!is_dir(get_option('simplepie_set_cache_location'))): ?>
  554. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/error.png" /> <span class="warning">Cache directory does not exist!</span>
  555. <p class="footnote">Please either create a <a href="http://simplepie.org/wiki/faq/file_permissions">writable</a> cache directory at <code><?php echo get_option('simplepie_set_cache_location'); ?></code>, or change the preferred location below.</p></td>
  556. <?php elseif (!is_writable(get_option('simplepie_set_cache_location'))): ?>
  557. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/error.png" /> <span class="warning">Cache directory not writable!</span>
  558. <p class="footnote">Please make sure that the cache directory at <code><?php echo get_option('simplepie_set_cache_location'); ?></code> is <a href="http://simplepie.org/wiki/faq/file_permissions">writable by the server</a>, or change the preferred location below.</p></td>
  559. <?php else: ?>
  560. <td valign="top"><img src="<?php echo SIMPLEPIE_PLUGINDIR_WEB; ?>/images/ok.png" /> <code><?php echo SimplePie_WordPress::clean_wp_path(get_option('simplepie_set_cache_location')); ?></code> exists and is writable.</td>
  561. <?php endif; ?>
  562. </tr>
  563.  
  564. </table>
  565. </fieldset>
  566.  
  567. <h3>General Settings</h3>
  568. <p>Most people should feel comfortable tweaking and modifying these settings. These settings are the defaults for SimplePie, but you can override any individual feed instance on the fly by passing additional parameters to it. See the <a href="http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress">documentation</a> to learn how to do this.</p>
  569.  
  570. <fieldset class="options">
  571. <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
  572. <tr>
  573. <th width="33%" scope="row" valign="top"><h4>Layout template:</h4></th>
  574. <td class="break"><select name="simplepie_template">
  575. <?php
  576. $templates = SimplePie_WordPress::get_files(SIMPLEPIE_PLUGINDIR . '/templates/', '.tmpl');
  577. sort($templates);
  578.  
  579. foreach($templates as $template)
  580. {
  581. echo '<option value="' . $template['location'] . '">' . $template['label'] . '</option>' . "\n";
  582. }
  583. ?>
  584. </select>
  585. <p class="footnote">Add or edit templates in the following directory:<br /><code><?php echo SimplePie_WordPress::clean_wp_path(SIMPLEPIE_PLUGINDIR); ?>/templates/</code></p></td>
  586. </tr>
  587.  
  588. <tr>
  589. <th width="33%" scope="row" valign="top"><h4>Number of items to display:</h4></th>
  590. <td class="break"><input type="text" class="text" name="simplepie_items" value="<?php echo get_option('simplepie_items'); ?>" size="3" maxlength="3" /> items
  591. <p class="footnote">By default, how many feed items (i.e. posts) to display. Use <code>0</code> for ALL.</p></td>
  592. </tr>
  593.  
  594. <tr>
  595. <th width="33%" scope="row" valign="top"><h4>Number of items to display per feed:</h4></th>
  596. <td class="break"><input type="text" class="text" name="simplepie_items_per_feed" value="<?php echo get_option('simplepie_items_per_feed'); ?>" size="3" maxlength="3" /> items
  597. <p class="footnote">Limit the number of items (i.e. posts) to use per-feed when merging multiple feeds. Use <code>0</code> for ALL.</p></td>
  598. </tr>
  599.  
  600. <tr>
  601. <th width="33%" scope="row" valign="top"><h4>Default format for English dates:</h4></th>
  602. <td class="break"><input type="text" class="text" name="simplepie_date_format" value="<?php echo get_option('simplepie_date_format'); ?>" /> (i.e. <?php echo date(get_option('simplepie_date_format')); ?>)
  603. <p class="footnote">Supports any format supported by PHP's <a href="http://php.net/date">date()</a> function. Only used with <code>{ITEM_DATE}</code> and <code>{ITEM_DATE_UTC}</code>.</p></td>
  604. </tr>
  605.  
  606. <tr>
  607. <th width="33%" scope="row" valign="top"><h4>Should we use caching:</h4></th>
  608. <td class="break"><select name="simplepie_enable_cache" onchange="simplepie_color_temp=document.body.style.color;if(document.forms['simplepie'].simplepie_enable_cache.value=='false'){document.forms['simplepie'].simplepie_set_cache_duration.disabled=true;document.forms['simplepie'].simplepie_cache_duration_units.disabled=true;document.getElementById('set_cache_duration_title').style.color='#cccccc';}else{document.forms['simplepie'].simplepie_set_cache_duration.disabled=false;document.forms['simplepie'].simplepie_cache_duration_units.disabled=false;document.getElementById('set_cache_duration_title').style.color=simplepie_color_temp;}">
  609. <option value="1">Yes (Recommended)</option>
  610. <option value="0">No</option>
  611. </select>
  612. <p class="footnote">Disabling cache will negatively impact performance (and anger feed creators), but will ensure that the very freshest version of the feed is displayed at all times.</p></td>
  613. </tr>
  614.  
  615. <tr>
  616. <th width="33%" scope="row" valign="top"><h4>Cache storage location:</h4></th>
  617. <td class="break"><input type="text" class="text" name="simplepie_set_cache_location" id="simplepie_set_cache_location" value="<?php echo get_option('simplepie_set_cache_location'); ?>" />
  618. <p class="footnote">This should be a complete, writable file system location. Default value is auto-detected, but is not always correct for all WordPress installations. Adjust only if cache isn't working.</p></td>
  619. </tr>
  620.  
  621. <tr>
  622. <th width="33%" scope="row" id="set_cache_duration_title" valign="top"><h4>How long should we cache for?:</h4></th>
  623. <td class="break"><input type="text" class="text" name="simplepie_set_cache_duration" value="<?php echo get_option('simplepie_set_cache_duration'); ?>" size="10" />
  624. <select name="simplepie_cache_duration_units">
  625. <option value="1">Seconds</option>
  626. <option value="60">Minutes</option>
  627. <option value="3600">Hours</option>
  628. <option value="87840">Days</option>
  629. </select>
  630. <p class="footnote">How long before we ask the feed if it's been updated? Recommend 1 hour (3600 seconds).</p></td>
  631. </tr>
  632.  
  633. <tr>
  634. <th width="33%" scope="row" valign="top"><h4>Re-order items by date:</h4></th>
  635. <td class="break"><select name="simplepie_enable_order_by_date">
  636. <option value="1">Yes (Recommended)</option>
  637. <option value="0">No</option>
  638. </select>
  639. <p class="footnote">Some feeds have items that are not chronologically ordered. This fixes that.</p></td>
  640. </tr>
  641.  
  642. <tr>
  643. <th width="33%" scope="row" valign="top"><h4>Seconds to wait while fetching data:</h4></th>
  644. <td class="break-noborder"><input type="text" class="text" name="simplepie_set_timeout" value="<?php echo get_option('simplepie_set_timeout'); ?>" size="3" maxlength="3" /> seconds
  645. <p class="footnote">Some feeds are on slow servers, so increasing this time allows more time to fetch the feed.</p></td>
  646. </tr>
  647.  
  648. </table>
  649. <p class="submit"><input type="submit" name="submitted" value="Update Options" /></p>
  650. </fieldset>
  651.  
  652. <h3>Text-Shortening Settings</h3>
  653. <p>Most people should feel comfortable tweaking and modifying these settings. These settings allow you to set default lengths for truncated text, but you can override any individual feed instance on the fly by passing additional parameters to it. See the <a href="http://simplepie.org/wiki/plugins/wordpress/simplepie_plugin_for_wordpress">documentation</a> to learn how to do this.</p>
  654. <p>These settings only apply to the <code>TRUNCATE_*</code> template tags: <code>{TRUNCATE_FEED_DESCRIPTION}</code>, <code>{TRUNCATE_ITEM_PARENT_DESCRIPTION}</code>, <code>{TRUNCATE_FEED_TITLE}</code>, <code>{TRUNCATE_ITEM_PARENT_TITLE}</code>, <code>{TRUNCATE_ITEM_DESCRIPTION}</code>, and <code>{TRUNCATE_ITEM_TITLE}</code>.</p>
  655.  
  656. <fieldset class="options">
  657. <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
  658. <tr valign="top">
  659. <th width="33%" scope="row" valign="top"><h4>Length for shortened feed titles:</h4></th>
  660. <td class="break"><input type="text" class="text" name="simplepie_truncate_feed_title" value="<?php echo get_option('simplepie_truncate_feed_title'); ?>" size="5" maxlength="5" /> characters
  661. <p class="footnote">Strips HTML, linebreaks, and converts entities first. Set <code>0</code> to clean (but not shorten) the text.</p></td>
  662. </tr>
  663.  
  664. <tr valign="top">
  665. <th width="33%" scope="row" valign="top"><h4>Length for shortened feed descriptions:</h4></th>
  666. <td class="break"><input type="text" class="text" name="simplepie_truncate_feed_description" value="<?php echo get_option('simplepie_truncate_feed_description'); ?>" size="5" maxlength="5" /> characters
  667. <p class="footnote">Strips HTML, linebreaks, and converts entities first. Set <code>0</code> to clean (but not shorten) the text.</p></td>
  668. </tr>
  669.  
  670. <tr valign="top">
  671. <th width="33%" scope="row" valign="top"><h4>Length for shortened item titles:</h4></th>
  672. <td class="break"><input type="text" class="text" name="simplepie_truncate_item_title" value="<?php echo get_option('simplepie_truncate_item_title'); ?>" size="5" maxlength="5" /> characters
  673. <p class="footnote">Strips HTML, linebreaks, and converts entities first. Set <code>0</code> to clean (but not shorten) the text.</p></td>
  674. </tr>
  675.  
  676. <tr valign="top">
  677. <th width="33%" scope="row" valign="top"><h4>Length for shortened item descriptions:</h4></th>
  678. <td class="break-noborder"><input type="text" class="text" name="simplepie_truncate_item_description" value="<?php echo get_option('simplepie_truncate_item_description'); ?>" size="5" maxlength="5" /> characters
  679. <p class="footnote">Strips HTML, linebreaks, and converts entities first. Set <code>0</code> to clean (but not shorten) the text.</p></td>
  680. </tr>
  681.  
  682. </table>
  683. <p class="submit"><input type="submit" name="submitted" value="Update Options" /></p>
  684. </fieldset>
  685.  
  686. <h3>Advanced Settings</h3>
  687. <p>These settings should only be modified if you know what you're doing.</p>
  688.  
  689. <fieldset class="options">
  690. <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
  691. <tr valign="top">
  692. <th width="33%" scope="row" valign="top"><h4>Content Post-Processing Rules:</h4></th>
  693. <td class="break"><select name="simplepie_processing">
  694. <?php
  695. $processes = SimplePie_WordPress::get_files(SIMPLEPIE_PLUGINDIR . '/processing/', '.php');
  696. sort($processes);
  697.  
  698. foreach($processes as $process)
  699. {
  700. echo '<option value="' . $process['location'] . '">' . $process['label'] . '</option>' . "\n";
  701. }
  702. ?>
  703. </select>
  704. <p class="footnote">Add or edit processing rules in the following directory:<br /><code><?php echo SimplePie_WordPress::clean_wp_path(SIMPLEPIE_PLUGINDIR); ?>/processing/</code>.</p></td>
  705. </tr>
  706.  
  707. <tr valign="top">
  708. <th width="33%" scope="row" valign="top"><h4>Locale for the website:</h4></th>
  709. <td class="break"><input type="text" class="text" name="simplepie_locale" value="<?php echo get_option('simplepie_locale'); ?>" />
  710. <p class="footnote">Switch the locale for the website to use. There are a variety of formats that can be used, depending on your server setup. See PHP's <a href="http://php.net/setlocale">setlocale()</a> function. Use <code>auto</code> to use the server's default.</p></td>
  711. </tr>
  712.  
  713. <tr valign="top">
  714. <th width="33%" scope="row" valign="top"><h4>Default format for localized dates:</h4></th>
  715. <td class="break"><input type="text" class="text" name="simplepie_local_date_format" value="<?php echo get_option('simplepie_local_date_format'); ?>" /> (i.e. <?php echo strftime(get_option('simplepie_local_date_format')); ?>)
  716. <p class="footnote">Supports any format supported by PHP's <a href="http://php.net/strftime">strftime()</a> function. Only used with <code>{ITEM_LOCAL_DATE}</code> and <code>{ITEM_LOCAL_DATE_UTC}</code>.</p></td>
  717. </tr>
  718.  
  719. <tr valign="top">
  720. <th width="33%" scope="row" valign="top"><h4>HTML tags to strip out of feeds:</h4></th>
  721. <td class="break"><input type="text" class="text" name="simplepie_strip_htmltags" value="<?php echo get_option('simplepie_strip_htmltags'); ?>" size="50" /> (space separated)
  722. <p class="footnote">These tags will be stripped from the output. By default, removes potentially dangerous tags as well as some deprecated ones.</p></td>
  723. </tr>
  724.  
  725. <tr valign="top">
  726. <th width="33%" scope="row" valign="top"><h4>HTML attributes to strip out of feeds:</h4></th>
  727. <td class="break"><input type="text" class="text" name="simplepie_strip_attributes" value="<?php echo get_option('simplepie_strip_attributes'); ?>" size="50" /> (space separated)
  728. <p class="footnote">These attributes will be stripped from the output. By default, removes potentially dangerous attributes as well as some deprecated ones.</p></td>
  729. </tr>
  730.  
  731. <tr valign="top">
  732. <th width="33%" scope="row" valign="top"><h4>Number of links to check during auto-discovery:</h4></th>
  733. <td class="break-noborder"><input type="text" class="text" name="simplepie_set_max_checked_feeds" value="<?php echo get_option('simplepie_set_max_checked_feeds'); ?>" size="3" maxlength="3" /> links
  734. <p class="footnote">SimplePie's ultra-liberal feed locator satisfies points 1&ndash;6 of Mark Pilgrim's <a href="http://diveintomark.org/archives/2002/08/15/ultraliberal_rss_locator">feed usability rant</a>. This tells how many links to check.</p></td>
  735. </tr>
  736.  
  737. </table>
  738. <p class="submit"><input type="submit" name="submitted" value="Update Options" /></p>
  739. </fieldset>
  740. </div>
  741. </form>
  742.  
  743. <br /><br /><br /><br /><br />
  744.  
  745. <form method="post" action="" name="simplepie">
  746. <?php wp_nonce_field('update-options') ?>
  747. <div class="wrap">
  748. <h2>Reset ALL Settings</h2>
  749. <p>Wipe out ALL custom settings (except for changes or additions to templates and post-processing files), and reset everything back to their default values.</p>
  750. <fieldset class="options">
  751. <input type="hidden" name="reset_all_settings" value="true" />
  752. <p class="submit"><input type="submit" name="submitted" class="warning" value="Reset ALL settings for this plugin to their default values!" /></p>
  753. </fieldset>
  754. </div>
  755. </form>
  756.  
  757.  
  758. <script type="text/javascript" charset="utf-8">
  759. // Set the correct value for simplepie_template
  760. for (var x = 0; x < document.forms['simplepie'].simplepie_template.length; x++) {
  761. if (document.forms['simplepie'].simplepie_template[x].value == "<?php echo get_option('simplepie_template'); ?>") {
  762. document.forms['simplepie'].simplepie_template.selectedIndex = x;
  763. break;
  764. }
  765. }
  766.  
  767. // Set the correct value for simplepie_enable_cache
  768. for (var x = 0; x < document.forms['simplepie'].simplepie_enable_cache.length; x++) {
  769. if (document.forms['simplepie'].simplepie_enable_cache[x].value == "<?php echo get_option('simplepie_enable_cache'); ?>") {
  770. document.forms['simplepie'].simplepie_enable_cache.selectedIndex = x;
  771. break;
  772. }
  773. }
  774.  
  775. // Set the correct value for simplepie_enable_order_by_date
  776. for (var x = 0; x < document.forms['simplepie'].simplepie_enable_order_by_date.length; x++) {
  777. if (document.forms['simplepie'].simplepie_enable_order_by_date[x].value == "<?php echo get_option('simplepie_enable_order_by_date'); ?>") {
  778. document.forms['simplepie'].simplepie_enable_order_by_date.selectedIndex = x;
  779. break;
  780. }
  781. }
  782.  
  783. // Set the correct value for simplepie_processing
  784. for (var x = 0; x < document.forms['simplepie'].simplepie_processing.length; x++) {
  785. if (document.forms['simplepie'].simplepie_processing[x].value == "<?php echo get_option('simplepie_processing'); ?>") {
  786. document.forms['simplepie'].simplepie_processing.selectedIndex = x;
  787. break;
  788. }
  789. }
  790.  
  791. </script>
  792.  
  793. <?php
  794. }
  795.  
  796. /**
  797. * Function that truncates text.
  798. */
  799. function SimplePie_Truncate($s, $length = 0)
  800. {
  801. // Strip out HTML tags.
  802. $s = strip_tags($s);
  803.  
  804. // Strip out superfluous whitespace and line breaks.
  805. //edited: prevent funny char in title tooltip->$s = preg_replace('/(\s+)/', ' ', $s);
  806.  
  807. // Avoid PHP 4.x bug. Only do this if we're on PHP5. http://bugs.php.net/25670
  808. if (SIMPLEPIE_PHP5)
  809. {
  810. // Convert all HTML entities to their character counterparts.
  811. $s = html_entity_decode($s, ENT_QUOTES, 'UTF-8');
  812. }
  813.  
  814. // Shorten the string to the number of characters requested, and strip wrapping whitespace.
  815. if ($length > 0 && strlen($s) > $length)
  816. {
  817. $s = trim(substr($s, 0, $length)) . '&hellip;'; //edited: valid xhtml-> $s = trim(substr($s, 0, $length)) . '. [&hellip;]';
  818. }
  819.  
  820. // Return the value.
  821. return $s;
  822. }
  823.  
  824. /**
  825. * Take the namespaced function and make it global so that it can be called by usort().
  826. */
  827. function sort_items($a, $b)
  828. {
  829. return SimplePie::sort_items($a, $b);
  830. }
  831.  
  832. /**
  833. * The actual function that can be called on webpages.
  834. */
  835. function SimplePieWP($feed_url, $options = null)
  836. {
  837. // Quit if the SimplePie class isn't loaded.
  838. if (!class_exists('SimplePie'))
  839. {
  840. die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> There is a problem with the SimplePie Plugin for WordPress. Check your <a href="' . WP_CPANEL . '" style="color:#ff0; text-decoration:underline;">Installation Status</a> for more information.</p>');
  841. }
  842.  
  843. if (isset($locale) && !empty($locale) && $locale != 'auto')
  844. {
  845. setlocale(LC_TIME, $locale);
  846. }
  847.  
  848. // Default general settings
  849. $template = get_option('simplepie_template');
  850. $items = get_option('simplepie_items');
  851. $items_per_feed = get_option('simplepie_items_per_feed');
  852. $date_format = get_option('simplepie_date_format');
  853. $enable_cache = get_option('simplepie_enable_cache');
  854. $set_cache_location = get_option('simplepie_set_cache_location');
  855. $set_cache_duration = get_option('simplepie_set_cache_duration');
  856. $enable_order_by_date = get_option('simplepie_enable_order_by_date');
  857. $set_timeout = get_option('simplepie_set_timeout');
  858.  
  859. // Default text-shortening settings
  860. $truncate_feed_title = get_option('simplepie_truncate_feed_title');
  861. $truncate_feed_description = get_option('simplepie_truncate_feed_description');
  862. $truncate_item_title = get_option('simplepie_truncate_item_title');
  863. $truncate_item_description = get_option('simplepie_truncate_item_description');
  864.  
  865. // Default advanced settings
  866. $processing = get_option('simplepie_processing');
  867. $locale = get_option('simplepie_locale');
  868. $local_date_format = get_option('simplepie_local_date_format');
  869. $strip_htmltags = get_option('simplepie_strip_htmltags');
  870. $strip_attributes = get_option('simplepie_strip_attributes');
  871. $set_max_checked_feeds = get_option('simplepie_set_max_checked_feeds');
  872.  
  873. // Overridden settings
  874. if ($options)
  875. {
  876. // Fix the template location if one was passed in.
  877. if (isset($options['template']) && !empty($options['template']))
  878. {
  879. $options['template'] = SIMPLEPIE_PLUGINDIR . '/templates/' . strtolower(str_replace(' ', '_', $options['template'])) . '.tmpl';
  880. }
  881.  
  882. // Fix the processing location if one was passed in.
  883. if (isset($options['processing']) && !empty($options['processing']))
  884. {
  885. $options['processing'] = SIMPLEPIE_PLUGINDIR . '/processing/' . strtolower(str_replace(' ', '_', $options['processing'])) . '.php';
  886. }
  887.  
  888. extract($options);
  889. }
  890.  
  891. // Load post-processing file.
  892. //if ($processing && $processing != '')
  893. //{
  894. // include_once($processing);
  895. //}
  896.  
  897. // If template doesn't exist, die.
  898. if (!file_exists($template) || !is_readable($template))
  899. {
  900. delete_option('simplepie_set_cache_location');
  901. delete_option('simplepie_processing');
  902. delete_option('simplepie_template');
  903. die('<p style="font-size:16px; line-height:1.5em; background-color:#c00; color:#fff; padding:10px; border:3px solid #f00; text-align:left;"><img src="' . SIMPLEPIE_PLUGINDIR_WEB . '/images/error.png" /> The SimplePie template file is not readable by WordPress. Attempting to fix issue. Please reload page again.</p>');
  904. }
  905.  
  906. // Initialize SimplePie
  907. $feed = new SimplePie();
  908. $feed->set_feed_url($feed_url);
  909. $feed->enable_cache($enable_cache);
  910. $feed->set_item_limit($items_per_feed);
  911. $feed->set_cache_location($set_cache_location);
  912. $feed->set_cache_duration($set_cache_duration);
  913. $feed->enable_order_by_date($enable_order_by_date);
  914. $feed->set_timeout($set_timeout);
  915. $feed->strip_htmltags(explode(' ', $strip_htmltags));
  916. $feed->strip_attributes(explode(' ', $strip_attributes));
  917. $feed->set_max_checked_feeds($set_max_checked_feeds);
  918. $feed->init();
  919.  
  920. // Load up the selected template file
  921. $handle = fopen($template, 'r');
  922. $tmpl = fread($handle, filesize($template));
  923. fclose($handle);
  924.  
  925. /**************************************************************************************************************/
  926. // ERRORS
  927. // I'm absolutely sure that there is a better way to do this.
  928.  
  929. // Define what we're looking for
  930. $error_start_tag = '{IF_ERROR_BEGIN}';
  931. $error_end_tag = '{IF_ERROR_END}';
  932. $error_start_length = strlen($error_start_tag);
  933. $error_end_length = strlen($error_end_tag);
  934.  
  935. // Find what we're looking for
  936. $error_start_pos = strpos($tmpl, $error_start_tag);
  937. $error_end_pos = strpos($tmpl, $error_end_tag);
  938. $error_length_pos = $error_end_pos - $error_start_pos;
  939.  
  940. // Grab what we're looking for
  941. $error_string = substr($tmpl, $error_start_pos + $error_start_length, $error_length_pos - $error_start_length);
  942. $replacable_string = $error_start_tag . $error_string . $error_end_tag;
  943.  
  944. if ($error_message = $feed->error())
  945. {
  946. $tmpl = str_replace($replacable_string, $error_string, $tmpl);
  947. $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', $error_message), $tmpl);
  948. }
  949. elseif ($feed->get_item_quantity() == 0)
  950. {
  951. $tmpl = str_replace($replacable_string, $error_string, $tmpl);
  952. $tmpl = str_replace('{ERROR_MESSAGE}', SimplePie_WordPress::post_process('ERROR_MESSAGE', 'There are no items in this feed.'), $tmpl);
  953. }
  954. else
  955. {
  956. $tmpl = str_replace($replacable_string, '', $tmpl);
  957. }
  958.  
  959. /**************************************************************************************************************/
  960. // FEED
  961.  
  962. // FEED_AUTHOR_EMAIL
  963. /* if ($author = $feed->get_author())
  964. {
  965. if ($email = $author->get_email())
  966. {
  967. $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('FEED_AUTHOR_EMAIL', $email), $tmpl);
  968. }
  969. else
  970. {
  971. $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl);
  972. }
  973. }
  974. else
  975. {
  976. $tmpl = str_replace('{FEED_AUTHOR_EMAIL}', '', $tmpl);
  977. }
  978.  
  979. // FEED_AUTHOR_LINK
  980. if ($author = $feed->get_author())
  981. {
  982. if ($link = $author->get_link())
  983. {
  984. $tmpl = str_replace('{FEED_AUTHOR_LINK}', SimplePie_WordPress::post_process('FEED_AUTHOR_LINK', $link), $tmpl);
  985. }
  986. else
  987. {
  988. $tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl);
  989. }
  990. }
  991. else
  992. {
  993. $tmpl = str_replace('{FEED_AUTHOR_LINK}', '', $tmpl);
  994. }
  995.  
  996. // FEED_AUTHOR_NAME
  997. if ($author = $feed->get_author())
  998. {
  999. if ($name = $author->get_name())
  1000. {
  1001. $tmpl = str_replace('{FEED_AUTHOR_NAME}', SimplePie_WordPress::post_process('FEED_AUTHOR_NAME', $name), $tmpl);
  1002. }
  1003. else
  1004. {
  1005. $tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl);
  1006. }
  1007. }
  1008. else
  1009. {
  1010. $tmpl = str_replace('{FEED_AUTHOR_NAME}', '', $tmpl);
  1011. }
  1012.  
  1013. // FEED_CONTRIBUTOR_EMAIL
  1014. if ($contributor = $feed->get_contributor())
  1015. {
  1016. if ($email = $contributor->get_email())
  1017. {
  1018. $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_EMAIL', $email), $tmpl);
  1019. }
  1020. else
  1021. {
  1022. $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl);
  1023. }
  1024. }
  1025. else
  1026. {
  1027. $tmpl = str_replace('{FEED_CONTRIBUTOR_EMAIL}', '', $tmpl);
  1028. }
  1029.  
  1030. // FEED_CONTRIBUTOR_LINK
  1031. if ($contributor = $feed->get_contributor())
  1032. {
  1033. if ($link = $contributor->get_link())
  1034. {
  1035. $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_LINK', $link), $tmpl);
  1036. }
  1037. else
  1038. {
  1039. $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl);
  1040. }
  1041. }
  1042. else
  1043. {
  1044. $tmpl = str_replace('{FEED_CONTRIBUTOR_LINK}', '', $tmpl);
  1045. }
  1046.  
  1047. // FEED_CONTRIBUTOR_NAME
  1048. if ($contributor = $feed->get_contributor())
  1049. {
  1050. if ($name = $contributor->get_name())
  1051. {
  1052. $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('FEED_CONTRIBUTOR_NAME', $name), $tmpl);
  1053. }
  1054. else
  1055. {
  1056. $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl);
  1057. }
  1058. }
  1059. else
  1060. {
  1061. $tmpl = str_replace('{FEED_CONTRIBUTOR_NAME}', '', $tmpl);
  1062. }
  1063.  
  1064. // FEED_COPYRIGHT
  1065. if ($copyright = $feed->get_copyright())
  1066. {
  1067. $tmpl = str_replace('{FEED_COPYRIGHT}', SimplePie_WordPress::post_process('FEED_COPYRIGHT', $copyright), $tmpl);
  1068. }
  1069. else
  1070. {
  1071. $tmpl = str_replace('{FEED_COPYRIGHT}', '', $tmpl);
  1072. }
  1073.  
  1074. // FEED_DESCRIPTION
  1075. if ($description = $feed->get_description())
  1076. {
  1077. $tmpl = str_replace('{FEED_DESCRIPTION}', SimplePie_WordPress::post_process('FEED_DESCRIPTION', $description), $tmpl);
  1078. }
  1079. else
  1080. {
  1081. $tmpl = str_replace('{FEED_DESCRIPTION}', '', $tmpl);
  1082. }
  1083.  
  1084. // FEED_ENCODING
  1085. if ($encoding = $feed->get_encoding())
  1086. {
  1087. $tmpl = str_replace('{FEED_ENCODING}', SimplePie_WordPress::post_process('FEED_ENCODING', $encoding), $tmpl);
  1088. }
  1089. else
  1090. {
  1091. $tmpl = str_replace('{FEED_ENCODING}', '', $tmpl);
  1092. }
  1093.  
  1094. // FEED_FAVICON
  1095. if ($favicon = $feed->get_favicon())
  1096. {
  1097. $tmpl = str_replace('{FEED_FAVICON}', SimplePie_WordPress::post_process('FEED_FAVICON', $favicon), $tmpl);
  1098. }
  1099. else
  1100. {
  1101. $tmpl = str_replace('{FEED_FAVICON}', '', $tmpl);
  1102. }
  1103.  
  1104. // FEED_IMAGE_HEIGHT
  1105. if ($image_height = $feed->get_image_height())
  1106. {
  1107. $tmpl = str_replace('{FEED_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('FEED_IMAGE_HEIGHT', $image_height), $tmpl);
  1108. }
  1109. else
  1110. {
  1111. $tmpl = str_replace('{FEED_IMAGE_HEIGHT}', '', $tmpl);
  1112. }
  1113.  
  1114. // FEED_IMAGE_LINK
  1115. if ($image_link = $feed->get_image_link())
  1116. {
  1117. $tmpl = str_replace('{FEED_IMAGE_LINK}', SimplePie_WordPress::post_process('FEED_IMAGE_LINK', $image_link), $tmpl);
  1118. }
  1119. else
  1120. {
  1121. $tmpl = str_replace('{FEED_IMAGE_LINK}', '', $tmpl);
  1122. }
  1123.  
  1124. // FEED_IMAGE_TITLE
  1125. if ($image_title = $feed->get_image_title())
  1126. {
  1127. $tmpl = str_replace('{FEED_IMAGE_TITLE}', SimplePie_WordPress::post_process('FEED_IMAGE_TITLE', $image_title), $tmpl);
  1128. }
  1129. else
  1130. {
  1131. $tmpl = str_replace('{FEED_IMAGE_TITLE}', '', $tmpl);
  1132. }
  1133.  
  1134. // FEED_IMAGE_URL
  1135. if ($image_url = $feed->get_image_url())
  1136. {
  1137. $tmpl = str_replace('{FEED_IMAGE_URL}', SimplePie_WordPress::post_process('FEED_IMAGE_URL', $image_url), $tmpl);
  1138. }
  1139. else
  1140. {
  1141. $tmpl = str_replace('{FEED_IMAGE_URL}', '', $tmpl);
  1142. }
  1143.  
  1144. // FEED_IMAGE_WIDTH
  1145. if ($image_width = $feed->get_image_width())
  1146. {
  1147. $tmpl = str_replace('{FEED_IMAGE_WIDTH}', SimplePie_WordPress::post_process('FEED_IMAGE_WIDTH', $image_width), $tmpl);
  1148. }
  1149. else
  1150. {
  1151. $tmpl = str_replace('{FEED_IMAGE_WIDTH}', '', $tmpl);
  1152. }
  1153.  
  1154. // FEED_LANGUAGE
  1155. if ($language = $feed->get_language())
  1156. {
  1157. $tmpl = str_replace('{FEED_LANGUAGE}', SimplePie_WordPress::post_process('FEED_LANGUAGE', $language), $tmpl);
  1158. }
  1159. else
  1160. {
  1161. $tmpl = str_replace('{FEED_LANGUAGE}', '', $tmpl);
  1162. }
  1163.  
  1164. // FEED_LATITUDE
  1165. if ($latitude = $feed->get_latitude())
  1166. {
  1167. $tmpl = str_replace('{FEED_LATITUDE}', SimplePie_WordPress::post_process('FEED_LATITUDE', $latitude), $tmpl);
  1168. }
  1169. else
  1170. {
  1171. $tmpl = str_replace('{FEED_LATITUDE}', '', $tmpl);
  1172. }
  1173.  
  1174. // FEED_LONGITUDE
  1175. if ($longitude = $feed->get_longitude())
  1176. {
  1177. $tmpl = str_replace('{FEED_LONGITUDE}', SimplePie_WordPress::post_process('FEED_LONGITUDE', $longitude), $tmpl);
  1178. }
  1179. else
  1180. {
  1181. $tmpl = str_replace('{FEED_LONGITUDE}', '', $tmpl);
  1182. }
  1183.  
  1184. // FEED_PERMALINK
  1185. if ($permalink = $feed->get_permalink())
  1186. {
  1187. $tmpl = str_replace('{FEED_PERMALINK}', SimplePie_WordPress::post_process('FEED_PERMALINK', $permalink), $tmpl);
  1188. }
  1189. else
  1190. {
  1191. $tmpl = str_replace('{FEED_PERMALINK}', '', $tmpl);
  1192. }
  1193.  
  1194. // FEED_TITLE
  1195. if ($title = $feed->get_title())
  1196. {
  1197. $tmpl = str_replace('{FEED_TITLE}', SimplePie_WordPress::post_process('FEED_TITLE', $title), $tmpl);
  1198. }
  1199. else
  1200. {
  1201. $tmpl = str_replace('{FEED_TITLE}', '', $tmpl);
  1202. }
  1203.  
  1204. // SUBSCRIBE_URL
  1205. if ($subscribe_url = $feed->subscribe_url())
  1206. {
  1207. $tmpl = str_replace('{SUBSCRIBE_URL}', SimplePie_WordPress::post_process('SUBSCRIBE_URL', $subscribe_url), $tmpl);
  1208. }
  1209. else
  1210. {
  1211. $tmpl = str_replace('{SUBSCRIBE_URL}', '', $tmpl);
  1212. }
  1213.  
  1214. // TRUNCATE_FEED_DESCRIPTION
  1215. if ($description = $feed->get_description())
  1216. {
  1217. $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_DESCRIPTION', $description), $truncate_feed_description), $tmpl);
  1218. }
  1219. else
  1220. {
  1221. $tmpl = str_replace('{TRUNCATE_FEED_DESCRIPTION}', '', $tmpl);
  1222. }
  1223.  
  1224. // TRUNCATE_FEED_TITLE
  1225. if ($title = $feed->get_title())
  1226. {
  1227. $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_FEED_TITLE', $title), $truncate_feed_title), $tmpl);
  1228. }
  1229. else
  1230. {
  1231. $tmpl = str_replace('{TRUNCATE_FEED_TITLE}', '', $tmpl);
  1232. }
  1233. */
  1234. /**************************************************************************************************************/
  1235. // ITEMS
  1236.  
  1237. // Separate out the pre-item template
  1238. $tmpl = explode('{ITEM_LOOP_BEGIN}', $tmpl);
  1239. $pre_tmpl = $tmpl[0];
  1240.  
  1241. // Separate out the item template
  1242. $tmpl = explode('{ITEM_LOOP_END}', $tmpl[1]);
  1243. $item_tmpl = $tmpl[0];
  1244.  
  1245. // Separate out the post-item template
  1246. $post_tmpl = $tmpl[1];
  1247.  
  1248. // Clear out the variable
  1249. unset($tmpl);
  1250.  
  1251. // Start putting the output string together.
  1252. $tmpl = $pre_tmpl;
  1253.  
  1254. // Loop through all of the items that we're supposed to.
  1255.  
  1256. if ($options['offset'] != '') {
  1257. $offset = $options['offset'];
  1258. } else {
  1259. $offset = 0;
  1260. }
  1261. $itemstart = $offset;
  1262. $itemend = $items;
  1263.  
  1264. if ($options['show_more'] && $items !='' && $feed->get_item_quantity() > $items + $offset) {
  1265. $itemstart = $items+$offset;
  1266. $itemend = 50;
  1267. $showmore = 'yes';
  1268. } elseif ($options['show_more'] && $items !='' && $feed->get_item_quantity() <= $items + $offset) {
  1269. return;
  1270. }
  1271.  
  1272. foreach ($feed->get_items($itemstart, $itemend) as $item)
  1273. {
  1274.  
  1275. // Get a reference to the parent $feed object.
  1276. $parent = $item->get_feed();
  1277.  
  1278. // Get a working copy of the item template. We don't want to edit the original.
  1279. $working_item = $item_tmpl;
  1280.  
  1281. /*
  1282. // ITEM_CONTRIBUTOR_EMAIL
  1283. if ($contributor = $item->get_contributor())
  1284. {
  1285. if ($email = $contributor->get_email())
  1286. {
  1287. $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_EMAIL', $email), $working_item);
  1288. }
  1289. else
  1290. {
  1291. $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item);
  1292. }
  1293. }
  1294. else
  1295. {
  1296. $working_item = str_replace('{ITEM_CONTRIBUTOR_EMAIL}', '', $working_item);
  1297. }
  1298.  
  1299. // ITEM_CONTRIBUTOR_LINK
  1300. if ($contributor = $item->get_contributor())
  1301. {
  1302. if ($link = $contributor->get_link())
  1303. {
  1304. $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_LINK', $link), $working_item);
  1305. }
  1306. else
  1307. {
  1308. $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item);
  1309. }
  1310. }
  1311. else
  1312. {
  1313. $working_item = str_replace('{ITEM_CONTRIBUTOR_LINK}', '', $working_item);
  1314. }
  1315.  
  1316. // ITEM_CONTRIBUTOR_NAME
  1317. if ($contributor = $item->get_contributor())
  1318. {
  1319. if ($name = $contributor->get_name())
  1320. {
  1321. $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_CONTRIBUTOR_NAME', $name), $working_item);
  1322. }
  1323. else
  1324. {
  1325. $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item);
  1326. }
  1327. }
  1328. else
  1329. {
  1330. $working_item = str_replace('{ITEM_CONTRIBUTOR_NAME}', '', $working_item);
  1331. }
  1332.  
  1333. // ITEM_COPYRIGHT
  1334. if ($copyright = $item->get_copyright())
  1335. {
  1336. $working_item = str_replace('{ITEM_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_COPYRIGHT', $copyright), $working_item);
  1337. }
  1338. else
  1339. {
  1340. $working_item = str_replace('{ITEM_COPYRIGHT}', '', $working_item);
  1341. }
  1342.  
  1343. // ITEM_PARENT_AUTHOR_EMAIL
  1344. if ($author = $parent->get_author())
  1345. {
  1346. if ($email = $author->get_email())
  1347. {
  1348. $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_EMAIL', $email), $working_item);
  1349. }
  1350. else
  1351. {
  1352. $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item);
  1353. }
  1354. }
  1355. else
  1356. {
  1357. $working_item = str_replace('{ITEM_PARENT_AUTHOR_EMAIL}', '', $working_item);
  1358. }
  1359.  
  1360. // ITEM_PARENT_AUTHOR_LINK
  1361. if ($author = $parent->get_author())
  1362. {
  1363. if ($link = $author->get_link())
  1364. {
  1365. $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_LINK', $link), $working_item);
  1366. }
  1367. else
  1368. {
  1369. $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item);
  1370. }
  1371. }
  1372. else
  1373. {
  1374. $working_item = str_replace('{ITEM_PARENT_AUTHOR_LINK}', '', $working_item);
  1375. }
  1376.  
  1377. // ITEM_PARENT_AUTHOR_NAME
  1378. if ($author = $parent->get_author())
  1379. {
  1380. if ($name = $author->get_name())
  1381. {
  1382. $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_AUTHOR_NAME', $name), $working_item);
  1383. }
  1384. else
  1385. {
  1386. $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item);
  1387. }
  1388. }
  1389. else
  1390. {
  1391. $working_item = str_replace('{ITEM_PARENT_AUTHOR_NAME}', '', $working_item);
  1392. }
  1393.  
  1394. // ITEM_PARENT_CONTRIBUTOR_EMAIL
  1395. if ($contributor = $parent->get_contributor())
  1396. {
  1397. if ($email = $contributor->get_email())
  1398. {
  1399. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_EMAIL', $email), $working_item);
  1400. }
  1401. else
  1402. {
  1403. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item);
  1404. }
  1405. }
  1406. else
  1407. {
  1408. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_EMAIL}', '', $working_item);
  1409. }
  1410.  
  1411. // ITEM_PARENT_CONTRIBUTOR_LINK
  1412. if ($contributor = $parent->get_contributor())
  1413. {
  1414. if ($link = $contributor->get_link())
  1415. {
  1416. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_LINK', $link), $working_item);
  1417. }
  1418. else
  1419. {
  1420. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item);
  1421. }
  1422. }
  1423. else
  1424. {
  1425. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_LINK}', '', $working_item);
  1426. }
  1427.  
  1428. // ITEM_PARENT_CONTRIBUTOR_NAME
  1429. if ($contributor = $parent->get_contributor())
  1430. {
  1431. if ($name = $contributor->get_name())
  1432. {
  1433. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', SimplePie_WordPress::post_process('ITEM_PARENT_CONTRIBUTOR_NAME', $name), $working_item);
  1434. }
  1435. else
  1436. {
  1437. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item);
  1438. }
  1439. }
  1440. else
  1441. {
  1442. $working_item = str_replace('{ITEM_PARENT_CONTRIBUTOR_NAME}', '', $working_item);
  1443. }
  1444.  
  1445. // ITEM_AUTHOR_EMAIL
  1446. if ($author = $item->get_author())
  1447. {
  1448. if ($email = $author->get_email())
  1449. {
  1450. $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', SimplePie_WordPress::post_process('ITEM_AUTHOR_EMAIL', $email), $working_item);
  1451. }
  1452. else
  1453. {
  1454. $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item);
  1455. }
  1456. }
  1457. else
  1458. {
  1459. $working_item = str_replace('{ITEM_AUTHOR_EMAIL}', '', $working_item);
  1460. }
  1461.  
  1462. // ITEM_AUTHOR_LINK
  1463. if ($author = $item->get_author())
  1464. {
  1465. if ($link = $author->get_link())
  1466. {
  1467. $working_item = str_replace('{ITEM_AUTHOR_LINK}', SimplePie_WordPress::post_process('ITEM_AUTHOR_LINK', $link), $working_item);
  1468. }
  1469. else
  1470. {
  1471. $working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item);
  1472. }
  1473. }
  1474. else
  1475. {
  1476. $working_item = str_replace('{ITEM_AUTHOR_LINK}', '', $working_item);
  1477. }
  1478.  
  1479. // ITEM_AUTHOR_NAME
  1480. if ($author = $item->get_author())
  1481. {
  1482. if ($name = $author->get_name())
  1483. {
  1484. $working_item = str_replace('{ITEM_AUTHOR_NAME}', SimplePie_WordPress::post_process('ITEM_AUTHOR_NAME', $name), $working_item);
  1485. }
  1486. else
  1487. {
  1488. $working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item);
  1489. }
  1490. }
  1491. else
  1492. {
  1493. $working_item = str_replace('{ITEM_AUTHOR_NAME}', '', $working_item);
  1494. }
  1495.  
  1496. // ITEM_CATEGORY
  1497. if ($category = $item->get_category())
  1498. {
  1499. if ($label = $category->get_label())
  1500. {
  1501. $working_item = str_replace('{ITEM_CATEGORY}', SimplePie_WordPress::post_process('ITEM_CATEGORY', $label), $working_item);
  1502. }
  1503. else
  1504. {
  1505. $working_item = str_replace('{ITEM_CATEGORY}', '', $working_item);
  1506. }
  1507. }
  1508. else
  1509. {
  1510. $working_item = str_replace('{ITEM_CATEGORY}', '', $working_item);
  1511. }
  1512.  
  1513. // ITEM_CONTENT
  1514. if ($content = $item->get_content())
  1515. {
  1516. $working_item = str_replace('{ITEM_CONTENT}', SimplePie_WordPress::post_process('ITEM_CONTENT', $content), $working_item);
  1517. }
  1518. else
  1519. {
  1520. $working_item = str_replace('{ITEM_CONTENT}', '', $working_item);
  1521. }
  1522.  
  1523. // ITEM_DATE_UTC
  1524. if ($date = $item->get_date('U'))
  1525. {
  1526. $date = gmdate($date_format, $date);
  1527. $working_item = str_replace('{ITEM_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_DATE_UTC', $date), $working_item);
  1528. }
  1529. else
  1530. {
  1531. $working_item = str_replace('{ITEM_DATE_UTC}', '', $working_item);
  1532. }
  1533.  
  1534. // ITEM_ENCLOSURE_EMBED
  1535. if ($enclosure = $item->get_enclosure())
  1536. {
  1537. if ($encltemp = $enclosure->native_embed())
  1538. {
  1539. $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EMBED', $encltemp), $working_item);
  1540. }
  1541. else
  1542. {
  1543. $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item);
  1544. }
  1545. }
  1546. else
  1547. {
  1548. $working_item = str_replace('{ITEM_ENCLOSURE_EMBED}', '', $working_item);
  1549. }
  1550.  
  1551. // ITEM_ENCLOSURE_EXTENSION
  1552. if ($enclosure = $item->get_enclosure())
  1553. {
  1554. if ($encltemp = $enclosure->get_extension())
  1555. {
  1556. $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXTENSION', $encltemp), $working_item);
  1557. }
  1558. else
  1559. {
  1560. $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item);
  1561. }
  1562. }
  1563. else
  1564. {
  1565. $working_item = str_replace('{ITEM_ENCLOSURE_EXTENSION}', '', $working_item);
  1566. }
  1567.  
  1568. // ITEM_ENCLOSURE_HANDLER
  1569. if ($enclosure = $item->get_enclosure())
  1570. {
  1571. if ($encltemp = $enclosure->get_handler())
  1572. {
  1573. $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HANDLER', $encltemp), $working_item);
  1574. }
  1575. else
  1576. {
  1577. $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item);
  1578. }
  1579. }
  1580. else
  1581. {
  1582. $working_item = str_replace('{ITEM_ENCLOSURE_HANDLER}', '', $working_item);
  1583. }
  1584.  
  1585. // ITEM_ENCLOSURE_LENGTH
  1586. if ($enclosure = $item->get_enclosure())
  1587. {
  1588. if ($encltemp = $enclosure->get_length())
  1589. {
  1590. $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LENGTH', $encltemp), $working_item);
  1591. }
  1592. else
  1593. {
  1594. $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item);
  1595. }
  1596. }
  1597. else
  1598. {
  1599. $working_item = str_replace('{ITEM_ENCLOSURE_LENGTH}', '', $working_item);
  1600. }
  1601.  
  1602. // ITEM_ENCLOSURE_LINK
  1603. if ($enclosure = $item->get_enclosure())
  1604. {
  1605. if ($encltemp = $enclosure->get_link())
  1606. {
  1607. $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LINK', $encltemp), $working_item);
  1608. }
  1609. else
  1610. {
  1611. $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item);
  1612. }
  1613. }
  1614. else
  1615. {
  1616. $working_item = str_replace('{ITEM_ENCLOSURE_LINK}', '', $working_item);
  1617. }
  1618.  
  1619. // ITEM_ENCLOSURE_REAL_TYPE
  1620. if ($enclosure = $item->get_enclosure())
  1621. {
  1622. if ($encltemp = $enclosure->get_real_type())
  1623. {
  1624. $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_REAL_TYPE', $encltemp), $working_item);
  1625. }
  1626. else
  1627. {
  1628. $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item);
  1629. }
  1630. }
  1631. else
  1632. {
  1633. $working_item = str_replace('{ITEM_ENCLOSURE_REAL_TYPE}', '', $working_item);
  1634. }
  1635.  
  1636. // ITEM_ENCLOSURE_SIZE
  1637. if ($enclosure = $item->get_enclosure())
  1638. {
  1639. if ($encltemp = $enclosure->get_size())
  1640. {
  1641. $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SIZE', $encltemp), $working_item);
  1642. }
  1643. else
  1644. {
  1645. $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item);
  1646. }
  1647. }
  1648. else
  1649. {
  1650. $working_item = str_replace('{ITEM_ENCLOSURE_SIZE}', '', $working_item);
  1651. }
  1652.  
  1653. // ITEM_ENCLOSURE_TYPE
  1654. if ($enclosure = $item->get_enclosure())
  1655. {
  1656. if ($encltemp = $enclosure->get_type())
  1657. {
  1658. $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TYPE', $encltemp), $working_item);
  1659. }
  1660. else
  1661. {
  1662. $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item);
  1663. }
  1664. }
  1665. else
  1666. {
  1667. $working_item = str_replace('{ITEM_ENCLOSURE_TYPE}', '', $working_item);
  1668. }
  1669.  
  1670. // ITEM_ENCLOSURE_BITRATE
  1671. if ($enclosure = $item->get_enclosure())
  1672. {
  1673. if ($encltemp = $enclosure->get_bitrate())
  1674. {
  1675. $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_BITRATE', $encltemp), $working_item);
  1676. }
  1677. else
  1678. {
  1679. $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item);
  1680. }
  1681. }
  1682. else
  1683. {
  1684. $working_item = str_replace('{ITEM_ENCLOSURE_BITRATE}', '', $working_item);
  1685. }
  1686.  
  1687. // ITEM_ENCLOSURE_CHANNELS
  1688. if ($enclosure = $item->get_enclosure())
  1689. {
  1690. if ($encltemp = $enclosure->get_channels())
  1691. {
  1692. $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_CHANNELS', $encltemp), $working_item);
  1693. }
  1694. else
  1695. {
  1696. $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item);
  1697. }
  1698. }
  1699. else
  1700. {
  1701. $working_item = str_replace('{ITEM_ENCLOSURE_CHANNELS}', '', $working_item);
  1702. }
  1703.  
  1704. // ITEM_ENCLOSURE_DESCRIPTION
  1705. if ($enclosure = $item->get_enclosure())
  1706. {
  1707. if ($encltemp = $enclosure->get_description())
  1708. {
  1709. $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DESCRIPTION', $encltemp), $working_item);
  1710. }
  1711. else
  1712. {
  1713. $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item);
  1714. }
  1715. }
  1716. else
  1717. {
  1718. $working_item = str_replace('{ITEM_ENCLOSURE_DESCRIPTION}', '', $working_item);
  1719. }
  1720.  
  1721. // ITEM_ENCLOSURE_DURATION
  1722. if ($enclosure = $item->get_enclosure())
  1723. {
  1724. if ($encltemp = $enclosure->get_duration())
  1725. {
  1726. $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_DURATION', $encltemp), $working_item);
  1727. }
  1728. else
  1729. {
  1730. $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item);
  1731. }
  1732. }
  1733. else
  1734. {
  1735. $working_item = str_replace('{ITEM_ENCLOSURE_DURATION}', '', $working_item);
  1736. }
  1737.  
  1738. // ITEM_ENCLOSURE_EXPRESSION
  1739. if ($enclosure = $item->get_enclosure())
  1740. {
  1741. if ($encltemp = $enclosure->get_expression())
  1742. {
  1743. $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_EXPRESSION', $encltemp), $working_item);
  1744. }
  1745. else
  1746. {
  1747. $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item);
  1748. }
  1749. }
  1750. else
  1751. {
  1752. $working_item = str_replace('{ITEM_ENCLOSURE_EXPRESSION}', '', $working_item);
  1753. }
  1754.  
  1755. // ITEM_ENCLOSURE_FRAMERATE
  1756. if ($enclosure = $item->get_enclosure())
  1757. {
  1758. if ($encltemp = $enclosure->get_framerate())
  1759. {
  1760. $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_FRAMERATE', $encltemp), $working_item);
  1761. }
  1762. else
  1763. {
  1764. $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item);
  1765. }
  1766. }
  1767. else
  1768. {
  1769. $working_item = str_replace('{ITEM_ENCLOSURE_FRAMERATE}', '', $working_item);
  1770. }
  1771.  
  1772. // ITEM_ENCLOSURE_HASH
  1773. if ($enclosure = $item->get_enclosure())
  1774. {
  1775. if ($encltemp = $enclosure->get_hash())
  1776. {
  1777. $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HASH', $encltemp), $working_item);
  1778. }
  1779. else
  1780. {
  1781. $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item);
  1782. }
  1783. }
  1784. else
  1785. {
  1786. $working_item = str_replace('{ITEM_ENCLOSURE_HASH}', '', $working_item);
  1787. }
  1788.  
  1789. // ITEM_ENCLOSURE_HEIGHT
  1790. if ($enclosure = $item->get_enclosure())
  1791. {
  1792. if ($encltemp = $enclosure->get_height())
  1793. {
  1794. $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_HEIGHT', $encltemp), $working_item);
  1795. }
  1796. else
  1797. {
  1798. $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item);
  1799. }
  1800. }
  1801. else
  1802. {
  1803. $working_item = str_replace('{ITEM_ENCLOSURE_HEIGHT}', '', $working_item);
  1804. }
  1805.  
  1806. // ITEM_ENCLOSURE_LANGUAGE
  1807. if ($enclosure = $item->get_enclosure())
  1808. {
  1809. if ($encltemp = $enclosure->get_language())
  1810. {
  1811. $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_LANGUAGE', $encltemp), $working_item);
  1812. }
  1813. else
  1814. {
  1815. $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item);
  1816. }
  1817. }
  1818. else
  1819. {
  1820. $working_item = str_replace('{ITEM_ENCLOSURE_LANGUAGE}', '', $working_item);
  1821. }
  1822.  
  1823. // ITEM_ENCLOSURE_MEDIUM
  1824. if ($enclosure = $item->get_enclosure())
  1825. {
  1826. if ($encltemp = $enclosure->get_medium())
  1827. {
  1828. $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_MEDIUM', $encltemp), $working_item);
  1829. }
  1830. else
  1831. {
  1832. $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item);
  1833. }
  1834. }
  1835. else
  1836. {
  1837. $working_item = str_replace('{ITEM_ENCLOSURE_MEDIUM}', '', $working_item);
  1838. }
  1839.  
  1840. // ITEM_ENCLOSURE_PLAYER
  1841. if ($enclosure = $item->get_enclosure())
  1842. {
  1843. if ($encltemp = $enclosure->get_player())
  1844. {
  1845. $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_PLAYER', $encltemp), $working_item);
  1846. }
  1847. else
  1848. {
  1849. $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item);
  1850. }
  1851. }
  1852. else
  1853. {
  1854. $working_item = str_replace('{ITEM_ENCLOSURE_PLAYER}', '', $working_item);
  1855. }
  1856.  
  1857. // ITEM_ENCLOSURE_SAMPLINGRATE
  1858. if ($enclosure = $item->get_enclosure())
  1859. {
  1860. if ($encltemp = $enclosure->get_sampling_rate())
  1861. {
  1862. $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_SAMPLINGRATE', $encltemp), $working_item);
  1863. }
  1864. else
  1865. {
  1866. $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item);
  1867. }
  1868. }
  1869. else
  1870. {
  1871. $working_item = str_replace('{ITEM_ENCLOSURE_SAMPLINGRATE}', '', $working_item);
  1872. }
  1873.  
  1874. // ITEM_ENCLOSURE_THUMBNAIL
  1875. if ($enclosure = $item->get_enclosure())
  1876. {
  1877. if ($encltemp = $enclosure->get_thumbnail())
  1878. {
  1879. $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_THUMBNAIL', $encltemp), $working_item);
  1880. }
  1881. else
  1882. {
  1883. $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item);
  1884. }
  1885. }
  1886. else
  1887. {
  1888. $working_item = str_replace('{ITEM_ENCLOSURE_THUMBNAIL}', '', $working_item);
  1889. }
  1890.  
  1891. // ITEM_ENCLOSURE_TITLE
  1892. if ($enclosure = $item->get_enclosure())
  1893. {
  1894. if ($encltemp = $enclosure->get_title())
  1895. {
  1896. $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_TITLE', $encltemp), $working_item);
  1897. }
  1898. else
  1899. {
  1900. $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item);
  1901. }
  1902. }
  1903. else
  1904. {
  1905. $working_item = str_replace('{ITEM_ENCLOSURE_TITLE}', '', $working_item);
  1906. }
  1907.  
  1908. // ITEM_ENCLOSURE_WIDTH
  1909. if ($enclosure = $item->get_enclosure())
  1910. {
  1911. if ($encltemp = $enclosure->get_width())
  1912. {
  1913. $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', SimplePie_WordPress::post_process('ITEM_ENCLOSURE_WIDTH', $encltemp), $working_item);
  1914. }
  1915. else
  1916. {
  1917. $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item);
  1918. }
  1919. }
  1920. else
  1921. {
  1922. $working_item = str_replace('{ITEM_ENCLOSURE_WIDTH}', '', $working_item);
  1923. }
  1924.  
  1925. // ITEM_ID
  1926. if ($id = $item->get_id())
  1927. {
  1928. $working_item = str_replace('{ITEM_ID}', SimplePie_WordPress::post_process('ITEM_ID', $id), $working_item);
  1929. }
  1930. else
  1931. {
  1932. $working_item = str_replace('{ITEM_ID}', '', $working_item);
  1933. }
  1934.  
  1935. // ITEM_ID
  1936. if ($latitude = $item->get_latitude())
  1937. {
  1938. $working_item = str_replace('{ITEM_LATITUDE}', SimplePie_WordPress::post_process('ITEM_LATITUDE', $latitude), $working_item);
  1939. }
  1940. else
  1941. {
  1942. $working_item = str_replace('{ITEM_LATITUDE}', '', $working_item);
  1943. }
  1944.  
  1945. // ITEM_LOCAL_DATE
  1946. if ($local_date = $item->get_local_date($local_date_format))
  1947. {
  1948. $working_item = str_replace('{ITEM_LOCAL_DATE}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE', $local_date), $working_item);
  1949. }
  1950. else
  1951. {
  1952. $working_item = str_replace('{ITEM_LOCAL_DATE}', '', $working_item);
  1953. }
  1954.  
  1955. // ITEM_LOCAL_DATE_UTC
  1956. if ($local_date = $item->get_date('U'))
  1957. {
  1958. $local_date = gmdate('U', $local_date);
  1959. $local_date = strftime($local_date_format, $local_date);
  1960. $working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', SimplePie_WordPress::post_process('ITEM_LOCAL_DATE_UTC', $local_date), $working_item);
  1961. }
  1962. else
  1963. {
  1964. $working_item = str_replace('{ITEM_LOCAL_DATE_UTC}', '', $working_item);
  1965. }
  1966.  
  1967. // ITEM_LONGITUDE
  1968. if ($longitude = $item->get_longitude())
  1969. {
  1970. $working_item = str_replace('{ITEM_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_LONGITUDE', $longitude), $working_item);
  1971. }
  1972. else
  1973. {
  1974. $working_item = str_replace('{ITEM_LONGITUDE}', '', $working_item);
  1975. }
  1976.  
  1977. // ITEM_PARENT_COPYRIGHT
  1978. if ($copyright = $parent->get_copyright())
  1979. {
  1980. $working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_COPYRIGHT', $copyright), $working_item);
  1981. }
  1982. else
  1983. {
  1984. $working_item = str_replace('{ITEM_PARENT_COPYRIGHT}', '', $working_item);
  1985. }
  1986.  
  1987. // ITEM_PARENT_DESCRIPTION
  1988. if ($description = $parent->get_description())
  1989. {
  1990. $working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_PARENT_DESCRIPTION', $description), $working_item);
  1991. }
  1992. else
  1993. {
  1994. $working_item = str_replace('{ITEM_PARENT_DESCRIPTION}', '', $working_item);
  1995. }
  1996.  
  1997. // ITEM_PARENT_ENCODING
  1998. if ($encoding = $parent->get_encoding())
  1999. {
  2000. $working_item = str_replace('{ITEM_PARENT_ENCODING}', SimplePie_WordPress::post_process('ITEM_PARENT_ENCODING', $encoding), $working_item);
  2001. }
  2002. else
  2003. {
  2004. $working_item = str_replace('{ITEM_PARENT_ENCODING}', '', $working_item);
  2005. }
  2006.  
  2007. // ITEM_PARENT_FAVICON
  2008. if ($favicon = $parent->get_favicon())
  2009. {
  2010. $working_item = str_replace('{ITEM_PARENT_FAVICON}', SimplePie_WordPress::post_process('ITEM_PARENT_FAVICON', $favicon), $working_item);
  2011. }
  2012. else
  2013. {
  2014. $working_item = str_replace('{ITEM_PARENT_FAVICON}', '', $working_item);
  2015. }
  2016.  
  2017. // ITEM_PARENT_IMAGE_HEIGHT
  2018. if ($image_height = $parent->get_image_height())
  2019. {
  2020. $working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_HEIGHT', $image_height), $working_item);
  2021. }
  2022. else
  2023. {
  2024. $working_item = str_replace('{ITEM_PARENT_IMAGE_HEIGHT}', '', $working_item);
  2025. }
  2026.  
  2027. // ITEM_PARENT_IMAGE_LINK
  2028. if ($image_link = $parent->get_image_link())
  2029. {
  2030. $working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_LINK', $image_link), $working_item);
  2031. }
  2032. else
  2033. {
  2034. $working_item = str_replace('{ITEM_PARENT_IMAGE_LINK}', '', $working_item);
  2035. }
  2036.  
  2037. // ITEM_PARENT_IMAGE_TITLE
  2038. if ($image_title = $parent->get_image_title())
  2039. {
  2040. $working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_TITLE', $image_title), $working_item);
  2041. }
  2042. else
  2043. {
  2044. $working_item = str_replace('{ITEM_PARENT_IMAGE_TITLE}', '', $working_item);
  2045. }
  2046.  
  2047. // ITEM_PARENT_IMAGE_URL
  2048. if ($image_url = $parent->get_image_url())
  2049. {
  2050. $working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_URL', $image_url), $working_item);
  2051. }
  2052. else
  2053. {
  2054. $working_item = str_replace('{ITEM_PARENT_IMAGE_URL}', '', $working_item);
  2055. }
  2056.  
  2057. // ITEM_PARENT_IMAGE_WIDTH
  2058. if ($image_width = $parent->get_image_width())
  2059. {
  2060. $working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', SimplePie_WordPress::post_process('ITEM_PARENT_IMAGE_WIDTH', $image_width), $working_item);
  2061. }
  2062. else
  2063. {
  2064. $working_item = str_replace('{ITEM_PARENT_IMAGE_WIDTH}', '', $working_item);
  2065. }
  2066.  
  2067. // ITEM_PARENT_LANGUAGE
  2068. if ($language = $parent->get_language())
  2069. {
  2070. $working_item = str_replace('{ITEM_PARENT_LANGUAGE}', SimplePie_WordPress::post_process('ITEM_PARENT_LANGUAGE', $language), $working_item);
  2071. }
  2072. else
  2073. {
  2074. $working_item = str_replace('{ITEM_PARENT_LANGUAGE}', '', $working_item);
  2075. }
  2076.  
  2077. // ITEM_PARENT_LATITUDE
  2078. if ($latitude = $parent->get_latitude())
  2079. {
  2080. $working_item = str_replace('{ITEM_PARENT_LATITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LATITUDE', $latitude), $working_item);
  2081. }
  2082. else
  2083. {
  2084. $working_item = str_replace('{ITEM_PARENT_LATITUDE}', '', $working_item);
  2085. }
  2086.  
  2087. // ITEM_PARENT_LONGITUDE
  2088. if ($longitude = $parent->get_longitude())
  2089. {
  2090. $working_item = str_replace('{ITEM_PARENT_LONGITUDE}', SimplePie_WordPress::post_process('ITEM_PARENT_LONGITUDE', $longitude), $working_item);
  2091. }
  2092. else
  2093. {
  2094. $working_item = str_replace('{ITEM_PARENT_LONGITUDE}', '', $working_item);
  2095. }
  2096.  
  2097. // ITEM_PARENT_PERMALINK
  2098. if ($permalink = $parent->get_permalink())
  2099. {
  2100. $working_item = str_replace('{ITEM_PARENT_PERMALINK}', SimplePie_WordPress::post_process('ITEM_PARENT_PERMALINK', $permalink), $working_item);
  2101. }
  2102. else
  2103. {
  2104.  
  2105. $working_item = str_replace('{ITEM_PARENT_PERMALINK}', '', $working_item);
  2106. }
  2107.  
  2108. // ITEM_PARENT_TITLE
  2109. if ($title = $parent->get_title())
  2110. {
  2111. $working_item = str_replace('{ITEM_PARENT_TITLE}', SimplePie_WordPress::post_process('ITEM_PARENT_TITLE', $title), $working_item);
  2112. }
  2113. else
  2114. {
  2115. $working_item = str_replace('{ITEM_PARENT_TITLE}', '', $working_item);
  2116. }
  2117.  
  2118. // ITEM_PARENT_SUBSCRIBE_URL
  2119. if ($subscribe_url = $parent->subscribe_url())
  2120. {
  2121. $working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', SimplePie_WordPress::post_process('ITEM_PARENT_SUBSCRIBE_URL', $subscribe_url), $working_item);
  2122. }
  2123. else
  2124. {
  2125. $working_item = str_replace('{ITEM_PARENT_SUBSCRIBE_URL}', '', $working_item);
  2126. }
  2127.  
  2128. // TRUNCATE_ITEM_PARENT_DESCRIPTION
  2129. if ($description = $parent->get_description())
  2130. {
  2131. $working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_DESCRIPTION', $description), $truncate_feed_description), $working_item);
  2132. }
  2133. else
  2134. {
  2135. $working_item = str_replace('{TRUNCATE_ITEM_PARENT_DESCRIPTION}', '', $working_item);
  2136. }
  2137.  
  2138. // TRUNCATE_ITEM_PARENT_TITLE
  2139. if ($title = $parent->get_title())
  2140. {
  2141. $working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', SimplePie_Truncate(SimplePie_WordPress::post_process('TRUNCATE_ITEM_PARENT_TITLE', $title), $truncate_feed_title), $working_item);
  2142. }
  2143. else
  2144. {
  2145. $working_item = str_replace('{TRUNCATE_ITEM_PARENT_TITLE}', '', $working_item);
  2146. }
  2147.  
  2148. // ITEM_DESCRIPTION
  2149. if ($description = $item->get_description())
  2150. {
  2151. $description = str_replace('[', '{', $description);
  2152. $description = str_replace(']','}',$description);
  2153. $working_item = str_replace('{ITEM_DESCRIPTION}', SimplePie_WordPress::post_process('ITEM_DESCRIPTION', $description), $working_item);
  2154. }
  2155. else
  2156. {
  2157. $working_item = str_replace('{ITEM_DESCRIPTION}', '', $working_item);
  2158. }
  2159.  
  2160. // ITEM_HOST_URL
  2161. if ($permalink = $item->get_permalink())
  2162. {
  2163. if (SIMPLEPIE_PHP5) {
  2164. $working_item = str_replace('{ITEM_HOST_URL}', parse_url(SimplePie_WordPress::post_process('ITEM_PERMALINK', $permalink),PHP_URL_HOST), $working_item);
  2165. }
  2166. else {
  2167. $host_url = parse_url(SimplePie_WordPress::post_process('ITEM_PERMALINK', $permalink));
  2168. $working_item = str_replace('{ITEM_HOST_URL}', $host_url['host'], $working_item);
  2169. }
  2170. }
  2171. else
  2172. {
  2173. $working_item = str_replace('{ITEM_HOST_URL}', '', $working_item); // ITEM_HOST_URL //edited: new template tag
  2174. }
  2175. */
  2176.  
  2177. global $onenews;
  2178.  
  2179. $tzstring = get_option('timezone_string');
  2180.  
  2181. if (!empty($tzstring)) {
  2182. date_default_timezone_set($tzstring);
  2183. }
  2184.  
  2185. // ITEM_DATE
  2186. if ($date = $item->get_date($onenews->option['dateformat']))
  2187. {
  2188. $itemdate = $item->get_date(); //use this format to ensure correct time format, in case user set some other date format
  2189. if (strtotime($itemdate) > time() - 8640000) { //100 days
  2190. $timeago = onenews_human_time_diff(strtotime($itemdate),time()) . ' ';
  2191. } else {
  2192. $timeago = '';
  2193. }
  2194.  
  2195. $working_item = str_replace('{ITEM_DATE}', esc_attr($timeago) . esc_attr(SimplePie_WordPress::post_process('ITEM_DATE', $date)), $working_item);
  2196. }
  2197. else
  2198. {
  2199. $working_item = str_replace('{ITEM_DATE}', '', $working_item);
  2200. }
  2201.  
  2202. // ITEM_TITLE
  2203. if ($title = $item->get_title())
  2204. {
  2205. $working_item = str_replace('{ITEM_TITLE}', esc_attr(strip_tags(html_entity_decode($title))), $working_item);
  2206. }
  2207. else
  2208. {
  2209. $working_item = str_replace('{ITEM_TITLE}', 'Untitled', $working_item);
  2210. }
  2211.  
  2212. // TRUNCATE_ITEM_TITLE
  2213. if ($title)
  2214. {
  2215. $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', esc_attr(SimplePie_Truncate($title), $truncate_item_title), $working_item);
  2216. }
  2217. else
  2218. {
  2219. $working_item = str_replace('{TRUNCATE_ITEM_TITLE}', '', $working_item);
  2220. }
  2221.  
  2222. // TRUNCATE_ITEM_DESCRIPTION
  2223. if ($description = $item->get_description())
  2224. {
  2225. $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', esc_attr(SimplePie_Truncate($description, $onenews->option['truncatedesc'])), $working_item);
  2226. }
  2227. else
  2228. {
  2229. $working_item = str_replace('{TRUNCATE_ITEM_DESCRIPTION}', '', $working_item);
  2230. }
  2231.  
  2232. //ITEM_NEW
  2233. if (($date_new = strtotime($item->get_date())) && ($onenews->option['item_new'] != ''))
  2234. {
  2235. if ($date_new > (time() - ($onenews->option['item_new_duration'] * 3600))) {
  2236. $working_item = str_replace('{ITEM_NEW}', '<span class="item_new">' . esc_attr($onenews->option['item_new']) . '</span>', $working_item);
  2237. }
  2238. else {
  2239. $working_item = str_replace('{ITEM_NEW}', '', $working_item);
  2240. }
  2241. }
  2242. else {
  2243. $working_item = str_replace('{ITEM_NEW}', '', $working_item);
  2244. }
  2245.  
  2246. //SHOW_THUMBNAIL & VIDEO_IMAGE
  2247. $defaultimg = get_template_directory_uri() . '/images/default_image.gif';
  2248. if ($enclosure = $item->get_enclosure())
  2249. {
  2250. if ($encltemp = $enclosure->get_thumbnail())
  2251. {
  2252.  
  2253. if ($encltemp) {
  2254. $working_item = str_replace('{VIDEO_IMAGE}', $encltemp, $working_item);
  2255. } else {
  2256. $working_item = str_replace('{VIDEO_IMAGE}', '$defaultimg', $working_item);
  2257. }
  2258.  
  2259. if ($encltemp && isset($options['show_thumbnail']) && $options['show_thumbnail'] == TRUE) {
  2260. $show_thumbnail = '<p class="show_thumbnail"><img src="' . $encltemp . '" alt="' . esc_attr($title) . '" /></p>';
  2261. $working_item = str_replace('{SHOW_THUMBNAIL}', $show_thumbnail, $working_item);
  2262. } else {
  2263. $working_item = str_replace('{SHOW_THUMBNAIL}', '', $working_item);
  2264. }
  2265. } else {
  2266. preg_match('/<img([^>]*)>/i',$item->get_content(),$imgUrlMatches);
  2267. preg_match('/src=([\'"])([^\'"\1]+)\1/i', $imgUrlMatches[1], $imagesrc);
  2268. $imgurl = $imagesrc[2];
  2269.  
  2270. if ($imgurl) {
  2271. $working_item = str_replace('{VIDEO_IMAGE}', $imgurl, $working_item);
  2272. } else {
  2273. $working_item = str_replace('{VIDEO_IMAGE}', '$defaultimg', $working_item);
  2274. }
  2275.  
  2276. if ($imgurl && isset($options['show_thumbnail']) && $options['show_thumbnail'] == TRUE) {
  2277. $show_thumbnail = '<p class="show_thumbnail"><img src="' . $imgurl . '" alt="' . esc_attr($title) . '" /></p>';
  2278. $working_item = str_replace('{SHOW_THUMBNAIL}', $show_thumbnail, $working_item);
  2279. } else {
  2280. $working_item = str_replace('{SHOW_THUMBNAIL}', '', $working_item);
  2281. }
  2282. }
  2283. }
  2284. else {
  2285. preg_match('/<img([^>]*)>/i',$item->get_content(),$imgUrlMatches);
  2286. preg_match('/src=([\'"])([^\'"\1]+)\1/i', $imgUrlMatches[1], $imagesrc);
  2287. $imgurl = $imagesrc[2];
  2288.  
  2289. if ($imgurl) {
  2290. $working_item = str_replace('{VIDEO_IMAGE}', $imgurl, $working_item);
  2291. } else {
  2292. $working_item = str_replace('{VIDEO_IMAGE}', $defaultimg, $working_item);
  2293. }
  2294.  
  2295. if ($imgurl && isset($options['show_thumbnail']) && $options['show_thumbnail'] == TRUE ) {
  2296. $show_thumbnail = '<p class="show_thumbnail"><img src="' . $imgurl . '" alt="' . esc_attr($title) . '" /></p>';
  2297. $working_item = str_replace('{SHOW_THUMBNAIL}', $show_thumbnail, $working_item);
  2298. } else {
  2299. $working_item = str_replace('{SHOW_THUMBNAIL}', '', $working_item);
  2300. }
  2301. }
  2302.  
  2303. // ITEM_PERMALINK
  2304. if ($permalink = $item->get_permalink()) {
  2305. if ($onenews->option['iframe'] != 'iframe') {
  2306. $working_item = str_replace('{ITEM_PERMALINK}', $permalink, $working_item);
  2307. } else {
  2308. $domains_exclude = array();
  2309. $domains_exclude = explode("\n", $onenews->option['iframe_exclude']);;
  2310.  
  2311. foreach ($domains_exclude as $domain_exclude) {
  2312. $domain_exclude_found = stripos($permalink, trim($domain_exclude));
  2313.  
  2314. if ($domain_exclude_found !== false) {
  2315. break;
  2316. }
  2317. }
  2318.  
  2319. if ($domain_exclude_found !== false) {
  2320. $working_item = str_replace('{ITEM_PERMALINK}', $permalink, $working_item);
  2321. } else {
  2322. $working_item = str_replace('{ITEM_PERMALINK}', get_bloginfo('wpurl') . '/browser/?onsurl=' . preg_replace('/http/', '', rawurlencode($permalink), 1) . '&amp;onstitle=' . rawurlencode(esc_attr(mb_strimwidth($title, 0, 255, ' ...'))) . '&amp;onsdesc=' . rawurlencode(esc_attr(mb_strimwidth(strip_tags($description), 0, 255, ' ...'))) . '&amp;onsimage=' . preg_replace('/http/', '', rawurlencode($imgurl), 1) , $working_item);
  2323. }
  2324. }
  2325. }
  2326. else
  2327. {
  2328. $working_item = str_replace('{ITEM_PERMALINK}', '', $working_item);
  2329. }
  2330.  
  2331. //ITEM_SOCIAL_ICONS
  2332. if ($onenews->option['item_social_icons'] == 'show')
  2333. {
  2334. if (strpos($options['template'],'photorss') !== false) {
  2335. $photoclass = ' addthis_toolbox_photo';
  2336. }
  2337.  
  2338. //global $current_user, $wpdb; $user_id = $current_user->ID ; $user = $current_user->user_login;
  2339. //$member_genre = str_replace("local.","http://",get_user_meta($user_id, 'genre', true));
  2340.  
  2341. // <a style="float:right" href= "http://www.addthis.com/bookmark.php &username="styleruby" addthis:url="{ITEM_PERMALINK}" addthis:title="{ITEM_TITLE}" addthis:description="{ITEM_DESCRIPTION}" addthis:ui_email_note="{ITEM_TITLE} Story below sent from IsOurPlace.com"" class="addthis_button">
  2342. // <img src="http://tsourplace.dev/wp-content/themes/styleruby-news2/images/inwsrbyblgs2.png" border="0" title ="Save to my IsOurPlace blog" /></a>
  2343.  
  2344.  
  2345.  
  2346.  
  2347. if ($onenews->option['iframe'] != 'iframe' || $domain_exclude_found !== false) {
  2348. $addthis_permalink = $permalink;
  2349. } else {
  2350. $addthis_permalink = home_url('/browser/?onsurl=') . preg_replace('/http/', '', rawurlencode($permalink), 1) . '&amp;onstitle=' . rawurlencode(esc_attr(mb_strimwidth($title, 0, 255, ' ...'))) . '&amp;onsdesc=' . rawurlencode(esc_attr(mb_strimwidth(strip_tags($description), 0, 255, ' ...'))) . '&amp;onsimage=' . preg_replace('/http/', '', rawurlencode($imgurl), 1);
  2351. }
  2352.  
  2353. $icon_social_icons_html = '
  2354. <div class="addthis_toolbox addthis_default_style' . $photoclass . '">
  2355. <a class="addthis_button" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news2/includes/images/inwsrbyblgs2.png"></a>
  2356. <a class="addthis_button_facebook" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/facebook_16.png"/></a>
  2357. <a class="addthis_button_twitter" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/twitter_16.png"/></a>
  2358. <a class="addthis_button_google_plusone_share" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/google-plus.png"/></a>
  2359. <a class="addthis_button_linkedin" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/linkedin_16.png"/></a>
  2360. <a class="addthis_button_email" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"addthis:ui_email_note="-the Story below sent from IsOurPlace.com""><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/email_16.png"/></a>
  2361. <a href="http://www.addthis.com/bookmark.php?v=250" class="addthis_button_expanded" addthis:url="' . $permalink . '" addthis:title="' . esc_attr($title) . '"><img src="http://tsourclace.dev/wp-content/themes/styleruby-news/images/icons/logo1212e.gif"/></a>
  2362. </div>';
  2363.  
  2364. $working_item = str_replace('{ITEM_SOCIAL_ICONS}', $icon_social_icons_html, $working_item);
  2365. }
  2366. else {
  2367. $working_item = str_replace('{ITEM_SOCIAL_ICONS}', '', $working_item);
  2368. }
  2369.  
  2370. //TARGET
  2371. if ($onenews->option['target'] == 'newwindow')
  2372. $target = ' target="_blank"';
  2373.  
  2374. $working_item = str_replace('{TARGET}', $target, $working_item);
  2375.  
  2376. //NOFOLLOW
  2377. if ($onenews->option['nofollow'] == 'nofollow')
  2378. $nofollow = ' rel="nofollow"';
  2379.  
  2380. $working_item = str_replace('{NOFOLLOW}', $nofollow, $working_item);
  2381.  
  2382. $tmpl .= $working_item;
  2383. }
  2384.  
  2385. /**************************************************************************************************************/
  2386. // LAST STUFF
  2387.  
  2388. // Start by removing all line breaks and tabs.
  2389. $tmpl = preg_replace('/(\n|\r|\t)/i', "", $tmpl);
  2390.  
  2391. // PLUGIN_DIR
  2392. $tmpl = str_replace('{PLUGIN_DIR}', SIMPLEPIE_PLUGINDIR_WEB, $tmpl);
  2393.  
  2394. $tmpl .= $post_tmpl;
  2395.  
  2396. if ($showmore == 'yes') {
  2397. $tmpl = '<ul class="toggle">' . $tmpl . '</ul>';
  2398. }
  2399.  
  2400. // Kill the object to prevent memory leaks.
  2401. $feed->__destruct();
  2402. unset($feed);
  2403. unset($encltemp);
  2404. unset($working_item);
  2405.  
  2406. // Return the data back to the page.
  2407. return $tmpl;
  2408. }
  2409. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement