PowerPress Podcasting plugin by Blubrry - Version 6.3

Version Description

  • Released on 12/14/2015
  • Import Podcast by feed added. You can now migrate your podcast from any service such as SoundCloud, LibSyn or PodBean into your own WordPress site powered by PowerPress!. With only a couple clicks you can import your program information, artwork and episodes. **NOTE: Import feature was planned for PowerPress 7.0. Based on requests and rumors we are releasing this feature now.
  • Import podcast feature includes program level information (Thanks Daniel Lewis for your feedback!)
  • Import podcast feature downloads iTunes artwork.
  • Import podcast feature advanced options: Allow duplicate episode titles and dates, Overwrite podcast program information, and include blog posts.
  • Import podcast feature only imports your feed and meta information. Media files may be migrated using the Media Migration tool or manually.
  • Fixed bug with podcast titles not displaying in some situations when using WordPress versions older than 4.4. (Thanks Daniel Lewis for pointing out the issue)
  • Fixed bug with image title not matching feed title (Thanks EntBuddha for the heads up!)
  • Happy Holidays! Jeff Buckley cover of Everyday People
Download this release

Release Info

Developer amandato
Plugin Icon 128x128 PowerPress Podcasting plugin by Blubrry
Version 6.3
Comparing to
See all releases

Code changes from version 6.2.2 to 6.3

feed-podcast.php CHANGED
@@ -47,7 +47,7 @@ echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
47
  <?php do_action('rss2_ns'); ?>
48
  >
49
  <channel>
50
- <title><?php echo get_wp_title_rss(); ?></title>
51
  <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
52
  <link><?php bloginfo_rss('url') ?></link>
53
  <description><?php bloginfo_rss("description") ?></description>
47
  <?php do_action('rss2_ns'); ?>
48
  >
49
  <channel>
50
+ <title><?php if( version_compare($GLOBALS['wp_version'], 4.4, '<' ) ) { bloginfo_rss('name'); } wp_title_rss(); ?></title>
51
  <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
52
  <link><?php bloginfo_rss('url') ?></link>
53
  <description><?php bloginfo_rss("description") ?></description>
powerpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://create.blubrry.com/resources/powerpress/
5
  Description: <a href="http://create.blubrry.com/resources/powerpress/" target="_blank">Blubrry PowerPress</a> is the No. 1 Podcasting plugin for WordPress. Developed by podcasters for podcasters; features include Simple and Advanced modes, multiple audio/video player options, subscribe to podcast tools, podcast SEO features, and more! Fully supports iTunes, Google Play, Stitcher, and Blubrry Podcasting directories, as well as all podcast applications and clients.
6
- Version: 6.2.2
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Requires at least: 3.7
@@ -35,7 +35,7 @@ if( !function_exists('add_action') )
35
  die("access denied.");
36
 
37
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
38
- define('POWERPRESS_VERSION', '6.2.2' );
39
 
40
  // Translation support:
41
  if ( !defined('POWERPRESS_ABSPATH') )
@@ -598,7 +598,12 @@ function powerpress_rss2_head()
598
  echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle') . '</itunes:subtitle>'.PHP_EOL;
599
  else
600
  echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle') .'</itunes:subtitle>'.PHP_EOL;
601
-
 
 
 
 
 
602
  if( !empty($Feed['rss2_image']) || !empty($Feed['itunes_image']) )
603
  {
604
  if( !empty($Feed['rss2_image']) ) // If the RSS image is set, use it, otherwise use the iTunes image...
@@ -607,7 +612,7 @@ function powerpress_rss2_head()
607
  $rss_image = $Feed['itunes_image'];
608
 
609
  echo "\t". '<image>' .PHP_EOL;
610
- echo "\t\t".'<title>' . get_wp_title_rss() . '</title>'.PHP_EOL;
611
  echo "\t\t".'<url>' . esc_html( str_replace(' ', '+', $rss_image)) . '</url>'.PHP_EOL;
612
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
613
  echo "\t".'</image>' . PHP_EOL;
@@ -615,13 +620,12 @@ function powerpress_rss2_head()
615
  else // Use the default image
616
  {
617
  echo "\t". '<image>' .PHP_EOL;
618
- echo "\t\t".'<title>' . get_wp_title_rss() . '</title>'.PHP_EOL;
619
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
620
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
621
  echo "\t".'</image>' . PHP_EOL;
622
  }
623
-
624
-
625
  // Handle iTunes categories
626
  $Categories = powerpress_itunes_categories();
627
  $Cat1 = false; $Cat2 = false; $Cat3 = false;
@@ -1059,7 +1063,7 @@ function powerpress_bloginfo_rss($content, $field = '')
1059
  $Feed = get_option('powerpress_feed');
1060
  }
1061
  }
1062
- //$Feed = true;
1063
  if( $Feed )
1064
  {
1065
  switch( $field )
@@ -1080,19 +1084,9 @@ function powerpress_bloginfo_rss($content, $field = '')
1080
  else if( is_category() )
1081
  return get_category_link( get_query_var('cat') );
1082
  }; break;
1083
- case 'name': { // As of wp 4.4 title is handled by get_the_title_rss completely.
1084
- if( version_compare($GLOBALS['wp_version'], 4.4, '<' ) ) {
1085
- if( !empty($Feed['title']) )
1086
- $new_value = $Feed['title'];
1087
- else
1088
- return ''; // Otherwise we need to set the blog title to blank (TEST)
1089
- }
1090
- // Otherwise WP 4.4+ we do what we've always done...
1091
- else
1092
- {
1093
- if( !empty($Feed['title']) )
1094
- $new_value = $Feed['title'];
1095
- }
1096
  }; break;
1097
  case 'language': {
1098
  // Get the feed language
@@ -1278,17 +1272,8 @@ function powerpress_do_podcast_feed($for_comments=false)
1278
  }
1279
  }
1280
 
1281
- //$wp_query->get_posts(); // No longer needed as it duplicates the existing get posts query already performed
1282
- if( !empty($GeneralSettings['episode_box_feature_in_itunes']) || !empty($powerpress_feed['maximize_feed']) )
1283
- {
1284
- // Use the template for the always featured option
1285
- load_template( POWERPRESS_ABSPATH . '/feed-podcast.php' );
1286
- }
1287
- else
1288
- {
1289
- do_feed_rss2(false);
1290
- }
1291
-
1292
  }
1293
 
1294
  function powerpress_template_redirect()
3
  Plugin Name: Blubrry PowerPress
4
  Plugin URI: http://create.blubrry.com/resources/powerpress/
5
  Description: <a href="http://create.blubrry.com/resources/powerpress/" target="_blank">Blubrry PowerPress</a> is the No. 1 Podcasting plugin for WordPress. Developed by podcasters for podcasters; features include Simple and Advanced modes, multiple audio/video player options, subscribe to podcast tools, podcast SEO features, and more! Fully supports iTunes, Google Play, Stitcher, and Blubrry Podcasting directories, as well as all podcast applications and clients.
6
+ Version: 6.3
7
  Author: Blubrry
8
  Author URI: http://www.blubrry.com/
9
  Requires at least: 3.7
35
  die("access denied.");
36
 
37
  // WP_PLUGIN_DIR (REMEMBER TO USE THIS DEFINE IF NEEDED)
38
+ define('POWERPRESS_VERSION', '6.3' );
39
 
40
  // Translation support:
41
  if ( !defined('POWERPRESS_ABSPATH') )
598
  echo "\t".'<itunes:subtitle>' . powerpress_format_itunes_value($Feed['itunes_subtitle'], 'subtitle') . '</itunes:subtitle>'.PHP_EOL;
599
  else
600
  echo "\t".'<itunes:subtitle>'. powerpress_format_itunes_value( get_bloginfo('description'), 'subtitle') .'</itunes:subtitle>'.PHP_EOL;
