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.5.0 #799

Merged
merged 3 commits into from
Aug 14, 2024
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
4 changes: 2 additions & 2 deletions assets/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jQuery(document).ready(function($) {
});
},
/**
* Validate the api credentials
*/
* Validate the api credentials
*/
initConnect = function () {
$connectBtn.on('click', function (e) {
e.preventDefault();
Expand Down
14 changes: 14 additions & 0 deletions php/classes/controllers/class-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ public function register_hooks_and_filters() {
add_filter( 'ssp_field_data', array( $this, 'provide_podcasts_sync_status' ), 10, 2 );

$this->generate_dynamic_color_scheme();

add_shortcode( 'castos_email', array( $this, 'castos_email' ) );
}

/**
* Gets castos email to show in the Hosting tab.
*
* @since 3.5.0
*
* @return string
* @throws \Exception
*/
public function castos_email() {
return $this->castos_handler->get_email();
}

/**
Expand Down
29 changes: 29 additions & 0 deletions php/classes/handlers/class-castos-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function __construct( $feed_handler, $log_helper ) {
add_filter( 'http_request_args', array( $this, 'authorization_headers' ), 10, 2 );
}


/**
* Adds authorization headers
*
Expand Down Expand Up @@ -181,6 +182,34 @@ public function connect( $account_api_token ) {
return $response;
}

/**
* Gets connected user email.
*
* @since 3.5.0
*
* @return string
* @throws Exception
*/
public function get_email() {
$this->logger->log( __METHOD__ );

$cache_key = 'ssp_castos_api_email';

$email = wp_cache_get( $cache_key );

if ( $email ) {
return $email;
}

$res = $this->send_request( 'api/v2/' );

$email = isset( $res['email'] ) ? $res['email'] : '';

wp_cache_add( $cache_key, $email, '', MINUTE_IN_SECONDS );

return $email;
}

public function set_token( $token ) {
update_option( self::API_TOKEN_OPTION, $token );
}
Expand Down
88 changes: 47 additions & 41 deletions php/config/settings/hosting.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,72 @@
* @var array $podcast_options
* */
return array(
'title' => __('Hosting', 'seriously-simple-podcasting'),
'button_text' => __('Connect', 'seriously-simple-podcasting'),
'title' => __( 'Hosting', 'seriously-simple-podcasting' ),
'button_text' => __( 'Connect', 'seriously-simple-podcasting' ),
'button_class' => 'castos-connect disabled hidden',
'sections' => array(
'credentials' => array(
'condition_callback' => function () {
return !ssp_is_connected_to_castos();
return ! ssp_is_connected_to_castos();
},
'title' => __('Podcast Hosting', 'seriously-simple-podcasting'),
'description' => sprintf(__('Connect your WordPress site to your %s account.', 'seriously-simple-podcasting'), '<a target="_blank" href="' . SSP_CASTOS_APP_URL . '">Castos</a>'),
'fields' => array(
'title' => __( 'Podcast Hosting', 'seriously-simple-podcasting' ),
'description' => sprintf( __( 'Connect your WordPress site to your %s account.', 'seriously-simple-podcasting' ), '<a target="_blank" href="' . SSP_CASTOS_APP_URL . '">Castos</a>' ),
'fields' => array(
array(
'id' => 'podmotor_account_api_token',
'type' => 'text',
'label' => __('Castos API token', 'seriously-simple-podcasting'),
'description' => sprintf(__('Your Castos API token. Available from your %s.', 'seriously-simple-podcasting'), '<a target="_blank" href="' . SSP_CASTOS_APP_URL . 'integrations/api-details' . '">Castos dashboard</a>'),
'default' => '',
'placeholder' => __('Enter your API token', 'seriously-simple-podcasting'),
'callback' => 'sanitize_text_field',
'class' => 'regular-text',
'id' => 'podmotor_account_api_token',
'type' => 'text',
'label' => __( 'Castos API token', 'seriously-simple-podcasting' ),
'description' => sprintf( __( 'Your Castos API token. Available from your %s.', 'seriously-simple-podcasting' ), '<a target="_blank" href="' . SSP_CASTOS_APP_URL . 'integrations/api-details' . '">Castos dashboard</a>' ),
'default' => '',
'placeholder' => __( 'Enter your API token', 'seriously-simple-podcasting' ),
'callback' => 'sanitize_text_field',
'class' => 'regular-text',
),
),
),
'sync' => array(
'sync' => array(
'condition_callback' => 'ssp_is_connected_to_castos',
'title' => __('Sync to Castos', 'seriously-simple-podcasting'),
'no_store' => true,
'description' => sprintf(
__('Use this option for a one time sync of your existing WordPress podcast to your Castos account. If you encounter any problems with it, please contact support at [email protected].', 'seriously-simple-podcasting'),
'<a href="' . SSP_CASTOS_APP_URL . '">Castos</a>'
),
'fields' => array(
'title' => __( 'Sync to Castos', 'seriously-simple-podcasting' ),
'no_store' => true,
'fields' => array(
array(
'id' => 'castos_sync_info',
'label' => __( 'Castos Account', 'seriously-simple-podcasting' ),
'description' => do_shortcode( '[castos_email]' ),
'type' => 'info',
),
array(
'id' => 'podcasts_sync',
'label' => __('Podcast', 'seriously-simple-podcasting'),
'description' => __('Select the podcast you want to sync to your Castos hosting account.', 'seriously-simple-podcasting'),
'type' => 'podcasts_sync',
'options' => $podcast_options,
'id' => 'podcasts_sync',
'label' => __( 'Podcast', 'seriously-simple-podcasting' ),
'description' => __( 'Select the podcast you want to sync to your Castos hosting account.', 'seriously-simple-podcasting' ),
'type' => 'podcasts_sync',
'options' => $podcast_options,
),
array(
'id' => 'trigger_sync',
'type' => 'button',
'label' => esc_attr(__('Trigger Sync', 'seriously-simple-podcasting')),
'id' => 'trigger_sync',
'type' => 'button',
'label' => esc_attr( __( 'Trigger Sync', 'seriously-simple-podcasting' ) ),
'description' => '<br><br>' . sprintf(
__( 'Use this option for a one time sync of your existing WordPress podcast to your %s. If you encounter any problems with it, please contact support at [email protected].', 'seriously-simple-podcasting' ),
'<a target="_blank" rel="noopener" href="' . esc_attr( SSP_CASTOS_APP_URL ) . '">' . __( 'Castos account', 'seriously-simple-podcasting' ) . '</a>'
),
'class' => 'button-primary',
),
),
),
'disconnect' => array(
'disconnect' => array(
'condition_callback' => 'ssp_is_connected_to_castos',
'title' => __('Danger Zone', 'seriously-simple-podcasting'),
'no_store' => true,
'fields' => array(
'title' => __( 'Danger Zone', 'seriously-simple-podcasting' ),
'no_store' => true,
'fields' => array(
array(
'id' => 'disconnect_castos',
'label' => __('Disconnect', 'seriously-simple-podcasting'),
'description' => __('Select this if you wish to disconnect your Castos account.', 'seriously-simple-podcasting'),
'type' => 'button',
'default' => '',
'callback' => 'wp_strip_all_tags',
'class' => 'disconnect-castos button',
'id' => 'disconnect_castos',
'label' => __( 'Disconnect', 'seriously-simple-podcasting' ),
'description' => __( 'Select this if you wish to disconnect your Castos account.', 'seriously-simple-podcasting' ),
'type' => 'button',
'default' => '',
'callback' => 'wp_strip_all_tags',
'class' => 'disconnect-castos button',
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/3_main-feed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: Login
And I can see in source "xmlns:podcast=\"https://podcastindex.org/namespace/1.0\""
And I can see in source "<channel>"
And I can see in source "<title>Automated test show</title>"
And I can see in source "<atom:link href=\"{{base_url_without_port}}/feed/podcast/automated-test-show/\" rel=\"self\" type=\"application/rss+xml\"/>"
And I can see in source "<atom:link href=\"{{base_url}}/feed/podcast/automated-test-show/\" rel=\"self\" type=\"application/rss+xml\"/>"
And I can see in source "<link>{{base_url}}/podcasts/automated-test-show/</link>"
And I can see in source "<description>This show is to test some SSP functionality</description>"
And I can see in source "<lastBuildDate>"
Expand Down
Loading