Skip to content

Commit

Permalink
episodes widget #40
Browse files Browse the repository at this point in the history
  • Loading branch information
jameer1612 committed Nov 23, 2022
1 parent 894c81d commit 3b5d75f
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 13 deletions.
3 changes: 2 additions & 1 deletion core/modules-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function __construct() {
'video',
'image-box',
'page-settings',
'mas-episodes',
'mas-tv-shows-episodes',
'episodes',
);

foreach ( $modules as $module_name ) {
Expand Down
6 changes: 6 additions & 0 deletions modules/episodes/css/episodes.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.episodes-wrapper {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
overflow-y: hidden;
}
12 changes: 6 additions & 6 deletions modules/mas-episodes/module.php → modules/episodes/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package MASElementor/Modules/MasBreadcrumb/Widgets
*/

namespace MASElementor\Modules\MasEpisodes;
namespace MASElementor\Modules\Episodes;

use MASElementor\Base\Module_Base;

Expand All @@ -23,7 +23,7 @@ class Module extends Module_Base {
* @return array
*/
public function get_style_depends() {
return array( 'mas-episodes-stylesheet' );
return array( 'episodes-stylesheet' );
}

/**
Expand All @@ -33,7 +33,7 @@ public function get_style_depends() {
*/
public function get_widgets() {
return array(
'Mas_Episodes',
'Episodes',
);
}

Expand All @@ -43,7 +43,7 @@ public function get_widgets() {
* @return string
*/
public function get_name() {
return 'mas-episodes';
return 'episodes';
}
/**
* Add Actions.
Expand All @@ -67,8 +67,8 @@ public function __construct() {
*/
public function register_frontend_styles() {
wp_register_style(
'mas-episodes-stylesheet',
MAS_ELEMENTOR_MODULES_URL . 'mas-episodes/css/mas-episodes-tab.css',
'episodes-stylesheet',
MAS_ELEMENTOR_MODULES_URL . 'episodes/css/episodes.css',
array(),
MAS_ELEMENTOR_VERSION
);
Expand Down
156 changes: 156 additions & 0 deletions modules/episodes/widgets/episodes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php
/**
* The Mas Nav Tab Widget.
*
* @package MASElementor/Modules/Episodes/Widgets
*/

namespace MASElementor\Modules\Episodes\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Modules\DynamicTags\Module as TagsModule;
use MASElementor\Base\Base_Widget;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Repeater;
use MASElementor\Core\Controls_Manager as MAS_Controls_Manager;
use Elementor\Icons_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Controls_Stack;


if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

/**
* MAS Episodes Elementor Widget.
*/
class Episodes extends Base_Widget {

/**
* Get the name of the widget.
*
* @return string
*/
public function get_name() {
return 'episodes';
}

/**
* Get the title of the widget.
*
* @return string
*/
public function get_title() {
return esc_html__( 'Episodes', 'mas-elementor' );
}

/**
* Get the icon for the widget.
*
* @return string
*/
public function get_icon() {
return 'eicon-product-related';
}

/**
* Get the keywords associated with the widget.
*
* @return array
*/
public function get_keywords() {
return array( 'episodes', 'mas' );
}

/**
* Get the categories for the widget.
*
* @return array
*/
public function get_categories() {
return array( 'mas-elements' );
}

/**
* Get style dependencies.
*
* Retrieve the list of style dependencies the element requires.
*
* @since 1.9.0
*
* @return array Element styles dependencies.
*/
public function get_style_depends() {
return array( 'episodes-stylesheet' );
}

/**
* Register Controls in Layout Section.
*/
protected function register_controls() {
$this->start_controls_section(
'section_layout',
array(
'label' => __( 'Layout', 'mas-elementor' ),
'tab' => Controls_Manager::TAB_CONTENT,
)
);

$templates = function_exists( 'mas_template_options' ) ? mas_template_options() : array();
$this->add_control(
'select_template',
array(
'label' => esc_html__( 'Mas Templates', 'mas-elementor' ),
'type' => Controls_Manager::SELECT,
'options' => $templates,
)
);

$this->end_controls_section();
}

/**
* Renders the Nav Tabs widget.
*/
protected function render() {

$episodes = masvideos_get_episode( get_the_ID() );
if ( empty( $episodes ) ) {
return;
}
$tv_show_id = $episodes->get_tv_show_id();
$tv_show = masvideos_get_tv_show( $tv_show_id );

$seasons = $tv_show->get_seasons();

$settings = $this->get_settings();
$test_id = get_the_ID();
?><div class="episodes-wrapper">
<?php
foreach ( $seasons as $key => $season ) {
$original_post = $GLOBALS['post'];
foreach ( $season['episodes'] as $key => $episode_id ) {
if ( $test_id === $episode_id ) {
continue;
}

$GLOBALS['post'] = get_post( $episode_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
setup_postdata( $GLOBALS['post'] );

setup_postdata( masvideos_setup_episode_data( $episode_id ) ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited, Squiz.PHP.DisallowMultipleAssignments.Found
print( mas_render_template( $settings['select_template'], false ) );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

}
$GLOBALS['post'] = $original_post;// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
wp_reset_postdata();
}
?>
</div>
<?php
}
}
76 changes: 76 additions & 0 deletions modules/mas-tv-shows-episodes/module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* The MAS Breadcrumb Widget.
*
* @package MASElementor/Modules/MasBreadcrumb/Widgets
*/

namespace MASElementor\Modules\MasTvShowsEpisodes;

use MASElementor\Base\Module_Base;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

/**
* The module class.
*/
class Module extends Module_Base {
/**
* Return the style dependencies of the module.
*
* @return array
*/
public function get_style_depends() {
return array( 'mas-tv-shows-episodes-stylesheet' );
}

/**
* Return the widgets in this module.
*
* @return array
*/
public function get_widgets() {
return array(
'Mas_Tv_Shows_Episodes',
);
}

/**
* Get the name of the module.
*
* @return string
*/
public function get_name() {
return 'mas-tv-shows-episodes';
}
/**
* Add Actions.
*/
protected function add_actions() {
}

/**
* Instantiate the class.
*/
public function __construct() {
parent::__construct();
$this->add_actions();

add_action( 'elementor/frontend/before_register_styles', array( $this, 'register_frontend_styles' ) );

}

/**
* Register frontend styles.
*/
public function register_frontend_styles() {
wp_register_style(
'mas-tv-shows-episodes-stylesheet',
MAS_ELEMENTOR_MODULES_URL . 'mas-tv-shows-episodes/css/mas-tv-shows-episodes-tab.css',
array(),
MAS_ELEMENTOR_VERSION
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
* The Mas Nav Tab Widget.
*
* @package MASElementor/Modules/MasEpisodes/Widgets
* @package MASElementor/Modules/MasTvShowsEpisodes/Widgets
*/

namespace MASElementor\Modules\MasEpisodes\Widgets;
namespace MASElementor\Modules\MasTvShowsEpisodes\Widgets;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
Expand All @@ -29,15 +29,15 @@
/**
* MAS Episodes Elementor Widget.
*/
class Mas_Episodes extends Base_Widget {
class Mas_Tv_Shows_Episodes extends Base_Widget {

/**
* Get the name of the widget.
*
* @return string
*/
public function get_name() {
return 'mas-episodes';
return 'mas-tv-shows-episodes';
}

/**
Expand All @@ -64,7 +64,7 @@ public function get_icon() {
* @return array
*/
public function get_keywords() {
return array( 'episode', 'mas' );
return array( 'tv-shows-episode', 'mas' );
}

/**
Expand All @@ -86,7 +86,7 @@ public function get_categories() {
* @return array Element styles dependencies.
*/
public function get_style_depends() {
return array( 'mas-episodes-stylesheet' );
return array( 'mas-tv-shows-episodes-stylesheet' );
}

/**
Expand Down

0 comments on commit 3b5d75f

Please sign in to comment.