Skip to content

Instantly share code, notes, and snippets.

@fastmover
Created August 16, 2016 21:04
Show Gist options
  • Select an option

  • Save fastmover/dfbd391b824c94f6181c841ac5bdd7e9 to your computer and use it in GitHub Desktop.

Select an option

Save fastmover/dfbd391b824c94f6181c841ac5bdd7e9 to your computer and use it in GitHub Desktop.
function powerPressHTTPStoHTTP( $ID = false, $post = false, $update = false )
{
if( ! $ID )
return;
if( isset( $_REQUEST[ 'Powerpress' ] ) and is_array( $_REQUEST[ 'Powerpress' ] ) ) {
$powerPress = $_REQUEST[ 'Powerpress' ];
if( is_array( $powerPress ) and count( $powerPress ) > 0 ) {
$meta = get_post_meta( $ID, 'enclosure', true);
if( ! empty( $meta ) ) {
if( FALSE !== $position = stripos( $meta, 'https' ) ) {
$MetaParts = explode("\n", $meta, 4);
if( count($MetaParts) > 0 )
$EnclosureURL = trim($MetaParts[0]);
$EnclosureSize = '';
if( count($MetaParts) > 1 )
$EnclosureSize = trim($MetaParts[1]);
$EnclosureType = '';
if( count($MetaParts) > 2 )
$EnclosureType = trim($MetaParts[2]);
$EpisodeData = false;
if( count($MetaParts) > 3 )
$EpisodeData = unserialize($MetaParts[3]);
$EnclosureURL = str_ireplace( "https", "http", $EnclosureURL );
$EpisodeData = str_ireplace( "https", "http", $EpisodeData );
$EnclosureData = $EnclosureURL . "\n" .
$EnclosureSize . "\n".
$EnclosureType . "\n" .
serialize($EpisodeData);
update_post_meta( $ID, 'enclosure', $EnclosureData );
}
}
}
}
}
add_action( 'save_post', 'powerPressHTTPStoHTTP' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment