array( 'sanitize_callback' => 'absolute_weaver_cz_sanitize_int', 'transport' => $transport, ), 'control' => array( 'control_type' => $control, 'label' => $label, 'description' => $description, // native checkbox does esc_html 'type' => 'checkbox', ), ); } function absolute_weaver_cz_checkbox_post( $label, $description = '', $plus = '' ) { return absolute_weaver_cz_checkbox( $label, $description, $plus, 'postMessage' ); } /** * @param $opt * @param $label * @param string $description * @param string $transport * @param string $plus * * @return array */ function absolute_weaver_cz_color( $opt, $label, $description = '', $transport = 'postMessage', $plus = '' ) { if ( $plus == 'plus' ) { $label .= ABSOLUTE_WEAVER_PLUS_ICON; } if ( $transport == 'refresh' ) { $label .= ABSOLUTE_WEAVER_REFRESH_ICON; } $default = absolute_weaver_cz_getopt( $opt ); if ( ! $default ) { $default = 'inherit'; } $control = apply_filters( 'absolute_weaver_plus_control', 'Customize_Alpha_Color_Control', $plus ); return array( 'setting' => array( 'sanitize_callback' => 'absolute_weaver_cz_sanitize_color', 'transport' => $transport, 'default' => $default, ), 'control' => array( 'control_type' => $control, 'label' => $label, 'description' => $description, ), ); } /** * @param $root * @param string $label * @param string $description * @param string $transport * @param string $bold * * @return array */ function absolute_weaver_cz_fonts_control( $root, $label = '', $description = '', $transport = 'refresh', $bold = 'bold' ) { $opt = array(); if ( $root != 'm_primary' && $root != 'wrapper' ) // add a line except top { $opt[ $root . '-headingline' ] = absolute_weaver_cz_line(); } $glabel = $label; if ( $transport == 'refresh' ) { $glabel .= ABSOLUTE_WEAVER_REFRESH_ICON; } $opt[ $root . '-font-hdrm' ] = absolute_weaver_cz_group_title( $glabel, $description ); // Font Size $opt[ $root . '_font_size' ] = absolute_weaver_cz_select( '', '' . __( 'Select Font Size for ', 'absolute-weaver' ) . esc_html( $label ) . '', array( 'default' => esc_html__( 'Inherit', 'absolute-weaver' ), 'm-font-size' => esc_html__( 'Medium Font', 'absolute-weaver' ), 'xxs-font-size' => esc_html__( 'XX-Small Font', 'absolute-weaver' ), 'xs-font-size' => esc_html__( 'X-Small Font', 'absolute-weaver' ), 's-font-size' => esc_html__( 'Small Font', 'absolute-weaver' ), 'l-font-size' => esc_html__( 'Large Font', 'absolute-weaver' ), 'xl-font-size' => esc_html__( 'X-Large Font', 'absolute-weaver' ), 'xxl-font-size' => esc_html__( 'XX-Large Font', 'absolute-weaver' ), 'customa-font-size' => esc_html__( 'Custom Size A', 'absolute-weaver' ), 'customb-font-size' => esc_html__( 'Custom Size B', 'absolute-weaver' ), ), '', $transport ); // Font Family $t_dir = absolute_weaver_relative_url( '' ) . 'help/font-demo.html'; $opt[ $root . '_font_family' ] = absolute_weaver_cz_select( '', '' . __( 'Select Font Family for ', 'absolute-weaver' ) . "{$label}  ", 'absolute_weaver_cz_choices_font_family', '', $transport ); // Bold / Normal if ( $root == 'tagline' || $root == 'content_h' || strpos( $root, '_title' ) > 0 ) { if ( $transport == 'refresh' ) { $opt[ $root . '_normal' ] = absolute_weaver_cz_checkbox( __( 'Normal Weight for ', 'absolute-weaver' ) . $label, '' //'' . esc_html__( 'Normal Weight for ', 'absolute-weaver' ) . $label . '' ); } else { $opt[ $root . '_normal' ] = absolute_weaver_cz_checkbox_post( __( 'Normal Weight for ', 'absolute-weaver' ) . $label, ''// '' . esc_html__( 'Normal Weight for ', 'absolute-weaver' ) . $label . '' ); } } else { $opt[ $root . '_bold' ] = absolute_weaver_cz_select( '', '' . __( 'Use Bold for ', 'absolute-weaver' ) . '' . $label, 'absolute_weaver_cz_choices_bold_italic', '', $transport ); } // Italic $opt[ $root . '_italic' ] = absolute_weaver_cz_select( '', '' . __( 'Use Italic for ', 'absolute-weaver' ) . '' . $label, 'absolute_weaver_cz_choices_bold_italic', '', $transport ); return $opt; } /** * @param $label * @param string $description * * @return array */ function absolute_weaver_cz_group_title( $label, $description = '' ) { /* 'group_title' => absolute_weaver_cz_group_title( label, description ), */ return array( 'control' => array( 'control_type' => 'Absolute_Weaver_Custom_Control', 'label' => $label, 'description' => $description, 'type' => 'group-title', ), ); } /** * @param $label * @param string $description * * @return array */ function absolute_weaver_cz_heading( $label, $description = '', $plus = '' ) { return array( 'control' => array( 'control_type' => apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Custom_Control', $plus ), 'label' => $label, 'description' => $description, 'type' => 'heading', ), ); } /** * @param $label * @param string $description * * @return array */ function absolute_weaver_cz_html_description( $description = '', $plus = '' ) { return array( 'control' => array( 'control_type' => apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Custom_Control', $plus ), 'label' => '', 'description' => $description, 'type' => 'HTML', ), ); } /** * @return array */ function absolute_weaver_cz_line() { return array( 'control' => array( 'control_type' => 'Absolute_Weaver_Custom_Control', 'type' => 'line', ), ); } /** * @param $label * @param $description * @param $default * @param $range * @param string $transport * @param string $plus * * @return array */ function absolute_weaver_cz_range( $label, $description, $default, $range, $transport = 'refresh', $plus = '' ) { if ( $plus == 'plus' ) { $label .= ABSOLUTE_WEAVER_PLUS_ICON; } if ( $transport == 'refresh' ) { $label .= ABSOLUTE_WEAVER_REFRESH_ICON; } $control = apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Range_Control', $plus ); return array( 'setting' => array( 'sanitize_callback' => 'absolute_weaver_cz_sanitize_int', 'transport' => $transport, 'default' => $default, ), 'control' => array( 'control_type' => $control, 'label' => $label, 'description' => $description, 'input_attrs' => $range, ), ); } /** * @param $label * @param $description * @param $default * @param $range * @param string $transport * @param string $plus * * @return array */ function absolute_weaver_cz_range_float( $label, $description, $default, $range, $transport = 'refresh', $plus = '' ) { if ( $plus == 'plus' ) { $label .= ABSOLUTE_WEAVER_PLUS_ICON; } if ( $transport == 'refresh' ) { $label .= ABSOLUTE_WEAVER_REFRESH_ICON; } $control = apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Range_Control', $plus ); return array( 'setting' => array( 'sanitize_callback' => 'absolute_weaver_cz_sanitize_float', 'transport' => $transport, 'default' => $default, ), 'control' => array( 'control_type' => $control, 'label' => $label, 'description' => $description, 'input_attrs' => $range, ), ); } /** * @param $label * @param $description * @param $choices * @param string $default * @param string $transport * @param array $input_attrs * * @return array */ function absolute_weaver_cz_select( $label, $description, $choices, $default = '', $transport = 'refresh', $plus = '' ) { if ( ! empty( $input_attrs ) ) { absolute_weaver_alert( 'SELECT INPUT VARS: ' . $label ); } if ( $plus == 'plus' && $label ) { $label .= ABSOLUTE_WEAVER_PLUS_ICON; } if ( $transport == 'refresh' && $label ) { $label .= ABSOLUTE_WEAVER_REFRESH_ICON; } if ( !is_array( $choices) && function_exists( $choices . '_sanitize' ) ) { $sanitize = $choices . '_sanitize'; } else { $sanitize = 'absolute_weaver_cz_sanitize_select'; } $control = apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Select_Control', $plus ); if ( is_array( $choices ) ) { $list = $choices; } else { $list = $choices(); } return array( 'setting' => array( 'default' => $default, 'sanitize_callback' => $sanitize, 'transport' => $transport, ), 'control' => array( 'control_type' => $control, 'label' => esc_html( $label ), 'description' => wp_kses_data( $description ), 'type' => 'select', 'choices' => $list, ), ); } function absolute_weaver_cz_sanitize_select( $input, $setting ) { //input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only return sanitize_key( $input ); } /** * @param $label * @param $description * @param $choices * @param string $default * @param string $transport * @param array $input_attrs * * @return array */ function absolute_weaver_cz_select_plus( $label, $description, $choices, $default = '', $transport = 'refresh' ) { return absolute_weaver_cz_select( $label, $description, $choices, $default, $transport, 'plus' ); } /** * @param string $description * * @return array */ function absolute_weaver_cz_text( $description = '' ) { return array( 'control' => array( 'control_type' => 'Absolute_Weaver_Custom_Control', 'label' => '', 'description' => $description, 'type' => 'text', ), ); } /** * @param $label * @param string $description * @param string $rows * @param string $placeholder * @param string $transport * @param string $plus * @param string $sanitize * * @return array */ function absolute_weaver_cz_htmlarea( $label, $description = '', $rows = '1', $placeholder = '', $transport = 'refresh', $plus = '', $sanitize = 'wp_kses_post' ) { if ( $placeholder == '') $placeholder = __('Any HTML','absolute-weaver'); return absolute_weaver_cz_textarea( $label, $description, $rows, $placeholder, $transport, $plus, $sanitize ); } /** * @param $label * @param string $description * @param string $rows * @param string $placeholder * @param string $transport * @param string $plus * @param string $sanitize * * @return array */ function absolute_weaver_cz_textarea( $label, $description = '', $rows = '1', $placeholder = '', $transport = 'refresh', $plus = '', $sanitize = 'sanitize_textarea_field') { if ( $plus == 'plus' ) { $label .= ABSOLUTE_WEAVER_PLUS_ICON; } if ( $transport == 'refresh' ) { $label .= ABSOLUTE_WEAVER_REFRESH_ICON; } return array( 'setting' => array( 'sanitize_callback' => $sanitize, 'transport' => $transport, 'default' => '', ), 'control' => array( 'control_type' => apply_filters( 'absolute_weaver_plus_control', 'Absolute_Weaver_Textarea_Control', $plus ), 'label' => $label, 'description' => $description, 'type' => 'textarea', 'input_attrs' => array( 'rows' => $rows, 'placeholder' => $placeholder, // might want markup in description ), ), ); } // ==================================== Support functions ==================================== /** * @param $root * @param string $label * @param string $description * @param string $transport * * @return array */ function absolute_weaver_cz_add_link_fonts( $root, $label = '', $description = '', $transport = 'postMessage' ) { // called for: link, ibarlink, contentlink, ilink, wlink, footerlink $opt = array(); $tlabel = ( $transport == 'postMessage' ) ? '' : ABSOLUTE_WEAVER_REFRESH_ICON; $opt[ $root . '-fontlink-hdm' ] = absolute_weaver_cz_group_title( $label, $description ); // Bold $opt[ $root . '_strong' ] = absolute_weaver_cz_select( '', '' . __( 'Use Bold for ', 'absolute-weaver' ) . $label . '' . $tlabel, 'absolute_weaver_cz_choices_bold_italic', '', $transport ); // Italic $opt[ $root . '_em' ] = absolute_weaver_cz_select( '', '' . __( 'Use Italic for ', 'absolute-weaver' ) . $label . '' . $tlabel, 'absolute_weaver_cz_choices_bold_italic', '', $transport ); // Underline // Transport can change, so use direct call to checkbox $opt[ $root . '_u' ] = array( 'setting' => array( 'transport' => $transport, ), 'control' => array( 'label' => __( 'Underline Link', 'absolute-weaver' ) . $tlabel, 'description' => '' . __( 'Use Underline link for ', 'absolute-weaver' ) . $label . '', 'type' => 'checkbox', ), ); // Underline $opt[ $root . '_u_h' ] = absolute_weaver_cz_checkbox( __( 'Underline Hover', 'absolute-weaver' ), '' . __( 'Use Underline on Hover.', 'absolute-weaver' ) . '' ); return $opt; } /** * */ function absolute_weaver_check_customizer_memory() { global $wp_customize; if ( isset( $wp_customize ) && ! $wp_customize->is_theme_active() ) { return; } // Not for preview! if ( isset( $wp_customize ) && ! absolute_weaver_getopt( '_ignore_PHP_memory' ) && ! absolute_weaver_getopt( '_PHP_warning_displayed' ) ) { $memlim = get_cfg_var( 'memory_limit' ); // the server memory limit. $memlim = str_ireplace( 'M', '', $memlim ); // kill the M if ( $memlim < ABSOLUTE_WEAVER_PHP_MEMORY_LIMIT ) { // show if not set // translators: %1: memory limit value absolute_weaver_alert( sprintf( esc_html__( ' **** WARNING! ****\r\n\r\nYour WP host server has only %s of PHP Memory. Depending on your WordPress configuration, this could cause settings made in the Absolute Weaver Customizer Interface to fail to be saved and applied to your live site.\r\n\r\nPlease verify that settings you make in the Customizer are being applied to your live site.\r\n\r\nThere are solutions if this issue applies to you. Please see the [Appearance : Absolute Weaver Admin : Help] tab for more information about the possible PHP Memory problem.\r\n\r\n *** IMPORTANT! ***\r\nThis warning will be displayed only ONCE! The information will be displayed on the Help tab until you resolve the problem.', 'absolute-weaver' ), $memlim . 'M' ) ); absolute_weaver_setopt( '_PHP_warning_displayed', true ); } } } // ==================================== Support for Theme Support Plugin ==================================== // ==================================== Classes ==================================== // // Define our own Classes to interface to the standard Customizer classes if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Absolute_Weaver_Textarea_Control' ) ) : class Absolute_Weaver_Textarea_Control extends WP_Customize_Control { public $type = 'textarea'; public function render_content() { if ( isset( $this->input_attrs['rows'] ) ) { $rows = $this->input_attrs['rows']; } else { $rows = 4; } if ( isset( $this->input_attrs['placeholder'] ) ) { $placeholder = $this->input_attrs['placeholder']; } else { $placeholder = ''; } ?> type ) { case 'group-title' : if ( '' !== $this->label ) { echo '

' . esc_html( $this->label ) . '

'; } if ( '' !== $this->description ) { echo '' . wp_kses_post( $this->description ) . ''; } break; case 'heading': if ( '' !== $this->label ) { echo '' . esc_html( $this->label ) . ''; } if ( '' !== $this->description ) { echo '' . wp_kses_data( $this->description ) . ''; } break; case 'HTML': case 'html': if ( '' !== $this->description ) { echo '' . wp_kses_post( $this->description ) . ''; } break; case 'radio-icons': if ( '' !== $this->label ) { echo '' . esc_html( $this->label ) . ''; } if ( '' !== $this->description ) { echo '' . esc_html( $this->description ) . ''; } if ( empty( $this->choices ) ) { return; } $name = '_customize-radio-' . $this->id; echo '
'; foreach ( $this->choices as $value => $label ) { ?> label ) { echo '' . esc_html( $this->label ) . ''; } if ( '' !== $this->description ) { echo '' . esc_html( $this->description ) . ''; } if ( empty( $this->choices ) ) { return; } $name = '_customize-select-' . $this->id; echo '
link(); ?>> choices as $value => $label ) { $disabled = ''; if ( strpos( $label, '---' ) !== false ) { $disabled = ' disabled'; $label = str_replace( '---', '', $label ); } echo ''; } ?> input_attrs['after'] ) ) { echo esc_html( $this->input_attrs['after'] ); } } } endif; if ( class_exists( 'WP_Customize_Control' ) && ! class_exists( 'Absolute_Weaver_Range_Control' ) ) : /** * Class Absolute_Weaver_Range_Control * * Specialized range control to enable a slider with an accompanying number field. * * Inspired by Kirki. * @link https://github.com/aristath/kirki/blob/0.5/includes/controls/class-Kirki_Customize_Sliderui_Control.php * */ class Absolute_Weaver_Range_Control extends WP_Customize_Control { public $type = 'range'; public $mode = 'slider'; public function enqueue() { wp_enqueue_script( 'jquery-ui-slider' ); } protected function render() { $id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); $class = 'customize-control customize-control-' . $this->type . ' customize-control-' . $this->type . '-' . $this->mode; ?>
  • render_content(); ?>
  • initial_priority = absint( $initial_priority ); // Value to begin the counter. $this->increment = absint( $increment ); // Value to increment the counter by. $this->current_priority = $this->initial_priority; } public function get() { return $this->current_priority; // The current priority value. } public function inc( $increment = 0 ) { // Increment the priority. if ( 0 === $increment ) { $increment = $this->increment; } $this->current_priority += absint( $increment ); } public function add() { // Increment by the $this->increment value. $priority = $this->get(); $this->inc(); return $priority; } /** * Change the current priority and/or increment value. */ public function set( $new_priority = null, $new_increment = null ) { if ( ! is_null( $new_priority ) ) { $this->current_priority = absint( $new_priority ); } if ( ! is_null( $new_increment ) ) { $this->increment = absint( $new_increment ); } } /** * Reset the counter. */ public function reboot() { $this->current_priority = $this->initial_priority; } } endif; // ================================================== CHOICES ================================================= /** * @return array */ function absolute_weaver_cz_choices_hide() { // used multiple places, so function return array( 'hide-none' => esc_html__( 'Do Not Hide', 'absolute-weaver' ), 's-hide' => esc_html__( 'Hide: Phones', 'absolute-weaver' ), 'm-hide' => esc_html__( 'Hide: Small Tablets', 'absolute-weaver' ), 'm-hide s-hide' => esc_html__( 'Hide: Phones+Tablets', 'absolute-weaver' ), 'l-hide' => esc_html__( 'Hide: Desktop', 'absolute-weaver' ), 'l-hide m-hide' => esc_html__( 'Hide: Desktop+Tablets', 'absolute-weaver' ), 'hide' => esc_html__( 'Hide on All Devices', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_hide_sanitize( $val ) { $choices = absolute_weaver_cz_choices_hide(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_align() { // used multiple places, so function return array( 'float-left' => esc_html__( 'Align Left', 'absolute-weaver' ), 'align-center' => esc_html__( 'Center', 'absolute-weaver' ), 'float-right' => esc_html__( 'Align Right', 'absolute-weaver' ), 'alignnone' => esc_html__( 'No Alignment', 'absolute-weaver' ), 'alignwide' => esc_html__( 'Align Wide', 'absolute-weaver' ), 'alignfull' => esc_html__( 'Align Full', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_align_sanitize( $val ) { $choices = absolute_weaver_cz_choices_align(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_align_menu() { // option values are not slugs, but css values, so need function/sanitize pair // used multiple places, so function return array( 'left' => esc_html__( 'Align Left', 'absolute-weaver' ), 'center' => esc_html__( 'Center', 'absolute-weaver' ), 'right' => esc_html__( 'Align Right', 'absolute-weaver' ), 'alignwide' => esc_html__( 'Align Wide', 'absolute-weaver' ), 'alignwide left' => esc_html__( 'Align Wide, Items Left', 'absolute-weaver' ), 'alignwide center' => esc_html__( 'Align Wide, Items Center', 'absolute-weaver' ), 'alignwide right' => esc_html__( 'Align Wide, Items Right', 'absolute-weaver' ), 'alignfull' => esc_html__( 'Align Full', 'absolute-weaver' ), 'alignfull left' => esc_html__( 'Align Full, Items Left', 'absolute-weaver' ), 'alignfull center' => esc_html__( 'Align Full, Items Center', 'absolute-weaver' ), 'alignfull right' => esc_html__( 'Align Full, Items Right', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_align_menu_sanitize( $val ) { $choices = absolute_weaver_cz_choices_align_menu(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_columns() { // used multiple places, so function return array( '1' => esc_html__( '1 Column', 'absolute-weaver' ), '2' => esc_html__( '2 Columns', 'absolute-weaver' ), '3' => esc_html__( '3 Columns', 'absolute-weaver' ), '4' => esc_html__( '4 Columns', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_columns_sanitize( $val ) { $choices = absolute_weaver_cz_choices_columns(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_fi_location() { // used multiple places, so function return array( 'content-top' => esc_html__( 'With Content - top', 'absolute-weaver' ), 'content-bottom' => esc_html__( 'With Content - bottom', 'absolute-weaver' ), 'title-before' => esc_html__( 'With Title', 'absolute-weaver' ), 'title-banner' => esc_html__( 'Banner above Title', 'absolute-weaver' ), 'header-image' => esc_html__( 'Header Image Replacement', 'absolute-weaver' ), 'post-before' => esc_html__( 'Before Page/Post, no wrap', 'absolute-weaver' ), 'post-bg' => esc_html__( 'As BG Image, Tile', 'absolute-weaver' ), 'post-bg-cover' => esc_html__( 'As BG Image, Cover', 'absolute-weaver' ), 'post-bg-parallax' => esc_html__( 'As BG Image, Parallax', 'absolute-weaver' ), 'post-bg-parallax-full' => esc_html__( 'As BG Image, Parallax Full', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_fi_location_sanitize( $val ) { $choices = absolute_weaver_cz_choices_fi_location(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_fi_size() { // used multiple places, so function return array( 'thumbnail' => esc_html__( 'Thumbnail', 'absolute-weaver' ), 'medium' => esc_html__( 'Medium', 'absolute-weaver' ), 'large' => esc_html__( 'Large', 'absolute-weaver' ), 'full' => esc_html__( 'Full', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_fi_size_sanitize( $val ) { $choices = absolute_weaver_cz_choices_fi_size(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_fi_align() { // used multiple places, so function return array( 'fi-alignleft' => esc_html__( 'Align Left', 'absolute-weaver' ), 'fi-aligncenter' => esc_html__( 'Center', 'absolute-weaver' ), 'fi-alignright' => esc_html__( 'Align Right', 'absolute-weaver' ), 'fi-alignnone' => esc_html__( 'No Align', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_fi_align_sanitize( $val ) { $choices = absolute_weaver_cz_choices_fi_align(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_list_bullets() { // used multiple places, so function return array( 'disc' => esc_html__( 'Filled Disc', 'absolute-weaver' ), 'circle' => esc_html__( 'Circle', 'absolute-weaver' ), 'square' => esc_html__( 'Square', 'absolute-weaver' ), 'none' => esc_html__( 'None', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_list_bullets_sanitize( $val ) { $choices = absolute_weaver_cz_choices_list_bullets(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_font_family() { // dynamically created here $base = array( 'inherit' => esc_html__( 'Inherit', 'absolute-weaver' ), ); $google = array( 'google' => esc_html__( '---* Google Fonts ( For All Browsers ) *', 'absolute-weaver' ), 'sans-g' => esc_html__( '--- -- Sans-Serif Google Fonts --', 'absolute-weaver' ), 'open-sans' => esc_html__( 'Open Sans', 'absolute-weaver' ), 'open-sans-condensed' => esc_html__( 'Open Sans Condensed', 'absolute-weaver' ), 'alegreya-sans' => esc_html__( 'Alegreya Sans', 'absolute-weaver' ), 'alegreya-sans-sc' => esc_html__( 'Alegreya Sans SC', 'absolute-weaver' ), 'archivo-black' => esc_html__( 'Archivo Black', 'absolute-weaver' ), 'arimo' => esc_html__( 'Arimo', 'absolute-weaver' ), 'droid-sans' => esc_html__( 'Droid Sans', 'absolute-weaver' ), 'exo-2' => esc_html__( 'Exo 2', 'absolute-weaver' ), 'lato' => esc_html__( 'Lato', 'absolute-weaver' ), 'roboto' => esc_html__( 'Roboto', 'absolute-weaver' ), 'roboto-condensed' => esc_html__( 'Roboto Condensed', 'absolute-weaver' ), 'source-sans-pro' => esc_html__( 'Source Sans Pro', 'absolute-weaver' ), 'serif-g' => esc_html__( '--- -- Serif Google Fonts --', 'absolute-weaver' ), 'alegreya' => esc_html__( 'Alegreya', 'absolute-weaver' ), 'alegreya-sc' => esc_html__( 'Alegreya SC', 'absolute-weaver' ), 'arvo' => esc_html__( 'Arvo Slab', 'absolute-weaver' ), 'droid-serif' => esc_html__( 'Droid Serif', 'absolute-weaver' ), 'lora' => esc_html__( 'Lora', 'absolute-weaver' ), 'roboto-slab' => esc_html__( 'Roboto Slab', 'absolute-weaver' ), 'source-serif-pro' => esc_html__( 'Source Serif Pro', 'absolute-weaver' ), 'tinos' => esc_html__( 'Tinos', 'absolute-weaver' ), 'vollkorn' => esc_html__( 'Vollkorn', 'absolute-weaver' ), 'ultra' => esc_html__( 'Ultra Black', 'absolute-weaver' ), 'mono-g' => esc_html__( '--- -- Monospace Google Fonts --', 'absolute-weaver' ), 'inconsolata' => esc_html__( 'Inconsolata', 'absolute-weaver' ), 'roboto-mono' => esc_html__( 'Roboto Mono', 'absolute-weaver' ), 'cursive-g' => esc_html__( '--- -- "Cursive" Google Fonts --', 'absolute-weaver' ), 'handlee' => esc_html__( 'Handlee', 'absolute-weaver' ), 'blank-w' => esc_html__( '--- ', 'absolute-weaver' ), ); $web = array( 'web' => esc_html__( '---* Web Fonts *', 'absolute-weaver' ), 'web-hote' => esc_html__( '--- - May not match on Android/iOS -', 'absolute-weaver' ), 'sans-w' => esc_html__( '--- -- Sans-Serif Web Fonts --', 'absolute-weaver' ), 'sans-serif' => esc_html__( 'Arial', 'absolute-weaver' ), 'arialBlack' => esc_html__( 'Arial Black', 'absolute-weaver' ), 'arialNarrow' => esc_html__( 'Arial Narrow', 'absolute-weaver' ), 'lucidaSans' => esc_html__( 'Lucida Sans', 'absolute-weaver' ), 'trebuchetMS' => esc_html__( 'Trebuchet MS', 'absolute-weaver' ), 'verdana' => esc_html__( 'Verdana', 'absolute-weaver' ), 'serif-w' => esc_html__( '--- -- Serif Web Fonts --', 'absolute-weaver' ), 'serif' => esc_html__( 'Times', 'absolute-weaver' ), 'cambria' => esc_html__( 'Cambria', 'absolute-weaver' ), 'garamond' => esc_html__( 'Garamond', 'absolute-weaver' ), 'georgia' => esc_html__( 'Georgia', 'absolute-weaver' ), 'lucidaBright' => esc_html__( 'Lucida Bright', 'absolute-weaver' ), 'palatino' => esc_html__( 'Palatino', 'absolute-weaver' ), 'mono-w' => esc_html__( '--- -- Monospace Web Fonts --', 'absolute-weaver' ), 'monospace' => esc_html__( 'Courier', 'absolute-weaver' ), 'consolas' => esc_html__( 'Consolas', 'absolute-weaver' ), 'cursive-w' => esc_html__( '--- -- "Cursive" Web Fonts --', 'absolute-weaver' ), 'papyrus' => esc_html__( 'Papyrus', 'absolute-weaver' ), 'comicSans' => esc_html__( 'Comic Sans MS', 'absolute-weaver' ), ); $gfonts = absolute_weaver_getopt_array( 'fonts_added' ); if ( ! empty( $gfonts ) ) { foreach ( $gfonts as $gfont => $val ) { // $gfont has slug, $val has vals $base[ $gfont ] = $val['name'] . ' (' . ABSOLUTE_WEAVER_PLUS_ICON . 'font)'; } } if ( ! absolute_weaver_getopt( 'disable_google_fonts' ) ) { $base = array_merge( $base, $google ); } $base = array_merge( $base, $web ); return $base; } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_font_family_sanitize( $val ) { $choices = absolute_weaver_cz_choices_font_family(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_bold_italic() { // used multiple places, so function return array( '' => esc_html__( 'Inherit', 'absolute-weaver' ), 'on' => esc_html__( 'On', 'absolute-weaver' ), 'off' => esc_html__( 'Off', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_bold_italic_sanitize( $val ) { $choices = absolute_weaver_cz_choices_bold_italic(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_sb_layout() { // used multiple places, so function return array( 'right' => esc_html__( 'Sidebars on Right', 'absolute-weaver' ), 'right-top' => esc_html__( 'Sidebars on Right (stack top)', 'absolute-weaver' ), 'left' => esc_html__( 'Sidebars on Left', 'absolute-weaver' ), 'left-top' => esc_html__( 'Sidebars on Left (stack top)', 'absolute-weaver' ), 'split' => esc_html__( 'Split - Sidebars on Right and Left', 'absolute-weaver' ), 'split-top' => esc_html__( 'Split (stack top)', 'absolute-weaver' ), 'one-column' => esc_html__( 'No sidebars, content only', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_sb_layout_sanitize( $val ) { $choices = absolute_weaver_cz_choices_sb_layout(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_elementor_pages() { // used multiple places, so function $pargs = array( 'post_type' => 'page', ); $posts = get_pages( $pargs ); $post_list = array(); $post_list[''] = esc_html__( 'None', 'absolute-weaver' ); foreach ( $posts as $post ) { if ( ! ! get_post_meta( $post->ID, '_elementor_edit_mode', true ) ) { $post_list[ $post->ID ] = substr( $post->post_title, 0, 60 ); } } $posts = get_posts( array( 'post_type' => 'post', ) ); foreach ( $posts as $post ) { if ( ! ! get_post_meta( $post->ID, '_elementor_edit_mode', true ) ) { $post_list[ $post->ID ] = substr( $post->post_title, 0, 60 ) . esc_html__( ' (post)', 'absolute-weaver' ); } } return $post_list; } /** * @param $val * * @return mixed */ function absolute_weaver_cz_choices_elementor_pages_sanitize( $val ) { return $val; } /** * @return array */ function absolute_weaver_cz_choices_siteorigin_pages() { // dynamically created $pargs = array( 'post_type' => 'page', ); $posts = get_pages( $pargs ); $post_list = array(); $post_list[''] = esc_html__( 'None', 'absolute-weaver' ); foreach ( $posts as $post ) { if ( ! ! get_post_meta( $post->ID, 'panels_data', true ) ) { $post_list[ $post->ID ] = substr( $post->post_title, 0, 60 ); } } $posts = get_posts( array( 'post_type' => 'post', ) ); foreach ( $posts as $post ) { if ( ! ! get_post_meta( $post->ID, 'panels_data', true ) ) { $post_list[ $post->ID ] = substr( $post->post_title, 0, 53 ) . esc_html__( ' (post)', 'absolute-weaver' ); } } return $post_list; } /** * @param $val * * @return mixed */ function absolute_weaver_cz_choices_siteorigin_pages_sanitize( $val ) { return $val; } /** * @return array */ function absolute_weaver_cz_choices_sb_layout_default() { // used multiple places, so function return array( 'default' => esc_html__( 'Sidebars Use Default', 'absolute-weaver' ), 'right' => esc_html__( 'Sidebars on Right', 'absolute-weaver' ), 'right-top' => esc_html__( 'Sidebars on Right (stack top)', 'absolute-weaver' ), 'left' => esc_html__( 'Sidebars on Left', 'absolute-weaver' ), 'left-top' => esc_html__( 'Sidebars on Left (stack top)', 'absolute-weaver' ), 'split' => esc_html__( 'Split - Sidebars on Right and Left', 'absolute-weaver' ), 'split-top' => esc_html__( 'Split (stack top)', 'absolute-weaver' ), 'one-column' => esc_html__( 'No sidebars, content only', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_sb_layout_default_sanitize( $val ) { $choices = absolute_weaver_cz_choices_sb_layout_default(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_shadow() { // used multiple places, so function return array( "-0" => esc_html__( 'No Shadow', 'absolute-weaver' ), "-1" => esc_html__( 'All Sides, 1px', 'absolute-weaver' ), "-2" => esc_html__( 'All Sides, 2px', 'absolute-weaver' ), "-3" => esc_html__( 'All Sides, 3px', 'absolute-weaver' ), "-4" => esc_html__( 'All Sides, 4px', 'absolute-weaver' ), "-rb" => esc_html__( 'Right + Bottom', 'absolute-weaver' ), "-lb" => esc_html__( 'Left + Bottom', 'absolute-weaver' ), "-tr" => esc_html__( 'Top + Right', 'absolute-weaver' ), "-tl" => esc_html__( 'Top + Left', 'absolute-weaver' ), "-custom" => esc_html__( 'Custom Shadow', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_shadow_sanitize( $val ) { $choices = absolute_weaver_cz_choices_shadow(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } /** * @return array */ function absolute_weaver_cz_choices_rounded() { // used multiple places, so function return array( "none" => esc_html__( 'None', 'absolute-weaver' ), "-all" => esc_html__( 'All Corners', 'absolute-weaver' ), "-left" => esc_html__( 'Left Corners', 'absolute-weaver' ), "-right" => esc_html__( 'Right Corners', 'absolute-weaver' ), "-top" => esc_html__( 'Top Corners', 'absolute-weaver' ), "-bottom" => esc_html__( 'Bottom Corners', 'absolute-weaver' ), ); } /** * @param $val * * @return string */ function absolute_weaver_cz_choices_rounded_sanitize( $val ) { $choices = absolute_weaver_cz_choices_rounded(); return ( isset( $choices[ $val ] ) ) ? $val : ''; } // helper functions /** * @param $control * @param $plus * * @return string */ function absolute_weaver_plus_control_filter( $control, $plus ) { if ( $plus == 'plus' ) { if ( ! absolute_weaver_cz_is_plus() ) { return 'Absolute_Weaver_XPlus_Control'; } else { return $control; } } else { return $control; } } add_filter( 'absolute_weaver_plus_control', 'absolute_weaver_plus_control_filter', 10, 2 ); // ==================================== other sanitization ==================================== /** * Sanitize a string to ensure that it is a float number. * */ function absolute_weaver_cz_sanitize_float( $value ) { if ( ! $value ) { return '0'; } // need to be able detect '0' vs 0 or false else { return floatval( $value ); } } /** * @param $value * * @return int|string */ function absolute_weaver_cz_sanitize_int( $value ) { if ( ! $value ) { return '0'; } else { return absint( $value ); } } /** * @param $in * * @return mixed */ function absolute_weaver_default_sanitize( $in ) { // called for checkboxes, which must be okay return $in; } if ( ! function_exists( 'absolute_weaver_cz_sanitize_text' ) ) : /** * Allow simple HTML markup and content */ function absolute_weaver_cz_sanitize_text( $string ) { return wp_kses_data( $string ); } endif; if ( ! function_exists( 'absolute_weaver_cz_sanitize_html' ) ) : /** * Allow any HTML or code for admins, otherwise restrict content */ function absolute_weaver_cz_sanitize_html( $string ) { return wp_kses_post( $string ); } endif; /** * @param $text * * @return string */ function absolute_weaver_cz_sanitize_head( $text ) { $allowed_head_tags = array( 'title' => array(), 'style' => array( 'media' => true, 'scoped' => true, 'type' => true ), 'meta' => array( 'charset' => true, 'content' => true, 'http-equiv' => true, 'name' => true, 'scheme' => true, 'property' => true, ), 'link' => array( 'href' => true, 'rel' => true, 'type' => true, 'title' => true, 'media' => true, 'id' => true, 'class' => true, 'sizes' => true, 'crossorigin' => true, 'hreflang' => true ), 'script' => array( 'async' => true, 'charset' => true, 'defer' => true, 'src' => true, 'type' => true ), 'noscript' => array(), 'base' => array( 'href' => true, 'target' => true ), ); // restrict head code to valid stuff for $noslash = trim( stripslashes( $text ) ); if ( $noslash == '' ) { return ''; } if ( current_user_can( 'unfiltered_html' ) ) { if ( strpos( $noslash, 's from being broken return wp_kses( $noslash, $allowed_head_tags ); } else { return ''; } } if ( ! function_exists( 'absolute_weaver_cz_sanitize_code' ) ) : /** * Allow only certain tags and attributes in a string. */ function absolute_weaver_cz_sanitize_code( $text ) { // Much option input from Weaver Xtreme can be code, and thus must not be // content filtered - at least for admins. The utf8 check is about the extent of it, although even // that is more restrictive than the standard text widget uses. // Note: this check also works OK for simple checkboxes/radio buttons/selections, // so it is ok to blindly pass those options in here, too. $trimmed = trim( $text ); if ( $trimmed == ' ' ) { return ''; } if ( current_user_can( 'unfiltered_html' ) ) { return wp_check_invalid_utf8( $trimmed ); } else { return wp_kses_post( $trimmed ); // wp_filter_post_kses() handles slashes } } endif; if ( ! function_exists( 'absolute_weaver_cz_sanitize_css' ) ) : /** * Allow only certain tags and attributes in a string. */ function absolute_weaver_cz_sanitize_css( $string ) { return wp_strip_all_tags( $string ); } endif; /** * @param $color * * @return mixed|string */ function absolute_weaver_cz_sanitize_color( $color ) { // sanitize color - allow rgb, rgba, color names, otherwise force to hashed hex $color_names = array( 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen', 'inherit', 'transparent', ); $color = str_replace( ' ', '', strtolower( $color ) ); if ( ! $color ) { return 'inherit'; } if ( strpos( $color, 'rgb' ) === 0 ) { // rgb value return $color; } elseif ( in_array( $color, $color_names ) ) { // CSS color names return $color; } else { // force leading # // 3 or 6 hex digits, or the empty string. if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { return ( $color[0] == '#' ) ? $color : '#' . $color; } else { return 'inherit'; } } } // utils function absolute_weaver_get_logo_html() { $wp_logo = esc_url( absolute_weaver_get_wp_custom_logo_url() ); if ( $wp_logo ) { return '
    ' . __( 'Current Site Logo: ', 'absolute-weaver' ) . ""; } else { return '
    ' . __( 'Site Logo has not been set. You can set the Site Logo on the General Options & Admin -> Site Identity menu.', 'absolute-weaver' ) ; } }