Post to Social"; $can_post = true; echo "

\n"; } } else { echo "Post to Social"; } echo " "; echo "Status: "; // What is the status of the posting to social? if ( get_post_status( get_the_ID() ) == 'publish' ) { if ( get_post_meta( get_the_ID(), 'pts_scheduled', true ) ) { _e( 'Episode posted to social sites.', 'powerpress' ); } else if( $can_post == false ) { _e( 'No podcast episode available in this post to send to social sites.', 'powerpress' ); } else if (parse_url($EpisodeData['url'], PHP_URL_HOST) == 'media.blubrry.com') { _e( 'Nothing posted yet.', 'powerpress' ); echo ' '; echo "Post Now!"; } else { _e('The media file must be hosted on Blubrry to post to social sites.', 'powerpress'); } } else { echo "This post must be published before you can post to social sharing sites."; } echo "

"; echo 'About: Post podcast episodes to Twitter, YouTube and Facebook using Blubrry\'s Post to Social service.'; echo "

"; } function do_pings() { $Settings = get_option( 'powerpress_general' ); $post_id = get_the_ID(); $guid = get_the_guid(); $enclosure_data = powerpress_get_enclosure_data( $post_id ); if ( !empty( $enclosure_data ) ) { $results = callUpdateListing($post_id, $guid); $podcast_id = $results['podcast-id']; add_post_meta( $post_id, 'podcast-id', $podcast_id, true ); } } } /** * @param int $post_id * @param string $program_keyword * @param string $guid * @return array|mixed|object|string */ function callUpdateListing( $post_id, $guid ) { $Settings = get_option('powerpress_general'); $episodeData = powerpress_get_enclosure_data( $post_id ); if(!empty($episodeData['program_keyword'])) { //for multi account support, if empty then fallback to $program_keyword = $episodeData['program_keyword']; } else { $program_keyword = $Settings['blubrry_program_keyword']; } if( empty($episodeData['duration']) ) $episodeData['duration'] = ''; $subtitle = ''; if( !empty($episodeData['subtitle']) ) $subtitle = $episodeData['subtitle']; if ( empty( $subtitle ) && !empty($episodeData['summary']) ) { $subtitle = substr( $episodeData['summary'], 0, 255 ); } if ( empty( $subtitle ) ) { $subtitle = powerpress_get_the_exerpt( false, true, $post_id ); } if ( empty( $subtitle ) ) { $subtitle = substr( get_the_content( $post_id ), 0, 255 ); } $FeedSettings = get_option( 'powerpress_feed' ); $post_params = array( 'feed-url' => '', // required 'title' => get_the_title( $post_id ), // required 'date' => get_the_date( 'r', $post_id ), // required 'guid' => $guid, 'media-url' => $episodeData['url'], // required 'subtitle' => $subtitle, 'duration' => $episodeData['duration'], // hh:mm:ss format; we assume no podcast episode will exceed 24 hours 'filesize' => $episodeData['size'], // required 'explicit' => $FeedSettings['itunes_explicit'], 'link' => get_the_permalink( $post_id ), 'image' => $FeedSettings['itunes_image'], ); $api_url_array = powerpress_get_api_array(); foreach ( $api_url_array as $api_url ) { $response = powerpress_remote_fopen( "{$api_url}social/{$program_keyword}/update-listing.json", $Settings['blubrry_auth'], json_encode( $post_params ) ); if ( $response ) { break; } } if ( $response ) { $result = json_decode( $response, true ); if( !empty($result) ) return $result; return $response; } else { return false; } } /** * @param string $program_keyword * @return array|mixed|object|string */ function callGetSocialOptions( $program_keyword, $podcast_id ) { $Settings = get_option( 'powerpress_general' ); $api_url_array = powerpress_get_api_array(); foreach ( $api_url_array as $api_url ) { $response = powerpress_remote_fopen("{$api_url}social/{$program_keyword}/get-social-options.json?podcast_id={$podcast_id}", $Settings['blubrry_auth'] ); if ( $response ) { break; } } if ( $response ) { return json_decode( $response, true ); } } /** * Generates an HTML text input * * @param $label * @param string $name * @param string $value * * @param string $placeholder * @param string $help_text * @param int $rows * @param int $maxlength * * @return string */ function generate_text_field( $label, $name, $value='', $placeholder='', $help_text='', $rows=1, $maxlength=4000 ) { $text_field = '
' ."\n"; $text_field .= "\n"; if ( $rows === 1 ) { $text_field .= ' 1 ) { $text_field .= $value; $text_field .= ''; } $text_field .= "\n{$help_text}"; $text_field .= "\n
"; return $text_field; } /** * Generates an HTML checkbox input * * @param string $label * @param string $name * @param string $value * @param string $checked 'checked' to have the box checked, '' otherwise * * @return string */ function generate_checkbox( $label, $name, $value, $checked='' ) { $checkbox = '' ."\n"; return $checkbox; } /** * Generates an HTML radio input * * @param string $label * @param string $name * @param string $value * @param string $checked 'checked' to have the radio selected, '' otherwise * * @return string */ function generate_radio( $label, $name, $value, $checked='' ) { $checkbox = '' ."\n"; return $checkbox; } function displayStatus($isPostedArray) { $tempStatusArray = $isPostedArray; if (sizeof($tempStatusArray) > 1){ if (end($tempStatusArray) == 0){ $tempStatusArray = array($tempStatusArray[0], end($tempStatusArray)); } else { $tempStatusArray = array($tempStatusArray[0]); } } foreach($tempStatusArray as $isPosted){ if ($isPosted == POWERPRESS_POSTED_STATUS_SUCCESS) { ?> Posted! 1) {?> Post Rescheduled Post Scheduled Error occurred: Video creation failed Error occurred: Mp3 file required for posting to Youtube Error occurred: Please re-link your account POWERPRESS_POSTED_STATUS_SUCCESS) { ?> Error occurred

