From 05941ced8d622dcd023ef8ce8ebd5f5159ee8119 Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Tue, 27 Apr 2021 11:01:06 +0000 Subject: [PATCH] Repeater code updates, Slick Carousel fixes and improve file selection control. Done #4419 @4 --- .../src/Elementor/Widgets/BackgroundImage.php | 2 +- .../src/Elementor/Widgets/HeroBlock.php | 2 +- .../src/Elementor/Widgets/ModalList.php | 49 ++-- .../Elementor/Widgets/MultimediaCarousel.php | 176 ++++++------ .../src/Elementor/Widgets/ProfileGrid.php | 136 +++++---- .../src/Elementor/Widgets/ResourceGrid.php | 99 ++++--- .../src/Elementor/Widgets/TextBlock.php | 2 +- .../src/Elementor/Widgets/TextCarousel.php | 105 ++++--- .../src/Elementor/Widgets/VideoGallery.php | 90 +++--- .../README.md | 13 + .../controls/fileselect-control.php | 80 ++++++ .../controls/js/fileselect-control.js | 25 ++ .../file-select-control-elementor.php | 267 ++++++++++++++++++ .../file-select-control-for-elementor.pot | 120 ++++++++ .../readme.txt | 78 +++++ .../widgets/file-link-widget.php | 149 ++++++++++ wp-content/themes/physioassist/package.json | 1 + .../physioassist/resources/assets/config.json | 3 + .../resources/assets/scripts/slick.js | 2 + wp-content/themes/physioassist/yarn.lock | 5 + 20 files changed, 1120 insertions(+), 284 deletions(-) create mode 100644 wp-content/plugins/file-select-control-for-elementor/README.md create mode 100644 wp-content/plugins/file-select-control-for-elementor/controls/fileselect-control.php create mode 100644 wp-content/plugins/file-select-control-for-elementor/controls/js/fileselect-control.js create mode 100644 wp-content/plugins/file-select-control-for-elementor/file-select-control-elementor.php create mode 100644 wp-content/plugins/file-select-control-for-elementor/languages/file-select-control-for-elementor.pot create mode 100644 wp-content/plugins/file-select-control-for-elementor/readme.txt create mode 100644 wp-content/plugins/file-select-control-for-elementor/widgets/file-link-widget.php create mode 100644 wp-content/themes/physioassist/resources/assets/scripts/slick.js diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/BackgroundImage.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/BackgroundImage.php index e0d18e54..c7123bfa 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/BackgroundImage.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/BackgroundImage.php @@ -49,7 +49,7 @@ class BackgroundImage extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_image', diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/HeroBlock.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/HeroBlock.php index 707fda5f..42058e55 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/HeroBlock.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/HeroBlock.php @@ -58,7 +58,7 @@ class HeroBlock extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ModalList.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ModalList.php index 7fa142df..2149d72c 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ModalList.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ModalList.php @@ -5,6 +5,10 @@ namespace PhysioAssist\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Scheme_Color; +use Elementor\Repeater; + +use function App\asset_path; +use function App\template; class ModalList extends Widget_Base { @@ -41,11 +45,11 @@ class ModalList extends Widget_Base { */ public function get_script_depends() { - wp_register_script('lity', \App\asset_path('scripts/lity.js'), ['jquery'], null, true); + wp_register_script('lity', asset_path('scripts/lity.js'), ['jquery'], null, true); wp_register_script( 'cube-modal-list', - \App\asset_path('scripts/modal-list.js'), + asset_path('scripts/modal-list.js'), ['jquery', 'lity'], // Dependencies null, // Version true // In footer? @@ -60,7 +64,7 @@ class ModalList extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -69,26 +73,33 @@ class ModalList extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'placeholder' => __( 'Enter your title', 'elementor' ), + 'default' => '', + ] + ); + + $repeater->add_control( + 'body', + [ + 'label' => __('Body', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Items', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'title', - 'label' => __( 'Title', 'elementor' ), - 'type' => Controls_Manager::TEXT, - 'placeholder' => __( 'Enter your title', 'elementor' ), - 'default' => '', - ], - [ - 'name' => 'body', - 'label' => __('Body', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); @@ -106,7 +117,7 @@ class ModalList extends Widget_Base { $items = $this->get_settings('items'); - echo \App\template('widgets/modal-list', compact('items')); + echo template('widgets/modal-list', compact('items')); } } diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/MultimediaCarousel.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/MultimediaCarousel.php index d645b365..992ec120 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/MultimediaCarousel.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/MultimediaCarousel.php @@ -6,6 +6,7 @@ use Elementor\Embed; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Utils as ElementorUtils; +use Elementor\Repeater; use PhysioAssist\Elementor\Utils; @@ -46,17 +47,17 @@ class MultimediaCarousel extends Widget_Base { public function get_script_depends() { wp_register_script('lity', asset_path('scripts/lity.js'), ['jquery'], null, true); + wp_register_script('slick', asset_path('scripts/slick.js'), ['jquery'], null, true); wp_register_script( 'cube-multimedia-carousel', asset_path('scripts/multimedia-carousel.js'), - ['jquery', 'lity'], // Dependencies + ['jquery', 'lity', 'slick'], // Dependencies null, // Version true // In footer? ); - // Use script already registered by Elementor so we don't have to include another copy of Slick - return ['jquery-slick', 'cube-multimedia-carousel']; + return ['cube-multimedia-carousel']; } /** * Register the widget controls. @@ -65,7 +66,7 @@ class MultimediaCarousel extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -74,92 +75,99 @@ class MultimediaCarousel extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'type', + [ + 'label' => __('Slide Type', 'cube'), + 'type' => Controls_Manager::SELECT, + 'default' => '', + 'options' => [ + '' => __('(Select)'), + 'video' => __( 'Video', 'cube' ), + 'text' => __( 'Text', 'cube' ), + ], + ] + ); + + $repeater->add_control( + 'image', + [ + 'label' => __('Image', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => ElementorUtils::get_placeholder_image_src(), + ], + 'condition' => [ + 'type' => ['text', 'video'] + ], + ] + ); + + // Video URL only used for video slides + $repeater->add_control( + 'url', + [ + 'label' => __( 'Video URL', 'cube' ), + 'placeholder' => __( 'Enter YouTube link', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'condition' => [ + 'type' => 'video' + ], + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + 'condition' => [ + 'type' => ['text', 'video'] + ], + ] + ); + + $repeater->add_control( + 'subtitle', + [ + 'label' => __( 'Subtitle', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'condition' => [ + 'type' => ['text', 'video'] + ], + ] + ); + + // Body field is only used for "text" slides + $repeater->add_control( + 'body', + [ + 'label' => __('Body', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + 'dynamic' => [ + 'active' => false, + ], + 'condition' => [ + 'type' => 'text' + ], + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Items', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - - - // TODO: finish video / text fields integration. Think about which fields can be used by both (image?) - // TODO: refactor blade partials so same partial can be used by individual carousels + mixed carousel to output content (switch based on item type) - - - - [ - 'name' => 'type', - 'label' => __('Slide Type', 'cube'), - 'type' => Controls_Manager::SELECT, - 'default' => '', - 'options' => [ - '' => __('(Select)'), - 'video' => __( 'Video', 'cube' ), - 'text' => __( 'Text', 'cube' ), - ], - ], - - - [ - 'name' => 'image', - 'label' => __('Image', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => ElementorUtils::get_placeholder_image_src(), - ], - 'condition' => [ - 'type' => ['text', 'video'] - ], - ], - - // Video URL only used for video slides - [ - 'name' => 'url', - 'label' => __( 'Video URL', 'cube' ), - 'placeholder' => __( 'Enter YouTube link', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'condition' => [ - 'type' => 'video' - ], - ], - - [ - 'name' => 'title', - 'label' => __( 'Title', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - 'condition' => [ - 'type' => ['text', 'video'] - ], - ], - [ - 'name' => 'subtitle', - 'label' => __( 'Subtitle', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'condition' => [ - 'type' => ['text', 'video'] - ], - ], - - // Body field is only used for "text" slides - [ - 'name' => 'body', - 'label' => __('Body', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - 'dynamic' => [ - 'active' => false, - ], - 'condition' => [ - 'type' => 'text' - ], - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ type == "text" ? \'\' : "" }}} {{{ type == "video" ? \'\' : "" }}} {{{ title }}}', ] ); diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php index 38c0ce9f..b6fc7e0f 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ProfileGrid.php @@ -5,7 +5,10 @@ namespace PhysioAssist\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; +use function App\asset_path; +use function App\template; class ProfileGrid extends Widget_Base { @@ -41,18 +44,18 @@ class ProfileGrid extends Widget_Base { */ public function get_script_depends() { - wp_register_script('lity', \App\asset_path('scripts/lity.js'), ['jquery'], null, true); + wp_register_script('lity', asset_path('scripts/lity.js'), ['jquery'], null, true); + wp_register_script('slick', asset_path('scripts/slick.js'), ['jquery'], null, true); wp_register_script( 'cube-profile-grid', - \App\asset_path('scripts/profile-grid.js'), - ['jquery', 'lity'], // Dependencies + asset_path('scripts/profile-grid.js'), + ['jquery', 'lity', 'slick'], // Dependencies null, // Version true // In footer? ); - // Use script already registered by Elementor so we don't have to include another copy of Slick - return ['jquery-slick', 'cube-profile-grid']; + return ['cube-profile-grid']; } /** * Register the widget controls. @@ -61,7 +64,7 @@ class ProfileGrid extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -85,60 +88,79 @@ class ProfileGrid extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'image', + [ + 'label' => __('Image', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'subtitle', + [ + 'label' => __( 'Subtitle', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'body', + [ + 'label' => __('Body', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + 'dynamic' => [ + 'active' => false, + ], + ] + ); + + $repeater->add_control( + 'cta_text', + [ + 'label' => __('Call to Action text', 'cube'), + 'type' => Controls_Manager::TEXT, + 'default' => '' + ] + ); + + $repeater->add_control( + 'cta_link', + [ + 'label' => __('Call to Action link', 'cube'), + 'type' => Controls_Manager::URL, + 'default' => [ + 'url' => '', + 'is_external' => false, + ], + 'show_external' => true + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Items', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'image', - 'label' => __('Image', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'title', - 'label' => __( 'Title', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'subtitle', - 'label' => __( 'Subtitle', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - [ - 'name' => 'body', - 'label' => __('Body', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - 'dynamic' => [ - 'active' => false, - ], - ], - [ - 'name' => 'cta_text', - 'label' => __('Call to Action text', 'cube'), - 'type' => Controls_Manager::TEXT, - 'default' => '' - ], - [ - 'name' => 'cta_link', - 'label' => __('Call to Action link', 'cube'), - 'type' => Controls_Manager::URL, - 'default' => [ - 'url' => '', - 'is_external' => false, - ], - 'show_external' => true - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); @@ -189,9 +211,9 @@ class ProfileGrid extends Widget_Base { $truncate_lines = $this->get_settings('truncate_lines'); if ($display_type == 'carousel') { - echo \App\template('widgets/profile-carousel', compact('items', 'ID')); + echo template('widgets/profile-carousel', compact('items', 'ID')); } else { - echo \App\template('widgets/profile-grid', compact('items', 'truncate_lines')); + echo template('widgets/profile-grid', compact('items', 'truncate_lines')); } } diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ResourceGrid.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ResourceGrid.php index 8432bda1..b6340796 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ResourceGrid.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/ResourceGrid.php @@ -5,6 +5,10 @@ namespace PhysioAssist\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Utils; +use Elementor\Repeater; + +use function App\asset_path; +use function App\template; class ResourceGrid extends Widget_Base { @@ -41,16 +45,18 @@ class ResourceGrid extends Widget_Base { */ public function get_script_depends() { + wp_register_script('slick', asset_path('scripts/slick.js'), ['jquery'], null, true); + wp_register_script( 'cube-resource-carousel', - \App\asset_path('scripts/resource-carousel.js'), - ['jquery'], // Dependencies + asset_path('scripts/resource-carousel.js'), + ['jquery', 'slick'], // Dependencies null, // Version true // In footer? ); // Use script already registered by Elementor so we don't have to include another copy of Slick - return [ 'jquery-slick', 'cube-resource-carousel' ]; + return ['cube-resource-carousel']; } /** @@ -60,7 +66,7 @@ class ResourceGrid extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -84,50 +90,59 @@ class ResourceGrid extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'image', + [ + 'label' => __('Preview Image', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => Utils::get_placeholder_image_src(), + ], + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'interactive_version', + [ + 'label' => __( 'Interactive version link', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'pdf', + [ + 'type' => 'file-select', // Using the file-select-control-for-elementor plugin + 'label' => __( 'PDF link', 'cube' ), + 'label_block' => true, + 'placeholder' => __('PDF URL', 'cube'), + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Items', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'image', - 'label' => __('Preview Image', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => Utils::get_placeholder_image_src(), - ], - ], - [ - 'name' => 'title', - 'label' => __( 'Title', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - - // Todo: revisit this to see if we can have a more user-friendly file control - // See: https://github.com/pojome/elementor/issues/4468 - // See also: https://github.com/elementor/elementor/issues/1573#issuecomment-561405541 - // A searchable URL field might be enough but the text control isn't compatible with the - // data structure of the URL control so that would need to be handled or transitioned - [ - 'name' => 'interactive_version', - 'label' => __( 'Interactive version link', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - [ - 'name' => 'pdf', - 'label' => __( 'PDF link', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); + $this->end_controls_section(); } /** @@ -143,9 +158,9 @@ class ResourceGrid extends Widget_Base { $items = $this->get_settings('items'); if ($display_type == 'carousel') { - echo \App\template('widgets/resource-carousel', compact('items')); + echo template('widgets/resource-carousel', compact('items')); } else { - echo \App\template('widgets/resource-grid', compact('items')); + echo template('widgets/resource-grid', compact('items')); } } diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php index 301ec52c..9f30ba31 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextBlock.php @@ -59,7 +59,7 @@ class TextBlock extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php index b1187d57..f50a23a4 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/TextCarousel.php @@ -2,10 +2,13 @@ namespace PhysioAssist\Elementor\Widgets; +use Elementor\Repeater; use Elementor\Widget_Base; use Elementor\Controls_Manager; use Elementor\Scheme_Color; +use function App\asset_path; +use function App\template; class TextCarousel extends Widget_Base { @@ -41,16 +44,18 @@ class TextCarousel extends Widget_Base { */ public function get_script_depends() { + wp_register_script('slick', asset_path('scripts/slick.js'), ['jquery'], null, true); + wp_register_script( 'cube-text-carousel', - \App\asset_path('scripts/text-carousel.js'), - ['jquery'], // Dependencies + asset_path('scripts/text-carousel.js'), + ['jquery', 'slick'], // Dependencies null, // Version true // In footer? ); // Use script already registered by Elementor so we don't have to include another copy of Slick - return ['jquery-slick', 'cube-text-carousel']; + return ['cube-text-carousel']; } /** * Register the widget controls. @@ -59,7 +64,7 @@ class TextCarousel extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -68,48 +73,64 @@ class TextCarousel extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'elementor' ), + 'type' => Controls_Manager::TEXT, + 'placeholder' => __( 'Enter your title', 'elementor' ), + 'default' => '', + ] + ); + + $repeater->add_control( + 'subtitle', + [ + 'label' => __( 'Subtitle', 'cube' ), + 'type' => Controls_Manager::TEXTAREA, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'body', + [ + 'label' => __('Body', 'cube'), + 'type' => Controls_Manager::WYSIWYG, + 'default' => '', + ] + ); + + $repeater->add_control( + 'cta_text', + [ + 'label' => __('Call to Action text', 'cube'), + 'type' => Controls_Manager::TEXT, + 'default' => '' + ] + ); + + $repeater->add_control( + 'cta_link', + [ + 'label' => __('Call to Action link', 'cube'), + 'type' => Controls_Manager::URL, + 'default' => [ + 'url' => '', + 'is_external' => false, + ], + 'show_external' => true + ] + ); + $this->add_control( 'items', [ 'label' => __( 'Items', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'title', - 'label' => __( 'Title', 'elementor' ), - 'type' => Controls_Manager::TEXT, - 'placeholder' => __( 'Enter your title', 'elementor' ), - 'default' => '', - ], - [ - 'name' => 'subtitle', - 'label' => __( 'Subtitle', 'cube' ), - 'type' => Controls_Manager::TEXTAREA, - 'label_block' => true, - ], - [ - 'name' => 'body', - 'label' => __('Body', 'cube'), - 'type' => Controls_Manager::WYSIWYG, - 'default' => '', - ], - [ - 'name' => 'cta_text', - 'label' => __('Call to Action text', 'cube'), - 'type' => Controls_Manager::TEXT, - 'default' => '' - ], - [ - 'name' => 'cta_link', - 'label' => __('Call to Action link', 'cube'), - 'type' => Controls_Manager::URL, - 'default' => [ - 'url' => '', - 'is_external' => false, - ], - 'show_external' => true - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); @@ -245,7 +266,7 @@ class TextCarousel extends Widget_Base { $items = $this->get_settings('items'); - echo \App\template('widgets/text-carousel', compact('items')); + echo template('widgets/text-carousel', compact('items')); } } diff --git a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/VideoGallery.php b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/VideoGallery.php index cbf03895..476471f7 100644 --- a/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/VideoGallery.php +++ b/wp-content/mu-plugins/physioassist/src/Elementor/Widgets/VideoGallery.php @@ -4,11 +4,13 @@ namespace PhysioAssist\Elementor\Widgets; use Elementor\Widget_Base; use Elementor\Controls_Manager; +use Elementor\Repeater; use Elementor\Utils as ElementorUtils; use Elementor\Embed; use PhysioAssist\Elementor\Utils; +use function App\asset_path; use function App\template; class VideoGallery extends Widget_Base { @@ -43,16 +45,17 @@ class VideoGallery extends Widget_Base { */ public function get_script_depends() { + wp_register_script('slick', asset_path('scripts/slick.js'), ['jquery'], null, true); + wp_register_script( 'cube-video-carousel', - \App\asset_path('scripts/video-carousel.js'), - ['jquery'], // Dependencies + asset_path('scripts/video-carousel.js'), + ['jquery', 'slick'], // Dependencies null, // Version true // In footer? ); - // Use script already registered by Elementor so we don't have to include another copy of Slick - return [ 'jquery-slick', 'cube-video-carousel' ]; + return ['cube-video-carousel']; } /** * Register the widget controls. @@ -61,7 +64,7 @@ class VideoGallery extends Widget_Base { * @since 1.0.0 * @access protected */ - protected function _register_controls() { + protected function register_controls() { $this->start_controls_section( 'section_content', @@ -85,43 +88,56 @@ class VideoGallery extends Widget_Base { ] ); + $repeater = new Repeater(); + + $repeater->add_control( + 'url', + [ + 'label' => __( 'Video URL', 'cube' ), + 'placeholder' => __( 'Enter YouTube link', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'title', + [ + 'label' => __( 'Title', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + 'default' => '', + ] + ); + + $repeater->add_control( + 'details', + [ + 'label' => __( 'Additional Details', 'cube' ), + 'placeholder' => __( 'Extra information for slider view', 'cube' ), + 'type' => Controls_Manager::TEXT, + 'label_block' => true, + ] + ); + + $repeater->add_control( + 'image', + [ + 'label' => __('Preview Image (optional)', 'cube'), + 'label_block' => true, + 'type' => Controls_Manager::MEDIA, + 'default' => [ + 'url' => ElementorUtils::get_placeholder_image_src(), + ], + ] + ); + $this->add_control( 'videos', [ 'label' => __( 'Videos', 'cube' ), 'type' => Controls_Manager::REPEATER, - 'fields' => [ - [ - 'name' => 'url', - 'label' => __( 'Video URL', 'cube' ), - 'placeholder' => __( 'Enter YouTube link', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - [ - 'name' => 'title', - 'label' => __( 'Title', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - 'default' => '', - ], - [ - 'name' => 'details', - 'label' => __( 'Additional Details', 'cube' ), - 'placeholder' => __( 'Extra information for slider view', 'cube' ), - 'type' => Controls_Manager::TEXT, - 'label_block' => true, - ], - [ - 'name' => 'image', - 'label' => __('Preview Image (optional)', 'cube'), - 'label_block' => true, - 'type' => Controls_Manager::MEDIA, - 'default' => [ - 'url' => ElementorUtils::get_placeholder_image_src(), - ], - ], - ], + 'fields' => $repeater->get_controls(), 'title_field' => '{{{ title }}}', ] ); diff --git a/wp-content/plugins/file-select-control-for-elementor/README.md b/wp-content/plugins/file-select-control-for-elementor/README.md new file mode 100644 index 00000000..f4379b77 --- /dev/null +++ b/wp-content/plugins/file-select-control-for-elementor/README.md @@ -0,0 +1,13 @@ +# Elementor File Select Control +Adds a new control for Elementor page builder which allows you to choose any kind of file from WordPress Media Library. Its Created for developers to take the code and use in your own project. + +Additionally this plugin comes with an Elementor Widget just to demonstrate how to integrate manily but that let's you create simple links to Media Files. + +## How To Use ? +Please find detailed instructions on the following blog post on my blog: https://abdulawal.com/elementor-file-select-control + +## Notes +As its a standalone plugin itself, you can actually just install this plugin on your site and use the control & widget that comes with this plugin if you're working on a website instead of a Theme or Plugin project. I'll try to put this on WordPress Repository as well, Will update the link here when its uploaded there. + +## Need Support ? +Please feel free to use the comment section of my blog or issues section here on github or Twitter @abdulawaluzzal diff --git a/wp-content/plugins/file-select-control-for-elementor/controls/fileselect-control.php b/wp-content/plugins/file-select-control-for-elementor/controls/fileselect-control.php new file mode 100644 index 00000000..f4f4a822 --- /dev/null +++ b/wp-content/plugins/file-select-control-for-elementor/controls/fileselect-control.php @@ -0,0 +1,80 @@ + true, + ]; + } + + /** + * Render control output in the editor. + * + * @since 1.0.0 + * @access public + */ + public function content_template() { + $control_uid = $this->get_control_uid(); + ?> +
+ +
+
+ + +
+
+ <# if ( data.description ) { #> +
{{{ data.description }}}
+ <# } #> + =' ) ) { + add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] ); + return; + } + + // Check for required PHP version + if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { + add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] ); + return; + } + + // Add Plugin actions + add_action( 'elementor/controls/controls_registered', [ $this, 'init_controls' ] ); + add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] ); + } + + /** + * Admin notice + * + * Warning when the site doesn't have Elementor installed or activated. + * + * @since 1.0.0 + * + * @access public + */ + public function admin_notice_missing_main_plugin() { + + if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); + + $message = sprintf( + /* translators: 1: Plugin name 2: Elementor */ + esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'file-select-control-for-elementor' ), + '' . esc_html__( 'File Select Control for Elementor', 'file-select-control-for-elementor' ) . '', + '' . esc_html__( 'Elementor', 'file-select-control-for-elementor' ) . '' + ); + + printf( '

