did some sniff sniff
This commit is contained in:
@@ -8,19 +8,19 @@
|
||||
add_action( 'customize_register', 'sophia_after_dark_register_custom_controls' );
|
||||
|
||||
if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
/**
|
||||
* Register Custom Controls
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function sophia_after_dark_register_custom_controls( $wp_customize ) {
|
||||
|
||||
if ( ! class_exists( 'sophia_after_dark_Control_Toggle' ) ) {
|
||||
/**
|
||||
* Register Custom Controls
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function sophia_after_dark_register_custom_controls( $wp_customize ) {
|
||||
|
||||
if ( ! class_exists( 'sophia_after_dark_Control_Toggle' ) ) {
|
||||
/**
|
||||
* Toggle control (modified checkbox)
|
||||
*/
|
||||
class Sophia_After_Dark_Control_Toggle extends WP_Customize_Control {
|
||||
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
@@ -28,29 +28,29 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'sad-toggle';
|
||||
|
||||
|
||||
public $tooltip = '';
|
||||
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
|
||||
if ( isset( $this->default ) ) {
|
||||
$this->json['default'] = $this->default;
|
||||
} else{
|
||||
} else {
|
||||
$this->json['default'] = $this->setting->default;
|
||||
}
|
||||
|
||||
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['id'] = $this->id;
|
||||
$this->json['tooltip'] = $this->tooltip;
|
||||
|
||||
|
||||
$this->json['inputAttrs'] = '';
|
||||
foreach ( $this->input_attrs as $attr => $value ) {
|
||||
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function content_template() {
|
||||
?>
|
||||
<# if ( data.tooltip ) { #>
|
||||
@@ -70,13 +70,13 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
}
|
||||
}
|
||||
} //Ends sophia_after_dark_Control_Toggle
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
if ( ! class_exists( 'sophia_after_dark_Control_Radio_Image' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Radio Image control (modified radio).
|
||||
*/
|
||||
*/
|
||||
class Sophia_After_Dark_Control_Radio_Image extends WP_Customize_Control {
|
||||
|
||||
/**
|
||||
@@ -86,30 +86,30 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'sad-radio-image';
|
||||
|
||||
|
||||
public $tooltip = '';
|
||||
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
|
||||
if ( isset( $this->default ) ) {
|
||||
$this->json['default'] = $this->default;
|
||||
} else {
|
||||
$this->json['default'] = $this->setting->default;
|
||||
}
|
||||
|
||||
|
||||
$this->json['value'] = $this->value();
|
||||
$this->json['link'] = $this->get_link();
|
||||
$this->json['id'] = $this->id;
|
||||
$this->json['tooltip'] = $this->tooltip;
|
||||
$this->json['choices'] = $this->choices;
|
||||
|
||||
|
||||
$this->json['inputAttrs'] = '';
|
||||
foreach ( $this->input_attrs as $attr => $value ) {
|
||||
$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function content_template() {
|
||||
?>
|
||||
|
||||
@@ -141,14 +141,14 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
if ( ! class_exists( 'sophia_after_dark_Control_Repeater' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Repeater control
|
||||
*/
|
||||
*/
|
||||
class Sophia_After_Dark_Control_Repeater extends WP_Customize_Control {
|
||||
|
||||
|
||||
/**
|
||||
* The control type.
|
||||
*
|
||||
@@ -156,11 +156,11 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'sad-repeater';
|
||||
|
||||
|
||||
public $sophia_after_dark_box_label = '';
|
||||
|
||||
|
||||
public $sophia_after_dark_box_add_control = '';
|
||||
|
||||
|
||||
/**
|
||||
* The fields that each container row will contain.
|
||||
*
|
||||
@@ -168,26 +168,26 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
* @var array
|
||||
*/
|
||||
public $fields = array();
|
||||
|
||||
|
||||
/**
|
||||
* Repeater drag and drop controller
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array(), $fields = array() ) {
|
||||
|
||||
$this->fields = $fields;
|
||||
$this->sophia_after_dark_box_label = $args['sophia_after_dark_box_label_text'] ;
|
||||
|
||||
$this->fields = $fields;
|
||||
$this->sophia_after_dark_box_label = $args['sophia_after_dark_box_label_text'];
|
||||
$this->sophia_after_dark_box_add_control = $args['sophia_after_dark_box_add_control_text'];
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
|
||||
protected function render_content() {
|
||||
|
||||
$values = json_decode( $this->value() );
|
||||
|
||||
$values = json_decode( $this->value() );
|
||||
$repeater_id = $this->id;
|
||||
$field_count = count( $values );
|
||||
?>
|
||||
?>
|
||||
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
|
||||
|
||||
<?php if ( $this->description ) { ?>
|
||||
@@ -201,121 +201,120 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
</ul>
|
||||
|
||||
<input type="hidden" <?php $this->link(); ?> class="sad-repeater-collector" value="<?php echo esc_attr( $this->value() ); ?>" />
|
||||
<input type="hidden" name="<?php echo esc_attr( $repeater_id ).'_count'; ?>" class="field-count" value="<?php echo absint( $field_count ); ?>">
|
||||
<input type="hidden" name="<?php echo esc_attr( $repeater_id ) . '_count'; ?>" class="field-count" value="<?php echo absint( $field_count ); ?>">
|
||||
<input type="hidden" name="field_limit" class="field-limit" value="6">
|
||||
<button type="button" class="button sad-repeater-add-control-field"><?php echo esc_html( $this->sophia_after_dark_box_add_control ); ?></button>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
private function sophia_after_dark_get_fields() {
|
||||
$fields = $this->fields;
|
||||
$values = json_decode( $this->value() );
|
||||
|
||||
|
||||
if ( is_array( $values ) ) {
|
||||
foreach( $values as $value ) {
|
||||
?>
|
||||
foreach ( $values as $value ) {
|
||||
?>
|
||||
<li class="sad-repeater-field-control">
|
||||
<h3 class="sad-repeater-field-title"><?php echo esc_html( $this->sophia_after_dark_box_label ); ?></h3>
|
||||
<div class="sad-repeater-fields">
|
||||
<?php
|
||||
<?php
|
||||
foreach ( $fields as $key => $field ) {
|
||||
$class = isset( $field['class'] ) ? $field['class'] : '';
|
||||
?>
|
||||
<div class="sad-repeater-field sad-repeater-type-<?php echo esc_attr( $field['type'] ).' '.esc_attr( $class ); ?>">
|
||||
$class = isset( $field['class'] ) ? $field['class'] : '';
|
||||
?>
|
||||
<div class="sad-repeater-field sad-repeater-type-<?php echo esc_attr( $field['type'] ) . ' ' . esc_attr( $class ); ?>">
|
||||
|
||||
<?php
|
||||
$label = isset( $field['label'] ) ? $field['label'] : '';
|
||||
<?php
|
||||
$label = isset( $field['label'] ) ? $field['label'] : '';
|
||||
$description = isset( $field['description'] ) ? $field['description'] : '';
|
||||
if ( $field['type'] != 'checkbox' ) {
|
||||
?>
|
||||
if ( $field['type'] != 'checkbox' ) {
|
||||
?>
|
||||
<span class="customize-control-title"><?php echo esc_html( $label ); ?></span>
|
||||
<span class="description customize-control-description"><?php echo esc_html( $description ); ?></span>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
$new_value = isset( $value->$key ) ? $value->$key : '';
|
||||
$default = isset( $field['default'] ) ? $field['default'] : '';
|
||||
|
||||
$default = isset( $field['default'] ) ? $field['default'] : '';
|
||||
|
||||
switch ( $field['type'] ) {
|
||||
/**
|
||||
* Text field
|
||||
*/
|
||||
case 'text':
|
||||
echo '<input data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'" type="text" value="'.esc_attr( $new_value ).'"/>';
|
||||
echo '<input data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '" type="text" value="' . esc_attr( $new_value ) . '"/>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Textarea field
|
||||
*/
|
||||
case 'textarea':
|
||||
echo '<textarea data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'">'.esc_attr( $new_value ).'</textarea>';
|
||||
echo '<textarea data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '">' . esc_attr( $new_value ) . '</textarea>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* URL field
|
||||
*/
|
||||
case 'url':
|
||||
echo '<input data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'" type="text" value="'.esc_url( $new_value ).'"/>';
|
||||
echo '<input data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '" type="text" value="' . esc_url( $new_value ) . '"/>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Icon field
|
||||
*/
|
||||
case 'icon':
|
||||
$sophia_after_dark_fork_awesome_icon_array = sophia_after_dark_fork_awesome_icon_array();
|
||||
echo '<div class="sad-repeater-selected-icon"><i class="'.esc_attr( $new_value ).'"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
|
||||
echo '<div class="sad-repeater-selected-icon"><i class="' . esc_attr( $new_value ) . '"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
|
||||
foreach ( $sophia_after_dark_fork_awesome_icon_array as $sophia_after_dark_fork_awesome_icon ) {
|
||||
$icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : '';
|
||||
echo '<li class='.esc_attr( $icon_class ).'><i class="'.esc_attr( $sophia_after_dark_fork_awesome_icon ).'"></i></li>';
|
||||
echo '<li class=' . esc_attr( $icon_class ) . '><i class="' . esc_attr( $sophia_after_dark_fork_awesome_icon ) . '"></i></li>';
|
||||
}
|
||||
echo '</ul><input data-default="'.esc_attr( $default ).'" type="hidden" value="'.esc_attr( $new_value ).'" data-name="'.esc_attr( $key ).'"/>';
|
||||
echo '</ul><input data-default="' . esc_attr( $default ) . '" type="hidden" value="' . esc_attr( $new_value ) . '" data-name="' . esc_attr( $key ) . '"/>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Social Icon field
|
||||
*/
|
||||
case 'social_icon':
|
||||
$sophia_after_dark_fork_awesome_social_icon_array = sophia_after_dark_fork_awesome_social_icon_array();
|
||||
echo '<div class="sad-repeater-selected-icon"><i class="'.esc_attr( $new_value ).'"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
|
||||
echo '<div class="sad-repeater-selected-icon"><i class="' . esc_attr( $new_value ) . '"></i><span><i class="fa fa-angle-down"></i></span></div><ul class="sad-repeater-icon-list sad-clearfix">';
|
||||
foreach ( $sophia_after_dark_fork_awesome_social_icon_array as $sophia_after_dark_fork_awesome_icon ) {
|
||||
$icon_class = $new_value == $sophia_after_dark_fork_awesome_icon ? 'icon-active' : '';
|
||||
echo '<li class='.esc_attr( $icon_class ).'><i class="'.esc_attr( $sophia_after_dark_fork_awesome_icon ).'"></i></li>';
|
||||
echo '<li class=' . esc_attr( $icon_class ) . '><i class="' . esc_attr( $sophia_after_dark_fork_awesome_icon ) . '"></i></li>';
|
||||
}
|
||||
echo '</ul><input data-default="'.esc_attr( $default ).'" type="hidden" value="'.esc_attr( $new_value ).'" data-name="'.esc_attr( $key ).'"/>';
|
||||
echo '</ul><input data-default="' . esc_attr( $default ) . '" type="hidden" value="' . esc_attr( $new_value ) . '" data-name="' . esc_attr( $key ) . '"/>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Select field
|
||||
*/
|
||||
case 'select':
|
||||
$options = $field['options'];
|
||||
echo '<select data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'">';
|
||||
foreach ( $options as $option => $val )
|
||||
{
|
||||
printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $option ), selected( $new_value, $option, false ), esc_html( $val ) );
|
||||
}
|
||||
echo '<select data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '">';
|
||||
foreach ( $options as $option => $val ) {
|
||||
printf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $option ), selected( $new_value, $option, false ), esc_html( $val ) );
|
||||
}
|
||||
echo '</select>';
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Dropdown field
|
||||
*/
|
||||
case 'dropdown_pages':
|
||||
$show_option_none = esc_html__( '— Select a page —', 'sophia-after-dark' );
|
||||
$select_field ='data-default="'.esc_attr( $default ).'" data-name="'.esc_attr( $key ).'"';
|
||||
$show_option_none = esc_html__( '— Select a page —', 'sophia-after-dark' );
|
||||
$select_field = 'data-default="' . esc_attr( $default ) . '" data-name="' . esc_attr( $key ) . '"';
|
||||
$option_none_value = '';
|
||||
$dropdown = wp_dropdown_pages(
|
||||
$dropdown = wp_dropdown_pages(
|
||||
array(
|
||||
'name' => esc_attr( $key ),
|
||||
'echo' => '',
|
||||
'show_option_none' => esc_html( $show_option_none ),
|
||||
'name' => esc_attr( $key ),
|
||||
'echo' => '',
|
||||
'show_option_none' => esc_html( $show_option_none ),
|
||||
'option_none_value' => esc_attr( $option_none_value ),
|
||||
'selected' => esc_attr( $new_value )
|
||||
'selected' => esc_attr( $new_value ),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
if ( empty( $dropdown ) ) {
|
||||
$dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $key ) );
|
||||
$dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $key ) );
|
||||
$dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
|
||||
$dropdown .= '</select>';
|
||||
}
|
||||
@@ -324,44 +323,44 @@ if ( ! function_exists( 'sophia_after_dark_register_custom_controls' ) ) :
|
||||
$dropdown = str_replace( '<select', '<select ' . $select_field, $dropdown );
|
||||
echo $dropdown;
|
||||
break;
|
||||
|
||||
|
||||
/**
|
||||
* Upload field
|
||||
*/
|
||||
case 'upload':
|
||||
$image_class = "";
|
||||
$image_class = '';
|
||||
$upload_btn_label = esc_html__( 'Select Image', 'sophia-after-dark' );
|
||||
$remove_btn_label = esc_html__( 'Remove', 'sophia-after-dark' );
|
||||
if ( $new_value ) {
|
||||
if ( $new_value ) {
|
||||
$image_class = ' hidden';
|
||||
}
|
||||
echo '<div class="sad-fields-wrap"><div class="attachment-media-view"><div class="placeholder'. esc_attr( $image_class ).'">';
|
||||
echo '<div class="sad-fields-wrap"><div class="attachment-media-view"><div class="placeholder' . esc_attr( $image_class ) . '">';
|
||||
esc_html_e( 'No image selected', 'sophia-after-dark' );
|
||||
echo '</div><div class="thumbnail thumbnail-image"><img src="'.esc_url( $new_value ).'" style="max-width:100%;"/></div><div class="actions sad-clearfix"><button type="button" class="button sad-delete-button align-left">'. esc_html( $remove_btn_label ) .'</button><button type="button" class="button sad-upload-button alignright">'. esc_html( $upload_btn_label ) .'</button><input data-default="'.esc_attr( $default ).'" class="upload-id" data-name="'.esc_attr( $key ).'" type="hidden" value="'.esc_attr( $new_value ).'"/></div></div></div>';
|
||||
echo '</div><div class="thumbnail thumbnail-image"><img src="' . esc_url( $new_value ) . '" style="max-width:100%;"/></div><div class="actions sad-clearfix"><button type="button" class="button sad-delete-button align-left">' . esc_html( $remove_btn_label ) . '</button><button type="button" class="button sad-upload-button alignright">' . esc_html( $upload_btn_label ) . '</button><input data-default="' . esc_attr( $default ) . '" class="upload-id" data-name="' . esc_attr( $key ) . '" type="hidden" value="' . esc_attr( $new_value ) . '"/></div></div></div>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="sad-clearfix sad-repeater-footer">
|
||||
<div class="alignright">
|
||||
<a class="sad-repeater-field-remove" href="#remove"><?php esc_html_e( 'Delete', 'sophia-after-dark' ) ?></a> |
|
||||
<a class="sad-repeater-field-close" href="#close"><?php esc_html_e( 'Close', 'sophia-after-dark' ) ?></a>
|
||||
<a class="sad-repeater-field-remove" href="#remove"><?php esc_html_e( 'Delete', 'sophia-after-dark' ); ?></a> |
|
||||
<a class="sad-repeater-field-close" href="#close"><?php esc_html_e( 'Close', 'sophia-after-dark' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}// Ends sophia_after_dark_register_custom_controls
|
||||
}//end sophia_after_dark_register_custom_controls()
|
||||
endif;
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user