| 1 |
<?php |
| 2 |
namespace Elementor\Core\Responsive; |
| 3 |
|
| 4 |
use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; |
| 5 |
use Elementor\Modules\DevTools\Deprecation; |
| 6 |
use Elementor\Plugin; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Elementor responsive. |
| 14 |
* |
| 15 |
* Elementor responsive handler class is responsible for setting up Elementor |
| 16 |
* responsive breakpoints. |
| 17 |
* |
| 18 |
* @since 1.0.0 |
| 19 |
* @deprecated 3.2.0 |
| 20 |
*/ |
| 21 |
class Responsive { |
| 22 |
|
| 23 |
/** |
| 24 |
* The Elementor breakpoint prefix. |
| 25 |
* |
| 26 |
* @deprecated 3.2.0 |
| 27 |
*/ |
| 28 |
const BREAKPOINT_OPTION_PREFIX = 'viewport_'; |
| 29 |
|
| 30 |
/** |
| 31 |
* Default breakpoints. |
| 32 |
* |
| 33 |
* Holds the default responsive breakpoints. |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* @deprecated 3.2.0 |
| 37 |
* @access private |
| 38 |
* @static |
| 39 |
* |
| 40 |
* @var array Default breakpoints. |
| 41 |
*/ |
| 42 |
private static $default_breakpoints = [ |
| 43 |
'xs' => 0, |
| 44 |
'sm' => 480, |
| 45 |
'md' => 768, |
| 46 |
'lg' => 1025, |
| 47 |
'xl' => 1440, |
| 48 |
'xxl' => 1600, |
| 49 |
]; |
| 50 |
|
| 51 |
/** |
| 52 |
* Editable breakpoint keys. |
| 53 |
* |
| 54 |
* Holds the editable breakpoint keys. |
| 55 |
* |
| 56 |
* @since 1.0.0 |
| 57 |
* @deprecated 3.2.0 |
| 58 |
* @access private |
| 59 |
* @static |
| 60 |
* |
| 61 |
* @var array Editable breakpoint keys. |
| 62 |
*/ |
| 63 |
private static $editable_breakpoints_keys = [ |
| 64 |
'md', |
| 65 |
'lg', |
| 66 |
]; |
| 67 |
|
| 68 |
/** |
| 69 |
* Get default breakpoints. |
| 70 |
* |
| 71 |
* Retrieve the default responsive breakpoints. |
| 72 |
* |
| 73 |
* @since 1.0.0 |
| 74 |
* @deprecated 3.2.0 Use `Elementor\Core\Breakpoints\Manager::get_default_config()` instead. |
| 75 |
* @access public |
| 76 |
* @static |
| 77 |
* |
| 78 |
* @return array Default breakpoints. |
| 79 |
*/ |
| 80 |
public static function get_default_breakpoints() { |
| 81 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Elementor\Core\Breakpoints\Manager::get_default_config()' ); |
| 82 |
|
| 83 |
return self::$default_breakpoints; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Get editable breakpoints. |
| 88 |
* |
| 89 |
* Retrieve the editable breakpoints. |
| 90 |
* |
| 91 |
* @since 1.0.0 |
| 92 |
* @deprecated 3.2.0 |
| 93 |
* @access public |
| 94 |
* @static |
| 95 |
* |
| 96 |
* @return array Editable breakpoints. |
| 97 |
*/ |
| 98 |
public static function get_editable_breakpoints() { |
| 99 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0' ); |
| 100 |
|
| 101 |
return array_intersect_key( self::get_breakpoints(), array_flip( self::$editable_breakpoints_keys ) ); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Get breakpoints. |
| 106 |
* |
| 107 |
* Retrieve the responsive breakpoints. |
| 108 |
* |
| 109 |
* @since 1.0.0 |
| 110 |
* @deprecated 3.2.0 |
| 111 |
* @access public |
| 112 |
* @static |
| 113 |
* |
| 114 |
* @return array Responsive breakpoints. |
| 115 |
*/ |
| 116 |
public static function get_breakpoints() { |
| 117 |
return array_reduce( |
| 118 |
array_keys( self::$default_breakpoints ), function( $new_array, $breakpoint_key ) { |
| 119 |
if ( ! in_array( $breakpoint_key, self::$editable_breakpoints_keys, true ) ) { |
| 120 |
$new_array[ $breakpoint_key ] = self::$default_breakpoints[ $breakpoint_key ]; |
| 121 |
} else { |
| 122 |
$saved_option = Plugin::$instance->kits_manager->get_current_settings( self::BREAKPOINT_OPTION_PREFIX . $breakpoint_key ); |
| 123 |
|
| 124 |
$new_array[ $breakpoint_key ] = $saved_option ? (int) $saved_option : self::$default_breakpoints[ $breakpoint_key ]; |
| 125 |
} |
| 126 |
|
| 127 |
return $new_array; |
| 128 |
}, [] |
| 129 |
); |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* @since 2.1.0 |
| 134 |
* @deprecated 3.2.0 Use `Plugin::$instance->breakpoints->has_custom_breakpoints()` instead. |
| 135 |
* @access public |
| 136 |
* @static |
| 137 |
*/ |
| 138 |
public static function has_custom_breakpoints() { |
| 139 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Plugin::$instance->breakpoints->has_custom_breakpoints()' ); |
| 140 |
|
| 141 |
return (bool) array_diff( self::$default_breakpoints, self::get_breakpoints() ); |
| 142 |
} |
| 143 |
|
| 144 |
/** |
| 145 |
* @since 2.1.0 |
| 146 |
* @deprecated 3.2.0 Use `Elementor\Core\Breakpoints\Manager::get_stylesheet_templates_path()` instead. |
| 147 |
* @access public |
| 148 |
* @static |
| 149 |
*/ |
| 150 |
public static function get_stylesheet_templates_path() { |
| 151 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Elementor\Core\Breakpoints\Manager::get_stylesheet_templates_path()' ); |
| 152 |
|
| 153 |
return Breakpoints_Manager::get_stylesheet_templates_path(); |
| 154 |
} |
| 155 |
|
| 156 |
/** |
| 157 |
* @since 2.1.0 |
| 158 |
* @deprecated 3.2.0 Use `Elementor\Core\Breakpoints\Manager::compile_stylesheet_templates()` instead. |
| 159 |
* @access public |
| 160 |
* @static |
| 161 |
*/ |
| 162 |
public static function compile_stylesheet_templates() { |
| 163 |
Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Elementor\Core\Breakpoints\Manager::compile_stylesheet_templates()' ); |
| 164 |
|
| 165 |
Breakpoints_Manager::compile_stylesheet_templates(); |
| 166 |
} |
| 167 |
} |
| 168 |
|