PluginProbe
Hello Plus / 1.7.7
Hello Plus v1.7.7
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / classes / widget-utils.php

widget-utils.php in Hello Plus 1.7.7, at classes/widget-utils.php

81 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HelloPlus\Classes;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 use HelloPlus\Includes\Utils as Theme_Utils;
10
11 class Widget_Utils {
12
13 public static function get_configured_breakpoints(): array {
14 $active_devices = Theme_Utils::elementor()->breakpoints->get_active_devices_list( [ 'reverse' => true ] );
15 $active_breakpoint_instances = Theme_Utils::elementor()->breakpoints->get_active_breakpoints();
16
17 $devices_options = [];
18
19 foreach ( $active_devices as $device_key ) {
20 $device_label = 'desktop' === $device_key ? esc_html__( 'Desktop', 'hello-plus' ) : $active_breakpoint_instances[ $device_key ]->get_label();
21 $devices_options[ $device_key ] = $device_label;
22 }
23
24 return [
25 'active_devices' => $active_devices,
26 'devices_options' => $devices_options,
27 ];
28 }
29
30 public static function maybe_render_text_html(
31 \Elementor\Widget_Base $context,
32 string $render_key,
33 string $css_class,
34 string $settings_text,
35 string $settings_tag = 'p'
36 ): void {
37 if ( '' === $settings_text ) {
38 return;
39 }
40
41 $context->add_render_attribute( $render_key, 'class', $css_class );
42
43 $element_html = sprintf(
44 '<%1$s %2$s>%3$s</%1$s>',
45 \Elementor\Utils::validate_html_tag( $settings_tag ),
46 $context->get_render_attribute_string( $render_key ),
47 $settings_text,
48 );
49
50 echo wp_kses_post( $element_html );
51 }
52
53 public static function get_available_menus(): array {
54 $menus = wp_get_nav_menus();
55
56 $options = [];
57
58 foreach ( $menus as $menu ) {
59 $options[ $menu->slug ] = $menu->name;
60 }
61
62 return $options;
63 }
64
65 public static function get_empty_menus(): array {
66 $menus = wp_get_nav_menus();
67
68 $options = [];
69
70 foreach ( $menus as $menu ) {
71 $menu_items = wp_get_nav_menu_items( $menu->term_id );
72
73 if ( empty( $menu_items ) ) {
74 $options[ $menu->term_id ] = $menu->slug;
75 }
76 }
77
78 return $options;
79 }
80 }
81