PATH:
home
/
letacommog
/
supportleta
/
wp-content
/
plugins
/
wp-domain-checker
/
titan-framework
/
lib
<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } class TitanFrameworkOptionMulticheck extends TitanFrameworkOption { public $defaultSecondarySettings = array( 'options' => array(), 'select_all' => false, ); /** * Constructor * * @param array $settings Option settings * @param string $owner Namespace * * @since 1.11 */ function __construct( $settings, $owner ) { parent::__construct( $settings, $owner ); tf_add_action_once( 'admin_enqueue_scripts', array( $this, 'load_select_scripts' ) ); tf_add_action_once( 'customize_controls_enqueue_scripts', array( $this, 'load_select_scripts' ) ); } /* * Display for options and meta */ public function display() { $this->echoOptionHeader( true ); echo '<fieldset>'; $savedValue = $this->getValue(); if ( ! empty( $this->settings['select_all'] ) ) { $select_all_label = __( 'Select All' ); if ( is_string( $this->settings['select_all'] ) ) { $select_all_label = $this->settings['select_all']; } printf('<label style="margin-bottom: 1em !important;"><input class="tf_checkbox_selectall" type="checkbox" /> %s </label><br>', esc_html( $select_all_label ) ); } foreach ( $this->settings['options'] as $value => $label ) { printf('<label for="%s"><input id="%s" type="checkbox" name="%s[]" value="%s" %s/> %s</label><br>', $this->getID() . $value, $this->getID() . $value, $this->getID(), esc_attr( $value ), checked( in_array( $value, $savedValue ), true, false ), $label ); } echo '</fieldset>'; $this->echoOptionFooter( false ); } /** * Load the multicheck-selectall script * * @since 1.11 * @return void */ public function load_select_scripts() { wp_enqueue_script( 'tf-multicheck-select-all', TitanFramework::getURL( '../js/multicheck-select-all.js', __FILE__ ), array( 'jquery' ), TF_VERSION, true ); } public function cleanValueForSaving( $value ) { if ( empty( $value ) ) { return array(); } if ( is_serialized( $value ) ) { return $value; } // CSV if ( is_string( $value ) ) { $value = explode( ',', $value ); } return serialize( $value ); } public function cleanValueForGetting( $value ) { if ( empty( $value ) ) { return array(); } if ( is_array( $value ) ) { return $value; } if ( is_serialized( $value ) ) { return unserialize( $value ); } if ( is_string( $value ) ) { return explode( ',', $value ); } } /* * Display for theme customizer */ public function registerCustomizerControl( $wp_customize, $section, $priority = 1 ) { $wp_customize->add_control( new TitanFrameworkOptionMulticheckControl( $wp_customize, $this->getID(), array( 'label' => $this->settings['name'], 'section' => $section->settings['id'], 'settings' => $this->getID(), 'description' => $this->settings['desc'], 'options' => $this->settings['options'], 'select_all' => $this->settings['select_all'], 'priority' => $priority, ) ) ); } } /* * WP_Customize_Control with description */ add_action( 'customize_register', 'registerTitanFrameworkOptionMulticheckControl', 1 ); function registerTitanFrameworkOptionMulticheckControl() { class TitanFrameworkOptionMulticheckControl extends WP_Customize_Control { public $description; public $options; public $select_all; private static $firstLoad = true; // Since theme_mod cannot handle multichecks, we will do it with some JS public function render_content() { // the saved value is an array. convert it to csv if ( is_array( $this->value() ) ) { $savedValueCSV = implode( ',', $this->value() ); $values = $this->value(); } else { $savedValueCSV = $this->value(); $values = explode( ',', $this->value() ); } if ( self::$firstLoad ) { self::$firstLoad = false; ?> <script> jQuery(document).ready(function($) { "use strict"; $('input.tf-multicheck').change(function(event) { event.preventDefault(); var csv = ''; $(this).parents('li:eq(0)').find('input[type=checkbox]').each(function() { if ($(this).is(':checked')) { csv += $(this).attr('value') + ','; } }); csv = csv.replace(/,+$/, ""); $(this).parents('li:eq(0)').find('input[type=hidden]').val(csv) // we need to trigger the field afterwards to enable the save button .trigger('change'); return true; }); }); </script> <?php } $description = ''; if ( ! empty( $this->description ) ) { $description = "<p class='description'>" . $this->description . '</p>'; } ?> <label class='tf-multicheck-container'> <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> <?php echo $description; if ( ! empty( $this->select_all ) ) { $select_all_label = __( 'Select All' ); if ( is_string( $this->select_all ) ) { $select_all_label = $this->select_all; } printf('<label style="margin-bottom: 1em !important; display: inline-block;"><input class="tf_checkbox_selectall" type="checkbox" /> %s </label><br>', esc_html( $select_all_label ) ); } foreach ( $this->options as $value => $label ) { printf('<label for="%s"><input class="tf-multicheck" id="%s" type="checkbox" value="%s" %s/> %s</label><br>', $this->id . $value, $this->id . $value, esc_attr( $value ), checked( in_array( $value, $values ), true, false ), $label ); } ?> <input type="hidden" value="<?php echo esc_attr( $savedValueCSV ); ?>" <?php $this->link(); ?> /> </label> <?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]