601
+ $podcast_title_safe = '';
602
+ if( version_compare($GLOBALS['wp_version'], 4.4, '<' ) ) {
603
+ $podcast_title_safe .= get_bloginfo_rss('name');
604
+ }
605
+ $podcast_title_safe .= get_wp_title_rss();
606
+
607
  if( !empty($Feed['rss2_image']) || !empty($Feed['itunes_image']) )
608
  {
609
  if( !empty($Feed['rss2_image']) ) // If the RSS image is set, use it, otherwise use the iTunes image...
612
  $rss_image = $Feed['itunes_image'];
613
 
614
  echo "\t". '<image>' .PHP_EOL;
615
+ echo "\t\t".'<title>' . $podcast_title_safe . '</title>'.PHP_EOL;
616
  echo "\t\t".'<url>' . esc_html( str_replace(' ', '+', $rss_image)) . '</url>'.PHP_EOL;
617
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
618
  echo "\t".'</image>' . PHP_EOL;
620
  else // Use the default image
621
  {
622
  echo "\t". '<image>' .PHP_EOL;
623
+ echo "\t\t".'<title>' . $podcast_title_safe . '</title>'.PHP_EOL;
624
  echo "\t\t".'<url>' . powerpress_get_root_url() . 'rss_default.jpg</url>'.PHP_EOL;
625
  echo "\t\t".'<link>'. $Feed['url'] . '</link>' . PHP_EOL;
626
  echo "\t".'</image>' . PHP_EOL;
627
  }
628
+
 
629
  // Handle iTunes categories
630
  $Categories = powerpress_itunes_categories();
631
  $Cat1 = false; $Cat2 = false; $Cat3 = false;
1063
  $Feed = get_option('powerpress_feed');
1064
  }
1065
  }
1066
+
1067
  if( $Feed )
1068
  {
1069
  switch( $field )
1084
  else if( is_category() )
1085
  return get_category_link( get_query_var('cat') );
1086
  }; break;
1087
+ case 'name': { // As of wp 4.4+ title is handled by get_the_title_rss completely.
1088
+ if( !empty($Feed['title']) )
1089
+ $new_value = $Feed['title'];
 
 
 
 
 
 
 
 
 
 
1090
  }; break;
1091
  case 'language': {
1092
  // Get the feed language
1272
  }
1273
  }
1274
 
1275
+ // Use the template to gurantee future WordPress behavior
1276
+ load_template( POWERPRESS_ABSPATH . '/feed-podcast.php' );
 
 
 
 
 
 
 
 
 
1277
  }
1278
 
1279
  function powerpress_template_redirect()
powerpressadmin-basic.php CHANGED
@@ -234,13 +234,27 @@ function powerpressadmin_advanced_options($General)
234
  <div style="margin-left: 10px;">
235
  <h3><?php echo __('Advanced Options', 'powerpress'); ?></h3>
236
  <div style="margin-left: 50px;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  <div>
238
  <input type="checkbox" name="NULL[player_options]" value="1" checked disabled />
239
  <strong><?php echo __('Audio Player Options', 'powerpress'); ?></strong> -
240
  <?php echo __('Select from 3 different web based audio players.', 'powerpress'); ?>
