* @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class Billow_Text_Radio_Button_Custom_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'text_radio_button'; /** * Enqueue our scripts and styles */ public function enqueue() { wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array(), '1.0', 'all' ); } /** * Render the control in the customizer */ public function render_content() { ?>
label ) ) { ?> label ); ?> description ) ) { ?> description ); ?>
choices as $key => $value ) { ?>
* @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class Billow_Image_Radio_Button_Custom_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'image_radio_button'; /** * Enqueue our scripts and styles */ public function enqueue() { wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array(), '1.0', 'all' ); } /** * Render the control in the customizer */ public function render_content() { ?>
label ) ) { ?> label ); ?> description ) ) { ?> description ); ?> choices as $key => $value ) { ?>
* @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class Billow_Slider_Custom_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'slider_control'; /** * Enqueue our scripts and styles */ public function enqueue() { wp_enqueue_script( 'billow-custom-controls-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/js/customizer.js', array( 'jquery', 'jquery-ui-core' ), '1.0.1', true ); wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array(), '1.0', 'all' ); } /** * Render the control in the customizer */ public function render_content() { ?>
label ); ?>link(); ?> />
description ) ) { ?> description ); ?> * @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class Billow_Toggle_Switch_Custom_control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'toogle_switch'; /** * Enqueue our scripts and styles */ public function enqueue(){ wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array(), '1.0', 'all' ); } /** * Render the control in the customizer */ public function render_content(){ ?>
link(); checked( $this->value() ); ?>>
label ); ?> description ) ) { ?> description ); ?>
* @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ class Billow_Google_Font_Select_Custom_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'google_fonts'; /** * The list of Google Fonts */ private $fontList = false; /** * The saved font values decoded from json */ private $fontValues = []; /** * The index of the saved font within the list of Google fonts */ private $fontListIndex = 0; /** * The number of fonts to display from the json file. Either positive integer or 'all'. Default = 'all' */ private $fontCount = 'all'; /** * The font list sort order. Either 'alpha' or 'popular'. Default = 'alpha' */ private $fontOrderBy = 'alpha'; /** * Get our list of Alternate Web Fonts */ public function __construct( $manager, $id, $args = array(), $options = array() ) { parent::__construct( $manager, $id, $args ); // Get the font sort order if ( isset( $this->input_attrs['orderby'] ) && strtolower( $this->input_attrs['orderby'] ) === 'popular' ) { $this->fontOrderBy = 'popular'; } // Get the list of Google fonts if ( isset( $this->input_attrs['font_count'] ) ) { if ( 'all' != strtolower( $this->input_attrs['font_count'] ) ) { $this->fontCount = ( abs( (int) $this->input_attrs['font_count'] ) > 0 ? abs( (int) $this->input_attrs['font_count'] ) : 'all' ); } } $this->fontList = $this->billow_getGoogleFonts( 'all' ); // Decode the default json font value $this->fontValues = json_decode( $this->value() ); // Find the index of our default font within our list of Google fonts $this->fontListIndex = is_object( $this->fontValues ) && property_exists( $this->fontValues, 'font' ) ? $this->billow_getFontIndex( $this->fontList, $this->fontValues->font ) : false; } /** * Enqueue our scripts and styles */ public function enqueue() { wp_enqueue_script( 'billow-select2-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/js/select2.full.min.js', array( 'jquery' ), '4.0.6', true ); wp_enqueue_script( 'billow-custom-controls-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/js/customizer.js', array( 'billow-select2-js' ), '1.0.1', true ); wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array(), '1.1', 'all' ); wp_enqueue_style( 'billow-select2-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/select2.full.min.css', array(), '4.0.6', 'all' ); } /** * Export our List of Google Fonts to JavaScript */ public function to_json() { parent::to_json(); $this->json['billowfontslist'] = $this->fontList; } /** * Render the control in the customizer */ public function render_content() { if (!empty($this->fontList)) { ?>
label)) { ?> label); ?> description)) { ?> description); ?> link(); ?>/>
$value ) { if( $value->family == $needle ) { return $key; } } return false; } /** * Google Fonts List. */ public function billow_getGoogleFonts( $count = 30 ) { if ( $this->fontOrderBy === 'popular' ) { require dirname( __FILE__ ) . '/google-fonts-popularity.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } else { require dirname( __FILE__ ) . '/google-fonts-alphabetical.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } if( $count == 'all' ) { return $fonts->items; } else { return array_slice( $fonts->items, 0, $count ); } } } /** * Alpha Color Picker Custom Control * * @author Braad Martin * @license http://www.gnu.org/licenses/gpl-3.0.html * @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker */ class Billow_Customize_Alpha_Color_Control extends WP_Customize_Control { /** * The type of control being rendered */ public $type = 'alpha-color'; /** * Add support for palettes to be passed in. * * Supported palette values are true, false, or an array of RGBa and Hex colors. */ public $palette; /** * Add support for showing the opacity value on the slider handle. */ public $show_opacity; /** * Enqueue our scripts and styles */ public function enqueue() { wp_enqueue_script( 'billow-custom-controls-js', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/js/customizer.js', array( 'jquery', 'wp-color-picker' ), '1.0.1', true ); wp_enqueue_style( 'billow-custom-controls-css', trailingslashit( get_template_directory_uri() ) . 'inc/customizer/custom-controls/css/customizer.css', array( 'wp-color-picker' ), '1.0', 'all' ); } /** * Render the control in the customizer */ public function render_content() { // Process the palette if ( is_array( $this->palette ) ) { $palette = implode( '|', $this->palette ); } else { // Default to true. $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true'; } // Support passing show_opacity as string or boolean. Default to true. $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true'; ?> link(); ?> /> $value ) { $input[$key] = sanitize_text_field( $value ); } $input = implode( ',', $input ); } else { $input = sanitize_text_field( $input ); } return $input; } } /** * Google Font sanitization * * @param string JSON string to be sanitized * @return string Sanitized input */ if ( ! function_exists( 'billow_google_font_sanitization' ) ) { function billow_google_font_sanitization( $input ) { $val = json_decode( $input, true ); if( is_array( $val ) ) { foreach ( $val as $key => $value ) { $val[$key] = sanitize_text_field( $value ); } $input = json_encode( $val ); } else { $input = json_encode( sanitize_text_field( $val ) ); } return $input; } } }