%1$s

', $message ); + + } + + /** + * Admin notice + * + * Warning when the site doesn't have a minimum required Elementor version. + * + * @since 1.0.0 + * + * @access public + */ + public function admin_notice_minimum_elementor_version() { + + if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); + + $message = sprintf( + /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ + esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'file-select-control-for-elementor' ), + '' . esc_html__( 'File Select Control for Elementor', 'file-select-control-for-elementor' ) . '', + '' . esc_html__( 'Elementor', 'file-select-control-for-elementor' ) . '', + self::MINIMUM_ELEMENTOR_VERSION + ); + + printf( '

%1$s

', $message ); + + } + + /** + * Admin notice + * + * Warning when the site doesn't have a minimum required PHP version. + * + * @since 1.0.0 + * + * @access public + */ + public function admin_notice_minimum_php_version() { + + if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); + + $message = sprintf( + /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ + esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'file-select-control-for-elementor' ), + '' . esc_html__( 'File Select Control for Elementor', 'file-select-control-for-elementor' ) . '', + '' . esc_html__( 'PHP', 'file-select-control-for-elementor' ) . '', + self::MINIMUM_PHP_VERSION + ); + + printf( '

%1$s

', $message ); + + } + + /** + * Init Widgets + * + * Include widgets files and register them + * + * @since 1.0.0 + * + * @access public + */ + public function init_widgets() { + + // Include Widget files + require_once( __DIR__ . '/widgets/file-link-widget.php' ); + + // Register widget + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor_File_Link_Widget() ); + } + + /** + * Init Controls + * + * Include control files and register them + * + * @since 1.0.0 + * + * @access public + */ + public function init_controls() { + + // Include Widget files + require_once( __DIR__ . '/controls/fileselect-control.php' ); + + // Register controls + \Elementor\Plugin::$instance->controls_manager->register_control( 'file-select', new \FileSelect_Control() ); + } + +} + +Elementor_File_Select_Control_Addon::instance(); \ No newline at end of file diff --git a/wp-content/plugins/file-select-control-for-elementor/languages/file-select-control-for-elementor.pot b/wp-content/plugins/file-select-control-for-elementor/languages/file-select-control-for-elementor.pot new file mode 100644 index 00000000..5c54065e --- /dev/null +++ b/wp-content/plugins/file-select-control-for-elementor/languages/file-select-control-for-elementor.pot @@ -0,0 +1,120 @@ +# Copyright (C) 2020 ThemeNcode +# This file is distributed under the same license as the File Select Control for Elementor plugin. +msgid "" +msgstr "" +"Project-Id-Version: File Select Control for Elementor 1.0\n" +"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/trunk\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"POT-Creation-Date: 2020-07-10T05:16:40+00:00\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"X-Generator: WP-CLI 2.4.0\n" +"X-Domain: file-select-control-for-elementor\n" + +#. Plugin Name of the plugin +#: file-select-control-for-elementor.php:171 +#: file-select-control-for-elementor.php:195 +#: file-select-control-for-elementor.php:220 +msgid "File Select Control for Elementor" +msgstr "" + +#. Plugin URI of the plugin +msgid "https://abdulawal.com/elementor-file-select-control/" +msgstr "" + +#. Description of the plugin +msgid "This addon adds a new control file-select to use in your widgets. Specially for developers." +msgstr "" + +#. Author of the plugin +msgid "ThemeNcode" +msgstr "" + +#. Author URI of the plugin +msgid "https://themencode.com/" +msgstr "" + +#: controls/fileselect-control.php:70 +msgid "Choose / Upload File" +msgstr "" + +#. translators: 1: Plugin name 2: Elementor +#: file-select-control-for-elementor.php:170 +msgid "\"%1$s\" requires \"%2$s\" to be installed and activated." +msgstr "" + +#: file-select-control-for-elementor.php:172 +#: file-select-control-for-elementor.php:196 +msgid "Elementor" +msgstr "" + +#. translators: 1: Plugin name 2: Elementor 3: Required Elementor version +#. translators: 1: Plugin name 2: PHP 3: Required PHP version +#: file-select-control-for-elementor.php:194 +#: file-select-control-for-elementor.php:219 +msgid "\"%1$s\" requires \"%2$s\" version %3$s or greater." +msgstr "" + +#: file-select-control-for-elementor.php:221 +msgid "PHP" +msgstr "" + +#: widgets/file-link-widget.php:36 +msgid "File Link" +msgstr "" + +#: widgets/file-link-widget.php:80 +msgid "Settings" +msgstr "" + +#: widgets/file-link-widget.php:88 +msgid "Select File" +msgstr "" + +#: widgets/file-link-widget.php:90 +msgid "URL to File" +msgstr "" + +#: widgets/file-link-widget.php:91 +msgid "Select file from media library or upload" +msgstr "" + +#: widgets/file-link-widget.php:98 +msgid "Link Text" +msgstr "" + +#: widgets/file-link-widget.php:100 +msgid "Ex. Open File" +msgstr "" + +#: widgets/file-link-widget.php:101 +msgid "Text that should be displayed as a link" +msgstr "" + +#: widgets/file-link-widget.php:109 +msgid "Link Target" +msgstr "" + +#: widgets/file-link-widget.php:112 +msgid "Same Tab" +msgstr "" + +#: widgets/file-link-widget.php:113 +msgid "New Tab" +msgstr "" + +#: widgets/file-link-widget.php:116 +#: widgets/file-link-widget.php:127 +msgid "CSS class to add to the link" +msgstr "" + +#: widgets/file-link-widget.php:123 +msgid "Link CSS Class" +msgstr "" + +#: widgets/file-link-widget.php:126 +msgid "Ex. file-link" +msgstr "" diff --git a/wp-content/plugins/file-select-control-for-elementor/readme.txt b/wp-content/plugins/file-select-control-for-elementor/readme.txt new file mode 100644 index 00000000..862e18b1 --- /dev/null +++ b/wp-content/plugins/file-select-control-for-elementor/readme.txt @@ -0,0 +1,78 @@ +=== File Select Control For Elementor === +Contributors: abdulawal39, ThemeNcode +Donate link: http://go.abdulawal.com/donate +Tags: elementor, media, file select, elementor control, elementor file link, elementor media extended +Requires at least: 4.0 +Tested up to: 5.4.2 +Stable tag: 1.2 +Requires PHP: 7.0 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +A custom control to Allow choosing any type of files from WordPress Media Library. An extended version of MEDIA control. + +== Description == + +This addon comes with a small widget that allows you to create a link to any media file of your media library as well as a new elementor control for to select any type of file from your media library. + +The main part of this plugin is the new file select control, you can use this in combination of this plugin for just integrate with your project by taking code from this plugin. + +This addon comes with a new elementor control called file-select which you can use in your widgets. Simply put file-select in the type parameter of add_control() while creating the widget. + +Please find more details on how to use and integrate this control here: https://abdulawal.com/elementor-file-select-control/ + +

Features :

+ +* Work with any type of file +* Easy to use +* Very Lightweight Plugin + +Please Don't Forget to leave a review if you find this plugin useful.
+Thanks
+ +== Installation == + +Installing this plugin is pretty simple like all other wordpress plugins. Here are 2 ways to install : + +1. Manual Install + +* Download the zipped plugin from wordpress repository +* Extract the zipped folder +* Upload `file-select-control-for-elementor.zip` to the `/wp-content/plugins/` directory +* Activate the plugin through the 'Plugins' menu in WordPress +* Go to any page or post editor and you'll see the new widget called File Link or. + +2. Automatic Install + +* Go to Plugins-> Add New from your wordpress Dashboard +* Search File Select Control for Elementor +* From the results click on 'install now' +* Activate the plugin through the 'Plugins' menu in WordPress +* Go to any page or post editor and you'll see the new widget called File Link or. + + +== Frequently Asked Questions == + +** How Do I use the control ? ** + +Please find more details of integration here: https://abdulawal.com/elementor-file-select-control/ + +== Screenshots == + +1. Editor View +1. Adding control to widget + +== Changelog == += 1.2 = +* Updated Name of language pot file +* Updated Text Domain + += 1.1 = +* Added Language file + += 1.0 = +* First Release. + +== Upgrade Notice == + +none \ No newline at end of file diff --git a/wp-content/plugins/file-select-control-for-elementor/widgets/file-link-widget.php b/wp-content/plugins/file-select-control-for-elementor/widgets/file-link-widget.php new file mode 100644 index 00000000..c737c5e1 --- /dev/null +++ b/wp-content/plugins/file-select-control-for-elementor/widgets/file-link-widget.php @@ -0,0 +1,149 @@ +start_controls_section( + 'settings_section', + [ + 'label' => esc_html__( 'Settings', 'file-select-control-for-elementor' ), + 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, + ] + ); + + $this->add_control( + 'file_link', + [ + 'label' => esc_html__( 'Select File', 'file-select-control-for-elementor' ), + 'type' => 'file-select', + 'placeholder' => esc_html__( 'URL to File', 'file-select-control-for-elementor' ), + 'description' => esc_html__( 'Select file from media library or upload', 'file-select-control-for-elementor' ), + ] + ); + + $this->add_control( + 'link_text', + [ + 'label' => esc_html__( 'Link Text', 'file-select-control-for-elementor' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'placeholder' => esc_html__( 'Ex. Open File', 'file-select-control-for-elementor' ), + 'description' => esc_html__( 'Text that should be displayed as a link', 'file-select-control-for-elementor' ), + 'default' => 'Open File', + ] + ); + + $this->add_control( + 'link_target', + [ + 'label' => esc_html__( 'Link Target', 'file-select-control-for-elementor' ), + 'type' => \Elementor\Controls_Manager::SELECT, + 'options' => [ + '_parent' => esc_html__( 'Same Tab', 'file-select-control-for-elementor' ), + '_blank' => esc_html__( 'New Tab', 'file-select-control-for-elementor' ), + ], + 'default' => '_parent', + 'description' => esc_html__( 'CSS class to add to the link', 'file-select-control-for-elementor' ), + ] + ); + + $this->add_control( + 'link_css_class', + [ + 'label' => esc_html__( 'Link CSS Class', 'file-select-control-for-elementor' ), + 'type' => \Elementor\Controls_Manager::TEXT, + 'input_type' => 'text', + 'placeholder' => esc_html__( 'Ex. file-link', 'file-select-control-for-elementor' ), + 'description' => esc_html__( 'CSS class to add to the link', 'file-select-control-for-elementor' ), + ] + ); + + $this->end_controls_section(); + + } + + /** + * Render Elementor_File_Link_Widget widget output on the frontend. + * + * Written in PHP and used to generate the final HTML. + * + * @since 1.0.0 + * @access protected + */ + protected function render() { + + $settings = $this->get_settings_for_display(); + + echo '' . $settings['link_text'] . ''; + } +} \ No newline at end of file diff --git a/wp-content/themes/physioassist/package.json b/wp-content/themes/physioassist/package.json index bc758e13..cbfa9c76 100644 --- a/wp-content/themes/physioassist/package.json +++ b/wp-content/themes/physioassist/package.json @@ -96,6 +96,7 @@ "rimraf": "~2.6", "rupture": "^0.7.1", "sass-loader": "~6.0", + "slick-carousel": "^1.8.1", "style-loader": "^0.20.1", "stylelint": "^8.4.0", "stylelint-config-standard": "~18.0.0", diff --git a/wp-content/themes/physioassist/resources/assets/config.json b/wp-content/themes/physioassist/resources/assets/config.json index 1d897715..2f2c60b3 100644 --- a/wp-content/themes/physioassist/resources/assets/config.json +++ b/wp-content/themes/physioassist/resources/assets/config.json @@ -31,6 +31,9 @@ "lity": [ "./scripts/lity.js" ], + "slick": [ + "./scripts/slick.js" + ], "cookie-notice": [ "./scripts/cookie-notice.js" ], diff --git a/wp-content/themes/physioassist/resources/assets/scripts/slick.js b/wp-content/themes/physioassist/resources/assets/scripts/slick.js new file mode 100644 index 00000000..fa3bf102 --- /dev/null +++ b/wp-content/themes/physioassist/resources/assets/scripts/slick.js @@ -0,0 +1,2 @@ +// Create a local copy of Slick Carousel. Maybe this could be copied directly to /dist/scripts on build instead? +import slick from 'slick-carousel'; // eslint-disable-line diff --git a/wp-content/themes/physioassist/yarn.lock b/wp-content/themes/physioassist/yarn.lock index 308566e7..b6c1aa45 100644 --- a/wp-content/themes/physioassist/yarn.lock +++ b/wp-content/themes/physioassist/yarn.lock @@ -8409,6 +8409,11 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" +slick-carousel@^1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/slick-carousel/-/slick-carousel-1.8.1.tgz#a4bfb29014887bb66ce528b90bd0cda262cc8f8d" + integrity sha512-XB9Ftrf2EEKfzoQXt3Nitrt/IPbT+f1fgqBdoxO3W/+JYvtEOW6EgxnWfr9GH6nmULv7Y2tPmEX3koxThVmebA== + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" -- 2.39.5