Modularización de GKACHELE SaaS
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize Base control class.
|
||||
*
|
||||
* @package Abiz
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
* @access public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Abiz_Customize_Base_Control
|
||||
*/
|
||||
class Abiz_Customize_Base_Control extends WP_Customize_Control {
|
||||
|
||||
/**
|
||||
* Enqueue scripts all controls.
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
// Main scripts.
|
||||
wp_enqueue_script(
|
||||
'abiz-controls',
|
||||
ABIZ_THEME_CORE_URI . '/customizer/assets/js/controls.js',
|
||||
array(
|
||||
'jquery',
|
||||
'customize-base',
|
||||
'jquery-ui-button',
|
||||
'jquery-ui-sortable',
|
||||
),
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_style( 'abiz-controls', ABIZ_THEME_CORE_URI . '/customizer/assets/css/controls.css' );
|
||||
wp_enqueue_style( 'all-css', ABIZ_THEME_URI . '/assets/css/all.min.css' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
parent::to_json();
|
||||
|
||||
$this->json['default'] = $this->setting->default;
|
||||
if ( isset( $this->default ) ) {
|
||||
$this->json['default'] = $this->default;
|
||||
}
|
||||
|
||||
$this->json['id'] = $this->id;
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = maybe_unserialize( $this->value() );
|
||||
$this->json['choices'] = $this->choices;
|
||||
$this->json['inputAttrs'] = '';
|
||||
|
||||
foreach ( $this->input_attrs as $attr => $value ) {
|
||||
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
$this->json['inputAttrs'] = maybe_serialize( $this->input_attrs() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content is still called, so be sure to override it with an empty function in your subclass as well.
|
||||
*/
|
||||
protected function render_content() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Underscore template for this control.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of translation strings.
|
||||
*
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function l10n() {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
if ( ! class_exists( 'WP_Customize_Control' ) )
|
||||
return NULL;
|
||||
class Abiz_Category_Dropdown_Custom_Control extends WP_Customize_Control
|
||||
{
|
||||
private $cats = false;
|
||||
|
||||
public function __construct($manager, $id, $args = array(), $options = array())
|
||||
{
|
||||
$this->cats = get_categories($options);
|
||||
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the content of the category dropdown
|
||||
*
|
||||
* @return HTML
|
||||
*/
|
||||
public function render_content()
|
||||
{
|
||||
if(!empty($this->cats))
|
||||
{
|
||||
?>
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
foreach ( $this->cats as $cat )
|
||||
{
|
||||
printf('<option value="%s">%s</option>', $cat->term_id, $cat->name);
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Customizer Control: sortable
|
||||
*/
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Sortable control (uses checkboxes).
|
||||
*/
|
||||
class Abiz_Control_Sortable extends Abiz_Customize_Base_Control {
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'abiz-sortable';
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
parent::to_json();
|
||||
|
||||
$this->json['default'] = $this->setting->default;
|
||||
if ( isset( $this->default ) ) {
|
||||
$this->json['default'] = $this->default;
|
||||
}
|
||||
|
||||
$this->json['id'] = $this->id;
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['value'] = maybe_unserialize( $this->value() );
|
||||
$this->json['choices'] = $this->choices;
|
||||
$this->json['inputAttrs'] = '';
|
||||
|
||||
foreach ( $this->input_attrs as $attr => $value ) {
|
||||
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
$this->json['inputAttrs'] = maybe_serialize( $this->input_attrs() );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
<label class='abiz-sortable'>
|
||||
<span class="customize-control-title">
|
||||
{{{ data.label }}}
|
||||
</span>
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<ul class="sortable">
|
||||
<# _.each( data.value, function( choiceID ) { #>
|
||||
<li {{{ data.inputAttrs }}} class='abiz-sortable-item' data-value='{{ choiceID }}'>
|
||||
<i class='dashicons dashicons-menu'></i>
|
||||
<i class="dashicons dashicons-visibility visibility"></i>
|
||||
{{{ data.choices[ choiceID ] }}}
|
||||
</li>
|
||||
<# }); #>
|
||||
<# _.each( data.choices, function( choiceLabel, choiceID ) { #>
|
||||
<# if ( -1 === data.value.indexOf( choiceID ) ) { #>
|
||||
<li {{{ data.inputAttrs }}} class='abiz-sortable-item invisible' data-value='{{ choiceID }}'>
|
||||
<i class='dashicons dashicons-menu'></i>
|
||||
<i class="dashicons dashicons-visibility visibility"></i>
|
||||
{{{ data.choices[ choiceID ] }}}
|
||||
</li>
|
||||
<# } #>
|
||||
<# }); #>
|
||||
</ul>
|
||||
</label>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the control's content.
|
||||
*
|
||||
* @see WP_Customize_Control::render_content()
|
||||
*/
|
||||
protected function render_content() {}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Customize Toggle control class.
|
||||
*
|
||||
* @package abiz
|
||||
*
|
||||
* @see WP_Customize_Control
|
||||
* @access public
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Abiz_Customize_Toggle_Control
|
||||
*/
|
||||
class Abiz_Customize_Toggle_Control extends Abiz_Customize_Base_Control {
|
||||
|
||||
/**
|
||||
* Customize control type.
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'abiz-toggle';
|
||||
|
||||
/**
|
||||
* Renders the Underscore template for this control.
|
||||
*
|
||||
* @see WP_Customize_Control::print_template()
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function content_template() {
|
||||
?>
|
||||
|
||||
<label for="toggle_{{ data.id }}">
|
||||
<span class="customize-control-title">
|
||||
{{{ data.label }}}
|
||||
</span>
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
<input class="screen-reader-text" {{{ data.inputAttrs }}} name="toggle_{{ data.id }}"
|
||||
id="toggle_{{ data.id }}" type="checkbox" value="{{ data.value }}" {{{ data.link }}}<# if ( true === data.value ) { #> checked<# } #> hidden />
|
||||
<span class="switch"></span>
|
||||
</label>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render content is still called, so be sure to override it with an empty function in your subclass as well.
|
||||
*/
|
||||
protected function render_content() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* Upgrade to pro options
|
||||
*/
|
||||
|
||||
function abiz_upgrade_pro_options( $wp_customize ) {
|
||||
class Abiz_WP_Button_Customize_Control extends WP_Customize_Control {
|
||||
public $type = 'abiz_upgrade_premium';
|
||||
|
||||
function render_content() {
|
||||
?>
|
||||
<div class="premium-info">
|
||||
<ul>
|
||||
<!--li><a class="documentation" href="#" target="_blank"><i class="dashicons dashicons-visibility"></i><?php //_e( 'View Documentation','abiz' ); ?> </a></li-->
|
||||
|
||||
<li><a class="support" href="https://themesdaddy.com/support/" target="_blank"><i class="dashicons dashicons-lightbulb"></i><?php _e( 'Need Support ?','abiz' ); ?> </a></li>
|
||||
|
||||
<li><a class="free-pro" href="https://demo.themesdaddy.com/abiz-pro/" target="_blank"><i class="dashicons dashicons-visibility"></i><?php _e( 'Premium Demo','abiz' ); ?> </a></li>
|
||||
|
||||
<li><a class="upgrade-to-pro" href="https://themesdaddy.com/themes/abiz-pro/" target="_blank"><i class="dashicons dashicons-update-alt"></i><?php _e( 'Upgrade to Pro','abiz' ); ?> </a></li>
|
||||
|
||||
<li><a class="show-love" href="https://wordpress.org/support/theme/abiz/reviews/#new-post" target="_blank"><i class="dashicons dashicons-smiley"></i><?php _e( 'Share a Good Review','abiz' ); ?> </a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'premium_info_buttons',
|
||||
array(
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'abiz_sanitize_text',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control( new Abiz_WP_Button_Customize_Control( $wp_customize, 'premium_info_buttons', array(
|
||||
'section' => 'abiz_upgrade_premium',
|
||||
))
|
||||
);
|
||||
}
|
||||
add_action( 'customize_register', 'abiz_upgrade_pro_options' );
|
||||
Reference in New Issue
Block a user