diff --git a/php/classes/integrations/elementor/widgets/elementor-episode-list-widget.php b/php/classes/integrations/elementor/widgets/elementor-episode-list-widget.php index d4a85238..43fad20f 100644 --- a/php/classes/integrations/elementor/widgets/elementor-episode-list-widget.php +++ b/php/classes/integrations/elementor/widgets/elementor-episode-list-widget.php @@ -2,10 +2,11 @@ namespace SeriouslySimplePodcasting\Integrations\Elementor\Widgets; +use Elementor\Controls_Manager; +use Elementor\Widget_Base; use SeriouslySimplePodcasting\Controllers\Episode_Controller; -use WP_Query; -class Elementor_Episode_List_Widget extends \Elementor\Widget_Base { +class Elementor_Episode_List_Widget extends Widget_Base { public function get_name() { return 'Episode List'; } @@ -22,30 +23,13 @@ public function get_categories() { return [ 'podcasting' ]; } - public function get_episodes() { - $args = array( - 'fields' => array( 'post_title, id' ), - 'posts_per_page' => get_option('posts_per_page', 10), - 'post_type' => SSP_CPT_PODCAST - ); - - $episodes = new \WP_Query( $args ); - - $episode_options = []; - foreach ( $episodes as $episode ) { - $episode_options[ $episode->ID ] = $episode->post_title; - } - - return $episode_options; - } - protected function _register_controls() { $this->start_controls_section( 'content_section', [ 'label' => __( 'Content', 'seriously-simple-podcasting' ), - 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, + 'tab' => Controls_Manager::TAB_CONTENT, ] ); @@ -53,7 +37,7 @@ protected function _register_controls() { 'show_featured_image', [ 'label' => __( 'Show Featured Image', 'seriously-simple-podcasting' ), - 'type' => \Elementor\Controls_Manager::SWITCHER, + 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); @@ -61,7 +45,7 @@ protected function _register_controls() { 'show_episode_player', [ 'label' => __( 'Show Episode Player', 'seriously-simple-podcasting' ), - 'type' => \Elementor\Controls_Manager::SWITCHER, + 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); @@ -69,7 +53,7 @@ protected function _register_controls() { 'show_episode_excerpt', [ 'label' => __( 'Show Episode Excerpt', 'seriously-simple-podcasting' ), - 'type' => \Elementor\Controls_Manager::SWITCHER, + 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); @@ -84,7 +68,7 @@ protected function render() { 'show_episode_player' => $settings['show_episode_player'], 'show_episode_excerpt' => $settings['show_episode_excerpt'], ); - $episode_controller = new Episode_Controller( __FILE__, SSP_VERSION ); - echo $episode_controller->render_episodes( $render_settings ); + global $ss_podcasting; + echo $ss_podcasting->episode_controller->render_episodes( $render_settings ); } } diff --git a/php/classes/integrations/elementor/widgets/elementor-media-player-widget.php b/php/classes/integrations/elementor/widgets/elementor-media-player-widget.php index c46f94a6..6fd54c94 100644 --- a/php/classes/integrations/elementor/widgets/elementor-media-player-widget.php +++ b/php/classes/integrations/elementor/widgets/elementor-media-player-widget.php @@ -2,9 +2,9 @@ namespace SeriouslySimplePodcasting\Integrations\Elementor\Widgets; -use SeriouslySimplePodcasting\Controllers\Players_Controller; +use Elementor\Widget_Base; -class Elementor_Media_Player_Widget extends \Elementor\Widget_Base { +class Elementor_Media_Player_Widget extends Widget_Base { public function get_name() { return 'Media Player'; diff --git a/php/classes/integrations/elementor/widgets/elementor-recent-episodes-widget.php b/php/classes/integrations/elementor/widgets/elementor-recent-episodes-widget.php index 9bbda503..2861ccf6 100644 --- a/php/classes/integrations/elementor/widgets/elementor-recent-episodes-widget.php +++ b/php/classes/integrations/elementor/widgets/elementor-recent-episodes-widget.php @@ -2,9 +2,10 @@ namespace SeriouslySimplePodcasting\Integrations\Elementor\Widgets; +use Elementor\Widget_Base; use SeriouslySimplePodcasting\Controllers\Episode_Controller; -class Elementor_Recent_Episodes_Widget extends \Elementor\Widget_Base { +class Elementor_Recent_Episodes_Widget extends Widget_Base { public function get_name() { return 'Recent Episodes'; } @@ -22,8 +23,7 @@ public function get_categories() { } protected function render() { - $settings = $this->get_settings_for_display(); - $episode_controller = new Episode_Controller( __FILE__, SSP_VERSION ); - echo $episode_controller->render_recent_episodes(); + global $ss_podcasting; + echo $ss_podcasting->episode_controller->render_recent_episodes(); } } diff --git a/php/classes/integrations/elementor/widgets/elementor-select-episode-widget.php b/php/classes/integrations/elementor/widgets/elementor-select-episode-widget.php index 3d761900..78c3a511 100644 --- a/php/classes/integrations/elementor/widgets/elementor-select-episode-widget.php +++ b/php/classes/integrations/elementor/widgets/elementor-select-episode-widget.php @@ -2,9 +2,10 @@ namespace SeriouslySimplePodcasting\Integrations\Elementor\Widgets; +use Elementor\Widget_Base; use SeriouslySimplePodcasting\Controllers\Episode_Controller; -class Elementor_Select_Episode_Widget extends \Elementor\Widget_Base { +class Elementor_Select_Episode_Widget extends Widget_Base { public function get_name() { return 'Select Episode'; } @@ -66,13 +67,14 @@ protected function _register_controls() { protected function render() { $settings = $this->get_settings_for_display(); $i = 0; + + $episode_ids = array(); foreach ( $settings['show_elements'] as $element ) { $episode_ids[ $i ] = $element; $i ++; } - $episode_controller = new Episode_Controller( __FILE__, SSP_VERSION ); - - echo $episode_controller->episode_list( $episode_ids ); + global $ss_podcasting; + echo $ss_podcasting->episode_controller->episode_list( $episode_ids ); } } diff --git a/php/classes/integrations/elementor/widgets/elementor-subscribe-buttons-widget.php b/php/classes/integrations/elementor/widgets/elementor-subscribe-buttons-widget.php index f74e644f..e73a66f6 100644 --- a/php/classes/integrations/elementor/widgets/elementor-subscribe-buttons-widget.php +++ b/php/classes/integrations/elementor/widgets/elementor-subscribe-buttons-widget.php @@ -2,10 +2,10 @@ namespace SeriouslySimplePodcasting\Integrations\Elementor\Widgets; +use Elementor\Widget_Base; use Exception; -use SeriouslySimplePodcasting\Controllers\Players_Controller; -class Elementor_Subscribe_Buttons_Widget extends \Elementor\Widget_Base { +class Elementor_Subscribe_Buttons_Widget extends Widget_Base { /** * Class constructor. @@ -46,22 +46,6 @@ public function get_categories() { return [ 'podcasting' ]; } - public function get_episodes() { - $args = array( - 'fields' => array( 'post_title, id' ), - 'posts_per_page' => - 1, - 'post_type' => SSP_CPT_PODCAST - ); - - $episodes = get_posts( $args ); - $episode_options = []; - foreach ( $episodes as $episode ) { - $episode_options[ $episode->ID ] = $episode->post_title; - } - - return $episode_options; - } - protected function _register_controls() { $this->start_controls_section(