241
  <span style="font-size: 85%;">(<a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_player.php'); ?>"><?php echo __('configure audio player', 'powerpress'); ?></a>)</span>
242
-
243
-
244
  </div>
245
  <div>
246
  <input type="checkbox" name="NULL[video_player_options]" value="1" checked disabled />
234
  <div style="margin-left: 10px;">
235
  <h3><?php echo __('Advanced Options', 'powerpress'); ?></h3>
236
  <div style="margin-left: 50px;">
237
+ <div>
238
+ <input type="checkbox" name="NULL[import_podcast]" value="1" checked disabled />
239
+ <strong><a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_import_feed.php'); ?>"><?php echo __('Import Podcast', 'powerpress'); ?></a></strong> <?php echo powerpressadmin_new(); ?> -
240
+ <?php echo __('Import podcast feed from SoundCloud, LibSyn, PodBean or other podcast service.', 'powerpress'); ?>
241
+ </div>
242
+ <div>
243
+ <input type="checkbox" name="NULL[migrate_media]" value="1" checked disabled />
244
+ <strong><a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php'); ?>"><?php echo __('Migrate Media', 'powerpress'); ?></a></strong> <?php echo powerpressadmin_new(); ?> -
245
+ <?php echo __('Migrate media files to Blubrry Podcast Media Hosting with only a few clicks.', 'powerpress'); ?>
246
+ </div>
247
+ <div>
248
+ <input type="checkbox" name="NULL[podcasting_seo]" value="1" checked disabled />
249
+ <strong><a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_search.php'); ?>"><?php echo __('Podcasting SEO', 'powerpress'); ?></a></strong> <?php echo powerpressadmin_new(); ?> -
250
+ <?php echo __('Select from 3 different web based audio players.', 'powerpress'); ?>
251
+ </div>
252
+
253
  <div>
254
  <input type="checkbox" name="NULL[player_options]" value="1" checked disabled />
255
  <strong><?php echo __('Audio Player Options', 'powerpress'); ?></strong> -
256
  <?php echo __('Select from 3 different web based audio players.', 'powerpress'); ?>
257
  <span style="font-size: 85%;">(<a href="<?php echo admin_url('admin.php?page=powerpress/powerpressadmin_player.php'); ?>"><?php echo __('configure audio player', 'powerpress'); ?></a>)</span>
 
 
258
  </div>
259
  <div>
260
  <input type="checkbox" name="NULL[video_player_options]" value="1" checked disabled />
powerpressadmin-import-feed.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ function powerpress_admin_import_feed()
6
+ {
7
+ ?>
8
+ <h2><?php echo __('Import podcast feed to WordPress', 'powerpress'); ?></h2>
9
+ <p><?php echo __('The following tool will import your podcast episodes to this website.', 'powerpress'); ?></p>
10
+
11
+ <ul><li>
12
+ <ul>
13
+ <li><strong><a href="<?php echo admin_url("admin.php?import=powerpress-soundcloud-rss-podcast"); ?>"><?php echo __('Podcast from SoundCloud', 'powerpress'); ?></a></strong></li>
14
+ <li><strong><a href="<?php echo admin_url("admin.php?import=powerpress-libsyn-rss-podcast"); ?>"><?php echo __('Podcast from LibSyn', 'powerpress'); ?></a></strong></li>
15
+ <li><strong><a href="<?php echo admin_url("admin.php?import=powerpress-podbean-rss-podcast"); ?>"><?php echo __('Podcast from PodBean', 'powerpress'); ?></a></strong></li>
16
+ <li><strong><a href="<?php echo admin_url("admin.php?import=powerpress-rss-podcast"); ?>"><?php echo __('Podcast RSS Feed', 'powerpress'); ?></a></strong></li>
17
+ </ul>
18
+ </li></ul>
19
+ <p><?php echo sprintf(__('Importing your feed does not migrate your media files. Please use the %s tool to migrate your media once your feed is imported.', 'powerpress'), '<strong><a href="'.admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php') .'">'. __('Migrate Media', 'powerpress') .'</a></strong>'); ?></p>
20
+
21
+ <br /><br />
22
+ <?php
23
+ }
24
+
25
+ // eof
powerpressadmin-rss-import.php ADDED
@@ -0,0 +1,821 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Load Importer API
4
+ require_once( ABSPATH . 'wp-admin/includes/import.php');
5
+
6
+ if ( !class_exists( 'WP_Importer' ) ) {
7
+ if ( file_exists( ABSPATH . 'wp-admin/includes/class-wp-importer.php' ) )
8
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-importer.php' );
9
+ }
10
+
11
+ /**
12
+ * PowerPress RSS Podcast Importer
13
+ *
14
+ * originally based on the rss importer, significantly modified specifically for podcasting
15
+ */
16
+
17
+ /**
18
+ * PowerPress RSS Podcast Importer
19
+ *
20
+ * Will process a Podcast RSS feed for importing posts into WordPress.
21
+ *
22
+ */
23
+ if ( class_exists( 'WP_Importer' ) ) {
24
+ class PowerPress_RSS_Podcast_Import extends WP_Importer {
25
+
26
+ var $m_content = '';
27
+ var $m_item_pos = 0;
28
+ var $m_item_inserted_count = 0;
29
+ var $m_item_skipped_count = 0;
30
+
31
+ function header() {
32
+ echo '<div class="wrap">';
33
+ screen_icon();
34
+
35
+ if( !empty($_GET['import']) )
36
+ {
37
+ switch($_GET['import'] )
38
+ {
39
+ case 'powerpress-soundcloud-rss-podcast': echo '<h2>'.__('Import Podcast from SoundCloud', 'powerpress').'</h2>'; break;
40
+ case 'powerpress-libsyn-rss-podcast': echo '<h2>'.__('Import Podcast from LibSyn', 'powerpress').'</h2>'; break;
41
+ case 'powerpress-podbean-rss-podcast': echo '<h2>'.__('Import Podcast from PodBean', 'powerpress').'</h2>'; break;
42
+ case 'powerpress-rss-podcast':
43
+ default: echo '<h2>'.__('Import Podcast RSS Feed', 'powerpress').'</h2>'; break;
44
+ }
45
+ }
46
+ else
47
+ {
48
+ echo '<h2>'.__('Podcast RSS Import', 'powerpress').'</h2>';
49
+ }
50
+ }
51
+
52
+ function footer() {
53
+ echo '</div>';
54
+ }
55
+
56
+ function greet() {
57
+ ?>
58
+ <div class="wrap">
59
+
60
+ <p><?php echo __('The following tool will import your podcast episodes to this website.', 'powerpress'); ?></p>
61
+
62
+ <form enctype="multipart/form-data" action="admin.php?import=<?php echo esc_attr($_GET['import']); ?>" method="post" name="blogroll">
63
+ <?php wp_nonce_field('import-powerpress-rss') ?>
64
+
65
+ <div style="width: 70%; margin: auto; height: 8em;">
66
+ <input type="hidden" name="step" value="1" />
67
+ <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo wp_max_upload_size(); ?>" />
68
+ <div style="width: 48%;" class="alignleft">
69
+ <h3><label for="podcast_feed_url"><?php _e('Podcast Feed URL:', 'powerpress'); ?></label></h3>
70
+ <?php
71
+ $placeholder = 'https://example.com/feed.xml';
72
+ switch($_GET['import']) {
73
+ case 'powerpress-soundcloud-rss-podcast': $placeholder = 'http://feeds.soundcloud.com/users/soundcloud:users:00000000/sounds.rss'; break;
74
+ case 'powerpress-libsyn-rss-podcast': $placeholder = 'http://yourshow.libsyn.com/rss'; break;
75
+ case 'powerpress-podbean-rss-podcast': $placeholder = 'http://yourshow.podbean.com/feed/'; break;
76
+ }
77
+ ?>
78
+ <input type="text" name="podcast_feed_url" id="podcast_feed_url" size="50" class="code" style="width: 90%;" placeholder="<?php echo esc_attr($placeholder); ?>" />
79
+ </div>
80
+
81
+ <div style="width: 48%;" class="alignleft">
82
+ <h3><label for="podcast_feed_file"><?php _e('Or choose from your local disk:', 'powerpress'); ?></label></h3>
83
+ <input id="podcast_feed_file" name="podcast_feed_file" type="file" />
84
+ </div>
85
+
86
+ </div>
87
+
88
+ <p><?php echo sprintf(__('Importing your feed does not migrate your media files. Please use the %s tool to migrate your media once your feed is imported.', 'powerpress'), '<strong><a href="'.admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php') .'">'. __('Migrate Media', 'powerpress') .'</a></strong>'); ?></p>
89
+
90
+
91
+ <div class="submit">
92
+ <div>
93
+ <label><input type="checkbox" name="import_itunes_image" value="1" checked> <?php echo __('Download and save iTunes image', 'powerpress'); ?></label>
94
+ </div>
95
+ <div id="powerpress-import-advanced-options-off">
96
+ <p><a href="#" onclick="document.getElementById('powerpress-import-advanced-options-off').style.display='none'; document.getElementById('powerpress-import-advanced-options-on').style.display='block'; return false;"><?php echo __('Advanced options', 'powerprses'); ?></a>
97
+ </p>
98
+ </div>
99
+ <div id="powerpress-import-advanced-options-on" style="display: none;">
100
+ <div>
101
+ <label><input type="checkbox" name="import_overwrite_program_info" value="1"> <?php echo __('Overwrite podcast program information', 'powerpress'); ?></label>
102
+ </div>
103
+ <div>
104
+ <label><input type="checkbox" name="import_strict" value="1" > <?php echo __('Allow duplicate episode titles and dates', 'powerpress'); ?></label>
105
+ </div>
106
+ <div>
107
+ <label><input type="checkbox" name="import_blog_posts" value="1" > <?php echo __('Include blog posts', 'powerpress'); ?></label>
108
+ </div>
109
+ </div>
110
+ <?php submit_button( __('Import Podcast', 'powerpress' ) ); ?>
111
+ </div>
112
+ </form>
113
+ </div>
114
+ <?php
115
+ return;
116
+ echo '<div class="narrow">';
117
+
118
+ echo '<h2>'.__('Import saved Feed', 'powerpress') .'</h2>';
119
+ wp_import_upload_form("admin.php?import=rss-podcast&amp;step=1");
120
+ echo '</div>';
121
+ }
122
+
123
+ function _normalize_tag( $matches ) {
124
+ return '<' . strtolower( $matches[1] );
125
+ }
126
+
127
+ function import_program_info($channel, $overwrite=false, $download_itunes_image=false) {
128
+ $Feed = get_option('powerpress_feed_podcast' );
129
+ if( empty($Feed) )
130
+ $Feed = get_option('powerpress_feed');
131
+
132
+ $NewSettings = array();
133
+
134
+ $matches = array();
135
+ $program_title = false;
136
+ if( preg_match('|<title>(.*?)</title>|is', $channel, $matches) ) {
137
+ $program_title = $this->_sanatize_tag_value( $matches[1] );
138
+
139
+ if( $overwrite || empty($Feed['title']) )
140
+ $NewSettings['title'] = $program_title;
141
+ }
142
+
143
+ // language
144
+ $language = false;
145
+ if( preg_match('|<language>(.*?)</language>|is', $channel, $matches) ) {
146
+ $language = $this->_sanatize_tag_value( $matches[1] );
147
+
148
+ if( $overwrite || empty($Feed['rss_language']) )
149
+ $NewSettings['rss_language'] = $language;
150
+ }
151
+
152
+ // copyright
153
+ $copyright = false;
154
+ if( preg_match('|<copyright>(.*?)</copyright>|is', $channel, $matches) ) {
155
+ $copyright = $this->_sanatize_tag_value( $matches[1] );
156
+
157
+ if( $overwrite || empty($Feed['copyright']) )
158
+ $NewSettings['copyright'] = $copyright;
159
+ }
160
+
161
+ // description
162
+ $description = false;
163
+ if( preg_match('|<description>(.*?)</description>|is', $channel, $matches) ) {
164
+ $description = $this->_sanatize_tag_value( $matches[1] );
165
+
166
+ if( $overwrite || empty($Feed['description']) )
167
+ $NewSettings['description'] = $description;
168
+ }
169
+
170
+ // itunes:subtitle
171
+ $itunes_subtitle = false;
172
+ if( preg_match('|<itunes:subtitle>(.*?)</itunes:subtitle>|is', $channel, $matches) ) {
173
+ $itunes_subtitle = $this->_sanatize_tag_value( $matches[1] );
174
+
175
+ if( $overwrite || empty($Feed['itunes_subtitle']) )
176
+ $NewSettings['itunes_subtitle'] = $itunes_subtitle;
177
+ }
178
+
179
+ // itunes:summary
180
+ $itunes_summary = false;
181
+ if( preg_match('|<itunes:summary>(.*?)</itunes:summary>|is', $channel, $matches) ) {
182
+ $itunes_summary = $this->_sanatize_tag_value( $matches[1] );
183
+
184
+ if( $overwrite || empty($Feed['itunes_summary']) )
185
+ $NewSettings['itunes_summary'] = $itunes_summary;
186
+ }
187
+
188
+ // itunes:email
189
+ $itunes_email = false;
190
+ if( preg_match('|<itunes:email>(.*?)</itunes:email>|is', $channel, $matches) ) {
191
+ $itunes_email = $this->_sanatize_tag_value( $matches[1] );
192
+
193
+ if( $overwrite || empty($Feed['email']) )
194
+ $NewSettings['email'] = $itunes_email;
195
+ }
196
+
197
+ // itunes:author
198
+ $itunes_talent_name = false;
199
+ if( preg_match('|<itunes:author>(.*?)</itunes:author>|is', $channel, $matches) ) {
200
+ $itunes_talent_name = $this->_sanatize_tag_value( $matches[1] );
201
+
202
+ if( $overwrite || empty($Feed['itunes_talent_name']) )
203
+ $NewSettings['itunes_talent_name'] = $itunes_talent_name;
204
+ }
205
+
206
+ // itunes:explicit
207
+ if( preg_match('|<itunes:explicit>(.*?)</itunes:explicit>|is', $channel, $explicit) )
208
+ {
209
+ $explicit_array = array('yes'=>1, 'clean'=>2); // No need to save 'no'
210
+ $value = strtolower( trim( $explicit[1] ) );
211
+ if( !empty($explicit_array[ $value ]) )
212
+ {
213
+ if( $overwrite || empty($Feed['itunes_explicit']) ) {
214
+ $NewSettings['itunes_explicit'] = $explicit_array[ $value ];
215
+ }
216
+ }
217
+ }
218
+
219
+ // itunes:image
220
+ $itunes_image = '';
221
+ if( preg_match('/<itunes:image.*href="(.*?)".*(\/>|>.*<\/itunes:image>)/is', $channel, $image) )
222
+ {
223
+ $itunes_image = html_entity_decode( trim( $image[1] ) ); // Now we need to download and save the image locally...
224
+
225
+ // download the image then save it locally...
226
+ if( $download_itunes_image ) {
227
+
228
+ $upload_path = false;
229
+ $upload_url = false;
230
+ $UploadArray = wp_upload_dir();
231
+ if( false === $UploadArray['error'] )
232
+ {
233
+ $upload_path = $UploadArray['basedir'].'/powerpress/';
234
+ $upload_url = $UploadArray['baseurl'].'/powerpress/';
235
+ $filename = str_replace(" ", "_", basename($itunes_image) );
236
+
237
+ if( file_exists($upload_path . $filename ) )
238
+ {
239
+ $filenameParts = pathinfo($filename);
240
+ if( !empty($filenameParts['extension']) ) {
241
+ do {
242
+ $filename_no_ext = substr($filenameParts['basename'], 0, (strlen($filenameParts['extension'])+1) * -1 );
243
+ $filename = sprintf('%s-%03d.%s', $filename_no_ext, rand(0, 999), $filenameParts['extension'] );
244
+ } while( file_exists($upload_path . $filename ) );
245
+ }
246
+ }
247
+
248
+ $image_data = wp_remote_fopen($itunes_image);
249
+ if( !empty($image_data) )
250
+ {
251
+ file_put_contents($upload_path.$filename, $image_data);
252
+ $NewSettings['itunes_image'] = $upload_url . $filename;
253
+ $NewSettings['rss2_image'] = $itunes_image;
254
+ }
255
+ }
256
+ } else if( $overwrite || empty($Feed['itunes_image']) ) {
257
+ $NewSettings['itunes_image'] = $itunes_image;
258
+ $NewSettings['rss2_image'] = $itunes_image;
259
+ }
260
+ }
261
+
262
+
263
+ if( preg_match('|<itunes:author>(.*?)</itunes:author>|is', $channel, $matches) ) {
264
+ $itunes_talent_name = $this->_sanatize_tag_value( $matches[1] );
265
+
266
+ if( $overwrite || empty($Feed['itunes_talent_name']) )
267
+ $NewSettings['itunes_talent_name'] = $itunes_talent_name;
268
+ }
269
+
270
+ // itunes:category (up to 3)
271
+ $itunes_categories = false;
272
+ if( preg_match_all('|<itunes:category.*text="(.*?)"|is', $channel, $matches) ) {
273
+ $pos = 1;
274
+ $itunes_categories = $matches[1];
275
+ $Categories = powerpress_itunes_categories();
276
+ $Categories = array_map('strtolower', $Categories);
277
+ $cats_by_title = array_flip( $Categories );
278
+
279
+ $FoundCategories = array();
280
+ while( list($index,$category) = each($itunes_categories) )
281
+ {
282
+ $category = str_replace('&amp;', '&', $category);
283
+ $category = strtolower($category);
284
+ if( !empty($cats_by_title[ $category ] ) )
285
+ $FoundCategories[] = $cats_by_title[ $category ];
286
+ }
287
+
288
+ // Now walk trouigh found categories and stack them correctly...
289
+ // this logic rebuilds the categorires in the correct order no matter what method the service stacked them
290
+ $FinalCats = array(1=>'', 2=>'', 3=>'');
291
+ $last_category_index = 1;
292
+ while( list($index,$cat_id) = each($FoundCategories) )
293
+ {
294
+ if( !empty($FinalCats[$last_category_index]) ) // Do we need to increment to the next category position
295
+ {
296
+ if( intval(substr($FinalCats[$last_category_index], 3)) > 0 )
297
+ {
298
+ $last_category_index++;
299
+ }
300
+ else if( intval(substr($FinalCats[$last_category_index],0, 2)) != intval(substr($cat_id,0, 2)) )
301
+ {
302
+ $last_category_index++;
303
+ }
304
+ // else we can overwrite this category with subcategory
305
+ }
306
+
307
+ if( $last_category_index > 3 )
308
+ break; // We are at the max cats available...
309
+
310
+ $FinalCats[ $last_category_index ] = $cat_id;
311
+ }
312
+
313
+ while( list($field_no, $cat_id) = each($FinalCats) ) {
314
+ if( empty( $cat_id) )
315
+ continue;
316
+ $field = sprintf('itunes_cat_%d', $field_no);
317
+
318
+ if( $overwrite || empty($Feed[ $field ]) ) {
319
+ $NewSettings[ $field ] = $cat_id;
320
+ }
321
+ }
322
+ }
323
+
324
+ if( !empty($NewSettings) )
325
+ {
326
+ // Save here..
327
+ if( get_option('powerpress_feed_podcast') ) { // If the settings were moved to the podcast channels feature...
328
+ powerpress_save_settings($NewSettings, 'powerpress_feed_podcast' ); // save a copy here if that is the case.
329
+ } else {
330
+ powerpress_save_settings($NewSettings, 'powerpress_feed' );
331
+ }
332
+
333
+ echo '<hr />';
334
+ echo '<p><strong>'. __('Program information imported', 'powerpress') .'</strong></p>';
335
+ echo '<ul class="ul-disc">';
336
+ while( list($field,$value) = each($NewSettings) )
337
+ {
338
+ if( $field == 'rss2_image' )
339
+ continue;
340
+
341
+ echo '<li>';
342
+ switch( $field )
343
+ {
344
+ case 'title': echo __('Feed Title (Show Title)', 'powerpress'); break;
345
+ case 'rss_language': echo __(' Feed Language', 'powerpress'); break;
346
+ case 'description': echo __('Feed Description', 'powerpress'); break;
347
+ case 'copyright': echo __('Copyright', 'powerpress'); break;
348
+ case 'itunes_talent_name': echo __('iTunes Author Name', 'powerpress'); break;
349
+ case 'itunes_summary': echo __('iTunes Program Summary', 'powerpress'); break;
350
+ case 'itunes_subtitle': echo __('iTunes Program Subtitle', 'powerpress'); break;
351
+ case 'itunes_image': echo __('iTunes Image', 'powerpress'); break;
352
+ case 'itunes_explicit': echo __('iTunes Explicit', 'powerpress'); break;
353
+ case 'email': echo __('iTunes Email', 'powerpress'); break;
354
+ case 'itunes_cat_1': echo __('iTunes Category', 'powerpress'); break;
355
+ case 'itunes_cat_2': echo __('iTunes Category 2', 'powerpress'); break;
356
+ case 'itunes_cat_3': echo __('iTunes Category 3', 'powerpress'); break;
357
+ default: echo $field . ': '.htmlspecialchars($value); break;
358
+ }
359
+ echo '</li>';
360
+ }
361
+ echo '</ul>';
362
+ }
363
+ }
364
+
365
+ function import_item($post, $import_strict=false, $import_blog_posts=false) {
366
+ global $wpdb;
367
+ $this->m_item_pos++;
368
+
369
+ $matches = array();
370
+ $post_title = false;
371
+ if( !preg_match('|<title>(.*?)</title>|is', $post, $matches) ) {
372
+ echo sprintf(__('Empty episode title for item %d', 'powerpress'), $this->m_item_pos);
373
+ $this->m_item_skipped_count++;
374
+ return false;
375
+ }
376
+ $post_title = $this->_sanatize_tag_value($matches[1]);
377
+
378
+ // Look for an enclosure, if not found skip it...
379
+ $enclosure_data = false;
380
+ if( !preg_match('|<enclosure(.*?)/>|is', $post, $enclosure_data) ) {
381
+ echo sprintf(__('No Media found for item %d', 'powerpress'), $this->m_item_pos);
382
+ if( empty($import_blog_posts) ) {
383
+ $this->m_item_skipped_count++;
384
+ return false;
385
+ }
386
+
387
+ echo ' - ';
388
+ }
389
+ if( !empty($enclosure_data[1]) ) {
390
+ $enclosure = $this->_parse_enclosure( '<enclosure '.$enclosure_data[1].' />', $post );
391
+ if( empty($enclosure) ) {
392
+ if( empty($import_blog_posts) ) {
393
+ echo sprintf(__('No Media found for item %d', 'powerpress'), $this->m_item_pos);
394
+ $this->m_item_skipped_count++;
395
+ return false;
396
+ }
397
+ }
398
+ }
399
+
400
+ // GUID has to be last, as we will use the media URL as the guid as a last resort
401
+ $guid = false;
402
+ if( preg_match('|<guid.*?>(.*?)</guid>|is', $post, $matches) )
403
+ $guid = $this->_sanatize_tag_value( $matches[1] );
404
+ else if( !empty($enclosure['url']) )
405
+ $guid = $enclosure['url'];
406
+
407
+ $post_date_gmt = false;
408
+ if( preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $matches) ) {
409
+ $post_date_gmt = strtotime($post_date_gmt[1]);
410
+ } else {
411
+ // if we don't already have something from pubDate
412
+ if( preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $matches) )
413
+ {
414
+ $post_date_gmt = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $matches[1]);
415
+ $post_date_gmt = str_replace('T', ' ', $post_date_gmt);
416
+ $post_date_gmt = strtotime($post_date_gmt);
417
+ }
418
+ }
419
+
420
+ $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt);
421
+ $post_date = get_date_from_gmt( $post_date_gmt );
422
+
423
+ // Before we go any further, lets see if we have imported this one already...
424
+ if( $import_strict && !empty($guid) )
425
+ $exists = $this->_post_exists_strict($guid);
426
+ else
427
+ $exists = $this->_post_exists($post_title, $guid, $post_date);
428
+
429
+ if( !empty($exists) )
430
+ {
431
+ echo sprintf(__('<i>%s</i> already imported.', 'powerpress'), htmlspecialchars($post_title) );
432
+ $this->m_item_skipped_count++;
433
+ return false;
434
+ }
435
+
436
+ // Okay awesome, lets dig through the rest...
437
+ $categories = array();
438
+ if( preg_match_all('|<category>(.*?)</category>|is', $post, $matches) )
439
+ $categories = $matches[1];
440
+
441
+ if ( empty($categories) ) {
442
+ if( preg_match_all('|<dc:subject>(.*?)</dc:subject>|is', $post, $matches) )
443
+ $categories = $matches[1];
444
+ }
445
+
446
+ $cat_index = 0;
447
+ foreach ($categories as $category) {
448
+ $categories[$cat_index] = $this->_sanatize_tag_value( $category );
449
+ $cat_index++;
450
+ }
451
+
452
+ $post_content = '';
453
+ if( preg_match('|<content:encoded>(.*?)</content:encoded>|is', $post, $matches) )
454
+ $post_content = $this->_sanatize_tag_value( $matches[1] );
455
+
456
+ if ( empty($post_content) ) {
457
+ // This is for feeds that put content in description
458
+ if( preg_match('|<description>(.*?)</description>|is', $post, $matches) )
459
+ $post_content = $this->_sanatize_tag_value( $matches[1] );
460
+ }
461
+
462
+ // Clean up content
463
+ $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
464
+ $post_content = str_replace('<br>', '<br />', $post_content);
465
+ $post_content = str_replace('<hr>', '<hr />', $post_content);
466
+
467
+ $post_author = 1;
468
+ $post_status = 'publish';
469
+
470
+ // Save this episode to the database...
471
+ $post_to_save = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories', 'enclosure');
472
+ $this->m_item_inserted_count++;
473
+ echo '<span style="color: green; font-weight: bold;">';
474
+ echo sprintf(__('<i>%s</i> imported.', 'powerpress'), htmlspecialchars($post_title) );
475
+ echo '</span>';
476
+ return $this->_import_post_to_db($post_to_save);
477
+ }
478
+
479
+ function _sanatize_tag_value($value)
480
+ {
481
+ if( !is_string($value) )
482
+ return '';
483
+
484
+ $value = trim($value);
485
+ if( preg_match('/^<!\[CDATA\[(.*)\]\]>$/is', $value, $matches) ) {
486
+ $value = $matches[1];
487
+ } else {
488
+ $value = html_entity_decode($value);
489
+ }
490
+
491
+ return $value;
492
+ }
493
+
494
+ function import_episodes($import_strict=false, $import_blog_posts=false) {
495
+ global $wpdb;
496
+ @set_time_limit(60*15); // Give it 15 minutes
497
+ $this->m_item_pos = 0;
498
+
499
+ $item_count = substr_count( $this->m_content, '<item>');
500
+ $item_count += substr_count( $this->m_content, '<ITEM>');
501
+
502
+ echo '<hr />';
503
+ echo '<p><strong>';
504
+ echo __('Importing Episodes...', 'powerpress');
505
+ echo '</strong></p>';
506
+
507
+ echo '<p>';
508
+ echo sprintf( __('Items Found: %d', 'powerpress'), $item_count);
509
+ echo '</p>';
510
+ @flush();
511
+
512
+ echo '<ol>';
513
+
514
+ $item_start_pos = 0;
515
+ $item_start_pos = mb_stripos($this->m_content, '<item>', $item_start_pos);
516
+ $item_end_pos = mb_stripos($this->m_content, '</item>', $item_start_pos);
517
+
518
+ $count = 0;
519
+ while( $item_start_pos !== false && $item_end_pos !== false ) // If one were to return false, we stap!
520
+ {
521
+ echo '<li>';
522
+ $new_start = $item_start_pos + mb_strlen('<item>');
523
+ $item_content = mb_substr($this->m_content, $new_start, $item_end_pos - $new_start);
524
+ $this->import_item($item_content, $import_strict, $import_blog_posts);
525
+ echo '</li>';
526
+
527
+ // Extra stop just in case...
528
+ if( $count > 3000 )
529
+ break;
530
+
531
+ if( $count % 50 == 0 )
532
+ @flush();
533
+
534
+ $item_start_pos = mb_stripos($this->m_content, '<item>', $item_end_pos); // Find the next item
535
+ $item_end_pos = mb_stripos($this->m_content, '</item>', $item_start_pos);
536
+ }
537
+ echo '</ol>';
538
+ }
539
+
540
+ function import() {
541
+ ?>
542
+ <div class="wrap">
543
+ <h3><?php _e('Importing Podcast', 'powerpress') ?></h3>
544
+ <?php
545
+
546
+ $result = false;
547
+ if ( empty($_POST['podcast_feed_url']) ) {
548
+ ?><p><?php _e('From Uploaded file...', 'powerpress'); ?></p><?php
549
+ $result = $this->_import_handle_upload();
550
+ }
551
+ else
552
+ {
553
+ ?><p><?php _e('From URL', 'powerpress'); ?> <?php echo esc_html($_POST['podcast_feed_url']); ?></p><?php
554
+ $result = $this->_import_handle_url();
555
+ }
556
+
557
+ if( $result == false )
558
+ return;
559
+ $import_strict = (!empty($_POST['import_strict'])?true:false);
560
+ $import_blog_posts = (!empty($_POST['import_blog_posts'])?true:false);
561
+ if( preg_match('/^(.*)<item>/is', $this->m_content, $matches) )
562
+ {
563
+ $overwrite_program_info = (!empty($_POST['import_overwrite_program_info'])?true:false);
564
+ $import_itunes_image = (!empty($_POST['import_itunes_image'])?true:false);
565
+ $this->import_program_info($matches[1], $overwrite_program_info, $import_itunes_image);
566
+ }
567
+
568
+ $this->import_episodes($import_strict, $import_blog_posts);
569
+
570
+ echo '<h3>';
571
+ echo __('Import Completed!', 'powerpress');
572
+ echo '</h3>';
573
+ echo '<p>'. sprintf(__('Items Skipped: %d', 'powerpress'), $this->m_item_skipped_count).'</p>';
574
+ echo '<p>'. sprintf(__('Items Inserted: %d', 'powerpress'), $this->m_item_inserted_count).'</p>';
575
+ echo '';
576
+ echo '<p>'. sprintf(__('You may now migrate your media manually or use the %s tool.','powerpress'), '<strong><a href="'.admin_url('admin.php?page=powerpress/powerpressadmin_migrate.php') .'">'. __('Migrate Media', 'powerpress') .'</a></strong>' ). '</p>';
577
+ }
578
+
579
+ function dispatch() {
580
+
581
+ $step = 0;
582
+ if( !empty($_POST['step']) )
583
+ $step = intval($_POST['step']);
584
+ else if( !empty($_GET['step']) )
585
+ $step = intval($_GET['step']);
586
+
587
+ $this->header();
588
+
589
+ switch ($step) {
590
+ case 0 :
591
+ $this->greet();
592
+ break;
593
+ case 1 :
594
+ check_admin_referer('import-powerpress-rss');
595
+ $result = $this->import();
596
+ if ( is_wp_error( $result ) )
597
+ echo $result->get_error_message();
598
+ break;
599
+ }
600
+
601
+ $this->footer();
602
+ }
603
+
604
+ function _post_exists_strict($guid)
605
+ {
606
+ global $wpdb;
607
+
608
+ $post_guid = wp_unslash( sanitize_post_field( 'guid', $guid, 0, 'db' ) );
609
+
610
+ $query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
611
+ $args = array();
612
+
613
+ if ( !empty ( $post_guid ) ) {
614
+ $query .= 'AND guid = %s';
615
+ $args[] = $post_guid;
616
+ }
617
+
618
+ if ( !empty ( $args ) )
619
+ return intval( $wpdb->get_var( $wpdb->prepare($query, $args) ) );
620
+
621
+ return 0;
622
+ }
623
+
624
+ function _post_exists($title, $guid = '', $date = '') {
625
+ global $wpdb;
626
+
627
+ $post_title = wp_unslash( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
628
+ $post_guid = wp_unslash( sanitize_post_field( 'guid', $guid, 0, 'db' ) );
629
+ $post_date = wp_unslash( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
630
+
631
+ $query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
632
+ $args = array();
633
+
634
+ if ( !empty ( $post_date ) ) {
635
+ $query .= ' AND post_date = %s';
636
+ $args[] = $post_date;
637
+ }
638
+
639
+ if ( !empty ( $post_title ) ) {
640
+ $query .= ' AND post_title = %s';
641
+ $args[] = $post_title;
642
+ }
643
+
644
+ if ( !empty ( $post_guid ) ) {
645
+ $query .= 'AND guid = %s';
646
+ $args[] = $post_guid;
647
+ }
648
+
649
+ if ( !empty ( $args ) )
650
+ return intval( $wpdb->get_var( $wpdb->prepare($query, $args) ) );
651
+
652
+ return 0;
653
+ }
654
+
655
+ function _import_post_to_db($post)
656
+ {
657
+ extract($post);
658
+ $post_id = wp_insert_post($post);
659
+ if ( is_wp_error( $post_id ) )
660
+ return $post_id;
661
+ if (!$post_id) {
662
+ _e('Couldn&#8217;t get post ID', 'powerpress');
663
+ return false;
664
+ }
665
+
666
+ if (0 != count($categories))
667
+ wp_create_categories($categories, $post_id);
668
+
669
+ if( !empty($enclosure['url']) )
670
+ {
671
+ $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'];
672
+ $serialize = array();
673
+ if( !empty($enclosure['duration']) && function_exists('powerpress_raw_duration') )
674
+ $serialize['duration'] = powerpress_raw_duration($enclosure['duration']);
675
+ if( !empty($enclosure['keywords']) )
676
+ $serialize['keywords'] = $enclosure['keywords'];
677
+ if( !empty($enclosure['summary']) )
678
+ $serialize['summary'] = $enclosure['summary'];
679
+ if( !empty($enclosure['subtitle']) )
680
+ $serialize['subtitle'] = $enclosure['subtitle'];
681
+ if( !empty($enclosure['author']) )
682
+ $serialize['author'] = $enclosure['author'];
683
+ if( !empty($enclosure['itunes_image']) )
684
+ $serialize['itunes_image'] = $enclosure['itunes_image'];
685
+ if( !empty($enclosure['block']) )
686
+ $serialize['block'] = $enclosure['block'];
687
+ if( !empty($enclosure['cc']) )
688
+ $serialize['cc'] = $enclosure['cc'];
689
+ if( !empty($enclosure['order']) )
690
+ $serialize['order'] = $enclosure['order'];
691
+ if( !empty($enclosure['explicit']) )
692
+ $serialize['explicit'] = $enclosure['explicit'];
693
+
694
+ if( !empty($serialize) )
695
+ $encstring .= "\n". serialize( $serialize );
696
+ add_post_meta($post_id, 'enclosure', $encstring, true);
697
+ }
698
+ return true;
699
+ }
700
+
701
+ function _parse_enclosure($string, $post)
702
+ {
703
+ global $wpdb;
704
+ $p = xml_parser_create();
705
+ xml_parse_into_struct($p, $string, $vals, $index);
706
+ xml_parser_free($p);
707
+
708
+ if( !empty($vals[0]['attributes']['URL']) )
709
+ {
710
+ $enclosure = array('url'=>trim($vals[0]['attributes']['URL']),'length'=>1, 'type'=>'');
711
+ if( !empty($vals[0]['attributes']['LENGTH']) )
712
+ $enclosure['length'] = trim($vals[0]['attributes']['LENGTH']);
713
+ if( !empty($vals[0]['attributes']['TYPE']) )
714
+ $enclosure['type'] = trim($vals[0]['attributes']['TYPE']);
715
+ if( empty($enclosure['type']) )
716
+ $enclosure['type'] = powerpress_get_contenttype($enclosure['url']);
717
+ $matches = array();
718
+ if( preg_match('|<itunes:duration>(.*?)</itunes:duration>|is', $post, $matches) )
719
+ {
720
+ $enclosure['duration'] = $this->_sanatize_tag_value( $matches[1] );
721
+ }
722
+
723
+ // keywords No longer supported by iTunes:
724
+ if( preg_match('|<itunes:keywords>(.*?)</itunes:keywords>|is', $post, $matches) )
725
+ {
726
+ $enclosure['keywords'] = $this->_sanatize_tag_value( $matches[1] );
727
+ }
728
+
729
+ if( preg_match('|<itunes:summary>(.*?)</itunes:summary>|is', $post, $matches) )
730
+ {
731
+ $enclosure['summary'] = $this->_sanatize_tag_value( $matches[1] );
732
+ }
733
+
734
+ if( preg_match('|<itunes:subtitle>(.*?)</itunes:subtitle>|is', $post, $matches) )
735
+ {
736
+ $enclosure['subtitle'] = $this->_sanatize_tag_value( $matches[1] );
737
+ }
738
+
739
+ if( preg_match('|<itunes:author>(.*?)</itunes:author>|is', $post, $matches) )
740
+ {
741
+ $enclosure['author'] = $this->_sanatize_tag_value( $matches[1] );
742
+ }
743
+
744
+ if( preg_match('|<itunes:block>(.*?)</itunes:block>|is', $post, $matches) )
745
+ {
746
+ $value = strtolower(trim( $matches[1] ));
747
+ if( $value == 'yes' )
748
+ $enclosure['block'] = 1;
749
+ }
750
+
751
+ // <itunes:image href="http://example.com/podcasts/everything/AllAboutEverything.jpg" />
752
+ if( preg_match('/<itunes:image[^h]*href="(.*?)".*(\/>|>.*<\/itunes:image>)/is', $post, $matches) )
753
+ {
754
+ $enclosure['itunes_image'] = html_entity_decode( trim( $matches[1] ) );
755
+ }
756
+
757
+ if( preg_match('|<itunes:isClosedCaptioned>(.*?)</itunes:isClosedCaptioned>|is', $post, $matches) )
758
+ {
759
+ $value = strtolower(trim( $matches[1] ));
760
+ if( $value == 'yes' )
761
+ $enclosure['cc'] = 1;
762
+ }
763
+
764
+ if( preg_match('|<itunes:order>(.*?)</itunes:order>|is', $post, $matches) )
765
+ {
766
+ $value = trim( $matches[1] );
767
+ if( !empty($value) )
768
+ $enclosure['order'] = intval($value);
769
+ }
770
+
771
+ if( preg_match('|<itunes:explicit>(.*?)</itunes:explicit>|is', $post, $matches) )
772
+ {
773
+ $explicit_array = array('yes'=>1, 'clean'=>2); // No need to save 'no'
774
+ $value = strtolower( trim( $matches[1] ) );
775
+ if( !empty($explicit_array[ $value ]) )
776
+ $enclosure['explicit'] = $explicit_array[ $value ];
777
+ }
778
+
779
+ return $enclosure;
780
+ }
781
+
782
+ return '';
783
+ }
784
+
785
+ function _import_handle_url() {
786
+
787
+ if( empty($_POST['podcast_feed_url']) ) {
788
+ echo '<p>'. __( 'URL is empty.', 'powerpress' ) .'<p>';
789
+ return false;
790
+ }
791
+
792
+ $content = wp_remote_fopen($_POST['podcast_feed_url']);
793
+ if( is_wp_error($content) ) {
794
+ echo '<p>'. $content->get_error_message() .'<p>';
795
+ return false;
796
+ }
797
+ $this->m_content = $content;
798
+ return true;
799
+ }
800
+
801
+ function _import_handle_upload() {
802
+ if ( ! isset( $_FILES['podcast_feed_file'] ) || empty($_FILES['podcast_feed_file']['tmp_name']) ) {
803
+ echo '<p>'. __( 'Upload failed.', 'powerpress' ).'<p>';
804
+ return false;
805
+ }
806
+
807
+ $this->m_content = file_get_contents($_FILES['podcast_feed_file']['tmp_name']);
808
+ return true;
809
+ }
810
+ } // end PowerPress_RSS_Podcast_Import class
811
+
812
+ $powerpress_rss_podcast_import = new PowerPress_RSS_Podcast_Import();
813
+
814
+ register_importer('powerpress-soundcloud-rss-podcast', __('Podcast from SoundCloud', 'powerpress'), __('Import episdoes from a SoundCloud podcast feed.', 'powerpress'), array ($powerpress_rss_podcast_import, 'dispatch'));
815
+ register_importer('powerpress-libsyn-rss-podcast', __('Podcast from LibSyn', 'powerpress'), __('Import episdoes from a LibSyn podcast feed.', 'powerpress'), array ($powerpress_rss_podcast_import, 'dispatch'));
816
+ register_importer('powerpress-podbean-rss-podcast', __('Podcast from PodBean ', 'powerpress'), __('Import episdoes from a PodBean podcast feed.', 'powerpress'), array ($powerpress_rss_podcast_import, 'dispatch'));
817
+ register_importer('powerpress-rss-podcast', __('Podcast RSS Feed', 'powerpress'), __('Import episdoes from a RSS podcast feed.', 'powerpress'), array ($powerpress_rss_podcast_import, 'dispatch'));
818
+
819
+ }; // end if WP_Importer exists
820
+
821
+ // eof
powerpressadmin.php CHANGED
@@ -1736,7 +1736,8 @@ function powerpress_admin_menu()
1736
 
1737
  add_options_page( __('PowerPress', 'powerpress'), __('PowerPress', 'powerpress'), POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic');
1738
 
1739
- add_submenu_page('powerpress/powerpressadmin_basic.php', __('Migrate to Blubrry Podcast Media Hosting', 'powerpress'), __('Migrate Media', 'powerpress') .' '. powerpressadmin_new('font-weight: bold; color: #ffffff;') , POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_migrate.php', 'powerpress_admin_page_migrate');
 
1740
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Podcasting SEO', 'powerpress'), '<span style="color:#f18500">'. __('Podcasting SEO', 'powerpress') .'</span> '.powerpressadmin_new('font-weight: bold; color: #ffffff;') .'', POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_search.php', 'powerpress_admin_page_search');
1741
 
1742
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Audio Player Options', 'powerpress'), __('Audio Player', 'powerpress'), POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_player.php', 'powerpress_admin_page_players');
@@ -3059,6 +3060,14 @@ function powerpress_admin_page_migrate()
3059
  powerpress_admin_page_footer(false);
3060
  }
3061
 
 
 
 
 
 
 
 
 
3062
 
3063
  // Admin page, advanced mode: feed settings
3064
  function powerpress_admin_page_search()
@@ -4472,3 +4481,7 @@ require_once( POWERPRESS_ABSPATH .'/powerpressadmin-jquery.php');
4472
  // Only include the dashboard when appropriate.
4473
  require_once( POWERPRESS_ABSPATH .'/powerpressadmin-dashboard.php');
4474
 
 
 
 
 
1736
 
1737
  add_options_page( __('PowerPress', 'powerpress'), __('PowerPress', 'powerpress'), POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_basic.php', 'powerpress_admin_page_basic');
1738
 
1739
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('Import podcast feed from SoundCloud, LibSyn, PodBean or other podcast service.', 'powerpress'), __('Import Podcast', 'powerpress') .' '. powerpressadmin_new('font-weight: bold; color: #ffffff;') , POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_import_feed.php', 'powerpress_admin_page_import_feed');
1740
+ add_submenu_page('powerpress/powerpressadmin_basic.php', __('Migrate media files to Blubrry Podcast Media Hosting with only a few clicks.', 'powerpress'), __('Migrate Media', 'powerpress') .' '. powerpressadmin_new('font-weight: bold; color: #ffffff;') , POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_migrate.php', 'powerpress_admin_page_migrate');
1741
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Podcasting SEO', 'powerpress'), '<span style="color:#f18500">'. __('Podcasting SEO', 'powerpress') .'</span> '.powerpressadmin_new('font-weight: bold; color: #ffffff;') .'', POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_search.php', 'powerpress_admin_page_search');
1742
 
1743
  add_submenu_page('powerpress/powerpressadmin_basic.php', __('PowerPress Audio Player Options', 'powerpress'), __('Audio Player', 'powerpress'), POWERPRESS_CAPABILITY_EDIT_PAGES, 'powerpress/powerpressadmin_player.php', 'powerpress_admin_page_players');
3060
  powerpress_admin_page_footer(false);
3061
  }
3062
 
3063
+ function powerpress_admin_page_import_feed()
3064
+ {
3065
+ powerpress_admin_page_header('powerpress/powerpressadmin_import_feed.php');
3066
+ require_once( POWERPRESS_ABSPATH .'/powerpressadmin-import-feed.php');
3067
+ powerpress_admin_import_feed();
3068
+ powerpress_admin_page_footer(false);
3069
+ }
3070
+
3071
 
3072
  // Admin page, advanced mode: feed settings
3073
  function powerpress_admin_page_search()
4481
  // Only include the dashboard when appropriate.
4482
  require_once( POWERPRESS_ABSPATH .'/powerpressadmin-dashboard.php');
4483
 
4484
+ if( defined('WP_LOAD_IMPORTERS') ) {
4485
+ require_once( POWERPRESS_ABSPATH .'/powerpressadmin-rss-import.php');
4486
+ }
4487
+
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: amandato, blubrry
3
  Tags: powerpress, podcasting, podcast, podcaster, itunes, google play music, google play, enclosure, professional, apple, apple tv, ipad, iphone, youtube, viddler, ustream, podcasting, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry, mp4, m4v, wordpressmu, mu, wordpress mu, multisite, multi site, mediacaster, post, plugin, posts, simple, social, dashboard, TSG, Buzzsprout, MTR, WP-boxCast, CastMyBlog, tgs podcasting, simple podcasting, seriously simple podcasting, seriously-simple-podcasting, serious, seriously, ssp, podlove, podcast.de, clammr, clammr radio, audio player, stitcher, show, shows, series, docs, documentation, support, free, add-ons, extensions, addons, libsyn, libsyn-podcasting, podbean, podomatic, spreaker
4
  Requires at least: 3.6
5
  Tested up to: 4.4
6
- Stable tag: 6.2.2
7
  Donate link: https://www.patreon.com/blubrry?ty=h
8
  License: GPLv2 or later
9
 
@@ -28,7 +28,8 @@ When you're ready you can switch to Advanced mode to tap into all the options pr
28
  - Integrated HTML5 Media Players: Audio/video Web players with embed support from sites such as YouTube.
29
  - Subscribe tools: Create subscribe page with our exclusive subscribe shortcode embed and subscribe sidebar widget optimized for responsive websites, high-resolution screens and Apple Retina displays.
30
  - Podcasting SEO: Improve discovery of your podcast on search engines such as Google, and with the iTunes podcast directory.
31
- - Migration tools: Quickly migrate from PodPress, TGS Podcasting, Seriously Simple Podcasting, Blogger or Movable Type without losing episodes.
 
32
  - Multi-podcast support: Create separate podcasts by category (Category Podcasting) or by media format (Podcast Channels).
33
  - Post type and taxonomy podcasting: Create podcasts from custom post types and taxonomies.
34
  - *Media Statistics: Get FREE Blubrry Media Statistics from your WordPress dashboard.
@@ -225,6 +226,19 @@ To install Blubrry PowerPress manually, follow these steps:
225
  = Become a PowerPress Patron! =
226
  Help support your favorite podcasting plugin via Patreon. [Visit Blubrry's Patreon page](https://www.patreon.com/blubrry?ty=h)
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  = 6.2.2 =
229
  * Released on 12/9/2015
230
  * WordPress 4.4 has changed how feed titles are set. Please update PowerPress immediately to avoid feed title issues.
3
  Tags: powerpress, podcasting, podcast, podcaster, itunes, google play music, google play, enclosure, professional, apple, apple tv, ipad, iphone, youtube, viddler, ustream, podcasting, audio, video, rss2, feed, player, media, rss, mp3, music, embed, feedburner, statistics, stats, flv, flash, id3, episodes, blubrry, mp4, m4v, wordpressmu, mu, wordpress mu, multisite, multi site, mediacaster, post, plugin, posts, simple, social, dashboard, TSG, Buzzsprout, MTR, WP-boxCast, CastMyBlog, tgs podcasting, simple podcasting, seriously simple podcasting, seriously-simple-podcasting, serious, seriously, ssp, podlove, podcast.de, clammr, clammr radio, audio player, stitcher, show, shows, series, docs, documentation, support, free, add-ons, extensions, addons, libsyn, libsyn-podcasting, podbean, podomatic, spreaker
4
  Requires at least: 3.6
5
  Tested up to: 4.4
6
+ Stable tag: 6.3
7
  Donate link: https://www.patreon.com/blubrry?ty=h
8
  License: GPLv2 or later
9
 
28
  - Integrated HTML5 Media Players: Audio/video Web players with embed support from sites such as YouTube.
29
  - Subscribe tools: Create subscribe page with our exclusive subscribe shortcode embed and subscribe sidebar widget optimized for responsive websites, high-resolution screens and Apple Retina displays.
30
  - Podcasting SEO: Improve discovery of your podcast on search engines such as Google, and with the iTunes podcast directory.
31
+ - Podcast Importing: Import your podcast from SoundCloud, LibSyn, PodBean, or other podcast RSS feed.
32
+ - Migration tools: Quickly migrate from PodPress, TGS Podcasting, Seriously Simple Podcasting, Blogger, or Movable Type without losing episodes.
33
  - Multi-podcast support: Create separate podcasts by category (Category Podcasting) or by media format (Podcast Channels).
34
  - Post type and taxonomy podcasting: Create podcasts from custom post types and taxonomies.
35
  - *Media Statistics: Get FREE Blubrry Media Statistics from your WordPress dashboard.
226
  = Become a PowerPress Patron! =
227
  Help support your favorite podcasting plugin via Patreon. [Visit Blubrry's Patreon page](https://www.patreon.com/blubrry?ty=h)
228
 
229
+ = 6.3 =
230
+ * Released on 12/14/2015
231
+ * Import Podcast by feed added. You can now migrate your podcast from any service such as SoundCloud, LibSyn or PodBean into your own WordPress site powered by PowerPress!. With only a couple clicks you can import your program information, artwork and episodes.
232
+ **NOTE: Import feature was planned for PowerPress 7.0. Based on requests and rumors we are releasing this feature now.
233
+ * Import podcast feature includes program level information (Thanks Daniel Lewis for your feedback!)
234
+ * Import podcast feature downloads iTunes artwork.
235
+ * Import podcast feature advanced options: Allow duplicate episode titles and dates, Overwrite podcast program information, and include blog posts.
236
+ * Import podcast feature only imports your feed and meta information. Media files may be migrated using the Media Migration tool or manually.
237
+ * Fixed bug with podcast titles not displaying in some situations when using WordPress versions older than 4.4. (Thanks Daniel Lewis for pointing out the issue)
238
+ * Fixed bug with image title not matching feed title (Thanks EntBuddha for the heads up!)
239
+ * Happy Holidays! [Jeff Buckley cover of Everyday People](https://www.youtube.com/watch?v=6CHwqGCnh7E)
240
+
241
+
242
  = 6.2.2 =
243
  * Released on 12/9/2015
244
  * WordPress 4.4 has changed how feed titles are set. Please update PowerPress immediately to avoid feed title issues.