'', 'facebook' => 'Facebook', 'instagram' => 'Instagram', 'linkedin' => 'LinkedIn', 'pinterest' => 'Pinterest', 'skype' => 'Skype', 'telegram' => 'Telegram', 'tiktok' => 'TikTok', 'twitterx' => 'Twitter X', 'wechat' => 'WeChat', 'whatsapp' => 'WhatsApp', 'youtube' => 'YouTube' ); } //? ========== ========== ========== Social link settings $wp_customize->add_setting( 'badoblog_cus_soc_block', array( 'sanitize_callback' => 'badoblog_fun_sanitize_elastic_soc', 'default' => json_encode(array( array( 'soc_net' => 'off', 'soc_link' => '/', 'soc_new_link' => 0, ) )) )); $wp_customize->add_control( new badoblog_Elastic_Controler_soc( $wp_customize, 'badoblog_cus_soc_block', array( 'priority' => 200, 'label' => esc_html__('Social links', 'bado-blog'), 'description' => esc_html__('Drag the block with the cursor to change the position of the links', 'bado-blog'), 'section' => 'badoblog_cus_section_soc', 'settings' => 'badoblog_cus_soc_block', 'badoblog_box_label' => esc_html__('Section with settings', 'bado-blog'), 'badoblog_box_add_control' => esc_html__('Add section', 'bado-blog'), ), array( 'soc_net' => array( 'type' => 'select', 'label' => esc_html__('Picture variant', 'bado-blog'), 'options' => $soc_net, 'default' => 'off', 'class' => 'class-soc-net' ), 'soc_link' => array( 'type' => 'url', 'label' => esc_html__('Link to social network (URL)', 'bado-blog'), 'default' => '/', 'class' => 'class-soc-link' ), 'soc_new_link' => array( 'type' => 'checkbox', 'label' => esc_html__('Open link in new tab', 'bado-blog'), 'default' => 0, 'class' => 'class-soc-new-link' ) ) ) ); } add_action('customize_register', 'badoblog_fun_customize_register_soc'); if (class_exists('WP_Customize_Control')) { class badoblog_Elastic_Controler_soc extends WP_Customize_Control { public $type = 'multi-elastic'; public $badoblog_box_label = ''; public $badoblog_box_add_control = ''; private $cats = ''; public $fields = array(); public function __construct($manager, $id, $args = array(), $fields = array()) { $this->fields = $fields; $this->badoblog_box_label = $args['badoblog_box_label'] ; $this->badoblog_box_add_control = $args['badoblog_box_add_control']; $this->cats = get_categories(array( 'hide_empty' => false )); parent::__construct($manager, $id, $args); } public function render_content() { $values = json_decode($this->value()); ?> label); ?> description) { ?> description); ?> link()); ?> class="multi-elastic-collector" value="value()); ?>"> fields; $values = json_decode($this->value()); if (is_array($values)) { foreach ($values as $value) { ?>
  • $field) { $class = isset($field['class']) ? $field['class'] : ''; ?>
    $key) ? $value->$key : ''; $default = isset($field['default']) ? $field['default'] : ''; switch ($field['type']) { case 'checkbox': echo ''; break; case 'url': echo ''; break; case 'selector': $options = $field['options']; echo '
    '; foreach ($options as $option => $val) { $class = ($new_value == $option) ? 'selector-soc-selected': ''; echo ''; } echo '
    '; echo ''; break; case 'select': $options = $field['options']; echo ''; break; } ?>
  • $box) { foreach ($box as $key => $value) { if ($key == 'soc_net') { $input_decoded[$boxes][$key] = sanitize_text_field($value); } else if ($key == 'soc_link') { $input_decoded[$boxes][$key] = esc_url_raw($value); } else if ($key == 'soc_new_link') { $input_decoded[$boxes][$key] = ($value == 1) ? 1 : 0; } } } return json_encode($input_decoded); } return $input; }