PageRenderTime 61ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/blog/wp-content/plugins/podpress/podpress.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 1183 lines | 864 code | 87 blank | 232 comment | 275 complexity | 55ad30a36200f98aecd27531257d2b3d MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1

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

  1. <?php
  2. define('PODPRESS_VERSION', '8.8.9.2 RC 5');
  3. /*
  4. Info for WordPress:
  5. ==============================================================================
  6. Plugin Name: podPress
  7. Version: 8.8.9.2 RC 5
  8. Plugin URI: http://www.mightyseek.com/podpress/
  9. Description: The podPress plugin gives you everything you need in one easy plugin to use WordPress for Podcasting. Set it up in <a href="admin.php?page=podpress/podpress_feed.php">'podPress'->Feed/iTunes Settings</a>. If this plugin works for you, send us a comment.
  10. Author: Dan Kuykendall (Seek3r)
  11. Author URI: http://www.mightyseek.com/
  12. Min WP Version: 2.1
  13. Max WP Version: 3.0.4
  14. podPress - Podcasting made easy for WordPress
  15. ==============================================================================
  16. This plugin makes it much easier and organized to use WordPress for Podcasting.
  17. The plugin was created as a way for me to merge Garrick Van Buren's WP-iPodCatter
  18. and Martin Laine's Audio Player with some hacks I made to WordPress 2.0.
  19. I had tweaked the player to have the [audio:filename.mp3] entry to drive the
  20. whole podcasting need. In the rss2.php I had tweaked it to generate the
  21. enclosure tag from it. So thats how the plugin took birth, and I have been adding
  22. features to make the process cleaner over time.
  23. Feel free to visit my website under www.mightyseek.com or contact me at
  24. dan [at] kuykendall [dot] org
  25. Have fun!
  26. Installation:
  27. ==============================================================================
  28. 1. Upload the full directory into your wp-content/plugins directory
  29. 2. Activate it in the Plugin options
  30. 3. Edit or publish a post or click on Rebuild Sitemap on the Sitemap Administration Interface
  31. Contributors:
  32. ==============================================================================
  33. Developer Dan Kuykendall (seek3r) http://www.mightyseek.com/
  34. Developer David Maciejewski (macx) http://www.macx.de/
  35. Forum Support/BugBoy Jeff Norris (iscfi) http://www.iscifi.tv/
  36. Maintenance / Development 2010 Tim Berger (ntm) http://undeuxoutrois.de/
  37. WP Audio Player Martin Laine http://www.1pixelout.net/
  38. WP-iPodCatter Garrick Van Buren http://garrickvanburen.com/
  39. Thanks to all contributors and bug reporters!
  40. If you discover a problem with this plugin then report it in the WP.org "Plugins and Hacks" forum (http://wordpress.org/tags/podpress?forum_id=10) and tag your post with the tag "podpress".
  41. Release History:
  42. ==============================================================================
  43. Instead of maintaining the history in here, I'm just going to maintain it at
  44. http://wordpress.org/extend/plugins/podpress/changelog/
  45. or
  46. http://www.mightyseek.com/podpress/changelog/
  47. License:
  48. ==============================================================================
  49. Copyright 2006 Dan Kuykendall (email : dan@kuykendall.org)
  50. This program is free software; you can redistribute it and/or modify
  51. it under the terms of the GNU General Public License as published by
  52. the Free Software Foundation; either version 2 of the License, or
  53. (at your option) any later version.
  54. This program is distributed in the hope that it will be useful,
  55. but WITHOUT ANY WARRANTY; without even the implied warranty of
  56. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  57. GNU General Public License for more details.
  58. You should have received a copy of the GNU General Public License
  59. along with this program; if not, write to the Free Software
  60. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-107 USA
  61. */
  62. // Pre-2.6 compatibility
  63. if ( ! defined( 'WP_CONTENT_URL' ) ) { define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); }
  64. if ( ! defined( 'WP_CONTENT_DIR' ) ) { define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); }
  65. if ( ! defined( 'WP_PLUGIN_URL' ) ) { define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' ); }
  66. if ( ! defined( 'WP_PLUGIN_DIR' ) ) { define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); }
  67. if ( ! defined( 'PODPRESS_URL' ) ) { define( 'PODPRESS_URL', WP_PLUGIN_URL.'/'.dirname(plugin_basename(__FILE__)) ); }
  68. if ( ! defined( 'PODPRESS_DIR' ) ) { define( 'PODPRESS_DIR', WP_PLUGIN_DIR.'/'.dirname(plugin_basename(__FILE__)) ); }
  69. // the folder for config file for podPress like podpress_xspf_config.php
  70. if ( ! defined( 'PODPRESS_OPTIONS_URL' ) ) { define( 'PODPRESS_OPTIONS_URL', WP_PLUGIN_URL.'/podpress_options' ); }
  71. if ( ! defined( 'PODPRESS_OPTIONS_DIR' ) ) { define( 'PODPRESS_OPTIONS_DIR', WP_PLUGIN_DIR.'/podpress_options' ); }
  72. // These two lines are old and could be replaced by the definitions above if the the code will be changed to the new constants above which should provide more indepence of the plugin folder name.
  73. if (!defined('PLUGINDIR')) { define('PLUGINDIR', 'wp-content/plugins'); }
  74. if (!defined('PODPRESSPLUGINDIR')) { define('PODPRESSPLUGINDIR', ABSPATH.PLUGINDIR); }
  75. // to (de-)activate the Podango Integration (default: FALSE) - Leave this feature deactivated because the Podango platform and all coresponding feature are offline for a long time (since end of 2008) now.
  76. if ( ! defined( 'PODPRESS_ACTIVATE_PODANGO_INTEGRATION' ) ) { define( 'PODPRESS_ACTIVATE_PODANGO_INTEGRATION', FALSE ); }
  77. // to (de-)activate the 3rd party stats "feature" (default: FALSE)
  78. if ( ! defined( 'PODPRESS_ACTIVATE_3RD_PARTY_STATS' ) ) { define( 'PODPRESS_ACTIVATE_3RD_PARTY_STATS', FALSE ); }
  79. // You can log some of the procedures of podPress if you define this constant as true. The log file is podpress_log.dat.
  80. if ( ! defined( 'PODPRESS_DEBUG_LOG' ) ) { define( 'PODPRESS_DEBUG_LOG', FALSE ); }
  81. // maximum number of the additional podPress Feeds
  82. if ( ! defined( 'PODPRESS_FEEDS_MAX_NUMBER' ) ) { define( 'PODPRESS_FEEDS_MAX_NUMBER', 5 ); }
  83. // #### podPress INIT ####
  84. // some things like the widgets need be initiated before init see http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_an_Admin_Page_Request
  85. add_action('plugins_loaded', 'podPress_init');
  86. add_action('init', 'podPress_class_init');
  87. // #### podPress INIT ####
  88. /**
  89. * podPress_init - all intializing actions which needs to be executed before the WP init Action Hook (Widget init)
  90. *
  91. * @package podPress
  92. * @since 8.8.8.6
  93. */
  94. function podPress_init() {
  95. GLOBAL $podPress, $wp_version, $podPress_memoryUsage, $podPress_memoryIncrease, $podPress_feedHooksAdded;
  96. $podPress_memoryUsage = array();
  97. $podPress_memoryIncrease = 0;
  98. $podPress_feedHooksAdded = false;
  99. $GLOBALS['podPressPlayer'] = 0; // Global counter of Players
  100. // Begin - import the XSPF Jukebox player configuration:
  101. // If you want to use custom skins for the XSPF players then edit the podpress_xspf_config-sample.php file and rename it to podpress_xspf_config.php, create a folder called podpress_options as a sub folder of the plugins folder e.g. /wp-content/plugins/podpress_options and copy this file to this folder.
  102. if (is_file(PODPRESS_OPTIONS_DIR.'/podpress_xspf_config.php')) {
  103. require_once(PODPRESS_OPTIONS_DIR.'/podpress_xspf_config.php');
  104. }
  105. // End - import the XSPF Jukebox player configuration
  106. if ( function_exists('load_plugin_textdomain') ) {
  107. if ( version_compare( $wp_version, '2.7', '>=' ) ) {
  108. load_plugin_textdomain( 'podpress', false, str_replace(WP_PLUGIN_DIR, '', PODPRESS_DIR.'/languages/') );
  109. } else {
  110. load_plugin_textdomain( 'podpress', PODPRESS_DIR.'/languages/' );
  111. }
  112. }
  113. if (!class_exists('podPress_class')) {
  114. require_once(PODPRESS_DIR.'/podpress_class.php');
  115. podPress_checkmem('podPress base class included');
  116. require_once(PODPRESS_DIR.'/podpress_functions.php');
  117. podPress_checkmem('podPress functions loaded');
  118. if($podPress_x = @parse_url($_SERVER['REQUEST_URI'])) {
  119. $podPress_x = $podPress_x['path'];
  120. if (strpos($podPress_x, 'crossdomain.xml')) {
  121. podPress_crossdomain();
  122. } elseif ($pos = strpos($podPress_x, 'podpress_trac')) {
  123. /* short circut the loading process for a simple redirect */
  124. podPress_checkmem('standard podPress class loaded', true);
  125. $podPress = new podPress_class;
  126. podPress_checkmem('standard podPress class loaded');
  127. podPress_statsDownloadRedirect($podPress_x);
  128. exit;
  129. }
  130. unset($podPress_x);
  131. }
  132. $customThemeFile = get_template_directory().'/podpress_theme.php';
  133. if(file_exists($customThemeFile)) {
  134. require_once($customThemeFile);
  135. podPress_checkmem('podPress custom theme file loaded');
  136. }
  137. require_once(PODPRESS_DIR.'/podpress_theme.php');
  138. podPress_checkmem('podPress core theme file loaded');
  139. if ( TRUE == isset($_GET['podpress_showmem']) AND 1 === $_GET['podpress_showmem'] ) {
  140. echo __('PHP has a memory_limit set to:', 'podpress').' '.ini_get('memory_limit').'<br/>';
  141. }
  142. podPress_checkmem('podPress start');
  143. if(file_exists(ABSPATH.PLUGINDIR.'/podpress.php')) {
  144. echo __('It appears you are upgrading podPress, but left the pre-4.x version of podpress.php file in the plugins directory. Please delete this file to continue.', 'podpress');
  145. exit;
  146. }
  147. }
  148. /* Widgets */
  149. if ( TRUE == version_compare($wp_version, '2.8', '>=') ) {
  150. // ntm: using the "new" Widget API
  151. add_action('widgets_init', create_function('', 'return register_widget("podpress_feedbuttons");'));
  152. add_action('widgets_init', create_function('', 'return register_widget("podpress_xspfplayer");'));
  153. } else {
  154. add_action('widgets_init', 'podPress_loadWidgets');
  155. }
  156. }
  157. /**
  158. * podPress_class_init - all intializing actions which should be executed after the WP init Action Hook / initiates the $podPress object
  159. *
  160. * @package podPress
  161. * @since 8.8.8.6
  162. */
  163. function podPress_class_init() {
  164. GLOBAL $podPress, $wp_version, $wp_importers;
  165. /*************************************************************/
  166. /* Create the podPress object */
  167. /*************************************************************/
  168. if ( FALSE == isset($podPress) OR FALSE == is_object($podPress) ) {
  169. $podpress_version_from_db = get_option('podPress_version');
  170. if ( FALSE === $podpress_version_from_db ) {
  171. // if the podPress version is not in the db then start the upgrade mechanism
  172. $podPress_inUpgrade = true;
  173. } else {
  174. if ( TRUE === version_compare($podpress_version_from_db, PODPRESS_VERSION, '<') ) {
  175. $podPress_inUpgrade = true;
  176. } else {
  177. $podPress_inUpgrade = false;
  178. }
  179. }
  180. if ($podPress_inUpgrade) {
  181. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_upgrade_class.php');
  182. podPress_checkmem('podpress upgrade class loaded');
  183. $podPress = new podPress_class();
  184. $podPress = $podPress->update_podpress_class($podpress_version_from_db);
  185. }
  186. if ( TRUE == is_admin() ) {
  187. podPress_checkmem('podpress admin functions loaded', true);
  188. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_functions.php');
  189. podPress_checkmem('podpress admin functions loaded');
  190. if(isset($_GET['page'])) {
  191. $podPress_adminPage = $_GET['page'];
  192. } elseif(isset($_POST['podPress_submitted'])) {
  193. $podPress_adminPage = 'podpress/podpress_'.$_POST['podPress_submitted'].'.php';
  194. } else {
  195. $podPress_adminPage = 'usedefault';
  196. }
  197. switch($podPress_adminPage) {
  198. case 'podpress/podpress_general.php':
  199. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_general_class.php');
  200. podPress_checkmem('admin general code loaded');
  201. break;
  202. case 'podpress/podpress_feed.php':
  203. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_feed_class.php');
  204. podPress_checkmem('admin feed code loaded');
  205. break;
  206. case 'podpress/podpress_players.php':
  207. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_player_class.php');
  208. podPress_checkmem('admin player code loaded');
  209. break;
  210. case 'podpress/podpress_stats.php':
  211. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_stats_class.php');
  212. podPress_checkmem('admin stats code loaded');
  213. break;
  214. case 'podpress/podpress_podango.php':
  215. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_podango_class.php');
  216. podPress_checkmem('admin podango code loaded');
  217. break;
  218. default:
  219. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_admin_class.php');
  220. podPress_checkmem('admin code loaded');
  221. break;
  222. }
  223. $podPress = new podPressAdmin_class();
  224. if($podPress->settings['enablePodangoIntegration']) {
  225. podPress_checkmem('PodangoAPI code loaded', true);
  226. require_once(ABSPATH.PLUGINDIR.'/podpress/podango-api.php');
  227. $podPress->podangoAPI = new PodangoAPI ($podPress->settings['podangoUserKey'], $podPress->settings['podangoPassKey']);
  228. if(!empty($podPress->settings['podangoDefaultPodcast'])) {
  229. $podPress->podangoAPI->defaultPodcast = $podPress->settings['podangoDefaultPodcast'];
  230. }
  231. if(!empty($podPress->settings['podangoDefaultTranscribe'])) {
  232. $podPress->podangoAPI->defaultTranscribe = (int)$podPress->settings['podangoDefaultTranscribe'];
  233. }
  234. podPress_checkmem('PodangoAPI code loaded');
  235. }
  236. } else {
  237. podPress_checkmem('standard podPress class loaded', true);
  238. $podPress = new podPress_class;
  239. podPress_checkmem('standard podPress class loaded');
  240. }
  241. }
  242. /*************************************************************/
  243. /* Register all the actions and filters */
  244. /*************************************************************/
  245. /* Add podpress data to each post */
  246. if(!podPress_WPVersionCheck()) {
  247. // WP 1.5 legacy vars support
  248. if(isset($table_prefix) && !isset($wpdb->prefix)) {
  249. $wpdb->prefix = $table_prefix;
  250. }
  251. if(isset($tablecomments) && !isset($wpdb->comments)) {
  252. $wpdb->comments = $tablecomments;
  253. }
  254. }
  255. add_action( 'pre_get_posts', 'podPress_feed_content_filtering' );
  256. /* Add podpress data to each post */
  257. if ( TRUE == version_compare($wp_version, '2.0.0', '<') ) {
  258. //~ if (podPress_WPVersionCheck()) {
  259. add_action('the_posts', array(&$podPress, 'the_posts'));
  260. } else {
  261. add_filter('the_posts', array(&$podPress, 'the_posts'));
  262. }
  263. // ntm: where is do_action('xmlrpc-mw_ ?
  264. add_action('xmlrpc-mw_newPost', array(&$podPress, 'xmlrpc_post_addMedia'));
  265. add_action('xmlrpc-mw_editPost', array(&$podPress, 'xmlrpc_post_addMedia'));
  266. add_filter('posts_join', array(&$podPress, 'posts_join'));
  267. add_filter('posts_where', array(&$podPress, 'posts_where'));
  268. /* stuff that goes in the display of the Post */
  269. add_filter('the_content', array(&$podPress, 'insert_content'));
  270. add_filter('get_the_excerpt', array(&$podPress, 'insert_the_excerpt'), 1);
  271. add_filter('the_excerpt', array(&$podPress, 'insert_the_excerptplayer'));
  272. add_filter('get_attached_file', 'podPress_get_attached_file');
  273. add_filter('wp_get_attachment_metadata', 'podPress_wp_get_attachment_metadata');
  274. /* stuff that goes in the HTML header */
  275. if ( TRUE == version_compare($wp_version, '2.7', '>=') ) {
  276. if (FALSE === is_admin()) {
  277. add_action('wp_print_scripts', 'podpress_print_frontend_js');
  278. add_action('wp_print_styles', 'podpress_print_frontend_css');
  279. }
  280. } else {
  281. add_action('wp_head', 'podPress_wp_head');
  282. }
  283. add_action('wp_footer', 'podPress_wp_footer');
  284. add_action('switch_theme', 'podPress_switch_theme');
  285. /* misc stuff */
  286. // the dashboard widget:
  287. if ( TRUE === $podPress->settings['enableStats'] ) {
  288. if ( (TRUE == isset($podPress->settings['disabledashboardwidget']) AND FALSE === $podPress->settings['disabledashboardwidget']) OR FALSE == isset($podPress->settings['disabledashboardwidget']) ) {
  289. if ( TRUE == version_compare($wp_version, '2.7', '>=') ) { // for WP >= 2.7 add the stats overview as a dashboard widget
  290. add_action('wp_dashboard_setup', 'podpress_wp_dashboard_setup');
  291. } else { // for older versions via the activity_box_end hook
  292. add_action('activity_box_end', 'podPress_activity_box');
  293. }
  294. }
  295. add_action('template_redirect', 'podPress_statsDownloadRedirect');
  296. }
  297. add_filter('get_the_guid', 'podPress_get_the_guid');
  298. /* stuff that goes into all feeds */
  299. // ntm: that seems to be unnecessary because that function is called in every do_feed function (see above)
  300. //~ if(is_feed()) {
  301. //~ podPress_addFeedHooks();
  302. //~ }
  303. /* stuff for premium podcasts */
  304. if ( isset($podPress->settings['enablePremiumContent']) AND TRUE === $podPress->settings['enablePremiumContent'] ) {
  305. require_once(ABSPATH.PLUGINDIR.'/podpress/podpress_premium_functions.php');
  306. podPress_checkmem('premium functions included');
  307. add_action('wp_login', 'podpress_adddigestauth');
  308. }
  309. /* stuff that goes into setting up the site for podpress */
  310. if ( TRUE === is_admin() ) {
  311. add_action('activate_podpress/podpress.php', array(&$podPress, 'activate'));
  312. add_action('deactivate_podpress/podpress.php', array(&$podPress, 'deactivate'));
  313. /* if this is an admin page, run the function to add podpress tab to options menu */
  314. if ( TRUE == version_compare($wp_version, '2.7', '>=') ) {
  315. add_action('admin_print_scripts', 'podpress_print_admin_js');
  316. add_action('admin_print_scripts-podpress/podpress_stats.php', 'podpress_print_admin_statistics_js');
  317. add_action('admin_print_styles', 'podpress_print_admin_css');
  318. add_action('admin_print_styles-podpress/podpress_stats.php', 'podpress_print_admin_statistics_css');
  319. add_action('admin_print_styles-index.php', 'podpress_print_admin_statistics_css');
  320. } else {
  321. add_action('admin_head', 'podPress_print_admin_js_and_css_old_wp');
  322. }
  323. add_action('admin_head', 'podPress_admin_head');
  324. add_action('admin_menu', 'podPress_add_menu_page');
  325. add_action('admin_footer', 'podPress_admin_footer');
  326. /* Adds a custom section to the "advanced" Post and Page edit screens */
  327. if ( TRUE == version_compare($wp_version, '2.5', '>=') ) {
  328. add_action('admin_menu', 'add_podpress_form_box_for_modern_wp');
  329. } else {
  330. add_action('simple_edit_form', array(&$podPress, 'post_form'));
  331. add_action('edit_form_advanced', array(&$podPress, 'post_form'));
  332. add_action('edit_page_form', array(&$podPress, 'page_form'));
  333. }
  334. add_action('save_post', array(&$podPress, 'post_edit'));
  335. /* stuff that goes in the category */
  336. add_action('create_category', array(&$podPress, 'edit_category'));
  337. add_action('edit_category_form', array(&$podPress, 'edit_category_form'));
  338. add_action('edit_category', array(&$podPress, 'edit_category'));
  339. //add_action('delete_category', array(&$podPress, 'delete_category'));
  340. /* stuff for editing settings */
  341. // ntm: saving the settings of the settings pages of podPress
  342. if(isset($_POST['podPress_submitted']) && method_exists($podPress, 'settings_'.$_POST['podPress_submitted'].'_save')) {
  343. $funcnametouse = 'settings_'.$_POST['podPress_submitted'].'_save';
  344. $podPress->$funcnametouse();
  345. }
  346. // ntm: there is no importer function ('import_dispatch') in the podPress files
  347. // $wp_importers['podcast'] = array (__('Podcast RSS2', 'podpress'), __('podPress import of posts from a Podcast RSS2 feed.', 'podpress'), array(&$podPress, 'import_dispatch'));
  348. // if(function_exists('register_importer')) {
  349. // register_importer('podcast', __('Podcast RSS2'), __('Import posts from an RSS2 Podcast feed'), array (&$podPress, 'import_dispatch'));
  350. // }
  351. }
  352. if ( function_exists('add_feed') ) {
  353. if ( is_array($podPress->settings['podpress_feeds']) AND FALSE == empty($podPress->settings['podpress_feeds']) ) {
  354. foreach ($podPress->settings['podpress_feeds'] as $feed) {
  355. if ( TRUE === $feed['use'] AND FALSE == empty($feed['slug']) ) {
  356. add_feed($feed['slug'], 'podPress_do_dyn_podcast_feed');
  357. }
  358. }
  359. }
  360. add_feed('playlist.xspf', 'podPress_do_feed_xspf');
  361. }
  362. remove_action('do_feed_rss', 'do_feed_rss', 10, 1);
  363. add_action('do_feed_rss', 'podPress_do_dyn_podcast_feed', 1, 1);
  364. add_action('do_feed_rss2', 'podPress_do_dyn_podcast_feed', 1, 1);
  365. remove_action('do_feed_atom', 'do_feed_atom', 10, 1);
  366. add_action('do_feed_atom', 'podPress_do_dyn_podcast_feed', 1, 1);
  367. // ntm: that seems to be unnecessary because that function is called in every do_feed function (see above)
  368. // and $podPress->feed_getCategory(); seems not to exist
  369. //if ( is_feed() ) {
  370. //podPress_addFeedHooks();
  371. //$podPress->feed_getCategory();
  372. //}
  373. }
  374. function podPress_add_menu_page() {
  375. GLOBAL $podPress, $wp_version;
  376. if(podPress_WPVersionCheck('2.0.0')) {
  377. $permission_needed = $podPress->requiredAdminRights;
  378. } else {
  379. $permission_needed = 1;
  380. }
  381. if (function_exists('add_menu_page')) {
  382. if($podPress->settings['enableStats'] == true) {
  383. $starting_point = 'podpress_stats';
  384. } else {
  385. $starting_point = 'podpress_feed';
  386. }
  387. if ( version_compare( $wp_version, '2.7', '>=' ) ) {
  388. $menutitle = __('podPress', 'podpress');
  389. add_menu_page('podPress', $menutitle, $permission_needed, 'podpress/'.$starting_point.'.php', '', PODPRESS_URL.'/images/podpress_icon_r2_v2_16.png');
  390. } else {
  391. add_menu_page('podPress', 'podPress', $permission_needed, 'podpress/'.$starting_point.'.php');
  392. }
  393. }
  394. if (function_exists('add_submenu_page')) {
  395. if($podPress->settings['enableStats'] == true) {
  396. $starting_point = 'podpress_stats';
  397. } else {
  398. $starting_point = 'podpress_feed';
  399. }
  400. if($podPress->settings['enableStats'] == true) {
  401. add_submenu_page('podpress/'.$starting_point.'.php', __('podPress - Statistics', 'podpress'), __('Statistics', 'podpress'), $permission_needed, 'podpress/podpress_stats.php');
  402. }
  403. add_submenu_page('podpress/'.$starting_point.'.php', __('podPress - Feed/iTunes Settings', 'podpress'), __('Feed/iTunes Settings', 'podpress'), $permission_needed, 'podpress/podpress_feed.php');
  404. add_submenu_page('podpress/'.$starting_point.'.php', __('podPress - General Settings', 'podpress'), __('General Settings', 'podpress'), $permission_needed, 'podpress/podpress_general.php');
  405. if($podPress->settings['contentPlayer'] != 'disabled') {
  406. add_submenu_page('podpress/'.$starting_point.'.php', __('podPress - Player Settings', 'podpress'), __('Player Settings', 'podpress'), $permission_needed, 'podpress/podpress_players.php');
  407. }
  408. if($podPress->settings['enablePodangoIntegration'] == true) {
  409. add_submenu_page('podpress/'.$starting_point.'.php', __('podPress - Podango Settings', 'podpress'), __('Podango Settings', 'podpress'), $permission_needed, 'podpress/podpress_podango.php');
  410. }
  411. }
  412. }
  413. function podPress_switch_theme() {
  414. GLOBAL $podPress;
  415. $podPress->settings['compatibilityChecks']['themeTested'] = false;
  416. $podPress->settings['compatibilityChecks']['wp_head'] = false;
  417. $podPress->settings['compatibilityChecks']['wp_footer'] = false;
  418. podPress_update_option('podPress_config', $podPress->settings);
  419. }
  420. // for WP 2.7+
  421. function podpress_print_frontend_js() {
  422. wp_register_script( 'podpress_frontend_script', PODPRESS_URL.'/js/podpress.js' );
  423. wp_enqueue_script( 'podpress_frontend_script' );
  424. // ntm: this way of loading a localized JS scripts is probably not very elegant but it works in WP version older than 2.3
  425. // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used.
  426. require_once(PODPRESS_DIR.'/podpress_js_i18.php');
  427. podpress_print_localized_frontend_js_vars();
  428. podpress_print_js_vars();
  429. }
  430. // for WP 2.7+
  431. function podpress_print_frontend_css() {
  432. if (file_exists(get_template_directory().'/podpress.css')) {
  433. wp_register_style( 'podpress_frontend_styles', get_template_directory_uri().'/podpress.css' );
  434. } else {
  435. wp_register_style( 'podpress_frontend_styles', PODPRESS_URL.'/podpress.css' );
  436. }
  437. wp_enqueue_style( 'podpress_frontend_styles' );
  438. }
  439. // for WP version < 2.7
  440. function podPress_wp_head() {
  441. // frontend header
  442. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/podpress.js"></script>'."\n";
  443. // ntm: this way of loading a localized Js scripts is probably not very elegant but it works in WP version older than 2.3
  444. // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used.
  445. require_once(PODPRESS_DIR.'/podpress_js_i18.php');
  446. podpress_print_localized_frontend_js_vars();
  447. podpress_print_js_vars();
  448. if (file_exists(get_template_directory().'/podpress.css')) {
  449. echo '<link rel="stylesheet" href="'.get_template_directory_uri().'/podpress.css" type="text/css" />'."\n";
  450. } else {
  451. echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/podpress.css" type="text/css" />'."\n";
  452. }
  453. }
  454. // the dashboard widget for all WP versions
  455. function podPress_activity_box() {
  456. GLOBAL $podPress, $wpdb, $wp_version;
  457. if ( TRUE === $podPress->settings['enableStats'] ) {
  458. if ( TRUE == version_compare($wp_version, '2.8', '>=') ) {
  459. // get the plugins version information via the WP plugins version check
  460. if ( TRUE == version_compare($wp_version, '2.9', '>=') ) {
  461. $versioninfo = get_site_transient( 'update_plugins' );
  462. } else {
  463. $versioninfo = get_transient( 'update_plugins' );
  464. }
  465. // If there is a new version then there is a 'response'. This is the method from the plugins page.
  466. if ( FALSE !== isset($versioninfo->response[plugin_basename(__FILE__)]->new_version) ) {
  467. echo '<p class="message updated"><a href="http://wordpress.org/extend/plugins/podpress/" target="_blank">'.__('a new podPress version is available', 'podpress').'</a></p>';
  468. }
  469. } else {
  470. // in older versions use the old version check
  471. if ( TRUE == version_compare($wp_version, '2.7', '>=') ) {
  472. echo '<a href="http://www.mightyseek.com/podpress/#download" target="_new"><img src="http://www.mightyseek.com/podpress_downloads/versioncheck.php?current='.PODPRESS_VERSION.'" alt="'.__('Checking for updates... Failed', 'podpress').'" border="0" /></a>'."\n";
  473. } else {
  474. echo '<h3>podPress&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.mightyseek.com/podpress/#download" target="_new"><img src="http://www.mightyseek.com/podpress_downloads/versioncheck.php?current='.PODPRESS_VERSION.'" alt="'.__('Checking for updates... Failed', 'podpress').'" border="0" /></a></h3>'."\n";
  475. }
  476. }
  477. if($podPress->settings['statLogging'] == 'Full' || $podPress->settings['statLogging'] == 'FullPlus') {
  478. $where = $podPress->wherestr_to_exclude_bots();
  479. $query_string="SELECT method, COUNT(DISTINCT id) as downloads FROM ".$wpdb->prefix."podpress_stats ".$where."GROUP BY method ORDER BY method ASC";
  480. $stats = $wpdb->get_results($query_string);
  481. echo ' <fieldset><legend>'.sprintf(__('Statistics Summary (%1$s/%2$s)', 'podpress'), __('Full', 'podpress'),__('Full+', 'podpress')).'</legend>'."\n";
  482. if (0 < count($stats)) {
  483. $feed = intval($stats[0]->downloads);
  484. $play = intval($stats[1]->downloads);
  485. $web = intval($stats[2]->downloads);
  486. $total = $feed + $web + $play;
  487. echo ' <table class="the-list-x podpress_statistics_summary_table">'."\n";
  488. echo ' <thead><tr><th>'.__('Feed', 'podpress').'</th><th>'.__('Web', 'podpress').'</th><th>'.__('Play', 'podpress').'</th><th>'.__('Total', 'podpress').'</th></tr></thead>'."\n";
  489. echo ' <tbody><tr><td>'.$feed.'</td><td>'.$web.'</td><td>'.$play.'</td><td>'.$total.'</td></tr></tbody>'."\n";
  490. echo ' </table>'."\n";
  491. } else {
  492. echo '<p>'.__('No downloads yet.','podpress').'</p>';
  493. }
  494. echo ' </fieldset>'."\n";
  495. } else {
  496. $sql = "SELECT SUM(total) as cnt_total, SUM(feed) as cnt_feed, SUM(web) as cnt_web, SUM(play) as cnt_play FROM ".$wpdb->prefix."podpress_statcounts";
  497. $stats = $wpdb->get_results($sql);
  498. if($stats) {
  499. echo ' <fieldset><legend>'.__('Statistics Summary', 'podpress').'</legend>'."\n";
  500. echo ' <table class="the-list-x podpress_statistics_summary_table">'."\n";
  501. echo ' <thead><tr><th>'.__('Feed', 'podpress').'</th><th>'.__('Web', 'podpress').'</th><th>'.__('Play', 'podpress').'</th><th>'.__('Total', 'podpress').'</th></tr></thead>'."\n";
  502. echo ' <tbody><tr><td>'.intval($stats[0]->cnt_feed).'</td><td>'.intval($stats[0]->cnt_web).'</td><td>'.intval($stats[0]->cnt_play).'</td><td>'.intval($stats[0]->cnt_total).'</td></tr></tbody>'."\n";
  503. echo ' </table></fieldset>'."\n";
  504. }
  505. }
  506. }
  507. }
  508. // adds the dasboard widget for WP >= 2.7
  509. function podpress_wp_dashboard_setup() {
  510. wp_add_dashboard_widget( 'podpress_wp_dashboard_widget', __('podPress Stats', 'podpress'), 'podPress_activity_box' );
  511. }
  512. // for WP 2.7+
  513. function podpress_print_admin_statistics_js() {
  514. wp_register_script( 'podpress_admin_statistics_script', PODPRESS_URL.'/js/podpress_admin_statistics.js' );
  515. wp_enqueue_script( 'podpress_admin_statistics_script' );
  516. }
  517. // for WP 2.7+
  518. function podpress_print_admin_statistics_css() {
  519. wp_register_style( 'podpress_admin_statistics_styles', PODPRESS_URL.'/podpress_admin_statistics.css' );
  520. wp_enqueue_style( 'podpress_admin_statistics_styles' );
  521. }
  522. // for WP 2.7+
  523. function podpress_print_admin_js() { // ntm: some of these scripts are not necessary on all admin pages
  524. GLOBAL $pagenow, $wp_version;
  525. $page_with_podPress = Array('post.php', 'page.php', 'post-new.php', 'page-new.php', 'categories.php', 'admin.php', 'edit-tags.php');
  526. if ( in_array($pagenow, $page_with_podPress) ) {
  527. wp_register_script( 'podpress_js', PODPRESS_URL.'/js/podpress.js' );
  528. wp_register_script( 'podpress_admin_js', PODPRESS_URL.'/js/podpress_admin.js' );
  529. wp_enqueue_script( 'podpress_js' );
  530. wp_enqueue_script( 'podpress_admin_js' );
  531. // ntm: this way of loading a localized Js scripts is probably not very elegant but it works in WP version older than 2.3
  532. // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used.
  533. require_once(PODPRESS_DIR.'/podpress_admin_js_i18.php');
  534. podpress_print_localized_admin_js_vars();
  535. podpress_print_js_vars();
  536. }
  537. if ( 'admin.php' == $pagenow AND 'podpress/podpress_feed.php' == $_GET['page'] ) {
  538. wp_register_script( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_feedssettings.js' );
  539. }
  540. if ( 'widgets.php' == $pagenow ) {
  541. if ( TRUE == version_compare($wp_version, '2.9', '>=') ) {
  542. wp_register_script( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_widgetssettings.js' );
  543. } elseif ( TRUE == version_compare($wp_version, '2.8', '>=') AND TRUE == version_compare($wp_version, '2.9', '<') ) {
  544. wp_register_script( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_widgetssettings_wp28.js' );
  545. } elseif (TRUE == version_compare($wp_version, '2.8', '<')) {
  546. wp_register_script( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_widgetssettings_pre_wp28.js' );
  547. }
  548. }
  549. if ( ('admin.php' == $pagenow AND 'podpress/podpress_feed.php' == $_GET['page']) OR 'widgets.php' == $pagenow ) {
  550. wp_register_script( 'podpress-jquery-ui-core', PODPRESS_URL.'/js/jquery/jquery-1.4.2.min.js' );
  551. wp_register_script( 'podpress_jquery_init', PODPRESS_URL.'/js/jquery/podpress_jquery142_init.js' );
  552. wp_register_script( 'jquery-ui-accordion-dialog', PODPRESS_URL.'/js/jquery/jquery-ui-1.8.5.accordion_dialog.min.js' );
  553. wp_enqueue_script( 'podpress-jquery-ui-core' );
  554. wp_enqueue_script( 'podpress_jquery_init' );
  555. wp_enqueue_script( 'jquery-ui-accordion-dialog' );
  556. wp_enqueue_script( 'podpress_jquery_ui' );
  557. }
  558. }
  559. // for WP 2.7+
  560. function podpress_print_admin_css() {
  561. wp_register_style( 'podpress_admin_styles', PODPRESS_URL.'/podpress_admin_wp27plus.css' );
  562. wp_enqueue_style( 'podpress_admin_styles' );
  563. GLOBAL $pagenow;
  564. if ( 'admin.php' == $pagenow AND $_GET['page'] == 'podpress/podpress_players.php' ) {
  565. // since 8.8.5.3: styles for the 1PixelOut player with listen wrapper
  566. podpress_print_frontend_css();
  567. }
  568. if ( ('admin.php' == $pagenow AND 'podpress/podpress_feed.php' == $_GET['page']) OR 'widgets.php' == $pagenow ) {
  569. //~ wp_register_style( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/css/custom-theme_legacy/jquery-ui-1.7.3.custom.css' );
  570. wp_register_style( 'podpress_jquery_ui', PODPRESS_URL.'/js/jquery/css/custom-theme/jquery-ui-1.8.5.custom.css' );
  571. wp_enqueue_style( 'podpress_jquery_ui' );
  572. }
  573. }
  574. // for WP version < 2.7
  575. function podPress_print_admin_js_and_css_old_wp() {
  576. Global $pagenow, $wp_version;
  577. $page_with_podPress = Array('post.php', 'page.php', 'post-new.php', 'page-new.php', 'categories.php', 'admin.php');
  578. if ( in_array($pagenow, $page_with_podPress) ) {
  579. // ntm: this way of loading a localized Js scripts is probably not very elegant but it works in WP version older than 2.3
  580. // I know that since WP 2.3 the function wp_localize_script() exists and when it is decided to raise the minimum WP requirement of this plugin then this method will be used.
  581. require_once(PODPRESS_DIR.'/podpress_admin_js_i18.php');
  582. podpress_print_localized_admin_js_vars();
  583. podpress_print_js_vars();
  584. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/podpress.js"></script>'."\n";
  585. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/podpress_admin.js"></script>'."\n";
  586. }
  587. $page_with_podPress = Array('post.php', 'page.php', 'post-new.php', 'page-new.php', 'categories.php', 'admin.php', 'widgets.php');
  588. if ( in_array($pagenow, $page_with_podPress) ) {
  589. //~ if ( function_exists('wp_admin_tiger_css') ) {
  590. if ( TRUE == version_compare($wp_version, '2.5', '>=') AND TRUE == version_compare($wp_version, '2.7', '<') ) {
  591. $admincss = 'podpress_admin_tigercheck.css';
  592. } else {
  593. $admincss = 'podpress_admin.css';
  594. }
  595. echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/'.$admincss.'" type="text/css" />'."\n";
  596. }
  597. if ( ('admin.php' == $pagenow AND 'podpress/podpress_feed.php' == $_GET['page']) OR 'widgets.php' == $pagenow ) {
  598. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/jquery/jquery-1.4.2.min.js"></script>'."\n";
  599. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/jquery/podpress_jquery142_init.js"></script>'."\n";
  600. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/jquery/jquery-ui-1.8.5.accordion_dialog.min.js"></script>'."\n";
  601. if ( 'widgets.php' == $pagenow ) {
  602. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_widgetssettings_pre_wp28.js"></script>'."\n";
  603. } else {
  604. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/jquery/podpress_jquery142_ui_feedssettings.js"></script>'."\n";
  605. }
  606. echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/js/jquery/css/custom-theme/jquery-ui-1.8.5.custom.css" type="text/css" />'."\n";
  607. }
  608. if ( ('admin.php' == $pagenow AND 'podpress/podpress_players.php' == $_GET['page']) OR 'widgets.php' == $pagenow ) {
  609. echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/podpress.css'.'" type="text/css" />'."\n";
  610. }
  611. if ( 'admin.php' == $pagenow AND 'podpress/podpress_stats.php' == $_GET['page'] ) {
  612. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/js/podpress_admin_statistics.js"></script>'."\n";
  613. echo '<link rel="stylesheet" href="'.PODPRESS_URL.'/podpress_admin_statistics.css'.'" type="text/css" />'."\n";
  614. }
  615. }
  616. function podpress_print_js_vars() {
  617. GLOBAL $podPress;
  618. // Set the player settings which are not part of $podPress->settings['player']. This for instance important after an podPress resp. 1PixelOut player update (if there are new settings)
  619. foreach ($podPress->PlayerDefaultSettings() as $key => $value) {
  620. if ( FALSE === isset($podPress->settings['player'][$key]) ) {
  621. $podPress->settings['player'][$key] = $value;
  622. }
  623. }
  624. $playerOptions = '';
  625. if($podPress->settings['enablePodangoIntegration'] || (TRUE == isset($podPress->settings['mp3Player']) AND 'podango' == $podPress->settings['mp3Player']) ) {
  626. $mp3playerswffile = 'var podPressPlayerFile = "podango_player.swf";'."\n";
  627. // create the parameter string for the mp3 player
  628. foreach($podPress->settings['player'] as $key => $val) {
  629. if ( 'listenWrapper' !== $key AND 'overwriteTitleandArtist' !== $key ) {
  630. $val = str_replace('#', '0x', $val);
  631. $playerOptions .= '&amp;' . $key . '=' . rawurlencode($val);
  632. }
  633. }
  634. $mp3playerOptionsStr = 'var podPressMP3PlayerOptions = "'.$playerOptions.'&amp;";'."\n";
  635. } else {
  636. $mp3playerswffile = '';
  637. $mp3playerOptionsStr = '';
  638. // create the parameter string for the mp3 player
  639. foreach($podPress->settings['player'] as $key => $val) {
  640. if ( 'listenWrapper' !== $key AND 'overwriteTitleandArtist' !== $key ) {
  641. $val = str_replace('#', '', $val);
  642. $playerOptions .= $key . ':"' . rawurlencode($val).'", ';
  643. $podpupplayerOptions .= ' podPressPopupPlayerOpt["' . $key . '"] = "' . rawurlencode($val).'";'."\n";
  644. }
  645. }
  646. echo '<script type="text/javascript" src="'.PODPRESS_URL.'/players/1pixelout/1pixelout_audio-player.js"></script>'."\n";
  647. echo '<script type="text/javascript">//<![CDATA['."\n";
  648. echo ' var podPressPlayerFile = "1pixelout_player.swf";'."\n"; // this is for the Play in Popup function, too!
  649. echo ' var podPressPopupPlayerOpt = new Object();'."\n";
  650. echo $podpupplayerOptions;
  651. echo ' podpressAudioPlayer.setup("'.PODPRESS_URL.'/players/1pixelout/" + podPressPlayerFile, {'.$playerOptions.' pagebg:"FFFFFF", transparentpagebg:"yes", encode: "no"} );'."\n";
  652. echo '//]]></script>'."\n";
  653. }
  654. echo '<script type="text/javascript">//<![CDATA['."\n";
  655. echo 'var podPressBlogURL = "'.get_option('siteurl').'/";'."\n";
  656. echo 'var podPressBackendURL = "'.PODPRESS_URL.'/";'."\n";
  657. if ( FALSE == isset($podPress->settings['videoPreviewImage']) OR empty($podPress->settings['videoPreviewImage']) ) {
  658. echo 'var podPressDefaultPreviewImage = podPressBackendURL+"images/vpreview_center.png";'."\n";
  659. } else {
  660. echo 'var podPressDefaultPreviewImage = "'.$podPress->settings['videoPreviewImage'].'";'."\n";
  661. }
  662. echo $mp3playerswffile;
  663. echo $mp3playerOptionsStr;
  664. if (TRUE == isset($podPress->settings['player']['listenWrapper']) AND TRUE == $podPress->settings['player']['listenWrapper']) {
  665. echo 'var podPressMP3PlayerWrapper = true;'."\n";
  666. } else {
  667. echo 'var podPressMP3PlayerWrapper = false;'."\n";
  668. }
  669. if (TRUE == isset($podPress->settings['cortado_version']) AND 'cortado_signed' == $podPress->settings['cortado_version']) {
  670. echo 'var podPress_cortado_signed = true;'."\n";
  671. } else {
  672. echo 'var podPress_cortado_signed = false;'."\n";
  673. }
  674. if ('yes' == $podPress->settings['player']['overwriteTitleandArtist']) { // should the 1Pixelout player try to show the ID3 data or the custom values
  675. echo 'var podPressOverwriteTitleandArtist = true;'."\n";
  676. } else {
  677. echo 'var podPressOverwriteTitleandArtist = false;'."\n";
  678. }
  679. echo 'var podPressText_PlayNow = "'.__('Play Now', 'podpress').'";'."\n";
  680. echo 'var podPressText_HidePlayer = "'.__('Hide Player', 'podpress').'";'."\n";
  681. echo '//]]></script>'."\n";
  682. }
  683. function podPress_admin_head() {
  684. GLOBAL $podPress, $action;
  685. if(!$podPress->settings['compatibilityChecks']['themeTested']) {
  686. $podPress->settings['compatibilityChecks']['themeTested'] = true;
  687. podPress_update_option('podPress_config', $podPress->settings);
  688. }
  689. if(!$podPress->settings['compatibilityChecks']['wp_head']) {
  690. $podPress->settings['compatibilityChecks']['wp_head'] = true;
  691. podPress_update_option('podPress_config', $podPress->settings);
  692. } else {
  693. $podPress->settings['compatibilityChecks']['wp_head'] = true;
  694. }
  695. // ntm: old podPress version check. It checks only at myghtyseek.com and not at wordpress.org for new versions !!! and only on the plugins.php page
  696. if ((strpos($_SERVER['REQUEST_URI'], 'plugins.php') !== false) && (podPress_remote_version_check() == 1)) {
  697. echo "<script type='text/javascript' src='" . PODPRESS_URL . "/js/prototype/prototype-1.4.0.js'></script>\n";
  698. $alert = "\n";
  699. $alert .= "\n<script type='text/javascript'>";
  700. $alert .= "\n//<![CDATA[";
  701. $alert .= "\nfunction alertNewPodPressVersion() {";
  702. $alert .= "\n pluginname = 'podPress';";
  703. $alert .= "\n allNodes = document.getElementsByClassName('name');";
  704. $alert .= "\n for(i = 0; i < allNodes.length; i++) {";
  705. $alert .= "\n var regExp=/<\S[^>]*>/g;";
  706. $alert .= "\n temp = allNodes[i].innerHTML;";
  707. $alert .= "\n if (temp.replace(regExp,'') == pluginname) {";
  708. $alert .= "\n Element.setStyle(allNodes[i].getElementsByTagName('a')[0], {color: '#f00'});";
  709. $alert .= "\n new Insertion.After(allNodes[i].getElementsByTagName('strong')[0],'<br/><small>" . __('new version available', 'podpress') . "</small>');";
  710. $alert .= "\n }";
  711. $alert .= "\n }";
  712. $alert .= "\n}";
  713. $alert .= "\naddLoadEvent(alertNewPodPressVersion);";
  714. $alert .= "\n//]]>";
  715. $alert .= "\n</script>";
  716. $alert .= "\n";
  717. echo $alert;
  718. }
  719. }
  720. function podPress_admin_footer() {
  721. GLOBAL $podPress;
  722. if(!$podPress->settings['compatibilityChecks']['themeTested']) {
  723. $podPress->settings['compatibilityChecks']['themeTested'] = true;
  724. podPress_update_option('podPress_config', $podPress->settings);
  725. }
  726. if(!$podPress->settings['compatibilityChecks']['wp_footer']) {
  727. $podPress->settings['compatibilityChecks']['wp_footer'] = true;
  728. podPress_update_option('podPress_config', $podPress->settings);
  729. } else {
  730. $podPress->settings['compatibilityChecks']['wp_footer'] = true;
  731. }
  732. }
  733. function podPress_wp_footer() {
  734. GLOBAL $podPress;
  735. if ( $podPress->settings['enableFooter'] ) {
  736. echo '<div id="podPress_footer">'.__('Podcast powered by', 'podpress').' <a href="http://wordpress.org/extend/plugins/podpress/" title="'.__('podPress, a plugin for podcasting with WordPress', 'podpress').'"><strong>podPress v'.PODPRESS_VERSION.'</strong></a></div>';
  737. }
  738. }
  739. function podPress_get_the_guid($guid) {
  740. GLOBAL $post, $wpdb;
  741. if ( empty($guid) ) {
  742. $guid = get_option('siteurl') . '/?p=' . $post->ID;
  743. if ( is_object($post) && !empty($post->ID) ) {
  744. $wpdb->query("UPDATE ".$wpdb->posts." SET guid = '". $guid ."' WHERE ID=".$post->ID);
  745. }
  746. }
  747. return $guid;
  748. }
  749. function podPress_get_attached_file($file, $id = '') {
  750. if ( is_feed() ) { return ''; }
  751. return $file;
  752. }
  753. function podPress_wp_get_attachment_metadata($data, $id = '') {
  754. if ( is_feed() ) { return ''; }
  755. return $data;
  756. }
  757. function podPress_crossdomain() {
  758. // ntm: Which purpose has this function? Shouldn't the crossdomain file on the server/domain with the mp3 files? And isn't it to sloppy and dangerous to allow acces from all domains?
  759. // http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html
  760. header("HTTP/1.0 200 OK");
  761. header('Content-type: text/xml; charset=' . get_bloginfo('charset'), true);
  762. echo '<?xml version="1.0"?>'."\n";
  763. echo '<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">'."\n";
  764. echo '<cross-domain-policy>'."\n";
  765. echo ' <allow-access-from domain="*" />'."\n";
  766. echo '</cross-domain-policy>'."\n";
  767. exit;
  768. }
  769. // only for compatibility with WP versions older than WP 2.3
  770. function podPress_get_cat_ID_by_nicename($cat_nicename='general') {
  771. global $wpdb;
  772. $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename='$cat_nicename'");
  773. return $cid?$cid:1; // default to cat 1
  774. }
  775. /**
  776. * podpress_get_exts_from_filetypes - extracts the file name extensions from the strings of the allowed file types
  777. *
  778. * @package podPress
  779. * @since 8.8.7 beta 3
  780. *
  781. * @param Array $filetypes
  782. *
  783. * @return mixed $allowed_extensions
  784. */
  785. function podpress_get_exts_from_filetypes($filetypes=array()) {
  786. if ( TRUE == is_array($filetypes) AND FALSE === empty($filetypes) ) {
  787. $allowed_extensions = Array();
  788. foreach ($filetypes as $filetype) {
  789. $allowed_extensions[] = end(explode('_', $filetype));
  790. }
  791. return $allowed_extensions;
  792. } else {
  793. return false;
  794. }
  795. }
  796. /**
  797. * podpress_get_IDs_of_posts_with_allowed_exts - retrieves the IDs of posts with podPress attachments of certain file tapes from the db
  798. *
  799. * @package podPress
  800. * @since 8.8.8.1
  801. *
  802. * @param Array $allowed_ext - file name extensions of the allowed file types e.g array('mp3', 'm4a')
  803. *
  804. * @return mixed $IDs as an array OR FALSE if it was not possible to retrieve IDs from the db
  805. */
  806. function podpress_get_IDs_of_posts_with_allowed_exts($allowed_ext = array()) {
  807. global $wpdb;
  808. $IDs = Array();
  809. if ( FALSE == empty($allowed_ext) AND TRUE == is_array($allowed_ext) ) {
  810. $querystring = "SELECT post_id, meta_value FROM ".$wpdb->postmeta." WHERE meta_key = 'podPressMedia'";
  811. $meta_values = $wpdb->get_results($querystring, ARRAY_A);
  812. $nr_meta_values = count($meta_values);
  813. foreach ($meta_values as $meta_value) {
  814. $unserialized_data_sets = @unserialize($meta_value['meta_value']);
  815. if ( is_array($unserialized_data_sets) AND FALSE == empty($unserialized_data_sets) ) {
  816. foreach ($unserialized_data_sets AS $unserialized_data) {
  817. if ( TRUE == isset($unserialized_data['URI']) AND 4 < strlen($unserialized_data['URI']) AND TRUE == in_array(substr(strtolower($unserialized_data['URI']), -3), $allowed_ext) ) {
  818. $IDs[] = $meta_value['post_id'];
  819. }
  820. }
  821. }
  822. }
  823. $IDs = array_unique($IDs);
  824. }
  825. if ( FALSE == empty($IDs) ) {
  826. return $IDs;
  827. } else {
  828. return FALSE;
  829. }
  830. }
  831. /**
  832. * podPress_feed_content_filtering - is called via the Action Hook pre_get_posts and influences the WP Query if the query is for a feed
  833. *
  834. * @package podPress
  835. * @since 8.8.8.1
  836. *
  837. * @param Array $query - WP Query object - see http://codex.wordpress.org/Function_Reference/WP_Query and http://codex.wordpress.org/Plugin_API/Action_Reference#Advanced_Actions
  838. */
  839. function podPress_feed_content_filtering( $query ) {
  840. global $podPress, $wp_version, $podpress_allowed_ext;
  841. if ( $query->is_feed ) {
  842. $is_podpress_feed = FALSE;
  843. $feedslug = $query->query_vars['feed'];
  844. foreach ( $podPress->settings['podpress_feeds'] as $feed ) {
  845. if ( $feedslug === $feed['slug'] ) {
  846. $is_podpress_feed = TRUE;
  847. break;
  848. }
  849. }
  850. if ( FALSE === $is_podpress_feed ) {
  851. if ( empty($query->query_vars['cat']) AND empty($query->query_vars['tag']) AND FALSE == empty($query->query_vars['category_name']) ) {
  852. if ( TRUE == version_compare($wp_version, '2.3', '>=') ) {
  853. $idObj = get_category_by_slug( $query->query_vars['category_name'] );
  854. $cat_id = $idObj->term_id;
  855. } else {
  856. $cat_id = podPress_get_cat_ID_by_nicename( $query->query_vars['category_name'] );
  857. }
  858. }
  859. $categorysettings = get_option('podPress_category_'.$cat_id);
  860. }
  861. if ( TRUE === $is_podpress_feed ) {
  862. // podPress Custom Feeds
  863. // get the list of allowed file extensions
  864. $podpress_allowed_ext = podpress_get_exts_from_filetypes($feed['FileTypes']);
  865. if ( (is_array($podpress_allowed_ext) AND FALSE === empty($podpress_allowed_ext)) OR (is_array($feed['inclCategories']) AND FALSE === empty($feed['inclCategories'])) ) {
  866. if ( is_array($podpress_allowed_ext) AND FALSE === empty($podpress_allowed_ext) ) {
  867. // get a list of IDs of posts which have podPress attachment of an allowed type
  868. $post_ids = podpress_get_IDs_of_posts_with_allowed_exts($podpress_allowed_ext);
  869. if ( is_array($post_ids) AND FALSE == empty($post_ids) ) {
  870. // insert the post IDs into the WP Query
  871. $query->set('post__in', $post_ids);
  872. } else {
  873. $query->set('post__in', Array(0));
  874. }
  875. }
  876. if ( is_array($feed['inclCategories']) AND FALSE === empty($feed['inclCategories']) ) {
  877. $query->query_vars['category__in'] = $feed['inclCategories'];
  878. }
  879. } else {
  880. if ( isset($feed['show_only_podPress_podcasts']) AND FALSE === $feed['show_only_podPress_podcasts'] ) {
  881. // the feed should not only posts with podPress attachments
  882. define('PODPRESS_PODCASTSONLY', FALSE);
  883. } else {
  884. // get only posts with podPress attachments (that is how was in older versions)
  885. define('PODPRESS_PODCASTSONLY', TRUE);
  886. }
  887. }
  888. if ( 'torrent' === $feed['slug'] ) {
  889. define('PODPRESS_TORRENTCAST', true);
  890. }
  891. if ( TRUE === $feed['premium'] ) {
  892. GLOBAL $cache_lastpostmodified;
  893. unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
  894. $cache_lastpostmodified = date('Y-m-d h:i:s', time()+36000);
  895. podPress_addFeedHooks();
  896. define('PREMIUMCAST', true);
  897. require_once( PODPRESS_DIR.'/podpress_premium_functions.php' );
  898. podPress_validateLogin();
  899. } else {
  900. podPress_addFeedHooks();
  901. }
  902. } elseif ( isset($categorysettings) AND FALSE !== $categorysettings AND isset($categorysettings['categoryCasting']) AND 'true' == $categorysettings['categoryCasting'] ) {
  903. // CategoryCasting Feeds
  904. // get the list of allowed file extensions
  905. $podpress_allowed_ext = podpress_get_exts_from_filetypes($categorysettings['FileTypes']);
  906. if (is_array($podpress_allowed_ext) AND FALSE === empty($podpress_allowed_ext)) {
  907. // get a list of IDs of posts which have podPress attachment of an allowed type
  908. $post_ids = podpress_get_IDs_of_posts_with_allowed_exts($podpress_allowed_ext);
  909. if ( is_array($post_ids) AND FALSE == empty($post_ids) ) {
  910. // insert the post IDs into the WP Query
  911. $query->set('post__in', $post_ids);
  912. } else {
  913. $query->set('post__in', Array(0));
  914. }
  915. } else {
  916. // get only posts with podPress attachments
  917. if ( isset($categorysettings['show_only_podPress_podcasts']) AND FALSE === $categorysettings['show_only_podPress_podcasts'] ) {
  918. // the feed should not only posts with podPress attachments
  919. define('PODPRESS_PODCASTSONLY', FALSE);
  920. } else {
  921. // get only posts with podPress attachments (that is how was in older…

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