responsive.php (3778B)
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 const BREAKPOINT_OPTION_PREFIX = 'viewport_'; 27 28 /** 29 * Default breakpoints. 30 * 31 * Holds the default responsive breakpoints. 32 * 33 * @since 1.0.0 34 * @access private 35 * @static 36 * 37 * @var array Default breakpoints. 38 */ 39 private static $default_breakpoints = [ 40 'xs' => 0, 41 'sm' => 480, 42 'md' => 768, 43 'lg' => 1025, 44 'xl' => 1440, 45 'xxl' => 1600, 46 ]; 47 48 /** 49 * Editable breakpoint keys. 50 * 51 * Holds the editable breakpoint keys. 52 * 53 * @since 1.0.0 54 * @access private 55 * @static 56 * 57 * @var array Editable breakpoint keys. 58 */ 59 private static $editable_breakpoints_keys = [ 60 'md', 61 'lg', 62 ]; 63 64 /** 65 * Get default breakpoints. 66 * 67 * Retrieve the default responsive breakpoints. 68 * 69 * @since 1.0.0 70 * @access public 71 * @static 72 * 73 * @return array Default breakpoints. 74 */ 75 public static function get_default_breakpoints() { 76 return self::$default_breakpoints; 77 } 78 79 /** 80 * Get editable breakpoints. 81 * 82 * Retrieve the editable breakpoints. 83 * 84 * @since 1.0.0 85 * @access public 86 * @static 87 * 88 * @return array Editable breakpoints. 89 */ 90 public static function get_editable_breakpoints() { 91 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0' ); 92 93 return array_intersect_key( self::get_breakpoints(), array_flip( self::$editable_breakpoints_keys ) ); 94 } 95 96 /** 97 * Get breakpoints. 98 * 99 * Retrieve the responsive breakpoints. 100 * 101 * @since 1.0.0 102 * @access public 103 * @static 104 * 105 * @return array Responsive breakpoints. 106 */ 107 public static function get_breakpoints() { 108 return array_reduce( 109 array_keys( self::$default_breakpoints ), function( $new_array, $breakpoint_key ) { 110 if ( ! in_array( $breakpoint_key, self::$editable_breakpoints_keys ) ) { 111 $new_array[ $breakpoint_key ] = self::$default_breakpoints[ $breakpoint_key ]; 112 } else { 113 $saved_option = Plugin::$instance->kits_manager->get_current_settings( self::BREAKPOINT_OPTION_PREFIX . $breakpoint_key ); 114 115 $new_array[ $breakpoint_key ] = $saved_option ? (int) $saved_option : self::$default_breakpoints[ $breakpoint_key ]; 116 } 117 118 return $new_array; 119 }, [] 120 ); 121 } 122 123 /** 124 * @since 2.1.0 125 * @access public 126 * @static 127 */ 128 public static function has_custom_breakpoints() { 129 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Plugin::$instance->breakpoints->has_custom_breakpoints()' ); 130 131 return ! ! array_diff( self::$default_breakpoints, self::get_breakpoints() ); 132 } 133 134 /** 135 * @since 2.1.0 136 * @access public 137 * @static 138 */ 139 public static function get_stylesheet_templates_path() { 140 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Elementor\Core\Breakpoints\Manager::get_stylesheet_templates_path()' ); 141 142 return Breakpoints_Manager::get_stylesheet_templates_path(); 143 } 144 145 /** 146 * @since 2.1.0 147 * @access public 148 * @static 149 */ 150 public static function compile_stylesheet_templates() { 151 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.2.0', 'Elementor\Core\Breakpoints\Manager::compile_stylesheet_templates()' ); 152 153 Breakpoints_Manager::compile_stylesheet_templates(); 154 } 155 }