base-ui.php (3292B)
1 <?php 2 3 namespace Elementor\Core\Schemes; 4 5 if ( ! defined( 'ABSPATH' ) ) { 6 exit; // Exit if accessed directly 7 } 8 9 abstract class Base_UI extends Base { 10 11 /** 12 * System schemes. 13 * 14 * Holds the list of all the system schemes. 15 * 16 * @since 2.8.0 17 * @access private 18 * 19 * @var array System schemes. 20 */ 21 private $_system_schemes; 22 23 /** 24 * Get scheme title. 25 * 26 * Retrieve the scheme title. 27 * 28 * @since 2.8.0 29 * @access public 30 */ 31 abstract public function get_title(); 32 33 /** 34 * Get scheme disabled title. 35 * 36 * Retrieve the scheme disabled title. 37 * 38 * @since 2.8.0 39 * @access public 40 */ 41 abstract public function get_disabled_title(); 42 43 /** 44 * Get scheme titles. 45 * 46 * Retrieve the scheme titles. 47 * 48 * @since 2.8.0 49 * @access public 50 */ 51 abstract public function get_scheme_titles(); 52 53 /** 54 * Print scheme content template. 55 * 56 * Used to generate the HTML in the editor using Underscore JS template. The 57 * variables for the class are available using `data` JS object. 58 * 59 * @since 2.8.0 60 * @access public 61 */ 62 abstract public function print_template_content(); 63 64 /** 65 * Init system schemes. 66 * 67 * Initialize the system schemes. 68 * 69 * @since 2.8.0 70 * @access protected 71 * @abstract 72 */ 73 abstract protected function _init_system_schemes(); 74 75 /** 76 * Get system schemes. 77 * 78 * Retrieve the system schemes. 79 * 80 * @since 1.0.0 81 * @access public 82 * 83 * @return array System schemes. 84 */ 85 final public function get_system_schemes() { 86 if ( null === $this->_system_schemes ) { 87 $this->_system_schemes = $this->_init_system_schemes(); 88 } 89 90 return $this->_system_schemes; 91 } 92 93 /** 94 * Print scheme template. 95 * 96 * Used to generate the scheme template on the editor using Underscore JS 97 * template. 98 * 99 * @since 2.8.0 100 * @access public 101 */ 102 final public function print_template() { 103 ?> 104 <script type="text/template" id="tmpl-elementor-panel-schemes-<?php echo esc_attr( static::get_type() ); ?>"> 105 <div class="elementor-panel-scheme-buttons"> 106 <div class="elementor-panel-scheme-button-wrapper elementor-panel-scheme-reset"> 107 <button class="elementor-button"> 108 <i class="fa fa-undo" aria-hidden="true"></i> 109 <?php echo esc_html__( 'Reset', 'elementor' ); ?> 110 </button> 111 </div> 112 <div class="elementor-panel-scheme-button-wrapper elementor-panel-scheme-discard"> 113 <button class="elementor-button"> 114 <i class="eicon-close" aria-hidden="true"></i> 115 <?php echo esc_html__( 'Discard', 'elementor' ); ?> 116 </button> 117 </div> 118 <div class="elementor-panel-scheme-button-wrapper elementor-panel-scheme-save"> 119 <button class="elementor-button elementor-button-success" disabled><?php echo esc_html__( 'Apply', 'elementor' ); ?></button> 120 </div> 121 </div> 122 <?php $this->print_template_content(); ?> 123 </script> 124 <?php 125 } 126 127 /** 128 * Get scheme. 129 * 130 * Retrieve the scheme. 131 * 132 * @since 2.8.0 133 * @access public 134 * 135 * @return array The scheme. 136 */ 137 public function get_scheme() { 138 $scheme = []; 139 140 $titles = $this->get_scheme_titles(); 141 142 foreach ( $this->get_scheme_value() as $scheme_key => $scheme_value ) { 143 $scheme[ $scheme_key ] = [ 144 'title' => isset( $titles[ $scheme_key ] ) ? $titles[ $scheme_key ] : '', 145 'value' => $scheme_value, 146 ]; 147 } 148 149 return $scheme; 150 } 151 }