PATH:
home
/
letacommog
/
supportleta
/
wp-content
/
plugins
/
wp-domain-checker
/
titan-framework
/
lib
<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class TitanFrameworkOptionRadioPalette extends TitanFrameworkOption { public $defaultSecondarySettings = array( 'options' => array(), ); function __construct( $settings, $owner ) { parent::__construct( $settings, $owner ); add_action( 'tf_livepreview_pre_' . $this->getOptionNamespace(), array( $this, 'preLivePreview' ), 10, 3 ); } /* * Display for options and meta */ public function display() { if ( empty( $this->settings['options'] ) ) { return; } if ( $this->settings['options'] == array() ) { return; } $this->echoOptionHeader(); // Get the correct value, since we are accepting indices in the default setting $value = $this->getValue(); // print the palettes foreach ( $this->settings['options'] as $key => $colorSet ) { printf( '<label id="%s"><input id="%s" type="radio" name="%s" value="%s" %s/> <span>', $this->getID() . $key, $this->getID() . $key, $this->getID(), esc_attr( $key ), $value == $colorSet ? 'checked="checked"' : '' // can't use checked with arrays ); if ( ! is_array( $colorSet ) ) { continue; } foreach ( $colorSet as $color ) { echo "<span style='background: {$color}'></span>"; } echo '</span></label>'; } $this->echoOptionFooter(); } // Save the index of the selected palette public function cleanValueForSaving( $value ) { if ( ! is_array( $this->settings['options'] ) ) { return $value; } // if the key above is zero, we will get a blank value if ( $value == '' ) { $value = 0; } return $value; } // The value we should return is an array of the selected colors public function cleanValueForGetting( $value ) { if ( is_array( $value ) ) { return $value; } $value = stripslashes( $value ); if ( is_serialized( $value ) ) { return unserialize( $value ); } if ( empty( $value ) ) { $value = 0; } if ( array_key_exists( $value, $this->settings['options'] ) ) { return $this->settings['options'][ $value ]; } return $value; } /* * Display for theme customizer */ public function registerCustomizerControl( $wp_customize, $section, $priority = 1 ) { $wp_customize->add_control( new TitanFrameworkOptionRadioPaletteControl( $wp_customize, $this->getID(), array( 'label' => $this->settings['name'], 'section' => $section->settings['id'], 'type' => 'select', 'choices' => $this->settings['options'], 'settings' => $this->getID(), 'description' => $this->settings['desc'], 'priority' => $priority, ) ) ); } // For live previews, we need to give our options to javascript and then get the proper value from it public function preLivePreview( $optionID, $optionType, $option ) { if ( $optionID != $this->settings['id'] || empty( $this->settings['options'] ) ) { return; } if ( $this->settings['options'] == array() ) { return; } ?> var options = JSON.parse('<?php echo json_encode( $this->settings['options'] ) ?>'), key = value; value = options[value]; <?php } } /* * We create a new control for the theme customizer */ add_action( 'customize_register', 'registerTitanFrameworkOptionRadioPaletteControl', 1 ); function registerTitanFrameworkOptionRadioPaletteControl() { class TitanFrameworkOptionRadioPaletteControl extends WP_Customize_Control { public $description; public function render_content() { // Get the correct value, we might get a blank if index / value is 0 $value = $this->value(); if ( $value == '' ) { $value = 0; } ?><span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span><?php if ( ! empty( $this->description ) ) { echo "<p class='description'>" . $this->description . '</p>'; } // print the palettes foreach ( $this->choices as $key => $colorSet ) { if ( ! is_array( $colorSet ) ) { continue; } ?> <span class='tf-radio-palette'> <label> <input type="radio" name="<?php echo $this->id ?>" value="<?php echo esc_attr( $key ) ?>" <?php $this->link(); checked( $value, $key ); ?>/> <span> <?php foreach ( $colorSet as $color ) { echo "<span style='background: {$color}'></span>"; } ?> </span> </label> </span> <?php } } } }
[+]
..
[-] class-admin-tab.php
[edit]
[-] class-titan-framework.php
[edit]
[-] class-option-date.php
[edit]
[-] class-option-textarea.php
[edit]
[-] class-option-multicheck-posts.php
[edit]
[-] class-option-radio.php
[edit]
[-] functions-utils.php
[edit]
[-] class-option-radio-palette.php
[edit]
[-] class-option-font.php
[edit]
[-] class-option-custom.php
[edit]
[-] class-option-select-pages.php
[edit]
[-] class-option-multicheck.php
[edit]
[-] class-option-multicheck-categories.php
[edit]
[-] class-option-heading.php
[edit]
[-] class-option-group.php
[edit]
[-] class-option-multicheck-post-types.php
[edit]
[-] class-admin-notification.php
[edit]
[-] class-option-iframe.php
[edit]
[-] class-option-radio-image.php
[edit]
[-] class-titan-css.php
[edit]
[-] class-option-upload.php
[edit]
[-] class-admin-page.php
[edit]
[-] functions-googlefonts.php
[edit]
[-] class-customizer.php
[edit]
[-] class-option-checkbox.php
[edit]
[-] class-option-number.php
[edit]
[-] class-option-select-categories.php
[edit]
[-] class-wp-customize-control.php
[edit]
[-] class-option-color.php
[edit]
[-] class-option-select-post-types.php
[edit]
[-] class-option-code.php
[edit]
[-] class-meta-box.php
[edit]
[-] iframe-font-preview.php
[edit]
[-] class-option-multicheck-pages.php
[edit]
[-] class-option-enable.php
[edit]
[-] class-option-editor.php
[edit]
[-] class-option-gallery.php
[edit]
[-] class-option-select.php
[edit]
[-] class-option-edd-license.php
[edit]
[-] class-option.php
[edit]
[-] class-option-file.php
[edit]
[-] class-option-save.php
[edit]
[-] class-option-separator.php
[edit]
[-] class-option-sortable.php
[edit]
[-] class-option-text.php
[edit]
[-] class-option-select-posts.php
[edit]
[-] class-option-ajax-button.php
[edit]
[-] class-option-note.php
[edit]