PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / core / frontend / widget-content-render-mode.php

widget-content-render-mode.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at core/frontend/widget-content-render-mode.php

45 lines 842 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Frontend;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 class Widget_Content_Render_Mode {
9
10 const NORMAL = 'normal';
11
12 const MARKDOWN = 'markdown';
13
14 private static $current_mode = self::NORMAL;
15
16 public static function get_current(): string {
17 return self::$current_mode;
18 }
19
20 public static function set_current( string $mode ): void {
21 self::$current_mode = $mode;
22 }
23
24 public static function is( string $mode ): bool {
25 return self::get_current() === $mode;
26 }
27
28 public static function execute_as( string $mode, callable $callback ) {
29 $previous_mode = self::get_current();
30 $should_reset = $previous_mode !== $mode;
31
32 if ( $should_reset ) {
33 self::set_current( $mode );
34 }
35
36 try {
37 return $callback();
38 } finally {
39 if ( $should_reset ) {
40 self::set_current( $previous_mode );
41 }
42 }
43 }
44 }
45