PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 1ms

/wordpress/wp-content/plugins/podpress/podpress_functions.php

https://github.com/bill742/verbalbrew
PHP | 2410 lines | 2126 code | 116 blank | 168 comment | 676 complexity | b73ad71bac4e0823eef4e97fe15551ce MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0, AGPL-1.0, LGPL-2.1, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. License:
  4. ==============================================================================
  5. Copyright 2006 Dan Kuykendall (email : dan@kuykendall.org)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-107 USA
  17. */
  18. if(!function_exists('getmicrotime')) {
  19. function getmicrotime() {
  20. list($usec, $sec) = explode(" ",microtime());
  21. return ((float)$usec + (float)$sec);
  22. }
  23. }
  24. function podPress_WPVersionCheck($input = '2.0.0') {
  25. GLOBAL $wp_version;
  26. if ( substr($wp_version, 0, 12) == 'wordpress-mu' ) {
  27. return true;
  28. }
  29. return ( (float) $input <= (float) $wp_version );
  30. }
  31. function podPress_iTunesLink() {
  32. GLOBAL $podPress;
  33. echo $podPress->iTunesLink();
  34. }
  35. function podPress_siteurl($noDomain = false) {
  36. if (!defined('PODPRESSSITEURL') || $noDomain) {
  37. $result = '';
  38. $urlparts = parse_url(get_option('siteurl'));
  39. if(!$noDomain) {
  40. if(empty($urlparts['scheme'])) {
  41. $urlparts['scheme'] = 'http';
  42. }
  43. $result .= $urlparts['scheme'].'://'.$_SERVER['HTTP_HOST'];
  44. if($urlparts['port'] != '' && $urlparts['port'] != '80') {
  45. $result .= ':'.$urlparts['port'];
  46. }
  47. }
  48. if(isset($urlparts['path'])) {
  49. $result .= $urlparts['path'];
  50. }
  51. if(substr($result, -1, 1) != '/') {
  52. $result .= '/';
  53. }
  54. if( TRUE == isset($urlparts['query']) AND '' != $urlparts['query'] ) {
  55. $result .= '?'.$urlparts['query'];
  56. }
  57. if( TRUE == isset($urlparts['fragment']) AND '' != $urlparts['fragment']) {
  58. $result .= '#'.$urlparts['fragment'];
  59. }
  60. if($noDomain) {
  61. return $result.'wp-content/plugins/';
  62. }
  63. define('PODPRESSSITEURL', $result.'wp-content/plugins/');
  64. }
  65. return PODPRESSSITEURL;
  66. }
  67. function podPress_url($noDomain = false) {
  68. if($noDomain) {
  69. if (!defined('PODPRESSURL')) {
  70. define('PODPRESSURL', podPress_siteurl($noDomain).'podpress/');
  71. }
  72. return PODPRESSURL;
  73. } else {
  74. //~ $result = get_option('siteurl');
  75. //~ if(substr($result, -1, 1) != '/') {
  76. //~ $result .= '/';
  77. //~ }
  78. //~ return $result.'wp-content/plugins/podpress/';
  79. return PODPRESS_URL.'/';
  80. }
  81. }
  82. function podPress_getFileExt($str)
  83. {
  84. $pos = strrpos($str, '.');
  85. $pos = $pos+1;
  86. return substr(strtolower($str), $pos);
  87. }
  88. function podPress_getFileName($str)
  89. {
  90. if(strrpos($str, '/')) {
  91. $pos = strrpos($str, '/');
  92. $pos = $pos+1;
  93. return substr($str, $pos);
  94. } elseif(strrpos($str, ':')) {
  95. $pos = strrpos($str, ':');
  96. $pos = $pos+1;
  97. return substr($str, $pos);
  98. } else {
  99. return $str;
  100. }
  101. }
  102. function podPress_wordspaceing($txt, $number = 5, $paddingchar = ' ') {
  103. $txt_array = array();
  104. $len = strlen($txt);
  105. $count=$len/$number;
  106. $i=0;
  107. while($i<=$count) {
  108. if($i==0) {$ib=0;} else {$ib=($i*$number)+1;}
  109. $txt_array[$i]=substr($txt, $ib, $number);
  110. $i++;
  111. }
  112. $i=0;
  113. $count_array=count($txt_array)-1;
  114. while ($i<=$count_array) {
  115. if ($i==0) {$txt=$txt_array[$i].$paddingchar;} else {$txt.=''.$txt_array[$i].' ';}
  116. $i++;
  117. }
  118. return $txt;
  119. }
  120. function podPress_stringLimiter($str, $len, $snipMiddle = false)
  121. {
  122. if (strlen($str) > $len) {
  123. if ( function_exists('mb_substr') ) {
  124. if($snipMiddle) {
  125. $startlen = $len / 3;
  126. $startlen = $startlen - 1;
  127. $endlen = $startlen * 2;
  128. $endlen = $endlen - $endlen - $endlen;
  129. return mb_substr($str, 0, $startlen).'...'.mb_substr($str, $endlen);
  130. } else {
  131. $len = $len - 3;
  132. return mb_substr($str, 0, $len).'...';
  133. }
  134. } else {
  135. if ($snipMiddle) {
  136. $startlen = $len / 3;
  137. $startlen = $startlen - 1;
  138. $endlen = $startlen * 2;
  139. $endlen = $endlen - $endlen - $endlen;
  140. return substr($str, 0, $startlen).'...'.substr($str, $endlen);
  141. } else {
  142. $len = $len - 3;
  143. return substr($str, 0, $len).'...';
  144. }
  145. }
  146. } else {
  147. return $str;
  148. }
  149. }
  150. /**
  151. * podPress_strlimiter2 - if the input phrase is longer then maxlength then cut out character from the middle of the phrase
  152. *
  153. * @package podPress
  154. * @since 8.8.5 beta 3
  155. *
  156. * @param str $phrase input string
  157. * @param int $maxlength [optional] - max. length of the output string
  158. * @param bool $abbrev [optional] - use the abbr-tag with the original string as the title element
  159. * @param str $paddingchar [optional] - character(s) which should symbolize the shortend string / placed in the middle of the shortend string
  160. * @param str $classname [optional] - name(s) of the CSS class(es) of the abbr-tag
  161. *
  162. * @return str phrase with max. length
  163. */
  164. function podPress_strlimiter2($phrase, $maxlength = 25, $abbrev = FALSE, $paddingchar = ' ... ', $classname = 'podpress_abbr') {
  165. $len = strlen($phrase);
  166. $maxlen = ($maxlength-strlen($paddingchar));
  167. if ( $len > $maxlen ) {
  168. $part1_len = floor($maxlen/2);
  169. $part1 = substr($phrase, 0, $part1_len);
  170. $part2_len = ceil($maxlen/2);
  171. $part2 = substr($phrase, -$part2_len, $len);
  172. if ($abbrev == TRUE) {
  173. if ( Trim($classname) != '' ) {
  174. return '<span class="'.$classname.'" title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $part1 . $paddingchar . $part2 . '</span>';
  175. } else {
  176. return '<span title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $part1 . $paddingchar . $part2 . '</span>';
  177. }
  178. } else {
  179. return $part1 . $paddingchar. $part2;
  180. }
  181. } else {
  182. return $phrase;
  183. }
  184. }
  185. /**
  186. * podPress_strlimiter_end - if the input phrase is longer then maxlength then cut characters from the end of the phrase
  187. *
  188. * @package podPress
  189. * @since 8.8.10.8
  190. *
  191. * @param str $phrase input string
  192. * @param int $maxlength [optional] - max. length of the output string
  193. * @param str $paddingchar [optional] - character(s) which should symbolize the shortend string / placed in the middle of the shortend string
  194. * @param bool $respecthtmlentities [optional] - if TRUE then the function will not cut htmlentities in half. It will cut before and after the entity.
  195. * @param bool $abbrev [optional] - use the abbr-tag with the original string as the title element
  196. * @param str $classname [optional] - name(s) of the CSS class(es) of the abbr-tag
  197. *
  198. * @return str phrase with max. length
  199. */
  200. function podPress_strlimiter_end($phrase, $maxlength = 25, $paddingchar = ' ... ', $respecthtmlentities = FALSE, $abbrev = FALSE, $classname = 'podpress_abbr', $charset = 'UTF-8') {
  201. $len = strlen($phrase);
  202. $maxlen = ($maxlength-strlen($paddingchar));
  203. if ( $len > $maxlen ) {
  204. if ( function_exists('mb_substr') AND function_exists('mb_strrpos') ) {
  205. $short_phrase = mb_substr($phrase, 0, $maxlen);
  206. if ( TRUE === $respecthtmlentities ) {
  207. $short_phrase_end = mb_substr($short_phrase, -10);
  208. $ampersandpos = mb_strrpos($short_phrase_end, '&');
  209. if ( FALSE !== $ampersandpos ) {
  210. // if there is an ampersand among the last characters then it might be an entity
  211. $semicolonpos = mb_strrpos($short_phrase_end, ';');
  212. if ( FALSE === $semicolonpos OR $semicolonpos < $ampersandpos ) {
  213. // if no semicolon is following the ampersand OR if the position of the semicolon is smaller than (before the) position of the ampersand then it is most likely an entity which was cut off
  214. // cut the string before the entity
  215. $short_phrase = mb_substr($phrase, 0, ($maxlen - 10 + $ampersandpos));
  216. }
  217. }
  218. }
  219. } else {
  220. $short_phrase = substr($phrase, 0, $maxlen);
  221. if ( TRUE === $respecthtmlentities ) {
  222. $short_phrase_end = substr($short_phrase, -10);
  223. $ampersandpos = strrpos($short_phrase_end, '&');
  224. if ( FALSE !== $ampersandpos ) {
  225. // if there is an ampersand among the last characters then it might be an entity
  226. $semicolonpos = strrpos($short_phrase_end, ';');
  227. if ( FALSE === $semicolonpos OR $semicolonpos < $ampersandpos ) {
  228. // if no semicolon is following the ampersand OR if the position of the semicolon is smaller than (before the) position of the ampersand then it is most likely an entity which was cut off
  229. // cut the string before the entity
  230. $short_phrase = substr($phrase, 0, ($maxlen - 10 + $ampersandpos));
  231. }
  232. }
  233. }
  234. }
  235. if ($abbrev == TRUE) {
  236. if ( Trim($classname) != '' ) {
  237. return '<span class="'.$classname.'" title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $short_phrase . $paddingchar . '</span>';
  238. } else {
  239. return '<span title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $short_phrase . $paddingchar . '</span>';
  240. }
  241. } else {
  242. return $short_phrase . $paddingchar;
  243. }
  244. } else {
  245. return $phrase;
  246. }
  247. }
  248. /**
  249. * podPress_strlimiter_middle - if the input phrase is longer then maxlength then cut characters from the center of the phrase
  250. *
  251. * @package podPress
  252. * @since 8.8.10.8
  253. *
  254. * @param str $phrase input string
  255. * @param int $maxlength [optional] - max. length of the output string
  256. * @param str $paddingchar [optional] - character(s) which should symbolize the shortend string / placed in the middle of the shortend string
  257. * @param bool $respecthtmlentities [optional] - if TRUE then the function will not cut htmlentities in half. It will cut before and after the entity.
  258. * @param bool $abbrev [optional] - use the abbr-tag with the original string as the title element
  259. * @param str $classname [optional] - name(s) of the CSS class(es) of the abbr-tag
  260. *
  261. * @return str phrase with max. length
  262. */
  263. function podPress_strlimiter_middle($phrase, $maxlength = 25, $paddingchar = ' ... ', $respecthtmlentities = FALSE, $abbrev = FALSE, $classname = 'podpress_abbr') {
  264. $len = strlen($phrase);
  265. $paddinglen = strlen($paddingchar);
  266. $maxlen = ($maxlength-$paddinglen);
  267. if ( $len > $maxlen ) {
  268. if ( function_exists('mb_substr') AND function_exists('mb_strrpos') AND function_exists('mb_strpos') ) {
  269. $part1_len = floor($maxlen/2);
  270. $part1 = mb_substr($phrase, 0, $part1_len);
  271. $part2_len = ceil($maxlen/2);
  272. $part2 = mb_substr($phrase, -$part2_len, $len);
  273. if ( TRUE === $respecthtmlentities ) {
  274. $part1_end = mb_substr($part1, -10);
  275. $ampersandpos_part1 = mb_strrpos($part1_end, '&');
  276. if ( FALSE !== $ampersandpos_part1 ) {
  277. // if there is an ampersand among the last characters of part1 then it might be an entity
  278. $semicolonpos_part1 = mb_strrpos($part1_end, ';');
  279. if ( FALSE === $semicolonpos_part1 OR $semicolonpos_part1 < $ampersandpos_part1 ) {
  280. // if no semicolon is following the ampersand then it is most likely an entity which was cut off
  281. // cut the 1. part phrase before the entity
  282. $part1 = mb_substr($part1, 0, ($part1_len - 10 + $ampersandpos_part1));
  283. }
  284. }
  285. $part2_start = mb_substr($part2, 0, 10);
  286. $semicolonpos_part2 = mb_strpos($part2_start, ';');
  287. if ( FALSE !== $semicolonpos_part2 ) {
  288. // if there is a semicolon among the first characters of part2 then check whether there is an ampersand before that semicolon
  289. $ampersandpos_part2 = mb_strrpos($part2_start, '&');
  290. if ( FALSE === $ampersandpos_part2 OR $ampersandpos_part2 > $semicolonpos_part2 ) {
  291. // if there is no ampersand among the first characters of part2 which comes before the semicolon then look for it in the 10 characters before the semicolon
  292. $part2_long_start = mb_substr($phrase, (-$part2_len+$semicolonpos_part2-10), 10); // a certain number of characters before the semicolon (this might include characters from part1 depending on the $paddinglen)
  293. $ampersandpos_part2_long = mb_strrpos($part2_long_start, '&');
  294. $semicolonpos_part2_long = mb_strrpos($part2_long_start, ';');
  295. if ( (FALSE !== $ampersandpos_part2_long AND FALSE === $semicolonpos_part2_long) OR (FALSE !== $ampersandpos_part2_long AND FALSE !== $semicolonpos_part2_long AND $semicolonpos_part2_long < $ampersandpos_part2_long) ) {
  296. // if there is an ampersand and no further semicolon OR if there is an ampersand and further semicolon which comes before the ampersand then this semicolon is most likely a semicolon of an entity
  297. // cut the 2. part phrase after the semicolon
  298. $part2 = mb_substr($part2, (-$part2_len+$semicolonpos_part2+1), $len);
  299. }
  300. }
  301. }
  302. }
  303. } else {
  304. $part1_len = floor($maxlen/2);
  305. $part1 = substr($phrase, 0, $part1_len);
  306. $part2_len = ceil($maxlen/2);
  307. $part2 = substr($phrase, -$part2_len, $len);
  308. if ( TRUE === $respecthtmlentities ) {
  309. $part1_end = substr($part1, -10);
  310. $ampersandpos_part1 = strrpos($part1_end, '&');
  311. if ( FALSE !== $ampersandpos_part1 ) {
  312. // if there is an ampersand among the last characters of part1 then it might be an entity
  313. $semicolonpos_part1 = strrpos($part1_end, ';');
  314. if ( FALSE === $semicolonpos_part1 OR $semicolonpos_part1 < $ampersandpos_part1 ) {
  315. // if no semicolon is following the ampersand then it is most likely an entity which was cut off
  316. // cut the 1. part phrase before the entity
  317. $part1 = substr($part1, 0, ($part1_len - 10 + $ampersandpos_part1));
  318. }
  319. }
  320. $part2_start = substr($part2, 0, 10);
  321. $semicolonpos_part2 = strpos($part2_start, ';');
  322. if ( FALSE !== $semicolonpos_part2 ) {
  323. // if there is a semicolon among the first characters of part2 then check whether there is an ampersand before that semicolon
  324. $ampersandpos_part2 = strrpos($part2_start, '&');
  325. if ( FALSE === $ampersandpos_part2 OR $ampersandpos_part2 > $semicolonpos_part2 ) {
  326. // if there is no ampersand among the first characters of part2 which comes before the semicolon then look for it in the 10 characters before the semicolon
  327. $part2_long_start = substr($phrase, (-$part2_len+$semicolonpos_part2-10), 10); // a certain number of characters before the semicolon (this might include characters from part1 depending on the $paddinglen)
  328. $ampersandpos_part2_long = strrpos($part2_long_start, '&');
  329. $semicolonpos_part2_long = strrpos($part2_long_start, ';');
  330. if ( (FALSE !== $ampersandpos_part2_long AND FALSE === $semicolonpos_part2_long) OR (FALSE !== $ampersandpos_part2_long AND FALSE !== $semicolonpos_part2_long AND $semicolonpos_part2_long < $ampersandpos_part2_long) ) {
  331. // if there is an ampersand and no further semicolon OR if there is an ampersand and further semicolon which comes before the ampersand then this semicolon is most likely a semicolon of an entity
  332. // cut the 2. part phrase after the semicolon
  333. $part2 = substr($part2, (-$part2_len+$semicolonpos_part2+1), $len);
  334. }
  335. }
  336. }
  337. }
  338. }
  339. if ($abbrev == TRUE) {
  340. if ( Trim($classname) != '' ) {
  341. return '<span class="'.$classname.'" title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $part1 . $paddingchar . $part2 . '</span>';
  342. } else {
  343. return '<span title="'.attribute_escape(str_replace('"', '\'', $phrase)).'">' . $part1 . $paddingchar . $part2 . '</span>';
  344. }
  345. } else {
  346. return $part1 . $paddingchar. $part2;
  347. }
  348. } else {
  349. return $phrase;
  350. }
  351. }
  352. if(!function_exists('html_print_r')) {
  353. function html_print_r($v, $n = '', $ret = false) {
  354. if($ret) {
  355. ob_start();
  356. }
  357. echo $n.'<pre>';
  358. print_r($v);
  359. echo '</pre>';
  360. if($ret) {
  361. $result = ob_get_contents();
  362. ob_end_clean();
  363. return $result;
  364. }
  365. }
  366. }
  367. if(!function_exists('comment_print_r')) {
  368. function comment_print_r($v, $n = '', $ret = false) {
  369. $result = "<!-- \n";
  370. $result .= html_print_r($v, $n, true);
  371. $result .= " -->\n";
  372. if($ret) {
  373. return $result;
  374. }
  375. echo $result;
  376. }
  377. }
  378. if(!function_exists('maybe_unserialize')) {
  379. function maybe_unserialize($original, $ss = false) {
  380. if($ss) {
  381. $original = stripslashes($original);
  382. }
  383. if ( false !== $gm = @ unserialize($original) ) {
  384. return $gm;
  385. } else {
  386. return $original;
  387. }
  388. }
  389. }
  390. if(!function_exists('isBase64')) {
  391. function isBase64($str)
  392. {
  393. $_tmp=preg_replace("/[^A-Z0-9\+\/\=]/i",'',$str);
  394. return (strlen($_tmp) % 4 == 0 ) ? true : false;
  395. }
  396. }
  397. function podPress_mimetypes($ext, $mp4_type = 'audio') {
  398. $ext = strtolower($ext);
  399. $ext_list = array (
  400. 'jpg' => 'image/jpeg',
  401. 'jpeg' => 'image/jpeg',
  402. 'jpe' => 'image/jpeg',
  403. 'gif' => 'image/gif',
  404. 'png' => 'image/png',
  405. 'bmp' => 'image/bmp',
  406. 'tif' => 'image/tiff',
  407. 'tiff' => 'image/tiff',
  408. 'ico' => 'image/x-icon',
  409. 'flv' => 'video/flv',
  410. 'asf' => 'video/asf',
  411. 'wmv' => 'video/wmv',
  412. 'asx' => 'video/asf',
  413. 'wax' => 'video/asf',
  414. 'wmx' => 'video/asf',
  415. 'avi' => 'video/avi',
  416. 'qt' => 'video/quicktime',
  417. 'mov' => 'video/quicktime',
  418. 'm4v' => 'video/x-m4v',
  419. 'mpeg' => 'video/mpeg',
  420. 'mpg' => 'video/mpeg',
  421. 'mpe' => 'video/mpeg',
  422. 'txt' => 'text/plain',
  423. 'c' => 'text/plain',
  424. 'cc' => 'text/plain',
  425. 'h' => 'text/plain',
  426. 'rtx' => 'text/richtext',
  427. 'css' => 'text/css',
  428. 'htm' => 'text/html',
  429. 'html' => 'text/html',
  430. 'mp3' => 'audio/mpeg',
  431. 'mp4' => $mp4_type.'/mpeg',
  432. 'm4a' => 'audio/x-m4a',
  433. 'aa' => 'audio/audible',
  434. 'ra' => 'audio/x-realaudio',
  435. 'ram' => 'audio/x-realaudio',
  436. 'wav' => 'audio/wav',
  437. 'ogg' => 'audio/ogg',
  438. 'ogv' => 'video/ogg',
  439. 'mid' => 'audio/midi',
  440. 'midi' => 'audio/midi',
  441. 'wma' => 'audio/wma',
  442. 'rtf' => 'application/rtf',
  443. 'js' => 'application/javascript',
  444. 'pdf' => 'application/pdf',
  445. 'epub' => 'document/x-epub',
  446. 'doc' => 'application/msword',
  447. 'pot' => 'application/vnd.ms-powerpoint',
  448. 'pps' => 'application/vnd.ms-powerpoint',
  449. 'ppt' => 'application/vnd.ms-powerpoint',
  450. 'wri' => 'application/vnd.ms-write',
  451. 'xla' => 'application/vnd.ms-excel',
  452. 'xls' => 'application/vnd.ms-excel',
  453. 'xlt' => 'application/vnd.ms-excel',
  454. 'xlw' => 'application/vnd.ms-excel',
  455. 'mdb' => 'application/vnd.ms-access',
  456. 'mpp' => 'application/vnd.ms-project',
  457. 'swf' => 'application/x-shockwave-flash',
  458. 'class' => 'application/java',
  459. 'tar' => 'application/x-tar',
  460. 'zip' => 'application/zip',
  461. 'gz' => 'application/x-gzip',
  462. 'gzip' => 'application/x-gzip',
  463. 'torrent' => 'application/x-bittorrent',
  464. 'exe' => 'application/x-msdownload'
  465. );
  466. if(!isset($ext_list[$ext])) {
  467. return 'application/unknown';
  468. }
  469. return $ext_list[$ext];
  470. }
  471. function podPress_maxMemory() {
  472. $max = ini_get('memory_limit');
  473. if (preg_match('/^([\d\.]+)([gmk])?$/i', $max, $m)) {
  474. $value = $m[1];
  475. if (isset($m[2])) {
  476. switch(strtolower($m[2])) {
  477. case 'g': $value *= 1024; # fallthrough
  478. case 'm': $value *= 1024; # fallthrough
  479. case 'k': $value *= 1024; break;
  480. default: $value = 2048000;
  481. }
  482. }
  483. $max = $value;
  484. } else {
  485. $max = 2048000;
  486. }
  487. return $max/2;
  488. }
  489. /**************************************************************/
  490. /* Functions for supporting the widgets */
  491. /**************************************************************/
  492. /* for WP < 2.8 only */
  493. function podPress_loadWidgets () {
  494. global $wp_version;
  495. if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') ) {
  496. return;
  497. }
  498. if (TRUE == version_compare($wp_version, '2.2', '>=')) {
  499. // Feed Buttons widget
  500. $widget_ops = array(
  501. 'classname' => 'podpress_feedbuttons',
  502. 'description' => __('Shows buttons for the podcast feeds in the sidebar', 'podpress')
  503. );
  504. $control_ops = array('width' => 400, 'height' => 700, 'id_base' => 'podpressfeedbuttons');
  505. $id = $control_ops['id_base'];
  506. wp_register_sidebar_widget($id, __('podPress - Feed Buttons','podpress'), 'podPress_feedButtons', $widget_ops);
  507. wp_register_widget_control($id, __('podPress - Feed Buttons','podpress'), 'podPress_feedButtons_control', $control_ops);
  508. // XSPF Player widget
  509. $widget_ops = array(
  510. 'classname' => 'podpress_xspfplayer',
  511. 'description' => __('Shows a XSPF Player in the sidebar which uses e.g. the XSPF playlist of your podcast episodes', 'podpress')
  512. );
  513. $control_ops = array('width' => 400, 'height' => 400, 'id_base' => 'podpressxspfplayer');
  514. $id = $control_ops['id_base'];
  515. wp_register_sidebar_widget($id, __('podPress - XSPF Player','podpress'), 'podPress_xspfPlayer', $widget_ops);
  516. wp_register_widget_control($id, __('podPress - XSPF Player','podpress'), 'podPress_xspfPlayer_control', $control_ops);
  517. } else {
  518. // Feed Buttons widget
  519. register_sidebar_widget(array('podPress - Feed Buttons', 'widgets'), 'podPress_feedButtons', $widget_ops);
  520. register_widget_control(array('podPress - Feed Buttons', 'widgets'), 'podPress_feedButtons_control', 400, 700);
  521. // XSPF Player widget
  522. register_sidebar_widget(array('podPress - XSPF Player', 'widgets'), 'podPress_xspfPlayer');
  523. register_widget_control(array('podPress - XSPF Player', 'widgets'), 'podPress_xspfPlayer_control', 400, 400);
  524. }
  525. }
  526. /* for WP < 2.8 only */
  527. function podPress_feedButtons_control() {
  528. GLOBAL $podPress, $wp_version, $wpdb;
  529. $options = get_option('widget_podPressFeedButtons');
  530. $newoptions = $options;
  531. if ( isset($_POST['podPressFeedButtons-submit']) ) {
  532. $newoptions['blog'] = isset($_POST['podPressFeedButtons-posts']);
  533. $newoptions['comments'] = isset($_POST['podPressFeedButtons-comments']);
  534. $newoptions['entries-atom'] = isset($_POST['podPressFeedButtons-entries-atom']);
  535. $newoptions['comments-atom'] = isset($_POST['podPressFeedButtons-comments-atom']);
  536. $newoptions['posts_buttonurl'] = clean_url($_POST['podPressFeedButtons-posts_buttonurl'], array('http', 'https'), 'db');
  537. $newoptions['comments_buttonurl'] = clean_url($_POST['podPressFeedButtons-comments_buttonurl'], array('http', 'https'), 'db');
  538. $newoptions['entries-atom_buttonurl'] = clean_url($_POST['podPressFeedButtons-entries-atom_buttonurl'], array('http', 'https'), 'db');
  539. $newoptions['comments-atom_buttonurl'] = clean_url($_POST['podPressFeedButtons-comments-atom_buttonurl'], array('http', 'https'), 'db');
  540. $newoptions['posts_altfeedurl'] = clean_url($_POST['podPressFeedButtons-posts_altfeedurl'], array('http', 'https'), 'db');
  541. $newoptions['comments_altfeedurl'] = clean_url($_POST['podPressFeedButtons-comments_altfeedurl'], array('http', 'https'), 'db');
  542. $newoptions['entries-atom_altfeedurl'] = clean_url($_POST['podPressFeedButtons-entries-atom_altfeedurl'], array('http', 'https'), 'db');
  543. $newoptions['comments-atom_altfeedurl'] = clean_url($_POST['podPressFeedButtons-comments-atom_altfeedurl'], array('http', 'https'), 'db');
  544. $newoptions['itunes'] = isset($_POST['podPressFeedButtons-itunes']);
  545. $newoptions['itunes_buttonurl'] = clean_url($_POST['podPressFeedButtons-itunes_buttonurl'], array('http', 'https'), 'db');
  546. // iscifi new option for itunes protocol
  547. $newoptions['iprot'] = isset($_POST['podPressItunesProtocol-iprot']);
  548. $blog_charset = get_bloginfo('charset');
  549. $newoptions['title'] = htmlspecialchars(strip_tags(trim($_POST['podPressFeedButtons-title'])), ENT_QUOTES, $blog_charset);
  550. $newoptions['buttons-or-text'] = $_POST['podPressFeedButtons-buttons-or-text'];
  551. // CategoryCasting Feeds:
  552. if ( is_array($_POST['podPressFeedButtons-catcast']) ) {
  553. foreach ( $_POST['podPressFeedButtons-catcast'] as $cat_id => $feed_options ) {
  554. if ( 'yes' === $feed_options['use'] ) {
  555. $newoptions['catcast'][$cat_id]['use'] = 'yes';
  556. } else {
  557. $newoptions['catcast'][$cat_id]['use'] = 'no';
  558. }
  559. $newoptions['catcast'][$cat_id]['buttonurl'] = clean_url($feed_options['buttonurl'], array('http', 'https'), 'db');
  560. $newoptions['catcast'][$cat_id]['altfeedurl'] = clean_url($feed_options['altfeedurl'], array('http', 'https'), 'db');
  561. }
  562. }
  563. // podPress Feeds:
  564. if ( is_array($_POST['podpressfeeds']) ) {
  565. foreach ( $_POST['podpressfeeds'] as $feed_slug => $feed_options ) {
  566. if ( 'yes' === $feed_options['use'] ) {
  567. $newoptions['podpressfeeds'][$feed_slug]['use'] = 'yes';
  568. } else {
  569. $newoptions['podpressfeeds'][$feed_slug]['use'] = 'no';
  570. }
  571. $newoptions['podpressfeeds'][$feed_slug]['button'] = $feed_options['button'];
  572. if ( 'custom' === $feed_options['button'] ) {
  573. $newoptions['podpressfeeds'][$feed_slug]['buttonurl'] = clean_url($feed_options['buttonurl'], array('http', 'https'), 'db');
  574. } else {
  575. $newoptions['podpressfeeds'][$feed_slug]['buttonurl'] = PODPRESS_URL.'/images/'.$feed_options['button'];
  576. }
  577. $newoptions['podpressfeeds'][$feed_slug]['altfeedurl'] = clean_url($feed_options['altfeedurl'], array('http', 'https'), 'db');
  578. }
  579. }
  580. }
  581. if ( $options != $newoptions ) {
  582. $options = $newoptions;
  583. update_option('widget_podPressFeedButtons', $options);
  584. }
  585. if(!isset($options['blog'])) {
  586. $options['blog'] = false;
  587. }
  588. if(!isset($options['comments'])) {
  589. $options['comments'] = false;
  590. }
  591. if(!isset($options['entries-atom'])) {
  592. $options['entries-atom'] = false;
  593. }
  594. if(!isset($options['comments-atom'])) {
  595. $options['comments-atom'] = false;
  596. }
  597. if(!isset($options['itunes'])) {
  598. $options['itunes'] = false;
  599. }
  600. if (!isset($options['iprot'])) {
  601. $options['iprot'] = false;
  602. }
  603. if (!isset($options['buttons-or-text'])) {
  604. $options['buttons-or-text'] = 'buttons';
  605. }
  606. if (!isset($options['itunes_buttonurl'])) {
  607. $options['itunes_buttonurl'] = PODPRESS_URL.'/images/itunes.png';
  608. }
  609. if (!isset($options['posts_buttonurl'])) {
  610. $options['posts_buttonurl'] = PODPRESS_URL.'/images/feed_button-rss-blog.png';
  611. }
  612. if (!isset($options['comments_buttonurl'])) {
  613. $options['comments_buttonurl'] = PODPRESS_URL.'/images/feed_button-rss-comments.png';
  614. }
  615. if (!isset($options['entries-atom_buttonurl'])) {
  616. $options['entries-atom_buttonurl'] = PODPRESS_URL.'/images/feed_button-atom-blog.png';
  617. }
  618. if (!isset($options['comments-atom_buttonurl'])) {
  619. $options['comments-atom_buttonurl'] = PODPRESS_URL.'/images/feed_button-atom-comments.png';
  620. }
  621. $blog = $options['blog'] ? 'checked="checked"' : '';
  622. $comments = $options['comments'] ? 'checked="checked"' : '';
  623. $entries_atom = $options['entries-atom'] ? 'checked="checked"' : '';
  624. $comments_atom = $options['comments-atom'] ? 'checked="checked"' : '';
  625. $itunes = $options['itunes'] ? 'checked="checked"' : '';
  626. $iprot = $options['iprot'] ? 'checked="checked"' :'';
  627. if ( 'text' == $options['buttons-or-text'] ) {
  628. $text = 'checked="checked"';
  629. $buttons = '';
  630. } else {
  631. $text = '';
  632. $buttons = 'checked="checked"';
  633. }
  634. if(!isset($options['title'])) {
  635. $options['title'] = __('Podcast Feeds', 'podpress');
  636. }
  637. $title = attribute_escape(stripslashes($options['title']));
  638. ?>
  639. <p><label for="podPressFeedButtons-title"><?php _e('Title:', 'podpress'); ?></label> <input class="podpress_widget_settings_title" id="podPressFeedButtons-title" name="podPressFeedButtons-title" type="text" value="<?php echo $title; ?>" /></p>
  640. <p><?php _e('Show the buttons for the following feeds:', 'podpress'); ?></p>
  641. <div class="podpress_widget_accordion"><!-- Begin: podPress Widget Accordion -->
  642. <h5><a href=""><?php _e('iTunes Button', 'podpress'); ?></a></h5>
  643. <div>
  644. <input class="checkbox" type="checkbox" <?php echo $itunes; ?> id="podPressFeedButtons-itunes" name="podPressFeedButtons-itunes" /> <label for="podPressFeedButtons-itunes"><?php _e('Show iTunes button', 'podpress'); ?></label><br />
  645. <input class="checkbox" type="checkbox" <?php echo $iprot; ?> id="podPressFeedButtons-iprot" name="podPressItunesProtocol-iprot" /> <label for="podPressFeedButtons-iprot"><?php _e('Use iTunes protocol for URL', 'podpress'); ?> <?php _e('(itpc://)', 'podpress'); ?></label><br />
  646. <span class="nonessential"><?php _e('The user subscribes immediatly with the click. Otherwise the iTunes Store page of the podcast will be displayed first and the user can subscribe manually.', 'podpress'); ?></span><br />
  647. <label for="podPressFeedButtons-itunes_buttonurl"><?php _e('Button URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-itunes_buttonurl" name="podPressFeedButtons-itunes_buttonurl" class="widefat" value="<?php echo $options['itunes_buttonurl']; ?>" />
  648. </div>
  649. <?php
  650. if ( version_compare( $wp_version, '2.1', '>=' ) ) { // ntm: the add_feed() functions exists since WP 2.1 and widgets are probably possible in earlier WP versions with a plugin.
  651. $feedbuttons = podpress_get_feed_buttons();
  652. if ( is_array($podPress->settings['podpress_feeds']) AND FALSE == empty($podPress->settings['podpress_feeds']) ) {
  653. foreach ($podPress->settings['podpress_feeds'] as $feed) {
  654. if ( TRUE === $feed['use'] AND FALSE == empty($feed['slug']) ) {
  655. if ( FALSE == empty($feed['descr']) ) {
  656. $descr = '<br /><span class="nonessential">'.stripslashes($feed['descr']).'</span>';
  657. } else {
  658. $descr = '';
  659. }
  660. // take over the old widget settings
  661. if ( TRUE == is_array($old_widget_options) AND FALSE == empty($old_widget_options) ) {
  662. Switch ($feed['slug']) {
  663. case 'podcast' :
  664. case 'enhancedpodcast' :
  665. case 'torrent' :
  666. $options['podpressfeeds'][$feed['slug']]['use'] = $old_widget_options[$feed['slug']];
  667. if ( 'podcast' === $feed['slug'] ) {
  668. $options['podpressfeeds'][$feed['slug']]['button'] = 'feed_button-rss-'.$feed['slug'].'.png';
  669. } else {
  670. $options['podpressfeeds'][$feed['slug']]['button'] = 'feed_button-'.$feed['slug'].'.png';
  671. }
  672. break;
  673. }
  674. }
  675. if ( TRUE == isset($options['podpressfeeds'][$feed['slug']]['use']) AND 'yes' === $options['podpressfeeds'][$feed['slug']]['use'] ) {
  676. $podpressfeed_checked = ' checked="checked"';
  677. } else {
  678. $podpressfeed_checked = '';
  679. }
  680. $feedname = stripslashes($feed['name']);
  681. echo '<h5><a href="">'.$feedname.'</a></h5>'."\n";
  682. echo '<div class="podpress_widget_settings_row_div">'."\n";
  683. echo '<input type="checkbox"'.$podpressfeed_checked.' id="podPressFeedButtons-'.$feed['slug'].'_use" name="podpressfeeds['.$feed['slug'].'][use]" value="yes" /> <label for="podPressFeedButtons-'.$feed['slug'].'_use">'.sprintf(__('Show %1$s button', 'podpress'), $feedname).'</label>'."\n";
  684. echo $descr."\n";
  685. echo '<br />'.__('Select a feed button:', 'podpress').'<br />'."\n";
  686. echo '<span class="podpress_feedbuttonsselectbox">'."\n";
  687. $id_base = 'podPressFeedButtons-'.$feed['slug'].'_'.$feed['button'];
  688. $i=0;
  689. $feedbutton_checked_nr = 0;
  690. foreach ($feedbuttons as $feedbutton) {
  691. if ( TRUE == isset($options['podpressfeeds'][$feed['slug']]['button']) AND $feedbutton == $options['podpressfeeds'][$feed['slug']]['button'] ) {
  692. $feedbutton_checked_nr = $i;
  693. }
  694. $i++;
  695. }
  696. $i=0;
  697. foreach ($feedbuttons as $feedbutton) {
  698. if ( $i == $feedbutton_checked_nr ) {
  699. $feedbutton_checked = ' checked="checked"';
  700. } else {
  701. $feedbutton_checked = '';
  702. }
  703. echo '<input type="radio" name="podpressfeeds['.$feed['slug'].'][button]" id="'.$id_base.''.$i.'" value="'.$feedbutton.'"'.$feedbutton_checked.' /> <label for="'.$id_base.''.$i.'"><img src="'.PODPRESS_URL.'/images/'.$feedbutton.'" alt="" /></label><br />'."\n";
  704. $i++;
  705. }
  706. if ( TRUE == isset($options['podpressfeeds'][$feed['slug']]['button']) AND 'custom' == $options['podpressfeeds'][$feed['slug']]['button'] ) {
  707. echo '<input type="radio" name="podpressfeeds['.$feed['slug'].'][button]" id="'.$id_base.''.$i.'" value="custom" checked="checked" /> <input type="text" id="podPressFeedButtons-'.$feed['slug'].'_'.$feed['custombuttonurl'].'" name="podpressfeeds['.$feed['slug'].'][buttonurl]" class="widefat podpress_customfeedbuttonurl" value="'.$options['podpressfeeds'][$feed['slug']]['buttonurl'].'" />'."\n";
  708. } else {
  709. echo '<input type="radio" name="podpressfeeds['.$feed['slug'].'][button]" id="'.$id_base.''.$i.'" value="custom" /> <input type="text" id="podPressFeedButtons-'.$feed['slug'].'_'.$feed['custombuttonurl'].'" name="podpressfeeds['.$feed['slug'].'][buttonurl]" class="widefat podpress_customfeedbuttonurl" value="" />'."\n";
  710. }
  711. echo '</span>'."\n";
  712. echo '<label for="podPressFeedButtons-'.$feed['slug'].'_altfeedurl">'.__('Alternative Feed URL:', 'podpress').'</label> <input type="text" id="podPressFeedButtons-'.$feed['slug'].'_altfeedurl" name="podpressfeeds['.$feed['slug'].'][altfeedurl]" class="widefat" value="'.$options['podpressfeeds'][$feed['slug']]['altfeedurl'].'" />'."\n";
  713. echo '</div>'."\n";
  714. }
  715. }
  716. }
  717. }
  718. ?>
  719. <h5><a href=""><?php _e('Entries RSS Feed', 'podpress'); ?></a></h5>
  720. <div>
  721. <input class="checkbox" type="checkbox" <?php echo $blog; ?> id="podPressFeedButtons-posts" name="podPressFeedButtons-posts" /> <label for="podPressFeedButtons-posts"><?php _e('Entries RSS Feed', 'podpress'); ?></label><br />
  722. <label for="podPressFeedButtons-posts_buttonurl"><?php _e('Button URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-posts_buttonurl" name="podPressFeedButtons-posts_buttonurl" class="widefat" value="<?php echo $options['posts_buttonurl']; ?>" /><br />
  723. <label for="podPressFeedButtons-posts_altfeedurl"><?php _e('Alternative Feed URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-posts_altfeedurl" name="podPressFeedButtons-posts_altfeedurl" class="widefat" value="<?php echo $options['posts_altfeedurl']; ?>" />
  724. </div>
  725. <h5><a href=""><?php _e('Comments RSS Feed', 'podpress'); ?></a></h5>
  726. <div>
  727. <input class="checkbox" type="checkbox" <?php echo $comments; ?> id="podPressFeedButtons-comments" name="podPressFeedButtons-comments" /> <label for="podPressFeedButtons-comments"><?php _e('Comments RSS Feed', 'podpress'); ?></label><br />
  728. <label for="podPressFeedButtons-posts_buttonurl"><?php _e('Button URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-comments_buttonurl" name="podPressFeedButtons-comments_buttonurl" class="widefat" value="<?php echo $options['comments_buttonurl']; ?>" /><br />
  729. <label for="podPressFeedButtons-posts_altfeedurl"><?php _e('Alternative Feed URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-comments_altfeedurl" name="podPressFeedButtons-comments_altfeedurl" class="widefat" value="<?php echo $options['comments_altfeedurl']; ?>" />
  730. </div>
  731. <h5><a href=""><?php _e('Entries ATOM Feed', 'podpress'); ?></a></h5>
  732. <div>
  733. <input class="checkbox" type="checkbox" <?php echo $entries_atom; ?> id="podPressFeedButtons-entries-atom" name="podPressFeedButtons-entries-atom" /> <label for="podPressFeedButtons-entries-atom"><?php _e('Entries ATOM Feed', 'podpress'); ?></label><br />
  734. <label for="podPressFeedButtons-posts_buttonurl"><?php _e('Button URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-entries-atom_buttonurl" name="podPressFeedButtons-entries-atom_buttonurl" class="widefat" value="<?php echo $options['entries-atom_buttonurl']; ?>" /><br />
  735. <label for="podPressFeedButtons-posts_altfeedurl"><?php _e('Alternative Feed URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-entries-atom_altfeedurl" name="podPressFeedButtons-entries-atom_altfeedurl" class="widefat" value="<?php echo $options['entries-atom_altfeedurl']; ?>" />
  736. </div>
  737. <h5><a href=""><?php _e('Comments ATOM Feed', 'podpress'); ?></a></h5>
  738. <div>
  739. <input class="checkbox" type="checkbox" <?php echo $comments_atom; ?> id="podPressFeedButtons-comments-atom" name="podPressFeedButtons-comments-atom" /> <label for="podPressFeedButtons-comments-atom"><?php _e('Comments ATOM Feed', 'podpress'); ?></label><br />
  740. <label for="podPressFeedButtons-posts_buttonurl"><?php _e('Button URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-comments-atom_buttonurl" name="podPressFeedButtons-comments-atom_buttonurl" class="widefat" value="<?php echo $options['comments-atom_buttonurl']; ?>" /><br />
  741. <label for="podPressFeedButtons-posts_altfeedurl"><?php _e('Alternative Feed URL:', 'podpress'); ?></label> <input type="text" id="podPressFeedButtons-comments-atom_altfeedurl" name="podPressFeedButtons-comments-atom_altfeedurl" class="widefat" value="<?php echo $options['comments-atom_altfeedurl']; ?>" />
  742. </div>
  743. <?php
  744. $query_string = 'SELECT option_name, option_value FROM '.$wpdb->prefix.'options WHERE INSTR(option_name, "podPress_category_")';
  745. $category_feeds = $wpdb->get_results($query_string);
  746. if ( isset($category_feeds) AND FALSE == empty($category_feeds) ) {
  747. foreach ($category_feeds as $feed_options) {
  748. $feed = maybe_unserialize($feed_options->option_value);
  749. if ( isset($feed['categoryCasting']) AND 'true' == $feed['categoryCasting'] ) {
  750. $cat_id = end(explode('_', $feed_options->option_name));
  751. $checked = $options['catcast'][$cat_id] ? 'checked="checked"' :'';
  752. echo '<h5><a href="">'.sprintf(__('Category "%1$s" RSS Feed', 'podpress'), get_cat_name($cat_id)).'</a></h5>'."\n";
  753. echo '<div>'."\n";
  754. echo '<input type="checkbox" '.$checked.' id="podPressFeedButtons-catcast_'.$cat_id.'_use" name="podPressFeedButtons-catcast['.$cat_id.'][use]" /> <label for="podPressFeedButtons-catcast_'.$cat_id.'_use">'.sprintf(__('Category "%1$s" RSS Feed', 'podpress'), get_cat_name($cat_id)).'</label><br />'."\n";
  755. echo '<label for="podPressFeedButtons-catcast_'.$cat_id.'_buttonurl">'.__('Button URL:', 'podpress').'</label> <input type="text" id="podPressFeedButtons-catcast_'.$cat_id.'_buttonurl" name="podPressFeedButtons-catcast['.$cat_id.'][buttonurl]" class="widefat" value="'.$options['podPressFeedButtons-catcast'][$cat_id]['buttonurl'].'" /><br />'."\n";
  756. echo '<label for="podPressFeedButtons-catcast_'.$cat_id.'_altfeedurl">'.__('Alternative Feed URL:', 'podpress').'</label> <input type="text" id="podPressFeedButtons-catcast_'.$cat_id.'_altfeedurl" name="podPressFeedButtons-catcast['.$cat_id.'][altfeedurl]" class="widefat" value="'.$options['podPressFeedButtons-catcast'][$cat_id]['altfeedurl'].'" />'."\n";
  757. echo '</div>'."\n";
  758. }
  759. }
  760. }
  761. ?>
  762. </div><!-- End: podPress Widget Accordion -->
  763. <p class="podpress_widget_settings_row"><?php _e('Show buttons or text?', 'podpress'); ?></p>
  764. <p><label for="podPressFeedButtons-buttons"><?php _e('Buttons', 'podpress'); ?></label> <input type="radio" <?php echo $buttons; ?> value="buttons" id="podPressFeedButtons-buttons" name="podPressFeedButtons-buttons-or-text" /> <input type="radio" <?php echo $text; ?> value="text" id="podPressFeedButtons-text" name="podPressFeedButtons-buttons-or-text" /> <label for="podPressFeedButtons-text"><?php _e('Text', 'podpress'); ?></label></p>
  765. <input type="hidden" id="podPressFeedButtons-submit" name="podPressFeedButtons-submit" value="1" />
  766. <?php
  767. }
  768. /* for WP < 2.8 only */
  769. function podPress_feedButtons ($args) {
  770. GLOBAL $podPress, $wp_version;
  771. extract($args);
  772. $options = get_option('widget_podPressFeedButtons');
  773. if ( version_compare( $wp_version, '2.2', '>=' ) ) { // the rss.png is in wp_includes since WP 2.2 (this is only necessary until the required WP version will be changed to e.g 2.3)
  774. $feed_icon = '<img src="'.get_option('siteurl') . '/' . WPINC . '/images/rss.png" class="podpress_feed_icon" alt="" />';
  775. } else {
  776. $feed_icon = apply_filters('podpress_legacy_support_feed_icon', '');
  777. }
  778. if(!isset($options['title'])) {
  779. $options['title'] = __('Podcast Feeds', 'podpress');
  780. } else {
  781. $options['title'] = stripslashes($options['title']);
  782. }
  783. if(!isset($options['blog'])) {
  784. $options['blog'] = false;
  785. }
  786. if(!isset($options['comments'])) {
  787. $options['comments'] = false;
  788. }
  789. if(!isset($options['entries-atom'])) {
  790. $options['entries-atom'] = false;
  791. }
  792. if(!isset($options['comments-atom'])) {
  793. $options['comments-atom'] = false;
  794. }
  795. if(!isset($options['itunes'])) {
  796. $options['itunes'] = true;
  797. }
  798. if (!isset($options['iprot'])) {
  799. $options['iprot'] = false;
  800. }
  801. if (!isset($options['buttons-or-text'])) {
  802. $options['buttons-or-text'] = 'buttons';
  803. }
  804. echo $before_widget;
  805. echo $before_title . $options['title'] . $after_title;
  806. echo '<ul class="podpress_feed_buttons_list">'."\n";
  807. switch ($options['buttons-or-text']) {
  808. default:
  809. case 'buttons' :
  810. if ($options['itunes']) {
  811. // for more info: http://www.apple.com/itunes/podcasts/specs.html#linking
  812. if ($options['iprot'] ) {
  813. echo ' <li><a href="itpc://'.preg_replace('/^https?:\/\//i', '', $podPress->settings['podcastFeedURL']).'"';
  814. } else {
  815. echo ' <li><a href="http://www.itunes.com/podcast?id='.$podPress->settings['iTunes']['FeedID'].'"';
  816. }
  817. if ( FALSE == empty($options['itunes_buttonurl']) ) {
  818. echo ' title="'.__('Subscribe to the Podcast Feed with iTunes', 'podpress').'"><img src="'.$options['itunes_buttonurl'].'" class="podpress_feed_buttons" alt="'.__('Subscribe with iTunes', 'podpress').'" /></a></li>'."\n";
  819. } else {
  820. echo ' title="'.__('Subscribe to the Podcast Feed with iTunes', 'podpress').'"><img src="'.podPress_url().'images/itunes.png" class="podpress_feed_buttons" alt="'.__('Subscribe with iTunes', 'podpress').'" /></a></li>'."\n";
  821. }
  822. }
  823. // podPress feeds:
  824. if ( is_array($options['podpressfeeds']) AND FALSE == empty($options['podpressfeeds']) ) {
  825. foreach ($options['podpressfeeds'] as $feed_slug => $feed_options) {
  826. if ( 'yes' === $feed_options['use'] AND is_array($podPress->settings['podpress_feeds']) ) {
  827. foreach ( $podPress->settings['podpress_feeds'] AS $feed ) {
  828. if ( $feed_slug === $feed['slug'] AND TRUE === $feed['use'] ) {
  829. if ( FALSE == empty($feed_options['altfeedurl']) ) {
  830. $feed_link = $feed_options['altfeedurl'];
  831. } else {
  832. $feed_link = get_feed_link($feed_slug);
  833. }
  834. if ( FALSE == empty($feed['slug']) ) {
  835. $descr = stripslashes($feed['descr']);
  836. } else {
  837. $descr = __('Subscribe to this Feed with any feed reader', 'podpress');
  838. }
  839. if ( FALSE == empty($feed_options['buttonurl']) ) {
  840. echo ' <li><a href="'.$feed_link.'" title="'.attribute_escape($descr).'"><img src="'.$feed_options['buttonurl'].'" class="podpress_feed_buttons" alt="'.attribute_escape(stripslashes($feed['name'])).'" /></a></li>'."\n";
  841. } else {
  842. echo ' <li><a href="'.$feed_link.'" title="'.attribute_escape($descr).'">'.$feed_icon.' '.stripslashes($feed['name']).'</a></li>'."\n";
  843. }
  844. }
  845. }
  846. }
  847. }
  848. }
  849. if($options['blog']) {
  850. if ( FALSE === empty($options['posts_altfeedurl']) ) {
  851. $feedlink = $options['posts_altfeedurl'];
  852. } else {
  853. $feedlink = get_bloginfo('rss2_url');
  854. }
  855. if ( FALSE == empty($options['posts_buttonurl']) ) {
  856. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the main RSS Feed with any feed reader', 'podpress').'"><img src="'.$options['posts_buttonurl'].'" class="podpress_feed_buttons" alt="'.__('Subscribe to the RSS Feed', 'podpress').'" /></a></li>'."\n";
  857. } else {
  858. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the main RSS Feed with any feed reader', 'podpress').'"><img src="'.podPress_url().'images/feed_button-rss-blog.png" class="podpress_feed_buttons" alt="'.__('Subscribe to the RSS Feed', 'podpress').'" /></a></li>'."\n";
  859. }
  860. }
  861. if($options['comments']) {
  862. if ( FALSE === empty($options['comments_altfeedurl']) ) {
  863. $feedlink = $options['comments_altfeedurl'];
  864. } else {
  865. $feedlink = get_bloginfo('comments_rss2_url');
  866. }
  867. if ( FALSE == empty($options['comments_buttonurl']) ) {
  868. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the comments RSS Feed with any feed reader', 'podpress').'"><img src="'.$options['comments_buttonurl'].'" class="podpress_feed_buttons" alt="'.__('Subscribe to the comments RSS Feed', 'podpress').'" /></a></li>'."\n";
  869. } else {
  870. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the comments RSS Feed with any feed reader', 'podpress').'"><img src="'.podPress_url().'images/feed_button-rss-comments.png" class="podpress_feed_buttons" alt="'.__('Subscribe to the comments RSS Feed', 'podpress').'" /></a></li>'."\n";
  871. }
  872. }
  873. if($options['entries-atom']) {
  874. if ( FALSE === empty($options['entries-atom_altfeedurl']) ) {
  875. $feedlink = $options['entries-atom_altfeedurl'];
  876. } else {
  877. $feedlink = get_bloginfo('atom_url');
  878. }
  879. if ( FALSE == empty($options['entries-atom_buttonurl']) ) {
  880. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the main ATOM Feed with any feed reader', 'podpress').'"><img src="'.$options['entries-atom_buttonurl'].'" class="podpress_feed_buttons" alt="'.__('Subscribe to the ATOM Feed', 'podpress').'" /></a></li>'."\n";
  881. } else {
  882. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the main ATOM Feed with any feed reader', 'podpress').'"><img src="'.podPress_url().'images/feed_button-atom-blog.png" class="podpress_feed_buttons" alt="'.__('Subscribe to the ATOM Feed', 'podpress').'" /></a></li>'."\n";
  883. }
  884. }
  885. if($options['comments-atom']) {
  886. if ( FALSE === empty($options['comments-atom_altfeedurl']) ) {
  887. $feedlink = $options['comments-atom_altfeedurl'];
  888. } else {
  889. $feedlink = get_bloginfo('comments_atom_url');
  890. }
  891. if ( FALSE == empty($options['comments-atom_buttonurl']) ) {
  892. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the comments ATOM Feed with any feed reader', 'podpress').'"><img src="'.$options['comments-atom_buttonurl'].'" class="podpress_feed_buttons" alt="'.__('Subscribe to the comments ATOM Feed', 'podpress').'" /></a></li>'."\n";
  893. } else {
  894. echo ' <li><a href="'.$feedlink.'" title="'.__('Subscribe to the comments ATOM Feed with any feed reader', 'podpress').'"><img src="'.podPress_url().'images/feed_button-atom-comments.png" class="podpress_feed_buttons" alt="'.__('Subscribe to the comments ATOM Feed', 'podpress').'" /></a></li>'."\n";
  895. }
  896. }
  897. if ( is_array($options['catcast']) AND FALSE == empty($options['catcast']) ) {
  898. foreach ($options['catcast'] as $cat_id => $catcast_options) {
  899. if ( 'yes' === $catcast_options['use'] ) {
  900. if ( FALSE == empty($catcast_options['altfeedurl']) ) {
  901. $cat_feed_link = $catcast_options['altfeedurl'];
  902. } else {
  903. if (TRUE == version_compare($wp_version, '2.9.3','>') ) {
  904. $cat_feed_link = get_term_feed_link($cat_id);
  905. } elseif ( TRUE == version_compare($wp_version, '2.9.3','<=') AND TRUE == version_compare($wp_version, '2.4','>') ) {
  906. $cat_feed_link = get_category_feed_link($cat_id);
  907. } else {
  908. $cat_feed_link = get_option('siteurl').'/?feed=rss2&cat='.$cat_id;
  909. }
  910. }
  911. if ( FALSE == empty($catcast_options['buttonurl']) ) {
  912. echo ' <li><a href="'.$cat_feed_link.'" title="'.__('Subscribe to this Category RSS Feed with any feed reader', 'podpress').'"><img src="'.$catcast_options['buttonurl'].'" class="podpress_feed_buttons" alt="'.attributes_escape(sprintf(__('Category "%1$s" RSS Feed', 'podpress'), get_cat_name($cat_id))).'" /></a></li>'."\n";
  913. } else {
  914. echo ' <li><a href="'.$cat_feed_link.'" title="'.__('Subscribe to this Category RSS Feed with any feed reader', 'podpress').'">'.$feed_icon.' '.sprintf(__('Category "%1$s" RSS Feed', 'podpress'), get_cat_name($cat_id)).'</a></li>'."\n";
  915. }
  916. }
  917. }
  918. }
  919. break;
  920. case 'text' :
  921. if ($options['itunes']) {
  922. // for more info: http://www.apple.com/itunes/podcasts/specs.html#linking
  923. if ($options['iprot'] ) {
  924. echo ' <li><a href="itpc://'.preg_replace('/^https?:\/\//i', '', $podPress->settings['podcastFeedURL']).'"';
  925. } else {
  926. echo ' <li><a href="http://www.itunes.com/podcast?id='.$podPress->settings['iTunes']['FeedID'].'"';
  927. }
  928. echo ' title="'.__('Subscribe to the Podcast Feed with iTunes', 'podpress').'">'.$feed_icon.' '.__('Subscribe with iTunes', 'podpress').'</a></li>'."\n";
  929. }
  930. // podPress feeds:
  931. if ( is_array($options['podpressfeeds']) AND FALSE == empty($options['podpressfeeds']) ) {
  932. foreach ($options['podpressfeeds'] as $feed_slug => $feed_options) {
  933. if ( 'yes' === $feed_options['use'] AND is_array($podPress->settings['podpress_feeds']) ) {
  934. foreach ( $podPress->set

Large files files are truncated, but you can click here to view the full file