cl01/wp-content/themes/hester/inc/customizer/controls/info/class-hester-customizer-control-info.php
2025-02-24 12:39:24 +08:00

120 lines
2.6 KiB
PHP
Executable File

<?php
/**
* Hester Customizer info control class.
*
* @package Hester
* @author Peregrine Themes
* @since 1.0.0
*/
/**
* Do not allow direct script access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'Hester_Customizer_Control_Info' ) ) :
/**
* Hester Customizer info control class.
*/
class Hester_Customizer_Control_Info extends Hester_Customizer_Control {
/**
* The control type.
*
* @var string
*/
public $type = 'hester-info';
/**
* Custom URL.
*
* @since 1.0.0
* @var string
*/
public $url = '';
/**
* Link target.
*
* @since 1.0.0
* @var string
*/
public $target = '_blank';
/**
* Button Text.
*
* @since 1.0.0
* @var string
*/
public $btn_text;
/**
* Enqueue control related scripts/styles.
*
* @access public
*/
public function enqueue() {
// Script debug.
$hester_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// Control type.
$hester_type = str_replace( 'hester-', '', $this->type );
/**
* Enqueue control stylesheet
*/
wp_enqueue_style(
'hester-' . $hester_type . '-control-style',
HESTER_THEME_URI . '/inc/customizer/controls/' . $hester_type . '/' . $hester_type . $hester_suffix . '.css',
false,
HESTER_THEME_VERSION,
'all'
);
}
/**
* Refresh the parameters passed to the JavaScript via JSON.
*
* @see WP_Customize_Control::to_json()
*/
public function to_json() {
parent::to_json();
$this->json['url'] = $this->url;
$this->json['target'] = $this->target;
$this->json['btn_text'] = $this->btn_text ?? __( 'Upgrade to pro', 'hester' );
}
/**
* An Underscore (JS) template for this control's content (but not its container).
*
* Class variables for this control class are available in the `data` JS object;
* export custom variables by overriding {@see WP_Customize_Control::to_json()}.
*
* @see WP_Customize_Control::print_template()
*/
protected function content_template() {
?>
<div class="hester-info-wrapper hester-control-wrapper">
<# if ( data.label ) { #>
<span class="hester-control-heading customize-control-title hester-field">{{{ data.label }}}</span>
<# } #>
<# if ( data.description ) { #>
<div class="description customize-control-description hester-field hester-info-description">{{{ data.description }}}</div>
<# } #>
<a href="{{ data.url }}" class="button button-primary" target="{{ data.target }}" rel="noopener noreferrer">{{{ data.btn_text }}} </a>
</div><!-- END .hester-control-wrapper -->
<?php
}
}
endif;