From 740788640a08f77d00ea0715ca118d58bbba2ce8 Mon Sep 17 00:00:00 2001 From: Aristeides Stathopoulos Date: Wed, 29 Nov 2017 19:40:48 +0200 Subject: [PATCH] void -> null See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1240#issuecomment-347910229 --- controls/class-kirki-controls.php | 2 +- controls/js/dist/script-legacy.js | 48 +++++++++++++-------------- controls/js/dist/script-legacy.min.js | 2 +- controls/js/dist/script.js | 48 +++++++++++++-------------- controls/js/dist/script.min.js | 2 +- controls/js/src/dynamic-control.js | 12 +++---- controls/js/src/kirki.js | 36 ++++++++++---------- core/class-kirki-init.php | 10 +++--- docs/docs/controls/custom.md | 2 +- docs/docs/controls/preset.md | 2 +- docs/files/class-my-theme-kirki.php | 6 ++-- lib/class-aricolor.php | 10 +++--- modules/css/class-kirki-output.php | 2 +- 13 files changed, 91 insertions(+), 91 deletions(-) diff --git a/controls/class-kirki-controls.php b/controls/class-kirki-controls.php index 4dcf860fb..e34f8e601 100644 --- a/controls/class-kirki-controls.php +++ b/controls/class-kirki-controls.php @@ -57,7 +57,7 @@ public function __construct() { * * @access public * @since 3.0.17 - * @return void + * @return null */ public function underscore_templates() { foreach ( $this->templates as $template ) { diff --git a/controls/js/dist/script-legacy.js b/controls/js/dist/script-legacy.js index 2deb76c9f..3909a5e96 100644 --- a/controls/js/dist/script-legacy.js +++ b/controls/js/dist/script-legacy.js @@ -217,7 +217,7 @@ var kirki = { * Initialize the object. * * @since 3.0.17 - * @returns {void} + * @returns {null} */ initialize: function() { var self = this; @@ -252,7 +252,7 @@ var kirki = { * * @since 3.0.17 * @param {Object} control - The customizer control object. - * @returns {void} + * @returns {null} */ init: function( control ) { var self = this; @@ -277,7 +277,7 @@ var kirki = { * @param {string} control.params.default - The default value. * @param {Object} control.params.choices - Any extra choices we may need. * @param {string} control.id - The setting. - * @returns {void} + * @returns {null} */ template: function( control ) { var template = wp.template( 'kirki-input-radio' ); @@ -305,7 +305,7 @@ var kirki = { * * @since 3.0.16 * @param {Object} control - The customizer control object. - * @returns {void} + * @returns {null} */ init: function( control ) { var self = this; @@ -335,7 +335,7 @@ var kirki = { * @param {Object} control.params.choices - Any extra choices we may need. * @param {boolean} control.params.choices.alpha - should we add an alpha channel? * @param {string} control.id - The setting. - * @returns {void} + * @returns {null} */ template: function( control ) { var template = wp.template( 'kirki-input-color' ); @@ -368,7 +368,7 @@ var kirki = { * @param {Object} control.params - Control parameters. * @param {Object} control.params.choices - Define the specifics for this input. * @param {string} control.params.choices.element - The HTML element we want to use ('input', 'div', 'span' etc). - * @returns {void} + * @returns {null} */ init: function( control ) { var self = this; @@ -397,7 +397,7 @@ var kirki = { * @param {Object} control.params.choices - Any extra choices we may need. * @param {boolean} control.params.choices.alpha - should we add an alpha channel? * @param {string} control.id - The setting. - * @returns {void} + * @returns {null} */ template: function( control ) { var args = { @@ -427,7 +427,7 @@ var kirki = { * * @since 3.0.17 * @param {Object} control - The customizer control object. - * @returns {void} + * @returns {null} */ init: function( control ) { var self = this; @@ -451,7 +451,7 @@ var kirki = { * @param {Object} control.params.default - The default value. * @param {Object} control.params.choices - The choices for the select dropdown. * @param {string} control.id - The setting. - * @returns {void} + * @returns {null} */ template: function( control ) { var template = wp.template( 'kirki-input-select' ); @@ -489,7 +489,7 @@ var kirki = { * @since 3.0.17 * @param {Object} control - The control object. * @param {Object} control.id - The setting. - * @returns {void} + * @returns {null} */ init: function( control ) { var input = jQuery( 'input[data-id="' + control.id + '"]' ); @@ -518,7 +518,7 @@ var kirki = { * @param {Object} control.params - Control parameters. * @param {Object} control.params.choices - alias for control.choices. - * @returns {void} + * @returns {null} */ init: function( control ) { var picker = jQuery( '.kirki-color-control[data-id="' + control.id + '"]' ), @@ -570,7 +570,7 @@ var kirki = { * @since 3.0.17 * @param {Object} control - The control object. * @param {Object} control.id - The setting. - * @returns {void} + * @returns {null} */ init: function( control ) { var input = jQuery( 'input[data-id="' + control.id + '"]' ); @@ -595,7 +595,7 @@ var kirki = { * @since 3.0.17 * @param {Object} control - The control object. * @param {Object} control.id - The setting. - * @returns {void} + * @returns {null} */ init: function( control ) { var textarea = jQuery( 'textarea[data-id="' + control.id + '"]' ); @@ -615,7 +615,7 @@ var kirki = { * @since 3.0.17 * @param {Object} control - The control object. * @param {Object} control.id - The setting. - * @returns {void} + * @returns {null} */ init: function( control ) { var element = jQuery( 'select[data-id="' + control.id + '"]' ), @@ -703,7 +703,7 @@ var kirki = { * * @since 3.0.17 * @param {Object} control - The control object. - * @returns {void} + * @returns {null} */ init: function( control ) { } @@ -774,7 +774,7 @@ var kirki = { * @param {mixed} value - Depends on the control-type. * @param {string} key - If we only want to save an item in an object * we can define the key here. - * @returns {void} + * @returns {null} */ set: function( element, value, key ) { var setting, @@ -894,7 +894,7 @@ var kirki = { * Init for google-fonts. * * @since 3.0.17 - * @returns {void} + * @returns {null} */ initialize: function() { var self = this; @@ -906,7 +906,7 @@ var kirki = { * Set fonts in this.fonts * * @since 3.0.17 - * @returns {void} + * @returns {null} */ setFonts: function() { var self = this, @@ -1044,7 +1044,7 @@ kirki.initialize(); * should be changed in Core to be applied once the control is embedded. * * @private - * @returns {void} + * @returns {null} */ _setUpSettingRootLinks: function() { var control = this, @@ -1066,7 +1066,7 @@ kirki.initialize(); * Add bidirectional data binding links between inputs and the setting properties. * * @private - * @returns {void} + * @returns {null} */ _setUpSettingPropertyLinks: function() { var control = this, @@ -1127,7 +1127,7 @@ kirki.initialize(); * so that the control isn't embedded on load, * unless the containing section is already expanded. * - * @returns {void} + * @returns {null} */ embed: function() { var control = this, @@ -1156,7 +1156,7 @@ kirki.initialize(); * This function is called in Section.onChangeExpanded() so the control * will only get embedded when the Section is first expanded. * - * @returns {void} + * @returns {null} */ actuallyEmbed: function() { var control = this; @@ -1171,7 +1171,7 @@ kirki.initialize(); * This is not working with autofocus. * * @param {object} [args] Args. - * @returns {void} + * @returns {null} */ focus: function( args ) { var control = this; @@ -1183,7 +1183,7 @@ kirki.initialize(); * Additional actions that run on ready. * * @param {object} [args] Args. - * @returns {void} + * @returns {null} */ initKirkiControl: function( control ) { if ( 'undefined' !== typeof kirki.control[ control.params.type ] ) { diff --git a/controls/js/dist/script-legacy.min.js b/controls/js/dist/script-legacy.min.js index 4db142461..9824ca16d 100644 --- a/controls/js/dist/script-legacy.min.js +++ b/controls/js/dist/script-legacy.min.js @@ -1 +1 @@ -if(_.isUndefined(window.kirkiSetSettingValue))var kirkiSetSettingValue={set:function(e,t){var i,n=this,a=wp.customize.settings.controls[e];if(_.isUndefined(a))return!0;switch(n.setValue(e,t),a.type){case"kirki-background":_.isUndefined(t["background-color"])||n.setColorPicker(n.findElement(e,".kirki-color-control"),t["background-color"]),n.findElement(e,".placeholder, .thumbnail").removeClass().addClass("placeholder").html("No file selected"),_.each(["background-repeat","background-position"],function(i){_.isUndefined(t[i])||n.setSelectWoo(n.findElement(e,"."+i+" select"),t[i])}),_.each(["background-size","background-attachment"],function(i){jQuery(n.findElement(e,"."+i+' input[value="'+t+'"]')).prop("checked",!0)}),i=JSON.stringify(t).replace(/'/g,"'"),jQuery(n.findElement(e,".background-hidden-value").attr("value",i)).trigger("change");break;case"kirki-code":jQuery(n.findElement(e,".CodeMirror"))[0].CodeMirror.setValue(t);break;case"checkbox":case"kirki-switch":case"kirki-toggle":t=1===t||"1"===t||!0===t,jQuery(n.findElement(e,"input")).prop("checked",t),wp.customize.instance(e).set(t);break;case"kirki-select":case"kirki-preset":case"kirki-fontawesome":n.setSelectWoo(n.findElement(e,"select"),t);break;case"kirki-slider":jQuery(n.findElement(e,"input")).prop("value",t),jQuery(n.findElement(e,".kirki_range_value .value")).html(t);break;case"kirki-generic":(_.isUndefined(a.choices)||_.isUndefined(a.choices.element))&&(a.choices.element="input"),jQuery(n.findElement(e,a.choices.element)).prop("value",t);break;case"kirki-color":n.setColorPicker(n.findElement(e,".kirki-color-control"),t);break;case"kirki-multicheck":n.findElement(e,"input").each(function(){jQuery(this).prop("checked",!1)}),_.each(t,function(i,a){jQuery(n.findElement(e,'input[value="'+t[a]+'"]')).prop("checked",!0)});break;case"kirki-multicolor":_.each(t,function(t,i){n.setColorPicker(n.findElement(e,".multicolor-index-"+i),t)});break;case"kirki-radio-buttonset":case"kirki-radio-image":case"kirki-radio":case"kirki-dashicons":case"kirki-color-palette":case"kirki-palette":jQuery(n.findElement(e,'input[value="'+t+'"]')).prop("checked",!0);break;case"kirki-typography":_.each(["font-family","variant","subsets"],function(i){_.isUndefined(t[i])||n.setSelectWoo(n.findElement(e,"."+i+" select"),t[i])}),_.each(["font-size","line-height","letter-spacing","word-spacing"],function(i){_.isUndefined(t[i])||jQuery(n.findElement(e,"."+i+" input")).prop("value",t[i])}),_.isUndefined(t.color)||n.setColorPicker(n.findElement(e,".kirki-color-control"),t.color),i=JSON.stringify(t).replace(/'/g,"'"),jQuery(n.findElement(e,".typography-hidden-value").attr("value",i)).trigger("change");break;case"kirki-dimensions":_.each(t,function(t,i){jQuery(n.findElement(e,"."+i+" input")).prop("value",t)});break;case"kirki-repeater":case"kirki-custom":break;default:jQuery(n.findElement(e,"input")).prop("value",t)}},setColorPicker:function(e,t){e.attr("data-default-color",t).data("default-color",t).wpColorPicker("color",t)},setSelectWoo:function(e,t){jQuery(e).selectWoo().val(t).trigger("change")},setTextarea:function(e,t){jQuery(e).prop("value",t)},findElement:function(e,t){return wp.customize.control(e).container.find(t)},setValue:function(e,t,i){i=_.isUndefined(i)?100:parseInt(i,10),wp.customize.instance(e).set({}),setTimeout(function(){wp.customize.instance(e).set(t)},i)}};var kirki={initialized:!1,initialize:function(){var e=this;e.initialized||(e.util.webfonts.google.initialize(),e.initialized=!0)},control:{"kirki-radio":{init:function(e){this.template(e),kirki.input.radio.init(e)},template:function(e){var t=wp.template("kirki-input-radio");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,default:e.params.default,value:kirki.setting.get(e.id),choices:e.params.choices}))}},"kirki-color":{init:function(e){this.template(e),kirki.input.color.init(e)},template:function(e){var t=wp.template("kirki-input-color");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,mode:e.params.mode,inputAttrs:e.params.inputAttrs,"data-palette":e.params.palette,"data-default-color":e.params.default,"data-alpha":e.params.choices.alpha,value:kirki.setting.get(e.id)}))}},"kirki-generic":{init:function(e){this.template(e),_.isUndefined(e.params)||_.isUndefined(e.params.choices)||_.isUndefined(e.params.choices.element)||"textarea"!==e.params.choices.element?kirki.input.genericInput.init(e):kirki.input.textarea.init(e)},template:function(e){var t,i={label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id)};if(!_.isUndefined(e.params)&&!_.isUndefined(e.params.choices)&&!_.isUndefined(e.params.choices.element)&&"textarea"===e.params.choices.element)return t=wp.template("kirki-input-textarea"),void e.container.html(t(i));t=wp.template("kirki-input-generic"),e.container.html(t(i))}},"kirki-select":{init:function(e){this.template(e),kirki.input.select.init(e)},template:function(e){var t=wp.template("kirki-input-select");e.container.html(t({label:e.params.label,description:e.params.description,"data-id":e.id,inputAttrs:e.params.inputAttrs,choices:e.params.choices,value:kirki.setting.get(e.id),multiple:e.params.multiple||1}))}}},input:{radio:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},color:{init:function(e){var t,i=jQuery('.kirki-color-control[data-id="'+e.id+'"]');e.choices=e.choices||{},_.isEmpty(e.choices)&&e.params.choices&&(e.choices=e.params.choices),_.isEmpty(e.choices)||i.wpColorPicker(e.choices),setTimeout(function(){(t=jQuery('.kirki-input-container[data-id="'+e.id+'"] .wp-picker-clear')).length&&t.click(function(){kirki.setting.set(e.id,"")})},200),i.wpColorPicker({change:function(){setTimeout(function(){kirki.setting.set(e.id,i.val())},20)}})}},genericInput:{init:function(e){jQuery('input[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},textarea:{init:function(e){jQuery('textarea[data-id="'+e.id+'"]').on("change keyup paste click",function(){kirki.setting.set(e.id,jQuery(this).val())})}},select:{init:function(e){var t,i=jQuery('select[data-id="'+e.id+'"]'),n=parseInt(i.data("multiple"),10),a={escapeMarkup:function(e){return e}};1",e.label&&(i+=''+e.label+""),e.description&&(i+=''+e.description+""),i+="",i+='
',e.value.url||""!==t?i+='
':i+='
'+kirkiL10n.noFileSelected+"
",i+='
',i+='",e.default&&""!==e.default&&(i+='",i+="
",'
'+i+"
"},init:function(e){}}},setting:{get:function(e){var t=e.split("["),i="",n=0,a="";return _.each(t,function(e,t){e=e.replace("]",""),0===t?i=e:i+="["+e+"]",_.isUndefined(wp.customize.instance(i))||(a=wp.customize.instance(i).get(),n=t),n"),n.params.content.attr("id","customize-control-"+e.replace(/]/g,"").replace(/\[/g,"-")),n.params.content.attr("class","customize-control customize-control-"+n.params.type)),i.propertyElements=[],wp.customize.Control.prototype.initialize.call(i,e,n)},_setUpSettingRootLinks:function(){var e=this;e.container.find("[data-customize-setting-link]").each(function(){var t=jQuery(this);wp.customize(t.data("customizeSettingLink"),function(i){var n=new wp.customize.Element(t);e.elements.push(n),n.sync(i),n.set(i())})})},_setUpSettingPropertyLinks:function(){var e=this;e.setting&&e.container.find("[data-customize-setting-property-link]").each(function(){var t,i=jQuery(this),n=i.data("customizeSettingPropertyLink");t=new wp.customize.Element(i),e.propertyElements.push(t),t.set(e.setting()[n]),t.bind(function(t){var i=e.setting();t!==i[n]&&((i=_.clone(i))[n]=t,e.setting.set(i))}),e.setting.bind(function(e){e[n]!==t.get()&&t.set(e[n])})})},ready:function(){var e=this;e._setUpSettingRootLinks(),e._setUpSettingPropertyLinks(),wp.customize.Control.prototype.ready.call(e),e.deferred.embedded.done(function(){e.initKirkiControl(e)})},embed:function(){var e=this,t=e.section();t&&wp.customize.section(t,function(t){"kirki-expanded"===t.params.type||t.expanded()||wp.customize.settings.autofocus.control===e.id?e.actuallyEmbed():t.expanded.bind(function(t){t&&e.actuallyEmbed()})})},actuallyEmbed:function(){var e=this;"resolved"!==e.deferred.embedded.state()&&(e.renderContent(),e.deferred.embedded.resolve())},focus:function(e){var t=this;t.actuallyEmbed(),wp.customize.Control.prototype.focus.call(t,e)},initKirkiControl:function(e){void 0===kirki.control[e.params.type]?this.container.on("change keyup paste click","input",function(){e.setting.set(jQuery(this).val())}):kirki.control[e.params.type].init(e)},kirkiValidateCSSValue:function(e){var t,i,n=["rem","em","ex","%","px","cm","mm","in","pt","pc","ch","vh","vw","vmin","vmax"];return"0"===e||0<=e.indexOf("calc(")&&0<=e.indexOf(")")||("auto"===e||"inherit"===e||"initial"===e||(t=parseFloat(e),i=e.replace(t,""),!isNaN(t)&&-1!==jQuery.inArray(i,n)))}})}(),_.each(kirki.control,function(e,t){wp.customize.controlConstructor[t]=wp.customize.kirkiDynamicControl.extend({})}),wp.customize.controlConstructor["kirki-background"]=wp.customize.Control.extend({ready:function(){"use strict";var e=this;!_.isUndefined(window.kirkiControlLoader)&&_.isFunction(kirkiControlLoader)?kirkiControlLoader(e):e.initKirkiControl()},initKirkiControl:function(){var e=this,t=e.getValue(),i=e.container.find(".kirki-color-control");(_.isUndefined(t["background-image"])||""===t["background-image"])&&(e.container.find(".background-wrapper > .background-repeat").hide(),e.container.find(".background-wrapper > .background-position").hide(),e.container.find(".background-wrapper > .background-size").hide(),e.container.find(".background-wrapper > .background-attachment").hide()),i.wpColorPicker({change:function(){setTimeout(function(){e.saveValue("background-color",i.val())},100)}}),e.container.on("change",".background-repeat select",function(){e.saveValue("background-repeat",jQuery(this).val())}),e.container.on("change click",".background-size input",function(){e.saveValue("background-size",jQuery(this).val())}),e.container.on("change",".background-position select",function(){e.saveValue("background-position",jQuery(this).val())}),e.container.on("change click",".background-attachment input",function(){e.saveValue("background-attachment",jQuery(this).val())}),e.container.on("click",".background-image-upload-button",function(t){var i=wp.media({multiple:!1}).open().on("select",function(){var t,n,a,r=i.state().get("selection").first(),o=r.toJSON().sizes.full.url;_.isUndefined(r.toJSON().sizes.medium)?_.isUndefined(r.toJSON().sizes.thumbnail)||(o=r.toJSON().sizes.thumbnail.url):o=r.toJSON().sizes.medium.url,t=r.toJSON().sizes.full.url,r.toJSON().id,r.toJSON().width,r.toJSON().height,""!==t&&e.container.find(".background-wrapper > .background-repeat, .background-wrapper > .background-position, .background-wrapper > .background-size, .background-wrapper > .background-attachment").show(),e.saveValue("background-image",t),n=e.container.find(".placeholder, .thumbnail"),a=e.container.find(".background-image-upload-remove-button"),n.length&&n.removeClass().addClass("thumbnail thumbnail-image").html(''),a.length&&a.show()});t.preventDefault()}),e.container.on("click",".background-image-upload-remove-button",function(t){var i,n;t.preventDefault(),e.saveValue("background-image",""),i=e.container.find(".placeholder, .thumbnail"),n=e.container.find(".background-image-upload-remove-button"),e.container.find(".background-wrapper > .background-repeat").hide(),e.container.find(".background-wrapper > .background-position").hide(),e.container.find(".background-wrapper > .background-size").hide(),e.container.find(".background-wrapper > .background-attachment").hide(),i.length&&i.removeClass().addClass("placeholder").html("No file selected"),n.length&&n.hide()})},getValue:function(){var e=this,t={};return _.each(e.params.default,function(i,n){!1!==i&&(t[n]=i,_.isUndefined(e.setting._value[n])||(t[n]=e.setting._value[n]))}),_.each(e.setting._value,function(e,i){_.isUndefined(t[i])&&(t[i]=e)}),t},saveValue:function(e,t){"use strict";var i=this,n=jQuery("#customize-control-"+i.id.replace("[","-").replace("]","")+" .background-hidden-value"),a=jQuery(n).val(),r=JSON.parse(a);r[e]=t,i.setting.set(r),jQuery(n).attr("value",JSON.stringify(r)).trigger("change")}}),wp.customize.controlConstructor["kirki-code"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this;_.isUndefined(wp.customize.CodeEditorControl)||(jQuery(e.container.find("textarea.kirki-codemirror-editor")).hide(),wp.customize.control.add(new wp.customize.CodeEditorControl(e.id,{section:e.params.section,priority:e.params.priority,label:e.params.label,editor_settings:{codemirror:{mode:e.params.choices.language}},settings:{default:e.id}})))}}),wp.customize.controlConstructor["kirki-color-palette"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-dashicons"]=wp.customize.kirkiDynamicControl.extend({}),wp.customize.controlConstructor["kirki-date"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e=this;_.isUndefined(wp.customize.DateTimeControl)||wp.customize.control.add(new wp.customize.DateTimeControl(e.id,{section:e.params.section,priority:e.params.priority,label:e.params.label,description:e.params.description,settings:{default:e.id},default:e.params.default}))}}),wp.customize.controlConstructor["kirki-dimension"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this;t.kirkiNotifications(),this.container.on("change keyup paste","input",function(){e=jQuery(this).val(),t.setting.set(e)})},kirkiNotifications:function(){var e=this;wp.customize(e.id,function(t){t.bind(function(i){var n="long_title";!1===e.kirkiValidateCSSValue(i)?t.notifications.add(n,new wp.customize.Notification(n,{type:"warning",message:dimensionkirkiL10n["invalid-value"]})):t.notifications.remove(n)})})}}),wp.customize.controlConstructor["kirki-dimensions"]=wp.customize.kirkiDynamicControl.extend({initKirkiControl:function(){var e,t=this,i=t.params.choices.controls,n={},a=[];for(_.each(i,function(e,t){!0===e&&a.push(t)}),e=0;e