PluginProbe
Enter Addons – Ultimate Template Builder for Elementor / 2.2.4
Enter Addons – Ultimate Template Builder for Elementor v2.2.4
trunk 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4
enteraddons / classes / Helper.php

Helper.php in Enter Addons – Ultimate Template Builder for Elementor 2.2.4, at classes/Helper.php

310 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Enteraddons\Classes;
3
4 /**
5 * Enteraddons helper class
6 *
7 * @package Enteraddons
8 * @author ThemeLooks
9 * @copyright 2022 ThemeLooks
10 * @license GPL-2.0-or-later
11 *
12 *
13 */
14
15 class Helper {
16
17 public static function ratingStar( $rating, $echo = true ) {
18
19 $starRating = '';
20
21 $j = 0;
22
23 for( $i = 0; $i <= 4; $i++ ) {
24 $j++;
25
26 if( $rating >= $j || $rating == '5' ) {
27 $starRating .= '<i class="fas fa-star"></i>';
28 }elseif( $rating < $j && $rating > $i ) {
29 $starRating .= '<i class="fas fa-star-half-alt"></i>';
30 } else {
31 $starRating .= '<i class="far fa-star"></i>';
32 }
33
34 }
35 //
36 if( $echo == true ) {
37 echo wp_kses( $starRating, [ 'i' => ['class' => [] ] ] );
38 } else {
39 return $starRating;
40 }
41
42 }
43
44 public static function includeCurrentPathFile( $path, $fileName ) {
45
46 if( !is_array( $fileName ) ) {
47 require_once( plugin_dir_path( $path ).$fileName );
48 } else {
49 foreach( $fileName as $name ) {
50 require_once( plugin_dir_path( $path ).$name );
51 }
52 }
53 }
54
55 public static function getElementorIcon( $optionValue ) {
56 if( empty( $optionValue ) ) {
57 return;
58 }
59 //
60 if( 'svg' != $optionValue['library'] ) {
61 if( !empty( $optionValue['value'] ) ) {
62 return '<i class="'.esc_attr( $optionValue['value'] ).'" /></i>';
63 }
64 } else {
65 return '<img src="'.esc_url( $optionValue['value']['url'] ).'" />';
66 }
67
68 }
69
70 public static function getElementorLinkHandler( $url, $innerData, $class= 'anchor--link' ) {
71 //
72 if( !empty( $url['url'] ) ) {
73 $target = '_self';
74 if( !empty( $url['is_external'] ) && $url['is_external'] == 'on' ) {
75 $target = '_blank';
76 }
77
78 return '<a class="'.esc_attr($class).'" href="'.esc_url( $url['url'] ).'" target="'.esc_attr( $target ).'">'.self::allowFormattingTagHtml( $innerData ).'</a>';
79 }
80 }
81 /**
82 * allowFormattingTagHtml
83 *
84 * @param string $text
85 * @return void
86 */
87 public static function allowFormattingTagHtml( $text = '' ) {
88
89 if( empty( $text ) ) {
90 return;
91 }
92
93 $allowHtml = [
94 'span' => ['class' => [],'style' => []],
95 'b' => [],
96 'strong' => [],
97 'br' => [],
98 'i' => ['class' => []],
99 'svg' => [],
100 'small' => [],
101 'img' => ['src'=>[],'class' => []]
102 ];
103
104 return wp_kses( $text, $allowHtml );
105 }
106 /**
107 * currency list
108 * @return array
109 */
110 public static function getCurrencyList() {
111 return [
112 '' => esc_html__( 'None', 'enteraddons' ),
113 'baht' => '&#3647; ' . esc_html__( 'Baht', 'enteraddons' ),
114 'bdt' => '&#2547; ' . esc_html__( 'BD Taka', 'enteraddons' ),
115 'dollar' => '&#36; ' . esc_html__( 'Dollar', 'enteraddons' ),
116 'euro' => '&#128; ' . esc_html__( 'Euro', 'enteraddons' ),
117 'franc' => '&#8355; ' . esc_html__( 'Franc', 'enteraddons' ),
118 'guilder' => '&fnof; ' . esc_html__( 'Guilder', 'enteraddons' ),
119 'indian_rupee' => '&#8377; ' . esc_html__( 'Rupee (Indian)', 'enteraddons' ),
120 'krona' => 'kr ' . esc_html__( 'Krona', 'enteraddons' ),
121 'lira' => '&#8356; ' . esc_html__( 'Lira', 'enteraddons' ),
122 'peseta' => '&#8359 ' . esc_html__( 'Peseta', 'enteraddons' ),
123 'peso' => '&#8369; ' . esc_html__( 'Peso', 'enteraddons' ),
124 'pound' => '&#163; ' . esc_html__( 'Pound Sterling', 'enteraddons' ),
125 'real' => 'R$ ' . esc_html__( 'Real', 'enteraddons' ),
126 'ruble' => '&#8381; ' . esc_html__( 'Ruble', 'enteraddons' ),
127 'rupee' => '&#8360; ' . esc_html__( 'Rupee', 'enteraddons' ),
128 'shekel' => '&#8362; ' . esc_html__( 'Shekel', 'enteraddons' ),
129 'yen' => '&#165; ' . esc_html__( 'Yen/Yuan', 'enteraddons' ),
130 'won' => '&#8361; ' . esc_html__( 'Won', 'enteraddons' ),
131 'custom' => esc_html__( 'Custom', 'enteraddons' ),
132 ];
133 }
134
135 public static function getCurrencySymbol( $symbol_code ) {
136
137 $symbolList = [
138 'baht' => '&#3647;',
139 'bdt' => '&#2547;',
140 'dollar' => '&#36;',
141 'euro' => '&#128;',
142 'franc' => '&#8355;',
143 'guilder' => '&fnof;',
144 'indian_rupee' => '&#8377;',
145 'krona' => 'kr',
146 'lira' => '&#8356;',
147 'peseta' => '&#8359',
148 'peso' => '&#8369;',
149 'pound' => '&#163;',
150 'real' => 'R$',
151 'ruble' => '&#8381;',
152 'rupee' => '&#8360;',
153 'shekel' => '&#8362;',
154 'yen' => '&#165;',
155 'won' => '&#8361;',
156 ];
157
158 return !empty( $symbolList[$symbol_code] ) ? $symbolList[$symbol_code] : '';
159
160 }
161 /**
162 * enteraddons_elementor
163 * @return void
164 */
165 public static function enteraddons_elementor() {
166 return \Elementor\Plugin::instance();
167 }
168 /**
169 * is_elementor_edit_mode
170 * @return boolean
171 */
172 public static function is_elementor_edit_mode() {
173 $elementor = self::enteraddons_elementor();
174 return $elementor->editor->is_edit_mode() || $elementor->preview->is_preview_mode() || is_preview();
175 }
176
177 /**
178 *
179 * Check WooCommerce plugin activities
180 *
181 * @return string
182 *
183 */
184 public static function is_woo_activated() {
185 $isWoo = false;
186 if( class_exists( 'woocommerce' ) ) {
187 $isWoo = true;
188 }
189 return $isWoo;
190 }
191 /**
192 * Change editor js folder permissions mode to work properly
193 * @return void
194 *
195 */
196 public static function change_permissions_mode() {
197
198 $dir = ENTERADDONS_DIR_CORE.'libs/editor/js';
199 if( !chmod($dir,0777) ) {
200 chmod($dir,0777);
201 }
202 }
203
204 /**
205 * [elementor_content_display description]
206 * @param [type] $contentId [description]
207 * @return [type] [description]
208 */
209 public static function elementor_content_display( $contentId = '' ) {
210
211 if( !self::is_elementor_edit_mode() ) {
212 global $ea_cache_dir_url, $ea_cache_file_prefix;
213 //
214 $handle = $ea_cache_file_prefix.$contentId;
215 $url = $ea_cache_dir_url.$handle.'.css';
216 $version = ENTERADDONS_VERSION.'.'.get_post_modified_time( 'U', false, $contentId, false );
217
218 // Enqueue Header Widget Css for Front-End
219 wp_enqueue_style( $handle, $url, array('elementor-frontend'), $version, false );
220 }
221 //wp_enqueue_style( 'enteraddons-'.$contentId );
222 return \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $contentId );
223 }
224
225 /**
226 * [menu_list description]
227 * @return [type] [description]
228 */
229 public static function menu_list(){
230 $siteMenu = wp_get_nav_menus();
231 $getMenu = [];
232 $getMenu[''] = esc_html__( 'Select A Menu','enteraddons' );
233 foreach( $siteMenu as $menu ) {
234 $getMenu[ $menu->slug ] = $menu->name;
235 }
236 return $getMenu;
237 }
238
239 public static function is_pro_active() {
240 return apply_filters( 'enteraddons_is_pro', false );
241 }
242
243 public static function getPages() {
244 return get_pages();
245 }
246
247 public static function getPagesIdTitle() {
248 $pages = self::getPages();
249 $getList = [];
250 if( !empty( $pages ) ) {
251 foreach( $pages as $page ) {
252 $getList[$page->ID] = $page->post_title;
253 }
254 }
255 return $getList;
256 }
257
258 public static function checkPhpV81() {
259 $b = version_compare( ENTERADDONS_CURRENT_PHPVERSION, '8.0.99', '>' );
260 $l = version_compare( ENTERADDONS_CURRENT_PHPVERSION, '8.2', '<' );
261
262 if( $b && $l ) {
263 return true;
264 } else {
265 return false;
266 }
267 }
268
269 public static function getElementorTemplates() {
270
271 $args = array(
272 'post_type' => 'elementor_library',
273 'numberposts' => '-1',
274 'post_status' => 'publish'
275 );
276
277 $elementor_templates = get_posts($args);
278 $templates = [];
279
280 foreach ( $elementor_templates as $template ) {
281 $templates[$template->ID] = $template->post_title;
282 }
283
284 return $templates;
285 }
286
287 public static function versionType() {
288 return self::is_pro_active() ? 'PRO' : 'LITE';
289 }
290
291 public static function ea_brand_icon_html() {
292 return '<i style="float: right;font-size: 16px;color: #E82A5C;" class="entera entera-ea-fev"></i>';
293 }
294
295 public static function ea_post_categoris() {
296
297 $terms = get_terms( [ 'taxonomy' => 'category', 'hide_empty' => true ] );
298
299 $getTerms = [];
300 if( !empty( $terms ) ) {
301 foreach( $terms as $term ) {
302 $getTerms[$term->term_id] = $term->name;
303 }
304 }
305
306 return $getTerms;
307
308 }
309
310 } // Class End