WP init
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
use \Elementor\Controls_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Wpr_Custom_CSS {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
public function __construct() {
|
||||
// Add new controls to advanced tab globally
|
||||
add_action('elementor/element/after_section_end', [$this, 'add_section_custom_css_controls'], 25, 3);
|
||||
|
||||
// Render the Custom CSS
|
||||
add_action('elementor/element/parse_css', [$this, 'add_post_css'], 10, 2);
|
||||
}
|
||||
|
||||
public function add_section_custom_css_controls($widget, $section_id, $args) {
|
||||
if ( 'section_custom_css_pro' !== $section_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Translators: %s is replaced with the plugin name
|
||||
$widget->start_controls_section(
|
||||
'wpr_section_custom_css',
|
||||
[
|
||||
'label' => sprintf(esc_html__('Custom CSS - %s', 'wpr-addons'), Utilities::get_plugin_name()),
|
||||
'tab' => Controls_Manager::TAB_ADVANCED
|
||||
]
|
||||
);
|
||||
|
||||
$widget->add_control(
|
||||
'wpr_custom_css',
|
||||
[
|
||||
'type' => Controls_Manager::CODE,
|
||||
'label' => esc_html__('Custom CSS', 'wpr-addons'),
|
||||
'language' => 'css',
|
||||
'render_type' => 'ui',
|
||||
'label_block' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$widget->add_control(
|
||||
'wpr_custom_css_description',
|
||||
[
|
||||
'raw' => esc_html__('Use "selector" keyword to target wrapper element.', 'wpr-addons'),
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'content_classes' => 'elementor-descriptor',
|
||||
'separator' => 'none'
|
||||
]
|
||||
);
|
||||
|
||||
$widget->end_controls_section();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function add_post_css($post_css, $element) {
|
||||
$element_settings = $element->get_settings();
|
||||
|
||||
if ( empty($element_settings['wpr_custom_css']) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css = trim($element_settings['wpr_custom_css']);
|
||||
|
||||
if ( empty($css) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css = str_replace('selector', $post_css->get_element_unique_selector($element), $css);
|
||||
|
||||
// Add a css comment
|
||||
$css = sprintf('/* Start custom CSS for %s, class: %s */', $element->get_name(), $element->get_unique_selector()) . $css . '/* End custom CSS */';
|
||||
|
||||
$post_css->get_stylesheet()->add_raw_css($css);
|
||||
}
|
||||
}
|
||||
|
||||
new Wpr_Custom_CSS();
|
||||
@@ -0,0 +1,467 @@
|
||||
<?php
|
||||
namespace WprAddons\Extensions;
|
||||
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Control_Media;
|
||||
use Elementor\Controls_Stack;
|
||||
use Elementor\Element_Base;
|
||||
use Elementor\Repeater;
|
||||
use Elementor\Utils;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Wpr_Parallax_Scroll {
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'elementor/element/section/section_background/after_section_end', [$this, 'register_controls'], 10);
|
||||
add_action( 'elementor/frontend/section/before_render', [$this, '_before_render'], 10, 1);
|
||||
add_action( 'elementor/section/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
|
||||
|
||||
// FLEXBOX
|
||||
add_action('elementor/element/container/section_layout/after_section_end', [$this, 'register_controls'], 10);
|
||||
add_action('elementor/frontend/container/before_render', [$this, '_before_render'], 10, 1);
|
||||
add_action( 'elementor/container/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
}
|
||||
|
||||
public function register_controls( $element ) {
|
||||
$element->start_controls_section(
|
||||
'wpr_section_parallax',
|
||||
[
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
'label' => sprintf(esc_html__('Parallax - %s', 'wpr-addons'), Utilities::get_plugin_name()),
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_parallax',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => '<div class="elementor-update-preview-button editor-wpr-preview-update"><span>Update changes to Preview</span><button class="elementor-button elementor-button-success" onclick="elementor.reloadPreview();">Apply</button></div>',
|
||||
'separator' => 'after'
|
||||
]
|
||||
);
|
||||
|
||||
if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
|
||||
$element->add_control(
|
||||
'parallax_video_tutorial',
|
||||
[
|
||||
'raw' => '<br><a href="https://www.youtube.com/watch?v=DcDeQ__lJbw" target="_blank">Watch Video Tutorial <span class="dashicons dashicons-video-alt3"></span></a>',
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_enable_jarallax',
|
||||
[
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label' => __('Enable Background Parallax', 'wpr-addons'),
|
||||
'default' => 'no',
|
||||
'label_on' => __('Yes', 'wpr-addons'),
|
||||
'label_off' => __('No', 'wpr-addons'),
|
||||
'return_value' => 'yes',
|
||||
'render_type' => 'template',
|
||||
'prefix_class' => 'wpr-jarallax-'
|
||||
]
|
||||
);
|
||||
|
||||
// $element->add_control(
|
||||
// 'parallax_item_bg_size',
|
||||
// [
|
||||
// 'label' => esc_html__( 'Size', 'wpr-addons' ),
|
||||
// 'type' => Controls_Manager::SELECT,
|
||||
// 'default' => 'cover',
|
||||
// 'options' => [
|
||||
// 'cover' => esc_html__( 'Cover', 'wpr-addons' ),
|
||||
// 'contain' => esc_html__( 'Contain', 'wpr-addons' ),
|
||||
// 'auto' => esc_html__( 'Auto', 'wpr-addons' ),
|
||||
// ],
|
||||
// 'selectors' => [
|
||||
// '{{WRAPPER}}.wpr-jarallax-yes' => 'position: relative; background-size: {{VALUE}}; background-repeat: no-repeat background-blend-mode: darken; background-position: left top;',
|
||||
// '{{WRAPPER}} .wpr-jarallax' => 'position: relative; background-size: {{VALUE}}; background-repeat: no-repeat; background-blend-mode: darken; background-position: left top;',
|
||||
// ],
|
||||
// ]
|
||||
// );
|
||||
|
||||
$element->add_control(
|
||||
'speed',
|
||||
[
|
||||
'label' => __( 'Animation Speed', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => -1.0,
|
||||
'max' => 2.0,
|
||||
'step' => 0.1,
|
||||
'default' => 1.4,
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'wpr_enable_jarallax' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
\WprAddonsPro\Extensions\Wpr_Parallax_Scroll_Pro::add_control_scroll_effect($element);
|
||||
} else {
|
||||
$element->add_control(
|
||||
'scroll_effect',
|
||||
[
|
||||
'label' => __( 'Scrolling Effect', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => 'scroll',
|
||||
'options' => [
|
||||
'scroll' => esc_html__( 'Scroll', 'wpr-addons' ),
|
||||
'scale' => esc_html__( 'Zoom', 'wpr-addons' ),
|
||||
'pro-op' => esc_html__( 'Opacity (Pro)', 'wpr-addons' ),
|
||||
'pro-sclo' => esc_html__('Scale Opacity (Pro)', 'wpr-addons'),
|
||||
'pro-scrlo' => esc_html__( 'Scroll Opacity (Pro)', 'wpr-addons' )
|
||||
],
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'wpr_enable_jarallax' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
// Upgrade to Pro Notice
|
||||
Utilities::upgrade_pro_notice( $element, Controls_Manager::RAW_HTML, 'parallax-background', 'scroll_effect', ['pro-op','pro-sclo','pro-scrlo'] );
|
||||
}
|
||||
|
||||
$element->add_control(
|
||||
'bg_image',
|
||||
[
|
||||
'label' => __( 'Choose Image', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::MEDIA,
|
||||
'dynamic' => [
|
||||
'active' => true,
|
||||
],
|
||||
'default' => [
|
||||
'url' => Utils::get_placeholder_image_src(),
|
||||
],
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'wpr_enable_jarallax' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
} // end if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
|
||||
$element->add_control(
|
||||
'parallax_type_divider',
|
||||
[
|
||||
'type' => Controls_Manager::DIVIDER,
|
||||
'style' => 'thick',
|
||||
]
|
||||
);
|
||||
|
||||
if ( 'on' === get_option('wpr-parallax-multi-layer', 'on') ) {
|
||||
|
||||
$element->add_control(
|
||||
'parallax_multi_video_tutorial',
|
||||
[
|
||||
'raw' => '<a href="https://youtu.be/DcDeQ__lJbw?t=121" target="_blank">Watch Video Tutorial <span class="dashicons dashicons-video-alt3"></span></a>',
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_enable_parallax_hover',
|
||||
[
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label' => __('Enable Multi Layer Parallax', 'wpr-addons'),
|
||||
'default' => 'no',
|
||||
'label_on' => __('Yes', 'wpr-addons'),
|
||||
'label_off' => __('No', 'wpr-addons'),
|
||||
'return_value' => 'yes',
|
||||
'render_type' => 'template',
|
||||
'prefix_class' => 'wpr-parallax-'
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'invert_direction',
|
||||
[
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label' => __('Invert Animation Direction', 'wpr-addons'),
|
||||
'default' => 'no',
|
||||
'label_on' => __('Yes', 'wpr-addons'),
|
||||
'label_off' => __('No', 'wpr-addons'),
|
||||
'return_value' => 'yes',
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'wpr_enable_parallax_hover' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'scalar_speed',
|
||||
[
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'label' => esc_html__( 'Animation Speed', 'wpr-addons' ),
|
||||
'size_units' => [ '%' ],
|
||||
'range' => [
|
||||
'%' => [
|
||||
'min' => 0.0,
|
||||
'max' => 100.0,
|
||||
]
|
||||
],
|
||||
'default' => [
|
||||
'unit' => '%',
|
||||
'size' => 10.0,
|
||||
],
|
||||
'condition' => [
|
||||
'wpr_enable_parallax_hover' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$repeater = new Repeater();
|
||||
|
||||
$repeater->add_control(
|
||||
'repeater_bg_image',
|
||||
[
|
||||
'label' => __( 'Choose Image', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::MEDIA,
|
||||
// 'dynamic' => [
|
||||
// 'active' => true,
|
||||
// ],
|
||||
'default' => [
|
||||
'url' => Utils::get_placeholder_image_src(),
|
||||
],
|
||||
'render_type' => 'template',
|
||||
]
|
||||
);
|
||||
|
||||
$repeater->add_control(
|
||||
'layer_width',
|
||||
[
|
||||
'label' => esc_html__( 'Image Width', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'default' => 100,
|
||||
'min' => 0,
|
||||
'max' => 1000,
|
||||
'step' => 10,
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} {{CURRENT_ITEM}}.wpr-parallax-ml-children' => 'width: {{SIZE}}px !important;',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$repeater->add_responsive_control(
|
||||
'layer_position_hr',
|
||||
[
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'label' => esc_html__( 'Horizontal Position (%)', 'wpr-addons' ),
|
||||
'size_units' => [ '%' ],
|
||||
'range' => [
|
||||
'%' => [
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
]
|
||||
],
|
||||
'default' => [
|
||||
'unit' => '%',
|
||||
'size' => 50,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} {{CURRENT_ITEM}}.wpr-parallax-ml-children' => 'left: {{SIZE}}{{UNIT}} !important;',
|
||||
],
|
||||
'separator' => 'before',
|
||||
]
|
||||
);
|
||||
|
||||
$repeater->add_responsive_control(
|
||||
'layer_position_vr',
|
||||
[
|
||||
'type' => Controls_Manager::SLIDER,
|
||||
'label' => esc_html__( 'Vertical Position (%)', 'wpr-addons' ),
|
||||
'size_units' => [ '%' ],
|
||||
'range' => [
|
||||
'%' => [
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
]
|
||||
],
|
||||
'default' => [
|
||||
'unit' => '%',
|
||||
'size' => 50,
|
||||
],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}} {{CURRENT_ITEM}}.wpr-parallax-ml-children' => 'top: {{SIZE}}{{UNIT}}!important;',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$repeater->add_control(
|
||||
'data_depth',
|
||||
[
|
||||
'label' => __( 'Data Depth', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => -1.0,
|
||||
'max' => 2.0,
|
||||
'step' => 0.1,
|
||||
'default' => 0.4,
|
||||
'render_type' => 'template',
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'hover_parallax',
|
||||
[
|
||||
'label' => __( 'Repeater List', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::REPEATER,
|
||||
'fields' => $repeater->get_controls(),
|
||||
'default' => [
|
||||
[
|
||||
'layer_position_vr' => [
|
||||
'unit' => '%',
|
||||
'size' => 30,
|
||||
],
|
||||
'layer_position_hr' => [
|
||||
'unit' => '%',
|
||||
'size' => 40,
|
||||
],
|
||||
],
|
||||
[
|
||||
'layer_position_vr' => [
|
||||
'unit' => '%',
|
||||
'size' => 60,
|
||||
],
|
||||
'layer_position_hr' => [
|
||||
'unit' => '%',
|
||||
'size' => 20,
|
||||
],
|
||||
],
|
||||
],
|
||||
'condition' => [
|
||||
'wpr_enable_parallax_hover' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) {
|
||||
$element->add_control(
|
||||
'paralax_repeater_pro_notice',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => 'More than 2 Layers are available<br> in the <strong><a href="https://royal-elementor-addons.com/?ref=rea-plugin-panel-parallax-multi-layer-upgrade-pro#purchasepro" target="_blank">Pro version</a></strong>',
|
||||
// 'raw' => 'More than 2 Layers are available<br> in the <strong><a href="'. admin_url('admin.php?page=wpr-addons-pricing') .'" target="_blank">Pro version</a></strong>',
|
||||
'content_classes' => 'wpr-pro-notice',
|
||||
'condition' => [
|
||||
'wpr_enable_parallax_hover' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
} // end if ( 'on' === get_option('wpr-parallax-multi-layer', 'on') ) {
|
||||
|
||||
$element->end_controls_section();
|
||||
}
|
||||
|
||||
public function _before_render( $element ) {
|
||||
// bail if any other element but section
|
||||
// output buffer controlling functions removed elements from live preview
|
||||
|
||||
if ( $element->get_name() !== 'section' && $element->get_name() !== 'container' ) return;
|
||||
|
||||
$settings = $element->get_settings_for_display();
|
||||
|
||||
// Parallax Background
|
||||
if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
if ( 'yes' === $settings['wpr_enable_jarallax'] ) {
|
||||
$element->add_render_attribute( '_wrapper', [
|
||||
'class' => 'wpr-jarallax',
|
||||
'speed-data' => $settings['speed'],
|
||||
'bg-image' => $settings['bg_image']['url'],
|
||||
'scroll-effect' => $settings['scroll_effect'],
|
||||
] );
|
||||
|
||||
// if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
// echo '<div '. $element->get_render_attribute_string( '_wrapper' ) .'></div>';
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// Parallax Multi Layer
|
||||
if ( 'on' === get_option('wpr-parallax-multi-layer', 'on') ) {
|
||||
if ( $settings['wpr_enable_parallax_hover'] == 'yes' ) {
|
||||
if ( $settings['hover_parallax'] ) {
|
||||
|
||||
echo '<div class="wpr-parallax-multi-layer" scalar-speed="'. esc_attr($settings['scalar_speed']['size']) .'" direction="'. esc_attr($settings['invert_direction']) .'" style="overflow: hidden;">';
|
||||
|
||||
foreach ( $settings['hover_parallax'] as $key => $item ) {
|
||||
if ( $key < 2 || defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
echo '<div data-depth="'. esc_attr($item['data_depth']) .'" style-top="'. esc_attr($item['layer_position_vr']['size']) .'%" style-left="'. esc_attr($item['layer_position_hr']['size']) .'%" class="wpr-parallax-ml-children elementor-repeater-item-'. esc_attr($item['_id']) .'">';
|
||||
echo '<img src="'. esc_url($item['repeater_bg_image']['url']) .'">';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function _print_template( $template, $widget ) {
|
||||
ob_start();
|
||||
|
||||
if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
echo '<div class="wpr-jarallax" speed-data-editor="{{settings.speed}}" scroll-effect-editor="{{settings.scroll_effect}}" bg-image-editor="{{settings.bg_image.url}}"></div>';
|
||||
}
|
||||
// Multi Layer
|
||||
if ( 'on' === get_option('wpr-parallax-multi-layer', 'on') ) {
|
||||
if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) {
|
||||
?>
|
||||
<# if ( settings.hover_parallax.length && settings.wpr_enable_parallax_hover == 'yes') { #>
|
||||
<div class="wpr-parallax-multi-layer" direction="{{settings.invert_direction}}" scalar-speed="{{settings.scalar_speed.size}}" data-relative-input="true" style="overflow: hidden;">
|
||||
<# _.each( settings.hover_parallax, function( item, index ) { #>
|
||||
<# if ( index > 1 ) return; #>
|
||||
<div data-depth="{{item.data_depth}}" class="wpr-parallax-ml-children elementor-repeater-item-{{ item._id }}">
|
||||
<img src="{{item.repeater_bg_image.url}}">
|
||||
</div>
|
||||
<# }); #>
|
||||
</div>
|
||||
<# } #>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<# if ( settings.hover_parallax.length && settings.wpr_enable_parallax_hover == 'yes') { #>
|
||||
<div class="wpr-parallax-multi-layer" direction="{{settings.invert_direction}}" scalar-speed="{{settings.scalar_speed.size}}" data-relative-input="true" style="overflow: hidden;">
|
||||
<# _.each( settings.hover_parallax, function( item ) { #>
|
||||
<div data-depth="{{item.data_depth}}" class="wpr-parallax-ml-children elementor-repeater-item-{{ item._id }}">
|
||||
<img src="{{item.repeater_bg_image.url}}">
|
||||
</div>
|
||||
<# }); #>
|
||||
</div>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
$parallax_content = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
return $template . $parallax_content;
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
if ( 'on' === get_option('wpr-parallax-background', 'on') ) {
|
||||
wp_enqueue_script( 'wpr-jarallax', WPR_ADDONS_URL . 'assets/js/lib/jarallax/jarallax.min.js', ['jquery'], '1.12.7', true );
|
||||
}
|
||||
|
||||
if ( 'on' === get_option('wpr-parallax-multi-layer', 'on') ) {
|
||||
wp_enqueue_script( 'wpr-parallax-hover', WPR_ADDONS_URL . 'assets/js/lib/parallax/parallax.min.js', ['jquery'], '1.0', true );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Wpr_Parallax_Scroll();
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
use Elementor\Controls_Manager;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Wpr_Particles {
|
||||
|
||||
private static $_instance = null;
|
||||
|
||||
public $default_particles = '{"particles":{"number":{"value":80,"density":{"enable":true,"value_area":800}},"color":{"value":"#000000"},"shape":{"type":"circle","stroke":{"width":0,"color":"#000000"},"polygon":{"nb_sides":5},"image":{"src":"img/github.svg","width":100,"height":100}},"opacity":{"value":0.5,"random":false,"anim":{"enable":false,"speed":1,"opacity_min":0.1,"sync":false}},"size":{"value":3,"random":true,"anim":{"enable":false,"speed":40,"size_min":0.1,"sync":false}},"line_linked":{"enable":true,"distance":150,"color":"#000000","opacity":0.4,"width":1},"move":{"enable":true,"speed":6,"direction":"none","random":false,"straight":false,"out_mode":"out","bounce":false,"attract":{"enable":false,"rotateX":600,"rotateY":1200}}},"interactivity":{"detect_on":"window","events":{"onhover":{"enable":true,"mode":"repulse"},"onclick":{"enable":true,"mode":"push"},"resize":true},"modes":{"grab":{"distance":400,"line_linked":{"opacity":1}},"bubble":{"distance":400,"size":40,"duration":2,"opacity":8,"speed":3},"repulse":{"distance":200,"duration":0.4},"push":{"particles_nb":4},"remove":{"particles_nb":2}}},"retina_detect":true}' ;
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'elementor/element/section/section_background/after_section_end', [ $this, 'register_controls' ], 10 );
|
||||
add_action( 'elementor/frontend/section/before_render', [ $this, '_before_render' ], 10, 1 );
|
||||
add_action( 'elementor/section/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
|
||||
|
||||
// FLEXBOX
|
||||
add_action( 'elementor/element/container/section_layout/after_section_end', [$this, 'register_controls'], 10 );
|
||||
add_action( 'elementor/frontend/container/before_render', [$this, '_before_render'], 10, 1 );
|
||||
add_action( 'elementor/container/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
}
|
||||
|
||||
public function register_controls( $element ) {
|
||||
|
||||
if ( ( 'section' === $element->get_name() || 'container' === $element->get_name() ) ) {
|
||||
|
||||
$element->start_controls_section (
|
||||
'wpr_section_particles',
|
||||
[
|
||||
'tab' => Controls_Manager::TAB_STYLE,
|
||||
'label' => sprintf(esc_html__('Particles - %s', 'wpr-addons'), Utilities::get_plugin_name()),
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_particles_apply_changes',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => '<div class="elementor-update-preview-button editor-wpr-preview-update"><span>Update changes to Preview</span><button class="elementor-button elementor-button-success" onclick="elementor.reloadPreview();">Apply</button></div>',
|
||||
'separator' => 'after'
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'particles_video_tutorial',
|
||||
[
|
||||
'raw' => '<br><a href="https://www.youtube.com/watch?v=8OdnaoFSj94" target="_blank">Watch Video Tutorial <span class="dashicons dashicons-video-alt3"></span></a>',
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control (
|
||||
'wpr_enable_particles',
|
||||
[
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label' => esc_html__( 'Enable Particles Background', 'wpr-addons' ),
|
||||
'default' => 'no',
|
||||
'return_value' => 'yes',
|
||||
'prefix_class' => 'wpr-particle-',
|
||||
'render_type' => 'template',
|
||||
]
|
||||
);
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
\WprAddonsPro\Extensions\Wpr_Particles_Pro::add_control_which_particle($element);
|
||||
} else {
|
||||
$element->add_control (
|
||||
'which_particle',
|
||||
[
|
||||
'label' => __( 'Select Style', 'plugin-domain' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => 'wpr_particle_json_custom',
|
||||
'options' => [
|
||||
'wpr_particle_json_custom' => __( 'Custom', 'plugin-domain' ),
|
||||
'pro-pjs' => __( 'Predefined (Pro)', 'plugin-domain' ),
|
||||
],
|
||||
'condition' => [
|
||||
'wpr_enable_particles' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
// Upgrade to Pro Notice
|
||||
Utilities::upgrade_pro_notice( $element, Controls_Manager::RAW_HTML, 'particles', 'which_particle', ['pro-pjs'] );
|
||||
}
|
||||
|
||||
$this->custom_json_particles( $this->default_particles, $element );
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
\WprAddonsPro\Extensions\Wpr_Particles_Pro::add_control_group_predefined_particles($element);
|
||||
}
|
||||
|
||||
$element->end_controls_section();
|
||||
|
||||
} // end if()
|
||||
|
||||
}
|
||||
|
||||
public function custom_json_particles($array, $element) {
|
||||
$element->add_control(
|
||||
'wpr_particle_json_custom_notice',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'content_classes' => 'elementor-control-field-description',
|
||||
'raw' => __('<a href="https://vincentgarreau.com/particles.js/" target="_blank">Click here</a> to generate JSON for the below field.', 'wpr-addons'),
|
||||
'condition' => [
|
||||
'which_particle' => 'wpr_particle_json_custom',
|
||||
'wpr_enable_particles' => 'yes'
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_particle_json_custom',
|
||||
[
|
||||
'type' => Controls_Manager::CODE,
|
||||
'label' => esc_html__( 'Enter Custom JSON', 'wpr-addons' ),
|
||||
'default' => $array,
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'which_particle' => 'wpr_particle_json_custom',
|
||||
'wpr_enable_particles' => 'yes'
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function _print_template( $template, $widget ) {
|
||||
if ( $widget->get_name() !== 'section' && $widget->get_name() !== 'container' ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
echo '<div class="wpr-particle-wrapper" id="wpr-particle-{{ view.getID() }}" data-wpr-particles-editor="{{ settings[settings.which_particle] }}" particle-source="{{settings.which_particle}}" wpr-quantity="{{settings.quantity}}" wpr-color="{{settings.particles_color}}" wpr-speed="{{settings.particles_speed}}" wpr-shape="{{settings.particles_shape}}" wpr-size="{{settings.particles_size}}"></div>';
|
||||
|
||||
$particles_content = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $template . $particles_content;
|
||||
}
|
||||
|
||||
public function _before_render( $element ) {
|
||||
if ( $element->get_name() !== 'section' && $element->get_name() !== 'container' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = $element->get_settings();
|
||||
|
||||
if ( $settings['wpr_enable_particles'] === 'yes' ) {
|
||||
$settings['which_particle'] = 'pro-pjs' === $settings['which_particle'] ? 'wpr_particle_json_custom' : $settings['which_particle'];
|
||||
|
||||
if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) {
|
||||
$element->add_render_attribute( '_wrapper', [
|
||||
'data-wpr-particles' => $settings[$settings['which_particle']],
|
||||
'particle-source' => $settings['which_particle'],
|
||||
] );
|
||||
} else {
|
||||
$element->add_render_attribute( '_wrapper', [
|
||||
'data-wpr-particles' => $settings[$settings['which_particle']],
|
||||
'particle-source' => $settings['which_particle'],
|
||||
'wpr-quantity' => $settings['quantity'],
|
||||
'wpr-color' => $settings['particles_color'],
|
||||
'wpr-speed' => $settings['particles_speed'],
|
||||
'wpr-shape' => $settings['particles_shape'],
|
||||
'wpr-size' => $settings['particles_size']
|
||||
] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function enqueue_scripts() {
|
||||
wp_enqueue_script( 'wpr-particles', WPR_ADDONS_URL . 'assets/js/lib/particles/particles.js', [ 'jquery' ], '3.0.6', true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new Wpr_Particles();
|
||||
@@ -0,0 +1,350 @@
|
||||
<?php
|
||||
use Elementor\Controls_Manager;
|
||||
use Elementor\Control_Media;
|
||||
use Elementor\Controls_Stack;
|
||||
use Elementor\Element_Base;
|
||||
use Elementor\Repeater;
|
||||
use Elementor\Utils;
|
||||
use Elementor\Core\Base\Module;
|
||||
use Elementor\Core\Kits\Documents\Tabs\Settings_Layout;
|
||||
use Elementor\Core\Responsive\Files\Frontend;
|
||||
use Elementor\Plugin;
|
||||
use Elementor\Core\Breakpoints\Manager;
|
||||
use Elementor\Core\Breakpoints;
|
||||
use Elementor\Group_Control_Box_Shadow;
|
||||
use WprAddons\Classes\Utilities;
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Wpr_Sticky_Section {
|
||||
|
||||
public function __construct() {
|
||||
add_action( 'elementor/element/section/section_background/after_section_end', [ $this, 'register_controls' ], 10 );
|
||||
add_action( 'elementor/section/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
add_action( 'elementor/frontend/section/before_render', [ $this, '_before_render' ], 10, 1 );
|
||||
|
||||
// FLEXBOX
|
||||
add_action('elementor/element/container/section_layout/after_section_end', [$this, 'register_controls'], 10);
|
||||
add_action( 'elementor/container/print_template', [ $this, '_print_template' ], 10, 2 );
|
||||
add_action('elementor/frontend/container/before_render', [$this, '_before_render'], 10, 1);
|
||||
}
|
||||
|
||||
public static function add_control_group_sticky_advanced_options($element) {
|
||||
|
||||
$element->add_control(
|
||||
'sticky_advanced_pro_notice',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => '<strong>Advanced Options</strong> are available in the <br><a href="https://royal-elementor-addons.com/?ref=rea-plugin-panel-advanced-stiky-upgrade-pro#purchasepro" target="_blank">Pro Version.</a> You\'ll have the ability to create impressive menu effects. Preview some examples: <strong><a href="https://demosites.royal-elementor-addons.com/fashion-v2/?ref=rea-plugin-panel-advanced-stiky-preview" target="_blank">Demo 1, </a><a href="https://demosites.royal-elementor-addons.com/digital-marketing-agency-v2/?ref=rea-plugin-panel-advanced-stiky-preview" target="_blank">Demo 2, </a><a href="https://demosites.royal-elementor-addons.com/personal-blog-v1/?ref=rea-plugin-panel-advanced-stiky-preview" target="_blank">Demo 3, </a><a href="https://demosites.royal-elementor-addons.com/digital-marketing-agency-v1/?ref=rea-plugin-panel-advanced-stiky-preview" target="_blank">Demo 4, </a><a href="https://demosites.royal-elementor-addons.com/construction-v3/?ref=rea-plugin-panel-advanced-stiky-preview" target="_blank">Demo 5</a></strong><a href="https://www.youtube.com/watch?v=ORay3VWrWuc" target="_blank" style="display: block; color: #f51f3d; margin-top: 10px; margin-bottom: 10px;">Watch Video Tutorial</a><img src="'. WPR_ADDONS_ASSETS_URL .'img/pro-options/sticky-section-pro-features.jpg" style="border: 1px solid #93003C;">',
|
||||
'content_classes' => 'wpr-pro-notice',
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function register_controls( $element ) {
|
||||
|
||||
if ( ( 'section' === $element->get_name() || 'container' === $element->get_name() ) ) {
|
||||
|
||||
$element->start_controls_section (
|
||||
'wpr_section_sticky_section',
|
||||
[
|
||||
'tab' => Controls_Manager::TAB_ADVANCED,
|
||||
'label' => sprintf(esc_html__('Sticky Section - %s', 'wpr-addons'), Utilities::get_plugin_name()),
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_sticky_apply_changes',
|
||||
[
|
||||
'type' => Controls_Manager::RAW_HTML,
|
||||
'raw' => '<div class="elementor-update-preview-button editor-wpr-preview-update"><span>Update changes to Preview</span><button class="elementor-button elementor-button-success" onclick="elementor.reloadPreview();">Apply</button></div>',
|
||||
'separator' => 'after'
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control (
|
||||
'enable_sticky_section',
|
||||
[
|
||||
'type' => Controls_Manager::SWITCHER,
|
||||
'label' => esc_html__( 'Make This Section Sticky', 'wpr-addons' ),
|
||||
'default' => 'no',
|
||||
'return_value' => 'yes',
|
||||
'prefix_class' => 'wpr-sticky-section-',
|
||||
'render_type' => 'template',
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'enable_on_devices',
|
||||
[
|
||||
'label' => esc_html__( 'Enable on Devices', 'wpr-addons' ),
|
||||
'label_block' => true,
|
||||
'type' => Controls_Manager::SELECT2,
|
||||
'default' => ['desktop_sticky'],
|
||||
'options' => $this->breakpoints_manager(),
|
||||
'multiple' => true,
|
||||
'separator' => 'before',
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
],
|
||||
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control (
|
||||
'position_type',
|
||||
[
|
||||
'label' => __( 'Position Type', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => 'sticky',
|
||||
'options' => [
|
||||
'sticky' => __( 'Stick on Scroll', 'wpr-addons' ),
|
||||
'fixed' => __( 'Fixed by Default', 'wpr-addons' ),
|
||||
],
|
||||
// 'selectors' => [
|
||||
// '{{WRAPPER}}' => 'position: {{VALUE}};',
|
||||
// ],
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control (
|
||||
'sticky_type',
|
||||
[
|
||||
'label' => __( 'Sticky Relation', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'description' => __('Please switch to *Window* if you are going to use <span style="color: red;">*Advanced Options*</span>.', 'wpr-addons'),
|
||||
'default' => 'sticky',
|
||||
'options' => [
|
||||
'sticky' => __( 'Parent', 'wpr-addons' ),
|
||||
'fixed' => __( 'Window', 'wpr-addons' ),
|
||||
],
|
||||
'render_type' => 'template',
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes',
|
||||
'position_type' => 'sticky'
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control (
|
||||
'position_location',
|
||||
[
|
||||
'label' => __( 'Location', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::SELECT,
|
||||
'default' => 'top',
|
||||
'render_type' => 'template',
|
||||
'options' => [
|
||||
'top' => __( 'Top', 'wpr-addons' ),
|
||||
'bottom' => __( 'Bottom', 'wpr-addons' ),
|
||||
],
|
||||
// 'selectors_dictionary' => [
|
||||
// 'top' => 'top: {{position_offset.VALUE}}px; bottom: auto;',
|
||||
// 'bottom' => 'bottom: {{position_offset.VALUE}}px; top: auto;'
|
||||
// ],
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'top: auto; bottom: auto; {{VALUE}}: {{position_offset.VALUE}}px;',
|
||||
],
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_responsive_control(
|
||||
'position_offset',
|
||||
[
|
||||
'label' => __( 'Offset', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => 0,
|
||||
'max' => 500,
|
||||
'required' => true,
|
||||
'frontend_available' => true,
|
||||
'render_type' => 'template',
|
||||
'default' => 0,
|
||||
'widescreen_default' => 0,
|
||||
'laptop_default' => 0,
|
||||
'tablet_extra_default' => 0,
|
||||
'tablet_default' => 0,
|
||||
'mobile_extra_default' => 0,
|
||||
'mobile_default' => 0,
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'top: auto; bottom: auto; {{position_location.VALUE}}: {{VALUE}}px;',
|
||||
'{{WRAPPER}} + .wpr-hidden-header' => 'top: {{VALUE}}px;',
|
||||
'{{WRAPPER}} + .wpr-hidden-header-flex' => 'top: {{VALUE}}px;'
|
||||
],
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'wpr_z_index',
|
||||
[
|
||||
'label' => esc_html__( 'Z-Index', 'wpr-addons' ),
|
||||
'type' => Controls_Manager::NUMBER,
|
||||
'min' => -99,
|
||||
'max' => 99999,
|
||||
'step' => 1,
|
||||
'default' => 10,
|
||||
'selectors' => [
|
||||
'{{WRAPPER}}' => 'z-index: {{VALUE}};',
|
||||
'.wpr-hidden-header' => 'z-index: {{VALUE}};',
|
||||
'.wpr-hidden-header-flex' => 'z-index: {{VALUE}};'
|
||||
],
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
],
|
||||
'render_type' => 'template'
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'custom_breakpoints',
|
||||
[
|
||||
'label' => __( 'Breakpoints', 'wpr-addons' ),
|
||||
'type' => \Elementor\Controls_Manager::HIDDEN,
|
||||
'default' => get_option('elementor_experiment-additional_custom_breakpoints'),
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$element->add_control(
|
||||
'active_breakpoints',
|
||||
[
|
||||
'label' => __( 'Active Breakpoints', 'wpr-addons' ),
|
||||
'type' => \Elementor\Controls_Manager::HIDDEN,
|
||||
'default' => $this->breakpoints_manager_active(),
|
||||
'condition' => [
|
||||
'enable_sticky_section' => 'yes'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
|
||||
if ( class_exists('WprAddonsPro\Extensions\Wpr_Sticky_Section_Pro') ) {
|
||||
\WprAddonsPro\Extensions\Wpr_Sticky_Section_Pro::add_control_group_sticky_advanced_options($element);
|
||||
}
|
||||
} else {
|
||||
$this->add_control_group_sticky_advanced_options($element);
|
||||
}
|
||||
|
||||
$element->end_controls_section();
|
||||
}
|
||||
}
|
||||
|
||||
public function breakpoints_manager() {
|
||||
$active_breakpoints = [];
|
||||
foreach ( \Elementor\Plugin::$instance->breakpoints->get_active_breakpoints() as $key => $value ) {
|
||||
$active_breakpoints[$key . '_sticky'] = esc_html__(ucwords(preg_replace('/_/i', ' ', $key)), 'wpr-addons');
|
||||
}
|
||||
|
||||
$active_breakpoints['desktop_sticky'] = esc_html__('Desktop', 'wpr-addons');
|
||||
return $active_breakpoints;
|
||||
}
|
||||
|
||||
public function breakpoints_manager_active() {
|
||||
$active_breakpoints = [];
|
||||
|
||||
foreach ( $this->breakpoints_manager() as $key => $value ) {
|
||||
array_push($active_breakpoints, $key);
|
||||
}
|
||||
|
||||
return $active_breakpoints;
|
||||
}
|
||||
|
||||
public function _before_render( $element ) {
|
||||
if ( $element->get_name() !== 'section' && $element->get_name() !== 'container' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = $element->get_settings_for_display();
|
||||
|
||||
if ($settings['enable_sticky_section'] !== 'yes') return;
|
||||
|
||||
$wpr_sticky_effects_offset_widescreen = isset($settings['wpr_sticky_effects_offset_widescreen']) && !empty($settings['wpr_sticky_effects_offset_widescreen']) ? $settings['wpr_sticky_effects_offset_widescreen'] : 0;
|
||||
$wpr_sticky_effects_offset_desktop = isset($settings['wpr_sticky_effects_offset']) && !empty($settings['wpr_sticky_effects_offset']) ? $settings['wpr_sticky_effects_offset'] : $wpr_sticky_effects_offset_widescreen;
|
||||
$wpr_sticky_effects_offset_laptop = isset($settings['wpr_sticky_effects_offset_laptop']) && !empty($settings['wpr_sticky_effects_offset_laptop']) ? $settings['wpr_sticky_effects_offset_laptop'] : $wpr_sticky_effects_offset_desktop;
|
||||
$wpr_sticky_effects_offset_tablet_extra = isset($settings['wpr_sticky_effects_offset_tablet_extra']) && !empty($settings['wpr_sticky_effects_offset_tablet_extra']) ? $settings['wpr_sticky_effects_offset_tablet_extra'] : $wpr_sticky_effects_offset_laptop;
|
||||
$wpr_sticky_effects_offset_tablet = isset($settings['wpr_sticky_effects_offset_tablet']) && !empty($settings['wpr_sticky_effects_offset_tablet']) ? $settings['wpr_sticky_effects_offset_tablet'] : $wpr_sticky_effects_offset_tablet_extra;
|
||||
$wpr_sticky_effects_offset_mobile_extra = isset($settings['wpr_sticky_effects_offset_mobile_extra']) && !empty($settings['wpr_sticky_effects_offset_mobile_extra']) ? $settings['wpr_sticky_effects_offset_mobile_extra'] : $wpr_sticky_effects_offset_tablet;
|
||||
$wpr_sticky_effects_offset_mobile = isset($settings['wpr_sticky_effects_offset_mobile']) && !empty($settings['wpr_sticky_effects_offset_mobile']) ? $settings['wpr_sticky_effects_offset_mobile'] : $wpr_sticky_effects_offset_mobile_extra;
|
||||
|
||||
$allowed_positions = ['top', 'bottom']; // Define allowed positions
|
||||
// $position_location = isset( $_POST['position_location'] ) ? $_POST['position_location'] : ''; // TODO: Check if this is needed
|
||||
$position_location = $settings['position_location'];
|
||||
|
||||
if ( ! in_array( $position_location, $allowed_positions ) ) {
|
||||
$position_location = 'top';
|
||||
} else {
|
||||
$position_location = sanitize_text_field( $position_location );
|
||||
}
|
||||
|
||||
if ( $settings['enable_sticky_section'] === 'yes' ) {
|
||||
$element->add_render_attribute( '_wrapper', [
|
||||
'data-wpr-sticky-section' => $settings['enable_sticky_section'],
|
||||
'data-wpr-position-type' => $settings['position_type'],
|
||||
'data-wpr-position-offset' => $settings['position_offset'],
|
||||
'data-wpr-position-location' => $position_location,
|
||||
'data-wpr-sticky-devices' => $settings['enable_on_devices'],
|
||||
'data-wpr-custom-breakpoints' => $settings['custom_breakpoints'],
|
||||
'data-wpr-active-breakpoints' => $this->breakpoints_manager_active(),
|
||||
'data-wpr-z-index' => $settings['wpr_z_index'],
|
||||
'data-wpr-sticky-hide' => isset($settings['sticky_hide']) ? $settings['sticky_hide'] : '',
|
||||
'data-wpr-replace-header' => isset($settings['sticky_replace_header']) ? $settings['sticky_replace_header'] : '',
|
||||
'data-wpr-animation-duration' => isset($settings['sticky_animation_duration']) ? $settings['sticky_animation_duration'] : '',
|
||||
'data-wpr-sticky-type' => isset($settings['sticky_type']) ? $settings['sticky_type'] : '',
|
||||
// 'data-wpr-offset-settings' => wp_json_encode([
|
||||
// 'widescreen' => $wpr_sticky_effects_offset_widescreen,
|
||||
// 'desktop' => $wpr_sticky_effects_offset_desktop,
|
||||
// 'laptop' => $wpr_sticky_effects_offset_laptop,
|
||||
// 'tablet_extra' => $wpr_sticky_effects_offset_tablet_extra,
|
||||
// 'tablet' => $wpr_sticky_effects_offset_tablet,
|
||||
// 'mobile_extra' => $wpr_sticky_effects_offset_mobile_extra,
|
||||
// 'mobile' => $wpr_sticky_effects_offset_mobile
|
||||
// ])
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
public function _print_template( $template, $widget ) {
|
||||
if ( $widget->get_name() !== 'section' && $widget->get_name() !== 'container' ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
?>
|
||||
|
||||
<# if ( 'yes' === settings.enable_sticky_section) { #>
|
||||
<# if ( 'top' !== settings.position_location && 'bottom' !== settings.position_location ) {
|
||||
settings.position_location = 'top';
|
||||
} #>
|
||||
|
||||
<div class="wpr-sticky-section-yes-editor" data-wpr-z-index={{{settings.wpr_z_index}}} data-wpr-sticky-section={{{settings.enable_sticky_section}}} data-wpr-position-type={{{settings.position_type}}} data-wpr-position-offset={{{settings.position_offset}}} data-wpr-position-location={{{settings.position_location}}} data-wpr-sticky-devices={{{settings.enable_on_devices}}} data-wpr-custom-breakpoints={{{settings.custom_breakpoints}}} data-wpr-active-breakpoints={{{settings.active_breakpoints}}} data-wpr-sticky-animation={{{settings.sticky_animation}}} data-wpr-offset-settings={{{settings.wpr_sticky_effects_offset}}} data-wpr-sticky-type={{{settings.sticky_type}}}></div>
|
||||
<# } #>
|
||||
|
||||
<?php
|
||||
|
||||
// how to render attributes without creating new div using view.addRenderAttributes
|
||||
$particles_content = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return $template . $particles_content;
|
||||
}
|
||||
}
|
||||
|
||||
new Wpr_Sticky_Section();
|
||||
Reference in New Issue
Block a user