update
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class CFF_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'cff-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('Facebook Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-inactive sb-elem-facebook';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sby-elementor-handler'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class CTF_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'ctf-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('Twitter Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-inactive sb-elem-twitter';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sby-elementor-handler'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class SBI_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'sbi-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('Instagram Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-inactive sb-elem-instagram';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sby-elementor-handler'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class SBR_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'sbr-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('Reviews Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-inactive sb-elem-reviews';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sby-elementor-handler'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class SBTT_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'sbtt-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('TikTok Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-inactive sb-elem-tiktok';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sby-elementor-handler'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use SmashBalloon\YouTubeFeed\Services\Integrations\Elementor\SBY_Elementor_Control;
|
||||
use SmashBalloon\YouTubeFeed\Services\Integrations\Elementor\SBY_Elementor_Widget;
|
||||
use SmashBalloon\YouTubeFeed\Helpers\Util;
|
||||
|
||||
class SBY_Elementor_Base
|
||||
{
|
||||
const VERSION = SBYVER;
|
||||
const MINIMUM_ELEMENTOR_VERSION = '3.6.0';
|
||||
const MINIMUM_PHP_VERSION = '5.6';
|
||||
const NAME_SPACE = 'SmashBalloon.YouTubeFeed.Services.Integrations.Elementor.';
|
||||
private static $instance;
|
||||
|
||||
public static function register()
|
||||
{
|
||||
if (!isset(self::$instance) && !self::$instance instanceof SBY_Elementor_Base) {
|
||||
self::$instance = new SBY_Elementor_Base();
|
||||
self::$instance->apply_hooks();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function apply_hooks()
|
||||
{
|
||||
add_action('elementor/frontend/after_register_scripts', [$this, 'register_frontend_scripts']);
|
||||
add_action('elementor/frontend/after_register_styles', [$this, 'register_frontend_styles'], 10);
|
||||
add_action('elementor/frontend/after_enqueue_styles', [$this, 'enqueue_frontend_styles'], 10);
|
||||
add_action('elementor/controls/register', [$this, 'register_controls']);
|
||||
add_action('elementor/widgets/register', [$this,'register_widgets']);
|
||||
add_action('elementor/elements/categories_registered', [$this, 'add_smashballon_categories']);
|
||||
}
|
||||
|
||||
public function register_controls($controls_manager)
|
||||
{
|
||||
$controls_manager->register(new SBY_Elementor_Control());
|
||||
}
|
||||
|
||||
public function register_widgets($widgets_manager)
|
||||
{
|
||||
$widgets_manager->register(new SBY_Elementor_Widget());
|
||||
|
||||
$installed_plugins = sby_get_installed_plugin_info();
|
||||
unset($installed_plugins['youtube']);
|
||||
|
||||
foreach($installed_plugins as $plugin) {
|
||||
if (!$plugin['installed']){
|
||||
$plugin_class = str_replace('.','\\', self::NAME_SPACE) . $plugin['class'];
|
||||
$widgets_manager->register(new $plugin_class());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function register_frontend_scripts(){
|
||||
|
||||
$css_free_file_name = 'sb-youtube-free.min.css';
|
||||
$css_pro_file_name = 'sb-youtube.min.css';
|
||||
$css_file_name = sby_is_pro() ? $css_pro_file_name : $css_free_file_name;
|
||||
|
||||
wp_enqueue_style(
|
||||
'sby_styles',
|
||||
trailingslashit(SBY_PLUGIN_URL) . 'css/' . $css_file_name,
|
||||
array(),
|
||||
SBYVER
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'isAdmin' => is_admin(),
|
||||
'adminAjaxUrl' => admin_url('admin-ajax.php' ),
|
||||
'placeholder' => trailingslashit(SBY_PLUGIN_URL) . 'img/placeholder.png',
|
||||
'placeholderNarrow' => trailingslashit(SBY_PLUGIN_URL) . 'img/placeholder-narrow.png',
|
||||
'lightboxPlaceholder' => trailingslashit(SBY_PLUGIN_URL) . 'img/lightbox-placeholder.png',
|
||||
'lightboxPlaceholderNarrow' => trailingslashit(SBY_PLUGIN_URL) . 'img/lightbox-placeholder-narrow.png',
|
||||
'autoplay' => false,
|
||||
'semiEagerload' => false,
|
||||
'eagerload' => false,
|
||||
'nonce' => wp_create_nonce('sby_nonce'),
|
||||
'isPro' => sby_is_pro(),
|
||||
'resized_url' => Util::sby_get_resized_uploads_url(),
|
||||
'isCustomizer' => false
|
||||
);
|
||||
|
||||
wp_register_script(
|
||||
'sbyscripts',
|
||||
SBY_PLUGIN_URL . 'js/sb-youtube.min.js',
|
||||
array('jquery'),
|
||||
SBYVER,
|
||||
true
|
||||
);
|
||||
wp_localize_script( 'sbyscripts', 'sbyOptions', $data );
|
||||
|
||||
$data_handler = array(
|
||||
'smashPlugins' => sby_get_installed_plugin_info(),
|
||||
'nonce' => wp_create_nonce('sby-admin'),
|
||||
'ajax_handler' => admin_url('admin-ajax.php'),
|
||||
);
|
||||
|
||||
wp_register_script(
|
||||
'sby-elementor-handler',
|
||||
SBY_PLUGIN_URL . 'js/elementor-handler.js' ,
|
||||
array('jquery'),
|
||||
SBYVER,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script('sby-elementor-handler', 'sbHandler', $data_handler);
|
||||
|
||||
wp_register_script(
|
||||
'sby-elementor-preview',
|
||||
SBY_PLUGIN_URL . 'js/elementor-preview.js' ,
|
||||
array('jquery'),
|
||||
SBYVER,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public function register_frontend_styles()
|
||||
{
|
||||
$css_free_file_name = 'sb-youtube-free.min.css';
|
||||
$css_pro_file_name = 'sb-youtube.min.css';
|
||||
$css_file_name = sby_is_pro() ? $css_pro_file_name : $css_free_file_name;
|
||||
|
||||
wp_register_style(
|
||||
'sby-styles',
|
||||
SBY_PLUGIN_URL . 'css/' . $css_file_name,
|
||||
array(),
|
||||
SBYVER
|
||||
);
|
||||
}
|
||||
|
||||
public function enqueue_frontend_styles()
|
||||
{
|
||||
wp_enqueue_style('sby-styles');
|
||||
}
|
||||
|
||||
public function add_smashballon_categories($elements_manager)
|
||||
{
|
||||
$elements_manager->add_category(
|
||||
'smash-balloon',
|
||||
[
|
||||
'title' => esc_html__('Smash Balloon', 'feeds-for-youtube'),
|
||||
'icon' => 'fa fa-plug',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Base_Data_Control;
|
||||
use \Elementor\Controls_Manager;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class SBY_Elementor_Control extends Base_Data_Control {
|
||||
|
||||
public function get_type(){
|
||||
return 'sby_feed_control';
|
||||
}
|
||||
|
||||
public function enqueue(){
|
||||
wp_enqueue_style(
|
||||
'sby-elementor-style',
|
||||
SBY_PLUGIN_URL . 'css/sb-elementor.css' ,
|
||||
null,
|
||||
SBYVER
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_default_settings(){
|
||||
return [
|
||||
'label_block' => false
|
||||
];
|
||||
}
|
||||
|
||||
public function content_template() {
|
||||
$control_uid = $this->get_control_uid();
|
||||
?>
|
||||
<div class="elementor-control-field">
|
||||
<# if ( data.label ) {#>
|
||||
<label for="<?php echo $control_uid; ?>" class="elementor-control-title">{{{ data.label }}}</label>
|
||||
<# } #>
|
||||
<div class="elementor-control-input-wrapper elementor-control-unit-5">
|
||||
<select id="<?php echo $control_uid; ?>" data-setting="{{ data.name }}" onchange="jQuery(this).parents('.elementor-control-field').find('.link-sby-builder').attr('href', '<?php echo admin_url( 'admin.php?page=sby-feed-builder' ) ?>&feed_id='+jQuery(this).val())">
|
||||
<#
|
||||
var printOptions = function( options ) {
|
||||
_.each( options, function( option_title, option_value ) { #>
|
||||
<option value="{{ option_value }}">{{{ option_title }}}</option>
|
||||
<# } );
|
||||
};
|
||||
|
||||
if ( data.groups ) {
|
||||
for ( var groupIndex in data.groups ) {
|
||||
var groupArgs = data.groups[ groupIndex ];
|
||||
if ( groupArgs.options ) { #>
|
||||
<optgroup label="{{ groupArgs.label }}">
|
||||
<# printOptions( groupArgs.options ) #>
|
||||
</optgroup>
|
||||
<# } else if ( _.isString( groupArgs ) ) { #>
|
||||
<option value="{{ groupIndex }}">{{{ groupArgs }}}</option>
|
||||
<# }
|
||||
}
|
||||
} else {
|
||||
printOptions( data.options );
|
||||
}
|
||||
#>
|
||||
</select>
|
||||
<div style="font-weight: 700; color:#a73061; margin-top: 10px;">
|
||||
<# if( data.controlValue != undefined && data.controlValue != '' ) { #>
|
||||
<a class="link-sby-builder" href="<?php echo admin_url( 'admin.php?page=sby-feed-builder' ) ?>&feed_id={{data.controlValue}}" target="_blank"><?php echo __('Edit this Feed', 'feeds-for-youtube'); ?></a>
|
||||
<span style="color:#aaa; display: inline-block; margin: 0 5px;">|</span>
|
||||
<# } #>
|
||||
<a href="<?php echo admin_url( 'admin.php?page=sby-feed-builder' ) ?>" target="_blank"><?php echo __('Create New Feed', 'feeds-for-youtube'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<# if ( data.description ) { #>
|
||||
<div class="elementor-control-field-description">{{{ data.description }}}</div>
|
||||
<# } #>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace SmashBalloon\YouTubeFeed\Services\Integrations\Elementor;
|
||||
|
||||
use \Elementor\Widget_Base;
|
||||
use \Elementor\Controls_Manager;
|
||||
use SmashBalloon\YouTubeFeed\Builder\SBY_Db;
|
||||
use SmashBalloon\YouTubeFeed\Services\Integrations\SBY_Integration;
|
||||
|
||||
if (!defined('ABSPATH'))
|
||||
exit; // Exit if accessed directly
|
||||
|
||||
class SBY_Elementor_Widget extends Widget_Base {
|
||||
|
||||
public function get_name() {
|
||||
return 'sby-widget';
|
||||
}
|
||||
public function get_title() {
|
||||
return esc_html__('YouTube Feed', 'feeds-for-youtube');
|
||||
}
|
||||
public function get_icon() {
|
||||
return 'sb-elem-icon sb-elem-youtube';
|
||||
}
|
||||
public function get_categories() {
|
||||
return array('smash-balloon');
|
||||
}
|
||||
public function get_script_depends() {
|
||||
return [
|
||||
'sbyscripts',
|
||||
'sby-elementor-preview'
|
||||
];
|
||||
}
|
||||
|
||||
protected function register_controls() {
|
||||
/********************************************
|
||||
CONTENT SECTION
|
||||
********************************************/
|
||||
$this->start_controls_section(
|
||||
'section_content',
|
||||
[
|
||||
'label' => esc_html__('YouTube Feed Settings', 'feeds-for-youtube'),
|
||||
]
|
||||
);
|
||||
$this->add_control(
|
||||
'feed_id',
|
||||
[
|
||||
'label' => esc_html__('Select a Feed', 'feeds-for-youtube'),
|
||||
'type' => 'sby_feed_control',
|
||||
'label_block' => true,
|
||||
'dynamic' => ['active' => true],
|
||||
'options' => SBY_Db::elementor_feeds_query(),
|
||||
]
|
||||
);
|
||||
$this->end_controls_section();
|
||||
}
|
||||
|
||||
protected function render() {
|
||||
$settings = $this->get_settings_for_display();
|
||||
if (isset($settings['feed_id']) && !empty($settings['feed_id'])) {
|
||||
$feed_id = (int) $settings['feed_id'];
|
||||
$output = do_shortcode( shortcode_unautop( '[youtube-feed feed='. $feed_id .']' ) );
|
||||
} else {
|
||||
$output = is_admin() ? SBY_Integration::get_widget_cta() : '';
|
||||
}
|
||||
echo apply_filters('sby_output', $output, $settings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user