This commit is contained in:
2025-11-18 16:39:33 +00:00
parent c70394d367
commit df1f90c6cd
9673 changed files with 3464697 additions and 34 deletions
@@ -0,0 +1,66 @@
jQuery(window).on("elementor:init", (function() {
"use strict";
var wprAjaxSelect2 = elementor.modules.controls.BaseData.extend({
onReady: function() {
var $this = this,
$select = $this.ui.select,
restUrl = $select.attr("data-rest-url"),
nonce = window.wpApiSettings.nonce;
var querySlug = '' !== $select.attr('data-query-slug') ? $select.attr('data-query-slug') : '';
$select.select2({
ajax: {
url: restUrl,
dataType: "json",
headers: {
"X-WP-Nonce": nonce
},
data: function(response) {
return {
s: response.term,
query_slug: querySlug
}
}
},
cache: !0
});
var controlValue = void 0 !== $this.getControlValue() ? $this.getControlValue() : "";
controlValue.isArray && (controlValue = $this.getControlValue().join()), jQuery.ajax({
url: restUrl,
dataType: "json",
headers: {
"X-WP-Nonce": nonce
},
data: {
ids: String(controlValue),
query_slug: querySlug
}
}).then((function(response) {
if ( '' !== controlValue ) {
null !== response && response.results.length > 0 && (jQuery.each(response.results, (function(index, element) {
var option = new Option(element.text, element.id, !0, !0);
$select.append(option);
$select.append(option).trigger('change.select2');
$select.val(controlValue).trigger('change.select2');
})), $select.trigger({
type: "select2:select",
params: {
data: response
}
}))
}
}))
},
onBeforeDestroy: function() {
this.ui.select.data("select2") && this.ui.select.select2("destroy"), this.el.remove()
}
});
elementor.addControlView("wpr-ajax-select2", wprAjaxSelect2)
}));
@@ -0,0 +1,426 @@
<?php
use WprAddons\Classes\Utilities;
class Wpr_Control_Ajax_Select2_Api {
public function __construct() {
$this->init();
}
public function init() {
add_action( 'rest_api_init', function() {
register_rest_route(
'wpraddons/v1/ajaxselect2',
'/(?P<action>\w+)/',
[
'methods' => 'GET',
'callback' => [$this, 'callback'],
'permission_callback' => '__return_true'
]
);
} );
}
public function callback( $request ) {
return $this->{$request['action']}( $request );
}
public function get_elementor_templates( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$args = [
'post_type' => 'elementor_library',
'post_status' => 'publish',
'meta_key' => '_elementor_template_type',
'meta_value' => ['page', 'section', 'container'],
'numberposts' => 15
];
if ( isset( $request['s'] ) ) {
$args['s'] = $request['s'];
}
$options = [];
$query = new \WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$options[] = [
'id' => get_the_ID(),
'text' => html_entity_decode(get_the_title()),
];
}
}
wp_reset_postdata();
return [ 'results' => $options ];
}
public function get_posts_by_post_type( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$post_type = isset($request['query_slug']) ? $request['query_slug'] : '';
$args = [
'post_type' => $post_type,
'post_status' => 'publish',
'posts_per_page' => 15,
];
if ( isset( $request['ids'] ) ) {
$ids = explode( ',', $request['ids'] );
$args['post__in'] = $ids;
}
if ( isset( $request['s'] ) ) {
$args['s'] = $request['s'];
}
if ( 'attachment' === $post_type ) {
$args['post_status'] = 'any';
}
$options = [];
$query = new \WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$options[] = [
'id' => get_the_ID(),
'text' => html_entity_decode(get_the_title()),
];
}
}
wp_reset_postdata();
return [ 'results' => $options ];
}
public function get_taxonomies( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$args = [
'orderby' => 'name',
'order' => 'DESC',
'hide_empty' => true,
'number' => 10,
];
$tax = isset($request['query_slug']) ? $request['query_slug'] : '';
if ( isset( $request['ids'] ) ) {
$request['ids'] = ('' !== $request['ids']) ? $request['ids'] : '99999999'; // Query Hack
$ids = explode( ',', $request['ids'] );
$args['include'] = $ids;
}
if ( isset( $request['s'] ) ) {
$args['name__like'] = $request['s'];
}
$options = [];
$terms = get_terms( $tax, $args );
if ( ! empty($terms) ) {
foreach ( $terms as $term ) {
$options[] = [
'id' => $term->term_id,
'text' => $term->name,
];
}
}
wp_reset_postdata();
return [ 'results' => $options ];
}
public function get_users( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$args = [
'number' => '15',
'blog_id' => 0
];
if ( isset( $request['ids'] ) ) {
$ids = array_map('intval', explode(',', $request['ids'] ));
$args['include'] = $ids;
}
if ( isset( $request['s'] ) ) {
$args['search'] = '*'. $request['s'] .'*';
}
$options = [];
$user_query = new \WP_User_Query( $args );
if ( ! empty( $user_query->get_results() ) ) {
foreach ( $user_query->get_results() as $user ) {
$options[] = [
'id' => $user->ID,
'text' => $user->display_name,
];
}
}
wp_reset_postdata();
return [ 'results' => $options ];
}
public function get_post_type_taxonomies( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$post_type = isset($request['query_slug']) ? $request['query_slug'] : '';
$args = [
'orderby' => 'name',
'order' => 'DESC',
'hide_empty' => true,
'number' => -1,
];
if ( isset( $request['ids'] ) ) {
$request['ids'] = ('' !== $request['ids']) ? $request['ids'] : '99999999'; // Query Hack
$ids = explode( ',', $request['ids'] );
$args['include'] = $ids;
}
if ( isset( $request['s'] ) ) {
$args['name__like'] = $request['s'];
}
$options = [];
$taxonomies = get_object_taxonomies( $post_type, 'objects' );
if ( ! empty($taxonomies) ) {
foreach ( $taxonomies as $taxonomy ) {
$options[] = [
'id' => $taxonomy->name,
'text' => $taxonomy->label,
];
}
}
wp_reset_postdata();
return [ 'results' => $options ];
}
/**
** Get Custom Meta Keys
*/
public function get_custom_meta_keys( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$data = [];
$options = [];
$merged_meta_keys = [];
$post_types = Utilities::get_custom_types_of( 'post', false );
foreach ( $post_types as $post_type_slug => $post_type_name ) {
$data[ $post_type_slug ] = [];
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
foreach ( $posts as $key => $post ) {
$meta_keys = get_post_custom_keys( $post->ID );
if ( ! empty($meta_keys) ) {
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
array_push( $data[$post_type_slug], $meta_keys[$i] );
}
}
}
}
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
}
foreach ( $data as $array ) {
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
}
// Rekey
$merged_meta_keys = array_values($merged_meta_keys);
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
// Add a search condition here
if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) {
$options[] = [
'id' => $merged_meta_keys[$i],
'text' => $merged_meta_keys[$i],
];
}
}
return [ 'results' => $options ];
}
/**
** Get Custom Meta Keys Product
*/
public function get_custom_meta_keys_product( $request ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$data = [];
$options = [];
$merged_meta_keys = [];
$post_types = Utilities::get_custom_types_of( 'post', false );
foreach ( $post_types as $post_type_slug => $post_type_name ) {
$data[ $post_type_slug ] = [];
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
foreach ( $posts as $key => $post ) {
$meta_keys = get_post_custom_keys( $post->ID );
if ( ! empty($meta_keys) ) {
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
array_push( $data[$post_type_slug], $meta_keys[$i] );
}
}
}
}
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
}
foreach ( $data as $array ) {
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
}
// Rekey
$merged_meta_keys = array_values($merged_meta_keys);
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
// Add a search condition here
if ( ! isset( $request['s'] ) || strpos( $merged_meta_keys[$i], $request['s'] ) !== false ) {
$options[] = [
'id' => $merged_meta_keys[$i],
'text' => $merged_meta_keys[$i],
];
}
}
// Get a list of all product attributes used by products
$product_attributes = array();
// Query for all products of the "product" post type
$args = array(
'post_type' => 'product', // Change to the correct post type if needed
'posts_per_page' => -1, // Retrieve all products
);
$products_query = new \WP_Query($args);
if ($products_query->have_posts()) {
while ($products_query->have_posts()) {
$products_query->the_post();
// Get the product object
$product = wc_get_product(get_the_ID());
// Get product attributes
$attributes = $product->get_attributes();
// Loop through attributes and add them to the master list
foreach ($attributes as $attribute) {
$product_attributes[$attribute->get_name()] = true;
}
}
// Reset post data
wp_reset_postdata();
// Extract attribute names from the master list
$attribute_names = array_keys($product_attributes);
// Initialize an empty array
$attributes_array = [];
// Iterate through the original array and set both key and value to be the same
foreach ($attribute_names as $value) {
$attributes_array[] = [
'id' => $value,
'text' => $value,
];
}
$options = array_merge($options, $attributes_array);
}
return [ 'results' => $options ];
}
/**
** Get Custom Meta Keys Data
*/
public function get_custom_meta_keys_data() { // TODO
if ( ! current_user_can( 'edit_posts' ) ) {
return;
}
$data = [];
$options = [];
$merged_meta_keys = [];
$post_types = Utilities::get_custom_types_of( 'post', false );
foreach ( $post_types as $post_type_slug => $post_type_name ) {
$data[ $post_type_slug ] = [];
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
foreach ( $posts as $key => $post ) {
$meta_keys = get_post_custom_keys( $post->ID );
if ( ! empty($meta_keys) ) {
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
array_push( $data[$post_type_slug], $meta_keys[$i] );
}
}
}
}
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
}
foreach ( $data as $array ) {
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
}
// Rekey
$merged_meta_keys = array_values($merged_meta_keys);
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
$options[ $merged_meta_keys[$i] ] = $merged_meta_keys[$i];
}
// return [ $data, $options ];
return [ 'results' => $data ];
}
}
new Wpr_Control_Ajax_Select2_Api();
@@ -0,0 +1,47 @@
<?php
namespace WprAddons\Includes\Controls\WprAjaxSelect2;
use Elementor\Base_Data_Control;
use WprAddons\Classes\Utilities;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class WPR_Control_Ajax_Select2 extends Base_Data_Control {
public function get_type() {
return 'wpr-ajax-select2';
}
public function enqueue() {
wp_register_script( 'wpr-control-ajax-select2', WPR_ADDONS_URL . 'includes/controls/wpr-ajax-select2/js/wpr-control-ajax-select2.js' );
wp_enqueue_script( 'wpr-control-ajax-select2' );
}
protected function get_default_settings() {
return [
'options' => [],
'multiple' => false,
'select2options' => [],
'query_slug' => '',
];
}
public function content_template() {
$control_uid = $this->get_control_uid();
?>
<div class="elementor-control-field">
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<# var multiple = ( data.multiple ) ? 'multiple' : ''; #>
<select id="<?php echo esc_attr($control_uid); ?>" class="elementor-control-type-wpr-ajaxselect2" {{ multiple }} data-query-slug="{{data.query_slug}}" data-setting="{{ data.name }}" data-rest-url="<?php echo esc_attr( get_rest_url(). 'wpraddons/v1' . '/{{data.options}}/' ); ?>">
</select>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<?php
}
}
@@ -0,0 +1,310 @@
<?php
namespace WprAddons\Includes\Controls;
use Elementor\Base_Data_Control;
use WprAddons\Classes\Utilities;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Animation Control for Elements.
*
* A base control for creating entrance animation control. Displays a select box
* with the available entrance animation effects @see WPR_Control_Animations::get_animations() .
*/
class WPR_Control_Animations extends Base_Data_Control {
/**
* List of animations.
*/
private static $_animations;
/**
* Get control type.
*/
public function get_type() {
return 'wpr-animations';
}
/**
* Get animations list.
* Retrieve the list of all the available animations.
*/
public static function get_animations() {
if ( is_null( self::$_animations ) ) {
self::$_animations = [
'Fade' => [
'fade-in' => 'Fade In',
'fade-out' => 'Fade Out',
],
'Slide' => [
'pro-sltp' => 'Top (Pro)',
'pro-slrt' => 'Right (Pro)',
'pro-slxrt' => 'X Right (Pro)',
'pro-slbt' => 'Bottom (Pro)',
'pro-sllt' => 'Left (Pro)',
'pro-slxlt' => 'X Left (Pro)',
],
'Skew' => [
'pro-sktp' => 'Top (Pro)',
'pro-skrt' => 'Right (Pro)',
'pro-skbt' => 'Bottom (Pro)',
'pro-sklt' => 'Left (Pro)',
],
'Scale' => [
'pro-scup' => 'Up (Pro)',
'pro-scdn' => 'Down (Pro)',
],
'Roll' => [
'pro-rllt' => 'Left (Pro)',
'pro-rlrt' => 'Right (Pro)',
],
];
}
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
self::$_animations = \WprAddonsPro\Includes\Controls\WPR_Control_Animations_Pro::wpr_animations();
}
return self::$_animations;
}
/**
* Render animations control template.
*
* Used to generate the control HTML in the editor using Underscore JS
* template. The variables for the class are available using `data` JS
* object.
*/
public function content_template() {
$control_uid = $this->get_control_uid();
?>
<div class="elementor-control-field">
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
<?php foreach ( self::get_animations() as $animations_group_name => $animations_group ) : ?>
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<?php
}
}
/**
* Animation Control for Overlays.
*
* A base control for creating entrance animation control. Displays a select box
* with the available entrance animation effects @see WPR_Control_Animations::get_animations() .
*/
class WPR_Control_Animations_Alt extends WPR_Control_Animations {
/**
* Get control type.
*/
public function get_type() {
return 'wpr-animations-alt';
}
/**
* Render animations control template.
*
* Used to generate the control HTML in the editor using Underscore JS
* template. The variables for the class are available using `data` JS
* object.
*/
public function content_template() {
$animations = self::get_animations();
$control_uid = $this->get_control_uid();
// Remove Extra
unset($animations['Slide']['slide-x-right']);
unset($animations['Slide']['slide-x-left']);
?>
<div class="elementor-control-field">
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
<?php foreach ( $animations as $animations_group_name => $animations_group ) : ?>
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<?php
}
}
/**
* Animation Control for Buttons.
*
* A base control for creating button animation control. Displays a select box
* with the available button animation effects @see WPR_Control_Button_Animations::get_animations() .
*/
class WPR_Control_Button_Animations extends Base_Data_Control {
/**
* List of animations.
*/
private static $_animations;
/**
* Get control type.
*/
public function get_type() {
return 'wpr-button-animations';
}
/**
* Get animations list.
* Retrieve the list of all the available animations.
*/
public static function get_animations() {
if ( is_null( self::$_animations ) ) {
self::$_animations = [
'Animations' => [
'wpr-button-none' => esc_html__( 'None', 'wpr-addons' ),
'pro-wnt' => esc_html__( 'Winona + Text (Pro)', 'wpr-addons' ),
'pro-rlt' => esc_html__( 'Ray Left + Text (Pro)', 'wpr-addons' ),
'pro-rrt' => esc_html__( 'Ray Right + Text (Pro)', 'wpr-addons' ),
'wpr-button-wayra-left' => esc_html__( 'Wayra Left', 'wpr-addons' ),
'wpr-button-wayra-right' => esc_html__( 'Wayra Right', 'wpr-addons' ),
'wpr-button-isi-left' => esc_html__( 'Isi Left', 'wpr-addons' ),
'wpr-button-isi-right' => esc_html__( 'Isi Right', 'wpr-addons' ),
'wpr-button-aylen' => esc_html__( 'Aylen', 'wpr-addons' ),
'wpr-button-antiman' => esc_html__( 'Antiman', 'wpr-addons' ),
],
'2D Animations' => [
'elementor-animation-grow' => esc_html__( 'Grow', 'wpr-addons' ),
'elementor-animation-shrink' => esc_html__( 'Shrink', 'wpr-addons' ),
'elementor-animation-pulse' => esc_html__( 'Pulse', 'wpr-addons' ),
'elementor-animation-pulse-grow' => esc_html__( 'Pulse Grow', 'wpr-addons' ),
'elementor-animation-pulse-shrink' => esc_html__( 'Pulse Shrink', 'wpr-addons' ),
'elementor-animation-push' => esc_html__( 'Push', 'wpr-addons' ),
'elementor-animation-pop' => esc_html__( 'Pop', 'wpr-addons' ),
'elementor-animation-bounce-in' => esc_html__( 'Bounce In', 'wpr-addons' ),
'elementor-animation-bounce-out' => esc_html__( 'Bounce Out', 'wpr-addons' ),
'elementor-animation-rotate' => esc_html__( 'Rotate', 'wpr-addons' ),
'elementor-animation-grow-rotate' => esc_html__( 'Grow Rotate', 'wpr-addons' ),
'elementor-animation-float' => esc_html__( 'Float', 'wpr-addons' ),
'elementor-animation-sink' => esc_html__( 'Sink', 'wpr-addons' ),
'elementor-animation-bob' => esc_html__( 'Bob', 'wpr-addons' ),
'elementor-animation-hang' => esc_html__( 'Hang', 'wpr-addons' ),
'elementor-animation-skew' => esc_html__( 'Skew', 'wpr-addons' ),
'elementor-animation-skew-forward' => esc_html__( 'Skew Forward', 'wpr-addons' ),
'elementor-animation-skew-backward' => esc_html__( 'Skew Backward', 'wpr-addons' ),
'elementor-animation-wobble-horizontal' => esc_html__( 'Wobble Horizontal', 'wpr-addons' ),
'elementor-animation-wobble-vertical' => esc_html__( 'Wobble Vertical', 'wpr-addons' ),
'elementor-animation-wobble-to-bottom-right' => esc_html__( 'Wobble To Bottom Right', 'wpr-addons' ),
'elementor-animation-wobble-to-top-right' => esc_html__( 'Wobble To Top Right', 'wpr-addons' ),
'elementor-animation-wobble-top' => esc_html__( 'Wobble Top', 'wpr-addons' ),
'elementor-animation-wobble-bottom' => esc_html__( 'Wobble Bottom', 'wpr-addons' ),
'elementor-animation-wobble-skew' => esc_html__( 'Wobble Skew', 'wpr-addons' ),
'elementor-animation-buzz' => esc_html__( 'Buzz', 'wpr-addons' ),
'elementor-animation-buzz-out' => esc_html__( 'Buzz Out', 'wpr-addons' ),
'elementor-animation-forward' => esc_html__( 'Forward', 'wpr-addons' ),
'elementor-animation-backward' => esc_html__( 'Backward', 'wpr-addons' ),
],
'Background Animations' => [
'wpr-button-back-pulse' => esc_html__( 'Back Pulse', 'wpr-addons' ),
'wpr-button-sweep-to-right' => esc_html__( 'Sweep To Right', 'wpr-addons' ),
'wpr-button-sweep-to-left' => esc_html__( 'Sweep To Left', 'wpr-addons' ),
'wpr-button-sweep-to-bottom' => esc_html__( 'Sweep To Bottom', 'wpr-addons' ),
'wpr-button-sweep-to-top' => esc_html__( 'Sweep To top', 'wpr-addons' ),
'wpr-button-bounce-to-right' => esc_html__( 'Bounce To Right', 'wpr-addons' ),
'wpr-button-bounce-to-left' => esc_html__( 'Bounce To Left', 'wpr-addons' ),
'wpr-button-bounce-to-bottom' => esc_html__( 'Bounce To Bottom', 'wpr-addons' ),
'wpr-button-bounce-to-top' => esc_html__( 'Bounce To Top', 'wpr-addons' ),
'wpr-button-radial-out' => esc_html__( 'Radial Out', 'wpr-addons' ),
'wpr-button-radial-in' => esc_html__( 'Radial In', 'wpr-addons' ),
'wpr-button-rectangle-in' => esc_html__( 'Rectangle In', 'wpr-addons' ),
'wpr-button-rectangle-out' => esc_html__( 'Rectangle Out', 'wpr-addons' ),
'wpr-button-shutter-in-horizontal' => esc_html__( 'Shutter In Horizontal', 'wpr-addons' ),
'wpr-button-shutter-out-horizontal' => esc_html__( 'Shutter Out Horizontal', 'wpr-addons' ),
'wpr-button-shutter-in-vertical' => esc_html__( 'Shutter In Vertical', 'wpr-addons' ),
'wpr-button-shutter-out-vertical' => esc_html__( 'Shutter Out Vertical', 'wpr-addons' ),
'wpr-button-underline-from-left' => esc_html__( 'Underline From Left', 'wpr-addons' ),
'wpr-button-underline-from-center' => esc_html__( 'Underline From Center', 'wpr-addons' ),
'wpr-button-underline-from-right' => esc_html__( 'Underline From Right', 'wpr-addons' ),
'wpr-button-underline-reveal' => esc_html__( 'Underline Reveal', 'wpr-addons' ),
'wpr-button-overline-reveal' => esc_html__( 'Overline Reveal', 'wpr-addons' ),
'wpr-button-overline-from-left' => esc_html__( 'Overline From Left', 'wpr-addons' ),
'wpr-button-overline-from-center' => esc_html__( 'Overline From Center', 'wpr-addons' ),
'wpr-button-overline-from-right' => esc_html__( 'Overline From Right', 'wpr-addons' ),
]
];
}
if ( defined('WPR_ADDONS_PRO_VERSION') && wpr_fs()->can_use_premium_code() ) {
self::$_animations = \WprAddonsPro\Includes\Controls\WPR_Control_Animations_Pro::wpr_button_animations();
}
return self::$_animations;
}
/**
* Render animations control template.
*
* Used to generate the control HTML in the editor using Underscore JS
* template. The variables for the class are available using `data` JS
* object.
*/
public function content_template() {
$control_uid = $this->get_control_uid();
?>
<div class="elementor-control-field">
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
<?php foreach ( self::get_animations() as $animations_group_name => $animations_group ) : ?>
<optgroup label="<?php echo esc_attr($animations_group_name); ?>">
<?php foreach ( $animations_group as $animation_name => $animation_title ) : ?>
<option value="<?php echo esc_attr($animation_name); ?>"><?php echo esc_html($animation_title); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<?php
}
public static function get_assets( $setting ) {
if ( ! $setting || 'none' === $setting || !str_contains($setting, 'elementor-animation') ) {
return [];
}
return [
'styles' => [ 'e-animation-' . str_replace('elementor-animation-', '', $setting) ],
];
}
}
@@ -0,0 +1,61 @@
<?php
namespace WprAddons\Includes\Controls;
use Elementor\Base_Data_Control;
use WprAddons\Classes\Utilities;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class WPR_Control_Arrow_Icons extends Base_Data_Control {
private static $_arrow_icons;
public function get_type() {
return 'wpr-arrow-icons';
}
public static function get_arrow_icons() {
if ( is_null( self::$_arrow_icons ) ) {
self::$_arrow_icons = [
'Font Awesome' => [
'fas fa-angle' => esc_html__( 'Angle', 'wpr-addons' ),
'fas fa-angle-double' => esc_html__( 'Angle Double', 'wpr-addons' ),
'fas fa-arrow' => esc_html__( 'Arrow', 'wpr-addons' ),
'fas fa-arrow-alt-circle' => esc_html__( 'Arrow Circle', 'wpr-addons' ),
'far fa-arrow-alt-circle' => esc_html__( 'Arrow Circle Alt', 'wpr-addons' ),
'fas fa-long-arrow-alt' => esc_html__( 'Long Arrow', 'wpr-addons' ),
'fas fa-chevron' => esc_html__( 'Chevron', 'wpr-addons' ),
],
'Svg' => Utilities::get_svg_icons_array( 'arrows', [] ),
];
}
return self::$_arrow_icons;
}
public function content_template() {
$control_uid = $this->get_control_uid();
?>
<div class="elementor-control-field">
<label for="<?php echo esc_attr($control_uid); ?>" class="elementor-control-title">{{{ data.label }}}</label>
<div class="elementor-control-input-wrapper">
<select id="<?php echo esc_attr($control_uid); ?>" data-setting="{{ data.name }}">
<option value="none"><?php echo esc_html__( 'None', 'wpr-addons' ); ?></option>
<?php foreach ( self::get_arrow_icons() as $arrow_icons_group_name => $arrow_icons_group ) : ?>
<optgroup label="<?php echo esc_attr($arrow_icons_group_name); ?>">
<?php foreach ( $arrow_icons_group as $arrow_icon_name => $arrow_icon_title ) : ?>
<option value="<?php echo esc_attr($arrow_icon_name); ?>"><?php echo esc_html($arrow_icon_title); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>
<# if ( data.description ) { #>
<div class="elementor-control-field-description">{{{ data.description }}}</div>
<# } #>
<?php
}
}