| 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 |
|