File "custom-controls.php"
Full Path: /home/pumpbmko/public_html/themes/pure-portfolio/inc/customizer/custom-controls/custom-controls.php
File size: 6.12 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Customizer Custom Controls
*/
if ( class_exists( 'WP_Customize_Control' ) ) {
/**
* Toggle Switch Custom Control
*/
class Pure_Portfolio_Toggle_Switch_Custom_Control extends WP_Customize_Control {
/**
* The type of control being rendered
*/
public $type = 'toggle_switch';
/**
* Render the control in the customizer
*/
public function render_content() {
?>
<div class="toggle-switch-control">
<div class="toggle-switch">
<input type="checkbox" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" class="toggle-switch-checkbox" value="<?php echo esc_attr( $this->value() ); ?>"
<?php
$this->link();
checked( $this->value() );
?>
>
<label class="toggle-switch-label" for="<?php echo esc_attr( $this->id ); ?>">
<span class="toggle-switch-inner"></span>
<span class="toggle-switch-switch"></span>
</label>
</div>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php if ( ! empty( $this->description ) ) { ?>
<span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
<?php } ?>
</div>
<?php
}
}
/**
* Sortable Repeater Custom Control
*/
class Pure_Portfolio_Sortable_Repeater_Custom_Control extends WP_Customize_Control {
/**
* The type of control being rendered
*/
public $type = 'sortable_repeater';
/**
* Button labels
*/
public $button_labels = array();
/**
* Constructor
*/
public function __construct( $manager, $id, $args = array(), $options = array() ) {
parent::__construct( $manager, $id, $args );
// Merge the passed button labels with our default labels
$this->button_labels = wp_parse_args(
$this->button_labels,
array(
'add' => __( 'Add', 'pure-portfolio' ),
)
);
}
/**
* Render the control in the customizer
*/
public function render_content() {
?>
<div class="sortable_repeater_control">
<?php if ( ! empty( $this->label ) ) { ?>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php } ?>
<?php if ( ! empty( $this->description ) ) { ?>
<span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
<?php } ?>
<input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize-control-sortable-repeater" <?php $this->link(); ?> />
<div class="sortable_repeater sortable">
<div class="repeater">
<input type="text" value="" class="repeater-input" placeholder="https://" /><span class="dashicons dashicons-sort"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a>
</div>
</div>
<button class="button customize-control-sortable-repeater-add" type="button"><?php echo esc_html( $this->button_labels['add'] ); ?></button>
</div>
<?php
}
}
/**
* Multi Input field
*/
class Pure_Portfolio_Multi_Input_Custom_control extends WP_Customize_Control {
public $type = 'multi_input';
public function render_content() {
?>
<label class="customize_multi_input">
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<p><?php echo wp_kses_post( $this->description ); ?></p>
<input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize_multi_value_field" data-customize-setting-link="<?php echo esc_attr( $this->id ); ?>"/>
<div class="customize_multi_fields ascendoor-multi-fields">
<div class="set">
<input type="text" value="" class="customize_multi_single_field"/>
<a href="#" class="customize_multi_remove_field dashicons dashicons-no-alt">X</a>
</div>
</div>
<a href="#" class="button button-primary customize_multi_add_field"><?php esc_html_e( 'Add More', 'pure-portfolio' ); ?></a>
</label>
<?php
}
}
/**
* Horizontal Line Control
*/
class Pure_Portfolio_Customize_Horizontal_Line extends WP_Customize_Control {
/**
* Control Type
*/
public $type = 'hr';
/**
* Render Settings
*/
public function render_content() {
?>
<div>
<hr style="border: 1px dotted #72777c;" />
</div>
<?php
}
}
}
if ( class_exists( 'WP_Customize_Section' ) ) {
/**
* Upsell section
*/
class Pure_Portfolio_Upsell_Section extends WP_Customize_Section {
/**
* The type of control being rendered
*/
public $type = 'pure-portfolio-upsell';
/**
* The Upsell button text
*/
public $button_text = '';
/**
* The Upsell URL
*/
public $url = '';
/**
* The background color for the control
*/
public $background_color = '';
/**
* The text color for the control
*/
public $text_color = '';
/**
* Render the section, and the controls that have been added to it.
*/
protected function render() {
$background_color = ! empty( $this->background_color ) ? esc_attr( $this->background_color ) : '#fff';
$text_color = ! empty( $this->text_color ) ? esc_attr( $this->text_color ) : '#50575e';
?>
<li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="pure_portfolio_upsell_section accordion-section control-section control-section-<?php echo esc_attr( $this->id ); ?> cannot-expand">
<h3 class="accordion-section-title" style="color:<?php echo esc_attr( $text_color ); ?>;background:<?php echo esc_attr( $background_color ); ?>;border-left-color:<?php echo esc_attr( $background_color ); ?>;">
<?php echo esc_html( $this->title ); ?>
<a href="<?php echo esc_url( $this->url ); ?>" class="button button-secondary alignright" target="_blank" style="margin-top: -4px;"><?php echo esc_html( $this->button_text ); ?></a>
</h3>
</li>
<?php
}
}
}