Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/3.8.0 #826

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions php/classes/controllers/class-podcast-post-types-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ protected function register_hooks_and_filters() {
// Update podcast details to Castos when a post is updated or saved
add_action( 'save_post', array( $this, 'sync_episode' ), 20, 2 );
add_action( 'et_save_post', array( $this, 'sync_divi_episode' ) );
add_action( 'elementor/editor/after_save', array( $this, 'sync_elementor_episode' ) );

// Assign default series if no series was specified
add_action( 'save_post', array( $this, 'maybe_assign_default_series' ), 20 );
Expand Down Expand Up @@ -741,6 +742,10 @@ public function sync_divi_episode( $post_id ) {
// Post type check
$post = get_post( $post_id );

if( 'publish' !== $post->post_status ){
return;
}

$podcast_post_types = ssp_post_types();

if ( ! in_array( $post->post_type, $podcast_post_types ) || ! ssp_is_connected_to_castos() ) {
Expand All @@ -760,12 +765,36 @@ public function sync_divi_episode( $post_id ) {

add_filter( 'ssp_feed_item_raw_content', $get_divi_content, 10, 2 );

$this->castos_handler->upload_episode_to_castos( $post );
$this->upload_episode_to_castos( $post );

remove_filter( 'ssp_feed_item_raw_content', $get_divi_content );
}

/**
* Syncs an Elementor episode with Castos
*
* @since 3.8.0
*
* @param $post_id
*
* @return void
*/
public function sync_elementor_episode( $post_id ) {
// Post type check
$post = get_post( $post_id );

if( 'publish' !== $post->post_status ){
return;
}

$podcast_post_types = ssp_post_types();

if ( ! in_array( $post->post_type, $podcast_post_types ) || ! ssp_is_connected_to_castos() ) {
return;
}

$this->upload_episode_to_castos( $post );
}

/**
* Send the podcast details to Castos
Expand Down Expand Up @@ -807,19 +836,34 @@ public function sync_episode( $id, $post ) {

$this->episode_repository->delete_episode_sync_error( $post->ID );

$this->upload_episode_to_castos( $post );
}


/**
* Uploads an episode to Castos and updates the episode's sync post metadata.
* Schedules a sync by cron in case of a sync error.
*
* @since 3.8.0
*
* @param $post
*
* @return void
*/
protected function upload_episode_to_castos( $post ) {
$response = $this->castos_handler->upload_episode_to_castos( $post );

if ( $response->success ) {
if ( $response->castos_episode_id ) {
update_post_meta( $id, 'podmotor_episode_id', $response->castos_episode_id );
update_post_meta( $post->ID, 'podmotor_episode_id', $response->castos_episode_id );
}
$this->admin_notices_handler->add_flash_notice(
$response->message,
Admin_Notifications_Handler::SUCCESS
);

// if uploading was scheduled before, lets unschedule it
delete_post_meta( $id, 'podmotor_schedule_upload' );
delete_post_meta( $post->ID, 'podmotor_schedule_upload' );
$this->episode_repository->update_episode_sync_status( $post->ID, Sync_Status::SYNC_STATUS_SYNCED );
$this->episode_repository->delete_sync_error( $post->ID );
} else {
Expand Down
4 changes: 2 additions & 2 deletions seriously-simple-podcasting.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Seriously Simple Podcasting
* Version: 3.8.0-alpha
* Version: 3.8.0-alpha.2
* Plugin URI: https://castos.com/seriously-simple-podcasting/?utm_medium=sspodcasting&utm_source=wordpress&utm_campaign=wpplugin_08_2019
* Description: Podcasting the way it's meant to be. No mess, no fuss - just you and your content taking over the world.
* Author: Castos
Expand All @@ -22,7 +22,7 @@
exit;
}

define( 'SSP_VERSION', '3.8.0-alpha' );
define( 'SSP_VERSION', '3.8.0-alpha.2' );
define( 'SSP_PLUGIN_FILE', __FILE__ );
define( 'SSP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SSP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
Expand Down
Loading