get_post_meta( $post_id, 'podcast-id', true ) ); } else { $response = callUpdateListing( $post_id, $guid ); } if ( !is_array( $response ) ) { // an error occurred\ echo "

"; echo $response; exit; } //die('ok2'); if ( isset( $response['error'] ) ) { powerpress_page_message_add_notice( $response['error'] ); powerpress_page_message_print(); ?>

{$response['success']}"; //else //var_dump($response); ?>
No social accounts linked'; echo '

Visit the Podcaster Dashboard to link your social accounts

'; } if (!empty($response['accounts']['Twitter'])){ echo '

' ."" ." Twitter" .'

'; ?>
$account){ $isPostedToTwitter = $account['status']; ?>

Characters Left: Player URL: ' ."" ." Youtube" .''; ?>
$account){ ?>

' ."" ." Facebook" .''; ?>
$account){ foreach ($account['pages'] as $page){ ?>



Disclaimer: By hitting "Post to Selected Media Accounts" you are agreeing to allow Blubrry to post the above content on the selected Social Media Accounts.

$value ) { if ( $value ) { // we don't allow empty messages to be posted to social media preg_match("/-(\d+)-?/", $key, $matches); $social_id = $matches[1]; preg_match("/^(\w+)-/i", $key, $matches); $social_type = strtolower($matches[1]); if ( !isset( $post_data[ $social_id ] ) ) { $post_data[ $social_id ] = array( 'social-id' => $social_id, 'social-type' => $social_type, ); } if ( !isset( $post_data[ $social_id ]['social-data'] ) ) { $post_data[ $social_id ]['social-data'] = array(); } $field_name = preg_replace( "/^\w+-/i", "", $key ); $post_data[ $social_id ]['social-data'][ $field_name ] = $value; } }*/ if (!empty($_POST['twitter_content'])){ $post_data['twitter']['accounts'] = $_POST['twitter_meta']; $post_data['twitter']['content'] = $_POST['twitter_content']; $post_data['twitter']['link'] = $_POST['twitter_link']; } if (!empty($_POST['facebook_description'])){ $post_data['facebook']['accounts'] = $_POST['facebook_meta']; $post_data['facebook']['description'] = $_POST['facebook_description']; if (!empty($_POST['facebook_link'])){ $post_data['facebook']['link'] = $_POST['facebook_link']; } else { $post_data['facebook']['link'] = $_POST['twitter_link']; } } if (!empty($_POST['youtube_description'])){ $post_data['youtube']['accounts'] = $_POST['youtube_meta']; $post_data['youtube']['description'] = $_POST['youtube_description']; $post_data['youtube']['title'] = $_POST['youtube_title']; } $post_params = array( 'podcast-id' => $podcast_id, 'post-data' => $post_data, '' ); foreach ( $api_url_array as $api_url ) { $response = powerpress_remote_fopen( "{$api_url}social/{$program_keyword}/post.json", $Settings['blubrry_auth'], json_encode( $post_params ) ); if ( $response ) { break; } } $response = json_decode( $response, true ); if ( $response['status'] == 'success' ) { powerpress_page_message_add_notice( __( 'Posting to social been scheduled! Please allow up to an hour to post.', 'powerpress' ) ); powerpress_page_message_print(); add_post_meta( $post_id, 'pts_scheduled', 1, true ); } else { powerpress_page_message_add_notice( $response['error'] ); powerpress_page_message_print(); } ?>