8889841cdist/control.js000064400000000774150544620010007532 0ustar00wp.customize.controlConstructor["kirki-generic"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(i){var c=(i=i||this).params;i.container.find("input, textarea").on("change input",(function(){var e=jQuery(this).val();"kirki-generic"===c.type&&c.choices&&"number"===c.choices.type&&(c.choices.min=parseFloat(c.choices.min),c.choices.max=parseFloat(c.choices.max),ec.choices.max&&(e=c.choices.max)),i.setting.set(e)}))}}); //# sourceMappingURL=control.js.map dist/control.js.map000064400000003271150544620010010301 0ustar00{"mappings":"AAAAA,GAAGC,UAAUC,mBAAmB,iBAC9BF,GAAGC,UAAUE,oBAAoBC,OAAO,CACtCC,iBAAkB,SAAUC,GAE1B,IAAMC,GADND,EAAUA,GAAWE,MACED,OAEvBD,EAAQG,UAAUC,KAAK,mBAAmBC,GAAG,gBAAgB,WAC3D,IAAMC,EAAQC,OAAOL,MAAMM,MAGzB,kBAAoBP,EAAOQ,MAC3BR,EAAOS,SACP,WAAaT,EAAOS,QAAQD,OAE5BR,EAAOS,QAAQC,IAAMC,WAAWX,EAAOS,QAAQC,KAC/CV,EAAOS,QAAQG,IAAMD,WAAWX,EAAOS,QAAQG,KAE3CP,EAAQL,EAAOS,QAAQC,IACzBL,EAAQL,EAAOS,QAAQC,IACdL,EAAQL,EAAOS,QAAQG,MAChCP,EAAQL,EAAOS,QAAQG,MAI3Bb,EAAQc,QAAQC,IAAIT","sources":["packages/kirki-framework/control-generic/src/control.js"],"sourcesContent":["wp.customize.controlConstructor[\"kirki-generic\"] =\n wp.customize.kirkiDynamicControl.extend({\n initKirkiControl: function (control) {\n control = control || this;\n const params = control.params;\n\n control.container.find(\"input, textarea\").on(\"change input\", function () {\n const value = jQuery(this).val();\n\n if (\n \"kirki-generic\" === params.type &&\n params.choices &&\n \"number\" === params.choices.type\n ) {\n params.choices.min = parseFloat(params.choices.min);\n params.choices.max = parseFloat(params.choices.max);\n\n if (value < params.choices.min) {\n value = params.choices.min;\n } else if (value > params.choices.max) {\n value = params.choices.max;\n }\n }\n\n control.setting.set(value);\n });\n },\n });\n"],"names":["wp","customize","controlConstructor","kirkiDynamicControl","extend","initKirkiControl","control","params","this","container","find","on","value","jQuery","val","type","choices","min","parseFloat","max","setting","set"],"version":3,"file":"control.js.map"}src/Field/Text.php000064400000003512150544620010010011 0ustar00args['settings'] ) { $args = parent::filter_setting_args( $args, $wp_customize ); // Set the sanitize-callback if none is defined. if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { $args['sanitize_callback'] = 'sanitize_textarea_field'; // ? Bagus: should we use `sanitize_text_field` instead ? } } return $args; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] ) { $args = parent::filter_control_args( $args, $wp_customize ); // Set the control-type. $args['type'] = 'kirki-generic'; // Choices. $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; $args['choices']['element'] = 'input'; $args['choices']['type'] = 'text'; } return $args; } } src/Field/Textarea.php000064400000002161150544620010010641 0ustar00args['settings'] ) { $args = parent::filter_control_args( $args, $wp_customize ); // Set the control-type. $args['type'] = 'kirki-generic'; // Choices. $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; $args['choices']['element'] = 'textarea'; $args['choices']['rows'] = '5'; } return $args; } } src/Field/Generic.php000064400000004214150544620010010441 0ustar00args['settings'] ) { $args = parent::filter_setting_args( $args, $wp_customize ); // Set the sanitize-callback if none is defined. if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { $args['sanitize_callback'] = 'wp_kses_post'; } } return $args; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] ) { $args = parent::filter_control_args( $args, $wp_customize ); // Set the control-type. $args['type'] = 'kirki-generic'; // Choices. $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; $args['choices']['element'] = isset( $args['choices']['element'] ) ? $args['choices']['element'] : 'input'; } return $args; } } src/Field/Number.php000064400000005646150544620010010327 0ustar00args['settings'] ) { return $args; } // Set the sanitize-callback if none is defined. if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { $args['sanitize_callback'] = function( $value ) use ( $args ) { $value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); if ( isset( $args['choices'] ) && isset( $args['choices']['min'] ) && isset( $args['choices']['max'] ) ) { // Make sure min & max are all numeric. $min = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $max = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); if ( $value < $min ) { $value = $min; } elseif ( $value > $max ) { $value = $max; } } return $value; }; } return $args; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] ) { $args = parent::filter_control_args( $args, $wp_customize ); // Set the control-type. $args['type'] = 'kirki-generic'; // Choices. $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; $args['choices']['element'] = 'input'; $args['choices']['type'] = 'number'; $args['choices'] = wp_parse_args( $args['choices'], [ 'min' => -999999999, 'max' => 999999999, 'step' => 1, ] ); // Make sure min, max & step are all numeric. $args['choices']['min'] = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $args['choices']['max'] = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $args['choices']['step'] = filter_var( $args['choices']['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); } return $args; } } src/Field/URL.php000064400000002071150544620010007526 0ustar00args['settings'] ) { $args = parent::filter_setting_args( $args, $wp_customize ); // Set the sanitize-callback if none is defined. if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { $args['sanitize_callback'] = 'esc_url_raw'; } } return $args; } } src/Control/Generic.php000064400000005426150544620010011044 0ustar00
<# element = ( data.choices.element ) ? data.choices.element : 'input'; #> <# if ( 'textarea' === element ) { #> <# } else { #> <{{ element }} {{{ data.inputAttrs }}} value="{{ data.value }}" {{ data.link.replace(/"/g, '') }} <# if ( ! data.choices.id ) { #> id="{{'customize-input-' + data.id}}" <# } #> <# _.each( data.choices, function( val, key ) { #> {{ key }}="{{ val }}" <# } ); #> <# if ( data.choices.content ) { #>>{{{ data.choices.content }}}<# } else { #>/><# } #> <# } #>
params.choices.max) { value = params.choices.max; } } control.setting.set(value); }); }, }); composer.json000064400000001273150544620010007266 0ustar00{ "name": "kirki-framework/control-generic", "type": "library", "description": "Generic control for the Kirki Customizer framework.", "keywords": [ "wordpress", "customizer", "framework" ], "homepage": "https://kirki.org", "license": "MIT", "authors": [ { "name": "Kirki Framework", "email": "connect@mapsteps.com" } ], "require": { "php": ">=7.0", "kirki-framework/url-getter": "*", "kirki-framework/control-base": "*" }, "autoload": { "psr-4": { "Kirki\\Control\\": "src/Control", "Kirki\\Field\\": "src/Field" } } } LICENSE000064400000002060150544620010005544 0ustar00MIT License Copyright (c) 2019 kirki-framework Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.