PluginProbe ʕ •ᴥ•ʔ
ECS – Ele Custom Skin for Elementor / 4.3.6
ECS – Ele Custom Skin for Elementor v4.3.6
4.3.6 4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.11 4.1.10 4.1.9 4.1.8 4.1.6 4.1.7 4.1.5 4.1.4 4.1.1 4.1.2 trunk 1.0.0 1.0.1 1.0.9 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.4 1.2.5 1.3.10 1.3.11 1.3.3 1.3.4 1.3.6 1.3.7 1.3.9 1.4.0 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 4.1.0
ele-custom-skin / includes / dynamic-style.php
ele-custom-skin / includes Last commit date
admin-bar-menu.php 3 years ago ajax-pagination.php 2 years ago class-ecs-core.php 2 months ago class-ecs-module-base.php 1 month ago class-ecs-modules-manager.php 2 months ago dynamic-style.php 3 years ago ecs-dependencies.php 6 years ago ecs-notices.php 6 years ago enqueue-styles.php 2 years ago pro-features.php 2 months ago pro-preview.php 6 years ago
dynamic-style.php
108 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4
5 function ECS_find_url_type($values){
6 $interest=["url"];
7 $keys=[];
8 if(is_array($values)){
9 foreach ($values as $key => $value){
10 if (isset($value["type"]) && $value["type"] == "url") $keys[]= $key;
11 }
12 }
13 return $keys;
14 }
15 /* peopele keep getting errors from url types */
16 function ECS_remove_url_type(&$array){
17 $keys=ECS_find_url_type($array);
18 foreach($keys as $key){
19 ECS_recursive_unset($array, $key);
20 }
21 }
22
23 function ECS_clean_selector_value($values){
24 $interest=["url"];
25 if(is_array($values)){
26 foreach ($values as $key => $value){
27 if (in_array($key,$interest)) return $value;
28 }
29 }
30 return $values;
31 }
32 function ECS_media_brakepoint($responsive){
33 if (!isset($responsive)) return "";
34 $condition="";
35 $breakpoints = \Elementor\Plugin::$instance->breakpoints->get_breakpoints();
36 foreach($responsive as $direction => $device) {
37 if(!isset($breakpoints[$device])) return ""; //if we don't have a brakepoint for the desktop / tablet etc we don't offer a query
38 $condition = $condition ? $condition : "and "; //in case for future multiple directions
39 $condition = "(".$direction."-width: ".$breakpoints[$device]->get_value()."px) ";
40 }
41 return " @media ".$condition."{";
42 }
43 function ECS_parse_selector($selector,$wrapper,$value,$responsive){
44 $clean_value=ECS_clean_selector_value($value);
45 $before = ECS_media_brakepoint($responsive);// insert media query?
46 $after = $before ? "}" : "";
47 $selector = str_replace("{{WRAPPER}}",$wrapper,$selector);
48 $selector = str_replace(["{{VALUE}}","{{URL}}","{{UNIT}}"],$clean_value,$selector);
49 return $before.$selector.$after;
50 }
51 function ECS_recursive_unset(&$array, $unwanted_key) {
52 unset($array[$unwanted_key]);
53 foreach ($array as &$value) {
54 if (is_array($value)) {
55 ECS_recursive_unset($value, $unwanted_key);
56 }
57 }
58 }
59 // dynamic style for elements
60 function ECS_set_dynamic_style( \Elementor\Element_Base $element ) {
61 global $ecs_render_loop;
62 if(!$ecs_render_loop)
63 return; // only act inside loop
64 list($PostID,$LoopID)=explode(",",$ecs_render_loop);
65 $ElementID = $element->get_ID();
66 $dynamic_settings = $element->get_settings( '__dynamic__' );
67 $all_controls = $element->get_controls();
68
69 $all_controls = isset($all_controls) ? $all_controls : []; $dynamic_settings = isset($dynamic_settings) ? $dynamic_settings : [];
70 $controls = array_intersect_key( $all_controls, $dynamic_settings );
71 ECS_remove_url_type($controls);//we don't need the link options
72 $settings = $element->parse_dynamic_settings( $dynamic_settings, $controls); // @ <- dirty fix for that fugly controls-stack.php Illegal string offset 'url' error
73
74 $ECS_css="";
75 $element_wrapper="#post-{$PostID} .elementor-{$LoopID} .elementor-element.elementor-element-{$ElementID}";
76
77 foreach($controls as $key => $control){
78 if(isset($control["selectors"])){
79 foreach($control["selectors"] as $selector => $rules){
80 if(isset($settings[$key])){
81 $responsive = isset($control["responsive"])? $control["responsive"] : NULL;
82 $ECS_css.= ECS_parse_selector($selector."{".$rules."}",$element_wrapper,$settings[$key],$responsive);
83 }
84 }
85
86 }
87 }
88
89
90 echo $ECS_css ? "<style>".$ECS_css."</style>" :"";
91 /* end custom css*/
92 }
93
94 add_action( 'elementor/frontend/section/before_render', 'ECS_set_dynamic_style' );
95 add_action( 'elementor/frontend/column/before_render', 'ECS_set_dynamic_style' );
96
97 add_action( 'elementor/frontend/container/before_render', 'ECS_set_dynamic_style' );
98
99 add_action( 'elementor/frontend/widget/before_render', 'ECS_set_dynamic_style' );
100
101 //keep track of index
102
103 add_action( 'elementor/frontend/widget/before_render', function ( \Elementor\Element_Base $element ) {
104 global $ecs_index;
105 if ( 'posts' === $element->get_name() || 'archive-posts' === $element->get_name()) {
106 $ecs_index=0;
107 }
108 } );