diff --git a/.gitattributes b/.gitattributes index 4548d6a380..8fab98e88c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,6 +18,7 @@ Gruntfile.js export-ignore package.json export-ignore package-lock.json export-ignore phpcs.ruleset.xml export-ignore +phpcs.xml export-ignore phpcs.xml.dist export-ignore phpunit.xml export-ignore phpunit.xml.dist export-ignore @@ -29,6 +30,7 @@ translations.pot export-ignore # Folders /.circleci export-ignore /.github export-ignore +/.husky export-ignore /.idea export-ignore /.tx export-ignore /assets/css/scss export-ignore diff --git a/.gitignore b/.gitignore index 508593ad96..2daa7332fe 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ docs/html docker-compose.yml docker-unit-tests.sh phpunit +phpunit.xml wordpress-51-tests-lib wordpress-latest-tests-lib diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..d24fdfc601 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/assets/js/admin-views.js b/assets/js/admin-views.js index 0c87883fa2..59d884a2a5 100644 --- a/assets/js/admin-views.js +++ b/assets/js/admin-views.js @@ -103,8 +103,8 @@ // Start by showing/hiding on load vcfg.toggleInitialVisibility( vcfg ); - // Start bind to $('body') - $( 'body' ) + // Start bind to $( document.body ) + $( document.body ) // Track modifier keys being clicked .on( 'keydown keyup', vcfg.altKeyListener ) @@ -205,7 +205,7 @@ $.cookie( 'warning-dismissed-' + warning_name, 1, { path: gvGlobals.admin_cookiepath } ); - $( 'body' ).trigger( 'gravityview/tabs-ready' ); + $( document.body ).trigger( 'gravityview/tabs-ready' ); }) .on( 'gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated', vcfg.toggleTabConfigurationWarnings ) @@ -242,7 +242,7 @@ } $( this ).parent( '.gv-fields' ).removeClass( 'trigger--active' ); }); - // End bind to $('body') + // End bind to $( document.body ) $( window ).resize( function() { @@ -588,7 +588,7 @@ parent.find( '.gv-field-controls .dashicons-media-default' ).toggleClass( 'hide-if-js', $( e.target ).not( ':checked' ) ); - $( 'body' ).trigger( 'gravityview/show-as-entry', $( e.target ).is( ':checked' ) ); + $( document.body ).trigger( 'gravityview/show-as-entry', $( e.target ).is( ':checked' ) ); }, /** @@ -914,7 +914,7 @@ vcfg.currentTemplateId = ''; vcfg.currentFormId = vcfg.gvSelectForm.val(); vcfg.setUnsavedChanges( true ); - $( 'body' ).trigger( 'gravityview_form_change' ).addClass( 'gv-form-changed' ); + $( document.body ).trigger( 'gravityview_form_change' ).addClass( 'gv-form-changed' ); }, showDialog: function ( dialogSelector, buttons ) { @@ -1040,7 +1040,7 @@ } ); } - $( 'body' ).trigger( 'gravityview/dialog-closed', thisDialog ); + $( document.body ).trigger( 'gravityview/dialog-closed', thisDialog ); }, closeOnEscape: true, buttons: buttons @@ -1116,7 +1116,7 @@ $( '#' + editorId ).autocomplete( 'close' ); }; - $( 'body' ).on( 'keyup', function ( e ) { + $( document.body ).on( 'keyup', function ( e ) { if ( $autocompleteEl.is( ':visible' ) && 27 === e.which ) { e.preventDefault(); closeAutocompletion(); @@ -1674,7 +1674,7 @@ * @since 2.10 * @param {object} JSON response with `header` `footer` (widgets) `directory` and `single` (contexts) properties */ - $( 'body' ).trigger( 'gravityview/view-config-updated', content ); + $( document.body ).trigger( 'gravityview/view-config-updated', content ); } resolve(); @@ -2002,7 +2002,7 @@ // append the new field to the active drop $( '[data-tooltip-id="' + areaId + '"]' ).parents( '.gv-droppable-area' ).find( '.active-drop' ).append( newField ).end().attr( 'data-tooltip-id', '' ); - $('body').trigger( 'gravityview/field-added', newField ); + $( document.body ).trigger( 'gravityview/field-added', newField ); // Show the new field newField.fadeIn( 100 ); @@ -2063,7 +2063,7 @@ } // Only init merge tags if the View has been saved and the form hasn't been changed. - if ( 'undefined' !== typeof( form ) && $( 'body' ).not( '.gv-form-changed' ) && $merge_tag_supported.length >= 0 ) { + if ( 'undefined' !== typeof( form ) && $( document.body ).not( '.gv-form-changed' ) && $merge_tag_supported.length >= 0 ) { if ( window.gfMergeTags ) { @@ -2236,7 +2236,7 @@ $( this ).remove(); - $('body').trigger( 'gravityview/field-removed', $( this ) ); + $( document.body ).trigger( 'gravityview/field-removed', $( this ) ); vcfg.toggleDropMessage(); } ); @@ -2271,7 +2271,7 @@ $( area ).find( '.gv-fields' ).remove(); - $('body').trigger( 'gravityview/all-fields-removed' ); + $( document.body ).trigger( 'gravityview/all-fields-removed' ); viewConfiguration.toggleDropMessage(); }, @@ -2306,7 +2306,7 @@ vcfg.updateVisibilitySettings( e, true ); // Toggle checkbox when changing field visibility - $( 'body' ).on( 'change', '.gv-fields input[type=checkbox]', vcfg.updateVisibilitySettings ); + $( document.body ).on( 'change', '.gv-fields input[type=checkbox]', vcfg.updateVisibilitySettings ); var buttons = [ { @@ -2571,7 +2571,7 @@ .on('change', viewGeneralSettings.updateSettingsDisplay ) .trigger('change'); - $('body') + $( document.body ) // Enable a setting tab (since 1.8) .on('gravityview/settings/tab/enable', viewGeneralSettings.enableSettingTab ) @@ -2730,7 +2730,7 @@ * * I tried setTimeout; it didn't work. * - * I tried moving window.gvAdminActions and $( 'body' ).trigger( 'gravityview/loaded' ); + * I tried moving window.gvAdminActions and $( document.body ).trigger( 'gravityview/loaded' ); * outside of this function; it didn't work. * * This probably needs to stay here until we rewrite this beast. @@ -2777,7 +2777,7 @@ viewConfiguration.init_droppables( ui.panel ); /** @since 2.14.1 */ - $( 'body' ) + $( document.body ) .trigger( 'gravityview/tab-ready', ui.panel ) .trigger( 'gravityview/tabs-ready' ); }, @@ -2788,7 +2788,7 @@ viewConfiguration.init_droppables( ui.newPanel ); /** @since 2.14.1 */ - $( 'body' ).trigger( 'gravityview/tab-ready', ui.newPanel ); + $( document.body ).trigger( 'gravityview/tab-ready', ui.newPanel ); } } ); @@ -2799,7 +2799,7 @@ showDialog: viewConfiguration.showDialog }; - $( 'body' ).trigger( 'gravityview/loaded' ); + $( document.body ).trigger( 'gravityview/loaded' ); } ); }(jQuery)); diff --git a/assets/js/admin-views.min.js b/assets/js/admin-views.min.js index 5291f08087..fe3b1d60f8 100644 --- a/assets/js/admin-views.min.js +++ b/assets/js/admin-views.min.js @@ -1 +1 @@ -!function($){var viewConfiguration,viewGeneralSettings;$.widget.bridge("gvTooltip",$.ui.tooltip),viewConfiguration={startFreshStatus:!1,hasUnsavedChanges:!1,altKey:!1,dialogWidth:750,performingAjaxAction:!1,init:function(){var vcfg=viewConfiguration;vcfg.gvSelectForm=$("#gravityview_form_id"),vcfg.gvSwitchView=$("#gv_switch_view_button"),vcfg.currentFormId=vcfg.gvSelectForm.val(),vcfg.currentTemplateId=$("#gravityview_directory_template").val(),vcfg.directAccessSelect=$("#gv-direct-access-select"),vcfg.toggleInitialVisibility(vcfg),$("body").on("keydown keyup",vcfg.altKeyListener).on("change","#gravityview_form_id",vcfg.formChange).on("click",'a[href="#gv_start_fresh"]',vcfg.startFresh).on("click","#publish, #save-post",vcfg.processFormSubmit).on("submit","#post",vcfg.processFormSubmit).on("click",".gv-view-types-hover",vcfg.selectTemplateHover).on("click","a[rel*=external]",vcfg.openExternalLinks).on("click mouseup keyup",vcfg.closeTooltips).on("click",'.gv-field-filter-form span[role="button"]',vcfg.switchTooltipLayout).on("click","#gv_switch_view_button",vcfg.switchView).on("click",".clear-all-fields",vcfg.removeAllFields).on("click",".gv_select_template",vcfg.selectTemplate).on("click",".ui-tooltip-content .gv-fields",vcfg.startAddField).on("click",".gv-shortcode input",vcfg.selectText).on("click","#gv-direct-access .edit-direct-access",vcfg.editDirectAccess).on("click","#gv-direct-access-select .cancel-direct-access",vcfg.cancelDirectAccess).on("click","#gv-direct-access-select .save-direct-access",vcfg.updateDirectAccess).on("gravityview_form_change",vcfg.updateFormLinks).on("gravityview_form_change",vcfg.updateWidgetFormIds).on("change",".gv-dialog-options input[name*=show_as_link]",vcfg.toggleShowAsEntry).on("change",".gv-dialog-options input[name*=only_loggedin]",vcfg.toggleCustomVisibility).on("change",".gv-dialog-options [name*=allow_edit_cap]",vcfg.toggleCustomVisibility).on("click",".gv-field-controls .gv-remove-field",vcfg.removeField).on("click",".gv-field-controls .gv-field-settings",vcfg.openFieldSettings).on("dblclick",".gv-fields:not(.gv-nonexistent-form-field)",vcfg.openFieldSettings).on("change","#gravityview_settings",vcfg.zebraStripeSettings).on("click",".gv-field-details--toggle",function(e){var $dialog=$(this).parents(".ui-dialog"),was_closed=$(".gv-field-details",$dialog).hasClass("gv-field-details--closed");return viewConfiguration.toggleFieldDetails($dialog,was_closed),$.cookie("gv-field-details-expanded",was_closed,{path:gvGlobals.admin_cookiepath}),!1}).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("click",".gv-section .is-dismissible .notice-dismiss",function(e){var warning_name=$(this).parents(".gv-section").attr("id")+"-"+$("#post_ID").val();$.cookie("warning-dismissed-"+warning_name,1,{path:gvGlobals.admin_cookiepath}),$("body").trigger("gravityview/tabs-ready")}).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleTabConfigurationWarnings).on("gravityview/loaded gravityview/tabs-ready gravityview/field-added gravityview/field-removed gravityview/all-fields-removed gravityview/show-as-entry gravityview/view-config-updated",vcfg.toggleRemoveAllFields).on("search keydown keyup",".gv-field-filter-form input:visible",vcfg.setupFieldFilters).on("gravityview/loaded",function(){$(".gv-setting-list, #gravityview_settings").on("change",vcfg.toggleCheckboxes)}).on("change",".gv-dialog-options",vcfg.toggleCheckboxes).on("focus",".gv-add-field",function(e){$(this).parent(".gv-fields").addClass("trigger--hover")}).on("blur",".gv-add-field",function(e){$(this).parent(".gv-fields").removeClass("trigger--hover")}).on("keydown",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").addClass("trigger--active")}).on("keyup",".gv-add-field",function(e){return 13!==e.keyCode&&32!==e.keyCode||void $(this).parent(".gv-fields").removeClass("trigger--active")}),$(window).resize(function(){var $open_dialog=$(".ui-dialog:visible").find(".ui-dialog-content");$open_dialog.dialog("option","position",{my:"center",at:"center",of:window});var window_width=vcfg.dialogWidth,ninety_five_per=.95*$(window).width();vcfg.dialogWidth>ninety_five_per&&(window_width=ninety_five_per),$open_dialog.dialog("option","width",window_width)}),window.addEventListener("beforeunload",event=>{vcfg.hasUnsavedChanges&&event.preventDefault()}),gvGlobals.passed_form_id&&vcfg.gvSelectForm.trigger("change");var _sendToEditor=window.send_to_editor;window.send_to_editor=function(val){var cursorPosition=$("#"+window.wpActiveEditor);if(!cursorPosition.hasClass("codemirror")&&_sendToEditor)return _sendToEditor(val);var codeMirror=cursorPosition.next(".CodeMirror")[0].CodeMirror,cursorPosition=codeMirror.getCursor();codeMirror.replaceRange(val,window.wp.CodeMirror.Pos(cursorPosition.line,cursorPosition.ch))},$("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor)},getCookieVal:function(cookie){return!(!cookie||"undefined"===cookie||"false"===cookie)&&cookie},toggleTabConfigurationWarnings:function(e){var tabs={single:{configured:$(".gv-dialog-options input[name*=show_as_link]:checked","#directory-active-fields").length||$('[data-fieldid="entry_link"]',"#directory-active-fields").length,icon:"dashicons-media-default"},edit:{configured:$('.gv-fields .field-key[value="edit_link"]').length,icon:"dashicons-welcome-write-blog"}};$.each(tabs,function(index,value){var show_warning=index+"-fields-"+$("#post_ID").val(),show_warning=!viewConfiguration.getCookieVal($.cookie("warning-dismissed-"+show_warning))&&0===value.configured;$("#"+index+"-fields").find(".notice-warning").toggle(show_warning),$('li[aria-controls="'+index+'-view"]').toggleClass("tab-not-configured",show_warning).find(".tab-icon").toggleClass("dashicons-warning",show_warning).toggleClass(value.icon,!show_warning)})},altKeyListener:function(e){viewConfiguration.altKey=e.altKey},zebraStripeSettings:function(){jQuery("#gravityview_settings").find("table").each(function(){$trs=$(this).find("tr").not('[style="display: none;"]'),$trs.removeClass("alternate"),$trs.filter(":even").addClass("alternate")})},toggleCheckboxes:function($parent){$parent=$parent.currentTarget||$parent;viewConfiguration.toggleRequired($parent,"requires",!1),viewConfiguration.toggleRequired($parent,"requires-not",!0);$parent=$($parent).is(".gv-fields")?$($parent):$($parent).parents(".gv-fields");$parent.length&&(viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_to_]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)),viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_phone]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)))},toggleDisabled:function($one,$two){0!==$one.length&&0!==$two.length&&($one.is(":checked")?$two.prop("disabled",!0):$two.is(":checked")&&$one.prop("disabled",!0))},toggleRequired:function(currentTarget,data_attr,reverse_logic){var $parent=$(currentTarget,"#post");$parent.find("[data-"+data_attr+"]").each(function(){var $this=$(this),requires_value=$this.data(data_attr).split("="),$input=requires_value[0],requires_value=requires_value[1],$input=$parent.find('[name$="['+$input+']"]').filter(":input");$input.is("[type=checkbox]")?reverse_logic?$this.toggle($input.not(":checked")):$this.toggle($input.is(":checked")):void 0!==requires_value&&(reverse_logic?$this.toggle($input.val()!==requires_value):$this.toggle($input.val()===requires_value))})},switchTooltipLayout:function(e){var layout=$(this).data("value");viewConfiguration.setTooltipLayout(layout)},setTooltipLayout:function(layout){$(".gv-items-picker--"+layout).addClass("active"),$(".gv-items-picker").not(".gv-items-picker--"+layout).removeClass("active"),$(".gv-items-picker-container").attr("data-layout",layout),$.cookie("gv-items-picker-layout",layout,{path:gvGlobals.admin_cookiepath})},closeTooltips:function(e){var activeTooltips=$("[data-tooltip='active']"),close=!1,return_false=!1;switch(e.type){case"keyup":if(27===e.keyCode){if($(".ui-autocomplete").is(":visible"))return;return_false=close=0===$(".gv-field-filter-form input[data-has-search]:focus").length,window.Beacon&&window.Beacon("close")}((13===e.keyCode||32===e.keyCode)&&$(e.target).is(".close")||$(e.target).is(".dashicons-dismiss"))&&(close=!0);break;case"mouseup":$(e.target).parents(".ui-dialog,.ui-tooltip").length||$(e.target).is(".ui-dialog,.ui-tooltip")?close=!1:0vcfg.dialogWidth?vcfg.dialogWidth:$(window).width()-10},open:function(){return $('
').prependTo("#wpwrap"),vcfg.toggleCheckboxes(thisDialog),vcfg.setupFieldDetails(thisDialog),vcfg.refresh_merge_tags(thisDialog,function(){vcfg.setupCodeMirror(thisDialog)}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("disable")}),!0},close:function(e){e.preventDefault(),$("textarea.code",thisDialog).each(function(){$CodeMirror=$(this).next(".CodeMirror"),0!==$CodeMirror.length&&$CodeMirror[0].hasOwnProperty("CodeMirror")&&$CodeMirror[0].CodeMirror.toTextArea()}),thisDialog.find(".merge-tag-support").removeClass("merge-tag-support").addClass("gv-merge-tag-support"),$(".gv-field-settings.active","#gravityview_view_config").removeClass("active"),vcfg.setCustomLabel(thisDialog),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("enable")}),$("body").trigger("gravityview/dialog-closed",thisDialog)},closeOnEscape:!0,buttons:buttons})},setupCodeMirror:function(dialog){var vcfg=viewConfiguration;$("textarea.code:visible",dialog).each(function(){const codemirrorConfig=$.extend(!0,{},wp.codeEditor.defaultSettings);var $textarea,editorId,mergeTag,initialEditorCursorPos,$autocompleteEl,closeAutocompletion,mergeTags=$(this).data("codemirror");mergeTags&&(codemirrorConfig.codemirror=$.extend({},codemirrorConfig.codemirror,mergeTags));let editor=wp.codeEditor.initialize($(this),codemirrorConfig);($(this).hasClass("merge-tag-support")||$(this).hasClass("gv-merge-tag-support"))&&(editor.codemirror.setSize("95%"),$textarea=$(this),editorId=$textarea.attr("id"),mergeTags=window.gfMergeTags.getAutoCompleteMergeTags($textarea),mergeTag="",initialEditorCursorPos=editor.codemirror.getCursor(),$textarea.parent().find(".all-merge-tags").detach().insertBefore($textarea),$textarea.parent().find("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor),$textarea.autocomplete({appendTo:$textarea.parent(),minLength:1,position:{my:"center top",at:"center bottom",collision:"none"},source:mergeTags,select:function(event,currentEditorCursorPos){var val=currentEditorCursorPos.item.value.replace(/^{|}$/gm,""),currentEditorCursorPos=editor.codemirror.getCursor();editor.codemirror.replaceRange(val,initialEditorCursorPos,window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch)),editor.codemirror.focus(),editor.codemirror.setCursor(window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch+val.length+1))}}),$autocompleteEl=$textarea.parent().find("ul.ui-autocomplete"),closeAutocompletion=function(){$("#"+editorId).autocomplete("close")},$("body").on("keyup",function(e){$autocompleteEl.is(":visible")&&27===e.which&&(e.preventDefault(),closeAutocompletion(),$textarea.focus())}),editor.codemirror.on("mousedown",function(){closeAutocompletion()}),editor.codemirror.on("keydown",function(el,e){$autocompleteEl.is(":visible")&&(38!==e.which&&40!==e.which&&13!==e.which||($autocompleteEl.not(":focus")&&$autocompleteEl.focus(),e.preventDefault()))}),editor.codemirror.on("change",function(e,currentEditorCursorPos){"{}"===currentEditorCursorPos.text[0]&&(initialEditorCursorPos=editor.codemirror.getCursor());currentEditorCursorPos=editor.codemirror.getCursor();"{"!==(mergeTag=editor.codemirror.getRange({ch:initialEditorCursorPos.ch-1,line:initialEditorCursorPos.line},currentEditorCursorPos))[0]?closeAutocompletion():$("#"+editorId).autocomplete("search",mergeTag)}))})},sendMergeTagValueToCodemirrorEditor:function(e){var _activeEditorBackup=window.wpActiveEditor;window.wpActiveEditor=$(e.currentTarget).parentsUntil(".gv-setting-container").find("textarea").attr("id"),window.wpActiveEditor&&window.send_to_editor($(this).data("value")),window.wpActiveEditor=_activeEditorBackup},setupFieldDetails:function(dialog){$(".gv-field-details--container",dialog).insertAfter(".ui-dialog-title:visible");var show_details=$.cookie("gv-field-details-expanded"),show_details=viewConfiguration.getCookieVal(show_details);viewConfiguration.toggleFieldDetails(dialog,show_details),viewConfiguration.migrateSurveyScore(dialog)},migrateSurveyScore:function($dialog){var $score;0===$dialog.parents('[data-inputtype="survey"]').length||($score=$dialog.find(".gv-setting-container-score input"))&&0!=+$score.val()&&$dialog.find('.gv-setting-container-choice_display input[value="score"]').trigger("click").trigger("focus")},toggleFieldDetails:function($dialog,show_details){$parent=$dialog.parent(),$parent.find(".gv-field-details").toggleClass("gv-field-details--closed",!show_details).end().find(".gv-field-details--toggle .dashicons").toggleClass("dashicons-arrow-down",!!show_details).toggleClass("dashicons-arrow-right",!show_details).end()},setCustomLabel:function($label){var custom_label_text=$("[name*=admin_label]",$label),custom_label_text=custom_label_text.length&&custom_label_text.val()?custom_label_text:$("[name*=custom_label]",$label),$label=$label.parents(".gv-fields").find(".gv-field-label-text-container");custom_label_text.length&&(0<(custom_label_text=custom_label_text.val().trim()).length?$label.html(custom_label_text):$label.html($label.attr("data-original-title")))},getSortableFields:function(context,id){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$(".gravityview_sort_field").prop("disabled","disabled").empty().append("");var data={action:"gv_sortable_fields_form",nonce:gvGlobals.nonce};void 0!==context&&"preset"===context?data.template_id=id:data.form_id=vcfg.gvSelectForm.val(),$.post(ajaxurl,data,function(response){"false"!==response&&"0"!==response&&$(".gravityview_sort_field").empty().append(response).prop("disabled",null),resolve()})})},hideViewConfig:function(){$("#gravityview_view_config").slideUp(150),$(document).trigger("gv_admin_views_hideViewConfig")},showViewConfig:function(){$("#gravityview_view_config").slideDown(150),viewGeneralSettings.metaboxObj.show(),viewConfiguration.toggleDropMessage(),viewConfiguration.init_tooltips(),$(document).trigger("gv_admin_views_showViewConfig")},switchView:function(vcfg){vcfg.preventDefault(),vcfg.stopImmediatePropagation();vcfg=viewConfiguration;vcfg.templateFilter("custom"),vcfg.toggleViewTypeMetabox()},templateFilter:function(templateType){$(".gv-view-types-module").each(function(){$(this).attr("data-filter")===templateType?$(this).parent().show():$(this).parent().hide()})},selectTemplate:function(slugmatch){var vcfg=viewConfiguration;slugmatch.preventDefault(),slugmatch.stopImmediatePropagation(),vcfg.wantedTemplate=$(this);var selectedTemplateId=vcfg.wantedTemplate.attr("data-templateid"),regexMatch=/(.*?)_(.*?)$/i,slugmatch=vcfg.currentTemplateId.replace(regexMatch,"$2"),slugmatch=selectedTemplateId.replace(regexMatch,"$2")===slugmatch;vcfg.currentTemplateId&&!slugmatch&&vcfg.getConfiguredFields().length?vcfg.currentTemplateId!==selectedTemplateId?vcfg.getConfiguredFields().length?vcfg.showDialog("#gravityview_switch_template_dialog"):(vcfg.toggleViewTypeMetabox(),vcfg.selectTemplateContinue(slugmatch)):(vcfg.toggleViewTypeMetabox(),vcfg.showViewConfig()):($("#gravityview_select_template").slideUp(150),vcfg.selectTemplateContinue(slugmatch))},selectTemplateContinue:function(slugmatch){var vcfg=viewConfiguration,selectedTemplateId=vcfg.wantedTemplate.attr("data-templateid"),selectedFormId=vcfg.gvSelectForm.val();$("#gravityview_directory_template").val(selectedTemplateId).trigger("change");var $parent=vcfg.wantedTemplate.parents(".gv-view-types-module");$parent.parents(".gv-grid").find(".gv-view-types-module").removeClass("gv-selected"),$parent.addClass("gv-selected"),vcfg.waiting("start"),vcfg.startFreshStatus?Promise.all([vcfg.getAvailableFields("preset",selectedTemplateId),vcfg.getPresetFields(selectedTemplateId),vcfg.getSortableFields("preset",selectedTemplateId)]).then(function(){$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)})}):(slugmatch?vcfg.waiting("stop"):vcfg.updateActiveAreas(selectedTemplateId,+selectedFormId),vcfg.gvSwitchView.fadeIn(150),vcfg.toggleViewTypeMetabox()),vcfg.currentTemplateId=selectedTemplateId,vcfg.setUnsavedChanges(!0)},selectTemplateHover:function(on_success){const vcfg=viewConfiguration,$link=$(on_success.target),$parent=$link.parents(".gv-view-types-module");if($link.is("[rel=internal]")&&!$link.hasClass("gv-layout-activate")&&!$link.hasClass("gv-layout-install"))return!0;on_success.preventDefault(),on_success.stopImmediatePropagation();var server_request=(ajaxRoute,payload)=>{const defer=$.Deferred();$link.addClass("disabled"),vcfg.performingAjaxAction=!0,$(".gv-view-template-notice").hide();var{_wpNonce:nonce,_wpAjaxAction:action,_wpAjaxUrl:url,ajaxRouter,frontendFoundationVersion}=window.gvGlobals.foundation_licenses_router;return $.post(url,{nonce:nonce,action:action,ajaxRouter:ajaxRouter,ajaxRoute:ajaxRoute,frontendFoundationVersion:frontendFoundationVersion,payload:payload}).done(response=>{response.success?defer.resolve():defer.reject(response.data)}).fail(response=>{defer.reject(response.responseText)}),defer.promise()},on_fail=error=>{$(".gv-view-template-notice").show().find("p").html(error),document.querySelector(".gv-view-template-notice").scrollIntoView({behavior:"smooth"})},do_always=()=>{vcfg.performingAjaxAction=!1,$link.removeClass("disabled")},on_success=()=>{$parent.find(".gv-view-types-hover > div:eq(0)").hide(),$parent.find(".gv-view-types-hover > div:eq(1)").removeClass("hidden"),$parent.removeClass("gv-view-template-placeholder"),$parent.find("a.gv_select_template").attr("data-templateid",$link.data("templateid")).trigger("click")};return $link.hasClass("gv-layout-activate")?vcfg.performingAjaxAction?void 0:void $.when(server_request("activate_product",{text_domain:$link.attr("data-template-text-domain")})).then(on_success).always(do_always).fail(on_fail):$link.hasClass("gv-layout-install")?vcfg.performingAjaxAction?void 0:void $.when(server_request("install_product",{id:$link.attr("data-download-id"),activate:!0})).then(on_success).always(do_always).fail(on_fail):void $(this).find(".gv_select_template").trigger("click")},openExternalLinks:function(){return window.Beacon&&($(this).is("[data-beacon-article]")||$(this).is("[data-beacon-article-modal]")||$(this).is("[data-beacon-article-sidebar]")||$(this).is("[data-beacon-article-inline]"))||window.open(this.href),!1},previewTemplate:function(e){e.preventDefault(),e.stopImmediatePropagation();var parent=$(e.currentTarget).parents(".gv-view-types-module");parent.find(".gv-template-preview").dialog({dialogClass:"wp-dialog gv-dialog",appendTo:$("#gravityview_select_template"),width:viewConfiguration.dialogWidth,open:function(){$('
').prependTo("#wpwrap")},close:function(){$(this).dialog("option","appendTo",parent),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()})},closeOnEscape:!0,buttons:[{text:gvGlobals.label_close,click:function(){$(this).dialog("close")}}]})},updateActiveAreas:function(template,data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_active_areas",template_id:template,form_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},getPresetFields:function(data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_preset_fields",template_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateViewConfig:function(data){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$.post(ajaxurl,data,function(content){content&&(content=JSON.parse(content),$("#directory-header-widgets").html(content.header),$("#directory-footer-widgets").html(content.footer),$("#directory-active-fields").append(content.directory),$("#single-active-fields").append(content.single),vcfg.showViewConfig(),vcfg.waiting("stop"),$("body").trigger("gravityview/view-config-updated",content)),resolve()}),vcfg.setUnsavedChanges(!0)})},waiting:function(action){$containers=$("#wpwrap,.gv-fields"),"start"===action?$containers.addClass("gv-wait"):$containers.removeClass("gv-wait")},remove_tooltips:function(el){$(el||".gv-add-field").is(":ui-tooltip")&&$(".gv-add-field").gvTooltip("destroy").off("click")},init_tooltips:function(el){0!==$(el||".gv-add-field","#post").not(":ui-tooltip").length&&$(el||".gv-add-field","#post").gvTooltip({show:150,hide:200,content:function(){var context=$(this).attr("data-context"),formId=$(this).attr("data-formid")||$("#gravityview_form_id").val(),templateId=$("#gravityview_directory_template").val();switch($(this).attr("data-objecttype")){case"field":return $("#"+context+"-available-fields-"+(formId||templateId)).html();case"widget":return $("#directory-available-widgets").html()}},close:function(){$(this).attr("data-tooltip",null)},open:function(event,tooltip){$(this).attr("data-tooltip","active").attr("data-tooltip-id",$(this).attr("aria-describedby")),$focus_item=$("input[type=search]",tooltip.tooltip),$focus_item.length||($focus_item=$(tooltip.tooltip).find(".close").first());var activate_layout="list";$(tooltip).find(".gv-items-picker-container[data-layout]").length?activate_layout=$(tooltip).find(".gv-items-picker-container[data-layout]").attr("data-layout"):(layout_cookie=$.cookie("gv-items-picker-layout"),viewConfiguration.getCookieVal(layout_cookie)&&(activate_layout=layout_cookie)),viewConfiguration.setTooltipLayout(activate_layout),$focus_item.trigger("focus")},closeOnEscape:!0,disabled:!0,position:{my:"center bottom",at:"center top-12"},tooltipClass:"gravityview-item-picker-tooltip top"}).attr("title","").on("mouseout focusout",function(e){e.stopImmediatePropagation()}).on("click",function(e){$(this).attr("title",""),e.preventDefault(),$(this).gvTooltip("open")})},setupFieldFilters:function(e){var input=$(this).val().trim(),$tooltip=$(this).parents(".ui-tooltip-content"),$resultsNotFound=$tooltip.find(".gv-no-results");"keydown"!==e.type?($tooltip.find(".gv-fields").show().filter(function(){var match_title=$(this).find(".gv-field-label").attr("data-original-title").match(new RegExp(input,"i")),match_id=$(this).attr("data-fieldid").match(new RegExp(input,"i")),match_parent=!!$(this).attr("data-parent-label")&&$(this).attr("data-parent-label").match(new RegExp(input,"i"));return!match_title&&!match_id&&!match_parent}).hide(),$tooltip.find(".gv-fields:visible").length?$resultsNotFound.hide():$resultsNotFound.show()):$(this).attr("data-has-search",0{var vcfg=viewConfiguration;vcfg.toggleDropMessage(),vcfg.getConfiguredFields().remove();var data={action:"gv_available_fields",nonce:gvGlobals.nonce};data.form_preset_ids=void 0!==preset&&"preset"===preset?[templateid]:[vcfg.gvSelectForm.val()],$("#directory-available-fields-"+data.form_preset_ids[0]).length||$.post(ajaxurl,data,function(response){response.success||response.data||resolve(),$.each(response.data,function(context,markup){$("#"+context+"-fields").append(markup)}),resolve()})})},startAddField:function(e){$(this).has(".field-id-all-fields").length?viewConfiguration.addAllFields($(this)):viewConfiguration.addField($(this),e)},addAllFields:function(clicked){clicked.siblings(".gv-fields").filter(function(){var field_id=$(this).data("fieldid");return+field_id===parseInt(field_id,10)}).each(function(){$(this).trigger("click")}),$("a.gv-add-field[data-tooltip='active']").gvTooltip("close")},addField:function(data,addButton){addButton.preventDefault();var vcfg=viewConfiguration,newField=data.clone().hide(),areaId=data.parents(".ui-tooltip").attr("id"),templateId=$("#gravityview_directory_template").val(),addButton=data.parents(".ui-tooltip").attr("id"),addButton=$('.gv-add-field[data-tooltip-id="'+addButton+'"]'),data={action:"gv_field_options",template:templateId,area:addButton.attr("data-areaid"),context:addButton.attr("data-context"),field_id:newField.attr("data-fieldid"),field_label:newField.find(".gv-field-label").attr("data-original-title"),field_type:addButton.attr("data-objecttype"),input_type:newField.attr("data-inputtype"),form_id:parseInt($(data).attr("data-formid"),10)||vcfg.currentFormId,nonce:gvGlobals.nonce};$.ajax({type:"POST",url:ajaxurl,data:data,async:!0,beforeSend:function(){vcfg.disable_publish()},complete:function(){vcfg.enable_publish()}}).done(function(response){newField.append(response),$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)}),0<$(".gv-dialog-options",newField).length&&$(".gv-field-settings",newField).removeClass("hide-if-js"),$('[data-tooltip-id="'+areaId+'"]').parents(".gv-droppable-area").find(".active-drop").append(newField).end().attr("data-tooltip-id",""),$("body").trigger("gravityview/field-added",newField),newField.fadeIn(100),vcfg.refreshGFtooltips()}).fail(function(jqXHR){vcfg.enable_publish(),alert(gvGlobals.field_loaderror),console.log(jqXHR)}).always(function(){vcfg.toggleDropMessage(),vcfg.setUnsavedChanges(!0)})},refresh_merge_tags:function($source,onRefresh){let $merge_tag_supported=$source?$(".gv-merge-tag-support,.merge-tag-support",$source):$(".gv-merge-tag-support:visible");if($merge_tag_supported.removeClass("gv-merge-tag-support mt-initialized").addClass("merge-tag-support"),window.gform?.instances?.mergeTags)return $(".all-merge-tags",$source).remove(),document.dispatchEvent(new Event("DOMContentLoaded")),void setTimeout(function(){$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh()},300);"undefined"!=typeof form&&$("body").not(".gv-form-changed")&&0<=$merge_tag_supported.length&&(window.gfMergeTags&&($(".all-merge-tags:visible").remove(),gfMergeTags.hasOwnProperty("destroy")?$merge_tag_supported.each(function(){new gfMergeTagsObj(form,$(this))}):window.gfMergeTags=new gfMergeTagsObj(form)),$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh())},enable_publish:function(){$(document).trigger("autosave-enable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled",null).removeClass("button-primary-disabled")},disable_publish:function(){$(document).trigger("autosave-disable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled","disabled").addClass("button-primary-disabled")},init_droppables:function(panel){var vcfg;$(panel).find(".active-drop-field").sortable("instance")||(vcfg=viewConfiguration,$(panel).find(".active-drop-widget").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-widget",start:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").addClass("is-receivable")},stop:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area=ui.sender.attr("data-areaid"),receiver_area=$(this).attr("data-areaid");ui.item.find('[name^="widgets['+sender_area+']"]').each(function(){var name=$(this).attr("name");$(this).attr("name",name.replace(sender_area,receiver_area))}),vcfg.toggleDropMessage()}}),$(panel).find(".active-drop-field").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-field",start:function(event,ui){$(panel).find(".active-drop-container-field").addClass("is-receivable")},stop:function(event,ui){$(panel).find(".active-drop-container-field").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area,receiver_area;0",{name:"gv_fields",value:serialized_data,type:"hidden"})),setTimeout(function(){$post.data("gv-valid",!0),"click"===e.type?$(e.target).trigger("click"):$post.trigger("submit")},101),!1)},createPresetForm:function(e,data){var vcfg=viewConfiguration,$target=$(e.target);e.stopPropagation();data={action:"gv_set_preset_form",template_id:data,nonce:gvGlobals.nonce};return $.ajax({type:"POST",url:ajaxurl,data:data,async:!1,success:function(response){"false"!==response&&"0"!==response?(vcfg.startFreshStatus=!1,vcfg.gvSelectForm.find("option:selected").removeAttr("selected").end().append(response),"click"===e.type?$target.trigger("click"):$("#post").trigger("submit")):$target.before('

'+gvGlobals.label_publisherror+"

")}}),!1}},viewGeneralSettings={templateId:null,metaboxObj:null,init:function(){viewGeneralSettings.metaboxObj=$("#gravityview_settings"),viewGeneralSettings.initTabs(),$("#gravityview_directory_template").on("change",viewGeneralSettings.updateSettingsDisplay).trigger("change"),$("body").on("gravityview/settings/tab/enable",viewGeneralSettings.enableSettingTab).on("gravityview/settings/tab/disable",viewGeneralSettings.disableSettingTab)},updateSettingsDisplay:function(){viewGeneralSettings.templateId=$(this).val(),$("tr[data-show-if]").each(viewGeneralSettings.toggleSetting)},toggleSetting:function(){var row=$(this),templates=row.attr("data-show-if");templates.length<1||(0ninety_five_per&&(window_width=ninety_five_per),$open_dialog.dialog("option","width",window_width)}),window.addEventListener("beforeunload",event=>{vcfg.hasUnsavedChanges&&event.preventDefault()}),gvGlobals.passed_form_id&&vcfg.gvSelectForm.trigger("change");var _sendToEditor=window.send_to_editor;window.send_to_editor=function(val){var cursorPosition=$("#"+window.wpActiveEditor);if(!cursorPosition.hasClass("codemirror")&&_sendToEditor)return _sendToEditor(val);var codeMirror=cursorPosition.next(".CodeMirror")[0].CodeMirror,cursorPosition=codeMirror.getCursor();codeMirror.replaceRange(val,window.wp.CodeMirror.Pos(cursorPosition.line,cursorPosition.ch))},$("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor)},getCookieVal:function(cookie){return!(!cookie||"undefined"===cookie||"false"===cookie)&&cookie},toggleTabConfigurationWarnings:function(e){var tabs={single:{configured:$(".gv-dialog-options input[name*=show_as_link]:checked","#directory-active-fields").length||$('[data-fieldid="entry_link"]',"#directory-active-fields").length,icon:"dashicons-media-default"},edit:{configured:$('.gv-fields .field-key[value="edit_link"]').length,icon:"dashicons-welcome-write-blog"}};$.each(tabs,function(index,value){var show_warning=index+"-fields-"+$("#post_ID").val(),show_warning=!viewConfiguration.getCookieVal($.cookie("warning-dismissed-"+show_warning))&&0===value.configured;$("#"+index+"-fields").find(".notice-warning").toggle(show_warning),$('li[aria-controls="'+index+'-view"]').toggleClass("tab-not-configured",show_warning).find(".tab-icon").toggleClass("dashicons-warning",show_warning).toggleClass(value.icon,!show_warning)})},altKeyListener:function(e){viewConfiguration.altKey=e.altKey},zebraStripeSettings:function(){jQuery("#gravityview_settings").find("table").each(function(){$trs=$(this).find("tr").not('[style="display: none;"]'),$trs.removeClass("alternate"),$trs.filter(":even").addClass("alternate")})},toggleCheckboxes:function($parent){$parent=$parent.currentTarget||$parent;viewConfiguration.toggleRequired($parent,"requires",!1),viewConfiguration.toggleRequired($parent,"requires-not",!0);$parent=$($parent).is(".gv-fields")?$($parent):$($parent).parents(".gv-fields");$parent.length&&(viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_to_]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)),viewConfiguration.toggleDisabled($("input[type=checkbox][name*=link_phone]",$parent),$("input[type=checkbox][name*=show_as_link]",$parent)))},toggleDisabled:function($one,$two){0!==$one.length&&0!==$two.length&&($one.is(":checked")?$two.prop("disabled",!0):$two.is(":checked")&&$one.prop("disabled",!0))},toggleRequired:function(currentTarget,data_attr,reverse_logic){var $parent=$(currentTarget,"#post");$parent.find("[data-"+data_attr+"]").each(function(){var $this=$(this),requires_value=$this.data(data_attr).split("="),$input=requires_value[0],requires_value=requires_value[1],$input=$parent.find('[name$="['+$input+']"]').filter(":input");$input.is("[type=checkbox]")?reverse_logic?$this.toggle($input.not(":checked")):$this.toggle($input.is(":checked")):void 0!==requires_value&&(reverse_logic?$this.toggle($input.val()!==requires_value):$this.toggle($input.val()===requires_value))})},switchTooltipLayout:function(e){var layout=$(this).data("value");viewConfiguration.setTooltipLayout(layout)},setTooltipLayout:function(layout){$(".gv-items-picker--"+layout).addClass("active"),$(".gv-items-picker").not(".gv-items-picker--"+layout).removeClass("active"),$(".gv-items-picker-container").attr("data-layout",layout),$.cookie("gv-items-picker-layout",layout,{path:gvGlobals.admin_cookiepath})},closeTooltips:function(e){var activeTooltips=$("[data-tooltip='active']"),close=!1,return_false=!1;switch(e.type){case"keyup":if(27===e.keyCode){if($(".ui-autocomplete").is(":visible"))return;return_false=close=0===$(".gv-field-filter-form input[data-has-search]:focus").length,window.Beacon&&window.Beacon("close")}((13===e.keyCode||32===e.keyCode)&&$(e.target).is(".close")||$(e.target).is(".dashicons-dismiss"))&&(close=!0);break;case"mouseup":$(e.target).parents(".ui-dialog,.ui-tooltip").length||$(e.target).is(".ui-dialog,.ui-tooltip")?close=!1:0vcfg.dialogWidth?vcfg.dialogWidth:$(window).width()-10},open:function(){return $('
').prependTo("#wpwrap"),vcfg.toggleCheckboxes(thisDialog),vcfg.setupFieldDetails(thisDialog),vcfg.refresh_merge_tags(thisDialog,function(){vcfg.setupCodeMirror(thisDialog)}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("disable")}),!0},close:function(e){e.preventDefault(),$("textarea.code",thisDialog).each(function(){$CodeMirror=$(this).next(".CodeMirror"),0!==$CodeMirror.length&&$CodeMirror[0].hasOwnProperty("CodeMirror")&&$CodeMirror[0].CodeMirror.toTextArea()}),thisDialog.find(".merge-tag-support").removeClass("merge-tag-support").addClass("gv-merge-tag-support"),$(".gv-field-settings.active","#gravityview_view_config").removeClass("active"),vcfg.setCustomLabel(thisDialog),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()}),$sortableEls=$('.ui-widget-content[aria-hidden="false"]').find(".active-drop-widget, .active-drop-field"),$sortableEls.length&&$sortableEls.each((i,el)=>{$(el).hasClass("ui-sortable")&&$(el).sortable("enable")}),$(document.body).trigger("gravityview/dialog-closed",thisDialog)},closeOnEscape:!0,buttons:buttons})},setupCodeMirror:function(dialog){var vcfg=viewConfiguration;$("textarea.code:visible",dialog).each(function(){const codemirrorConfig=$.extend(!0,{},wp.codeEditor.defaultSettings);var $textarea,editorId,mergeTag,initialEditorCursorPos,$autocompleteEl,closeAutocompletion,mergeTags=$(this).data("codemirror");mergeTags&&(codemirrorConfig.codemirror=$.extend({},codemirrorConfig.codemirror,mergeTags));let editor=wp.codeEditor.initialize($(this),codemirrorConfig);($(this).hasClass("merge-tag-support")||$(this).hasClass("gv-merge-tag-support"))&&(editor.codemirror.setSize("95%"),$textarea=$(this),editorId=$textarea.attr("id"),mergeTags=window.gfMergeTags.getAutoCompleteMergeTags($textarea),mergeTag="",initialEditorCursorPos=editor.codemirror.getCursor(),$textarea.parent().find(".all-merge-tags").detach().insertBefore($textarea),$textarea.parent().find("div .gform-dropdown__trigger").on("click.gravityforms",vcfg.sendMergeTagValueToCodemirrorEditor),$textarea.autocomplete({appendTo:$textarea.parent(),minLength:1,position:{my:"center top",at:"center bottom",collision:"none"},source:mergeTags,select:function(event,currentEditorCursorPos){var val=currentEditorCursorPos.item.value.replace(/^{|}$/gm,""),currentEditorCursorPos=editor.codemirror.getCursor();editor.codemirror.replaceRange(val,initialEditorCursorPos,window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch)),editor.codemirror.focus(),editor.codemirror.setCursor(window.wp.CodeMirror.Pos(currentEditorCursorPos.line,currentEditorCursorPos.ch+val.length+1))}}),$autocompleteEl=$textarea.parent().find("ul.ui-autocomplete"),closeAutocompletion=function(){$("#"+editorId).autocomplete("close")},$(document.body).on("keyup",function(e){$autocompleteEl.is(":visible")&&27===e.which&&(e.preventDefault(),closeAutocompletion(),$textarea.focus())}),editor.codemirror.on("mousedown",function(){closeAutocompletion()}),editor.codemirror.on("keydown",function(el,e){$autocompleteEl.is(":visible")&&(38!==e.which&&40!==e.which&&13!==e.which||($autocompleteEl.not(":focus")&&$autocompleteEl.focus(),e.preventDefault()))}),editor.codemirror.on("change",function(e,currentEditorCursorPos){"{}"===currentEditorCursorPos.text[0]&&(initialEditorCursorPos=editor.codemirror.getCursor());currentEditorCursorPos=editor.codemirror.getCursor();"{"!==(mergeTag=editor.codemirror.getRange({ch:initialEditorCursorPos.ch-1,line:initialEditorCursorPos.line},currentEditorCursorPos))[0]?closeAutocompletion():$("#"+editorId).autocomplete("search",mergeTag)}))})},sendMergeTagValueToCodemirrorEditor:function(e){var _activeEditorBackup=window.wpActiveEditor;window.wpActiveEditor=$(e.currentTarget).parentsUntil(".gv-setting-container").find("textarea").attr("id"),window.wpActiveEditor&&window.send_to_editor($(this).data("value")),window.wpActiveEditor=_activeEditorBackup},setupFieldDetails:function(dialog){$(".gv-field-details--container",dialog).insertAfter(".ui-dialog-title:visible");var show_details=$.cookie("gv-field-details-expanded"),show_details=viewConfiguration.getCookieVal(show_details);viewConfiguration.toggleFieldDetails(dialog,show_details),viewConfiguration.migrateSurveyScore(dialog)},migrateSurveyScore:function($dialog){var $score;0===$dialog.parents('[data-inputtype="survey"]').length||($score=$dialog.find(".gv-setting-container-score input"))&&0!=+$score.val()&&$dialog.find('.gv-setting-container-choice_display input[value="score"]').trigger("click").trigger("focus")},toggleFieldDetails:function($dialog,show_details){$parent=$dialog.parent(),$parent.find(".gv-field-details").toggleClass("gv-field-details--closed",!show_details).end().find(".gv-field-details--toggle .dashicons").toggleClass("dashicons-arrow-down",!!show_details).toggleClass("dashicons-arrow-right",!show_details).end()},setCustomLabel:function($label){var custom_label_text=$("[name*=admin_label]",$label),custom_label_text=custom_label_text.length&&custom_label_text.val()?custom_label_text:$("[name*=custom_label]",$label),$label=$label.parents(".gv-fields").find(".gv-field-label-text-container");custom_label_text.length&&(0<(custom_label_text=custom_label_text.val().trim()).length?$label.html(custom_label_text):$label.html($label.attr("data-original-title")))},getSortableFields:function(context,id){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$(".gravityview_sort_field").prop("disabled","disabled").empty().append("");var data={action:"gv_sortable_fields_form",nonce:gvGlobals.nonce};void 0!==context&&"preset"===context?data.template_id=id:data.form_id=vcfg.gvSelectForm.val(),$.post(ajaxurl,data,function(response){"false"!==response&&"0"!==response&&$(".gravityview_sort_field").empty().append(response).prop("disabled",null),resolve()})})},hideViewConfig:function(){$("#gravityview_view_config").slideUp(150),$(document).trigger("gv_admin_views_hideViewConfig")},showViewConfig:function(){$("#gravityview_view_config").slideDown(150),viewGeneralSettings.metaboxObj.show(),viewConfiguration.toggleDropMessage(),viewConfiguration.init_tooltips(),$(document).trigger("gv_admin_views_showViewConfig")},switchView:function(vcfg){vcfg.preventDefault(),vcfg.stopImmediatePropagation();vcfg=viewConfiguration;vcfg.templateFilter("custom"),vcfg.toggleViewTypeMetabox()},templateFilter:function(templateType){$(".gv-view-types-module").each(function(){$(this).attr("data-filter")===templateType?$(this).parent().show():$(this).parent().hide()})},selectTemplate:function(slugmatch){var vcfg=viewConfiguration;slugmatch.preventDefault(),slugmatch.stopImmediatePropagation(),vcfg.wantedTemplate=$(this);var selectedTemplateId=vcfg.wantedTemplate.attr("data-templateid"),regexMatch=/(.*?)_(.*?)$/i,slugmatch=vcfg.currentTemplateId.replace(regexMatch,"$2"),slugmatch=selectedTemplateId.replace(regexMatch,"$2")===slugmatch;vcfg.currentTemplateId&&!slugmatch&&vcfg.getConfiguredFields().length?vcfg.currentTemplateId!==selectedTemplateId?vcfg.getConfiguredFields().length?vcfg.showDialog("#gravityview_switch_template_dialog"):(vcfg.toggleViewTypeMetabox(),vcfg.selectTemplateContinue(slugmatch)):(vcfg.toggleViewTypeMetabox(),vcfg.showViewConfig()):($("#gravityview_select_template").slideUp(150),vcfg.selectTemplateContinue(slugmatch))},selectTemplateContinue:function(slugmatch){var vcfg=viewConfiguration,selectedTemplateId=vcfg.wantedTemplate.attr("data-templateid"),selectedFormId=vcfg.gvSelectForm.val();$("#gravityview_directory_template").val(selectedTemplateId).trigger("change");var $parent=vcfg.wantedTemplate.parents(".gv-view-types-module");$parent.parents(".gv-grid").find(".gv-view-types-module").removeClass("gv-selected"),$parent.addClass("gv-selected"),vcfg.waiting("start"),vcfg.startFreshStatus?Promise.all([vcfg.getAvailableFields("preset",selectedTemplateId),vcfg.getPresetFields(selectedTemplateId),vcfg.getSortableFields("preset",selectedTemplateId)]).then(function(){$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)})}):(slugmatch?vcfg.waiting("stop"):vcfg.updateActiveAreas(selectedTemplateId,+selectedFormId),vcfg.gvSwitchView.fadeIn(150),vcfg.toggleViewTypeMetabox()),vcfg.currentTemplateId=selectedTemplateId,vcfg.setUnsavedChanges(!0)},selectTemplateHover:function(on_success){const vcfg=viewConfiguration,$link=$(on_success.target),$parent=$link.parents(".gv-view-types-module");if($link.is("[rel=internal]")&&!$link.hasClass("gv-layout-activate")&&!$link.hasClass("gv-layout-install"))return!0;on_success.preventDefault(),on_success.stopImmediatePropagation();var server_request=(ajaxRoute,payload)=>{const defer=$.Deferred();$link.addClass("disabled"),vcfg.performingAjaxAction=!0,$(".gv-view-template-notice").hide();var{_wpNonce:nonce,_wpAjaxAction:action,_wpAjaxUrl:url,ajaxRouter,frontendFoundationVersion}=window.gvGlobals.foundation_licenses_router;return $.post(url,{nonce:nonce,action:action,ajaxRouter:ajaxRouter,ajaxRoute:ajaxRoute,frontendFoundationVersion:frontendFoundationVersion,payload:payload}).done(response=>{response.success?defer.resolve():defer.reject(response.data)}).fail(response=>{defer.reject(response.responseText)}),defer.promise()},on_fail=error=>{$(".gv-view-template-notice").show().find("p").html(error),document.querySelector(".gv-view-template-notice").scrollIntoView({behavior:"smooth"})},do_always=()=>{vcfg.performingAjaxAction=!1,$link.removeClass("disabled")},on_success=()=>{$parent.find(".gv-view-types-hover > div:eq(0)").hide(),$parent.find(".gv-view-types-hover > div:eq(1)").removeClass("hidden"),$parent.removeClass("gv-view-template-placeholder"),$parent.find("a.gv_select_template").attr("data-templateid",$link.data("templateid")).trigger("click")};return $link.hasClass("gv-layout-activate")?vcfg.performingAjaxAction?void 0:void $.when(server_request("activate_product",{text_domain:$link.attr("data-template-text-domain")})).then(on_success).always(do_always).fail(on_fail):$link.hasClass("gv-layout-install")?vcfg.performingAjaxAction?void 0:void $.when(server_request("install_product",{id:$link.attr("data-download-id"),activate:!0})).then(on_success).always(do_always).fail(on_fail):void $(this).find(".gv_select_template").trigger("click")},openExternalLinks:function(){return window.Beacon&&($(this).is("[data-beacon-article]")||$(this).is("[data-beacon-article-modal]")||$(this).is("[data-beacon-article-sidebar]")||$(this).is("[data-beacon-article-inline]"))||window.open(this.href),!1},previewTemplate:function(e){e.preventDefault(),e.stopImmediatePropagation();var parent=$(e.currentTarget).parents(".gv-view-types-module");parent.find(".gv-template-preview").dialog({dialogClass:"wp-dialog gv-dialog",appendTo:$("#gravityview_select_template"),width:viewConfiguration.dialogWidth,open:function(){$('
').prependTo("#wpwrap")},close:function(){$(this).dialog("option","appendTo",parent),$("#wpwrap").find("> .gv-overlay").fadeOut("fast",function(){$(this).remove()})},closeOnEscape:!0,buttons:[{text:gvGlobals.label_close,click:function(){$(this).dialog("close")}}]})},updateActiveAreas:function(template,data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_active_areas",template_id:template,form_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},getPresetFields:function(data){var vcfg=viewConfiguration;$("#directory-active-fields, #single-active-fields").children().remove();data={action:"gv_get_preset_fields",template_id:data,nonce:gvGlobals.nonce};return vcfg.updateViewConfig(data)},updateViewConfig:function(data){return new Promise((resolve,reject)=>{var vcfg=viewConfiguration;$.post(ajaxurl,data,function(content){content&&(content=JSON.parse(content),$("#directory-header-widgets").html(content.header),$("#directory-footer-widgets").html(content.footer),$("#directory-active-fields").append(content.directory),$("#single-active-fields").append(content.single),vcfg.showViewConfig(),vcfg.waiting("stop"),$(document.body).trigger("gravityview/view-config-updated",content)),resolve()}),vcfg.setUnsavedChanges(!0)})},waiting:function(action){$containers=$("#wpwrap,.gv-fields"),"start"===action?$containers.addClass("gv-wait"):$containers.removeClass("gv-wait")},remove_tooltips:function(el){$(el||".gv-add-field").is(":ui-tooltip")&&$(".gv-add-field").gvTooltip("destroy").off("click")},init_tooltips:function(el){0!==$(el||".gv-add-field","#post").not(":ui-tooltip").length&&$(el||".gv-add-field","#post").gvTooltip({show:150,hide:200,content:function(){var context=$(this).attr("data-context"),formId=$(this).attr("data-formid")||$("#gravityview_form_id").val(),templateId=$("#gravityview_directory_template").val();switch($(this).attr("data-objecttype")){case"field":return $("#"+context+"-available-fields-"+(formId||templateId)).html();case"widget":return $("#directory-available-widgets").html()}},close:function(){$(this).attr("data-tooltip",null)},open:function(event,tooltip){$(this).attr("data-tooltip","active").attr("data-tooltip-id",$(this).attr("aria-describedby")),$focus_item=$("input[type=search]",tooltip.tooltip),$focus_item.length||($focus_item=$(tooltip.tooltip).find(".close").first());var activate_layout="list";$(tooltip).find(".gv-items-picker-container[data-layout]").length?activate_layout=$(tooltip).find(".gv-items-picker-container[data-layout]").attr("data-layout"):(layout_cookie=$.cookie("gv-items-picker-layout"),viewConfiguration.getCookieVal(layout_cookie)&&(activate_layout=layout_cookie)),viewConfiguration.setTooltipLayout(activate_layout),$focus_item.trigger("focus")},closeOnEscape:!0,disabled:!0,position:{my:"center bottom",at:"center top-12"},tooltipClass:"gravityview-item-picker-tooltip top"}).attr("title","").on("mouseout focusout",function(e){e.stopImmediatePropagation()}).on("click",function(e){$(this).attr("title",""),e.preventDefault(),$(this).gvTooltip("open")})},setupFieldFilters:function(e){var input=$(this).val().trim(),$tooltip=$(this).parents(".ui-tooltip-content"),$resultsNotFound=$tooltip.find(".gv-no-results");"keydown"!==e.type?($tooltip.find(".gv-fields").show().filter(function(){var match_title=$(this).find(".gv-field-label").attr("data-original-title").match(new RegExp(input,"i")),match_id=$(this).attr("data-fieldid").match(new RegExp(input,"i")),match_parent=!!$(this).attr("data-parent-label")&&$(this).attr("data-parent-label").match(new RegExp(input,"i"));return!match_title&&!match_id&&!match_parent}).hide(),$tooltip.find(".gv-fields:visible").length?$resultsNotFound.hide():$resultsNotFound.show()):$(this).attr("data-has-search",0{var vcfg=viewConfiguration;vcfg.toggleDropMessage(),vcfg.getConfiguredFields().remove();var data={action:"gv_available_fields",nonce:gvGlobals.nonce};data.form_preset_ids=void 0!==preset&&"preset"===preset?[templateid]:[vcfg.gvSelectForm.val()],$("#directory-available-fields-"+data.form_preset_ids[0]).length||$.post(ajaxurl,data,function(response){response.success||response.data||resolve(),$.each(response.data,function(context,markup){$("#"+context+"-fields").append(markup)}),resolve()})})},startAddField:function(e){$(this).has(".field-id-all-fields").length?viewConfiguration.addAllFields($(this)):viewConfiguration.addField($(this),e)},addAllFields:function(clicked){clicked.siblings(".gv-fields").filter(function(){var field_id=$(this).data("fieldid");return+field_id===parseInt(field_id,10)}).each(function(){$(this).trigger("click")}),$("a.gv-add-field[data-tooltip='active']").gvTooltip("close")},addField:function(data,addButton){addButton.preventDefault();var vcfg=viewConfiguration,newField=data.clone().hide(),areaId=data.parents(".ui-tooltip").attr("id"),templateId=$("#gravityview_directory_template").val(),addButton=data.parents(".ui-tooltip").attr("id"),addButton=$('.gv-add-field[data-tooltip-id="'+addButton+'"]'),data={action:"gv_field_options",template:templateId,area:addButton.attr("data-areaid"),context:addButton.attr("data-context"),field_id:newField.attr("data-fieldid"),field_label:newField.find(".gv-field-label").attr("data-original-title"),field_type:addButton.attr("data-objecttype"),input_type:newField.attr("data-inputtype"),form_id:parseInt($(data).attr("data-formid"),10)||vcfg.currentFormId,nonce:gvGlobals.nonce};$.ajax({type:"POST",url:ajaxurl,data:data,async:!0,beforeSend:function(){vcfg.disable_publish()},complete:function(){vcfg.enable_publish()}}).done(function(response){newField.append(response),$(".ui-tabs-panel").each(function(){vcfg.init_droppables(this)}),0<$(".gv-dialog-options",newField).length&&$(".gv-field-settings",newField).removeClass("hide-if-js"),$('[data-tooltip-id="'+areaId+'"]').parents(".gv-droppable-area").find(".active-drop").append(newField).end().attr("data-tooltip-id",""),$(document.body).trigger("gravityview/field-added",newField),newField.fadeIn(100),vcfg.refreshGFtooltips()}).fail(function(jqXHR){vcfg.enable_publish(),alert(gvGlobals.field_loaderror),console.log(jqXHR)}).always(function(){vcfg.toggleDropMessage(),vcfg.setUnsavedChanges(!0)})},refresh_merge_tags:function($source,onRefresh){let $merge_tag_supported=$source?$(".gv-merge-tag-support,.merge-tag-support",$source):$(".gv-merge-tag-support:visible");if($merge_tag_supported.removeClass("gv-merge-tag-support mt-initialized").addClass("merge-tag-support"),window.gform?.instances?.mergeTags)return $(".all-merge-tags",$source).remove(),document.dispatchEvent(new Event("DOMContentLoaded")),void setTimeout(function(){$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh()},300);"undefined"!=typeof form&&$(document.body).not(".gv-form-changed")&&0<=$merge_tag_supported.length&&(window.gfMergeTags&&($(".all-merge-tags:visible").remove(),gfMergeTags.hasOwnProperty("destroy")?$merge_tag_supported.each(function(){new gfMergeTagsObj(form,$(this))}):window.gfMergeTags=new gfMergeTagsObj(form)),$merge_tag_supported.removeClass("merge-tag-support").addClass("gv-merge-tag-support"),onRefresh&&onRefresh())},enable_publish:function(){$(document).trigger("autosave-enable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled",null).removeClass("button-primary-disabled")},disable_publish:function(){$(document).trigger("autosave-disable-buttons.edit-post"),$("#publishing-action").find("#publish").prop("disabled","disabled").addClass("button-primary-disabled")},init_droppables:function(panel){var vcfg;$(panel).find(".active-drop-field").sortable("instance")||(vcfg=viewConfiguration,$(panel).find(".active-drop-widget").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-widget",start:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").addClass("is-receivable")},stop:function(event,ui){$("#directory-fields, #single-fields").find(".active-drop-container-widget").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area=ui.sender.attr("data-areaid"),receiver_area=$(this).attr("data-areaid");ui.item.find('[name^="widgets['+sender_area+']"]').each(function(){var name=$(this).attr("name");$(this).attr("name",name.replace(sender_area,receiver_area))}),vcfg.toggleDropMessage()}}),$(panel).find(".active-drop-field").sortable({placeholder:"fields-placeholder",items:"> .gv-fields",distance:2,revert:75,connectWith:".active-drop-field",start:function(event,ui){$(panel).find(".active-drop-container-field").addClass("is-receivable")},stop:function(event,ui){$(panel).find(".active-drop-container-field").removeClass("is-receivable")},change:function(event,ui){vcfg.setUnsavedChanges(!0)},receive:function(event,ui){var sender_area,receiver_area;0",{name:"gv_fields",value:serialized_data,type:"hidden"})),setTimeout(function(){$post.data("gv-valid",!0),"click"===e.type?$(e.target).trigger("click"):$post.trigger("submit")},101),!1)},createPresetForm:function(e,data){var vcfg=viewConfiguration,$target=$(e.target);e.stopPropagation();data={action:"gv_set_preset_form",template_id:data,nonce:gvGlobals.nonce};return $.ajax({type:"POST",url:ajaxurl,data:data,async:!1,success:function(response){"false"!==response&&"0"!==response?(vcfg.startFreshStatus=!1,vcfg.gvSelectForm.find("option:selected").removeAttr("selected").end().append(response),"click"===e.type?$target.trigger("click"):$("#post").trigger("submit")):$target.before('

'+gvGlobals.label_publisherror+"

")}}),!1}},viewGeneralSettings={templateId:null,metaboxObj:null,init:function(){viewGeneralSettings.metaboxObj=$("#gravityview_settings"),viewGeneralSettings.initTabs(),$("#gravityview_directory_template").on("change",viewGeneralSettings.updateSettingsDisplay).trigger("change"),$(document.body).on("gravityview/settings/tab/enable",viewGeneralSettings.enableSettingTab).on("gravityview/settings/tab/disable",viewGeneralSettings.disableSettingTab)},updateSettingsDisplay:function(){viewGeneralSettings.templateId=$(this).val(),$("tr[data-show-if]").each(viewGeneralSettings.toggleSetting)},toggleSetting:function(){var row=$(this),templates=row.attr("data-show-if");templates.length<1||(0=7.2.0", "psr/log": "^1.1", - "trustedlogin/client": "dev-main" + "trustedlogin/client": "^1.7" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7", @@ -296,7 +296,7 @@ }, "scripts": { "prefix_vendor": [ - "@php strauss.phar" + "@php tools/strauss.phar" ], "post_update_install": [ "./composer_post_update_install.sh" @@ -322,10 +322,10 @@ } ], "support": { - "source": "https://github.com/GravityKit/Foundation/tree/v1.2.6", + "source": "https://github.com/GravityKit/Foundation/tree/v1.2.8", "issues": "https://github.com/GravityKit/Foundation/issues" }, - "time": "2023-12-07T15:17:04+00:00" + "time": "2024-02-07T15:22:05+00:00" }, { "name": "illuminate/container", @@ -957,16 +957,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -980,9 +980,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1020,7 +1017,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -1036,7 +1033,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php70", @@ -1108,25 +1105,25 @@ }, { "name": "trustedlogin/client", - "version": "dev-main", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/trustedlogin/client.git", - "reference": "1c924f8dee1b10624223741b72e5ce83f1e45ce3" + "reference": "35938a4bd9749f475518b88d4ce593d27970024c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/trustedlogin/client/zipball/1c924f8dee1b10624223741b72e5ce83f1e45ce3", - "reference": "1c924f8dee1b10624223741b72e5ce83f1e45ce3", + "url": "https://api.github.com/repos/trustedlogin/client/zipball/35938a4bd9749f475518b88d4ce593d27970024c", + "reference": "35938a4bd9749f475518b88d4ce593d27970024c", "shasum": "" }, "require-dev": { "ext-curl": "*", "ext-json": "*", "php": ">=5.3.0", - "yoast/phpunit-polyfills": "^1.0" + "spatie/phpunit-watcher": "^1.23", + "yoast/phpunit-polyfills": "^1.1.0" }, - "default-branch": true, "bin": [ "bin/build-sass" ], @@ -1156,9 +1153,9 @@ ], "support": { "issues": "https://github.com/trustedlogin/client/issues", - "source": "https://github.com/trustedlogin/client/tree/v1.6.1" + "source": "https://github.com/trustedlogin/client/tree/v1.7.0" }, - "time": "2023-09-22T17:54:18+00:00" + "time": "2024-01-29T20:51:28+00:00" } ], "packages-dev": [ @@ -2531,6 +2528,84 @@ ], "time": "2022-02-25T21:32:43+00:00" }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "time": "2023-01-05T11:28:13+00:00" + }, { "name": "dg/mysql-dump", "version": "v1.5.1", @@ -3697,6 +3772,346 @@ }, "time": "2022-10-11T11:49:44+00:00" }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.3.5", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, + "time": "2019-12-27T09:44:58+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "reference": "bba5a9dfec7fcfbd679cfaf611d86b4d3759da26", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "paragonie/random_compat": "dev-master", + "paragonie/sodium_compat": "dev-master" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, + "time": "2022-10-25T01:46:02+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.1.4", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, + "time": "2022-10-24T09:00:36+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T16:49:07+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/908247bc65010c7b7541a9551e002db12e9dae70", + "reference": "908247bc65010c7b7541a9551e002db12e9dae70", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.8.0 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T14:50:00+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.26", @@ -5632,6 +6047,86 @@ }, "time": "2022-08-31T10:31:18+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.8.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "reference": "5805f7a4e4958dbb5e944ef1e6edae0a303765e7", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2023-12-08T12:32:31+00:00" + }, { "name": "symfony/browser-kit", "version": "v5.4.21", @@ -6567,16 +7062,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -6584,9 +7079,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -6630,7 +7122,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -6646,7 +7138,7 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/process", @@ -9167,6 +9659,72 @@ }, "time": "2023-01-12T03:32:05+00:00" }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=5.4", + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.2" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcompatibility/php-compatibility": "^9.0", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "type": "custom" + } + ], + "time": "2023-09-14T07:06:09+00:00" + }, { "name": "yoast/phpunit-polyfills", "version": "1.1.0", @@ -9297,5 +9855,5 @@ "ext-openssl": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/future/_mocks.php b/future/_mocks.php index 96e4eb6cea..c6d8468376 100644 --- a/future/_mocks.php +++ b/future/_mocks.php @@ -24,8 +24,16 @@ function GravityView_View_Data_add_view( $view_id, $atts, $_this ) { } return array_combine( - array_map( function( $view ) { return $view->ID; }, $_this->views->all() ), - array_map( function( $view ) { return $view->as_data(); }, $_this->views->all() ) + array_map( + function ( $view ) { + return $view->ID; }, + $_this->views->all() + ), + array_map( + function ( $view ) { + return $view->as_data(); }, + $_this->views->all() + ) ); } @@ -107,14 +115,19 @@ function GravityView_frontend_get_view_entries( $args, $form_id, $parameters, $c /** Set paging, count and unwrap the entries. */ $paging = array( - 'offset' => ( $page - 1 ) * $view->settings->get( 'page_size' ), + 'offset' => ( $page - 1 ) * $view->settings->get( 'page_size' ), 'page_size' => $view->settings->get( 'page_size' ), ); /** * GF_Query does not subtract the offset, we have to subtract it ourselves. */ - $count = $entries->total() - ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ? $view->settings->get( 'offset' ) : 0 ); - $entries = array_map( function( $e ) { return $e->as_entry(); }, $entries->all() ); + $count = $entries->total() - ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ? $view->settings->get( 'offset' ) : 0 ); + $entries = array_map( + function ( $e ) { + return $e->as_entry(); + }, + $entries->all() + ); } /** Just one more filter, for compatibility's sake! */ @@ -149,7 +162,7 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) { if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) { $multientry = \GV\Multi_Entry::from_entries( array_map( '\GV\GF_Entry::from_entry', $entry['_multi'] ) ); - $entry = $entry['_multi'][ $field_settings['form_id'] ]; + $entry = $entry['_multi'][ $field_settings['form_id'] ]; } if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) { @@ -162,10 +175,10 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) { * * Fields with a numeric ID are Gravity Forms ones. */ - $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;; + $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; /** Initialize the future field. */ - switch ( $source ): + switch ( $source ) : /** The Gravity Forms backend. */ case \GV\Source::BACKEND_GRAVITYFORMS: if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { @@ -197,17 +210,17 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) { $field->update_configuration( $field_settings ); $renderer = new \GV\Field_Renderer(); - $views = gravityview()->views->get(); + $views = gravityview()->views->get(); if ( $views instanceof \GV\View_Collection ) { $view = $views->first(); - } else if ( $views instanceof \GV\View ) { + } elseif ( $views instanceof \GV\View ) { $view = $views; } else { return null; } - return $renderer->render( $field, $view, $source == \GV\Source::BACKEND_GRAVITYFORMS ? $form : null, isset( $multientry ) ? $multientry : $entry, gravityview()->request ); + return $renderer->render( $field, $view, \GV\Source::BACKEND_GRAVITYFORMS == $source ? $form : null, isset( $multientry ) ? $multientry : $entry, gravityview()->request ); } /** @@ -224,7 +237,7 @@ function GravityView_API_field_value( $entry, $field_settings, $format ) { function GravityView_API_field_label( $form, $field_settings, $entry, $force_show_label = false ) { /** A bail condition. */ - $bail = function( $label, $field_settings, $entry, $force_show_label, $form ) { + $bail = function ( $label, $field_settings, $entry, $force_show_label, $form ) { if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) { $label = isset( $field_settings['label'] ) ? $field_settings['label'] : ''; @@ -235,7 +248,8 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho } /** - * @filter `gravityview_render_after_label` Append content to a field label + * Append content to a field label. + * * @param string $appended_content Content you can add after a label. Empty by default. * @param array $field GravityView field array */ @@ -243,7 +257,8 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho } /** - * @filter `gravityview/template/field_label` Modify field label output + * Modify field label output. + * * @since 1.7 * @param string $label Field label HTML * @param array $field GravityView field array @@ -284,7 +299,7 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho $source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; /** Initialize the future field. */ - switch ( $source ): + switch ( $source ) : /** The Gravity Forms backend. */ case \GV\Source::BACKEND_GRAVITYFORMS: if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) { @@ -293,7 +308,13 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho } if ( ! $field = $gf_form::get_field( $gf_form, $field_settings['id'] ) ) { - gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings['id'], 'data' => $form ) ); + gravityview()->log->error( + 'No field found for specified form and field ID #{field_id}', + array( + 'field_id' => $field_settings['id'], + 'data' => $form, + ) + ); return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form ); } if ( empty( $field_settings['show_label'] ) ) { @@ -317,7 +338,7 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho break; endswitch; - if( $force_show_label ) { + if ( $force_show_label ) { $field_settings['show_label'] = '1'; } @@ -329,7 +350,8 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho $label = $field->get_label( null, isset( $gf_form ) ? $gf_form : null, $entry ); /** - * @filter `gravityview_render_after_label` Append content to a field label + * Append content to a field label. + * * @param string $appended_content Content you can add after a label. Empty by default. * @param array $field GravityView field array */ @@ -338,7 +360,8 @@ function GravityView_API_field_label( $form, $field_settings, $entry, $force_sho } /** - * @filter `gravityview/template/field_label` Modify field label output + * Modify field label output. + * * @since 1.7 * @param string $label Field label HTML * @param array $field GravityView field array @@ -374,34 +397,34 @@ final class Legacy_Context { * * Configuration keys: * - * - \GV\View view: sets \GravityView_View::atts, \GravityView_View::view_id, - * \GravityView_View::back_link_label - * \GravityView_frontend::context_view_id, - * \GravityView_View::form, \GravityView_View::form_id - * - \GV\Field field: sets \GravityView_View::_current_field, \GravityView_View::field_data, - * - \GV\Entry entry: sets \GravityView_View::_current_entry, \GravityView_frontend::single_entry, - * \GravityView_frontend::entry - * - \WP_Post post: sets \GravityView_View::post_id, \GravityView_frontend::post_id, - * \GravityView_frontend::is_gravityview_post_type, - * \GravityView_frontend::post_has_shortcode - * - array paging: sets \GravityView_View::paging - * - array sorting: sets \GravityView_View::sorting - * - array template: sets \GravityView_View::template_part_slug, \GravityView_View::template_part_name + * - \GV\View view: sets \GravityView_View::atts, \GravityView_View::view_id, + * \GravityView_View::back_link_label + * \GravityView_frontend::context_view_id, + * \GravityView_View::form, \GravityView_View::form_id + * - \GV\Field field: sets \GravityView_View::_current_field, \GravityView_View::field_data, + * - \GV\Entry entry: sets \GravityView_View::_current_entry, \GravityView_frontend::single_entry, + * \GravityView_frontend::entry + * - \WP_Post post: sets \GravityView_View::post_id, \GravityView_frontend::post_id, + * \GravityView_frontend::is_gravityview_post_type, + * \GravityView_frontend::post_has_shortcode + * - array paging: sets \GravityView_View::paging + * - array sorting: sets \GravityView_View::sorting + * - array template: sets \GravityView_View::template_part_slug, \GravityView_View::template_part_name * - * - boolean in_the_loop sets $wp_actions['loop_start'] and $wp_query::in_the_loop + * - boolean in_the_loop sets $wp_actions['loop_start'] and $wp_query::in_the_loop * * also: * - * - \GV\Request request: sets \GravityView_frontend::is_search, \GravityView_frontend::single_entry, - * \GravityView_View::context, \GravityView_frontend::entry + * - \GV\Request request: sets \GravityView_frontend::is_search, \GravityView_frontend::single_entry, + * \GravityView_View::context, \GravityView_frontend::entry * - * - \GV\View_Collection views: sets \GravityView_View_Data::views - * - \GV\Field_Collection fields: sets \GravityView_View::fields - * - \GV\Entry_Collection entries: sets \GravityView_View::entries, \GravityView_View::total_entries + * - \GV\View_Collection views: sets \GravityView_View_Data::views + * - \GV\Field_Collection fields: sets \GravityView_View::fields + * - \GV\Entry_Collection entries: sets \GravityView_View::entries, \GravityView_View::total_entries * * and automagically: * - * - \GravityView_View data: sets \GravityView_frontend::gv_output_data + * - \GravityView_View data: sets \GravityView_frontend::gv_output_data * * @param array $configuration The configuration. * @@ -430,32 +453,32 @@ public static function freeze() { global $wp_actions, $wp_query; return array( - '\GravityView_View::atts' => \GravityView_View::getInstance()->getAtts(), - '\GravityView_View::view_id' => \GravityView_View::getInstance()->getViewId(), - '\GravityView_View::back_link_label' => \GravityView_View::getInstance()->getBackLinkLabel( false ), - '\GravityView_View_Data::views' => \GravityView_View_Data::getInstance()->views, - '\GravityView_View::entries' => \GravityView_View::getInstance()->getEntries(), - '\GravityView_View::form' => \GravityView_View::getInstance()->getForm(), - '\GravityView_View::form_id' => \GravityView_View::getInstance()->getFormId(), - '\GravityView_View::context' => \GravityView_View::getInstance()->getContext(), - '\GravityView_View::total_entries' => \GravityView_View::getInstance()->getTotalEntries(), - '\GravityView_View::post_id' => \GravityView_View::getInstance()->getPostId(), - '\GravityView_View::hide_until_searched' => \GravityView_View::getInstance()->isHideUntilSearched(), - '\GravityView_frontend::post_id' => \GravityView_frontend::getInstance()->getPostId(), - '\GravityView_frontend::context_view_id' => \GravityView_frontend::getInstance()->get_context_view_id(), + '\GravityView_View::atts' => \GravityView_View::getInstance()->getAtts(), + '\GravityView_View::view_id' => \GravityView_View::getInstance()->getViewId(), + '\GravityView_View::back_link_label' => \GravityView_View::getInstance()->getBackLinkLabel( false ), + '\GravityView_View_Data::views' => \GravityView_View_Data::getInstance()->views, + '\GravityView_View::entries' => \GravityView_View::getInstance()->getEntries(), + '\GravityView_View::form' => \GravityView_View::getInstance()->getForm(), + '\GravityView_View::form_id' => \GravityView_View::getInstance()->getFormId(), + '\GravityView_View::context' => \GravityView_View::getInstance()->getContext(), + '\GravityView_View::total_entries' => \GravityView_View::getInstance()->getTotalEntries(), + '\GravityView_View::post_id' => \GravityView_View::getInstance()->getPostId(), + '\GravityView_View::hide_until_searched' => \GravityView_View::getInstance()->isHideUntilSearched(), + '\GravityView_frontend::post_id' => \GravityView_frontend::getInstance()->getPostId(), + '\GravityView_frontend::context_view_id' => \GravityView_frontend::getInstance()->get_context_view_id(), '\GravityView_frontend::is_gravityview_post_type' => \GravityView_frontend::getInstance()->isGravityviewPostType(), '\GravityView_frontend::post_has_shortcode' => \GravityView_frontend::getInstance()->isPostHasShortcode(), - '\GravityView_frontend::gv_output_data' => \GravityView_frontend::getInstance()->getGvOutputData(), - '\GravityView_View::paging' => \GravityView_View::getInstance()->getPaging(), - '\GravityView_View::sorting' => \GravityView_View::getInstance()->getSorting(), - '\GravityView_frontend::is_search' => \GravityView_frontend::getInstance()->isSearch(), - '\GravityView_frontend::single_entry' => \GravityView_frontend::getInstance()->getSingleEntry(), - '\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(), - '\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(), - '\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(), - '\GravityView_View::_current_field' => \GravityView_View::getInstance()->getCurrentField(), - 'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'], - 'wp_query::in_the_loop' => $wp_query->in_the_loop, + '\GravityView_frontend::gv_output_data' => \GravityView_frontend::getInstance()->getGvOutputData(), + '\GravityView_View::paging' => \GravityView_View::getInstance()->getPaging(), + '\GravityView_View::sorting' => \GravityView_View::getInstance()->getSorting(), + '\GravityView_frontend::is_search' => \GravityView_frontend::getInstance()->isSearch(), + '\GravityView_frontend::single_entry' => \GravityView_frontend::getInstance()->getSingleEntry(), + '\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(), + '\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(), + '\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(), + '\GravityView_View::_current_field' => \GravityView_View::getInstance()->getCurrentField(), + 'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'], + 'wp_query::in_the_loop' => $wp_query->in_the_loop, ); } @@ -465,8 +488,8 @@ public static function freeze() { * @param array $data Saved configuration from self::freeze() */ public static function thaw( $data ) { - foreach ( (array)$data as $key => $value ) { - switch ( $key ): + foreach ( (array) $data as $key => $value ) { + switch ( $key ) : case '\GravityView_View::atts': \GravityView_View::getInstance()->setAtts( $value ); break; @@ -504,7 +527,7 @@ public static function thaw( $data ) { \GravityView_frontend::getInstance()->setPostId( $value ); break; case '\GravityView_frontend::context_view_id': - $frontend = \GravityView_frontend::getInstance(); + $frontend = \GravityView_frontend::getInstance(); $frontend->context_view_id = $value; break; case '\GravityView_frontend::is_gravityview_post_type': @@ -560,115 +583,144 @@ public static function thaw( $data ) { * @return void */ public static function load( $configuration ) { - foreach ( (array)$configuration as $key => $value ) { - switch ( $key ): + foreach ( (array) $configuration as $key => $value ) { + switch ( $key ) : case 'view': $views = new \GV\View_Collection(); $views->add( $value ); - self::thaw( array( - '\GravityView_View::atts' => $value->settings->as_atts(), - '\GravityView_View::view_id' => $value->ID, - '\GravityView_View::back_link_label' => $value->settings->get( 'back_link_label', null ), - '\GravityView_View::form' => $value->form ? $value->form->form : null, - '\GravityView_View::form_id' => $value->form ? $value->form->ID : null, - '\GravityView_View::is_hide_until_searched' => $value->settings->get( 'hide_until_searched', null ) && ! gravityview()->request->is_search(), - - '\GravityView_View_Data::views' => $views, - '\GravityView_frontend::gv_output_data' => \GravityView_View_Data::getInstance(), - '\GravityView_frontend::context_view_id' => $value->ID, - ) ); + self::thaw( + array( + '\GravityView_View::atts' => $value->settings->as_atts(), + '\GravityView_View::view_id' => $value->ID, + '\GravityView_View::back_link_label' => $value->settings->get( 'back_link_label', null ), + '\GravityView_View::form' => $value->form ? $value->form->form : null, + '\GravityView_View::form_id' => $value->form ? $value->form->ID : null, + '\GravityView_View::is_hide_until_searched' => $value->settings->get( 'hide_until_searched', null ) && ! gravityview()->request->is_search(), + + '\GravityView_View_Data::views' => $views, + '\GravityView_frontend::gv_output_data' => \GravityView_View_Data::getInstance(), + '\GravityView_frontend::context_view_id' => $value->ID, + ) + ); break; case 'post': $has_shortcode = false; foreach ( \GV\Shortcode::parse( $value->post_content ) as $shortcode ) { - if ( $shortcode->name == 'gravityview' ) { + if ( 'gravityview' == $shortcode->name ) { $has_shortcode = true; break; } } - self::thaw( array( - '\GravityView_View::post_id' => $value->ID, - '\GravityView_frontend::post_id' => $value->ID, - '\GravityView_frontend::is_gravityview_post_type' => $value->post_type == 'gravityview', - '\GravityView_frontend::post_has_shortcode' => $has_shortcode, - ) ); + self::thaw( + array( + '\GravityView_View::post_id' => $value->ID, + '\GravityView_frontend::post_id' => $value->ID, + '\GravityView_frontend::is_gravityview_post_type' => 'gravityview' == $value->post_type, + '\GravityView_frontend::post_has_shortcode' => $has_shortcode, + ) + ); break; case 'views': - self::thaw( array( - '\GravityView_View_Data::views' => $value, - '\GravityView_frontend::gv_output_data' => \GravityView_View_Data::getInstance(), - ) ); + self::thaw( + array( + '\GravityView_View_Data::views' => $value, + '\GravityView_frontend::gv_output_data' => \GravityView_View_Data::getInstance(), + ) + ); break; case 'entries': - self::thaw( array( - '\GravityView_View::entries' => array_map( function( $e ) { return $e->as_entry(); }, $value->all() ), - '\GravityView_View::total_entries' => $value->total(), - ) ); + self::thaw( + array( + '\GravityView_View::entries' => array_map( + function ( $e ) { + return $e->as_entry(); }, + $value->all() + ), + '\GravityView_View::total_entries' => $value->total(), + ) + ); break; case 'entry': - self::thaw( array( - '\GravityView_frontend::single_entry' => $value->ID, - '\GravityView_frontend::entry' => $value->as_entry(), - '\GravityView_View::_current_entry' => $value->as_entry(), - ) ); + self::thaw( + array( + '\GravityView_frontend::single_entry' => $value->ID, + '\GravityView_frontend::entry' => $value->as_entry(), + '\GravityView_View::_current_entry' => $value->as_entry(), + ) + ); break; case 'fields': - self::thaw( array( - '\GravityView_View::fields' => $value->as_configuration(), - ) ); + self::thaw( + array( + '\GravityView_View::fields' => $value->as_configuration(), + ) + ); break; case 'field': - self::thaw( array( - '\GravityView_View::_current_field' => array( - 'field_id' => $value->ID, - 'field' => $value->field, - 'field_settings' => $value->as_configuration(), - 'form' => \GravityView_View::getInstance()->getForm(), - 'field_type' => $value->type, /** {@since 1.6} */ - 'entry' => \GravityView_View::getInstance()->getCurrentEntry(), - 'UID' => $value->UID, + self::thaw( + array( + '\GravityView_View::_current_field' => array( + 'field_id' => $value->ID, + 'field' => $value->field, + 'field_settings' => $value->as_configuration(), + 'form' => \GravityView_View::getInstance()->getForm(), + 'field_type' => $value->type, + /** {@since 1.6} */ + 'entry' => \GravityView_View::getInstance()->getCurrentEntry(), + 'UID' => $value->UID, // 'field_path' => $field_path, /** {@since 1.16} */ // 'value' => $value, // 'display_value' => $display_value, // 'format' => $format, - ), - ) ); + ), + ) + ); break; case 'request': - self::thaw( array( - '\GravityView_View::context' => ( - $value->is_entry() ? 'single' : - ( $value->is_edit_entry() ? 'edit' : - ( $value->is_view( false ) ? 'directory': null ) - ) - ), - '\GravityView_frontend::is_search' => $value->is_search(), - ) ); + self::thaw( + array( + '\GravityView_View::context' => ( + $value->is_entry() ? 'single' : + ( $value->is_edit_entry() ? 'edit' : + ( $value->is_view( false ) ? 'directory' : null ) + ) + ), + '\GravityView_frontend::is_search' => $value->is_search(), + ) + ); if ( ! $value->is_entry() ) { - self::thaw( array( - '\GravityView_frontend::single_entry' => 0, - '\GravityView_frontend::entry' => 0 - ) ); + self::thaw( + array( + '\GravityView_frontend::single_entry' => 0, + '\GravityView_frontend::entry' => 0, + ) + ); } break; case 'paging': - self::thaw( array( - '\GravityView_View::paging' => $value, - ) ); + self::thaw( + array( + '\GravityView_View::paging' => $value, + ) + ); break; case 'sorting': - self::thaw( array( - '\GravityView_View::sorting' => $value, - ) ); + self::thaw( + array( + '\GravityView_View::sorting' => $value, + ) + ); break; case 'in_the_loop': - self::thaw( array( - 'wp_query::in_the_loop' => $value, - 'wp_actions[loop_start]' => $value ? 1 : 0, - ) ); + self::thaw( + array( + 'wp_query::in_the_loop' => $value, + 'wp_actions[loop_start]' => $value ? 1 : 0, + ) + ); break; endswitch; } @@ -688,113 +740,127 @@ public static function load( $configuration ) { * @return void */ public static function reset() { - \GravityView_View::$instance = null; - \GravityView_frontend::$instance = null; + \GravityView_View::$instance = null; + \GravityView_frontend::$instance = null; \GravityView_View_Data::$instance = null; global $wp_query, $wp_actions; - $wp_query->in_the_loop = false; + $wp_query->in_the_loop = false; $wp_actions['loop_start'] = 0; } } /** Add some global fix for field capability discrepancies. */ -add_filter( 'gravityview/configuration/fields', function( $fields ) { - if ( empty( $fields ) ) { - return $fields; - } - - /** - * Each view field is saved in a weird capability state by default. - * - * With loggedin set to false, but a capability of 'read' it introduces - * some logical issues and is not robust. Fix this behavior throughout - * core by making sure capability is '' if log in is not required. - * - * Perhaps in the UI a fix would be to unite the two fields (as our new - * \GV\Field class already does) into one dropdown: - * - * Anyone, Logged In Only, ... etc. etc. - * - * The two "settings" should be as tightly coupled as possible to avoid - * split logic scenarios. Uniting them into one field is the way to go. - */ +add_filter( + 'gravityview/configuration/fields', + function ( $fields ) { + if ( empty( $fields ) ) { + return $fields; + } - foreach ( $fields as $position => &$_fields ) { + /** + * Each view field is saved in a weird capability state by default. + * + * With loggedin set to false, but a capability of 'read' it introduces + * some logical issues and is not robust. Fix this behavior throughout + * core by making sure capability is '' if log in is not required. + * + * Perhaps in the UI a fix would be to unite the two fields (as our new + * \GV\Field class already does) into one dropdown: + * + * Anyone, Logged In Only, ... etc. etc. + * + * The two "settings" should be as tightly coupled as possible to avoid + * split logic scenarios. Uniting them into one field is the way to go. + */ - if ( empty( $_fields ) || ! is_array( $_fields ) ) { - continue; - } + foreach ( $fields as $position => &$_fields ) { - foreach ( $_fields as $uid => &$_field ) { - if ( ! isset( $_field['only_loggedin'] ) ) { + if ( empty( $_fields ) || ! is_array( $_fields ) ) { continue; } - /** If we do not require login, we don't require a cap. */ - $_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' ); + + foreach ( $_fields as $uid => &$_field ) { + if ( ! isset( $_field['only_loggedin'] ) ) { + continue; + } + /** If we do not require login, we don't require a cap. */ + '1' != $_field['only_loggedin'] && ( $_field['only_loggedin_cap'] = '' ); + } } + return $fields; } - return $fields; -} ); +); /** Add a future fix to make sure field configurations include the form ID. */ -add_filter( 'gravityview/view/configuration/fields', function( $fields, $view ) { - if ( ! $view || empty( $fields ) ) { - return $fields; - } +add_filter( + 'gravityview/view/configuration/fields', + function ( $fields, $view ) { + if ( ! $view || empty( $fields ) ) { + return $fields; + } - if ( ! $view->form || ! $view->form->ID ) { - return $fields; - } + if ( ! $view->form || ! $view->form->ID ) { + return $fields; + } - /** - * In order to instantiate the correct \GV\Field implementation - * we need to provide a form_id inside the configuration. - * - * @todo Make sure this actually happens in the admin side - * when saving the views. - */ - foreach ( $fields as $position => &$_fields ) { + /** + * In order to instantiate the correct \GV\Field implementation + * we need to provide a form_id inside the configuration. + * + * @todo Make sure this actually happens in the admin side + * when saving the views. + */ + foreach ( $fields as $position => &$_fields ) { - if ( empty( $_fields ) || ! is_array( $_fields ) ) { - continue; - } + if ( empty( $_fields ) || ! is_array( $_fields ) ) { + continue; + } - foreach ( $_fields as $uid => &$_field ) { - if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) { - $_field['form_id'] = $view->form->ID; + foreach ( $_fields as $uid => &$_field ) { + if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) { + $_field['form_id'] = $view->form->ID; + } } } - } - return $fields; -}, 10, 2 ); + return $fields; + }, + 10, + 2 +); /** Make sure the non-configured notice is not output twice. */ -add_action( 'gravityview/template/after', function( $gravityview = null ) { - if ( class_exists( '\GravityView_frontend' ) ) { - global $wp_filter; - - if ( empty( $wp_filter['gravityview_after'] ) ) { - return; - } +add_action( + 'gravityview/template/after', + function ( $gravityview = null ) { + if ( class_exists( '\GravityView_frontend' ) ) { + global $wp_filter; + + if ( empty( $wp_filter['gravityview_after'] ) ) { + return; + } - foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) { - if ( strpos( $function_key, 'context_not_configured_warning' ) ) { - unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] ); + foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) { + if ( strpos( $function_key, 'context_not_configured_warning' ) ) { + unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] ); + } } } } -} ); +); -add_filter( 'gravityview/query/is_null_condition', function() { - if ( ! class_exists( $class = '\GV\Mocks\GF_Query_Condition_IS_NULL' ) ) { - require_once gravityview()->plugin->dir( 'future/_mocks.isnull.php' ); - } +add_filter( + 'gravityview/query/is_null_condition', + function () { + if ( ! class_exists( $class = '\GV\Mocks\GF_Query_Condition_IS_NULL' ) ) { + require_once gravityview()->plugin->dir( 'future/_mocks.isnull.php' ); + } - return $class; -} ); + return $class; + } +); diff --git a/future/_mocks.timesort.php b/future/_mocks.timesort.php index 1e4a54fc5e..88f8c1a0f7 100644 --- a/future/_mocks.timesort.php +++ b/future/_mocks.timesort.php @@ -11,34 +11,34 @@ public function timesort_sql( $query ) { global $wpdb; list( $column, $sql ) = $this->parameters; - $meta_table = \GFFormsModel::get_entry_meta_table_name(); + $meta_table = \GFFormsModel::get_entry_meta_table_name(); $alias = $query->_alias( $column->field_id, $column->source, 'm' ); -/* -SELECT v, -IF( -POSITION('pm' IN v) > 0, + /* + SELECT v, + IF( + POSITION('pm' IN v) > 0, -( -SUBSTRING_INDEX(v, ':', 1) -+ IF(SUBSTRING_INDEX(v, ':', 1) < 12, 12, 0) -) * 60, + ( + SUBSTRING_INDEX(v, ':', 1) + + IF(SUBSTRING_INDEX(v, ':', 1) < 12, 12, 0) + ) * 60, -SUBSTRING_INDEX(v, ':', 1) * 60 -) + -RIGHT(IF( -POSITION('m' IN v) > 0, -SUBSTRING_INDEX(v, ' ', 1), -v -),2) t1 + SUBSTRING_INDEX(v, ':', 1) * 60 + ) + + RIGHT(IF( + POSITION('m' IN v) > 0, + SUBSTRING_INDEX(v, ' ', 1), + v + ),2) t1 -FROM meta; -*/ + FROM meta; + */ // Detect if 'pm' is in the time field $pm_exists = "POSITION('pm' IN $alias.`meta_value`)"; - + // Transform a pm time into minutes ((hour + (12 if hour > 12 else 0)) * 60) $minutes_12 = "(SUBSTRING_INDEX($alias.`meta_value`, ':', 1) + IF(SUBSTRING_INDEX($alias.`meta_value`, ':', 1) < 12, 12, 0)) * 60"; diff --git a/future/gravityview.php b/future/gravityview.php index 4a45a634fc..db9ff7e558 100644 --- a/future/gravityview.php +++ b/future/gravityview.php @@ -29,4 +29,3 @@ function gravityview() { /** Liftoff...*/ add_action( 'plugins_loaded', 'gravityview', 1 ); - diff --git a/future/includes/class-gv-collection-entry-filter-gravityforms.php b/future/includes/class-gv-collection-entry-filter-gravityforms.php index 5eb6816d7c..850337a773 100644 --- a/future/includes/class-gv-collection-entry-filter-gravityforms.php +++ b/future/includes/class-gv-collection-entry-filter-gravityforms.php @@ -27,7 +27,7 @@ class GF_Entry_Filter extends Entry_Filter { * @return \GV\GF_Entry_Filter The filter. */ public static function from_search_criteria( $search_criteria ) { - $filter = new self(); + $filter = new self(); $filter->search_criteria = $search_criteria; return $filter; } @@ -48,7 +48,7 @@ public static function merge_search_criteria( $a, $b ) { $search_criteria = array(); foreach ( array( 'field_filters', 'start_date', 'end_date', 'status' ) as $key ) { - switch ( $key ): + switch ( $key ) : case 'field_filters': $field_filters = array_merge( empty( $a[ $key ] ) ? array() : $a[ $key ], empty( $b[ $key ] ) ? array() : $b[ $key ] ); if ( ! empty( $field_filters ) ) { @@ -56,9 +56,9 @@ public static function merge_search_criteria( $a, $b ) { } if ( ! empty( $b[ $key ]['mode'] ) ) { - $search_criteria[ $key ]['mode' ] = $b[ $key ]['mode']; - } else if ( ! empty( $a[ $key ]['mode'] ) ) { - $search_criteria[ $key ]['mode' ] = $a[ $key ]['mode']; + $search_criteria[ $key ]['mode'] = $b[ $key ]['mode']; + } elseif ( ! empty( $a[ $key ]['mode'] ) ) { + $search_criteria[ $key ]['mode'] = $a[ $key ]['mode']; } break; case 'start_date': @@ -66,7 +66,7 @@ public static function merge_search_criteria( $a, $b ) { case 'status': if ( isset( $b[ $key ] ) ) { $search_criteria[ $key ] = $b[ $key ]; - } else if ( isset( $a[ $key ] ) ) { + } elseif ( isset( $a[ $key ] ) ) { $search_criteria[ $key ] = $a[ $key ]; } break; diff --git a/future/includes/class-gv-collection-entry-filter.php b/future/includes/class-gv-collection-entry-filter.php index d8c5b373fc..58c5dc77c2 100644 --- a/future/includes/class-gv-collection-entry-filter.php +++ b/future/includes/class-gv-collection-entry-filter.php @@ -13,11 +13,11 @@ * similar to the new-school ORMs out there. * * new Entry_Filter( - * Field::by_id( 3 )->eq( 99 )->and( - * Field::by_id( 4 )->neq( null )->or( Field::by_id( 4 )->lte( 0 ) ) - * )->and( - * Field::by_id( 5 )->like( "%search%" )->and( Field::by_id( 6 )->between( $t, $f ) ) - * ) + * Field::by_id( 3 )->eq( 99 )->and( + * Field::by_id( 4 )->neq( null )->or( Field::by_id( 4 )->lte( 0 ) ) + * )->and( + * Field::by_id( 5 )->like( "%search%" )->and( Field::by_id( 6 )->between( $t, $f ) ) + * ) * ); * * Very flexible in code, but unserialization could be a pain in the neck. diff --git a/future/includes/class-gv-collection-entry-offset.php b/future/includes/class-gv-collection-entry-offset.php index 8da03e70e1..00f6d67851 100644 --- a/future/includes/class-gv-collection-entry-offset.php +++ b/future/includes/class-gv-collection-entry-offset.php @@ -7,7 +7,7 @@ } /** - * Filtering window settings: + * Filtering window settings: * * Offset and limit, pagination. */ @@ -29,7 +29,7 @@ class Entry_Offset { public function to_paging( $page = 1 ) { return array( 'page_size' => $this->limit, - 'offset' => ( ( $page - 1 ) * $this->limit ) + $this->offset, + 'offset' => ( ( $page - 1 ) * $this->limit ) + $this->offset, ); } } diff --git a/future/includes/class-gv-collection-entry-sort.php b/future/includes/class-gv-collection-entry-sort.php index c7eacb839e..a2452b9951 100644 --- a/future/includes/class-gv-collection-entry-sort.php +++ b/future/includes/class-gv-collection-entry-sort.php @@ -55,8 +55,8 @@ class Entry_Sort { * Instantiate a sort for a field. * * @param \GV\Field $field The field we're sorting by. - * @param string $direction The direction of this sort (\GV\Entry_Sort::ASC, \GV\Entry_Sort::DESC, etc.). Default: self::ASC. - * @param string $mode The sort mode (self::NUMERIC). Default: self::ALPHA. + * @param string $direction The direction of this sort (\GV\Entry_Sort::ASC, \GV\Entry_Sort::DESC, etc.). Default: self::ASC. + * @param string $mode The sort mode (self::NUMERIC). Default: self::ALPHA. * * @api * @since 2.0 @@ -64,9 +64,9 @@ class Entry_Sort { * @return \GV\Entry_Sort An instance of this class, pass to \GV\Entry_Collection::sort() */ public function __construct( \GV\Field $field, $direction = self::ASC, $mode = self::ALPHA ) { - $this->field = $field; + $this->field = $field; $this->direction = $direction; - $this->mode = $mode; + $this->mode = $mode; } /** @@ -77,8 +77,8 @@ public function __construct( \GV\Field $field, $direction = self::ASC, $mode = s public function to_sorting() { if ( $this->field ) { return array( - 'key' => $this->field->ID, - 'direction' => $this->direction ? : self::ASC, + 'key' => $this->field->ID, + 'direction' => $this->direction ? : self::ASC, 'is_numeric' => self::ALPHA ? true : false, ); } diff --git a/future/includes/class-gv-collection-entry.php b/future/includes/class-gv-collection-entry.php index 32d5292d90..e85fc4728d 100644 --- a/future/includes/class-gv-collection-entry.php +++ b/future/includes/class-gv-collection-entry.php @@ -74,7 +74,7 @@ public function add( $entry ) { /** * Get a \GV\Entry from this list. * - * @param int $entry_id The ID of the entry to get. + * @param int $entry_id The ID of the entry to get. * @param string $backend The form backend identifier, allows for multiple form backends in the future. Unused until then. * * @api @@ -104,7 +104,7 @@ public function total() { /** Call all lazy callbacks. */ foreach ( $this->callbacks as $callback ) { - if ( $callback[0] != 'count' ) { + if ( 'count' != $callback[0] ) { continue; } @@ -147,7 +147,7 @@ public function pluck( $key ) { $result = array(); foreach ( $this->all() as $entry ) { - $entry = $entry->as_entry(); + $entry = $entry->as_entry(); $result[] = Utils::get( $entry, $key, null ); } @@ -201,13 +201,13 @@ public function fetch() { $this->clear(); /** Calculate the offsets. */ - $offset = new \GV\Entry_Offset(); - $offset->limit = $this->limit; + $offset = new \GV\Entry_Offset(); + $offset->limit = $this->limit; $offset->offset = ( $this->limit * ( $this->current_page - 1 ) ) + $this->offset; /** Call all lazy callbacks. */ foreach ( $this->callbacks as $i => $callback ) { - if ( $callback[0] != 'fetch' ) { + if ( 'fetch' != $callback[0] ) { continue; } @@ -368,7 +368,7 @@ private function add_callback( $type, $callback ) { return; } - $this->callbacks []= array( $type, $callback ); + $this->callbacks [] = array( $type, $callback ); } /** diff --git a/future/includes/class-gv-collection-field.php b/future/includes/class-gv-collection-field.php index fc0924bb07..5351747745 100644 --- a/future/includes/class-gv-collection-field.php +++ b/future/includes/class-gv-collection-field.php @@ -111,20 +111,20 @@ public function by_visible( $view = null ) { * * array( * - * [other zones] + * [other zones] * - * 'directory_list-title' => array( + * 'directory_list-title' => array( * - * [other fields] + * [other fields] * - * '5372653f25d44' => array( - * @see \GV\Field::as_configuration() for structure - * ) + * '5372653f25d44' => array( + * @see \GV\Field::as_configuration() for structure + * ) * - * [other fields] + * [other fields] * ) * - * [other zones] + * [other zones] * ) * * @return \GV\Field_Collection A collection of fields. @@ -138,8 +138,8 @@ public static function from_configuration( $configuration ) { } foreach ( $_fields as $uid => $_configuration ) { - $field = Field::from_configuration( $_configuration ); - $field->UID = $uid; + $field = Field::from_configuration( $_configuration ); + $field->UID = $uid; $field->position = $position; $fields->add( $field ); diff --git a/future/includes/class-gv-collection-form.php b/future/includes/class-gv-collection-form.php index a0409a5b47..6910f59d29 100644 --- a/future/includes/class-gv-collection-form.php +++ b/future/includes/class-gv-collection-form.php @@ -30,7 +30,7 @@ public function add( $form ) { /** * Get a \GV\Form from this list. * - * @param int $form_id The ID of the form to get. + * @param int $form_id The ID of the form to get. * @param string $backend The form backend identifier, allows for multiple form backends in the future. Unused until then. * * @api diff --git a/future/includes/class-gv-collection-view.php b/future/includes/class-gv-collection-view.php index 46d05a1452..d576a3cbaa 100644 --- a/future/includes/class-gv-collection-view.php +++ b/future/includes/class-gv-collection-view.php @@ -96,7 +96,7 @@ public static function from_post( \WP_Post $post ) { $views->merge( self::from_content( $post->post_content ) ); /** - * @filter `gravityview/view_collection/from_post/meta_keys` Define meta keys to parse to check for GravityView shortcode content. + * Define meta keys to parse to check for GravityView shortcode content. * * This is useful when using themes that store content that may contain shortcodes in custom post meta. * @@ -131,7 +131,7 @@ public static function from_post( \WP_Post $post ) { * @since 2.1 * * @param \GV\View_Collection $views Existing View Collection to merge with - * @param string|array $meta_value Value to parse. Normally the value of $post->{$meta_key}. + * @param string|array $meta_value Value to parse. Normally the value of $post->{$meta_key}. * * @return \GV\View_Collection $views View Collection containing any additional Views found */ @@ -168,7 +168,7 @@ public static function from_content( $content ) { /** Let's find us some [gravityview] shortcodes perhaps. */ foreach ( Shortcode::parse( $content ) as $shortcode ) { - if ( $shortcode->name != 'gravityview' || empty( $shortcode->atts['id'] ) ) { + if ( 'gravityview' != $shortcode->name || empty( $shortcode->atts['id'] ) ) { continue; } diff --git a/future/includes/class-gv-collection-widget.php b/future/includes/class-gv-collection-widget.php index 9662e79ade..bf3c9d1bd8 100644 --- a/future/includes/class-gv-collection-widget.php +++ b/future/includes/class-gv-collection-widget.php @@ -98,20 +98,20 @@ public function by_id( $id ) { * * array( * - * [other zones] + * [other zones] * - * 'footer_right' => array( + * 'footer_right' => array( * - * [other widgets] + * [other widgets] * - * '5372653f25d44' => array( - * @see \GV\Widget::as_configuration() for structure - * ) + * '5372653f25d44' => array( + * @see \GV\Widget::as_configuration() for structure + * ) * - * [other widgets] + * [other widgets] * ) * - * [other zones] + * [other zones] * ) * * @return \GV\Widget_Collection A collection of widgets. @@ -129,7 +129,7 @@ public static function from_configuration( $configuration ) { continue; } - $widget->UID = $uid; + $widget->UID = $uid; $widget->position = $position; $widgets->add( $widget ); diff --git a/future/includes/class-gv-collection.php b/future/includes/class-gv-collection.php index 38b6696490..4a4e186833 100644 --- a/future/includes/class-gv-collection.php +++ b/future/includes/class-gv-collection.php @@ -25,7 +25,7 @@ class Collection { * @return void */ public function add( $value ) { - $this->storage []= $value; + $this->storage [] = $value; } /** @@ -49,7 +49,7 @@ public function clear() { * @return void */ public function merge( \GV\Collection $collection ) { - array_map( array( $this, 'add'), $collection->all() ); + array_map( array( $this, 'add' ), $collection->all() ); } /** diff --git a/future/includes/class-gv-context-template.php b/future/includes/class-gv-context-template.php index 06bf982a03..556765ce8b 100644 --- a/future/includes/class-gv-context-template.php +++ b/future/includes/class-gv-context-template.php @@ -66,7 +66,7 @@ class Template_Context extends Context { * Create a context from a Template * * @param \GV\Template|array $template The template or array with values expected in a template - * @param array $data Additional data not tied to the template object. + * @param array $data Additional data not tied to the template object. * * @return \GV\Template_Context The context holder. */ @@ -79,19 +79,19 @@ public static function from_template( $template, $data = array() ) { * Data. */ $context->display_value = Utils::get( $data, 'display_value' ); - $context->value = Utils::get( $data, 'value' ); + $context->value = Utils::get( $data, 'value' ); /** * Shortcuts. */ - $context->view = Utils::get( $template, 'view' ); - $context->source = Utils::get( $template, 'source' ); - $context->field = Utils::get( $template, 'field' ) ? : Utils::get( $data, 'field' ); - $context->entry = Utils::get( $template, 'entry' ) ? : Utils::get( $data, 'entry' ); + $context->view = Utils::get( $template, 'view' ); + $context->source = Utils::get( $template, 'source' ); + $context->field = Utils::get( $template, 'field' ) ? : Utils::get( $data, 'field' ); + $context->entry = Utils::get( $template, 'entry' ) ? : Utils::get( $data, 'entry' ); $context->request = Utils::get( $template, 'request' ); $context->entries = Utils::get( $template, 'entries' ) ? $template->entries : null; - $context->fields = $context->view ? $context->view->fields : null; + $context->fields = $context->view ? $context->view->fields : null; return $context; } diff --git a/future/includes/class-gv-core.php b/future/includes/class-gv-core.php index 3920ceb018..8f0584b938 100644 --- a/future/includes/class-gv-core.php +++ b/future/includes/class-gv-core.php @@ -50,7 +50,7 @@ final class Core { */ public static function get() { if ( ! self::$__instance instanceof self ) { - self::$__instance = new self; + self::$__instance = new self(); } return self::$__instance; } @@ -61,7 +61,7 @@ public static function get() { * Activation handlers, rewrites, post type registration. */ public static function bootstrap() { - require_once dirname( __FILE__ ) . '/class-gv-plugin.php'; + require_once __DIR__ . '/class-gv-plugin.php'; Plugin::get()->register_activation_hooks(); } @@ -88,7 +88,8 @@ private function init() { /** Enable logging. */ require_once $this->plugin->dir( 'future/includes/class-gv-logger.php' ); /** - * @filter `gravityview/logger` Filter the logger instance being used for logging. + * Filter the logger instance being used for logging. + * * @param \GV\Logger $logger The logger instance. */ $this->log = apply_filters( 'gravityview/logger', new WP_Action_Logger() ); @@ -114,14 +115,14 @@ private function init() { /** Require critical legacy core files. @todo Deprecate */ require_once $this->plugin->dir( 'includes/import-functions.php' ); require_once $this->plugin->dir( 'includes/helper-functions.php' ); - require_once $this->plugin->dir( 'includes/class-common.php'); - require_once $this->plugin->dir( 'includes/connector-functions.php'); + require_once $this->plugin->dir( 'includes/class-common.php' ); + require_once $this->plugin->dir( 'includes/connector-functions.php' ); require_once $this->plugin->dir( 'includes/class-gravityview-compatibility.php' ); require_once $this->plugin->dir( 'includes/class-gravityview-roles-capabilities.php' ); require_once $this->plugin->dir( 'includes/class-gravityview-admin-notices.php' ); require_once $this->plugin->dir( 'includes/class-admin.php' ); - require_once $this->plugin->dir( 'includes/class-post-types.php'); - require_once $this->plugin->dir( 'includes/class-cache.php'); + require_once $this->plugin->dir( 'includes/class-post-types.php' ); + require_once $this->plugin->dir( 'includes/class-cache.php' ); /** * GravityView extensions and widgets. @@ -238,7 +239,7 @@ private function init() { add_action( 'clean_post_cache', '\GV\View::_flush_cache' ); /** - * @action `gravityview/loaded` The core has been loaded. + * The core has been loaded. * * Note: this is a very early load hook, not all of WordPress core has been loaded here. * `init` hasn't been called yet. diff --git a/future/includes/class-gv-entry-gravityforms.php b/future/includes/class-gv-entry-gravityforms.php index 85b84c5c29..2ca6f05fed 100644 --- a/future/includes/class-gv-entry-gravityforms.php +++ b/future/includes/class-gv-entry-gravityforms.php @@ -33,7 +33,7 @@ private function __construct() { * Construct a \GV\Entry instance by ID. * * @param int|string $entry_id The internal entry ID. - * @param int $form_id The form ID, since slugs can be non-unique. Default: 0. + * @param int $form_id The form ID, since slugs can be non-unique. Default: 0. * * @api * @since 2.0 @@ -63,7 +63,7 @@ public static function by_id( $entry_id, $form_id = 0 ) { * Construct a \GV\Entry instance by slug name. * * @param int|string $entry_slug The registered slug for the entry. - * @param int $form_id The form ID, since slugs can be non-unique. Default: 0. + * @param int $form_id The form ID, since slugs can be non-unique. Default: 0. * * @api * @since 2.0 @@ -74,15 +74,14 @@ public static function by_slug( $entry_slug, $form_id = 0 ) { if ( version_compare( \GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { $entry_meta = \GFFormsModel::get_entry_meta_table_name(); - $sql = "SELECT entry_id FROM $entry_meta"; + $sql = "SELECT entry_id FROM $entry_meta"; } else { $lead_meta = \GFFormsModel::get_lead_meta_table_name(); - $sql = "SELECT lead_id FROM $lead_meta"; + $sql = "SELECT lead_id FROM $lead_meta"; } $sql = "$sql WHERE meta_key = 'gravityview_unique_id' AND"; - if ( $form_id = apply_filters( 'gravityview/common/get_entry_id_from_slug/form_id', $form_id ) ) { $sql = $wpdb->prepare( "$sql meta_value = %s AND form_id = %s", $entry_slug, $form_id ); } else { @@ -110,10 +109,10 @@ public static function from_entry( $entry ) { return null; } - $self = new self(); + $self = new self(); $self->entry = $entry; - $self->ID = $self->entry['id']; + $self->ID = $self->entry['id']; $self->slug = $self->get_slug(); return $self; @@ -129,7 +128,7 @@ public static function from_entry( $entry ) { */ #[\ReturnTypeWillChange] public function offsetExists( $offset ) { - return isset( $this->entry[$offset] ); + return isset( $this->entry[ $offset ] ); } /** @@ -145,7 +144,7 @@ public function offsetExists( $offset ) { */ #[\ReturnTypeWillChange] public function offsetGet( $offset ) { - return $this->entry[$offset]; + return $this->entry[ $offset ]; } /** diff --git a/future/includes/class-gv-entry-multi.php b/future/includes/class-gv-entry-multi.php index be663979b7..d41b18a671 100644 --- a/future/includes/class-gv-entry-multi.php +++ b/future/includes/class-gv-entry-multi.php @@ -44,7 +44,7 @@ public static function from_entries( $entries ) { if ( ! $entry instanceof Entry ) { continue; } - $_entry->entries[ $entry['form_id'] ] = &$entry; + $_entry->entries[ $entry['form_id'] ] = &$entry; } return $_entry; } @@ -64,7 +64,7 @@ public function as_entry() { $_entry = $entry->as_entry(); foreach ( $this->entries as $entry ) { - $entry = $entry->as_entry(); + $entry = $entry->as_entry(); $_entry['_multi'][ $entry['form_id'] ] = $entry; } } @@ -79,17 +79,22 @@ public function as_entry() { * @since 2.2 * * @param \GV\View|null $view The View context. - * @param \GV\Request $request The Request (current if null). - * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. + * @param \GV\Request $request The Request (current if null). + * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. * * @return string The permalink to this entry. */ public function get_permalink( \GV\View $view = null, \GV\Request $request = null, $track_directory = true ) { - $slugs = array(); - add_filter( 'gravityview/entry/slug', $callback = function( $slug ) use ( &$slugs ) { - $slugs[] = $slug; - return implode( ',', $slugs ); - }, 10, 1 ); + $slugs = array(); + add_filter( + 'gravityview/entry/slug', + $callback = function ( $slug ) use ( &$slugs ) { + $slugs[] = $slug; + return implode( ',', $slugs ); + }, + 10, + 1 + ); foreach ( $this->entries as $entry ) { $permalink = call_user_func_array( array( $entry, __FUNCTION__ ), func_get_args() ); diff --git a/future/includes/class-gv-entry.php b/future/includes/class-gv-entry.php index c59c8ef77c..a0f3ec0f4f 100644 --- a/future/includes/class-gv-entry.php +++ b/future/includes/class-gv-entry.php @@ -62,7 +62,8 @@ public static function add_rewrite_endpoint() { */ public static function get_endpoint_name() { /** - * @filter `gravityview_directory_endpoint` Change the slug used for single entries + * Change the slug used for single entries. + * * @param string $endpoint Slug to use when accessing single entry. Default: `entry` */ $endpoint = apply_filters( 'gravityview_directory_endpoint', 'entry' ); @@ -99,8 +100,8 @@ public function as_entry() { * @since 2.0 * * @param \GV\View|null $view The View context. - * @param \GV\Request $request The Request (current if null). - * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. + * @param \GV\Request $request The Request (current if null). + * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. * * @return string The permalink to this entry. */ @@ -114,7 +115,8 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul $args = array(); /** - * @filter `gravityview/entry_link/add_query_args` Modify whether to include passed $_GET parameters to the end of the url + * Modify whether to include passed $_GET parameters to the end of the url. + * * @since 2.10 * @param bool $add_query_params Whether to include passed $_GET parameters to the end of the Entry Link URL. Default: true. */ @@ -124,7 +126,7 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul $args = gv_get_query_args(); } - $view_id = is_null ( $view ) ? null : $view->ID; + $view_id = is_null( $view ) ? null : $view->ID; $permalink = null; @@ -137,7 +139,7 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul $view_collection = View_Collection::from_post( $post ); - if( 1 < $view_collection->count() ) { + if ( 1 < $view_collection->count() ) { $args['gvid'] = $view_id; } } @@ -149,14 +151,15 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul } /** - * @filter `gravityview_directory_link` Modify the URL to the View "directory" context + * Modify the URL to the View "directory" context. + * * @since 1.19.4 * @param string $link URL to the View's "directory" context (Multiple Entries screen) * @param int $post_id ID of the post to link to. If the View is embedded, it is the post or page ID */ $permalink = apply_filters( 'gravityview_directory_link', $permalink, $request->is_view( false ) ? $view_id : ( $post ? $post->ID : null ) ); - $entry_endpoint_name = \GV\Entry::get_endpoint_name(); + $entry_endpoint_name = self::get_endpoint_name(); $entry_slug = $this->get_slug( true, $view, $request, $track_directory ); @@ -164,13 +167,14 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul if ( get_option( 'permalink_structure' ) && ! is_preview() ) { /** * Make sure the $directory_link doesn't contain any query otherwise it will break when adding the entry slug. + * * @since 1.16.5 */ $link_parts = explode( '?', $permalink ); $query = ! empty( $link_parts[1] ) ? '?' . $link_parts[1] : ''; - $permalink = trailingslashit( $link_parts[0] ) . $entry_endpoint_name . '/'. $entry_slug .'/' . $query; + $permalink = trailingslashit( $link_parts[0] ) . $entry_endpoint_name . '/' . $entry_slug . '/' . $query; } else { $args[ $entry_endpoint_name ] = $entry_slug; } @@ -182,14 +186,15 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul if ( $sort = Utils::_GET( 'sort' ) ) { $args['sort'] = $sort; - $args['dir'] = Utils::_GET( 'dir' ); + $args['dir'] = Utils::_GET( 'dir' ); } } $permalink = add_query_arg( $args, $permalink ); /** - * @filter `gravityview/entry/permalink` The permalink of this entry. + * The permalink of this entry. + * * @since 2.0 * @param string $permalink The permalink. * @param \GV\Entry $entry The entry we're retrieving it for. @@ -209,10 +214,10 @@ public function get_permalink( \GV\View $view = null, \GV\Request $request = nul * * @uses \GravityView_API::get_entry_slug * - * @param bool $apply_filter Whether to apply the `gravityview/entry/slug` filter. Default: false. + * @param bool $apply_filter Whether to apply the `gravityview/entry/slug` filter. Default: false. * @param \GV\View|null $view The View context. - * @param \GV\Request $request The Request (current if null). - * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. + * @param \GV\Request $request The Request (current if null). + * @param boolean $track_directory Keep the housing directory arguments intact (used for breadcrumbs, for example). Default: true. * * @return string Unique slug ID, passed through `sanitize_title()`, with `gravityview/entry/slug` filter applied */ @@ -220,12 +225,13 @@ public function get_slug( $apply_filter = false, \GV\View $view = null, \GV\Requ $entry_slug = \GravityView_API::get_entry_slug( $this->ID, $this->as_entry() ); - if( ! $apply_filter ) { + if ( ! $apply_filter ) { return $entry_slug; } /** - * @filter `gravityview/entry/slug` Modify the entry URL slug as needed. + * Modify the entry URL slug as needed. + * * @since 2.2.1 * @param string $entry_slug The slug, sanitized with sanitize_title() * @param null|\GV\Entry $this The entry object. @@ -255,7 +261,7 @@ public function is_multi() { * @since 2.2 * * @param \GV\Field $field The field to filter by. - * @param int $fallback A fallback form_id if the field supplied is invalid. + * @param int $fallback A fallback form_id if the field supplied is invalid. * * @return \GV\Entry|null A \GV\Entry or null if not found. */ diff --git a/future/includes/class-gv-extension.php b/future/includes/class-gv-extension.php index 24576b34f9..98d333e09c 100644 --- a/future/includes/class-gv-extension.php +++ b/future/includes/class-gv-extension.php @@ -19,18 +19,18 @@ abstract class Extension { /** * @var string Name of the plugin in gravitykit.com */ - protected $_title = NULL; + protected $_title = null; /** * @var string Version number of the plugin */ - protected $_version = NULL; + protected $_version = null; /** * @var int The ID of the download on gravitykit.com * @since 1.1 */ - protected $_item_id = NULL; + protected $_item_id = null; /** * @var string Translation textdomain @@ -65,13 +65,13 @@ abstract class Extension { /** * @var array Admin notices to display */ - static protected $admin_notices = array(); + protected static $admin_notices = array(); /** * @var boolean[] An array of extension compatibility. * @since 2.0 This is an array of classes instead. */ - static public $is_compatible = array(); + public static $is_compatible = array(); /** * Generic initialization. @@ -122,12 +122,12 @@ public function load_plugin_textdomain() { $locale = get_locale(); - if ( function_exists('get_user_locale') && is_admin() ) { + if ( function_exists( 'get_user_locale' ) && is_admin() ) { $locale = get_user_locale(); } // Traditional WordPress plugin locale filter - $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); + $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain ); $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); @@ -171,8 +171,8 @@ public function save_post( $post_id ) { } * * * $tooltips['gv_example_extension_setting'] = array( - * 'title' => 'About Example Extension Setting', - * 'value' => 'When you do [x] with [y], [z] happens.' + * 'title' => 'About Example Extension Setting', + * 'value' => 'When you do [x] with [y], [z] happens.' * ); * * @@ -212,14 +212,14 @@ public function add_metabox_tab() { } $tab_defaults = array( - 'id' => '', - 'title' => '', - 'callback' => '', - 'icon-class' => '', - 'file' => '', + 'id' => '', + 'title' => '', + 'callback' => '', + 'icon-class' => '', + 'file' => '', 'callback_args' => '', - 'context' => 'side', - 'priority' => 'default', + 'context' => 'side', + 'priority' => 'default', ); $tab = wp_parse_args( $tab_settings, $tab_defaults ); @@ -260,14 +260,14 @@ protected function is_extension_supported() { if ( ! function_exists( 'gravityview' ) ) { $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gk-gravityview' ), esc_html( $this->_title ) ); - } else if ( false === version_compare( Plugin::$version, $this->_min_gravityview_version , ">=" ) ) { - $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gk-gravityview' ), esc_html( $this->_title ), ''.$this->_min_gravityview_version.'' ); - } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=" ) ) { - $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gk-gravityview' ), esc_html( $this->_title ), ''.$this->_min_php_version.'' ); - } else if ( ! empty( $this->_max_gravityview_version ) && false === version_compare( $this->_max_gravityview_version, Plugin::$version, ">" ) ) { + } elseif ( false === version_compare( Plugin::$version, $this->_min_gravityview_version, '>=' ) ) { + $message = sprintf( __( 'The %1$s Extension requires GravityView Version %2$s or newer.', 'gk-gravityview' ), esc_html( $this->_title ), '' . $this->_min_gravityview_version . '' ); + } elseif ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, '>=' ) ) { + $message = sprintf( __( 'The %1$s Extension requires PHP Version %2$s or newer. Please ask your host to upgrade your server\'s PHP.', 'gk-gravityview' ), esc_html( $this->_title ), '' . $this->_min_php_version . '' ); + } elseif ( ! empty( $this->_max_gravityview_version ) && false === version_compare( $this->_max_gravityview_version, Plugin::$version, '>' ) ) { $message = sprintf( __( 'The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gk-gravityview' ), esc_html( $this->_title ) ); } else { - $message = ''; + $message = ''; self::$is_compatible[ get_called_class() ] = gravityview()->plugin->is_compatible(); } @@ -292,13 +292,13 @@ public static function add_notice( $notice = array() ) { if ( is_array( $notice ) && empty( $notice['message'] ) ) { gravityview()->log->error( 'Notice not set', array( 'data' => $notice ) ); return; - } else if ( is_string( $notice ) ) { + } elseif ( is_string( $notice ) ) { $notice = array( 'message' => $notice ); } $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; - self::$admin_notices []= $notice; + self::$admin_notices [] = $notice; } /** @@ -312,13 +312,13 @@ public function admin_notice() { } foreach ( self::$admin_notices as $key => $notice ) { - echo '
'; + echo '
'; echo wpautop( $notice['message'] ); echo '
'; echo '
'; } - //reset the notices handler + // reset the notices handler self::$admin_notices = array(); } } diff --git a/future/includes/class-gv-field-gravityforms.php b/future/includes/class-gv-field-gravityforms.php index 26a24ff79a..fcdfee3f7f 100644 --- a/future/includes/class-gv-field-gravityforms.php +++ b/future/includes/class-gv-field-gravityforms.php @@ -28,19 +28,37 @@ class GF_Field extends Field { */ public static function from_configuration( $configuration ) { if ( empty( $configuration['id'] ) || ! is_numeric( $configuration['id'] ) ) { - gravityview()->log->error( 'Invalid configuration[id] supplied: {id}', array( 'data' => $configuration, 'id' => \GV\Utils::get( $configuration, 'id' ) ) ); + gravityview()->log->error( + 'Invalid configuration[id] supplied: {id}', + array( + 'data' => $configuration, + 'id' => \GV\Utils::get( $configuration, 'id' ), + ) + ); return null; } - if ( empty( $configuration['form_id'] ) || ! $form = \GV\GF_Form::by_id( $configuration['form_id'] ) ) { - gravityview()->log->error( 'Invalid configuration[form_id] supplied: {form_id}', array( 'data' => $configuration, 'form_id' => \GV\Utils::get( $configuration, 'form_id' ) ) ); + if ( empty( $configuration['form_id'] ) || ! $form = \GV\GF_Form::by_id( $configuration['form_id'] ) ) { + gravityview()->log->error( + 'Invalid configuration[form_id] supplied: {form_id}', + array( + 'data' => $configuration, + 'form_id' => \GV\Utils::get( $configuration, 'form_id' ), + ) + ); return null; } $field = self::by_id( $form, $configuration['id'] ); if ( ! $field ) { - gravityview()->log->error( 'Invalid configuration: Field not found by [id] supplied: {id}', array( 'data' => $configuration, 'id' => \GV\Utils::get( $configuration, 'id' ) ) ); + gravityview()->log->error( + 'Invalid configuration: Field not found by [id] supplied: {id}', + array( + 'data' => $configuration, + 'id' => \GV\Utils::get( $configuration, 'id' ), + ) + ); return null; } @@ -52,7 +70,7 @@ public static function from_configuration( $configuration ) { * Get a \GV\GF_Field by \GV\GF_Form and Field ID. * * @param \GV\GF_Form $form The Gravity Form form. - * @param int $field_id The Gravity Form field ID for the $form. + * @param int $field_id The Gravity Form field ID for the $form. * * @return \GV\Field|null The requested field or null if not found. */ @@ -68,16 +86,21 @@ public static function by_id( $form, $field_id ) { return null; } - $gv_field = \GFFormsModel::get_field( $form->form, $field_id ); if ( ! $gv_field ) { - gravityview()->log->error( 'Invalid $field_id #{field_id} for current source', array( 'data' => $form, 'field_id' => $field_id ) ); + gravityview()->log->error( + 'Invalid $field_id #{field_id} for current source', + array( + 'data' => $form, + 'field_id' => $field_id, + ) + ); return null; } - $field = new self(); - $field->ID = $field_id; + $field = new self(); + $field->ID = $field_id; $field->field = $gv_field; return $field; @@ -88,9 +111,9 @@ public static function by_id( $form, $field_id ) { * * Requires a \GV\GF_Form in this implementation. * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return string The label for this Gravity Forms field. @@ -130,9 +153,9 @@ public function get_label( View $view = null, Source $source = null, Entry $entr * * Requires a \GV\GF_Entry in this implementation. * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return mixed The value for this field. diff --git a/future/includes/class-gv-field-internal.php b/future/includes/class-gv-field-internal.php index 178d4bf1be..81b7ea26c0 100644 --- a/future/includes/class-gv-field-internal.php +++ b/future/includes/class-gv-field-internal.php @@ -30,7 +30,13 @@ class Internal_Field extends Field { public static function from_configuration( $configuration ) { if ( empty( $configuration['id'] ) || ! is_string( $configuration['id'] ) ) { - gravityview()->log->error( 'Invalid configuration[id] supplied for internal field: {id}', array( 'data' => $configuration, 'id' => \GV\Utils::get( $configuration, 'id' ) ) ); + gravityview()->log->error( + 'Invalid configuration[id] supplied for internal field: {id}', + array( + 'data' => $configuration, + 'id' => \GV\Utils::get( $configuration, 'id' ), + ) + ); return null; } @@ -49,12 +55,13 @@ public static function from_configuration( $configuration ) { * @return \GV\Internal_Field|null The requested field or null if not found. */ public static function by_id( $field_id ) { - $field = new self(); - $field->ID = $field_id; + $field = new self(); + $field->ID = $field_id; $field->type = $field->ID; /** * Retrieve the internal backing field (old for now) + * * @todo switch to future subclasses */ $field->field = \GravityView_Fields::get_instance( $field_id ); @@ -65,9 +72,9 @@ public static function by_id( $field_id ) { /** * Retrieve the label for this field. * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return string The label for this field. @@ -94,9 +101,9 @@ public function get_label( View $view = null, Source $source = null, Entry $entr * * Requires the \GV\Entry in this implementation. * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return mixed The value for this field. diff --git a/future/includes/class-gv-field.php b/future/includes/class-gv-field.php index 7ea5435cf2..c166183879 100644 --- a/future/includes/class-gv-field.php +++ b/future/includes/class-gv-field.php @@ -101,17 +101,17 @@ class Field { /** * Return an array of the old format as used by callers of `GVCommon:get_directory_fields()` for example. * - * 'id' => string '9' (length=1) - * 'label' => string 'Screenshots' (length=11) - * 'show_label' => string '1' (length=1) - * 'custom_label' => string '' (length=0) - * 'custom_class' => string 'gv-gallery' (length=10) - * 'only_loggedin' => string '0' (length=1) - * 'only_loggedin_cap' => string 'read' (length=4) - * 'search_filter' => string '0' - * 'show_as_link' => string '0' + * 'id' => string '9' (length=1) + * 'label' => string 'Screenshots' (length=11) + * 'show_label' => string '1' (length=1) + * 'custom_label' => string '' (length=0) + * 'custom_class' => string 'gv-gallery' (length=10) + * 'only_loggedin' => string '0' (length=1) + * 'only_loggedin_cap' => string 'read' (length=4) + * 'search_filter' => string '0' + * 'show_as_link' => string '0' * - * + whatever else specific field types may have + * + whatever else specific field types may have * * @internal * @since 2.0 @@ -119,17 +119,20 @@ class Field { * @return array */ public function as_configuration() { - return array_merge( array( - 'id' => $this->ID, - 'label' => $this->label, - 'show_label' => $this->show_label ? '1' : '0', - 'custom_label' => $this->custom_label, - 'custom_class' => $this->custom_class, - 'only_loggedin' => $this->cap ? '1' : '0', - 'only_loggedin_cap' => $this->cap, - 'search_filter' => $this->search_filter ? '1' : '0', - 'show_as_link' => $this->show_as_link ? '1' : '0', - ), $this->configuration ); + return array_merge( + array( + 'id' => $this->ID, + 'label' => $this->label, + 'show_label' => $this->show_label ? '1' : '0', + 'custom_label' => $this->custom_label, + 'custom_class' => $this->custom_class, + 'only_loggedin' => $this->cap ? '1' : '0', + 'only_loggedin_cap' => $this->cap, + 'search_filter' => $this->search_filter ? '1' : '0', + 'show_as_link' => $this->show_as_link ? '1' : '0', + ), + $this->configuration + ); } /** @@ -137,7 +140,7 @@ public function as_configuration() { * * @see \GV\Source::get_field() * @param string $source A \GV\Source class as string this field is tied to. - * @param array $args The arguments required for the backend to fetch the field (usually just the ID). + * @param array $args The arguments required for the backend to fetch the field (usually just the ID). * * @return \GV\Field|null A \GV\Field instance or null if not found. */ @@ -180,7 +183,7 @@ public static function from_configuration( $configuration ) { $trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); } $trace = $trace[1]; - if ( $trace['function'] == 'from_configuration' && $trace['class'] == __CLASS__ ) { + if ( 'from_configuration' == $trace['function'] && __CLASS__ == $trace['class'] ) { $field = new self(); gravityview()->log->error( 'Infinite loop protection tripped. Returning default class here.' ); $field->update_configuration( $configuration ); @@ -191,7 +194,8 @@ public static function from_configuration( $configuration ) { $field_class = is_numeric( $configuration['id'] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; /** - * @filter `gravityview/field/class` Filter the field class about to be created from the configuration. + * Filter the field class about to be created from the configuration. + * * @param string $field_class The field class about to be used. * @param array $configuration The configuration as per \GV\Field::as_configuration() */ @@ -199,7 +203,13 @@ public static function from_configuration( $configuration ) { if ( ! class_exists( $field_class ) || ! method_exists( $field_class, 'from_configuration' ) ) { $field = new self(); - gravityview()->log->error( 'Class {field_class}::from_configuration does not exist.', array( 'field_class' => $field_class, 'data' => $configuration ) ); + gravityview()->log->error( + 'Class {field_class}::from_configuration does not exist.', + array( + 'field_class' => $field_class, + 'data' => $configuration, + ) + ); $field->update_configuration( $configuration ); return $field; } @@ -209,7 +219,13 @@ public static function from_configuration( $configuration ) { if ( ! $field ) { $field = new self(); - gravityview()->log->error( 'Could not configure {field_class} with given configuration.', array( 'field_class' => __CLASS__, 'data' => $configuration ) ); + gravityview()->log->error( + 'Could not configure {field_class} with given configuration.', + array( + 'field_class' => __CLASS__, + 'data' => $configuration, + ) + ); $field->update_configuration( $configuration ); } @@ -233,19 +249,26 @@ public function update_configuration( $configuration ) { gravityview()->log->warning( 'ID is being changed for {field_class} instance, but implementation is not. Use ::from_configuration instead', array( 'field_class', __CLASS__ ) ); } - $this->ID = $configuration['id']; - $this->label = $configuration['label']; - $this->show_label = $configuration['show_label'] == '1'; - $this->custom_label = $configuration['custom_label']; - $this->custom_class = $configuration['custom_class']; - $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; - $this->search_filter = $configuration['search_filter'] == '1'; - $this->show_as_link = $configuration['show_as_link'] == '1'; + $this->ID = $configuration['id']; + $this->label = $configuration['label']; + $this->show_label = '1' == $configuration['show_label']; + $this->custom_label = $configuration['custom_label']; + $this->custom_class = $configuration['custom_class']; + $this->cap = '1' == $configuration['only_loggedin'] ? $configuration['only_loggedin_cap'] : ''; + $this->search_filter = '1' == $configuration['search_filter']; + $this->show_as_link = '1' == $configuration['show_as_link']; /** Shared among all field types (sort of). */ $shared_configuration_keys = array( - 'id', 'label', 'show_label', 'custom_label', 'custom_class', - 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', + 'id', + 'label', + 'show_label', + 'custom_label', + 'custom_class', + 'only_loggedin', + 'only_loggedin_cap', + 'search_filter', + 'show_as_link', ); /** Everything else goes into the properties for now. @todo subclasses! */ @@ -259,9 +282,9 @@ public function update_configuration( $configuration ) { /** * Retrieve the label for this field. * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return string The label for this field. Nothing here. @@ -285,9 +308,9 @@ public function get_label( View $view = null, Source $source = null, Entry $entr * * Returns null in this implementation (or, rather, lack thereof). * - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * @return mixed The value for this field. @@ -299,10 +322,10 @@ public function get_value( View $view = null, Source $source = null, Entry $entr /** * Apply all the required filters after get_value() was called. * - * @param mixed $value The value that will be filtered. - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param mixed $value The value that will be filtered. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. * * This is in its own function since \GV\Field subclasses have to call it. @@ -310,7 +333,8 @@ public function get_value( View $view = null, Source $source = null, Entry $entr protected function get_value_filters( $value, View $view = null, Source $source = null, Entry $entry = null, Request $request = null ) { if ( $this->type ) { /** - * @filter `gravityview/field/$type/value` Override the displayed value here. + * Override the displayed value here. + * * @param string $value The value. * @param \GV\Field The field we're doing this for. * @param \GV\View $view The view for this context if applicable. @@ -322,7 +346,8 @@ protected function get_value_filters( $value, View $view = null, Source $source } /** - * @filter `gravityview/field/value` Override the displayed value here. + * Override the displayed value here. + * * @param string $value The value. * @param \GV\Field The field we're doing this for. * @param \GV\View $view The view for this context if applicable. @@ -343,7 +368,7 @@ protected function get_value_filters( $value, View $view = null, Source $source */ public function is_visible( $view = null ) { /** - * @filter `gravityview/field/is_visible` Should this field be visible? + * Should this field be visible? * * @param boolean $visible Visible or not, defaults to the set field capability requirement if defined. * @param \GV\Field $field The field we're looking at. @@ -360,7 +385,7 @@ public function is_visible( $view = null ) { * @return mixed|null The value for the given configuration key, null if doesn't exist. */ public function __get( $key ) { - switch( $key ) { + switch ( $key ) { default: if ( isset( $this->configuration[ $key ] ) ) { return $this->configuration[ $key ]; @@ -378,7 +403,7 @@ public function __get( $key ) { * @return boolean Whether this $key is set or not. */ public function __isset( $key ) { - switch( $key ) { + switch ( $key ) { default: return isset( $this->configuration[ $key ] ); } diff --git a/future/includes/class-gv-form-gravityforms.php b/future/includes/class-gv-form-gravityforms.php index 08c55f7254..bb5f0ae195 100644 --- a/future/includes/class-gv-form-gravityforms.php +++ b/future/includes/class-gv-form-gravityforms.php @@ -46,7 +46,7 @@ public static function by_id( $form_id ) { return null; } - $self = new self(); + $self = new self(); $self->form = $form; $self->ID = intval( $self->form['id'] ); @@ -68,9 +68,9 @@ public static function from_form( $form ) { return null; } - $self = new self(); + $self = new self(); $self->form = $form; - $self->ID = $self->form['id']; + $self->ID = $self->form['id']; return $self; } @@ -89,57 +89,61 @@ public function get_entries() { $form = &$this; /** Add the fetcher lazy callback. */ - $entries->add_fetch_callback( function( $filters, $sorts, $offset ) use ( $form ) { - $entries = new \GV\Entry_Collection(); + $entries->add_fetch_callback( + function ( $filters, $sorts, $offset ) use ( $form ) { + $entries = new \GV\Entry_Collection(); - $search_criteria = array(); - $sorting = array(); - $paging = array(); + $search_criteria = array(); + $sorting = array(); + $paging = array(); - /** Apply the filters */ - foreach ( $filters as $filter ) { - $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() ); - } + /** Apply the filters */ + foreach ( $filters as $filter ) { + $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() ); + } - /** Apply the sorts */ - foreach ( $sorts as $sort ) { - /** Gravity Forms does not have multi-sorting, so just overwrite. */ - $sorting = array( - 'key' => $sort->field->ID, - 'direction' => $sort->direction, - 'is_numeric' => $sort->mode == Entry_Sort::NUMERIC, - ); - } + /** Apply the sorts */ + foreach ( $sorts as $sort ) { + /** Gravity Forms does not have multi-sorting, so just overwrite. */ + $sorting = array( + 'key' => $sort->field->ID, + 'direction' => $sort->direction, + 'is_numeric' => Entry_Sort::NUMERIC == $sort->mode, + ); + } - /** The offset and limit */ - if ( ! empty( $offset->limit ) ) { - $paging['page_size'] = $offset->limit; - } + /** The offset and limit */ + if ( ! empty( $offset->limit ) ) { + $paging['page_size'] = $offset->limit; + } - if ( ! empty( $offset->offset ) ) { - $paging['offset'] = $offset->offset; - } + if ( ! empty( $offset->offset ) ) { + $paging['offset'] = $offset->offset; + } - foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) { - $entries->add( \GV\GF_Entry::from_entry( $entry ) ); - } + foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) { + $entries->add( \GV\GF_Entry::from_entry( $entry ) ); + } - return $entries; - } ); + return $entries; + } + ); /** Add the counter lazy callback. */ - $entries->add_count_callback( function( $filters ) use ( $form ) { - $search_criteria = array(); - $sorting = array(); - - /** Apply the filters */ - /** @type \GV\GF_Entry_Filter|\GV\Entry_Filter $filter */ - foreach ( $filters as $filter ) { - $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() ); - } + $entries->add_count_callback( + function ( $filters ) use ( $form ) { + $search_criteria = array(); + $sorting = array(); + + /** Apply the filters */ + /** @type \GV\GF_Entry_Filter|\GV\Entry_Filter $filter */ + foreach ( $filters as $filter ) { + $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() ); + } - return \GFAPI::count_entries( $form->ID, $search_criteria ); - } ); + return \GFAPI::count_entries( $form->ID, $search_criteria ); + } + ); return $entries; } @@ -148,14 +152,14 @@ public function get_entries() { * Get a \GV\Field by Form and Field ID for this data source. * * @param \GV\GF_Form $form The Gravity Form form ID. - * @param int $field_id The Gravity Form field ID for the $form_id. + * @param int $field_id The Gravity Form field ID for the $form_id. * * @return \GV\Field|null The requested field or null if not found. */ public static function get_field( /** varargs */ ) { $args = func_get_args(); - if ( ! is_array( $args ) || count( $args ) != 2 ) { + if ( ! is_array( $args ) || 2 != count( $args ) ) { gravityview()->log->error( '{source} expects 2 arguments for ::get_field ($form, $field_id)', array( 'source' => __CLASS__ ) ); return null; } @@ -213,7 +217,7 @@ public function __get( $key ) { */ #[\ReturnTypeWillChange] public function offsetExists( $offset ) { - return isset( $this->form[$offset] ); + return isset( $this->form[ $offset ] ); } /** @@ -229,7 +233,7 @@ public function offsetExists( $offset ) { */ #[\ReturnTypeWillChange] public function offsetGet( $offset ) { - return $this->form[$offset]; + return $this->form[ $offset ]; } /** diff --git a/future/includes/class-gv-form-join.php b/future/includes/class-gv-form-join.php index 6694b6dc62..e1fa9fe7c1 100644 --- a/future/includes/class-gv-form-join.php +++ b/future/includes/class-gv-form-join.php @@ -39,9 +39,9 @@ class Join { * Construct a JOIN container. * * @param \GV\Source $join The form we're joining to. - * @param \GV\Field $join_column Its column. + * @param \GV\Field $join_column Its column. * @param \GV\Source $join_on The form we're joining on. - * @param \GV\Field $join_on_column Its column. + * @param \GV\Field $join_on_column Its column. */ public function __construct( $join, $join_column, $join_on, $join_on_column ) { if ( $join instanceof \GV\Source ) { diff --git a/future/includes/class-gv-form.php b/future/includes/class-gv-form.php index 5e982abd65..a5df13e655 100644 --- a/future/includes/class-gv-form.php +++ b/future/includes/class-gv-form.php @@ -55,7 +55,7 @@ abstract public function get_entries(); * - `entries` -> `$this->get_entries()` */ public function __get( $key ) { - switch ( $key ): + switch ( $key ) : case 'entries': return $this->get_entries(); endswitch; diff --git a/future/includes/class-gv-logger-wp-action.php b/future/includes/class-gv-logger-wp-action.php index cfa9334195..a29e6b4ad7 100644 --- a/future/includes/class-gv-logger-wp-action.php +++ b/future/includes/class-gv-logger-wp-action.php @@ -21,18 +21,18 @@ class WP_Action_Logger extends Logger { * * $context['data'] will be passed to the action. * - * @param mixed $level The log level. + * @param mixed $level The log level. * @param string $message The message to log. - * @param array $context The context. + * @param array $context The context. * * @return void */ protected function log( $level, $message, $context ) { $backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 3 ); - $location = $this->interpolate( "{class}{type}{function}", $backtrace[2] ); - $message = $this->interpolate( "[$level, $location] $message", $context ); + $location = $this->interpolate( '{class}{type}{function}', $backtrace[2] ); + $message = $this->interpolate( "[$level, $location] $message", $context ); - switch ( $level ): + switch ( $level ) : case LogLevel::EMERGENCY: case LogLevel::ALERT: case LogLevel::CRITICAL: @@ -55,7 +55,7 @@ protected function log( $level, $message, $context ) { empty( $context['data'] ) ? array() : $context['data'] ); } - + do_action( sprintf( 'gravityview_log_%s', $action ), $this->interpolate( $message, $context ), diff --git a/future/includes/class-gv-logger.php b/future/includes/class-gv-logger.php index db5cfbe2bd..5104ea495f 100644 --- a/future/includes/class-gv-logger.php +++ b/future/includes/class-gv-logger.php @@ -10,14 +10,14 @@ * Describes log levels. */ class LogLevel { - const EMERGENCY = 'emergency'; - const ALERT = 'alert'; - const CRITICAL = 'critical'; - const ERROR = 'error'; - const WARNING = 'warning'; - const NOTICE = 'notice'; - const INFO = 'info'; - const DEBUG = 'debug'; + const EMERGENCY = 'emergency'; + const ALERT = 'alert'; + const CRITICAL = 'critical'; + const ERROR = 'error'; + const WARNING = 'warning'; + const NOTICE = 'notice'; + const INFO = 'info'; + const DEBUG = 'debug'; } /** @@ -26,131 +26,124 @@ class LogLevel { * @TODO: (Foundation) Deprecate in future versions. */ abstract class Logger /** @todo extends Psr\Log\AbstractLogger */ { - /** - * System is unusable. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function emergency($message, array $context = array()) - { - $this->log(LogLevel::EMERGENCY, $message, $context); - } + /** + * System is unusable. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function emergency( $message, array $context = array() ) { + $this->log( LogLevel::EMERGENCY, $message, $context ); + } - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function alert( $message, array $context = array() ) { + $this->log( LogLevel::ALERT, $message, $context ); + } - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function critical( $message, array $context = array() ) { + $this->log( LogLevel::CRITICAL, $message, $context ); + } - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function error( $message, array $context = array() ) { + $this->log( LogLevel::ERROR, $message, $context ); + } - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function warning( $message, array $context = array() ) { + $this->log( LogLevel::WARNING, $message, $context ); + } - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function notice( $message, array $context = array() ) { + $this->log( LogLevel::NOTICE, $message, $context ); + } - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function info( $message, array $context = array() ) { + $this->log( LogLevel::INFO, $message, $context ); + } - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * + * @return void + */ + public function debug( $message, array $context = array() ) { + $this->log( LogLevel::DEBUG, $message, $context ); + } /** * Bake the context into { } placeholders in the message. - * @param string $message - * @param array $context - * - * @return string The baked message; + * + * @param string $message + * @param array $context + * + * @return string The baked message; */ protected function interpolate( $message, $context ) { foreach ( $context as $key => $val ) { - if ( strpos( $message, "{{$key}}" ) !== false ) { + if ( false !== strpos( $message, "{{$key}}" ) ) { $message = str_replace( "{{$key}}", (string) $val, $message ); } } diff --git a/future/includes/class-gv-oembed.php b/future/includes/class-gv-oembed.php index badf526377..8bf78897ea 100644 --- a/future/includes/class-gv-oembed.php +++ b/future/includes/class-gv-oembed.php @@ -53,29 +53,31 @@ public static function render_provider_request() { /** Parse the URL to an entry and a view */ preg_match( self::get_entry_regex(), $url, $matches ); $result = self::parse_matches( $matches, $url ); - if ( ! $result || count( $result ) != 2 ) { + if ( ! $result || 2 != count( $result ) ) { header( 'HTTP/1.0 404 Not Found' ); exit; } list( $view, $entry ) = $result; - echo json_encode( array( - 'version' => '1.0', - 'provider_name' => 'gravityview', - 'provider_url' => self::$provider_url, - 'html' => self::render_preview_notice() . self::render_frontend( $view, $entry ), - ) ); + echo json_encode( + array( + 'version' => '1.0', + 'provider_name' => 'gravityview', + 'provider_url' => self::$provider_url, + 'html' => self::render_preview_notice() . self::render_frontend( $view, $entry ), + ) + ); exit; } /** * Output the embed HTML. * - * @param array $matches The regex matches from the provided regex when calling wp_embed_register_handler() - * @param array $attr Embed attributes. + * @param array $matches The regex matches from the provided regex when calling wp_embed_register_handler() + * @param array $attr Embed attributes. * @param string $url The original URL that was matched by the regex. - * @param array $rawattr The original unmodified attributes. + * @param array $rawattr The original unmodified attributes. * * @return string The embed HTML. */ @@ -83,8 +85,14 @@ public static function render( $matches, $attr, $url, $rawattr ) { $result = self::parse_matches( $matches, $url ); - if ( ! $result || count( $result ) != 2 ) { - gravityview()->log->notice( 'View or entry could not be parsed in oEmbed url {url}', array( 'url' => $url, 'matches' => $matches ) ); + if ( ! $result || 2 != count( $result ) ) { + gravityview()->log->notice( + 'View or entry could not be parsed in oEmbed url {url}', + array( + 'url' => $url, + 'matches' => $matches, + ) + ); return __( 'You are not allowed to view this content.', 'gk-gravityview' ); } @@ -93,7 +101,7 @@ public static function render( $matches, $attr, $url, $rawattr ) { if ( Request::is_ajax() && ! Request::is_add_oembed_preview() ) { /** Render a nice placeholder in the Visual mode. */ return self::render_admin( $view, $entry ); - } else if ( Request::is_add_oembed_preview() ) { + } elseif ( Request::is_add_oembed_preview() ) { /** Prepend a preview notice in Add Media / From URL screen */ return self::render_preview_notice() . self::render_frontend( $view, $entry ); } @@ -104,7 +112,7 @@ public static function render( $matches, $attr, $url, $rawattr ) { /** * Parse oEmbed regex matches and return View and Entry. * - * @param array $matches The regex matches. + * @param array $matches The regex matches. * @param string $url The URL of the embed. * * @return array (\GV\View, \GV\Entry) @@ -112,8 +120,8 @@ public static function render( $matches, $attr, $url, $rawattr ) { private static function parse_matches( $matches, $url ) { // If not using permalinks, re-assign values for matching groups if ( ! empty( $matches['entry_slug2'] ) ) { - $matches['is_cpt'] = $matches['is_cpt2']; - $matches['slug'] = $matches['slug2']; + $matches['is_cpt'] = $matches['is_cpt2']; + $matches['slug'] = $matches['slug2']; $matches['entry_slug'] = $matches['entry_slug2']; unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); } @@ -140,17 +148,23 @@ private static function parse_matches( $matches, $url ) { if ( ! $view ) { // If the slug doesn't work, maybe using Plain permalinks and not the slug, only ID - if( is_numeric( $matches['slug'] ) ) { + if ( is_numeric( $matches['slug'] ) ) { $view = \GV\View::by_id( $matches['slug'] ); } - if( ! $view ) { + if ( ! $view ) { $view = \GV\View::from_post( get_page_by_path( $matches['slug'], OBJECT, 'gravityview' ) ); } } if ( ! $view ) { - gravityview()->log->error( 'Could not detect View from URL {url}', array( 'url' => $url, 'data' => $matches ) ); + gravityview()->log->error( + 'Could not detect View from URL {url}', + array( + 'url' => $url, + 'data' => $matches, + ) + ); return null; } @@ -160,7 +174,7 @@ private static function parse_matches( $matches, $url ) { /** * Display a nice placeholder in the admin for the entry. * - * @param \GV\View $view The View. + * @param \GV\View $view The View. * @param \GV\Entry $entry The Entry. * * @return string A placeholder, with Mr. Floaty :) @@ -176,9 +190,9 @@ private static function render_admin( $view, $entry ) { return '
-

'.$image.$embed_heading.'

+

' . $image . $embed_heading . '

- '.$embed_text.' + ' . $embed_text . '


'; @@ -190,16 +204,16 @@ private static function render_admin( $view, $entry ) { * @return string HTML notice */ private static function render_preview_notice() { - $floaty = \GravityView_Admin::get_floaty(); - $title = esc_html__( 'This will look better when it is embedded.', 'gk-gravityview' ); - $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gk-gravityview'); - return '
'.$floaty.'

'.$title.'

'.$message.'


'; + $floaty = \GravityView_Admin::get_floaty(); + $title = esc_html__( 'This will look better when it is embedded.', 'gk-gravityview' ); + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gk-gravityview' ); + return '
' . $floaty . '

' . $title . '

' . $message . '


'; } /** * Render the entry as an oEmbed. * - * @param \GV\View $view The View. + * @param \GV\View $view The View. * @param \GV\Entry $entry The Entry. * * @return string The rendered oEmbed. @@ -218,7 +232,7 @@ private static function render_frontend( $view, $entry ) { } if ( $view->settings->get( 'show_only_approved' ) ) { - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); return __( 'You are not allowed to view this content.', 'gk-gravityview' ); } @@ -227,7 +241,7 @@ private static function render_frontend( $view, $entry ) { /** * When this is embedded inside a view we should not display the widgets. */ - $request = gravityview()->request; + $request = gravityview()->request; $is_reembedded = false; // Assume not embedded unless detected otherwise. if ( in_array( get_class( $request ), array( 'GV\Frontend_Request', 'GV\Mock_Request' ) ) ) { if ( ( $_view = $request->is_view() ) && $_view->ID !== $view->ID ) { @@ -254,17 +268,19 @@ private static function render_frontend( $view, $entry ) { $form = \GVCommon::get_form( $entry['form_id'] ); // @todo We really need to rewrite Edit Entry soon - \GravityView_View::$instance = null; + \GravityView_View::$instance = null; \GravityView_View_Data::$instance = null; - $data = \GravityView_View_Data::getInstance( get_post( $view->ID ) ); - $template = \GravityView_View::getInstance( array( - 'form' => $form, - 'form_id' => $form['id'], - 'view_id' => $view->ID, - 'entries' => array( $entry->as_entry() ), - 'atts' => \GVCommon::get_template_settings( $view->ID ), - ) ); + $data = \GravityView_View_Data::getInstance( get_post( $view->ID ) ); + $template = \GravityView_View::getInstance( + array( + 'form' => $form, + 'form_id' => $form['id'], + 'view_id' => $view->ID, + 'entries' => array( $entry->as_entry() ), + 'atts' => \GVCommon::get_template_settings( $view->ID ), + ) + ); ob_start() && $render->init( $data, \GV\Entry::by_id( $entry['id'] ), $view ); $output = ob_get_clean(); // Render :) @@ -273,8 +289,8 @@ private static function render_frontend( $view, $entry ) { add_filter( 'gravityview/template/links/back/url', '__return_false' ); $renderer = new \GV\Entry_Renderer(); - $output = $renderer->render( $entry, $view, gravityview()->request ); - $output = sprintf( '
%s
', $entry->ID, $output ); + $output = $renderer->render( $entry, $view, gravityview()->request ); + $output = sprintf( '
%s
', $entry->ID, $output ); remove_filter( 'gravityview/template/links/back/url', '__return_false' ); } @@ -293,7 +309,8 @@ private static function get_entry_regex() { $entry_var_name = \GV\Entry::get_endpoint_name(); /** - * @filter `gravityview_slug` Modify the url part for a View. [Read the doc](https://docs.gravitykit.com/article/62-changing-the-view-slug) + * Modify the url part for a View. [Read the doc](https://docs.gravitykit.com/article/62-changing-the-view-slug). + * * @param string $rewrite_slug The slug shown in the URL */ $rewrite_slug = apply_filters( 'gravityview_slug', 'view' ); @@ -305,12 +322,12 @@ private static function get_entry_regex() { $using_permalinks = $prefix . "(?P{$rewrite_slug})?/?(?P.+?)/{$entry_var_name}/(?P.+?)/?\$"; // Not using permalinks - $not_using_permalinks = $prefix . "(?:index.php)?\?(?P[^=]+)=(?P[^&]+)&entry=(?P[^&]+)\$"; + $not_using_permalinks = $prefix . '(?:index.php)?\?(?P[^=]+)=(?P[^&]+)&entry=(?P[^&]+)$'; // Catch either $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; - return '#'.$match_regex.'#i'; + return '#' . $match_regex . '#i'; } /** @@ -322,7 +339,7 @@ public static function pre_oembed_result( $result, $url, $args ) { } $view_entry = self::parse_matches( $matches, $url ); - if ( ! $view_entry || count( $view_entry ) != 2 ) { + if ( ! $view_entry || 2 != count( $view_entry ) ) { return $result; } diff --git a/future/includes/class-gv-plugin.php b/future/includes/class-gv-plugin.php index 31625b2aae..b9223def23 100644 --- a/future/includes/class-gv-plugin.php +++ b/future/includes/class-gv-plugin.php @@ -27,7 +27,6 @@ final class Plugin { * @since 2.0 * @api * @var string The plugin version. - * */ public static $version = GV_PLUGIN_VERSION; @@ -77,7 +76,6 @@ final class Plugin { * @since 2.0 * @api * @var \GV\Plugin_Settings The plugin settings. - * */ public $settings; @@ -109,7 +107,7 @@ final class Plugin { public static function get() { if ( ! self::$__instance instanceof self ) { - self::$__instance = new self; + self::$__instance = new self(); } return self::$__instance; @@ -144,7 +142,6 @@ public function load_settings() { * * @return bool * @todo add @since - * */ public function is_GF_25() { @@ -240,6 +237,9 @@ public function include_legacy_core() { include_once $this->dir( 'includes/class-api.php' ); include_once $this->dir( 'includes/class-oembed.php' ); + // Add notification + include_once $this->dir( 'includes/class-gravityview-notifications.php' ); + // Add logging include_once $this->dir( 'includes/class-gravityview-logging.php' ); @@ -494,7 +494,8 @@ private function get_gravityforms_version() { public function supports( $feature ) { /** - * @filter `gravityview/supports` Overrides whether GravityView supports a feature. + * Overrides whether GravityView supports a feature. + * * @since 2.0 * @param boolean|null $supports Whether the feature is supported. Default: null. */ @@ -504,12 +505,12 @@ public function supports( $feature ) { return (bool) $supports; } - switch ( $feature ): + switch ( $feature ) : case self::FEATURE_GFQUERY: return class_exists( '\GF_Query' ); case self::FEATURE_JOINS: case self::FEATURE_UNIONS: - return apply_filters( 'gravityview/query/class', false ) === '\GF_Patched_Query'; + return '\GF_Patched_Query' === apply_filters( 'gravityview/query/class', false ); case self::FEATURE_REST: return class_exists( '\WP_REST_Controller' ); default: @@ -531,12 +532,14 @@ public function uninstall() { /** * Posts. */ - $items = get_posts( array( - 'post_type' => 'gravityview', - 'post_status' => 'any', - 'numberposts' => - 1, - 'fields' => 'ids', - ) ); + $items = get_posts( + array( + 'post_type' => 'gravityview', + 'post_status' => 'any', + 'numberposts' => - 1, + 'fields' => 'ids', + ) + ); foreach ( $items as $item ) { wp_delete_post( $item, true ); @@ -579,14 +582,18 @@ public function uninstall() { $suppress = $wpdb->suppress_errors(); foreach ( $tables as $notes_table ) { - $sql = $wpdb->prepare( " + $sql = $wpdb->prepare( + " DELETE FROM $notes_table WHERE ( `note_type` = 'gravityview' OR `value` = %s OR `value` = %s ); - ", $approved, $disapproved ); + ", + $approved, + $disapproved + ); $wpdb->query( $sql ); } @@ -648,13 +655,13 @@ public function setup_gravitykit_admin_menu_redirects() { /** * Returns the URL to the "All Views" page. * - * @since $ver$ + * @since 2.17 * * @return string */ public function get_link_to_new_view() { return add_query_arg( - [ 'post_type' => 'gravityview' ], + array( 'post_type' => 'gravityview' ), admin_url( 'post-new.php' ) ); } @@ -662,13 +669,13 @@ public function get_link_to_new_view() { /** * Returns the URL to the "New View" page. * - * @since $ver$ + * @since 2.17 * * @return string */ public function get_link_to_all_views() { return add_query_arg( - [ 'post_type' => 'gravityview' ], + array( 'post_type' => 'gravityview' ), admin_url( 'edit.php' ) ); } @@ -687,47 +694,56 @@ public function add_to_gravitykit_admin_menu( $foundation ) { return; } - $admin_menu = $foundation::admin_menu(); - $post_type = 'gravityview'; - $capability = 'edit_gravityviews'; + $admin_menu = $foundation::admin_menu(); + $post_type = 'gravityview'; + $capability = 'edit_gravityviews'; $all_views_menu_id = "{$post_type}_all_views"; $new_view_menu_id = "{$post_type}_new_view"; - $admin_menu::add_submenu_item( [ - 'page_title' => __( 'All Views', 'gk-gravityview' ), - 'menu_title' => __( 'All Views', 'gk-gravityview' ), - 'capability' => $capability, - 'id' => $all_views_menu_id, - 'callback' => '__return_false', // We'll redirect this to edit.php?post_type=gravityview (@see Plugin::setup_gravitykit_admin_menu_redirects()). - 'order' => 1, - ], 'center' ); - - $admin_menu::add_submenu_item( [ - 'page_title' => __( 'New View', 'gk-gravityview' ), - 'menu_title' => __( 'New View', 'gk-gravityview' ), - 'capability' => $capability, - 'id' => $new_view_menu_id, - 'callback' => '__return_false', // We'll redirect this to post-new.php?post_type=gravityview (@see Plugin::setup_gravitykit_admin_menu_redirects()). - 'order' => 2, - ], 'center' ); - - add_filter( 'parent_file', function ( $parent_file ) use ( $admin_menu, $post_type, $all_views_menu_id, $new_view_menu_id ) { - global $submenu_file; - - if ( ! $submenu_file || strpos( $submenu_file, "post_type={$post_type}" ) === false ) { - return $parent_file; - } + $admin_menu::add_submenu_item( + array( + 'page_title' => __( 'All Views', 'gk-gravityview' ), + 'menu_title' => __( 'All Views', 'gk-gravityview' ), + 'capability' => $capability, + 'id' => $all_views_menu_id, + 'callback' => '__return_false', // We'll redirect this to edit.php?post_type=gravityview (@see Plugin::setup_gravitykit_admin_menu_redirects()). + 'order' => 1, + ), + 'center' + ); - if ( strpos( $submenu_file, 'edit.php' ) !== false ) { - $submenu_file = $all_views_menu_id; - } + $admin_menu::add_submenu_item( + array( + 'page_title' => __( 'New View', 'gk-gravityview' ), + 'menu_title' => __( 'New View', 'gk-gravityview' ), + 'capability' => $capability, + 'id' => $new_view_menu_id, + 'callback' => '__return_false', // We'll redirect this to post-new.php?post_type=gravityview (@see Plugin::setup_gravitykit_admin_menu_redirects()). + 'order' => 2, + ), + 'center' + ); - if ( strpos( $submenu_file, 'post-new.php' ) !== false ) { - $submenu_file = $new_view_menu_id; - } + add_filter( + 'parent_file', + function ( $parent_file ) use ( $admin_menu, $post_type, $all_views_menu_id, $new_view_menu_id ) { + global $submenu_file; + + if ( ! $submenu_file || false === strpos( $submenu_file, "post_type={$post_type}" ) ) { + return $parent_file; + } - return constant( get_class( $admin_menu ) . '::WP_ADMIN_MENU_SLUG' ); - } ); + if ( false !== strpos( $submenu_file, 'edit.php' ) ) { + $submenu_file = $all_views_menu_id; + } + + if ( false !== strpos( $submenu_file, 'post-new.php' ) ) { + $submenu_file = $new_view_menu_id; + } + + return constant( get_class( $admin_menu ) . '::WP_ADMIN_MENU_SLUG' ); + } + ); } public function __clone() { diff --git a/future/includes/class-gv-renderer-entry-edit.php b/future/includes/class-gv-renderer-entry-edit.php index 6cd1e894b3..5705e20482 100644 --- a/future/includes/class-gv-renderer-entry-edit.php +++ b/future/includes/class-gv-renderer-entry-edit.php @@ -16,8 +16,8 @@ class Edit_Entry_Renderer extends Entry_Renderer { /** * Renders a an editable \GV\Entry instance. * - * @param \GV\Entry $entry The Entry instance to render. - * @param \GV\View $view The View connected to the entry. + * @param \GV\Entry $entry The Entry instance to render. + * @param \GV\View $view The View connected to the entry. * @param \GV\Request $request The request context we're currently in. Default: `gravityview()->request` * * @todo Just a wrapper around the old code. Cheating. Needs rewrite :) @@ -31,10 +31,12 @@ public function render( Entry $entry, View $view, Request $request = null ) { $entries = new \GV\Entry_Collection(); $entries->add( $entry ); - \GV\Mocks\Legacy_Context::push( array( - 'view' => $view, - 'entries' => $entries, - ) ); + \GV\Mocks\Legacy_Context::push( + array( + 'view' => $view, + 'entries' => $entries, + ) + ); ob_start(); do_action( 'gravityview_edit_entry', null, $entry, $view, $request ); diff --git a/future/includes/class-gv-renderer-entry.php b/future/includes/class-gv-renderer-entry.php index d087078921..59e2ea1265 100644 --- a/future/includes/class-gv-renderer-entry.php +++ b/future/includes/class-gv-renderer-entry.php @@ -16,8 +16,8 @@ class Entry_Renderer extends Renderer { /** * Renders a single \GV\Entry instance. * - * @param \GV\Entry $entry The Entry instance to render. - * @param \GV\View $view The View connected to the entry. + * @param \GV\Entry $entry The Entry instance to render. + * @param \GV\View $view The View connected to the entry. * @param \GV\Request $request The request context we're currently in. Default: `gravityview()->request` * * @api @@ -42,9 +42,9 @@ public function render( Entry $entry, View $view, Request $request = null ) { return get_the_password_form( $view->ID ); } - /** - * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID + * Before rendering a single entry for a specific View ID. + * * @since 1.17 * * @since 2.0 @@ -63,17 +63,30 @@ public function render( Entry $entry, View $view, Request $request = null ) { } foreach ( $entry->entries as $e ) { if ( ! in_array( $e['form_id'], $form_ids ) ) { - gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', array( 'entry_id' => $e->ID, 'view_id' => $view->ID ) ); + gravityview()->log->error( + 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', + array( + 'entry_id' => $e->ID, + 'view_id' => $view->ID, + ) + ); return null; } } - } else if ( $view->form && $view->form->ID != $entry['form_id'] ) { - gravityview()->log->error( 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', array( 'entry_id' => $entry->ID, 'view_id' => $view->ID ) ); + } elseif ( $view->form && $view->form->ID != $entry['form_id'] ) { + gravityview()->log->error( + 'The requested entry does not belong to this View. Entry #{entry_id}, #View {view_id}', + array( + 'entry_id' => $entry->ID, + 'view_id' => $view->ID, + ) + ); return null; } /** - * @filter `gravityview_template_slug_{$template_id}` Modify the template slug about to be loaded in directory views. + * Modify the template slug about to be loaded in directory views. + * * @since 1.6 * @param deprecated * @see The `gravityview_get_template_id` filter @@ -87,7 +100,7 @@ public function render( Entry $entry, View $view, Request $request = null ) { */ $override = new \GV\Legacy_Override_Template( $view, $entry, null, $request ); foreach ( array( 'single' ) as $part ) { - if ( ( $path = $override->get_template_part( $template_slug, $part ) ) && strpos( $path, '/deprecated' ) === false ) { + if ( ( $path = $override->get_template_part( $template_slug, $part ) ) && false === strpos( $path, '/deprecated' ) ) { /** * We have to bail and call the legacy renderer. Crap! */ @@ -103,7 +116,8 @@ public function render( Entry $entry, View $view, Request $request = null ) { } /** - * @filter `gravityview/template/entry/class` Filter the template class that is about to be used to render the entry. + * Filter the template class that is about to be used to render the entry. + * * @since 2.0 * @param string $class The chosen class - Default: \GV\Entry_Table_Template. * @param \GV\Entry $entry The entry about to be rendered. @@ -117,19 +131,24 @@ public function render( Entry $entry, View $view, Request $request = null ) { } $template = new $class( $entry, $view, $request ); - add_action( 'gravityview/template/after', $view_id_output = function( $context ) { - printf( '', $context->view->ID ); - } ); + add_action( + 'gravityview/template/after', + $view_id_output = function ( $context ) { + printf( '', $context->view->ID ); + } + ); /** Mock the legacy state for the widgets and whatnot */ $entries = new Entry_Collection(); $entries->add( $entry ); - \GV\Mocks\Legacy_Context::push( array( - 'view' => $view, - 'entries' => $entries, - 'entry' => $entry, - 'request' => $request, - ) ); + \GV\Mocks\Legacy_Context::push( + array( + 'view' => $view, + 'entries' => $entries, + 'entry' => $entry, + 'request' => $request, + ) + ); ob_start(); $template->render(); diff --git a/future/includes/class-gv-renderer-field.php b/future/includes/class-gv-renderer-field.php index 21a7b15909..e8e8676ad7 100644 --- a/future/includes/class-gv-renderer-field.php +++ b/future/includes/class-gv-renderer-field.php @@ -16,12 +16,12 @@ class Field_Renderer extends Renderer { /** * Renders a \GV\Field instance. * - * @param \GV\Field $request The field. - * @param \GV\View $view The view for this context if applicable. - * @param \GV\Source $source The source (form) for this context if applicable. - * @param \GV\Entry $entry The entry for this context if applicable. + * @param \GV\Field $request The field. + * @param \GV\View $view The view for this context if applicable. + * @param \GV\Source $source The source (form) for this context if applicable. + * @param \GV\Entry $entry The entry for this context if applicable. * @param \GV\Request $request The request for this context if applicable. - * @param string $class The field template class. Default: \GV\Field_HTML_Template'. + * @param string $class The field template class. Default: \GV\Field_HTML_Template'. * * @api * @since 2.0 @@ -40,7 +40,8 @@ public function render( Field $field, View $view = null, Source $source = null, } /** - * @filter `gravityview/template/field/class` Filter the template class that is about to be used to render the view. + * Filter the template class that is about to be used to render the view. + * * @since 2.0 * @param string $class The chosen class - Default: \GV\Field_HTML_Template. * @param \GV\Field $field The field about to be rendered. diff --git a/future/includes/class-gv-renderer-view.php b/future/includes/class-gv-renderer-view.php index a7c03f1460..0a585a8c35 100644 --- a/future/includes/class-gv-renderer-view.php +++ b/future/includes/class-gv-renderer-view.php @@ -22,7 +22,7 @@ class View_Renderer extends Renderer { * * @param \GV\Request $request The request context we're currently in. Default: `gravityview()->request` * - * @param View $view The View instance to render. + * @param View $view The View instance to render. * * @return string The rendered View. */ @@ -37,7 +37,8 @@ public function render( View $view, Request $request = null ) { } /** - * @filter `gravityview_template_slug_{$template_id}` Modify the template slug about to be loaded in directory views. + * Modify the template slug about to be loaded in directory views. + * * @since 1.6 * @deprecated * @see The `gravityview_get_template_id` filter @@ -51,7 +52,8 @@ public function render( View $view, Request $request = null ) { * * Some contexts don't need initial entries, like the DataTables directory type. * - * @filter `gravityview_get_view_entries_{$template_slug}` Whether to get the entries or not. + * Whether to get the entries or not. + * * @param boolean $get_entries Get entries or not, default: true. */ $get_entries = apply_filters( 'gravityview_get_view_entries_' . $template_slug, true ); @@ -80,7 +82,7 @@ public function render( View $view, Request $request = null ) { $path = $override->get_template_part( $template_slug, $part ); - if ( $path && strpos( $path, '/deprecated' ) === false ) { + if ( $path && false === strpos( $path, '/deprecated' ) ) { /** * We have to bail and call the legacy renderer. Crap! */ @@ -96,7 +98,8 @@ public function render( View $view, Request $request = null ) { } /** - * @filter `gravityview/template/view/class` Filter the template class that is about to be used to render the view. + * Filter the template class that is about to be used to render the view. + * * @since 2.0 * @param string $class The chosen class - Default: \GV\View_Table_Template. * @param View $view The view about to be rendered. @@ -122,21 +125,26 @@ public function render( View $view, Request $request = null ) { /** * Updates the View anchor ID each time the View is rendered. + * * @since 2.15 * @uses {@var $counter} * @param Template_Context $context */ - add_action( 'gravityview/template/view/render', $add_anchor_id_filter = function ( $context ) use ( &$counter ) { - /** @see \GV\View::set_anchor_id() */ - $context->view->set_anchor_id( $counter[ $context->view->ID ] ); - } ); + add_action( + 'gravityview/template/view/render', + $add_anchor_id_filter = function ( $context ) use ( &$counter ) { + /** @see \GV\View::set_anchor_id() */ + $context->view->set_anchor_id( $counter[ $context->view->ID ] ); + } + ); $add_search_action_filter = function ( $action ) use ( $view ) { return $action . '#' . esc_attr( $view->get_anchor_id() ); }; /** - * @filter `gravityview/widget/search/set_view_id_anchor` Allow appending the View ID anchor to the search URL. + * Allow appending the View ID anchor to the search URL. + * * @since 2.15 * * @param bool $set_view_id_anchor @@ -144,6 +152,7 @@ public function render( View $view, Request $request = null ) { if ( apply_filters( 'gravityview/widget/search/append_view_id_anchor', true ) ) { /** * Append the View anchor ID to the search form action. + * * @since 2.15 * * @param string $action The search form action URL. @@ -159,7 +168,7 @@ public function render( View $view, Request $request = null ) { */ $parameters = $view->settings->as_atts(); if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { - $has_multisort = true; + $has_multisort = true; $parameters['sort_field'] = reset( $parameters['sort_field'] ); if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); @@ -172,20 +181,29 @@ public function render( View $view, Request $request = null ) { global $post; /** Mock the legacy state for the widgets and whatnot */ - \GV\Mocks\Legacy_Context::push( array_merge( array( - 'view' => $view, - 'entries' => $entries, - 'request' => $request, - ), empty( $parameters ) ? array() : array( - 'paging' => $parameters['paging'], - 'sorting' => $parameters['sorting'], - ), empty( $post ) ? array() : array( - 'post' => $post, - ) ) ); - - add_action( 'gravityview/template/after', $view_id_output = function( $context ) { - printf( '', $context->view->ID ); - } ); + \GV\Mocks\Legacy_Context::push( + array_merge( + array( + 'view' => $view, + 'entries' => $entries, + 'request' => $request, + ), + empty( $parameters ) ? array() : array( + 'paging' => $parameters['paging'], + 'sorting' => $parameters['sorting'], + ), + empty( $post ) ? array() : array( + 'post' => $post, + ) + ) + ); + + add_action( + 'gravityview/template/after', + $view_id_output = function ( $context ) { + printf( '', $context->view->ID ); + } + ); ob_start(); $template->render(); diff --git a/future/includes/class-gv-renderer.php b/future/includes/class-gv-renderer.php index 6cad675294..81c27a6fc3 100644 --- a/future/includes/class-gv-renderer.php +++ b/future/includes/class-gv-renderer.php @@ -66,7 +66,7 @@ private static function disable_show_only_approved_entries( $gravityview ) { $settings['show_only_approved'] = 0; - $updated = update_post_meta( $gravityview->view->ID, '_gravityview_template_settings', $settings ); + $updated = update_post_meta( $gravityview->view->ID, '_gravityview_template_settings', $settings ); if ( ! $updated ) { gravityview()->log->error( 'Could not update View settings => Show only approved' ); @@ -136,16 +136,19 @@ private static function maybe_print_entry_approval_notice( $gravityview ) { return; } - $count = \GFAPI::count_entries( $gravityview->view->form->ID, array( - 'status' => 'active', - 'field_filters' => array( - array( - 'key' => 'is_approved', - 'operator' => 'isnot', - 'value' => \GravityView_Entry_Approval_Status::APPROVED, + $count = \GFAPI::count_entries( + $gravityview->view->form->ID, + array( + 'status' => 'active', + 'field_filters' => array( + array( + 'key' => 'is_approved', + 'operator' => 'isnot', + 'value' => \GravityView_Entry_Approval_Status::APPROVED, + ), ), - ), - ) ); + ) + ); // There aren't any entries to show! if ( empty( $count ) ) { @@ -225,9 +228,15 @@ private static function maybe_print_entry_approval_notice( $gravityview ) { $dismiss_notice_link = wp_nonce_url( add_query_arg( array() ), $dismiss_nonce_action, $dismiss_nonce_name ); - $disable_setting_link = wp_nonce_url( add_query_arg( array( - 'disable_setting' => 'show_only_approved_' . $gravityview->view->ID - ) ), 'setting', 'gv-setting' ); + $disable_setting_link = wp_nonce_url( + add_query_arg( + array( + 'disable_setting' => 'show_only_approved_' . $gravityview->view->ID, + ) + ), + 'setting', + 'gv-setting' + ); $placeholders = array( '{dom_id}' => sprintf( 'gv-notice-approve-entries-%d', $gravityview->view->ID ), @@ -270,11 +279,10 @@ private static function maybe_print_configuration_notice( $gravityview ) { switch ( true ) { case ( $gravityview->request->is_edit_entry() ): - $tab = esc_html__( 'Edit Entry', 'gk-gravityview' ); + $tab = esc_html__( 'Edit Entry', 'gk-gravityview' ); $context = 'edit'; break; case ( $entry = $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ): - // When the entry is not found, we're probably inside a shortcode. if ( ! $gravityview->entry ) { return; @@ -285,16 +293,16 @@ private static function maybe_print_configuration_notice( $gravityview ) { return; } - $tab = esc_html__( 'Single Entry', 'gk-gravityview' ); + $tab = esc_html__( 'Single Entry', 'gk-gravityview' ); $context = 'single'; break; default: - $tab = esc_html__( 'Multiple Entries', 'gk-gravityview' ); + $tab = esc_html__( 'Multiple Entries', 'gk-gravityview' ); $context = 'directory'; break; } - $cls = $gravityview->template; + $cls = $gravityview->template; $slug = property_exists( $cls, '_configuration_slug' ) ? $cls::$_configuration_slug : $cls::$slug; // If the zone has been configured, don't display notice. @@ -319,12 +327,12 @@ private static function maybe_print_configuration_notice( $gravityview ) { return; } - $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gk-gravityview' ), $tab ); - $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $gravityview->view->ID, $context ) ); + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gk-gravityview' ), $tab ); + $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $gravityview->view->ID, $context ) ); $action_text = sprintf( esc_html__( 'Add fields to %s', 'gk-gravityview' ), $tab ); - $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gk-gravityview' ); + $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gk-gravityview' ); - $image = sprintf( '%s', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); + $image = sprintf( '%s', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); $output = sprintf( '

%s %s

%s

', $title, esc_url( $edit_link ), $action_text, $message ); echo \GVCommon::generate_notice( $output . $image, 'gv-warning warning', 'edit_gravityview', $gravityview->view->ID ); @@ -350,7 +358,7 @@ private static function maybe_print_reserved_slugs_notice( $gravityview ) { $post_types = get_post_types(); - foreach( $post_types as $post_type ) { + foreach ( $post_types as $post_type ) { $post_type_rewrite = get_post_type_object( $post_type )->rewrite; if ( $slug = \GV\Utils::get( $post_type_rewrite, 'slug' ) ) { @@ -361,7 +369,8 @@ private static function maybe_print_reserved_slugs_notice( $gravityview ) { unset( $post_types, $post_type_rewrite ); /** - * @filter `gravityview/rewrite/reserved_slugs` Modify the reserved embed slugs that trigger a warning. + * Modify the reserved embed slugs that trigger a warning. + * * @since 2.5 * @param array $reserved_slugs An array of strings, reserved slugs. * @param \GV\Template_Context $gravityview The context. @@ -376,8 +385,8 @@ private static function maybe_print_reserved_slugs_notice( $gravityview ) { gravityview()->log->error( '{slug} page URL is reserved.', array( 'slug' => $wp->request ) ); - $title = esc_html__( 'GravityView will not work correctly on this page because of the URL Slug.', 'gk-gravityview' ); - $message = __( 'Please read this article for more information.', 'gk-gravityview' ); + $title = esc_html__( 'GravityView will not work correctly on this page because of the URL Slug.', 'gk-gravityview' ); + $message = __( 'Please read this article for more information.', 'gk-gravityview' ); $message .= ' ' . esc_html__( 'You can only see this message because you are able to edit this View.', 'gk-gravityview' ); $output = sprintf( '

%s

%s

', $title, sprintf( $message, 'https://docs.gravitykit.com/article/659-reserved-urls' ) ); @@ -392,12 +401,12 @@ private static function maybe_print_reserved_slugs_notice( $gravityview ) { * Used in gravityview_before. * * @param \GV\View $view The view we're looking at. - * @param string $path The path of the offending template. + * @param string $path The path of the offending template. * * @return \Callable A closure used in the filter. */ public function legacy_template_warning( $view, $path ) { - return function() use ( $view, $path ) { + return function () use ( $view, $path ) { // Do not panic for now... }; } diff --git a/future/includes/class-gv-request-admin.php b/future/includes/class-gv-request-admin.php index 0043aea604..f64fa6700e 100644 --- a/future/includes/class-gv-request-admin.php +++ b/future/includes/class-gv-request-admin.php @@ -38,28 +38,29 @@ public static function is_admin() { */ $is_page = false; - if( function_exists( '\get_current_screen' ) || function_exists( 'get_current_screen' ) ) { + if ( function_exists( '\get_current_screen' ) || function_exists( 'get_current_screen' ) ) { $current_screen = \get_current_screen(); } else { $current_screen = false; } - if ( $current_screen && $current_screen->post_type == 'gravityview' ) { + if ( $current_screen && 'gravityview' == $current_screen->post_type ) { if ( 'edit' === $current_screen->base ) { $is_page = 'views'; } elseif ( 'post' === $current_screen->base ) { $is_page = 'single'; - } elseif( 'gravityview_page_gv-changelog' === $current_screen->id ) { + } elseif ( 'gravityview_page_gv-changelog' === $current_screen->id ) { $is_page = 'changelog'; - } elseif( 'gravityview_page_gv-getting-started' === $current_screen->id ) { + } elseif ( 'gravityview_page_gv-getting-started' === $current_screen->id ) { $is_page = 'getting-started'; - } elseif( 'gravityview_page_gv-credits' === $current_screen->id ) { + } elseif ( 'gravityview_page_gv-credits' === $current_screen->id ) { $is_page = 'credits'; } } /** - * @filter `gravityview_is_admin_page` Is the current admin page a GravityView-related page? + * Is the current admin page a GravityView-related page? + * * @param string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) * @param string $hook The name of the page to check against. Is passed to the method. */ diff --git a/future/includes/class-gv-request-mock.php b/future/includes/class-gv-request-mock.php index b84ee9eb6d..c42e45df9d 100644 --- a/future/includes/class-gv-request-mock.php +++ b/future/includes/class-gv-request-mock.php @@ -14,10 +14,10 @@ class Mock_Request extends Request { * @var array The return values. */ public $returns = array( - 'is_view' => false, - 'is_entry' => false, + 'is_view' => false, + 'is_entry' => false, 'is_edit_entry' => false, - 'is_search' => false, + 'is_search' => false, ); public function is_view( $return_view = true ) { diff --git a/future/includes/class-gv-request.php b/future/includes/class-gv-request.php index 394ca5351a..c13d2fa3bd 100644 --- a/future/includes/class-gv-request.php +++ b/future/includes/class-gv-request.php @@ -24,14 +24,19 @@ public function __construct() {} */ public function is_renderable() { - $is_renderable = in_array( get_class( $this ), array( - 'GV\Frontend_Request', - 'GV\Mock_Request', - 'GV\REST\Request', - ), true ); + $is_renderable = in_array( + get_class( $this ), + array( + 'GV\Frontend_Request', + 'GV\Mock_Request', + 'GV\REST\Request', + ), + true + ); /** - * @filter `gravityview/request/is_renderable` Is this request renderable? + * Is this request renderable? + * * @since 2.5.2 * @param boolean $is_renderable Huh? * @param \GV\Request $this This. @@ -45,7 +50,7 @@ public function is_renderable() { * @return boolean */ public static function is_admin() { - $doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false; + $doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false; $load_scripts_styles = preg_match( '#^/wp-admin/load-(scripts|styles).php$#', Utils::_SERVER( 'SCRIPT_NAME' ) ); return is_admin() && ! ( $doing_ajax || $load_scripts_styles ); @@ -69,7 +74,7 @@ public static function is_frontend() { */ public static function is_add_oembed_preview() { /** The preview request is a parse-embed AJAX call without a type set. */ - return ( self::is_ajax() && ! empty( $_POST['action'] ) && $_POST['action'] == 'parse-embed' && ! isset( $_POST['type'] ) ); + return ( self::is_ajax() && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] && ! isset( $_POST['type'] ) ); } /** @@ -149,16 +154,16 @@ public function is_entry( $form_id = 0 ) { } // If there are multiple Views on a page, the permalink _should_ include `gvid` to specify which View to use. - if( $view instanceof \GV\View_Collection ) { - $gvid = \GV\Utils::_GET( 'gvid' ); - $view = $view->get( $gvid ); + if ( $view instanceof \GV\View_Collection ) { + $gvid = \GV\Utils::_GET( 'gvid' ); + $view = $view->get( $gvid ); } /** * A joined request. */ if ( $view instanceof \GV\View && ( $joins = $view->joins ) ) { - $forms = array_merge( wp_list_pluck( $joins, 'join' ), wp_list_pluck( $joins, 'join_on' ) ); + $forms = array_merge( wp_list_pluck( $joins, 'join' ), wp_list_pluck( $joins, 'join_on' ) ); $valid_forms = array_unique( wp_list_pluck( $forms, 'ID' ) ); $multientry = array(); @@ -186,7 +191,7 @@ public function is_entry( $form_id = 0 ) { } $entry = Multi_Entry::from_entries( array_filter( $multientry ) ); - } else { + } else { /** * A regular one. */ @@ -214,7 +219,7 @@ public function is_edit_entry( $form_id = 0 ) { $entry = $this->is_entry( $form_id ); /** - * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n + * Whether we're currently on the Edit Entry screen \n. * The Edit Entry functionality overrides this value. * * @param boolean $is_edit_entry @@ -254,7 +259,7 @@ public function is_search() { $get = array_filter( (array) $get, 'gravityview_is_not_empty_string' ); - if( $this->_has_field_key( $get ) ) { + if ( $this->_has_field_key( $get ) ) { return true; } @@ -281,13 +286,13 @@ private function _has_field_key( $get ) { $meta = array(); foreach ( $fields as $field ) { - if( empty( $field->_gf_field_class_name ) ) { + if ( empty( $field->_gf_field_class_name ) ) { $meta[] = preg_quote( $field->name ); } } foreach ( $get as $key => $value ) { - if ( preg_match('/^(filter|input)_(([0-9_]+)|'. implode( '|', $meta ) .')$/sm', $key ) ) { + if ( preg_match( '/^(filter|input)_(([0-9_]+)|' . implode( '|', $meta ) . ')$/sm', $key ) ) { $has_field_key = true; break; } diff --git a/future/includes/class-gv-settings-plugin.php b/future/includes/class-gv-settings-plugin.php index e45b16dcfc..3afdb454e7 100644 --- a/future/includes/class-gv-settings-plugin.php +++ b/future/includes/class-gv-settings-plugin.php @@ -30,17 +30,20 @@ class Plugin_Settings { * * @var array */ - private $_plugin_settings = []; + private $_plugin_settings = array(); public function __construct() { // GravityKitFoundation may not yet be available when this class is instantiated, so let's temporarily use the Settings framework from Foundation that's included with GravityView and then possibly replace it with the latest version. $this->_foundation_settings = SettingsFramework::get_instance(); - add_action( 'gk/foundation/initialized', function () { - $this->_foundation_settings = GravityKitFoundation::settings(); - } ); + add_action( + 'gk/foundation/initialized', + function () { + $this->_foundation_settings = GravityKitFoundation::settings(); + } + ); - add_filter( 'gk/foundation/settings/data/plugins', [ $this, 'add_settings' ] ); + add_filter( 'gk/foundation/settings/data/plugins', array( $this, 'add_settings' ) ); } /** @@ -75,7 +78,7 @@ public function get( $key, $default = null ) { * @return mixed * @deprecated Use gravityview()->plugin->settings->get() */ - static public function getSetting( $key ) { + public static function getSetting( $key ) { if ( gravityview()->plugin->settings instanceof Plugin_Settings ) { return gravityview()->plugin->settings->get( $key ); } @@ -132,13 +135,13 @@ public function migrate_legacy_settings() { } if ( empty( $legacy_settings ) ) { - return []; + return array(); } // Migrate legacy GravityView settings that are still part of GravityView. - $plugin_settings = [ + $plugin_settings = array( 'rest_api' => (int) Arr::get( $legacy_settings, 'rest_api' ), - ]; + ); $this->_foundation_settings->save_plugin_settings( self::SETTINGS_PLUGIN_ID, $plugin_settings ); @@ -150,7 +153,7 @@ public function migrate_legacy_settings() { $gk_settings = $this->_foundation_settings->get_plugin_settings( $gk_settings_id ); if ( empty( $gk_settings ) ) { - $gk_settings = [ + $gk_settings = array( 'support_email' => Arr::get( $legacy_settings, 'support-email' ), 'support_port' => Arr::get( $legacy_settings, 'support_port' ), 'powered_by' => (int) Arr::get( $legacy_settings, 'powered_by' ), @@ -159,7 +162,7 @@ public function migrate_legacy_settings() { 'support_email' => Arr::get( $legacy_settings, 'support-email' ), 'support_port' => (int) Arr::get( $legacy_settings, 'support_port' ), 'no_conflict_mode' => (int) Arr::get( $legacy_settings, 'no-conflict-mode' ), - ]; + ); $this->_foundation_settings->save_plugin_settings( $gk_settings_id, $gk_settings ); } @@ -187,13 +190,13 @@ public function get_gravitykit_setting( $setting, $default = null ) { * @return array The defaults. */ public function defaults() { - $defaults = [ - 'rest_api' => 0, + $defaults = array( + 'rest_api' => 0, 'public_entry_moderation' => 0, - ]; + ); /** - * @filter `gravityview/settings/default` Filter default global settings. + * Filter default global settings. * * @param [in,out] array The defaults. */ @@ -225,48 +228,48 @@ public function add_settings( $plugins_data ) { $default_settings = $this->defaults(); - $settings = [ + $settings = array( 'id' => self::SETTINGS_PLUGIN_ID, 'title' => 'GravityView', 'defaults' => $default_settings, 'icon' => 'data:image/svg+xml,%3Csvg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Crect width="80" height="80" rx="8" fill="%23FF1B67"/%3E%3Cg clip-path="url(%23clip0_16_27)"%3E%3Cpath fill-rule="evenodd" clip-rule="evenodd" d="M58.4105 54.6666H52.8824V56.4999C52.8824 59.5375 50.3902 61.9999 47.3544 61.9999H32.6134C29.5375 61.9999 27.0853 59.5375 27.0853 56.4999V29H21.5572C20.5144 29 19.7148 29.8207 19.7148 30.8333V49.1666C19.7148 50.1792 20.5144 51 21.5572 51H22.4788C22.9629 51 23.3997 51.4104 23.3997 51.9167V53.75C23.3997 54.2562 22.9629 54.6666 22.4788 54.6666H21.5572C18.4786 54.6666 16.0292 52.2042 16.0292 49.1666V30.8333C16.0292 27.7957 18.4786 25.3333 21.5572 25.3333H27.0853V23.5C27.0853 20.4624 29.5375 18 32.6134 18H47.3544C50.3902 18 52.8824 20.4624 52.8824 23.5V51H58.4105C59.4132 51 60.2529 50.1792 60.2529 49.1666V30.8333C60.2529 29.8207 59.4132 29 58.4105 29H57.4889C56.9647 29 56.5673 28.5896 56.5673 28.0833V26.2499C56.5673 25.7437 56.9647 25.3333 57.4889 25.3333H58.4105C61.449 25.3333 63.9378 27.7957 63.9378 30.8333V49.1666C63.9378 52.2042 61.449 54.6666 58.4105 54.6666ZM49.1968 23.5C49.1968 22.4874 48.3544 21.6667 47.3544 21.6667H32.6134C31.5733 21.6667 30.7709 22.4874 30.7709 23.5V56.4999C30.7709 57.5125 31.5733 58.3333 32.6134 58.3333H47.3544C48.3544 58.3333 49.1968 57.5125 49.1968 56.4999V23.5Z" fill="white"/%3E%3C/g%3E%3Cdefs%3E%3CclipPath id="clip0_16_27"%3E%3Crect width="48" height="44" fill="white" transform="translate(16 18)"/%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E%0A', - 'sections' => [ - [ + 'sections' => array( + array( 'title' => esc_html__( 'General', 'gk-gravityview' ), - 'settings' => [ - [ + 'settings' => array( + array( 'id' => 'rest_api', 'type' => 'checkbox', 'title' => esc_html__( 'REST API', 'gk-gravityview' ), 'description' => esc_html__( 'Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gk-gravityview' ) . ' ' . esc_html__( 'If you are unsure, disable this setting.', 'gk-gravityview' ), 'value' => $this->get( 'rest_api', $default_settings['rest_api'] ), - ], - ], - ], - [ + ), + ), + ), + array( 'title' => esc_html__( 'Permissions', 'gk-gravityview' ), - 'settings' => [ - [ + 'settings' => array( + array( 'id' => 'public_entry_moderation', 'type' => 'checkbox', 'title' => esc_html__( 'Enable Public Entry Moderation', 'gk-gravityview' ), - 'description' => strtr( + 'description' => strtr( // translators: Do not translate the words inside the {} curly brackets; they are replaced. __( 'If enabled, adding {public} to {link}entry moderation merge tags{/link} will allow logged-out users to approve or reject entries. If disabled, all entry moderation actions require the user to be logged-in and have the ability to edit the entry.', 'gk-gravityview' ), array( '{public}' => ':public', - '{link}' => '', - '{/link}' => ' ' . esc_html__( '(This link opens in a new window.)', 'gk-gravityview' ) . '', + '{link}' => '', + '{/link}' => ' ' . esc_html__( '(This link opens in a new window.)', 'gk-gravityview' ) . '', ) ), 'value' => $this->get( 'public_entry_moderation', $default_settings['public_entry_moderation'] ), - ], - ], - ], - ], - ]; + ), + ), + ), + ), + ); - return array_merge( (array) $plugins_data, [ self::SETTINGS_PLUGIN_ID => $settings ] ); + return array_merge( (array) $plugins_data, array( self::SETTINGS_PLUGIN_ID => $settings ) ); } /** @@ -287,11 +290,11 @@ public function update_app_settings( $settings ) { * Sets a subset of settings. * * @param array|string An array of settings to update, or string (key) and $value to update one setting. - * @param mixed $value A value if $settings is string (key). Default: null. + * @param mixed $value A value if $settings is string (key). Default: null. */ public function set( $settings, $value = null ) { if ( is_string( $settings ) ) { - $settings = [ $settings => $value ]; + $settings = array( $settings => $value ); } $settings = wp_parse_args( $settings, $this->all() ); @@ -334,7 +337,7 @@ public function maybe_save_app_settings() { return; } - $_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't + $_POST = array(); // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't \GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gk-gravityview' ) ); } @@ -359,6 +362,6 @@ private function _uninstall_form_strings() { __( 'I found a better plugin', 'gk-gravityview' ); __( 'What plugin you are using, and why?', 'gk-gravityview' ); __( 'Other', 'gk-gravityview' ); - _x( '%s ("Not at all likely") to %s ("Extremely likely")', 'A scale from 0 (bad) to 10 (good)', 'gk-gravityview' ); + _x( '%1$s ("Not at all likely") to %2$s ("Extremely likely")', 'A scale from 0 (bad) to 10 (good)', 'gk-gravityview' ); } } diff --git a/future/includes/class-gv-settings-view.php b/future/includes/class-gv-settings-view.php index ef62151cfc..5580fd676c 100644 --- a/future/includes/class-gv-settings-view.php +++ b/future/includes/class-gv-settings-view.php @@ -282,7 +282,7 @@ public static function defaults( $detailed = false, $group = null ) { 'value' => '', 'group' => 'sort', 'options' => array( - '' => __( 'Default', 'gk-gravityview' ), + 'id' => __( 'Default', 'gk-gravityview' ), 'date_created' => __( 'Date Created', 'gk-gravityview' ), ), 'show_in_shortcode' => true, @@ -313,7 +313,7 @@ public static function defaults( $detailed = false, $group = null ) { 'value' => '', 'group' => 'sort', 'options' => array( - '' => __( 'Default', 'gk-gravityview' ), + 'id' => __( 'Default', 'gk-gravityview' ), 'date_created' => __( 'Date Created', 'gk-gravityview' ), ), 'requires_not' => 'sort_direction][=RAND', // ][ is for toggleRequired, so it ends in [] @@ -352,7 +352,7 @@ public static function defaults( $detailed = false, $group = null ) { 'preset_business_data', 'preset_issue_tracker', 'preset_resume_board', - 'preset_job_board' + 'preset_job_board', ), 'article' => array( 'id' => '54ee1246e4b034c37ea91c11', @@ -572,65 +572,65 @@ public static function defaults( $detailed = false, $group = null ) { 'show_in_shortcode' => false, 'full_width' => true, 'article' => array( - 'id' => '5590376ce4b027e1978eb8d0', + 'id' => '5590376ce4b027e1978eb8d0', 'type' => 'modal', - 'url' => 'https://docs.gravitykit.com/article/288-how-gravityview-security-works', + 'url' => 'https://docs.gravitykit.com/article/288-how-gravityview-security-works', ), ), - 'custom_css' => array( + 'custom_css' => array( 'label' => __( 'Custom CSS', 'gk-gravityview' ), 'group' => 'default', // translators: Do not translate the words inside the square brackets ([]); they are replaced. 'desc' => strtr( // translators: Do not translate the words inside the square brackets ([]); they are replaced. esc_html__( 'CSS added here will be placed inside [style] tags in the page’s [head], after GravityView styles.', 'gk-gravityview' ), - [ + array( '[style]' => '' . esc_html( ' -enableColumns ) ) { + if ( empty( $list_field->enableColumns ) ) { continue; } $list_columns = array(); - foreach ( (array)$list_field->choices as $key => $input ) { + foreach ( (array) $list_field->choices as $key => $input ) { $input_id = sprintf( '%d.%d', $list_field->id, $key ); // {field_id}.{column_key} @@ -109,15 +109,16 @@ function add_form_fields( $fields = array(), $form = array(), $include_parent_fi } // If there are columns, add them under the parent field - if( ! empty( $list_columns ) ) { + if ( ! empty( $list_columns ) ) { $index = array_search( $list_field->id, array_keys( $fields ) ) + 1; /** * Merge the $list_columns into the $fields array at $index + * * @see https://stackoverflow.com/a/1783125 */ - $fields = array_slice( $fields, 0, $index, true) + $list_columns + array_slice( $fields, $index, null, true); + $fields = array_slice( $fields, 0, $index, true ) + $list_columns + array_slice( $fields, $index, null, true ); } unset( $list_columns, $index, $input_id ); @@ -134,9 +135,9 @@ function add_form_fields( $fields = array(), $form = array(), $include_parent_fi * @see GF_Field_List::get_value_entry_detail() * * @param GF_Field_List $field Gravity Forms field - * @param string|array $field_value Serialized or unserialized array value for the field - * @param int|string $column_id The numeric key of the column (0-index) or the label of the column - * @param string $format If set to 'raw', return an array of values for the column. Otherwise, allow Gravity Forms to render using `html` or `text` + * @param string|array $field_value Serialized or unserialized array value for the field + * @param int|string $column_id The numeric key of the column (0-index) or the label of the column + * @param string $format If set to 'raw', return an array of values for the column. Otherwise, allow Gravity Forms to render using `html` or `text` * * @return array|string|null Returns null if the $field_value passed wasn't an array or serialized array */ @@ -144,7 +145,7 @@ public static function column_value( GF_Field_List $field, $field_value, $column $list_rows = maybe_unserialize( $field_value ); - if( ! is_array( $list_rows ) ) { + if ( ! is_array( $list_rows ) ) { gravityview()->log->error( '$field_value did not unserialize', array( 'data' => $field_value ) ); return null; } @@ -157,15 +158,15 @@ public static function column_value( GF_Field_List $field, $field_value, $column foreach ( (array) $list_row as $column_key => $column_value ) { // If the label of the column matches $column_id, or the numeric key value matches, add the value - if( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { + if ( (string) $column_key === (string) $column_id || ( is_numeric( $column_id ) && (int) $column_id === $current_column ) ) { $column_values[] = $column_value; } - $current_column++; + ++$current_column; } } // Return the array of values - if( 'raw' === $format ) { + if ( 'raw' === $format ) { return $column_values; } // Return the Gravity Forms Field output @@ -180,9 +181,9 @@ public static function column_value( GF_Field_List $field, $field_value, $column * @since 1.14 * * @param string $label Existing label string - * @param array $field GV field settings array, with `id`, `show_label`, `label`, `custom_label`, etc. keys - * @param array $form Gravity Forms form array - * @param array $entry Gravity Forms entry array + * @param array $field GV field settings array, with `id`, `show_label`, `label`, `custom_label`, etc. keys + * @param array $form Gravity Forms form array + * @param array $entry Gravity Forms entry array * * @return string Existing label if the field isn't */ @@ -191,19 +192,19 @@ public function _filter_field_label( $label, $field, $form, $entry ) { $field_object = RGFormsModel::get_field( $form, $field['id'] ); // Not a list field - if( ! $field_object || 'list' !== $field_object->type ) { + if ( ! $field_object || 'list' !== $field_object->type ) { return $label; } // Custom label is defined, so use it - if( ! empty( $field['custom_label'] ) ) { + if ( ! empty( $field['custom_label'] ) ) { return $label; } $column_id = gravityview_get_input_id_from_id( $field['id'] ); // Parent field, not column field - if( false === $column_id ) { + if ( false === $column_id ) { return $label; } @@ -216,15 +217,15 @@ public function _filter_field_label( $label, $field, $form, $entry ) { * @since 1.14 * * @param GF_Field_List $field Gravity Forms List field - * @param int $column_id The key of the column (0-index) - * @param string $backup_label Backup label to use. Optional. + * @param int $column_id The key of the column (0-index) + * @param string $backup_label Backup label to use. Optional. * * @return string */ public static function get_column_label( GF_Field_List $field, $column_id, $backup_label = '' ) { // Doesn't have columns enabled - if( ! isset( $field->choices ) || ! $field->enableColumns ) { + if ( ! isset( $field->choices ) || ! $field->enableColumns ) { return $backup_label; } @@ -233,7 +234,6 @@ public static function get_column_label( GF_Field_List $field, $column_id, $back return isset( $columns[ $column_id ] ) ? $columns[ $column_id ] : $backup_label; } - } -new GravityView_Field_List; +new GravityView_Field_List(); diff --git a/includes/fields/class-gravityview-field-multiselect.php b/includes/fields/class-gravityview-field-multiselect.php index da93297bc8..3d22867887 100644 --- a/includes/fields/class-gravityview-field-multiselect.php +++ b/includes/fields/class-gravityview-field-multiselect.php @@ -13,7 +13,7 @@ class GravityView_Field_MultiSelect extends GravityView_Field { * @see GFCommon::get_field_filter_settings Gravity Forms suggests checkboxes should just be "contains" * @var array */ - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); var $is_searchable = true; @@ -32,7 +32,7 @@ public function __construct() { /** * Add `choice_display` setting to the field * - * @param array $field_options + * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context @@ -47,7 +47,7 @@ public function field_options( $field_options, $template_id, $field_id, $context // Set the $_field_id var $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); - if( $this->is_choice_value_enabled() ) { + if ( $this->is_choice_value_enabled() ) { $field_options['choice_display'] = array( 'type' => 'radio', 'value' => 'value', @@ -65,4 +65,4 @@ public function field_options( $field_options, $template_id, $field_id, $context } } -new GravityView_Field_MultiSelect; +new GravityView_Field_MultiSelect(); diff --git a/includes/fields/class-gravityview-field-name.php b/includes/fields/class-gravityview-field-name.php index 3b65086e0b..90f9f58fb5 100644 --- a/includes/fields/class-gravityview-field-name.php +++ b/includes/fields/class-gravityview-field-name.php @@ -24,7 +24,6 @@ public function __construct() { $this->label = esc_html__( 'Name', 'gk-gravityview' ); parent::__construct(); } - } -new GravityView_Field_Name; +new GravityView_Field_Name(); diff --git a/includes/fields/class-gravityview-field-number.php b/includes/fields/class-gravityview-field-number.php index 260f20a6f5..83fbd249d4 100644 --- a/includes/fields/class-gravityview-field-number.php +++ b/includes/fields/class-gravityview-field-number.php @@ -34,25 +34,24 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { $field_options['number_format'] = array( - 'type' => 'checkbox', + 'type' => 'checkbox', 'label' => __( 'Format number?', 'gk-gravityview' ), - 'desc' => __('Display numbers with thousands separators.', 'gk-gravityview'), + 'desc' => __( 'Display numbers with thousands separators.', 'gk-gravityview' ), 'value' => false, 'group' => 'field', ); $field_options['decimals'] = array( - 'type' => 'number', - 'label' => __( 'Decimals', 'gk-gravityview' ), - 'desc' => __('Precision of the number of decimal places. Leave blank to use existing precision.', 'gk-gravityview'), - 'value' => '', + 'type' => 'number', + 'label' => __( 'Decimals', 'gk-gravityview' ), + 'desc' => __( 'Precision of the number of decimal places. Leave blank to use existing precision.', 'gk-gravityview' ), + 'value' => '', 'merge_tags' => false, - 'group' => 'field', + 'group' => 'field', ); return $field_options; } - } -new GravityView_Field_Number; +new GravityView_Field_Number(); diff --git a/includes/fields/class-gravityview-field-option.php b/includes/fields/class-gravityview-field-option.php index 656e93b0ac..3c686dccce 100644 --- a/includes/fields/class-gravityview-field-option.php +++ b/includes/fields/class-gravityview-field-option.php @@ -33,4 +33,4 @@ public function __construct() { } } -new GravityView_Field_Option; +new GravityView_Field_Option(); diff --git a/includes/fields/class-gravityview-field-other-entries.php b/includes/fields/class-gravityview-field-other-entries.php index bd9e03b1d1..2d373da26a 100644 --- a/includes/fields/class-gravityview-field-other-entries.php +++ b/includes/fields/class-gravityview-field-other-entries.php @@ -26,8 +26,8 @@ class GravityView_Field_Other_Entries extends GravityView_Field { private $context; public function __construct() { - $this->label = esc_html__( 'Other Entries', 'gk-gravityview' ); - $this->description = esc_html__('Display other entries created by the entry creator.', 'gk-gravityview'); + $this->label = esc_html__( 'Other Entries', 'gk-gravityview' ); + $this->description = esc_html__( 'Display other entries created by the entry creator.', 'gk-gravityview' ); parent::__construct(); } @@ -37,7 +37,7 @@ public function __construct() { */ public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } @@ -47,31 +47,31 @@ public function field_options( $field_options, $template_id, $field_id, $context $new_options = array(); $new_options['link_format'] = array( - 'type' => 'text', - 'label' => __( 'Entry link text (required)', 'gk-gravityview' ), - 'value' => __('Entry #{entry_id}', 'gk-gravityview'), + 'type' => 'text', + 'label' => __( 'Entry link text (required)', 'gk-gravityview' ), + 'value' => __( 'Entry #{entry_id}', 'gk-gravityview' ), 'merge_tags' => 'force', - 'group' => 'field', + 'group' => 'field', ); $new_options['after_link'] = array( - 'type' => 'textarea', - 'label' => __( 'Text or HTML to display after the link (optional)', 'gk-gravityview' ), - 'desc' => __('This content will be displayed below each entry link.', 'gk-gravityview'), - 'value' => '', + 'type' => 'textarea', + 'label' => __( 'Text or HTML to display after the link (optional)', 'gk-gravityview' ), + 'desc' => __( 'This content will be displayed below each entry link.', 'gk-gravityview' ), + 'value' => '', 'merge_tags' => 'force', - 'class' => 'widefat code', - 'group' => 'field', + 'class' => 'widefat code', + 'group' => 'field', ); $new_options['page_size'] = array( - 'type' => 'number', - 'label' => __( 'Entries to Display', 'gk-gravityview' ), - 'desc' => __( 'What is the maximum number of entries that should be shown?', 'gk-gravityview' ) . ' ' . sprintf( _x( 'Set to %s for no maximum.', '%s replaced with a formatted 0', 'gk-gravityview' ), '0' ), - 'value' => '10', + 'type' => 'number', + 'label' => __( 'Entries to Display', 'gk-gravityview' ), + 'desc' => __( 'What is the maximum number of entries that should be shown?', 'gk-gravityview' ) . ' ' . sprintf( _x( 'Set to %s for no maximum.', '%s replaced with a formatted 0', 'gk-gravityview' ), '0' ), + 'value' => '10', 'merge_tags' => false, - 'min' => 0, - 'group' => 'field', + 'min' => 0, + 'group' => 'field', ); $new_options['no_entries_hide'] = array( @@ -83,13 +83,13 @@ public function field_options( $field_options, $template_id, $field_id, $context ); $new_options['no_entries_text'] = array( - 'type' => 'text', - 'label' => __( 'No Entries Text', 'gk-gravityview' ), - 'desc' => __( 'The text that is shown if the entry creator has no other entries (and "Hide if no entries" is disabled).', 'gk-gravityview' ), - 'value' => __( 'This user has no other entries.', 'gk-gravityview' ), - 'class' => 'widefat', + 'type' => 'text', + 'label' => __( 'No Entries Text', 'gk-gravityview' ), + 'desc' => __( 'The text that is shown if the entry creator has no other entries (and "Hide if no entries" is disabled).', 'gk-gravityview' ), + 'value' => __( 'This user has no other entries.', 'gk-gravityview' ), + 'class' => 'widefat', 'requires' => 'no_entries_hide', - 'group' => 'visibility', + 'group' => 'visibility', ); return $new_options + $field_options; @@ -129,7 +129,7 @@ public function get_entries( $context ) { foreach ( $remove as $r ) { list( $filter, $priority, $id ) = $r; - $removed[] = array( $filter, $priority, $id, $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); + $removed[] = array( $filter, $priority, $id, $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); unset( $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] ); } @@ -138,7 +138,7 @@ public function get_entries( $context ) { $entries = $context->view->get_entries()->all(); foreach ( $removed as $r ) { - list( $filter, $priority, $id, $function ) = $r; + list( $filter, $priority, $id, $function ) = $r; $wp_filter[ $filter ]->callbacks[ $priority ][ $id ] = $function; } @@ -157,13 +157,13 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array /** Filter entries by approved and created_by. */ $search_criteria['field_filters'][] = array( - 'key' => 'created_by', - 'value' => $created_by, - 'operator' => 'is' + 'key' => 'created_by', + 'value' => $created_by, + 'operator' => 'is', ); /** - * @filter `gravityview/field/other_entries/criteria` Modify the search parameters before the entries are fetched. + * Modify the search parameters before the entries are fetched. * * @since 1.11 * @@ -177,10 +177,10 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array /** Force mode all and filter out our own entry. */ $search_criteria['field_filters']['mode'] = 'all'; - $search_criteria['field_filters'][] = array( - 'key' => 'id', - 'value' => $context->entry->ID, - 'operator' => 'isnot' + $search_criteria['field_filters'][] = array( + 'key' => 'id', + 'value' => $context->entry->ID, + 'operator' => 'isnot', ); $search_criteria['paging']['page_size'] = $context->field->page_size ? : 10; @@ -194,4 +194,4 @@ public function gf_query_filter( &$query, $view, $request ) { } } -new GravityView_Field_Other_Entries; +new GravityView_Field_Other_Entries(); diff --git a/includes/fields/class-gravityview-field-page.php b/includes/fields/class-gravityview-field-page.php index b4eba6eca7..565bf74b3d 100644 --- a/includes/fields/class-gravityview-field-page.php +++ b/includes/fields/class-gravityview-field-page.php @@ -24,4 +24,4 @@ public function __construct() { } } -new GravityView_Field_Page; +new GravityView_Field_Page(); diff --git a/includes/fields/class-gravityview-field-password.php b/includes/fields/class-gravityview-field-password.php index a9727c0e44..d414abcb1f 100644 --- a/includes/fields/class-gravityview-field-password.php +++ b/includes/fields/class-gravityview-field-password.php @@ -22,7 +22,7 @@ public function __construct() { $this->add_hooks(); parent::__construct(); - + add_filter( 'gravityview/field/password/value', array( $this, 'get_value' ), 10, 6 ); } @@ -31,12 +31,12 @@ public function __construct() { * * @since 2.0 * - * @param mixed $value The value of the field. - * @param \GV\Field $field The field as seen by future. - * @param \GV\View $view The view requested in. - * @param \GV\Source $source The data source (form). - * @param \GV\Entry $entry The entry. - * @param \GV\Request $request The request context. + * @param mixed $value The value of the field. + * @param \GV\Field $field The field as seen by future. + * @param \GV\View $view The view requested in. + * @param \GV\Source $source The data source (form). + * @param \GV\Entry $entry The entry. + * @param \GV\Request $request The request context. * * @return mixed $value The filtered value. */ @@ -65,22 +65,22 @@ function add_hooks() { * @since 1.17 * * @param string $label Field label HTML - * @param array $field GravityView field array - * @param array $form Gravity Forms form array - * @param array $entry Gravity Forms entry array + * @param array $field GravityView field array + * @param array $form Gravity Forms form array + * @param array $entry Gravity Forms entry array * * @return string If a custom field label isn't set, return the field label for the password field */ - function field_label( $label = '', $field = array(), $form = array(), $entry = array() ){ + function field_label( $label = '', $field = array(), $form = array(), $entry = array() ) { // If using a custom label, no need to fetch the parent label - if( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { + if ( ! is_numeric( $field['id'] ) || ! empty( $field['custom_label'] ) ) { return $label; } $field_object = GFFormsModel::get_field( $form, $field['id'] ); - if( $field_object && 'password' === $field_object->type ) { + if ( $field_object && 'password' === $field_object->type ) { $label = $field['label']; } @@ -94,19 +94,19 @@ function field_label( $label = '', $field = array(), $form = array(), $entry = a * * @param array $fields Associative array of fields, with keys as field type * @param array $form GF Form array - * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs + * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs * * @return array $fields with list field columns added, if exist. Unmodified if form has no list fields. */ function add_form_fields( $fields = array(), $form = array(), $include_parent_field = true ) { foreach ( $fields as $key => $field ) { - if( 'password' === $field['type'] ) { + if ( 'password' === $field['type'] ) { // The Enter Password input - if( floor( $key ) === floatval( $key ) ) { + if ( floor( $key ) === floatval( $key ) ) { - if( ! empty( $field['parent'] ) ) { + if ( ! empty( $field['parent'] ) ) { $field['label'] = $field['parent']->label; $field['adminOnly'] = $field['parent']->adminOnly; $field['adminLabel'] = $field['parent']->adminLabel; @@ -124,7 +124,6 @@ function add_form_fields( $fields = array(), $form = array(), $include_parent_fi return $fields; } - } -new GravityView_Field_Password; +new GravityView_Field_Password(); diff --git a/includes/fields/class-gravityview-field-payment-amount.php b/includes/fields/class-gravityview-field-payment-amount.php index c23c850ad6..c05b4d65c9 100644 --- a/includes/fields/class-gravityview-field-payment-amount.php +++ b/includes/fields/class-gravityview-field-payment-amount.php @@ -43,15 +43,16 @@ public function __construct() { * * @param string $output HTML value output * @param array $entry The GF entry array - * @param array $field_settings Settings for the particular GV field - * @param array $field Current field being displayed + * @param array $field_settings Settings for the particular GV field + * @param array $field Current field being displayed * * @return String values for this field based on the numeric values used by Gravity Forms */ public function get_content( $output = '', $entry = array(), $field_settings = array(), $field = array() ) { /** Overridden by a template. */ - if( ! empty( $field['field_path'] ) ) { return $output; } + if ( ! empty( $field['field_path'] ) ) { + return $output; } $amount = \GV\Utils::get( $entry, 'payment_amount' ); $return = GFCommon::to_money( $amount, \GV\Utils::get( $entry, 'currency' ) ); @@ -64,12 +65,12 @@ public function get_content( $output = '', $entry = array(), $field_settings = a * * @since 2.0 * - * @param mixed $value The value of the field. - * @param \GV\Field $field The field as seen by future. - * @param \GV\View $view The view requested in. - * @param \GV\Source $source The data source (form). - * @param \GV\Entry $entry The entry. - * @param \GV\Request $request The request context. + * @param mixed $value The value of the field. + * @param \GV\Field $field The field as seen by future. + * @param \GV\View $view The view requested in. + * @param \GV\Source $source The data source (form). + * @param \GV\Entry $entry The entry. + * @param \GV\Request $request The request context. * * @return mixed $value The filtered value. */ @@ -81,16 +82,16 @@ public function get_value( $value, $field, $view, $source, $entry, $request ) { * Add {payment_amount} merge tag * * @since 1.16 - ** - * @param array $matches Array of Merge Tag matches found in text by preg_match_all + * * + * @param array $matches Array of Merge Tag matches found in text by preg_match_all * @param string $text Text to replace - * @param array $form Gravity Forms form array - * @param array $entry Entry array - * @param bool $url_encode Whether to URL-encode output + * @param array $form Gravity Forms form array + * @param array $entry Entry array + * @param bool $url_encode Whether to URL-encode output * * @return string Original text if {date_created} isn't found. Otherwise, replaced text. */ - public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { + public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { $return = $text; @@ -112,4 +113,4 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array } } -new GravityView_Field_Payment_Amount; +new GravityView_Field_Payment_Amount(); diff --git a/includes/fields/class-gravityview-field-payment-date.php b/includes/fields/class-gravityview-field-payment-date.php index 5e1e8ffb42..7a654e4525 100644 --- a/includes/fields/class-gravityview-field-payment-date.php +++ b/includes/fields/class-gravityview-field-payment-date.php @@ -28,7 +28,7 @@ public function __construct() { // Constructor before the variables because the class extends Date_Created parent::__construct(); - $this->label = esc_html__( 'Payment Date', 'gk-gravityview' ); + $this->label = esc_html__( 'Payment Date', 'gk-gravityview' ); $this->description = esc_html__( 'The date the payment was received.', 'gk-gravityview' ); add_filter( 'gravityview/field/payment_date/value', array( $this, 'get_value' ), 10, 6 ); @@ -39,12 +39,12 @@ public function __construct() { * * @since 2.0 * - * @param mixed $value The value of the field. - * @param \GV\Field $field The field as seen by future. - * @param \GV\View $view The view requested in. - * @param \GV\Source $source The data source (form). - * @param \GV\Entry $entry The entry. - * @param \GV\Request $request The request context. + * @param mixed $value The value of the field. + * @param \GV\Field $field The field as seen by future. + * @param \GV\View $view The view requested in. + * @param \GV\Source $source The data source (form). + * @param \GV\Entry $entry The entry. + * @param \GV\Request $request The request context. * * @return mixed $value The filtered value. */ @@ -55,4 +55,4 @@ public function get_value( $value, $field, $view, $source, $entry, $request ) { } } -new GravityView_Field_Payment_Date; +new GravityView_Field_Payment_Date(); diff --git a/includes/fields/class-gravityview-field-payment-method.php b/includes/fields/class-gravityview-field-payment-method.php index 6dd4764f20..25030b3836 100644 --- a/includes/fields/class-gravityview-field-payment-method.php +++ b/includes/fields/class-gravityview-field-payment-method.php @@ -26,10 +26,10 @@ class GravityView_Field_Payment_Method extends GravityView_Field { * GravityView_Field_Date_Created constructor. */ public function __construct() { - $this->label = esc_html__( 'Payment Method', 'gk-gravityview' ); + $this->label = esc_html__( 'Payment Method', 'gk-gravityview' ); $this->description = esc_html__( 'The way the entry was paid for (ie "Credit Card", "PayPal", etc.)', 'gk-gravityview' ); parent::__construct(); } } -new GravityView_Field_Payment_Method; +new GravityView_Field_Payment_Method(); diff --git a/includes/fields/class-gravityview-field-payment-status.php b/includes/fields/class-gravityview-field-payment-status.php index 9baa9de59b..081fb8f6bb 100644 --- a/includes/fields/class-gravityview-field-payment-status.php +++ b/includes/fields/class-gravityview-field-payment-status.php @@ -24,10 +24,10 @@ class GravityView_Field_Payment_Status extends GravityView_Field { * GravityView_Field_Payment_Status constructor. */ public function __construct() { - $this->label = esc_html__( 'Payment Status', 'gk-gravityview' ); - $this->description = esc_html__('The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gk-gravityview' ); + $this->label = esc_html__( 'Payment Status', 'gk-gravityview' ); + $this->description = esc_html__( 'The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gk-gravityview' ); parent::__construct(); } } -new GravityView_Field_Payment_Status; +new GravityView_Field_Payment_Status(); diff --git a/includes/fields/class-gravityview-field-phone.php b/includes/fields/class-gravityview-field-phone.php index 9cb6afd3a6..3cdab26e1b 100644 --- a/includes/fields/class-gravityview-field-phone.php +++ b/includes/fields/class-gravityview-field-phone.php @@ -30,7 +30,7 @@ public function __construct() { * * @since 1.17 * - * @param array $field_options + * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context @@ -40,21 +40,21 @@ public function __construct() { */ public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } $field_options['link_phone'] = array( - 'type' => 'checkbox', - 'label' => __( 'Make Phone Number Clickable', 'gk-gravityview' ), - 'desc' => __( 'Allow dialing a number by clicking it?', 'gk-gravityview'), - 'value' => true, - 'group' => 'display', - 'priority' => 100, - ); + 'type' => 'checkbox', + 'label' => __( 'Make Phone Number Clickable', 'gk-gravityview' ), + 'desc' => __( 'Allow dialing a number by clicking it?', 'gk-gravityview' ), + 'value' => true, + 'group' => 'display', + 'priority' => 100, + ); return $field_options; } } -new GravityView_Field_Phone; +new GravityView_Field_Phone(); diff --git a/includes/fields/class-gravityview-field-pipe_recorder.php b/includes/fields/class-gravityview-field-pipe_recorder.php index e07a1efb05..33b625c22a 100644 --- a/includes/fields/class-gravityview-field-pipe_recorder.php +++ b/includes/fields/class-gravityview-field-pipe_recorder.php @@ -29,10 +29,10 @@ public function field_options( $field_options, $template_id, $field_id, $context } $add_options['embed'] = array( - 'type' => 'checkbox', - 'label' => __( 'Display as embedded', 'gk-gravityview' ), - 'desc' => __( 'Display the video in a player, rather than a direct link to the video.', 'gk-gravityview' ), - 'value' => true, + 'type' => 'checkbox', + 'label' => __( 'Display as embedded', 'gk-gravityview' ), + 'desc' => __( 'Display the video in a player, rather than a direct link to the video.', 'gk-gravityview' ), + 'value' => true, 'merge_tags' => false, ); @@ -40,4 +40,4 @@ public function field_options( $field_options, $template_id, $field_id, $context } } -new GravityView_Field_Pipe_Recorder; +new GravityView_Field_Pipe_Recorder(); diff --git a/includes/fields/class-gravityview-field-post-category.php b/includes/fields/class-gravityview-field-post-category.php index 725c6810dc..7a0289b673 100644 --- a/includes/fields/class-gravityview-field-post-category.php +++ b/includes/fields/class-gravityview-field-post-category.php @@ -11,7 +11,7 @@ class GravityView_Field_Post_Category extends GravityView_Field { var $is_searchable = true; - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); var $_gf_field_class_name = 'GF_Field_Post_Category'; @@ -37,16 +37,16 @@ public function __construct() { * @since 1.17 * * @param array $form Gravity Forms form array - * @param int $entry_id Numeric ID of the entry that was updated + * @param int $entry_id Numeric ID of the entry that was updated * * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post. */ public function set_post_categories( $form = array(), $entry_id = 0 ) { - $entry = GFAPI::get_entry( $entry_id ); + $entry = GFAPI::get_entry( $entry_id ); $post_id = \GV\Utils::get( $entry, 'post_id' ); - if( empty( $post_id ) ) { + if ( empty( $post_id ) ) { return false; } @@ -54,15 +54,15 @@ public function set_post_categories( $form = array(), $entry_id = 0 ) { $post_category_fields = GFAPI::get_fields_by_type( $form, 'post_category' ); - if( $post_category_fields ) { + if ( $post_category_fields ) { $updated_categories = array(); foreach ( $post_category_fields as $field ) { // Get the value of the field, including $_POSTed value - $field_cats = RGFormsModel::get_field_value( $field ); - $field_cats = is_array( $field_cats ) ? array_values( $field_cats ) : (array)$field_cats; - $field_cats = gv_map_deep( $field_cats, 'intval' ); + $field_cats = RGFormsModel::get_field_value( $field ); + $field_cats = is_array( $field_cats ) ? array_values( $field_cats ) : (array) $field_cats; + $field_cats = gv_map_deep( $field_cats, 'intval' ); $updated_categories = array_merge( $updated_categories, array_values( $field_cats ) ); } @@ -70,7 +70,8 @@ public function set_post_categories( $form = array(), $entry_id = 0 ) { $updated_categories = array_filter( $updated_categories ); /** - * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced? + * Should post categories be added to or replaced? + * * @since 1.17 * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false` */ @@ -121,12 +122,12 @@ function remove_edit_entry_post_category_choices_filter() { * * @return mixed */ - function edit_entry_post_category_choices( $choices, $field, $form_id ) { + function edit_entry_post_category_choices( $choices, $field, $form_id ) { $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); // $entry['post_id'] should always be set, but we check to make sure. - if( $entry && isset( $entry['post_id'] ) && $post_id = $entry['post_id'] ) { + if ( $entry && isset( $entry['post_id'] ) && $post_id = $entry['post_id'] ) { $post_categories = wp_get_post_categories( $post_id, array( 'fields' => 'ids' ) ); @@ -141,19 +142,18 @@ function edit_entry_post_category_choices( $choices, $field, $form_id ) { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('dynamic_data', $field_options ); - $this->add_field_support('link_to_term', $field_options ); - $this->add_field_support('new_window', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); + $this->add_field_support( 'link_to_term', $field_options ); + $this->add_field_support( 'new_window', $field_options ); $field_options['new_window']['requires'] = 'link_to_term'; return $field_options; } - } -new GravityView_Field_Post_Category; +new GravityView_Field_Post_Category(); diff --git a/includes/fields/class-gravityview-field-post-content.php b/includes/fields/class-gravityview-field-post-content.php index 3d4722a940..87a7a537b0 100644 --- a/includes/fields/class-gravityview-field-post-content.php +++ b/includes/fields/class-gravityview-field-post-content.php @@ -28,11 +28,11 @@ public function field_options( $field_options, $template_id, $field_id, $context unset( $field_options['show_as_link'] ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('dynamic_data', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); return $field_options; } @@ -40,19 +40,19 @@ public function field_options( $field_options, $template_id, $field_id, $context /** * Returns the field inner markup. * - * @param array $form The Form Object currently being processed. - * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. - * @param null|array $entry Null or the Entry Object currently being edited. + * @param array $form The Form Object currently being processed. + * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. + * @param null|array $entry Null or the Entry Object currently being edited. * @param null|GF_Field_Post_Content The field being edited. * * @return string */ public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Content $field = null ) { - $id = (int) $field->id; + $id = (int) $field->id; $input_name = "input_{$id}"; - $class = esc_attr( $field->size ); - $tabindex = $field->get_tabindex(); + $class = esc_attr( $field->size ); + $tabindex = $field->get_tabindex(); $editor_settings = array( 'editor_class' => "textarea {$class}", @@ -60,13 +60,14 @@ public function get_field_input( $form, $value = '', $entry = null, GF_Field_Pos 'textarea_rows' => 15, 'tabindex' => $tabindex, 'media_buttons' => false, - 'quicktags' => false, - 'logic_event' => $field->get_conditional_logic_event( 'keyup' ), - 'placeholder' => $field->get_field_placeholder_attribute(), + 'quicktags' => false, + 'logic_event' => $field->get_conditional_logic_event( 'keyup' ), + 'placeholder' => $field->get_field_placeholder_attribute(), ); /** - * @filter `gravityview/edit_entry/post_content/wp_editor_settings` Modify the settings passed to the Post Content wp_editor() + * Modify the settings passed to the Post Content wp_editor(). + * * @see wp_editor() For the options available * @since 1.7 * @param array $editor_settings Array of settings to be passed to wp_editor(). Note: there are also two additional values in the array: `logic_event` and `placehodler`, added to the textarea HTML by GravityView. @@ -85,7 +86,6 @@ public function get_field_input( $form, $value = '', $entry = null, GF_Field_Pos return sprintf( "
%s
", trim( $editor ) ); } - } -new GravityView_Field_Post_Content; +new GravityView_Field_Post_Content(); diff --git a/includes/fields/class-gravityview-field-post-custom-field.php b/includes/fields/class-gravityview-field-post-custom-field.php index c6f3ab5706..15a5464b18 100644 --- a/includes/fields/class-gravityview-field-post-custom-field.php +++ b/includes/fields/class-gravityview-field-post-custom-field.php @@ -40,7 +40,7 @@ public function __construct() { * @return void */ private function add_hooks() { - add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value'), 10, 2 ); + add_filter( 'gravityview/edit_entry/field_value_post_custom_field', array( $this, 'edit_entry_field_value' ), 10, 2 ); } /** @@ -48,14 +48,14 @@ private function add_hooks() { * * @since 1.17 * - * @param mixed $field_value field value used to populate the input + * @param mixed $field_value field value used to populate the input * @param GF_Field $field Gravity Forms field object * * @return mixed If a List input for Custom Field, returns JSON-decoded value. Otherwise, original value. */ public function edit_entry_field_value( $field_value, $field ) { - if( 'list' === $field->inputType ) { + if ( 'list' === $field->inputType ) { $field_value = is_string( $field_value ) ? json_decode( $field_value, true ) : $field_value; if ( ! is_array( $field_value ) ) { @@ -65,7 +65,6 @@ public function edit_entry_field_value( $field_value, $field ) { return $field_value; } - } -new GravityView_Field_Post_Custom_Field; +new GravityView_Field_Post_Custom_Field(); diff --git a/includes/fields/class-gravityview-field-post-excerpt.php b/includes/fields/class-gravityview-field-post-excerpt.php index 5276dc5cf9..a2aeb5b37a 100644 --- a/includes/fields/class-gravityview-field-post-excerpt.php +++ b/includes/fields/class-gravityview-field-post-excerpt.php @@ -28,14 +28,14 @@ public function field_options( $field_options, $template_id, $field_id, $context unset( $field_options['show_as_link'] ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('dynamic_data', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); return $field_options; } } -new GravityView_Post_Excerpt; +new GravityView_Post_Excerpt(); diff --git a/includes/fields/class-gravityview-field-post-id.php b/includes/fields/class-gravityview-field-post-id.php index cc61635ebb..b4aa46e83b 100644 --- a/includes/fields/class-gravityview-field-post-id.php +++ b/includes/fields/class-gravityview-field-post-id.php @@ -31,11 +31,10 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - $this->add_field_support('link_to_post', $field_options ); + $this->add_field_support( 'link_to_post', $field_options ); return $field_options; } - } -new GravityView_Field_Post_ID; +new GravityView_Field_Post_ID(); diff --git a/includes/fields/class-gravityview-field-post-image.php b/includes/fields/class-gravityview-field-post-image.php index ca84dda71a..306a525b5c 100644 --- a/includes/fields/class-gravityview-field-post-image.php +++ b/includes/fields/class-gravityview-field-post-image.php @@ -25,16 +25,16 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - unset ( $field_options['search_filter'] ); + unset( $field_options['search_filter'] ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('link_to_post', $field_options ); + $this->add_field_support( 'link_to_post', $field_options ); // @since 1.5.4 - $this->add_field_support('dynamic_data', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); return $field_options; } @@ -51,7 +51,7 @@ public function field_options( $field_options, $template_id, $field_id, $context * * @return array with `url`, `title`, `caption` and `description` values */ - static public function explode_value( $value ) { + public static function explode_value( $value ) { // Already is an array, perhaps? if ( ! is_string( $value ) ) { @@ -61,14 +61,14 @@ static public function explode_value( $value ) { $url = $title = $caption = $description = ''; // If there's a |:| match, process. Otherwise, empty array! - if( preg_match( '/\|\:\|/', $value ) ) { + if ( preg_match( '/\|\:\|/', $value ) ) { list( $url, $title, $caption, $description ) = array_pad( explode( '|:|', $value ), 4, false ); } return array( - 'url' => $url, - 'title' => $title, - 'caption' => $caption, + 'url' => $url, + 'title' => $title, + 'caption' => $caption, 'description' => $description, ); } @@ -81,34 +81,35 @@ static public function explode_value( $value ) { * * @since 1.16.2 * - * @param array $form The Form Object currently being processed. - * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. - * @param null|array $entry Null or the Entry Object currently being edited. + * @param array $form The Form Object currently being processed. + * @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission. + * @param null|array $entry Null or the Entry Object currently being edited. * @param GF_Field_Post_Image $field The field being edited. * * @return string */ public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Image $field = null ) { - $id = (int) $field->id; - $form_id = $form['id']; + $id = (int) $field->id; + $form_id = $form['id']; $input_name = "input_{$id}"; - $field_id = sprintf( 'input_%d_%d', $form_id, $id ); - $img_name = null; + $field_id = sprintf( 'input_%d_%d', $form_id, $id ); + $img_name = null; // Convert |:| to associative array $img_array = self::explode_value( $value ); - if( ! empty( $img_array['url'] ) ) { + if ( ! empty( $img_array['url'] ) ) { $img_name = basename( $img_array['url'] ); /** * Set the $uploaded_files value so that the .ginput_preview renders, and the file upload is hidden + * * @see GF_Field_Post_Image::get_field_input See the `` code * @see GFFormsModel::get_temp_filename See the `rgget( $input_name, self::$uploaded_files[ $form_id ] );` code */ - if( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { + if ( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $img_name; } } @@ -132,18 +133,18 @@ public function get_field_input( $form, $value = '', $entry = null, GF_Field_Pos /** * Insert a hidden field into the output that is used to store the image URL + * * @var string $current_file We need to have a reference of whether same file is being updated, or user wants to remove the image. * @see \GravityView_Edit_Entry_Render::maybe_update_post_fields * @hack */ if ( null !== $img_name ) { - $current_file = sprintf( "", $input_name, $field_id, esc_url_raw( $img_array['url'] ) ); - $gf_post_image_field_output = str_replace('', ''.$current_file, $gf_post_image_field_output ); + $current_file = sprintf( "", $input_name, $field_id, esc_url_raw( $img_array['url'] ) ); + $gf_post_image_field_output = str_replace( '', '' . $current_file, $gf_post_image_field_output ); } return $gf_post_image_field_output; } - } -new GravityView_Field_Post_Image; +new GravityView_Field_Post_Image(); diff --git a/includes/fields/class-gravityview-field-post-tags.php b/includes/fields/class-gravityview-field-post-tags.php index a0d7604d9b..b550929860 100644 --- a/includes/fields/class-gravityview-field-post-tags.php +++ b/includes/fields/class-gravityview-field-post-tags.php @@ -14,7 +14,7 @@ class GravityView_Field_Post_Tags extends GravityView_Field { var $is_searchable = true; - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); var $_gf_field_class_name = 'GF_Field_Post_Tags'; @@ -29,19 +29,18 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('dynamic_data', $field_options ); - $this->add_field_support('link_to_term', $field_options ); - $this->add_field_support('new_window', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); + $this->add_field_support( 'link_to_term', $field_options ); + $this->add_field_support( 'new_window', $field_options ); $field_options['new_window']['requires'] = 'link_to_term'; return $field_options; } - } -new GravityView_Field_Post_Tags; +new GravityView_Field_Post_Tags(); diff --git a/includes/fields/class-gravityview-field-post-title.php b/includes/fields/class-gravityview-field-post-title.php index 1166d19d92..10cf8c2246 100644 --- a/includes/fields/class-gravityview-field-post-title.php +++ b/includes/fields/class-gravityview-field-post-title.php @@ -30,17 +30,16 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $this->add_field_support('link_to_post', $field_options ); + $this->add_field_support( 'link_to_post', $field_options ); - $this->add_field_support('dynamic_data', $field_options ); + $this->add_field_support( 'dynamic_data', $field_options ); return $field_options; } - } -new GravityView_Field_Post_Title; +new GravityView_Field_Post_Title(); diff --git a/includes/fields/class-gravityview-field-product.php b/includes/fields/class-gravityview-field-product.php index 5f47fcda90..3960dcdec7 100644 --- a/includes/fields/class-gravityview-field-product.php +++ b/includes/fields/class-gravityview-field-product.php @@ -43,15 +43,15 @@ public function __construct() { * * @since 1.20 * - * @param array $form Gravity Forms array - * @param int $entry_id Gravity Forms entry ID + * @param array $form Gravity Forms array + * @param int $entry_id Gravity Forms entry ID * @param GravityView_Edit_Entry_Render $Edit_Entry_Render * * @return void */ function clear_product_info_cache( $form = array(), $entry_id = 0, $Edit_Entry_Render = null ) { - if( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { + if ( $this->should_hide_product_fields( $Edit_Entry_Render->entry ) ) { return; } @@ -62,7 +62,6 @@ function clear_product_info_cache( $form = array(), $entry_id = 0, $Edit_Entry_R gform_delete_meta( $entry_id, 'gform_product_info_1_' ); gform_delete_meta( $entry_id, 'gform_product_info_1_1' ); } - } /** @@ -106,7 +105,8 @@ public function should_hide_product_fields( $entry = array() ) { $has_transaction_data = GVCommon::entry_has_transaction_data( $entry ); /** - * @filter `gravityview/edit_entry/hide-product-fields` Hide product fields from being editable + * Hide product fields from being editable. + * * @since 1.9.1 * @since 1.20 Changed default from false to whether or not entry has transaction data * @see GVCommon::entry_has_transaction_data() @@ -118,4 +118,4 @@ public function should_hide_product_fields( $entry = array() ) { } } -new GravityView_Field_Product; +new GravityView_Field_Product(); diff --git a/includes/fields/class-gravityview-field-quantity.php b/includes/fields/class-gravityview-field-quantity.php index 25d88cd0cf..762402989b 100644 --- a/includes/fields/class-gravityview-field-quantity.php +++ b/includes/fields/class-gravityview-field-quantity.php @@ -33,4 +33,4 @@ public function __construct() { } } -new GravityView_Field_Quantity; +new GravityView_Field_Quantity(); diff --git a/includes/fields/class-gravityview-field-quiz.php b/includes/fields/class-gravityview-field-quiz.php index becff33b73..e15510c2a5 100644 --- a/includes/fields/class-gravityview-field-quiz.php +++ b/includes/fields/class-gravityview-field-quiz.php @@ -20,23 +20,22 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } $new_fields = array( 'quiz_show_explanation' => array( - 'type' => 'checkbox', - 'label' => __( 'Show Answer Explanation?', 'gk-gravityview' ), - 'desc' => __('If the field has an answer explanation, show it?', 'gk-gravityview'), - 'value' => false, + 'type' => 'checkbox', + 'label' => __( 'Show Answer Explanation?', 'gk-gravityview' ), + 'desc' => __( 'If the field has an answer explanation, show it?', 'gk-gravityview' ), + 'value' => false, 'merge_tags' => false, ), ); return $new_fields + $field_options; } - } -new GravityView_Field_Quiz; +new GravityView_Field_Quiz(); diff --git a/includes/fields/class-gravityview-field-radio.php b/includes/fields/class-gravityview-field-radio.php index a356b494b4..50fc5a8e7e 100644 --- a/includes/fields/class-gravityview-field-radio.php +++ b/includes/fields/class-gravityview-field-radio.php @@ -11,7 +11,7 @@ class GravityView_Field_Radio extends GravityView_Field { var $is_searchable = true; - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); var $_gf_field_class_name = 'GF_Field_Radio'; @@ -27,7 +27,7 @@ public function __construct() { /** * Add `choice_display` setting to the field * - * @param array $field_options + * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context @@ -42,7 +42,7 @@ public function field_options( $field_options, $template_id, $field_id, $context // Set the $_field_id var $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); - if( $this->is_choice_value_enabled() ) { + if ( $this->is_choice_value_enabled() ) { $field_options['choice_display'] = array( 'type' => 'radio', 'value' => 'value', @@ -60,4 +60,4 @@ public function field_options( $field_options, $template_id, $field_id, $context } } -new GravityView_Field_Radio; +new GravityView_Field_Radio(); diff --git a/includes/fields/class-gravityview-field-section.php b/includes/fields/class-gravityview-field-section.php index 700346d09d..48781438a7 100644 --- a/includes/fields/class-gravityview-field-section.php +++ b/includes/fields/class-gravityview-field-section.php @@ -43,14 +43,13 @@ function prevent_empty_field( $output = '' ) { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - unset ( $field_options['search_filter'], $field_options['show_as_link'] ); + unset( $field_options['search_filter'], $field_options['show_as_link'] ); // Set the default CSS class to gv-section, which applies a border and top/bottom margin $field_options['custom_class']['value'] = 'gv-section'; return $field_options; } - } -new GravityView_Field_Section; +new GravityView_Field_Section(); diff --git a/includes/fields/class-gravityview-field-select.php b/includes/fields/class-gravityview-field-select.php index afc944ab84..e2ad2332c6 100644 --- a/includes/fields/class-gravityview-field-select.php +++ b/includes/fields/class-gravityview-field-select.php @@ -31,7 +31,7 @@ public function __construct() { /** * Add `choice_display` setting to the field * - * @param array $field_options + * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context @@ -46,7 +46,7 @@ public function field_options( $field_options, $template_id, $field_id, $context // Set the $_field_id var $field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); - if( $this->is_choice_value_enabled() ) { + if ( $this->is_choice_value_enabled() ) { $field_options['choice_display'] = array( 'type' => 'radio', 'value' => 'value', @@ -62,7 +62,6 @@ public function field_options( $field_options, $template_id, $field_id, $context return $field_options; } - } -new GravityView_Field_Select; +new GravityView_Field_Select(); diff --git a/includes/fields/class-gravityview-field-sequence.php b/includes/fields/class-gravityview-field-sequence.php index 2d9102f3e3..7c60b401b6 100644 --- a/includes/fields/class-gravityview-field-sequence.php +++ b/includes/fields/class-gravityview-field-sequence.php @@ -7,6 +7,7 @@ /** * Add a sequence field. + * * @since 2.3.3 */ class GravityView_Field_Sequence extends GravityView_Field { @@ -38,10 +39,10 @@ class GravityView_Field_Sequence extends GravityView_Field { public function __construct() { - $this->label = esc_html__( 'Number Sequence', 'gk-gravityview' ); + $this->label = esc_html__( 'Number Sequence', 'gk-gravityview' ); $this->description = esc_html__( 'Display a sequential result number for each entry.', 'gk-gravityview' ); - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips') ); + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips' ) ); add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); @@ -53,9 +54,9 @@ public function __construct() { * * @since 2.10 Moved here from GravityView_Admin_Views::get_entry_default_fields * - * @param array $entry_default_fields Existing fields + * @param array $entry_default_fields Existing fields * @param string|array $form form_ID or form object - * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer' + * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer' * * @return array */ @@ -78,6 +79,7 @@ public function add_default_field( $entry_default_fields, $form = array(), $zone /** * Add tooltips + * * @param array $tooltips Existing tooltips * @return array Modified tooltips */ @@ -86,8 +88,8 @@ public function field_tooltips( $tooltips ) { $return = $tooltips; $return['reverse_sequence'] = array( - 'title' => __('Reverse the order of the result numbers', 'gk-gravityview'), - 'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gk-gravityview'), + 'title' => __( 'Reverse the order of the result numbers', 'gk-gravityview' ), + 'value' => __( 'Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gk-gravityview' ), ); return $return; @@ -95,21 +97,21 @@ public function field_tooltips( $tooltips ) { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - unset ( $field_options['search_filter'] ); + unset( $field_options['search_filter'] ); $new_fields = array( - 'start' => array( - 'type' => 'number', - 'label' => __( 'First Number in the Sequence', 'gk-gravityview' ), - 'desc' => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gk-gravityview'), - 'value' => '1', + 'start' => array( + 'type' => 'number', + 'label' => __( 'First Number in the Sequence', 'gk-gravityview' ), + 'desc' => __( 'For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gk-gravityview' ), + 'value' => '1', 'merge_tags' => false, ), 'reverse' => array( - 'type' => 'checkbox', - 'label' => __( 'Reverse the order of the number sequence (high to low)', 'gk-gravityview' ), + 'type' => 'checkbox', + 'label' => __( 'Reverse the order of the number sequence (high to low)', 'gk-gravityview' ), 'tooltip' => 'reverse_sequence', - 'value' => '', + 'value' => '', ), ); @@ -122,12 +124,12 @@ public function field_options( $field_options, $template_id, $field_id, $context * TODO: * - Find a better way to infer current View data (without using legacy code) * - * @param array $matches + * @param array $matches * @param string $text - * @param array $form - * @param array $entry - * @param bool $url_encode - * @param bool $esc_html + * @param array $form + * @param array $entry + * @param bool $url_encode + * @param bool $esc_html * * @return string */ @@ -156,11 +158,11 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array $return = $text; - $context = new \GV\Template_Context(); - $context->view = \GV\View::by_id( $view_data['view_id'] ); + $context = new \GV\Template_Context(); + $context->view = \GV\View::by_id( $view_data['view_id'] ); $context->entry = \GV\GF_Entry::from_entry( $entry ); - $gv_field = \GV\Internal_Field::by_id( 'sequence' ); + $gv_field = \GV\Internal_Field::by_id( 'sequence' ); $merge_tag_context = \GV\Utils::get( $legacy_field, 'UID' ); $merge_tag_context = $entry['id'] . "/{$merge_tag_context}"; @@ -170,7 +172,7 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array $property = $match[1]; $gv_field->reverse = false; - $gv_field->start = 1; + $gv_field->start = 1; $modifiers = explode( ',', trim( $property ) ); @@ -186,7 +188,7 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array // If there is a field with the ID of the start number, the merge tag won't work. // In that case, you can use "=" instead: `{sequence start=10}` - if( 1 === sizeof( $maybe_start ) ) { + if ( 1 === sizeof( $maybe_start ) ) { $maybe_start = explode( '=', $modifier ); } @@ -202,9 +204,9 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array $merge_tag_context_modifiers = $merge_tag_context . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; if ( ! isset( $merge_tag_sequences[ $merge_tag_context_modifiers ] ) ) { - $gv_field->UID = $legacy_field['UID'] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; + $gv_field->UID = $legacy_field['UID'] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start; $context->field = $gv_field; - $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context ); + $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context ); } else { $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ]; } @@ -225,12 +227,14 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array public function get_sequence( $context ) { static $startlines = array(); - $context_key = md5( json_encode( - array( - $context->view->ID, - \GV\Utils::get( $context, 'field/UID' ), + $context_key = md5( + json_encode( + array( + $context->view->ID, + \GV\Utils::get( $context, 'field/UID' ), + ) ) - ) ); + ); /** * Figure out the starting number. @@ -239,10 +243,13 @@ public function get_sequence( $context ) { $sql_query = array(); - add_filter( 'gform_gf_query_sql', $callback = function( $sql ) use ( &$sql_query ) { - $sql_query = $sql; - return $sql; - } ); + add_filter( + 'gform_gf_query_sql', + $callback = function ( $sql ) use ( &$sql_query ) { + $sql_query = $sql; + return $sql; + } + ); $total = $context->view->get_entries()->total(); remove_filter( 'gform_gf_query_sql', $callback ); @@ -263,7 +270,7 @@ public function get_sequence( $context ) { $pagesize = $context->view->settings->get( 'page_size', 25 ); if ( $context->field->reverse ) { - $startlines[ $context_key ] = $context->view->get_entries()->total() - ( $pagenum * $pagesize ); + $startlines[ $context_key ] = $context->view->get_entries()->total() - ( $pagenum * $pagesize ); $startlines[ $context_key ] += $context->field->start - 1; } else { $startlines[ $context_key ] = ( $pagenum * $pagesize ) + $context->field->start; @@ -274,4 +281,4 @@ public function get_sequence( $context ) { } } -new GravityView_Field_Sequence; +new GravityView_Field_Sequence(); diff --git a/includes/fields/class-gravityview-field-shipping.php b/includes/fields/class-gravityview-field-shipping.php index b539de89da..a4a3eb7eeb 100644 --- a/includes/fields/class-gravityview-field-shipping.php +++ b/includes/fields/class-gravityview-field-shipping.php @@ -33,4 +33,4 @@ public function __construct() { } } -new GravityView_Field_Shipping; +new GravityView_Field_Shipping(); diff --git a/includes/fields/class-gravityview-field-source-url.php b/includes/fields/class-gravityview-field-source-url.php index 96eccd0649..69d95c76bc 100644 --- a/includes/fields/class-gravityview-field-source-url.php +++ b/includes/fields/class-gravityview-field-source-url.php @@ -31,30 +31,29 @@ public function field_options( $field_options, $template_id, $field_id, $context // Don't link to entry; doesn't make sense. unset( $field_options['show_as_link'] ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } - $add_options = array(); - $add_options['link_to_source'] = array( - 'type' => 'checkbox', - 'label' => __( 'Link to URL:', 'gk-gravityview' ), - 'desc' => __('Display as a link to the Source URL', 'gk-gravityview'), - 'value' => false, + $add_options = array(); + $add_options['link_to_source'] = array( + 'type' => 'checkbox', + 'label' => __( 'Link to URL:', 'gk-gravityview' ), + 'desc' => __( 'Display as a link to the Source URL', 'gk-gravityview' ), + 'value' => false, 'merge_tags' => false, ); $add_options['source_link_text'] = array( - 'type' => 'text', - 'label' => __( 'Link Text:', 'gk-gravityview' ), - 'desc' => __('Customize the link text. If empty, the link text will be the URL.', 'gk-gravityview'), - 'value' => NULL, + 'type' => 'text', + 'label' => __( 'Link Text:', 'gk-gravityview' ), + 'desc' => __( 'Customize the link text. If empty, the link text will be the URL.', 'gk-gravityview' ), + 'value' => null, 'merge_tags' => true, - 'requires' => 'link_to_source', + 'requires' => 'link_to_source', ); return $add_options + $field_options; } - } -new GravityView_Field_Source_URL; +new GravityView_Field_Source_URL(); diff --git a/includes/fields/class-gravityview-field-survey.php b/includes/fields/class-gravityview-field-survey.php index 46b69d466f..1bb2866000 100644 --- a/includes/fields/class-gravityview-field-survey.php +++ b/includes/fields/class-gravityview-field-survey.php @@ -33,8 +33,8 @@ public function __construct() { * @since 2.11 * * @param GF_Field_Likert $field - * @param string|array $value - * @param int|string $input_id ID of the field or input (for example, 7.3 or 7) + * @param string|array $value + * @param int|string $input_id ID of the field or input (for example, 7.3 or 7) * * @return mixed|string */ @@ -51,7 +51,7 @@ public static function get_choice_score( $field, $value, $input_id = 0 ) { foreach ( $field->choices as $choice ) { if ( is_array( $value ) && RGFormsModel::choice_value_match( $field, $choice, $value[ $input_id ] ) ) { return $choice['score']; - } else if ( ! is_array( $value ) && RGFormsModel::choice_value_match( $field, $choice, $value ) ) { + } elseif ( ! is_array( $value ) && RGFormsModel::choice_value_match( $field, $choice, $value ) ) { return $choice['score']; } } @@ -67,11 +67,11 @@ public function field_options( $field_options, $template_id, $field_id, $context return $field_options; } - $field = \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ); - $input_id = gravityview_get_input_id_from_id( $field_id ); + $field = \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ); + $input_id = gravityview_get_input_id_from_id( $field_id ); $add_options = array(); - $glue = apply_filters( 'gravityview/template/field/survey/glue', '; ' ); + $glue = apply_filters( 'gravityview/template/field/survey/glue', '; ' ); $multiple_rows_suffix = sprintf( _x( ' (separated by %s)', 'text added to a label if multiple rows are enabled for the field)', 'gk-gravityview' ), esc_html( trim( $glue ) ) ); if ( 'likert' === $field->field->inputType ) { @@ -80,60 +80,60 @@ public function field_options( $field_options, $template_id, $field_id, $context $likert_display_options = array( 'default' => __( 'A table (default Gravity Forms formatting)', 'gk-gravityview' ), - 'text' => __( 'Text value of the selected choice', 'gk-gravityview' ) . ( $show_suffix ? '' : $multiple_rows_suffix ), + 'text' => __( 'Text value of the selected choice', 'gk-gravityview' ) . ( $show_suffix ? '' : $multiple_rows_suffix ), ); - if( $field->field->gsurveyLikertEnableScoring ) { + if ( $field->field->gsurveyLikertEnableScoring ) { $likert_display_options['score'] = __( 'Score value of the selected choice', 'gk-gravityview' ) . ( $show_suffix ? '' : $multiple_rows_suffix ); } // Maintain for back-compatibility $add_options['score'] = array( - 'type' => 'hidden', + 'type' => 'hidden', 'value' => '', 'group' => 'display', ); $add_options['choice_display'] = array( - 'type' => 'radio', - 'label' => __( 'What should be displayed:', 'gk-gravityview' ), - 'options' => $likert_display_options, - 'desc' => '', - 'group' => 'display', - 'class' => 'block', - 'value' => 'default', + 'type' => 'radio', + 'label' => __( 'What should be displayed:', 'gk-gravityview' ), + 'options' => $likert_display_options, + 'desc' => '', + 'group' => 'display', + 'class' => 'block', + 'value' => 'default', 'merge_tags' => false, ); } - if( 'checkbox' === $field->field->inputType && $input_id ) { + if ( 'checkbox' === $field->field->inputType && $input_id ) { $field_options['choice_display'] = array( - 'type' => 'radio', - 'class' => 'vertical', - 'label' => __( 'What should be displayed:', 'gk-gravityview' ), - 'value' => 'tick', - 'desc' => '', - 'choices' => array( + 'type' => 'radio', + 'class' => 'vertical', + 'label' => __( 'What should be displayed:', 'gk-gravityview' ), + 'value' => 'tick', + 'desc' => '', + 'choices' => array( 'tick' => __( 'A check mark, if the input is checked', 'gk-gravityview' ), 'text' => __( 'Text value of the selected choice', 'gk-gravityview' ), ), - 'group' => 'display', + 'group' => 'display', 'priority' => 100, ); } if ( 'rating' === $field->field->inputType ) { $field_options['choice_display'] = array( - 'type' => 'radio', - 'class' => 'vertical', - 'label' => __( 'What should be displayed:', 'gk-gravityview' ), - 'value' => 'default', - 'desc' => '', - 'choices' => array( + 'type' => 'radio', + 'class' => 'vertical', + 'label' => __( 'What should be displayed:', 'gk-gravityview' ), + 'value' => 'default', + 'desc' => '', + 'choices' => array( 'default' => __( 'Text value of the selected choice', 'gk-gravityview' ), - 'stars' => __( 'Stars (default Gravity Forms formatting)', 'gk-gravityview' ), + 'stars' => __( 'Stars (default Gravity Forms formatting)', 'gk-gravityview' ), ), - 'group' => 'display', + 'group' => 'display', 'priority' => 100, ); } @@ -206,4 +206,4 @@ static function output_frontend_css() { } } -new GravityView_Field_Survey; +new GravityView_Field_Survey(); diff --git a/includes/fields/class-gravityview-field-text.php b/includes/fields/class-gravityview-field-text.php index a45aad7246..0917d58b86 100644 --- a/includes/fields/class-gravityview-field-text.php +++ b/includes/fields/class-gravityview-field-text.php @@ -25,4 +25,4 @@ public function __construct() { } } -new GravityView_Field_Text; +new GravityView_Field_Text(); diff --git a/includes/fields/class-gravityview-field-textarea.php b/includes/fields/class-gravityview-field-textarea.php index 78de63d476..f8dad63c8b 100644 --- a/includes/fields/class-gravityview-field-textarea.php +++ b/includes/fields/class-gravityview-field-textarea.php @@ -29,39 +29,38 @@ public function __construct() { public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } unset( $field_options['show_as_link'] ); $field_options['trim_words'] = array( - 'type' => 'number', + 'type' => 'number', 'merge_tags' => false, - 'value' => null, - 'label' => __( 'Maximum words shown', 'gk-gravityview' ), - 'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gk-gravityview' ), + 'value' => null, + 'label' => __( 'Maximum words shown', 'gk-gravityview' ), + 'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gk-gravityview' ), ); - $field_options['make_clickable'] = array( - 'type' => 'checkbox', - 'merge_tags' => false, - 'value' => 0, - 'label' => __( 'Convert text URLs to HTML links', 'gk-gravityview' ), - 'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gk-gravityview' ), - ); + $field_options['make_clickable'] = array( + 'type' => 'checkbox', + 'merge_tags' => false, + 'value' => 0, + 'label' => __( 'Convert text URLs to HTML links', 'gk-gravityview' ), + 'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gk-gravityview' ), + ); $field_options['allow_html'] = array( - 'type' => 'checkbox', + 'type' => 'checkbox', 'merge_tags' => false, - 'value' => 1, - 'label' => __( 'Display as HTML', 'gk-gravityview' ), - 'tooltip' => esc_html__( 'If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gk-gravityview' ), + 'value' => 1, + 'label' => __( 'Display as HTML', 'gk-gravityview' ), + 'tooltip' => esc_html__( 'If enabled, safe HTML will be displayed and unsafe or unrecognized HTML tags will be stripped. If disabled, the field value will be displayed as text.', 'gk-gravityview' ), ); return $field_options; } - } -new GravityView_Field_Textarea; +new GravityView_Field_Textarea(); diff --git a/includes/fields/class-gravityview-field-time.php b/includes/fields/class-gravityview-field-time.php index 8fea030b01..997d671fe8 100644 --- a/includes/fields/class-gravityview-field-time.php +++ b/includes/fields/class-gravityview-field-time.php @@ -64,7 +64,7 @@ public function __construct() { add_filter( 'gravityview/sorting/time', array( $this, 'modify_sort_id' ), 10, 2 ); - add_filter('gravityview_search_criteria', array( $this, '_maybe_filter_gravity_forms_query' ), 10, 4 ); + add_filter( 'gravityview_search_criteria', array( $this, '_maybe_filter_gravity_forms_query' ), 10, 4 ); } /** @@ -74,7 +74,7 @@ public function __construct() { * * @since 1.14 * @param string $sort_field_id Existing sort field ID (like "5") - * @param int $form_id Gravity Forms Form ID being sorted + * @param int $form_id Gravity Forms Form ID being sorted * * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A` */ @@ -98,14 +98,14 @@ public function modify_sort_id( $sort_field_id, $form_id ) { * * @param array $criteria Search criteria used by GravityView * @param array $form_ids Forms to search - * @param int $view_id ID of the view being used to search + * @param int $view_id ID of the view being used to search * * @return array $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int */ public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_id ) { // If the search is not being sorted, return early - if( empty( $criteria['sorting']['key'] ) ) { + if ( empty( $criteria['sorting']['key'] ) ) { return $criteria; } @@ -113,9 +113,10 @@ public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_i /** * If the sort key does not match the key set in modify_sort_id(), do not modify the Gravity Forms query SQL + * * @see modify_sort_id() */ - if( empty( $pieces[1] ) ) { + if ( empty( $pieces[1] ) ) { return $criteria; } @@ -128,12 +129,13 @@ public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_i /** * Make sure sorting is numeric (# of seconds). IMPORTANT. + * * @see GVCommon::is_field_numeric() is_numeric should also be set here */ $criteria['sorting']['is_numeric'] = true; // Modify the Gravity Forms WP Query - add_filter('query', array( $this, '_modify_query_sort_by_time_hack' ) ); + add_filter( 'query', array( $this, '_modify_query_sort_by_time_hack' ) ); return $criteria; } @@ -152,11 +154,12 @@ function _modify_query_sort_by_time_hack( $query ) { /** * If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(), * then we want to modify the query. + * * @see GFFormsModel::sort_by_field_query() */ - if( strpos( $query, self::GF_SORTING_SQL ) > 0 ) { + if ( strpos( $query, self::GF_SORTING_SQL ) > 0 ) { - if( $this->_time_format === '24' ) { + if ( '24' === $this->_time_format ) { $sql_str_to_date = "STR_TO_DATE( `value`, '%H:%i' )"; } else { $sql_str_to_date = "STR_TO_DATE( `value`, '%h:%i %p' )"; @@ -202,18 +205,18 @@ public function field_options( $field_options, $template_id, $field_id, $context // Set variables parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } /** * Set default date format based on field ID and Form ID */ - add_filter('gravityview_date_format', array( $this, '_filter_date_display_date_format' ) ); + add_filter( 'gravityview_date_format', array( $this, '_filter_date_display_date_format' ) ); - $this->add_field_support('date_display', $field_options ); + $this->add_field_support( 'date_display', $field_options ); - remove_filter('gravityview_date_format', array( $this, '_filter_date_display_date_format' ) ); + remove_filter( 'gravityview_date_format', array( $this, '_filter_date_display_date_format' ) ); return $field_options; } @@ -239,15 +242,15 @@ private function _get_time_format() { * @since 1.14 * * @param string $field_id ID for Gravity Forms time field - * @param int $form_id ID for Gravity Forms form + * @param int $form_id ID for Gravity Forms form * @return string Either "12" or "24". "12" is default. */ - static public function _get_time_format_for_field( $field_id, $form_id = 0 ) { + public static function _get_time_format_for_field( $field_id, $form_id = 0 ) { // GF defaults to 12, so should we. $time_format = '12'; - if( $form_id ) { + if ( $form_id ) { $form = GVCommon::get_form( $form_id ); if ( $form ) { @@ -272,7 +275,7 @@ static public function _get_time_format_for_field( $field_id, $form_id = 0 ) { public function _filter_date_display_date_format() { $time_format = $this->_get_time_format(); - $field_id = $this->_field_id; + $field_id = $this->_field_id; return self::date_format( $time_format, $field_id ); } @@ -283,21 +286,21 @@ public function _filter_date_display_date_format() { * @since 1.14 * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} - * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} + * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} * * @return string PHP date format for the time */ - static public function date_format( $time_format = '12', $field_id = 0 ) { + public static function date_format( $time_format = '12', $field_id = 0 ) { $field_input_id = gravityview_get_input_id_from_id( $field_id ); $default = 'h:i A'; // This doesn't take into account 24-hour - switch( $field_input_id ) { + switch ( $field_input_id ) { // Hours case 1: - return ( $time_format === '12' ) ? 'h' : 'H'; + return ( '12' === $time_format ) ? 'h' : 'H'; break; // Minutes case 2: @@ -309,13 +312,12 @@ static public function date_format( $time_format = '12', $field_id = 0 ) { break; // Full time field case 0: - return ( $time_format === '12' ) ? $default : 'H:i'; + return ( '12' === $time_format ) ? $default : 'H:i'; break; } return $default; } - } -new GravityView_Field_Time; +new GravityView_Field_Time(); diff --git a/includes/fields/class-gravityview-field-total.php b/includes/fields/class-gravityview-field-total.php index 75592dac3a..b1d5f44a09 100644 --- a/includes/fields/class-gravityview-field-total.php +++ b/includes/fields/class-gravityview-field-total.php @@ -47,14 +47,14 @@ public function __construct() { * * @todo Support Total fields in Edit Entry configuration * - * @param array $blocklist Array of field types not able to be added to Edit Entry + * @param array $blocklist Array of field types not able to be added to Edit Entry * @param string|null $context Context * * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total. */ - public function add_to_blocklist( $blocklist = array(), $context = NULL ){ + public function add_to_blocklist( $blocklist = array(), $context = null ) { - if( empty( $context ) || $context !== 'edit' ) { + if ( empty( $context ) || 'edit' !== $context ) { return $blocklist; } @@ -68,8 +68,8 @@ public function add_to_blocklist( $blocklist = array(), $context = NULL ){ * * @since 1.20 * - * @param array $form Gravity Forms form array - * @param int $entry_id Gravity Forms Entry ID + * @param array $form Gravity Forms form array + * @param int $entry_id Gravity Forms Entry ID * @param GravityView_Edit_Entry_Render $Edit_Entry_Render * * @return void @@ -80,19 +80,19 @@ function edit_entry_recalculate_totals( $form = array(), $entry_id = 0, $Edit_En $total_fields = GFCommon::get_fields_by_type( $original_form, 'total' ); - //saving total field as the last field of the form. + // saving total field as the last field of the form. if ( ! empty( $total_fields ) ) { $entry = GFAPI::get_entry( $entry_id ); /** @type GF_Field_Total $total_field */ foreach ( $total_fields as $total_field ) { - $entry["{$total_field->id}"] = GFCommon::get_order_total( $original_form, $entry ); + $entry[ "{$total_field->id}" ] = GFCommon::get_order_total( $original_form, $entry ); } $return_entry = GFAPI::update_entry( $entry ); - if( is_wp_error( $return_entry ) ) { + if ( is_wp_error( $return_entry ) ) { gravityview()->log->error( 'Updating the entry total fields failed', array( 'data' => $return_entry ) ); } else { gravityview()->log->debug( 'Updating the entry total fields succeeded' ); @@ -101,4 +101,4 @@ function edit_entry_recalculate_totals( $form = array(), $entry_id = 0, $Edit_En } } -new GravityView_Field_Total; +new GravityView_Field_Total(); diff --git a/includes/fields/class-gravityview-field-transaction-id.php b/includes/fields/class-gravityview-field-transaction-id.php index 39485dbae5..b47ee42fe8 100644 --- a/includes/fields/class-gravityview-field-transaction-id.php +++ b/includes/fields/class-gravityview-field-transaction-id.php @@ -14,7 +14,7 @@ class GravityView_Field_Transaction_ID extends GravityView_Field { var $is_numeric = true; - var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); + var $search_operators = array( 'is', 'isnot', 'starts_with', 'ends_with' ); var $group = 'pricing'; @@ -31,4 +31,4 @@ public function __construct() { } } -new GravityView_Field_Transaction_ID; +new GravityView_Field_Transaction_ID(); diff --git a/includes/fields/class-gravityview-field-transaction-type.php b/includes/fields/class-gravityview-field-transaction-type.php index e9f01777d6..8f5eaa574d 100644 --- a/includes/fields/class-gravityview-field-transaction-type.php +++ b/includes/fields/class-gravityview-field-transaction-type.php @@ -36,7 +36,7 @@ class GravityView_Field_Transaction_Type extends GravityView_Field { * GravityView_Field_Transaction_Type constructor. */ public function __construct() { - $this->label = esc_html__( 'Transaction Type', 'gk-gravityview' ); + $this->label = esc_html__( 'Transaction Type', 'gk-gravityview' ); $this->description = esc_html__( 'The type of the order: one-time payment or subscription', 'gk-gravityview' ); add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', array( $this, 'get_content' ), 10, 4 ); @@ -54,15 +54,16 @@ public function __construct() { * * @param string $output HTML value output * @param array $entry The GF entry array - * @param array $field_settings Settings for the particular GV field - * @param array $field Current field being displayed + * @param array $field_settings Settings for the particular GV field + * @param array $field Current field being displayed * * @return String values for this field based on the numeric values used by Gravity Forms */ public function get_content( $output, $entry = array(), $field_settings = array(), $field = array() ) { /** Overridden by a template. */ - if( ! empty( $field['field_path'] ) ) { return $output; } + if ( ! empty( $field['field_path'] ) ) { + return $output; } return $this->get_string_from_value( $output ); } @@ -94,11 +95,11 @@ private function get_string_from_value( $value ) { switch ( intval( $value ) ) { case self::ONE_TIME_PAYMENT: default: - $return = __('One-Time Payment', 'gk-gravityview'); + $return = __( 'One-Time Payment', 'gk-gravityview' ); break; case self::SUBSCRIPTION: - $return = __('Subscription', 'gk-gravityview'); + $return = __( 'Subscription', 'gk-gravityview' ); break; } @@ -106,4 +107,4 @@ private function get_string_from_value( $value ) { } } -new GravityView_Field_Transaction_Type; +new GravityView_Field_Transaction_Type(); diff --git a/includes/fields/class-gravityview-field-unsubscribe.php b/includes/fields/class-gravityview-field-unsubscribe.php index 0e50fc51f9..c90da302de 100644 --- a/includes/fields/class-gravityview-field-unsubscribe.php +++ b/includes/fields/class-gravityview-field-unsubscribe.php @@ -19,8 +19,8 @@ class GravityView_Field_Unsubscribe extends GravityView_Field { var $icon = 'dashicons-cart'; public function __construct() { - $this->label = esc_html__( 'Unsubscribe', 'gk-gravityview' ); - $this->description = esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gk-gravityview' ); + $this->label = esc_html__( 'Unsubscribe', 'gk-gravityview' ); + $this->description = esc_attr__( 'Unsubscribe from a Payment-based entry.', 'gk-gravityview' ); $this->add_hooks(); @@ -48,12 +48,12 @@ public function add_hooks() { * Remove the logged in, new window and show as link options. * Add the allow unsubscribe for all admins option. * - * @param array $field_options The options. - * @param string $template_id The template ID. + * @param array $field_options The options. + * @param string $template_id The template ID. * @param int|string|float $field_id The field ID. - * @param string $context The configuration context (edit, single, etc.) - * @param string $input_type The input type. - * @param int $form_id The form ID. + * @param string $context The configuration context (edit, single, etc.) + * @param string $input_type The input type. + * @param int $form_id The form ID. * * @return array The field options. */ @@ -83,7 +83,7 @@ public function field_options( $field_options, $template_id, $field_id, $context * * Hide the field for non-logged in users for sure. * - * @param bool $visible Consider visible or not. + * @param bool $visible Consider visible or not. * @param \GV\Field $field The field. * * @return bool Visible or not. @@ -101,9 +101,9 @@ public function maybe_not_visible( $visible, $field ) { * * Called from `gravityview_entry_default_fields` * - * @param array $entry_default_fields An array of available for configuration - * @param array|int $form Form ID or array - * @param string $context The configuration context (edit, single, etc.) + * @param array $entry_default_fields An array of available for configuration + * @param array|int $form Form ID or array + * @param string $context The configuration context (edit, single, etc.) * * @return array The array of available default fields. */ @@ -127,7 +127,7 @@ public function filter_gravityview_entry_default_field( $entry_default_fields, $ foreach ( $registered as $addon ) { if ( method_exists( $addon, 'cancel_subscription' ) && is_callable( array( $addon, 'get_instance' ) ) ) { - $addon = $addon::get_instance(); + $addon = $addon::get_instance(); $subscription_addons[ $addon->get_slug() ] = $addon; } } @@ -139,8 +139,8 @@ public function filter_gravityview_entry_default_field( $entry_default_fields, $ foreach ( $feeds as $feed ) { if ( isset( $subscription_addons[ $feed['addon_slug'] ] ) && 'subscription' === \GV\Utils::get( $feed, 'meta/transactionType' ) ) { - if ( ! isset( $entry_default_fields["{$this->name}"] ) && 'edit' !== $context ) { - $entry_default_fields["{$this->name}"] = array( + if ( ! isset( $entry_default_fields[ "{$this->name}" ] ) && 'edit' !== $context ) { + $entry_default_fields[ "{$this->name}" ] = array( 'label' => $this->label, 'desc' => $this->description, 'type' => $this->name, @@ -159,9 +159,9 @@ public function filter_gravityview_entry_default_field( $entry_default_fields, $ * * Called from `gravityview_field_entry_value_unsubscribe` * - * @param string $output The output. - * @param array $entry The entry. - * @param array $field_settings The field settings. + * @param string $output The output. + * @param array $entry The entry. + * @param array $field_settings The field settings. * @param \GV\Field $field The field. * * @return string The content. @@ -242,7 +242,7 @@ private function maybe_unsubscribe( $entry ) { foreach ( $registered as $addon ) { if ( method_exists( $addon, 'cancel_subscription' ) ) { - $addon = $addon::get_instance(); + $addon = $addon::get_instance(); $subscription_addons[ $addon->get_slug() ] = $addon; } } @@ -278,4 +278,4 @@ private function maybe_unsubscribe( $entry ) { } } -new GravityView_Field_Unsubscribe; +new GravityView_Field_Unsubscribe(); diff --git a/includes/fields/class-gravityview-field-username.php b/includes/fields/class-gravityview-field-username.php index c77bf0d138..8e67b2d05d 100644 --- a/includes/fields/class-gravityview-field-username.php +++ b/includes/fields/class-gravityview-field-username.php @@ -30,4 +30,4 @@ public function __construct() { } } -new GravityView_Field_Username; +new GravityView_Field_Username(); diff --git a/includes/fields/class-gravityview-field-website.php b/includes/fields/class-gravityview-field-website.php index ec73fc313d..e4f4ca0e20 100644 --- a/includes/fields/class-gravityview-field-website.php +++ b/includes/fields/class-gravityview-field-website.php @@ -33,7 +33,7 @@ public function field_options( $field_options, $template_id, $field_id, $context // It makes no sense to use this as the link. unset( $field_options['show_as_link'] ); - if( 'edit' === $context ) { + if ( 'edit' === $context ) { return $field_options; } @@ -41,20 +41,20 @@ public function field_options( $field_options, $template_id, $field_id, $context * @since 1.8 */ $field_options['anchor_text'] = array( - 'type' => 'text', - 'label' => __( 'Link Text:', 'gk-gravityview' ), - 'desc' => __( 'Define custom link text. Leave blank to display the URL', 'gk-gravityview' ), - 'value' => '', + 'type' => 'text', + 'label' => __( 'Link Text:', 'gk-gravityview' ), + 'desc' => __( 'Define custom link text. Leave blank to display the URL', 'gk-gravityview' ), + 'value' => '', 'merge_tags' => 'force', - 'priority' => 1000, + 'priority' => 1000, ); $field_options['truncatelink'] = array( - 'type' => 'checkbox', - 'value' => true, - 'label' => __( 'Shorten Link Display', 'gk-gravityview' ), - 'tooltip' => __( 'Only show the domain for a URL instead of the whole link.', 'gk-gravityview' ), - 'desc' => __( 'Don’t show the full URL, only show the domain.', 'gk-gravityview' ), + 'type' => 'checkbox', + 'value' => true, + 'label' => __( 'Shorten Link Display', 'gk-gravityview' ), + 'tooltip' => __( 'Only show the domain for a URL instead of the whole link.', 'gk-gravityview' ), + 'desc' => __( 'Don’t show the full URL, only show the domain.', 'gk-gravityview' ), 'priority' => 1500, ); @@ -62,14 +62,14 @@ public function field_options( $field_options, $template_id, $field_id, $context /** * Set default to opening in new links for back-compatibility with Version 1.5.1 + * * @link https://github.com/gravityview/GravityView/commit/e12e76e2d032754227728d41e65103042d4f75ec */ - $field_options['new_window']['value'] = true; + $field_options['new_window']['value'] = true; $field_options['new_window']['priority'] = 2000; return $field_options; } - } -new GravityView_Field_Website; +new GravityView_Field_Website(); diff --git a/includes/fields/class-gravityview-field-workflow_current_status_timestamp.php b/includes/fields/class-gravityview-field-workflow_current_status_timestamp.php index 9303e05579..f0d99badbb 100644 --- a/includes/fields/class-gravityview-field-workflow_current_status_timestamp.php +++ b/includes/fields/class-gravityview-field-workflow_current_status_timestamp.php @@ -35,8 +35,8 @@ function add_hooks() { * * @param string $output HTML value output * @param array $entry The GF entry array - * @param array $field_settings Settings for the particular GV field, - * @param array $field Current field being displayed + * @param array $field_settings Settings for the particular GV field, + * @param array $field Current field being displayed * * @since 1.17 * @@ -53,7 +53,7 @@ function modify_entry_value_workflow_current_status_timestamp( $output, $entry, } public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { - if ( $context == 'edit' ) { + if ( 'edit' == $context ) { return $field_options; } @@ -63,4 +63,4 @@ public function field_options( $field_options, $template_id, $field_id, $context } } -new GravityView_Field_Workflow_Current_Status_Timestamp; +new GravityView_Field_Workflow_Current_Status_Timestamp(); diff --git a/includes/fields/class-gravityview-field-workflow_final_status.php b/includes/fields/class-gravityview-field-workflow_final_status.php index 198fbb68b6..aecf251782 100644 --- a/includes/fields/class-gravityview-field-workflow_final_status.php +++ b/includes/fields/class-gravityview-field-workflow_final_status.php @@ -15,7 +15,7 @@ class GravityView_Field_Workflow_Final_Status extends GravityView_Field { public $icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43IDExLjIiPjxwYXRoIGQ9Ik0xNC43IDUuOWwtNy00Yy0xLjItLjctMi41LS44LTMuNy0uMy0xLjcuNy0yLjYgMS45LTIuNyAzLjYtLjEgMS41LjQgMi43IDEuNCAzLjcgMS4xIDEuMSAyLjYgMS40IDQuMy45LjIgMCAuNS0uMiAxLjEtLjQuMi0uMS4zLS4xLjQtLjEuMyAwIC41LjEuNi40LjEuMyAwIC41LS4zLjctMS4yLjctMi40LjktMy44LjgtMS4zLS4yLTIuNS0uNy0zLjQtMS42Qy41IDguNS0uMSA3LjEgMCA1LjVjLjEtMi40IDEuMi00IDMuMy01QzQuNS0uMSA1LjgtLjIgNy4yLjJjLjIuMS42LjIgMS4yLjZsNyAzLjkuNC0uNi44IDIuMS0yLjIuMy4zLS42em0tNy44LS41bDcgNGMxLjIuNyAyLjUuOCAzLjcuMyAxLjctLjcgMi42LTEuOSAyLjgtMy42LjEtMS40LS40LTIuNi0xLjUtMy43cy0yLjUtMS40LTQuMy0xYy0uNC4xLS44LjMtMS4xLjRsLS40LjFjLS4zIDAtLjUtLjEtLjYtLjQtLjEtLjMgMC0uNS4zLS43IDEuMS0uNyAyLjQtLjkgMy44LS44IDEuNC4yIDIuNS43IDMuNCAxLjcgMS4yIDEuMiAxLjcgMi41IDEuNiA0LjEtLjEgMi4zLTEuMiA0LTMuMyA1LTEuNC42LTIuNy42LTMuOS4yLS4zLS4xLS43LS4zLTEuMS0uNWwtNy0zLjktLjQuNUw1LjEgNWwyLjItLjMtLjQuN3oiLz48L3N2Zz4='; public function __construct() { - $this->label = esc_html__( 'Workflow Status', 'gk-gravityview' ); + $this->label = esc_html__( 'Workflow Status', 'gk-gravityview' ); $this->default_search_label = $this->label; $this->add_hooks(); parent::__construct(); @@ -34,8 +34,8 @@ function add_hooks() { * * @param string $output HTML value output * @param array $entry The GF entry array - * @param array $field_settings Settings for the particular GV field - * @param array $field Current field being displayed + * @param array $field_settings Settings for the particular GV field + * @param array $field Current field being displayed * * @since 1.17 * @@ -43,7 +43,7 @@ function add_hooks() { */ function modify_entry_value_workflow_final_status( $output, $entry, $field_settings, $field ) { - if( ! empty( $output ) ) { + if ( ! empty( $output ) ) { $output = gravity_flow()->translate_status_label( $output ); } @@ -56,9 +56,9 @@ function modify_entry_value_workflow_final_status( $output, $entry, $field_setti * * @since 1.17.3 * - * @param array $search_fields + * @param array $search_fields * @param GravityView_Widget_Search|null $widget - * @param array $widget_args + * @param array $widget_args * * @return array */ @@ -72,7 +72,6 @@ function modify_search_filters( $search_fields = array(), GravityView_Widget_Sea return $search_fields; } - } -new GravityView_Field_Workflow_Final_Status; +new GravityView_Field_Workflow_Final_Status(); diff --git a/includes/fields/class-gravityview-field-workflow_step.php b/includes/fields/class-gravityview-field-workflow_step.php index 6e04f71071..457137c2ec 100644 --- a/includes/fields/class-gravityview-field-workflow_step.php +++ b/includes/fields/class-gravityview-field-workflow_step.php @@ -15,7 +15,7 @@ class GravityView_Field_Workflow_Step extends GravityView_Field { public $icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMS43IDExLjIiPjxwYXRoIGQ9Ik0xNC43IDUuOWwtNy00Yy0xLjItLjctMi41LS44LTMuNy0uMy0xLjcuNy0yLjYgMS45LTIuNyAzLjYtLjEgMS41LjQgMi43IDEuNCAzLjcgMS4xIDEuMSAyLjYgMS40IDQuMy45LjIgMCAuNS0uMiAxLjEtLjQuMi0uMS4zLS4xLjQtLjEuMyAwIC41LjEuNi40LjEuMyAwIC41LS4zLjctMS4yLjctMi40LjktMy44LjgtMS4zLS4yLTIuNS0uNy0zLjQtMS42Qy41IDguNS0uMSA3LjEgMCA1LjVjLjEtMi40IDEuMi00IDMuMy01QzQuNS0uMSA1LjgtLjIgNy4yLjJjLjIuMS42LjIgMS4yLjZsNyAzLjkuNC0uNi44IDIuMS0yLjIuMy4zLS42em0tNy44LS41bDcgNGMxLjIuNyAyLjUuOCAzLjcuMyAxLjctLjcgMi42LTEuOSAyLjgtMy42LjEtMS40LS40LTIuNi0xLjUtMy43cy0yLjUtMS40LTQuMy0xYy0uNC4xLS44LjMtMS4xLjRsLS40LjFjLS4zIDAtLjUtLjEtLjYtLjQtLjEtLjMgMC0uNS4zLS43IDEuMS0uNyAyLjQtLjkgMy44LS44IDEuNC4yIDIuNS43IDMuNCAxLjcgMS4yIDEuMiAxLjcgMi41IDEuNiA0LjEtLjEgMi4zLTEuMiA0LTMuMyA1LTEuNC42LTIuNy42LTMuOS4yLS4zLS4xLS43LS4zLTEuMS0uNWwtNy0zLjktLjQuNUw1LjEgNWwyLjItLjMtLjQuN3oiLz48L3N2Zz4='; public function __construct() { - $this->label = esc_html__( 'Workflow Step', 'gk-gravityview' ); + $this->label = esc_html__( 'Workflow Step', 'gk-gravityview' ); $this->default_search_label = $this->label; $this->add_hooks(); @@ -39,8 +39,8 @@ function add_hooks() { * * @param string $output HTML value output * @param array $entry The GF entry array - * @param array $field_settings Settings for the particular GV field - * @param array $field Current field being displayed + * @param array $field_settings Settings for the particular GV field + * @param array $field Current field being displayed * * @since 1.17 * @@ -51,7 +51,7 @@ function modify_entry_value_workflow_step( $output, $entry, $field_settings, $fi // If not set, the entry hasn't started a workflow $has_workflow_step = isset( $entry['workflow_step'] ); - if( $has_workflow_step ) { + if ( $has_workflow_step ) { $GFlow = new Gravity_Flow_API( $entry['form_id'] ); @@ -90,9 +90,9 @@ private function get_step_id_from_key( $key ) { /** * @since 1.17.3 * - * @param string $label Existing label text, sanitized. + * @param string $label Existing label text, sanitized. * @param null|GF_Field $gf_field If search field is connected to a Gravity Forms field, the field object. - * @param array $field Array with the following keys: `field` ID of the meta key or field ID to be searched, `input` the type of search input to be shown, `label` the existing label. Same as $label parameter. + * @param array $field Array with the following keys: `field` ID of the meta key or field ID to be searched, `input` the type of search input to be shown, `label` the existing label. Same as $label parameter. * * @return string If showing a search field for a Step, show the step label. */ @@ -130,7 +130,7 @@ function get_workflow_step( $workflow_step_id = 0 ) { $workflow_step = $GFlow->get_step( $workflow_step_id ); - if( ! $GFlow || ! $workflow_step ) { + if ( ! $GFlow || ! $workflow_step ) { return false; } @@ -142,9 +142,9 @@ function get_workflow_step( $workflow_step_id = 0 ) { * * @since 1.17.3 * - * @param array $search_fields + * @param array $search_fields * @param GravityView_Widget_Search $widget - * @param array $widget_args + * @param array $widget_args * * @return array */ @@ -162,8 +162,8 @@ function modify_frontend_search_fields( $search_fields = array(), GravityView_Wi foreach ( $workflow_steps as $step ) { $choices[] = array( - 'text' => $step->get_name(), - 'value' => $step->get_id(), + 'text' => $step->get_name(), + 'value' => $step->get_id(), ); } @@ -171,7 +171,7 @@ function modify_frontend_search_fields( $search_fields = array(), GravityView_Wi } // Workflow Step Statuses - else if ( $workflow_step_id = $this->get_step_id_from_key( $search_field['key'] ) ) { + elseif ( $workflow_step_id = $this->get_step_id_from_key( $search_field['key'] ) ) { $status_key = sprintf( 'workflow_step_status_%d', $workflow_step_id ); @@ -181,7 +181,6 @@ function modify_frontend_search_fields( $search_fields = array(), GravityView_Wi return $search_fields; } - } -new GravityView_Field_Workflow_Step; +new GravityView_Field_Workflow_Step(); diff --git a/includes/fields/class-gravityview-field.php b/includes/fields/class-gravityview-field.php index 6a971e7ec3..69ec5be957 100644 --- a/includes/fields/class-gravityview-field.php +++ b/includes/fields/class-gravityview-field.php @@ -13,6 +13,7 @@ abstract class GravityView_Field { /** * The name of the GravityView field type * Example: `created_by`, `text`, `fileupload`, `address`, `entry_link` + * * @var string */ public $name; @@ -148,31 +149,33 @@ public function __construct() { /** * Modify the field options based on the name of the field type + * * @see GravityView_Render_Settings::get_default_field_options */ add_filter( sprintf( 'gravityview_template_%s_options', $this->name ), array( &$this, 'field_options' ), 10, 6 ); add_filter( 'gravityview/sortable/field_blocklist', array( $this, '_filter_sortable_fields' ), 1 ); - if( $this->entry_meta_key ) { + if ( $this->entry_meta_key ) { add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) ); add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 ); } - if( $this->_custom_merge_tag ) { + if ( $this->_custom_merge_tag ) { add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); } - if( 'meta' === $this->group || '' !== $this->default_search_label ) { + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); } /** * Auto-assign label from Gravity Forms label, if exists + * * @since 1.20 */ - if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { + if ( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { $this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() ); } @@ -225,7 +228,7 @@ public function get_icon() { $gf_field = GF_Fields::get( $this->name ); // If the field exists and is a GF_Field, return the icon. - if( $gf_field && $gf_field instanceof GF_Field ) { + if ( $gf_field && $gf_field instanceof GF_Field ) { return $gf_field->get_form_editor_field_icon(); } @@ -245,10 +248,10 @@ public function add_sortable_field( $fields ) { $added_field = array( 'label' => $this->label, - 'type' => $this->name + 'type' => $this->name, ); - $fields["{$this->entry_meta_key}"] = $added_field; + $fields[ "{$this->entry_meta_key}" ] = $added_field; return $fields; } @@ -261,14 +264,14 @@ public function add_sortable_field( $fields ) { * @since 1.17.3 * * @param string $label Existing label text, sanitized. - * @param array $gf_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` - * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys + * @param array $gf_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` + * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys * * @return string */ function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { - if( $this->name === $field['field'] && '' === $label ) { + if ( $this->name === $field['field'] && '' === $label ) { $label = esc_html( $this->default_search_label ); } @@ -283,13 +286,13 @@ function set_default_search_label( $label = '', $gf_field = null, $field = array * @since 1.16 * * @param string $text Text to replace - * @param array $form Gravity Forms form array - * @param array $entry Entry array - * @param bool $url_encode Whether to URL-encode output + * @param array $form Gravity Forms form array + * @param array $entry Entry array + * @param bool $url_encode Whether to URL-encode output * * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. */ - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { // Is there is field merge tag? Strip whitespace off the ned, too. preg_match_all( '/{' . preg_quote( $this->_custom_merge_tag ) . ':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER ); @@ -311,30 +314,30 @@ public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry * * @see GFCommon::replace_variables() * - * @param array $matches Array of Merge Tag matches found in text by preg_match_all - * @param string $text Text to replace + * @param array $matches Array of Merge Tag matches found in text by preg_match_all + * @param string $text Text to replace * @param array|bool $form Gravity Forms form array. When called inside {@see GFCommon::replace_variables()} (now deprecated), `false` * @param array|bool $entry Entry array. When called inside {@see GFCommon::replace_variables()} (now deprecated), `false` - * @param bool $url_encode Whether to URL-encode output - * @param bool $esc_html Whether to apply `esc_html()` to output + * @param bool $url_encode Whether to URL-encode output + * @param bool $esc_html Whether to apply `esc_html()` to output * * @return mixed */ public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { - foreach( $matches as $match ) { + foreach ( $matches as $match ) { $full_tag = $match[0]; // Strip the Merge Tags - $tag = str_replace( array( '{', '}'), '', $full_tag ); + $tag = str_replace( array( '{', '}' ), '', $full_tag ); // Replace the value from the entry, if exists - if( isset( $entry[ $tag ] ) ) { + if ( isset( $entry[ $tag ] ) ) { $value = $entry[ $tag ]; - if( is_callable( array( $this, 'get_content') ) ) { + if ( is_callable( array( $this, 'get_content' ) ) ) { $value = $this->get_content( $value ); } @@ -354,10 +357,10 @@ public function replace_merge_tag( $matches = array(), $text = '', $form = array * * @since 1.8.4 * - * @param array $custom_merge_tags - * @param int $form_id GF Form ID + * @param array $custom_merge_tags + * @param int $form_id GF Form ID * @param GF_Field[] $fields Array of fields in the form - * @param string $element_id The ID of the input that Merge Tags are being used on + * @param string $element_id The ID of the input that Merge Tags are being used on * * @return array Modified merge tags */ @@ -377,7 +380,7 @@ public function _filter_gform_custom_merge_tags( $custom_merge_tags = array(), $ * * @since 1.16 * - * @param array $form GF Form array + * @param array $form GF Form array * @param GF_Field[] $fields Array of fields in the form * * @return array Merge tag array with `label` and `tag` keys based on class `label` and `_custom_merge_tag` variables @@ -388,7 +391,7 @@ protected function custom_merge_tags( $form = array(), $fields = array() ) { $merge_tags = array( array( 'label' => $this->label, - 'tag' => '{' . $this->_custom_merge_tag . '}', + 'tag' => '{' . $this->_custom_merge_tag . '}', ), ); @@ -407,7 +410,7 @@ protected function custom_merge_tags( $form = array(), $fields = array() ) { */ public function _filter_sortable_fields( $not_sortable ) { - if( ! $this->is_sortable ) { + if ( ! $this->is_sortable ) { $not_sortable[] = $this->name; } @@ -425,7 +428,7 @@ public function _filter_sortable_fields( $not_sortable ) { */ function add_entry_meta( $entry_meta ) { - if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) { + if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) { $added_meta = array( 'label' => $this->label, @@ -437,10 +440,16 @@ function add_entry_meta( $entry_meta ) { $added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback; } - $entry_meta["{$this->entry_meta_key}"] = $added_meta; + $entry_meta[ "{$this->entry_meta_key}" ] = $added_meta; } else { - gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta["{$this->entry_meta_key}"] ) ); + gravityview()->log->error( + 'Entry meta already set: {meta_key}', + array( + 'meta_key' => $this->entry_meta_key, + 'data' => $entry_meta[ "{$this->entry_meta_key}" ], + ) + ); } return $entry_meta; @@ -449,53 +458,55 @@ function add_entry_meta( $entry_meta ) { private function field_support_options() { $options = array( 'link_to_post' => array( - 'type' => 'checkbox', - 'label' => __( 'Link to the post', 'gk-gravityview' ), - 'desc' => __( 'Link to the post created by the entry.', 'gk-gravityview' ), - 'value' => false, + 'type' => 'checkbox', + 'label' => __( 'Link to the post', 'gk-gravityview' ), + 'desc' => __( 'Link to the post created by the entry.', 'gk-gravityview' ), + 'value' => false, 'priority' => 1200, - 'group' => 'display', + 'group' => 'display', ), 'link_to_term' => array( - 'type' => 'checkbox', - 'label' => __( 'Link to the category or tag', 'gk-gravityview' ), - 'desc' => __( 'Link to the current category or tag. "Link to single entry" must be unchecked.', 'gk-gravityview' ), - 'value' => false, + 'type' => 'checkbox', + 'label' => __( 'Link to the category or tag', 'gk-gravityview' ), + 'desc' => __( 'Link to the current category or tag. "Link to single entry" must be unchecked.', 'gk-gravityview' ), + 'value' => false, 'priority' => 1210, - 'group' => 'display', + 'group' => 'display', ), 'dynamic_data' => array( - 'type' => 'checkbox', - 'label' => __( 'Use the live post data', 'gk-gravityview' ), - 'desc' => __( 'Instead of using the entry data, instead use the current post data.', 'gk-gravityview' ), - 'value' => true, + 'type' => 'checkbox', + 'label' => __( 'Use the live post data', 'gk-gravityview' ), + 'desc' => __( 'Instead of using the entry data, instead use the current post data.', 'gk-gravityview' ), + 'value' => true, 'priority' => 1100, - 'group' => 'display', + 'group' => 'display', ), 'date_display' => array( - 'type' => 'text', - 'label' => __( 'Override Date Format', 'gk-gravityview' ), - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gk-gravityview'), '', '' ), + 'type' => 'text', + 'label' => __( 'Override Date Format', 'gk-gravityview' ), + 'desc' => sprintf( __( 'Define how the date is displayed (using %1$sthe PHP date format%2$s)', 'gk-gravityview' ), '', '' ), /** - * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) + * Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time). + * * @param null|string $date_format Date Format (default: null) */ - 'value' => apply_filters( 'gravityview_date_format', null ), - 'class' => 'code widefat', + 'value' => apply_filters( 'gravityview_date_format', null ), + 'class' => 'code widefat', 'priority' => 1500, - 'group' => 'display', + 'group' => 'display', ), - 'new_window' => array( - 'type' => 'checkbox', - 'label' => __( 'Open link in a new tab or window?', 'gk-gravityview' ), - 'value' => false, - 'group' => 'display', + 'new_window' => array( + 'type' => 'checkbox', + 'label' => __( 'Open link in a new tab or window?', 'gk-gravityview' ), + 'value' => false, + 'group' => 'display', 'priority' => 1300, ), ); /** - * @filter `gravityview_field_support_options` Modify the settings that a field supports + * Modify the settings that a field supports. + * * @param array $options Options multidimensional array with each key being the input name, with each array setting having `type`, `label`, `desc` and `value` (default values) keys */ return apply_filters( 'gravityview_field_support_options', $options ); @@ -503,7 +514,7 @@ private function field_support_options() { /** * @param string $key - * @param array $field_options + * @param array $field_options * * @return array */ @@ -511,7 +522,7 @@ function add_field_support( $key, &$field_options ) { $options = $this->field_support_options(); - if( isset( $options[ $key ] ) ) { + if ( isset( $options[ $key ] ) ) { $field_options[ $key ] = $options[ $key ]; } @@ -525,33 +536,33 @@ function add_field_support( $key, &$field_options ) { * *
 	 * $field_options['name_display'] = array(
-	 * 	'type' => 'select',
-	 * 	'label' => __( 'User Format', 'gravityview' ),
-	 * 	'desc' => __( 'How should the User information be displayed?', 'gravityview'),
-	 * 	'choices' => array(
-	 * 		array(
-	 *		 	'value' => 'display_name',
-	 *		  	'label' => __('Display Name (Example: "Ellen Ripley")', 'gravityview'),
-	 *		),
-	 *  	array(
-	 *			'value' => 'user_login',
-	 *			'label' => __('Username (Example: "nostromo")', 'gravityview')
-	 *		),
-	 * 	 'value' => 'display_name'
+	 *  'type' => 'select',
+	 *  'label' => __( 'User Format', 'gravityview' ),
+	 *  'desc' => __( 'How should the User information be displayed?', 'gravityview'),
+	 *  'choices' => array(
+	 *      array(
+	 *          'value' => 'display_name',
+	 *          'label' => __('Display Name (Example: "Ellen Ripley")', 'gravityview'),
+	 *      ),
+	 *      array(
+	 *          'value' => 'user_login',
+	 *          'label' => __('Username (Example: "nostromo")', 'gravityview')
+	 *      ),
+	 *   'value' => 'display_name'
 	 * );
 	 * 
* - * @param array $field_options [description] - * @param string $template_id [description] - * @param string $field_id [description] - * @param string $context [description] - * @param string $input_type [description] + * @param array $field_options [description] + * @param string $template_id [description] + * @param string $field_id [description] + * @param string $context [description] + * @param string $input_type [description] * @return array [description] */ public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { $this->_field_options = $field_options; - $this->_field_id = $field_id; + $this->_field_id = $field_id; return $field_options; } @@ -575,11 +586,11 @@ protected function is_choice_value_enabled() { $connected_form = \GV\Utils::_POST( 'form_id' ); // Otherwise, get the Form ID from the Post page - if( empty( $connected_form ) ) { + if ( empty( $connected_form ) ) { $connected_form = gravityview_get_form_id( get_the_ID() ); } - if( empty( $connected_form ) ) { + if ( empty( $connected_form ) ) { gravityview()->log->error( 'Form not found for form ID "{form_id}"', array( 'form_id' => $connected_form ) ); return false; } @@ -587,7 +598,13 @@ protected function is_choice_value_enabled() { $form = GVCommon::get_form( $connected_form ); if ( ! $form ) { - gravityview()->log->error( 'Form not found for field ID of "{field_id}", when checking for a form with ID of "{form_id}"', array( 'field_id' => $this->_field_id, 'form_id' => $connected_form ) ); + gravityview()->log->error( + 'Form not found for field ID of "{field_id}", when checking for a form with ID of "{form_id}"', + array( + 'field_id' => $this->_field_id, + 'form_id' => $connected_form, + ) + ); return false; } @@ -595,5 +612,4 @@ protected function is_choice_value_enabled() { return ! empty( $field->enableChoiceValue ); } - } diff --git a/includes/fields/class-gravityview-fields.php b/includes/fields/class-gravityview-fields.php index 4285133c47..fbfab77456 100644 --- a/includes/fields/class-gravityview-fields.php +++ b/includes/fields/class-gravityview-fields.php @@ -62,7 +62,7 @@ public static function create( $properties ) { * @return bool True: yes, it exists; False: nope */ public static function exists( $field_name ) { - return isset( self::$_fields["{$field_name}"] ); + return isset( self::$_fields[ "{$field_name}" ] ); } /** @@ -96,8 +96,8 @@ public static function get_associated_field( $gf_field ) { $field_type = is_a( $gf_field, 'GF_Field' ) ? get_class( $gf_field ) : $gf_field; - foreach( self::$_fields as $field ) { - if( $field_type === $field->_gf_field_class_name ) { + foreach ( self::$_fields as $field ) { + if ( $field_type === $field->_gf_field_class_name ) { return $field; } } @@ -111,7 +111,7 @@ public static function get_associated_field( $gf_field ) { * @since 1.16 Added $group parameter * * @param string|array $groups Optional. If defined, fetch all fields in a group or array of groups. - * @param string $context Optional. If defined, limit returned fields to those that support the defined context. + * @param string $context Optional. If defined, limit returned fields to those that support the defined context. * * @return GravityView_Field[] */ @@ -119,12 +119,12 @@ public static function get_all( $groups = '', $context = '' ) { $return_fields = self::$_fields; - if( '' !== $groups ) { + if ( '' !== $groups ) { $groups = (array) $groups; foreach ( $return_fields as $key => $field ) { - if( ! in_array( $field->group, $groups, true ) ) { + if ( ! in_array( $field->group, $groups, true ) ) { unset( $return_fields[ $key ] ); } } @@ -149,12 +149,11 @@ public static function get_all( $groups = '', $context = '' ) { continue; } - if( ! in_array( $context, $field->contexts, true ) ) { + if ( ! in_array( $context, $field->contexts, true ) ) { unset( $return_fields[ $key ] ); } } return $return_fields; } - } diff --git a/includes/fields/index.php b/includes/fields/index.php index e71af0ef21..8142269b13 100644 --- a/includes/fields/index.php +++ b/includes/fields/index.php @@ -1 +1 @@ -log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => esc_attr( $css_file ) ) ); } else { // Default: use GravityView CSS file // If no path is provided, assume default plugin templates CSS folder - if( '' === $dir_path ) { + if ( '' === $dir_path ) { $dir_path = GRAVITYVIEW_DIR . 'templates/css/'; } // plugins_url() expects a path to a file, not directory. We append a file to be stripped. - $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); + $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); } return $path; @@ -62,7 +63,7 @@ function gravityview_css_url( $css_file = '', $dir_path = '' ) { * @return bool true: $mixed is *not* an empty string; false: $mixed *is* an empty string */ function gravityview_is_not_empty_string( $mixed = '' ) { - return ( $mixed !== '' ); + return ( '' !== $mixed ); } /** @@ -82,9 +83,9 @@ function gravityview_get_permalink_query_args( $id = 0 ) { $parsed_permalink = parse_url( get_permalink( $id ) ); - $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; + $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; - if( empty( $permalink_args ) ) { + if ( empty( $permalink_args ) ) { return array(); } @@ -100,8 +101,8 @@ function gravityview_get_permalink_query_args( $id = 0 ) { * @see selected() WordPress core function * * @param string $value One of the values to compare - * @param mixed $current (true) The other value to compare if not just true - * @param bool $echo Whether to echo or just return the string + * @param mixed $current (true) The other value to compare if not just true + * @param bool $echo Whether to echo or just return the string * @param string $type The type of checked|selected|disabled we are doing * * @return string html attribute or empty string @@ -109,15 +110,15 @@ function gravityview_get_permalink_query_args( $id = 0 ) { function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { $output = ''; - if( is_array( $current ) ) { - if( in_array( $value, $current ) ) { + if ( is_array( $current ) ) { + if ( in_array( $value, $current ) ) { $output = __checked_selected_helper( true, true, false, $type ); } } else { $output = __checked_selected_helper( $value, $current, false, $type ); } - if( $echo ) { + if ( $echo ) { echo $output; } @@ -125,7 +126,7 @@ function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { } -if( ! function_exists( 'gravityview_sanitize_html_class' ) ) { +if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) { /** * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that. @@ -171,7 +172,7 @@ function gravityview_sanitize_html_class( $classes ) { */ function gravityview_strip_whitespace( $string ) { $string = normalize_whitespace( $string ); - return preg_replace('/[\r\n\t ]+/', ' ', $string ); + return preg_replace( '/[\r\n\t ]+/', ' ', $string ); } /** @@ -181,16 +182,16 @@ function gravityview_strip_whitespace( $string ) { * @since 1.15 Added $object param * * @param string $file_path Full path to a file - * @param mixed $object Pass pseudo-global to the included file + * @param mixed $object Pass pseudo-global to the included file * @return string Included file contents */ -function gravityview_ob_include( $file_path, $object = NULL ) { - if( ! file_exists( $file_path ) ) { +function gravityview_ob_include( $file_path, $object = null ) { + if ( ! file_exists( $file_path ) ) { gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); return ''; } ob_start(); - include( $file_path ); + include $file_path; return ob_get_clean(); } @@ -200,7 +201,7 @@ function gravityview_ob_include( $file_path, $object = NULL ) { * @since 1.12 * @since 2.1 Added $class parameter * - * @param int $height Height of the cutie in pixels + * @param int $height Height of the cutie in pixels * @param null|string $css_class If defined, use the passed CSS class (can be empty string). Otherwise, use default alignleft (or alignright, based on RTL). * * @return string HTML image tag with floaty's cute mug on it @@ -209,15 +210,15 @@ function gravityview_get_floaty( $height = 87, $css_class = null ) { $width = $height * 0.7586206897; - if( function_exists('is_rtl') && is_rtl() ) { - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; + if ( function_exists( 'is_rtl' ) && is_rtl() ) { + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; $css_class = is_string( $css_class ) ? $css_class : 'alignright'; } else { - $style = 'margin:10px 10px 10px 0; height='. $height .'px; width: '. $width .'px;'; + $style = 'margin:10px 10px 10px 0; height=' . $height . 'px; width: ' . $width . 'px;'; $css_class = is_string( $css_class ) ? $css_class : 'alignleft'; } - return 'The GravityView Astronaut Says:'; + return 'The GravityView Astronaut Says:'; } /** @@ -233,27 +234,28 @@ function gravityview_get_floaty( $height = 87, $css_class = null ) { * @since 1.13 * * @param int|float|string|double $number A number to format - * @param int|string $decimals Optional. Precision of the number of decimal places. Default '' (use existing number of decimals) - * @param boolean $separator Separate with dots or commas, etc. Default: true. + * @param int|string $decimals Optional. Precision of the number of decimal places. Default '' (use existing number of decimals) + * @param boolean $separator Separate with dots or commas, etc. Default: true. * * @return string Converted number in string format. */ function gravityview_number_format( $number, $decimals = '', $separator = true ) { global $wp_locale; - if( '' === $decimals ) { + if ( '' === $decimals ) { $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; /** * Calculate the position of the decimal point in the number + * * @see http://stackoverflow.com/a/2430144/480856 */ $decimals = strlen( substr( strrchr( $number, $decimal_point ), 1 ) ); } if ( $separator ) { - $number = number_format_i18n( $number, (int)$decimals ); + $number = number_format_i18n( $number, (int) $decimals ); } else { $number = sprintf( "%.{$decimals}f", $number ); } @@ -272,11 +274,10 @@ function gravityview_number_format( $number, $decimals = '', $separator = true ) */ function gravityview_format_link( $value = null ) { - $parts = parse_url( $value ); // No domain? Strange...show the original text. - if( empty( $parts['host'] ) ) { + if ( empty( $parts['host'] ) ) { return $value; } @@ -284,44 +285,46 @@ function gravityview_format_link( $value = null ) { $return = ''; /** - * @filter `gravityview_anchor_text_striphttp` Strip scheme from the displayed URL? + * Strip scheme from the displayed URL? + * * @since 1.5.1 * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n * If true: `http://example.com => example.com` */ - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { - if( isset( $parts['scheme'] ) ) { + if ( isset( $parts['scheme'] ) ) { $return .= $parts['scheme']; } - } // The domain, which may contain a subdomain $domain = $parts['host']; /** - * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? + * Strip www from the domain? + * * @since 1.5.1 * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n * If true: `www.example.com => example.com` */ - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); - if( $strip_www ) { - $domain = str_replace('www.', '', $domain ); + if ( $strip_www ) { + $domain = str_replace( 'www.', '', $domain ); } /** - * @filter `gravityview_anchor_text_nosubdomain` Strip subdomains from the domain? + * Strip subdomains from the domain? + * * @since 1.5.1 * @param boolean $enable Whether to strip subdomains. Return false to show subdomains. (default: true)\n * If true: `http://demo.example.com => example.com` \n * If false: `http://demo.example.com => demo.example.com` */ - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); - if( $strip_subdomains ) { + if ( $strip_subdomains ) { $domain = _gravityview_strip_subdomain( $parts['host'] ); @@ -331,35 +334,36 @@ function gravityview_format_link( $value = null ) { $return .= $domain; /** - * @filter `gravityview_anchor_text_rootonly` Display link path going only to the base directory, not a sub-directory or file? + * Display link path going only to the base directory, not a sub-directory or file? + * * @since 1.5.1 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n * If true: `http://example.com/sub/directory/page.html => example.com` \n * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` */ - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); - if( empty( $root_only ) ) { + if ( empty( $root_only ) ) { - if( isset( $parts['path'] ) ) { + if ( isset( $parts['path'] ) ) { $return .= $parts['path']; } } /** - * @filter `gravityview_anchor_text_noquerystring` Strip the query string from the end of the URL? + * Strip the query string from the end of the URL? + * * @since 1.5.1 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n * If true: `http://example.com/?query=example => example.com` */ - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); - if( empty( $strip_query_string ) ) { + if ( empty( $strip_query_string ) ) { - if( isset( $parts['query'] ) ) { - $return .= '?'.$parts['query']; + if ( isset( $parts['query'] ) ) { + $return .= '?' . $parts['query']; } - } return $return; @@ -369,12 +373,13 @@ function gravityview_format_link( $value = null ) { * Do a _very_ basic match for second-level TLD domains, like `.co.uk` * * Ideally, we'd use https://github.com/jeremykendall/php-domain-parser to check for this, but it's too much work for such a basic functionality. Maybe if it's needed more in the future. So instead, we use [Basic matching regex](http://stackoverflow.com/a/12372310). + * * @param string $domain Domain to check if it's a TLD or subdomain * @return string Extracted domain if it has a subdomain */ function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { - if( preg_match("/(?P[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { + if ( preg_match( '/(?P[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i', $string_maybe_has_subdomain, $matches ) ) { return $matches['domain']; } else { return $string_maybe_has_subdomain; @@ -386,9 +391,9 @@ function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { * * @since 2.0 * - * @param mixed $value Check whether this is not empty - * @param bool $zero_is_empty Should the number zero be treated as an empty value? Default: `false` - * @param bool $allow_string_booleans Whether to check if 'yes', 'true' => `true` and 'no', 'false' => `false`. Default: `false` + * @param mixed $value Check whether this is not empty + * @param bool $zero_is_empty Should the number zero be treated as an empty value? Default: `false` + * @param bool $allow_string_booleans Whether to check if 'yes', 'true' => `true` and 'no', 'false' => `false`. Default: `false` * * @return bool */ @@ -404,7 +409,7 @@ function gv_not_empty( $value, $zero_is_empty = false, $allow_string_booleans = * Checks whether `false`, `null`, empty string, empty array, object with no vars defined * * @since 1.15.1 - * @param mixed $value Check whether this is empty + * @param mixed $value Check whether this is empty * @param boolean $zero_is_empty Should the number zero be treated as an empty value? * @param boolean $allow_string_booleans Whether to check if 'yes', 'true' => `true` and 'no', 'false' => `false` * @return boolean True: empty; false: not empty @@ -430,7 +435,7 @@ function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true ! isset( $value ) // If it's not set, it's empty! || false === $value || null === $value - || '' === $value // Empty string + || '' === $value // Empty string || array() === $value // Empty array || ( is_object( $value ) && ! get_object_vars( $value ) ) // Empty object ) { @@ -444,7 +449,7 @@ function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true if ( in_array( $value, array( 'yes', 'true' ), true ) ) { $value = true; - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { + } elseif ( in_array( $value, array( 'no', 'false' ), true ) ) { $value = false; } } @@ -465,15 +470,15 @@ function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true * @see json_decode() for more information about the function parameters * * @param string $value The string that may be decoded - * @param bool $assoc [optional] When `true`, returned objects will be converted into associative arrays - * @param int $depth [optional] User specified recursion depth. - * @param int $options [optional] Bitmask of JSON decode options. Used only on sites running PHP 5.4+ + * @param bool $assoc [optional] When `true`, returned objects will be converted into associative arrays + * @param int $depth [optional] User specified recursion depth. + * @param int $options [optional] Bitmask of JSON decode options. Used only on sites running PHP 5.4+ * * @return array|mixed|object|string If $value is JSON, returns the response from `json_decode()`. Otherwise, returns original value. */ function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { - if( ! is_string( $value ) ) { + if ( ! is_string( $value ) ) { return $value; } @@ -484,12 +489,12 @@ function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = } // There was a JSON error (PHP 5.3+) - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { return $value; } // It wasn't JSON (PHP < 5.3 fallback) - if( is_null( $decoded ) ) { + if ( is_null( $decoded ) ) { return $value; } @@ -591,7 +596,8 @@ function gravityview_get_terms_choices( $args = array() ) { $args = wp_parse_args( $args, $defaults ); /** - * @filter `gravityview_get_terms_choices_args` Modify the arguments passed to `get_terms()` + * Modify the arguments passed to `get_terms()`. + * * @see get_terms() * @since 1.15.3 */ @@ -605,7 +611,7 @@ function gravityview_get_terms_choices( $args = array() ) { foreach ( $terms as $term_id => $term_name ) { $choices[] = array( 'text' => $term_name, - 'value' => $term_id + 'value' => $term_id, ); } } @@ -627,7 +633,7 @@ function gravityview_get_terms_choices( $args = array() ) { function _gravityview_process_posted_fields() { $fields = array(); - if( !empty( $_POST['gv_fields'] ) ) { + if ( ! empty( $_POST['gv_fields'] ) ) { if ( ! is_array( $_POST['gv_fields'] ) ) { // We are not using parse_str() due to max_input_vars limitation with large View configurations @@ -639,7 +645,6 @@ function _gravityview_process_posted_fields() { } else { gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); } - } else { $fields = $_POST['gv_fields']; } @@ -672,7 +677,7 @@ function gravityview_maybe_convert_date_string_to_timestamp( $value = '' ) { return false; } - if( false !== strpos( strtolower( $value ), "relative:") ) { + if ( false !== strpos( strtolower( $value ), 'relative:' ) ) { $value = str_replace( 'relative:', '', $value ); $timestamp = strtotime( $value ); diff --git a/includes/import-functions.php b/includes/import-functions.php index 5d6394e847..2cffb7bd06 100644 --- a/includes/import-functions.php +++ b/includes/import-functions.php @@ -41,7 +41,7 @@ * @since 2.12.1 * * @param array $postmeta Copy of $post['postmeta'] to be filtered. - * @param int $post_id + * @param int $post_id * @param array $post * * @return array Modified array, if GravityView @@ -103,9 +103,9 @@ function gravityview_import_helper_fix_line_breaks( $postmeta = array(), $post_i * * @see gravityview_import_helper_fix_line_breaks() * - * @param int $post_id + * @param int $post_id * @param string $key - * @param mixed $value + * @param mixed $value */ function gravityview_import_helper_restore_line_breaks( $post_id, $key, $value ) { diff --git a/includes/index.php b/includes/index.php index e71af0ef21..8142269b13 100644 --- a/includes/index.php +++ b/includes/index.php @@ -1 +1 @@ -email_regex = '[\w\d+_.-]+@(?:[\w\d_-]+\.)+[\w]{2,6}'; - // First matching group specifies banned first characters - // Second matching group excludes email address preceded by =" i.e. src="img@2x.gif" - $this->ptext_email = '/(?<=[^\/\w\d\+_.:-])(?email_regex . ')/i'; - $this->mailto_email = '#(]*?href=[\042\047]mailto:' . $this->email_regex . '[^<>]*?>.*?)#i'; - $this->link_text = "#/>(.*?)enk_dec_reverse = <<email_regex = '[\w\d+_.-]+@(?:[\w\d_-]+\.)+[\w]{2,6}'; + // First matching group specifies banned first characters + // Second matching group excludes email address preceded by =" i.e. src="img@2x.gif" + $this->ptext_email = '/(?<=[^\/\w\d\+_.:-])(?email_regex . ')/i'; + $this->mailto_email = '#(]*?href=[\042\047]mailto:' . $this->email_regex . '[^<>]*?>.*?)#i'; + $this->link_text = '#/>(.*?)enk_dec_reverse = <<enk_dec_num = <<enk_dec_num = <<enk_dec_swap = <<enk_dec_swap = <<enkodings = array( - array('enkEncReverse', $this->enk_dec_reverse), - array('enkEncNum', $this->enk_dec_num), - array('enkEncSwap', $this->enk_dec_swap) - ); - } - - /** - * Enkode plaintext emails - * - * Encodes all plaintext e-mails into a JavaScript-obscured mailto; the - * text of the mailto: is the e-mail address itself. - */ - public function enkodePlaintextEmails($text) { - return preg_replace_callback($this->ptext_email, array($this, 'enkEmailToLink'), $text); - } - - /** - * Enkode mailto: links - * - * Encodes all mailto: links into JavaScript obscured text. - */ - public function enkodeMailtos($text) { - return preg_replace_callback($this->mailto_email, array($this, 'enkPlaintextLink'), $text); - } - - /** - * Enkode all emails - * - * Encodes all mailto: and plaintext links into JavaScript obscured text. - */ - public function enkodeAllEmails($text) { - $js = $this->enkodeMailtos($text); - $js = $this->enkodePlaintextEmails($js); - - return $js; - } - - /** - * Extract link text - */ - private function enkExtractLinktext($text) { - if (preg_match($this->link_text, $text, $tmatches)) { - return $tmatches[1]; - } - return null; - } - - /** - * Enkode a single mailto: link - */ - private function enkEmailToLink($matches) { - return $this->enkodeMailto($matches[1], $matches[1]); - } - - /** - * Enkode a single plaintext link - */ - private function enkPlaintextLink($matches) { - $text = $this->enkExtractLinktext($matches[1]); - return $this->enkode($matches[1], $text); - } - - /** - * Enkode a mailto: link - */ - public function enkodeMailto($email, $text, $subject = "", $title = "") { - $content = ''; - - return $this->enkode($content); - } - - /** - * Enkode - * - * Encodes a string to be view-time written by obfuscated Javascript. - * The max passes parameter is a tight bound on the number of encodings - * perormed. The max length paramater is a loose bound on the length of - * the generated Javascript. Setting it to 0 will use a single pass of - * enkEncNum. - * - * The function works by selecting encodings at random from the array - * enkodings, applying them to the given string, and then producing - * Javascript to decode. The Javascript works by recursive evaluation, - * which should be nasty enough to stop anything but the most determined - * spambots. - * - * The text parameter, if set, overrides the user-settable option - * enk_msg. This is the message overwritten by the JavaScript; if a - * browser doesn't support JavaScript, this message will be shown to the - * user. - */ - public function enkode($content, $text = NULL) { - $max_passes = $this->max_passes; - $max_length = $this->max_length; - - // Our base case -- we'll eventually evaluate this code. - // Note that we're using innerHTML() since document.write() fails on - // pages loaded using AJAX. - $kode = "document.getElementById('ENKODER_ID').outerHTML=\"" . - addcslashes($content,"\\\'\"&\n\r<>") . - "\";"; - - $max_length = max($max_length, strlen($kode) + $this->min_length + 1); - - $result = ""; - - // Build up as many encodings as we can. - for ($passes = 0; $passes < $max_passes && strlen($kode) < $max_length; $passes++) { - // Pick an encoding at random. - $idx = rand(0, count($this->enkodings) - 1); - $enc = $this->enkodings[$idx][0]; - $dec = $this->enkodings[$idx][1]; - $kode = $this->enkodePass($kode, $enc, $dec); - } - - // Mandatory numerical encoding, prevents catching @ signs and - // interpreting neighboring characters as e-mail addresses. - $kode = $this->enkodePass($kode, 'enkEncNum', $this->enk_dec_num); - - return $this->enkBuildJS($kode, $text); - } - - /** - * Encode a single pass - * - * $enc is a function pointer and $dec is the Javascript. - */ - private function enkodePass($kode, $enc, $dec) { - // First encode. - $kode = addslashes($this->$enc($kode)); - - // Then generate encoded code with decoding afterwards. - $kode = "kode=\"$kode\";$dec;"; - - return $kode; - } - - /** - * Build JavaScript - * - * Generates the Javascript recursive evaluator, which is 269 characters - * of boilerplate code. - * - * Unfortunately,
+ +
$view, - ) ); + $context = \GV\Template_Context::from_template( + array( + 'view' => $view, + ) + ); if ( ! in_array( (int) $page_size, wp_list_pluck( self::get_page_sizes( $context ), 'value' ), true ) ) { gravityview()->log->warning( 'The passed page size is not allowed: {page_size}. Not modifying result.', array( 'page_size' => $page_size ) ); @@ -177,4 +189,4 @@ public function override_view_page_size( &$view ) { } } -new Page_Size; +new Page_Size(); diff --git a/includes/widgets/class-gravityview-widget-pagination-info.php b/includes/widgets/class-gravityview-widget-pagination-info.php index 4481413f64..4d937528c2 100644 --- a/includes/widgets/class-gravityview-widget-pagination-info.php +++ b/includes/widgets/class-gravityview-widget-pagination-info.php @@ -12,13 +12,14 @@ class GravityView_Widget_Pagination_Info extends \GV\Widget { /** * Does this get displayed on a single entry? + * * @var boolean */ protected $show_on_single = false; function __construct() { - $this->widget_description = __('Summary of the number of visible entries out of the total results.', 'gk-gravityview' ); + $this->widget_description = __( 'Summary of the number of visible entries out of the total results.', 'gk-gravityview' ); $default_values = array( 'header' => 1, @@ -27,17 +28,17 @@ function __construct() { $settings = array(); - parent::__construct( __( 'Show Pagination Info', 'gk-gravityview' ) , 'page_info', $default_values, $settings ); + parent::__construct( __( 'Show Pagination Info', 'gk-gravityview' ), 'page_info', $default_values, $settings ); } - public function render_frontend( $widget_args, $content = '', $context = '') { + public function render_frontend( $widget_args, $content = '', $context = '' ) { $gravityview_view = GravityView_View::getInstance(); if ( ! $this->pre_render_frontend( $context ) ) { return; } - if( !empty( $widget_args['title'] ) ) { + if ( ! empty( $widget_args['title'] ) ) { echo $widget_args['title']; } @@ -47,29 +48,28 @@ public function render_frontend( $widget_args, $content = '', $context = '') { $output = ''; - if( ! empty( $pagination_counts ) ) { + if ( ! empty( $pagination_counts ) ) { $first = $pagination_counts['first']; - $last = $pagination_counts['last']; + $last = $pagination_counts['last']; $total = $pagination_counts['total']; - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; + $class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; $class = gravityview_sanitize_html_class( $class ); - $output = '

'. sprintf(__( 'Displaying %1$s - %2$s of %3$s', 'gk-gravityview' ), number_format_i18n( $first ), number_format_i18n( $last ), number_format_i18n( $total ) ) . '

'; + $output = '

' . sprintf( __( 'Displaying %1$s - %2$s of %3$s', 'gk-gravityview' ), number_format_i18n( $first ), number_format_i18n( $last ), number_format_i18n( $total ) ) . '

'; } /** - * @filter `gravityview_pagination_output` Modify the pagination widget output + * Modify the pagination widget output. + * * @param string $output HTML output * @param int $first First entry # * @param int $last Last entry # * @param int $total Total entries # */ echo apply_filters( 'gravityview_pagination_output', $output, $first, $last, $total ); - } - } -new GravityView_Widget_Pagination_Info; +new GravityView_Widget_Pagination_Info(); diff --git a/includes/widgets/index.php b/includes/widgets/index.php index e71af0ef21..8142269b13 100644 --- a/includes/widgets/index.php +++ b/includes/widgets/index.php @@ -1 +1 @@ -widget_id = 'poll'; - $this->icon = 'dashicons-chart-bar'; - $this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gk-gravityview' ); - $this->widget_subtitle = sprintf( _x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gk-gravityview' ), '', '' ); + $this->widget_id = 'poll'; + $this->icon = 'dashicons-chart-bar'; + $this->widget_description = __( 'Displays the results of Poll Fields that exist in the form.', 'gk-gravityview' ); + $this->widget_subtitle = sprintf( _x( 'Note: this will display poll results for %1$sall form entries%2$s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gk-gravityview' ), '', '' ); $default_values = array( 'header' => 1, @@ -33,27 +34,27 @@ function __construct() { $settings = array( 'percentages' => array( - 'label' => __('Display Percentages', 'gk-gravityview'), - 'type' => 'checkbox', - 'value' => true, + 'label' => __( 'Display Percentages', 'gk-gravityview' ), + 'type' => 'checkbox', + 'value' => true, 'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gk-gravityview' ), ), - 'counts' => array( - 'label' => __('Display Counts', 'gk-gravityview'), - 'type' => 'checkbox', - 'value' => true, + 'counts' => array( + 'label' => __( 'Display Counts', 'gk-gravityview' ), + 'type' => 'checkbox', + 'value' => true, 'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gk-gravityview' ), ), - 'style' => array( - 'type' => 'select', - 'label' => __('Style', 'gk-gravityview'), + 'style' => array( + 'type' => 'select', + 'label' => __( 'Style', 'gk-gravityview' ), 'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gk-gravityview' ), - 'value' => 'green', + 'value' => 'green', 'choices' => array( - 'green' => __('Green', 'gk-gravityview'), - 'blue' => __('Blue', 'gk-gravityview'), - 'red' => __('Red', 'gk-gravityview'), - 'orange' => __('Orange', 'gk-gravityview'), + 'green' => __( 'Green', 'gk-gravityview' ), + 'blue' => __( 'Blue', 'gk-gravityview' ), + 'red' => __( 'Red', 'gk-gravityview' ), + 'orange' => __( 'Orange', 'gk-gravityview' ), ), ), ); @@ -63,11 +64,12 @@ function __construct() { add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); } - parent::__construct( __( 'Poll Results', 'gk-gravityview' ) , null, $default_values, $settings ); + parent::__construct( __( 'Poll Results', 'gk-gravityview' ), null, $default_values, $settings ); } /** * Include this extension templates path + * * @since 1.8 * @param array $file_paths List of template paths ordered */ @@ -90,16 +92,15 @@ private function enqueue_scripts_and_styles() { $GFPolls = GFPolls::get_instance(); - wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version); + wp_enqueue_script( 'gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array( 'jquery' ), $GFPolls->_version ); $GFPolls->localize_scripts(); - if( version_compare( $GFPolls->_version, '4.0', '>=' ) ) { - wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/assets/css/dist/theme.css', null, $GFPolls->_version); + if ( version_compare( $GFPolls->_version, '4.0', '>=' ) ) { + wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/assets/css/dist/theme.css', null, $GFPolls->_version ); } else { - wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version); + wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version ); } - } /** @@ -112,7 +113,7 @@ private function enqueue_scripts_and_styles() { */ public function pre_render_frontend( $context = '' ) { - if( ! class_exists('GFPolls') ) { + if ( ! class_exists( 'GFPolls' ) ) { gravityview()->log->error( 'Poll Widget not displayed; the Poll Addon is not loaded' ); @@ -129,7 +130,7 @@ public function pre_render_frontend( $context = '' ) { $poll_fields = array_filter( $poll_fields ); - if ( empty ( $poll_fields ) ) { + if ( empty( $poll_fields ) ) { gravityview()->log->error( 'Poll Widget not displayed; there are no poll fields for the form' ); return false; } @@ -149,16 +150,17 @@ public function pre_render_frontend( $context = '' ) { function get_frontend_settings( $widget_settings ) { $default_settings = array( - 'field' => 0, - 'style' => 'green', + 'field' => 0, + 'style' => 'green', 'percentages' => true, - 'counts' => true, + 'counts' => true, ); $settings = wp_parse_args( $widget_settings, $default_settings ); /** - * @filter `gravityview/widget/poll/settings` Modify display settings for the poll widget + * Modify display settings for the poll widget. + * * @since 1.8 * @param array $settings Settings with `field`, `style`, `percentages` and `counts` keys */ @@ -181,8 +183,8 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { } // Make sure the class is loaded in DataTables - if( !class_exists( 'GFFormDisplay' ) ) { - include_once( GFCommon::get_base_path() . '/form_display.php' ); + if ( ! class_exists( 'GFFormDisplay' ) ) { + include_once GFCommon::get_base_path() . '/form_display.php'; } $this->enqueue_scripts_and_styles(); @@ -193,7 +195,7 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { $counts = empty( $settings['counts'] ) ? 'false' : 'true'; - if( !empty( $settings['field'] ) ) { + if ( ! empty( $settings['field'] ) ) { $merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts ); } else { $merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts ); @@ -204,13 +206,12 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { $gravityview_view->poll_merge_tag = $merge_tag; $gravityview_view->poll_settings = $settings; - $gravityview_view->poll_fields = $this->poll_fields; + $gravityview_view->poll_fields = $this->poll_fields; - $gravityview_view->render('widget', 'poll', false ); + $gravityview_view->render( 'widget', 'poll', false ); unset( $gravityview_view->poll_merge_tag, $gravityview_view->poll_settings, $gravityview_view->poll_form, $gravityview_view->poll_fields ); } - } -new GravityView_Widget_Poll; +new GravityView_Widget_Poll(); diff --git a/includes/widgets/poll/index.php b/includes/widgets/poll/index.php index e71af0ef21..8142269b13 100644 --- a/includes/widgets/poll/index.php +++ b/includes/widgets/poll/index.php @@ -1 +1 @@ -widget_id = 'search_bar'; + $this->widget_id = 'search_bar'; $this->widget_description = esc_html__( 'Display a search form for users to search a View\'s entries.', 'gk-gravityview' ); - $this->widget_subtitle = esc_html__( 'Search form for searching entries.', 'gk-gravityview' ); + $this->widget_subtitle = esc_html__( 'Search form for searching entries.', 'gk-gravityview' ); self::$instance = &$this; self::$file = plugin_dir_path( __FILE__ ); - $default_values = array( 'header' => 0, 'footer' => 0 ); + $default_values = array( + 'header' => 0, + 'footer' => 0, + ); $settings = array( 'search_layout' => array( - 'type' => 'radio', + 'type' => 'radio', 'full_width' => true, - 'label' => esc_html__( 'Search Layout', 'gk-gravityview' ), - 'value' => 'horizontal', - 'options' => array( + 'label' => esc_html__( 'Search Layout', 'gk-gravityview' ), + 'value' => 'horizontal', + 'options' => array( 'horizontal' => esc_html__( 'Horizontal', 'gk-gravityview' ), - 'vertical' => esc_html__( 'Vertical', 'gk-gravityview' ), + 'vertical' => esc_html__( 'Vertical', 'gk-gravityview' ), ), ), - 'search_clear' => array( + 'search_clear' => array( 'type' => 'checkbox', 'label' => __( 'Show Clear button', 'gk-gravityview' ), - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview'), + 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview' ), 'value' => true, ), 'search_fields' => array( - 'type' => 'hidden', + 'type' => 'hidden', 'label' => '', 'class' => 'gv-search-fields-value', 'value' => '[{"field":"search_all","input":"input_text"}]', // Default: Search Everything text box ), - 'search_mode' => array( - 'type' => 'radio', + 'search_mode' => array( + 'type' => 'radio', 'full_width' => true, - 'label' => esc_html__( 'Search Mode', 'gk-gravityview' ), - 'desc' => __('Should search results match all search fields, or any?', 'gk-gravityview'), - 'value' => 'any', - 'class' => 'hide-if-js', - 'options' => array( + 'label' => esc_html__( 'Search Mode', 'gk-gravityview' ), + 'desc' => __( 'Should search results match all search fields, or any?', 'gk-gravityview' ), + 'value' => 'any', + 'class' => 'hide-if-js', + 'options' => array( 'any' => esc_html__( 'Match Any Fields', 'gk-gravityview' ), 'all' => esc_html__( 'Match All Fields', 'gk-gravityview' ), ), ), 'sieve_choices' => array( - 'type' => 'radio', + 'type' => 'radio', 'full_width' => true, - 'label' => esc_html__( 'Pre-Filter Choices', 'gk-gravityview' ), + 'label' => esc_html__( 'Pre-Filter Choices', 'gk-gravityview' ), // translators: Do not translate [b], [/b], [link], or [/link]; they are placeholders for HTML and links to documentation. - 'desc' => strtr( + 'desc' => strtr( esc_html__( 'For fields with choices: Instead of showing all choices for each field, show only field choices that exist in submitted form entries.', 'gk-gravityview' ) . - '

⚠️ ' . esc_html__('This setting affects security.', 'gk-gravityview' ) . ' ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview') . '

', + '

⚠️ ' . esc_html__( 'This setting affects security.', 'gk-gravityview' ) . ' ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview' ) . '

', array( - '[b]' => '', - '[/b]' => '', - '[link]' => '', + '[b]' => '', + '[/b]' => '', + '[link]' => '', '[/link]' => '', ) ), - 'value' => '0', - 'class' => 'hide-if-js', - 'options' => array( + 'value' => '0', + 'class' => 'hide-if-js', + 'options' => array( '0' => esc_html__( 'Show all field choices', 'gk-gravityview' ), '1' => esc_html__( 'Only show choices that exist in form entries', 'gk-gravityview' ), ), @@ -109,7 +113,7 @@ public function __construct() { // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); // ajax - get the searchable fields @@ -134,7 +138,7 @@ public function __construct() { */ public static function getInstance() { if ( empty( self::$instance ) ) { - self::$instance = new GravityView_Widget_Search; + self::$instance = new GravityView_Widget_Search(); } return self::$instance; } @@ -169,11 +173,13 @@ public function add_reserved_args( $args ) { /** * Sets the search method to GET (default) or POST + * * @since 1.16.4 */ private function set_search_method() { /** - * @filter `gravityview/search/method` Modify the search form method (GET / POST) + * Modify the search form method (GET / POST). + * * @since 1.16.4 * @param string $search_method Assign an input type according to the form field type. Defaults: `boolean`, `multi`, `select`, `date`, `text` * @param string $field_type Gravity Forms field type (also the `name` parameter of GravityView_Field classes) @@ -187,6 +193,7 @@ private function set_search_method() { /** * Returns the search method + * * @since 1.16.4 * @return string */ @@ -204,25 +211,27 @@ public function get_search_method() { public static function get_input_types_by_field_type() { /** * Input Type groups + * * @see admin-search-widget.js (getSelectInput) */ $input_types = array( - 'text' => array( 'input_text' ), - 'address' => array( 'input_text' ), - 'number' => array( 'input_text' ), - 'date' => array( 'date', 'date_range' ), - 'boolean' => array( 'single_checkbox' ), - 'select' => array( 'select', 'radio', 'link' ), - 'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ), + 'text' => array( 'input_text' ), + 'address' => array( 'input_text' ), + 'number' => array( 'input_text' ), + 'date' => array( 'date', 'date_range' ), + 'boolean' => array( 'single_checkbox' ), + 'select' => array( 'select', 'radio', 'link' ), + 'multi' => array( 'select', 'multiselect', 'radio', 'checkbox', 'link' ), // hybrids 'created_by' => array( 'select', 'radio', 'checkbox', 'multiselect', 'link', 'input_text' ), 'multi_text' => array( 'select', 'radio', 'checkbox', 'multiselect', 'link', 'input_text' ), - 'product' => array( 'select', 'radio', 'link', 'input_text' ), + 'product' => array( 'select', 'radio', 'link', 'input_text' ), ); /** - * @filter `gravityview/search/input_types` Change the types of search fields available to a field type + * Change the types of search fields available to a field type. + * * @see GravityView_Widget_Search::get_search_input_labels() for the available input types * @param array $input_types Associative array: key is field `name`, value is array of GravityView input types (note: use `input_text` for `text`) */ @@ -241,22 +250,24 @@ public static function get_input_types_by_field_type() { public static function get_search_input_labels() { /** * Input Type labels l10n + * * @see admin-search-widget.js (getSelectInput) */ $input_labels = array( - 'input_text' => esc_html__( 'Text', 'gk-gravityview' ), - 'date' => esc_html__( 'Date', 'gk-gravityview' ), - 'select' => esc_html__( 'Select', 'gk-gravityview' ), - 'multiselect' => esc_html__( 'Select (multiple values)', 'gk-gravityview' ), - 'radio' => esc_html__( 'Radio', 'gk-gravityview' ), - 'checkbox' => esc_html__( 'Checkbox', 'gk-gravityview' ), + 'input_text' => esc_html__( 'Text', 'gk-gravityview' ), + 'date' => esc_html__( 'Date', 'gk-gravityview' ), + 'select' => esc_html__( 'Select', 'gk-gravityview' ), + 'multiselect' => esc_html__( 'Select (multiple values)', 'gk-gravityview' ), + 'radio' => esc_html__( 'Radio', 'gk-gravityview' ), + 'checkbox' => esc_html__( 'Checkbox', 'gk-gravityview' ), 'single_checkbox' => esc_html__( 'Checkbox', 'gk-gravityview' ), - 'link' => esc_html__( 'Links', 'gk-gravityview' ), - 'date_range' => esc_html__( 'Date range', 'gk-gravityview' ), + 'link' => esc_html__( 'Links', 'gk-gravityview' ), + 'date_range' => esc_html__( 'Date range', 'gk-gravityview' ), ); /** - * @filter `gravityview/search/input_types` Change the label of search field input types + * Change the label of search field input types. + * * @param array $input_types Associative array: key is input type name, value is label */ $input_labels = apply_filters( 'gravityview/search/input_labels', $input_labels ); @@ -272,6 +283,7 @@ public static function get_search_input_label( $input_type ) { /** * Add script to Views edit screen (admin) + * * @param mixed $hook */ public function add_scripts_and_styles( $hook ) { @@ -282,27 +294,31 @@ public function add_scripts_and_styles( $hook ) { return; } - $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; + $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; $script_source = empty( $script_min ) ? '/source' : ''; - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); - - wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( - 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), - 'label_nofields' => esc_html__( 'No search fields configured yet.', 'gk-gravityview' ), - 'label_addfield' => esc_html__( 'Add Search Field', 'gk-gravityview' ), - 'label_label' => esc_html__( 'Label', 'gk-gravityview' ), - 'label_searchfield' => esc_html__( 'Search Field', 'gk-gravityview' ), - 'label_inputtype' => esc_html__( 'Input Type', 'gk-gravityview' ), - 'label_ajaxerror' => esc_html__( 'There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gk-gravityview' ), - 'input_labels' => json_encode( self::get_search_input_labels() ), - 'input_types' => json_encode( self::get_input_types_by_field_type() ), - ) ); - + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); + + wp_localize_script( + 'gravityview_searchwidget_admin', + 'gvSearchVar', + array( + 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), + 'label_nofields' => esc_html__( 'No search fields configured yet.', 'gk-gravityview' ), + 'label_addfield' => esc_html__( 'Add Search Field', 'gk-gravityview' ), + 'label_label' => esc_html__( 'Label', 'gk-gravityview' ), + 'label_searchfield' => esc_html__( 'Search Field', 'gk-gravityview' ), + 'label_inputtype' => esc_html__( 'Input Type', 'gk-gravityview' ), + 'label_ajaxerror' => esc_html__( 'There was an error loading searchable fields. Save the View or refresh the page to fix this issue.', 'gk-gravityview' ), + 'input_labels' => json_encode( self::get_search_input_labels() ), + 'input_types' => json_encode( self::get_input_types_by_field_type() ), + ) + ); } /** * Add admin script to the no-conflict scripts allowlist + * * @param array $allowed Scripts allowed in no-conflict mode * @return array Scripts allowed in no-conflict mode, plus the search widget script */ @@ -348,7 +364,8 @@ public static function get_searchable_fields() { /** * Generates html for the available Search Fields dropdown - * @param int $form_id + * + * @param int $form_id * @param string $current (for future use) * @return string */ @@ -371,7 +388,7 @@ public static function render_searchable_fields( $form_id = null, $current = '' 'text' => esc_html__( 'Entry Date', 'gk-gravityview' ), 'type' => 'date', ), - 'entry_id' => array( + 'entry_id' => array( 'text' => esc_html__( 'Entry ID', 'gk-gravityview' ), 'type' => 'text', ), @@ -392,15 +409,16 @@ public static function render_searchable_fields( $form_id = null, $current = '' ); } - foreach( $custom_fields as $custom_field_key => $custom_field ) { - $output .= sprintf( '', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); + foreach ( $custom_fields as $custom_field_key => $custom_field ) { + $output .= sprintf( '', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field['text'] ); } // Get fields with sub-inputs and no parent $fields = gravityview_get_form_fields( $form_id, true, true ); /** - * @filter `gravityview/search/searchable_fields` Modify the fields that are displayed as searchable in the Search Bar dropdown\n + * Modify the fields that are displayed as searchable in the Search Bar dropdown\n. + * * @since 1.17 * @see gravityview_get_form_fields() Used to fetch the fields * @see GravityView_Widget_Search::get_search_input_types See this method to modify the type of input types allowed for a field @@ -421,14 +439,13 @@ public static function render_searchable_fields( $form_id = null, $current = '' $types = self::get_search_input_types( $id, $field['type'] ); - $output .= ''; + $output .= ''; } } $output .= ''; return $output; - } /** @@ -437,7 +454,7 @@ public static function render_searchable_fields( $form_id = null, $current = '' * @see admin-search-widget.js * * @param string|int|float $field_id Gravity Forms field ID - * @param string $field_type Gravity Forms field type (also the `name` parameter of GravityView_Field classes) + * @param string $field_type Gravity Forms field type (also the `name` parameter of GravityView_Field classes) * * @return string GV field search input type ('multi', 'boolean', 'select', 'date', 'text') */ @@ -447,8 +464,8 @@ public static function get_search_input_types( $field_id = '', $field_type = nul if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { $input_type = 'boolean'; // on/off checkbox } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { - $input_type = 'multi'; //multiselect - } elseif ( in_array( $field_id, [ 'payment_status' ] ) ) { + $input_type = 'multi'; // multiselect + } elseif ( in_array( $field_id, array( 'payment_status' ) ) ) { $input_type = 'multi_text'; } elseif ( in_array( $field_type, array( 'select', 'radio' ) ) ) { $input_type = 'select'; @@ -463,7 +480,8 @@ public static function get_search_input_types( $field_id = '', $field_type = nul } /** - * @filter `gravityview/extension/search/input_type` Modify the search form input type based on field type + * Modify the search form input type based on field type. + * * @since 1.2 * @since 1.19.2 Added $field_id parameter * @param string $input_type Assign an input type according to the form field type. Defaults: `boolean`, `multi`, `select`, `date`, `text` @@ -496,7 +514,7 @@ public function add_no_permalink_fields( $search_fields, $object, $widget_args = $post_id = absint( $widget_args['post_id'] ); } // We're in the WordPress Widget context, and the base View ID should be used - else if ( ! empty( $widget_args['view_id'] ) ) { + elseif ( ! empty( $widget_args['view_id'] ) ) { $post_id = absint( $widget_args['view_id'] ); } @@ -522,10 +540,10 @@ public function add_no_permalink_fields( $search_fields, $object, $widget_args = * @since 2.0.9 Added $with_full_field parameter * * @param \GV\View|null $view - * @param bool $with_full_field Return full field array, or just field ID? Default: false (just field ID) + * @param bool $with_full_field Return full field array, or just field ID? Default: false (just field ID) * - * TODO: Move to \GV\View, perhaps? And return a Field_Collection - * TODO: Use in gravityview()->request->is_search() to calculate whether a valid search + * TODO: Move to \GV\View, perhaps? And return a Field_Collection + * TODO: Use in gravityview()->request->is_search() to calculate whether a valid search * * @return array If no View, returns empty array. Otherwise, returns array of fields configured in widgets and Search Bar for a View */ @@ -547,7 +565,7 @@ private function get_view_searchable_fields( $view, $with_full_field = false ) { foreach ( $widgets as $widget ) { if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { - if( $_fields = json_decode( $widget['search_fields'], true ) ) { + if ( $_fields = json_decode( $widget['search_fields'], true ) ) { foreach ( $_fields as $field ) { if ( empty( $field['form_id'] ) ) { $field['form_id'] = $view->form ? $view->form->ID : 0; @@ -559,7 +577,7 @@ private function get_view_searchable_fields( $view, $with_full_field = false ) { } foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { foreach ( $_fields as $field ) { if ( empty( $field['form_id'] ) ) { $field['form_id'] = $view->form ? $view->form->ID : 0; @@ -576,7 +594,8 @@ private function get_view_searchable_fields( $view, $with_full_field = false ) { $searchable_fields = apply_filters_deprecated( 'gravityview/search/searchable_fields/whitelist', array( $searchable_fields, $view, $with_full_field ), '2.14', 'gravityview/search/searchable_fields/allowlist' ); /** - * @filter `gravityview/search/searchable_fields/allowlist` Modifies the fields able to be searched using the Search Bar + * Modifies the fields able to be searched using the Search Bar. + * * @since 2.14 * * @param array $searchable_fields Array of GravityView-formatted fields or only the field ID? Example: [ '1.2', 'created_by' ] @@ -592,11 +611,12 @@ private function get_view_searchable_fields( $view, $with_full_field = false ) { /** * Calculate the search criteria to filter entries + * * @param array $search_criteria The search criteria - * @param int $form_id The form ID + * @param int $form_id The form ID * @param array $args Some args * - * @param bool $force_search_criteria Whether to suppress GF_Query filter, internally used in self::gf_query_filter + * @param bool $force_search_criteria Whether to suppress GF_Query filter, internally used in self::gf_query_filter * * @return array */ @@ -610,17 +630,23 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array return $search_criteria; // Return the original criteria, GF_Query modification kicks in later } - if( 'post' === $this->search_method ) { + if ( 'post' === $this->search_method ) { $get = $_POST; } else { $get = $_GET; } - $view = \GV\View::by_id( \GV\Utils::get( $args, 'id' ) ); + $view = \GV\View::by_id( \GV\Utils::get( $args, 'id' ) ); $view_id = $view ? $view->ID : null; $form_id = $view ? $view->form->ID : null; - gravityview()->log->debug( 'Requested $_{method}: ', array( 'method' => $this->search_method, 'data' => $get ) ); + gravityview()->log->debug( + 'Requested $_{method}: ', + array( + 'method' => $this->search_method, + 'data' => $get, + ) + ); if ( empty( $get ) || ! is_array( $get ) ) { return $search_criteria; @@ -635,22 +661,28 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array // Make sure array key is set up $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); - $searchable_fields = $this->get_view_searchable_fields( $view ); + $searchable_fields = $this->get_view_searchable_fields( $view ); $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); /** - * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? + * Search for each word separately or the whole phrase? + * * @since 1.20.2 + * @since TODO Added $view parameter * @param bool $split_words True: split a phrase into words; False: search whole word only [Default: true] + * @param \GV\View $view The View being searched */ - $split_words = apply_filters( 'gravityview/search-all-split-words', true ); + $split_words = apply_filters( 'gravityview/search-all-split-words', true, $view ); /** - * @filter `gravityview/search-trim-input` Remove leading/trailing whitespaces from search value + * Remove leading/trailing whitespaces from search value. + * * @since 2.9.3 + * @since TODO Added $view parameter * @param bool $trim_search_value True: remove whitespace; False: keep as is [Default: true] + * @param \GV\View $view The View being searched */ - $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); + $trim_search_value = apply_filters( 'gravityview/search-trim-input', true, $view ); // add free search if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { @@ -672,8 +704,8 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array foreach ( $words as $word ) { $search_criteria['field_filters'][] = array( - 'key' => null, // The field ID to search - 'value' => $word, // The value to search + 'key' => null, // The field ID to search + 'value' => $word, // The value to search 'operator' => 'contains', // What to search in. Options: `is` or `contains` ); } @@ -685,13 +717,13 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array * Get and normalize the dates according to the input format. */ if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { $curr_start = $curr_start_date->format( 'Y-m-d' ); } } if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { $curr_end = $curr_end_date->format( 'Y-m-d' ); } } @@ -713,9 +745,10 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array } /** - * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n + * Whether to adjust the timezone for entries. \n. * `date_created` is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php). \n * This is for backward compatibility before \GF_Query started to automatically apply the timezone offset. + * * @since 1.12 * @param boolean $adjust_tz Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default is `false`. * @param string $context Where the filter is being called from. `search` in this case. @@ -726,13 +759,13 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries) */ if ( ! empty( $curr_start ) ) { - $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); + $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; } if ( ! empty( $curr_end ) ) { // Fast-forward 24 hour on the end time - $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); + $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); @@ -741,25 +774,25 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array } // search for a specific entry ID - if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { + if ( ! empty( $get['gv_id'] ) && in_array( 'entry_id', $searchable_fields ) ) { $search_criteria['field_filters'][] = array( - 'key' => 'id', - 'value' => absint( $get[ 'gv_id' ] ), + 'key' => 'id', + 'value' => absint( $get['gv_id'] ), 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), ); } // search for a specific Created_by ID - if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { + if ( ! empty( $get['gv_by'] ) && in_array( 'created_by', $searchable_fields ) ) { $search_criteria['field_filters'][] = array( - 'key' => 'created_by', - 'value' => $get['gv_by'], + 'key' => 'created_by', + 'value' => $get['gv_by'], 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), ); } // Get search mode passed in URL - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; + $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; // get the other search filters foreach ( $get as $key => $value ) { @@ -767,7 +800,7 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array continue; } - if ( strpos( $key, '|op' ) !== false ) { + if ( false !== strpos( $key, '|op' ) ) { continue; // This is an operator } @@ -777,9 +810,10 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); } - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && 1 === count( $value ) && gv_empty( $value[0], false, false ) ) ) { /** - * @filter `gravityview/search/ignore-empty-values` Filter to control if empty field values should be ignored or strictly matched (default: true) + * Filter to control if empty field values should be ignored or strictly matched (default: true). + * * @since 2.14.2.1 * @param bool $ignore_empty_values * @param int|null $filter_key @@ -821,13 +855,14 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { $mode = 'all'; } - } elseif( !empty( $filter ) ) { + } elseif ( ! empty( $filter ) ) { $search_criteria['field_filters'][] = $filter; } } /** - * @filter `gravityview/search/mode` Set the Search Mode (`all` or `any`) + * or `any`). + * * @since 1.5.1 * @param string $mode Search mode (`any` vs `all`) */ @@ -845,8 +880,8 @@ public function filter_entries( $search_criteria, $form_id = null, $args = array * * Dropin for the legacy flat filters when \GF_Query is available. * - * @param \GF_Query $query The current query object reference - * @param \GV\View $this The current view object + * @param \GF_Query $query The current query object reference + * @param \GV\View $this The current view object * @param \GV\Request $request The request object */ public function gf_query_filter( &$query, $view, $request ) { @@ -884,7 +919,7 @@ public function gf_query_filter( &$query, $view, $request ) { } $extra_conditions = array(); - $mode = 'any'; + $mode = 'any'; foreach ( $search_criteria['field_filters'] as $key => &$filter ) { if ( ! is_array( $filter ) ) { @@ -896,21 +931,24 @@ public function gf_query_filter( &$query, $view, $request ) { // Construct a manual query for unapproved statuses if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { - $_tmp_query = new $query_class( $view->form->ID, array( - 'field_filters' => array( - array( - 'operator' => 'in', - 'key' => 'is_approved', - 'value' => (array) $filter['value'], - ), - array( - 'operator' => 'is', - 'key' => 'is_approved', - 'value' => '', + $_tmp_query = new $query_class( + $view->form->ID, + array( + 'field_filters' => array( + array( + 'operator' => 'in', + 'key' => 'is_approved', + 'value' => (array) $filter['value'], + ), + array( + 'operator' => 'is', + 'key' => 'is_approved', + 'value' => '', + ), + 'mode' => 'any', ), - 'mode' => 'any' - ), - ) ); + ) + ); $_tmp_query_parts = $_tmp_query->_introspect(); $extra_conditions[] = $_tmp_query_parts['where']; @@ -922,7 +960,7 @@ public function gf_query_filter( &$query, $view, $request ) { // Construct manual query for text mode creator search if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); - $filter = false; + $filter = false; continue; } @@ -940,7 +978,8 @@ public function gf_query_filter( &$query, $view, $request ) { } /** - * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) + * Modify the search operator for the field (contains, is, isnot, etc). + * * @since 2.0 Added $view parameter * @param string $operator Existing search operator * @param array $filter array with `key`, `value`, `operator`, `type` keys @@ -983,7 +1022,13 @@ public function gf_query_filter( &$query, $view, $request ) { * code by reusing what's inside GF_Query already as they * take care of many small things like forcing numeric, etc. */ - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); + $_tmp_query = new $query_class( + $filter['form_id'], + array( + 'mode' => 'any', + 'field_filters' => array( $filter ), + ) + ); $_tmp_query_parts = $_tmp_query->_introspect(); $search_condition = $_tmp_query_parts['where']; @@ -1012,9 +1057,9 @@ public function gf_query_filter( &$query, $view, $request ) { $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); - if ( $view->joins && $left->field_id == GF_Query_Column::META ) { + if ( $view->joins && GF_Query_Column::META == $left->field_id ) { foreach ( $view->joins as $_join ) { - $on = $_join->join_on; + $on = $_join->join_on; $join = $_join->join; $search_conditions[] = GF_Query_Condition::_or( @@ -1043,7 +1088,7 @@ public function gf_query_filter( &$query, $view, $request ) { } if ( $search_conditions ) { - $search_conditions = array( call_user_func_array( '\GF_Query_Condition::' . ( $mode == 'all' ? '_and' : '_or' ), $search_conditions ) ); + $search_conditions = array( call_user_func_array( '\GF_Query_Condition::' . ( 'all' == $mode ? '_and' : '_or' ), $search_conditions ) ); } } @@ -1078,7 +1123,7 @@ private function convert_request_key_to_filter_key( $key ) { $field_id = str_replace( array( 'filter_', 'input_' ), '', $key ); // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { $field_id = str_replace( '_', '.', $field_id ); } @@ -1092,10 +1137,10 @@ private function convert_request_key_to_filter_key( $key ) { * * Format searched values * - * @param string $filter_key ID of the field, or entry meta key - * @param string $value $_GET/$_POST search value + * @param string $filter_key ID of the field, or entry meta key + * @param string $value $_GET/$_POST search value * @param \GV\View $view The view we're looking at - * @param array[] $searchable_fields The searchable fields as configured by the widget. + * @param array[] $searchable_fields The searchable fields as configured by the widget. * @param string[] $get The $_GET/$_POST array. * * @since develop Added 5th $get parameter for operator overrides. @@ -1104,7 +1149,7 @@ private function convert_request_key_to_filter_key( $key ) { * @return array|false 1 or 2 deph levels, false if not allowed */ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fields, $get = array() ) { - $key = $filter_key; + $key = $filter_key; $filter_key = explode( ':', $filter_key ); // field_id, form_id $form = null; @@ -1145,7 +1190,7 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi return false; } } else { - $field_id = reset( $filter_key ); + $field_id = reset( $filter_key ); $searchable_fields = wp_list_pluck( $searchable_fields, 'field' ); if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $field_id, $searchable_fields ) ) { return false; @@ -1166,8 +1211,8 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi // default filter array $filter = array( - 'key' => $field_id, - 'value' => $value, + 'key' => $field_id, + 'value' => $value, 'form_id' => $form->ID, ); @@ -1179,7 +1224,6 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi break; case 'post_category': - if ( ! is_array( $value ) ) { $value = array( $value ); } @@ -1188,7 +1232,7 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi $filter = array(); foreach ( $value as $val ) { - $cat = get_term( $val, 'category' ); + $cat = get_term( $val, 'category' ); $filter[] = array( 'key' => $field_id, 'value' => esc_attr( $cat->name ) . ':' . $val, @@ -1199,7 +1243,6 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi break; case 'multiselect': - if ( ! is_array( $value ) ) { break; } @@ -1208,7 +1251,10 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi $filter = array(); foreach ( $value as $val ) { - $filter[] = array( 'key' => $field_id, 'value' => $val ); + $filter[] = array( + 'key' => $field_id, + 'value' => $val, + ); } break; @@ -1218,7 +1264,7 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { foreach ( $form_field->inputs as $k => $input ) { if ( $input['id'] == $field_id ) { - $filter['value'] = $form_field->choices[ $k ]['value']; + $filter['value'] = $form_field->choices[ $k ]['value']; $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); break; } @@ -1241,7 +1287,6 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi case 'name': case 'address': - if ( false === strpos( $field_id, '.' ) ) { $words = explode( ' ', $value ); @@ -1266,12 +1311,12 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi foreach ( $searchable_fields as $searchable_field ) { - if( $form_field->ID !== $searchable_field['field'] ) { + if ( $form_field->ID !== $searchable_field['field'] ) { continue; } // Only exact-match dropdowns, not text search - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { + if ( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { continue; } @@ -1279,7 +1324,7 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi if ( 4 === $input_id ) { $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); - }; + } } } @@ -1287,7 +1332,6 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi case 'payment_date': case 'date': - $date_format = $this->get_datepicker_format( true ); if ( is_array( $value ) ) { @@ -1306,9 +1350,9 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi * @since 1.16.3 * Safeguard until GF implements '<=' operator */ - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { + if ( ! GFFormsModel::is_valid_operator( $operator ) && '<=' === $operator ) { $operator = '<'; - $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); + $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); } $filter[] = array( @@ -1318,12 +1362,12 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi ); } } else { - $date = $value; - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); + $date = $value; + $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); } - if ('payment_date' === $key) { + if ( 'payment_date' === $key ) { $filter['operator'] = 'contains'; } @@ -1342,18 +1386,18 @@ public function prepare_field_filter( $filter_key, $value, $view, $searchable_fi * @return string Format of the date in the database */ public static function get_date_field_format( GF_Field_Date $field ) { - $format = 'm/d/Y'; + $format = 'm/d/Y'; $datepicker = array( - 'mdy' => 'm/d/Y', - 'dmy' => 'd/m/Y', - 'dmy_dash' => 'd-m-Y', - 'dmy_dot' => 'd.m.Y', + 'mdy' => 'm/d/Y', + 'dmy' => 'd/m/Y', + 'dmy_dash' => 'd-m-Y', + 'dmy_dot' => 'd.m.Y', 'ymd_slash' => 'Y/m/d', - 'ymd_dash' => 'Y-m-d', - 'ymd_dot' => 'Y.m.d', + 'ymd_dash' => 'Y-m-d', + 'ymd_dot' => 'Y.m.d', ); - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { $format = $datepicker[ $field->dateFormat ]; } @@ -1385,6 +1429,7 @@ public static function get_formatted_date( $value = '', $format = 'Y-m-d', $valu /** * Include this extension templates path + * * @param array $file_paths List of template paths ordered */ public function add_template_path( $file_paths ) { @@ -1420,8 +1465,9 @@ private function has_date_field( $search_fields ) { /** * Renders the Search Widget - * @param array $widget_args - * @param string $content + * + * @param array $widget_args + * @param string $content * @param string|\GV\Template_Context $context * * @return void @@ -1455,35 +1501,35 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { switch ( $field['field'] ) { case 'search_all': - $updated_field['key'] = 'search_all'; + $updated_field['key'] = 'search_all'; $updated_field['input'] = 'search_all'; $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); break; case 'entry_date': - $updated_field['key'] = 'entry_date'; + $updated_field['key'] = 'entry_date'; $updated_field['input'] = 'entry_date'; $updated_field['value'] = array( 'start' => $this->rgget_or_rgpost( 'gv_start' ), - 'end' => $this->rgget_or_rgpost( 'gv_end' ), + 'end' => $this->rgget_or_rgpost( 'gv_end' ), ); break; case 'entry_id': - $updated_field['key'] = 'entry_id'; + $updated_field['key'] = 'entry_id'; $updated_field['input'] = 'entry_id'; $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); break; case 'created_by': - $updated_field['key'] = 'created_by'; - $updated_field['name'] = 'gv_by'; + $updated_field['key'] = 'created_by'; + $updated_field['name'] = 'gv_by'; $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); break; case 'is_approved': - $updated_field['key'] = 'is_approved'; - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); + $updated_field['key'] = 'is_approved'; + $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); $updated_field['choices'] = self::get_is_approved_choices(); break; } @@ -1494,7 +1540,8 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { gravityview()->log->debug( 'Calculated Search Fields: ', array( 'data' => $search_fields ) ); /** - * @filter `gravityview_widget_search_filters` Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget. + * Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget. + * * @param array $search_fields Array of search filters with `key`, `label`, `value`, `type`, `choices` keys * @param GravityView_Widget_Search $this Current widget object * @param array $widget_args Args passed to this method. {@since 1.8} @@ -1536,14 +1583,15 @@ public function render_frontend( $widget_args, $content = '', $context = '' ) { public static function get_search_class( $custom_class = '' ) { $gravityview_view = GravityView_View::getInstance(); - $search_class = 'gv-search-'.$gravityview_view->search_layout; + $search_class = 'gv-search-' . $gravityview_view->search_layout; - if ( ! empty( $custom_class ) ) { - $search_class .= ' '.$custom_class; + if ( ! empty( $custom_class ) ) { + $search_class .= ' ' . $custom_class; } /** - * @filter `gravityview_search_class` Modify the CSS class for the search form + * Modify the CSS class for the search form. + * * @param string $search_class The CSS class for the search form */ $search_class = apply_filters( 'gravityview_search_class', $search_class ); @@ -1557,6 +1605,7 @@ public static function get_search_class( $custom_class = '' ) { /** * Calculate the search form action + * * @since 1.6 * * @return string @@ -1569,7 +1618,8 @@ public static function get_search_form_action() { $url = add_query_arg( array(), get_permalink( $post_id ) ); /** - * @filter `gravityview/widget/search/form/action` Override the search URL. + * Override the search URL. + * * @param string $action Where the form submits to. * * Further parameters will be added once adhoc context is added. @@ -1580,6 +1630,7 @@ public static function get_search_form_action() { /** * Get the label for a search form field + * * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys * @param array $form_field Form field data, as fetched by `gravityview_get_field()` * @return string Label for the search form @@ -1592,7 +1643,7 @@ private static function get_field_label( $field, $form_field = array() ) { $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; - switch( $field['field'] ) { + switch ( $field['field'] ) { case 'search_all': $label = __( 'Search Entries:', 'gk-gravityview' ); break; @@ -1622,7 +1673,8 @@ private static function get_field_label( $field, $form_field = array() ) { } /** - * @filter `gravityview_search_field_label` Modify the label for a search field. Supports returning HTML + * Modify the label for a search field. Supports returning HTML. + * * @since 1.17.3 Added $field parameter * @param string $label Existing label text, sanitized. * @param array $form_field Gravity Forms field array, as returned by `GFFormsModel::get_field()` @@ -1638,9 +1690,9 @@ private static function get_field_label( $field, $form_field = array() ) { * * @since 2.16 Added $widget_args parameter. * - * @param array $field + * @param array $field * @param \GV\Context $context - * @param array $widget_args + * @param array $widget_args * * @return array */ @@ -1662,12 +1714,12 @@ private function get_search_filter_details( $field, $context, $widget_args ) { $form_field_type = \GV\Utils::get( $form_field, 'type' ); $filter = array( - 'key' => \GV\Utils::get( $field, 'field' ), - 'name' => $name, + 'key' => \GV\Utils::get( $field, 'field' ), + 'name' => $name, 'label' => self::get_field_label( $field, $form_field ), 'input' => \GV\Utils::get( $field, 'input' ), 'value' => $value, - 'type' => $form_field_type, + 'type' => $form_field_type, ); // collect choices @@ -1678,21 +1730,25 @@ private function get_search_filter_details( $field, $context, $widget_args ) { } if ( 'date_range' === $field['input'] && empty( $value ) ) { - $filter['value'] = array( 'start' => '', 'end' => '' ); + $filter['value'] = array( + 'start' => '', + 'end' => '', + ); } if ( 'created_by' === $field['field'] ) { $filter['choices'] = self::get_created_by_choices( ( isset( $context->view ) ? $context->view : null ) ); - $filter['type'] = 'created_by'; + $filter['type'] = 'created_by'; } - if( 'payment_status' === $field['field'] ) { + if ( 'payment_status' === $field['field'] ) { $filter['type'] = 'entry_meta'; $filter['choices'] = GFCommon::get_entry_payment_statuses_as_choices(); } /** - * @filter `gravityview/search/filter_details` Filter the output filter details for the Search widget. + * Filter the output filter details for the Search widget. + * * @since 2.5 * @param array $filter The filter details * @param array $field The search field configuration @@ -1708,10 +1764,10 @@ private function get_search_filter_details( $field, $context, $widget_args ) { * * @uses sieve_filter_choices * - * @param array $search_fields Array of search filters with `key`, `label`, `value`, `type` keys + * @param array $search_fields Array of search filters with `key`, `label`, `value`, `type` keys * @param GravityView_Widget_Search $widget Current widget object - * @param array $widget_args Args passed to this method. {@since 1.8} - * @param \GV\Template_Context $context + * @param array $widget_args Args passed to this method. {@since 1.8} + * @param \GV\Template_Context $context * * @return array If the search field GF Field type is `address`, and there are choices to add, adds them and changes the input type. Otherwise, sets the input to text. */ @@ -1731,7 +1787,8 @@ public function maybe_sieve_filter_choices( $search_fields, $widget, $widget_arg $field = gravityview_get_field( $context->view->form->form, $filter['key'] ); // @todo Support multiple forms (joins) /** - * @filter `gravityview/search/sieve_choices` Only output used choices for this field. + * Only output used choices for this field. + * * @since 2.16 Modified default value to the `sieve_choices` widget setting and added $widget_args parameter. * * @param bool $sieve_choices True: Yes, filter choices based on whether the value exists in entries. False: show all choices in the original field. Default: false. @@ -1749,7 +1806,7 @@ public function maybe_sieve_filter_choices( $search_fields, $widget, $widget_arg /** * Sieve filter choices to only ones that are used. * - * @param array $filter The filter configuration. + * @param array $filter The filter configuration. * @param \GV\Context $context The context * * @since 2.5 @@ -1763,13 +1820,13 @@ private function sieve_filter_choices( $filter, $context ) { } // Allow only specific entry meta and field-ids to be sieved. - if ( ! in_array( $filter['key'], [ 'created_by', 'payment_status' ], true ) && ! is_numeric( $filter['key'] ) ) { + if ( ! in_array( $filter['key'], array( 'created_by', 'payment_status' ), true ) && ! is_numeric( $filter['key'] ) ) { return $filter; } $form_id = $context->view->form->ID; // @todo Support multiple forms (joins) - $cache = new GravityView_Cache( $form_id, [ 'sieve', $filter['key'], $context->view->ID ] ); + $cache = new GravityView_Cache( $form_id, array( 'sieve', $filter['key'], $context->view->ID ) ); $filter_choices = $cache->get(); @@ -1782,27 +1839,35 @@ private function sieve_filter_choices( $filter, $context ) { $entry_table_name = GFFormsModel::get_entry_table_name(); $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; + $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; $filter_type = \GV\Utils::get( $filter, 'type' ); switch ( $filter_type ) { case 'post_category': - $choices = $wpdb->get_col( $wpdb->prepare( - "SELECT DISTINCT SUBSTRING_INDEX( `meta_value`, ':', 1) FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %d) AND `form_id` = %d", - $key_like, $filter['key'], $form_id - ) ); + $choices = $wpdb->get_col( + $wpdb->prepare( + "SELECT DISTINCT SUBSTRING_INDEX( `meta_value`, ':', 1) FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %d) AND `form_id` = %d", + $key_like, + $filter['key'], + $form_id + ) + ); break; case 'created_by': case 'entry_meta': - $choices = $wpdb->get_col( $wpdb->prepare( - "SELECT DISTINCT `{$filter['key']}` FROM $entry_table_name WHERE `form_id` = %d", - $form_id - ) ); + $choices = $wpdb->get_col( + $wpdb->prepare( + "SELECT DISTINCT `{$filter['key']}` FROM $entry_table_name WHERE `form_id` = %d", + $form_id + ) + ); break; default: $sql = $wpdb->prepare( "SELECT DISTINCT `meta_value` FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %s ) AND `form_id` = %d", - $key_like, $filter['key'], $form_id + $key_like, + $filter['key'], + $form_id ); $choices = $wpdb->get_col( $sql ); @@ -1851,6 +1916,7 @@ private static function get_created_by_choices( $view ) { /** * filter gravityview/get_users/search_widget + * * @see \GVCommon::get_users */ $users = GVCommon::get_users( 'search_widget', array( 'fields' => array( 'ID', 'display_name' ) ) ); @@ -1858,16 +1924,17 @@ private static function get_created_by_choices( $view ) { $choices = array(); foreach ( $users as $user ) { /** - * @filter `gravityview/search/created_by/text` Filter the display text in created by search choices + * Filter the display text in created by search choices. + * * @since 2.3 * @param string[in,out] The text. Default: $user->display_name * @param \WP_User $user The user. * @param \GV\View|null $view The view. */ - $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); + $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); $choices[] = array( 'value' => $user->ID, - 'text' => $text, + 'text' => $text, ); } @@ -1887,7 +1954,7 @@ private static function get_is_approved_choices() { foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { $choices[] = array( 'value' => $status['value'], - 'text' => $status['label'], + 'text' => $status['label'], ); } @@ -1896,6 +1963,7 @@ private static function get_is_approved_choices() { /** * Output the Clear Search Results button + * * @since 1.5.4 */ public static function the_clear_search_button() { @@ -1936,6 +2004,7 @@ private function rgget_or_rgpost( $name ) { /** * Require the datepicker script for the frontend GV script + * * @param array $js_dependencies Array of existing required scripts for the fe-views.js script * @return array Array required scripts, with `jquery-ui-datepicker` added */ @@ -1958,37 +2027,41 @@ public function add_datepicker_localization( $localizations = array(), $view_dat global $wp_locale; /** - * @filter `gravityview_datepicker_settings` Modify the datepicker settings + * Modify the datepicker settings. + * * @see http://api.jqueryui.com/datepicker/ Learn what settings are available * @see http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n Thanks for the helpful information on $wp_locale * @param array $js_localization The data padded to the Javascript file * @param array $view_data View data array with View settings */ - $datepicker_settings = apply_filters( 'gravityview_datepicker_settings', array( - 'yearRange' => '-5:+5', - 'changeMonth' => true, - 'changeYear' => true, - 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gk-gravityview' ), - 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gk-gravityview' ), - 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gk-gravityview' ), - 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gk-gravityview' ), - 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gk-gravityview' ), - 'monthStatus' => __( 'Show a different month', 'gk-gravityview' ), - 'monthNames' => array_values( $wp_locale->month ), - 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), - 'dayNames' => array_values( $wp_locale->weekday ), - 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), - 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), - // get the start of week from WP general setting - 'firstDay' => get_option( 'start_of_week' ), - // is Right to left language? default is false - 'isRTL' => is_rtl(), - ), $view_data ); + $datepicker_settings = apply_filters( + 'gravityview_datepicker_settings', + array( + 'yearRange' => '-5:+5', + 'changeMonth' => true, + 'changeYear' => true, + 'closeText' => esc_attr_x( 'Close', 'Close calendar', 'gk-gravityview' ), + 'prevText' => esc_attr_x( 'Prev', 'Previous month in calendar', 'gk-gravityview' ), + 'nextText' => esc_attr_x( 'Next', 'Next month in calendar', 'gk-gravityview' ), + 'currentText' => esc_attr_x( 'Today', 'Today in calendar', 'gk-gravityview' ), + 'weekHeader' => esc_attr_x( 'Week', 'Week in calendar', 'gk-gravityview' ), + 'monthStatus' => __( 'Show a different month', 'gk-gravityview' ), + 'monthNames' => array_values( $wp_locale->month ), + 'monthNamesShort' => array_values( $wp_locale->month_abbrev ), + 'dayNames' => array_values( $wp_locale->weekday ), + 'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), + 'dayNamesMin' => array_values( $wp_locale->weekday_initial ), + // get the start of week from WP general setting + 'firstDay' => get_option( 'start_of_week' ), + // is Right to left language? default is false + 'isRTL' => is_rtl(), + ), + $view_data + ); $localizations['datepicker'] = $datepicker_settings; return $localizations; - } /** @@ -2034,7 +2107,7 @@ public function enqueue_datepicker() { add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); $scheme = is_ssl() ? 'https://' : 'http://'; - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); /** * @filter `gravityview_search_datepicker_class` @@ -2049,7 +2122,7 @@ public function enqueue_datepicker() { * - `ymd_dash` (yyyy-mm-dd) * - `ymd_dot` (yyyy.mm.dd) */ - $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', "gv-datepicker datepicker " . $this->get_datepicker_format() ); + $datepicker_class = apply_filters( 'gravityview_search_datepicker_class', 'gv-datepicker datepicker ' . $this->get_datepicker_format() ); $gravityview_view->datepicker_class = $datepicker_class; } @@ -2083,15 +2156,15 @@ private function get_datepicker_format( $date_format = false ) { $format = apply_filters( 'gravityview/widgets/search/datepicker/format', $default_format ); $gf_date_formats = array( - 'mdy' => 'm/d/Y', + 'mdy' => 'm/d/Y', - 'dmy_dash' => 'd-m-Y', - 'dmy_dot' => 'd.m.Y', - 'dmy' => 'd/m/Y', + 'dmy_dash' => 'd-m-Y', + 'dmy_dot' => 'd.m.Y', + 'dmy' => 'd/m/Y', 'ymd_slash' => 'Y/m/d', - 'ymd_dash' => 'Y-m-d', - 'ymd_dot' => 'Y.m.d', + 'ymd_dash' => 'Y-m-d', + 'ymd_dot' => 'Y.m.d', ); if ( ! $date_format ) { @@ -2113,7 +2186,7 @@ private function get_datepicker_format( $date_format = false ) { public function add_preview_inputs() { global $wp; - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { return; } @@ -2121,7 +2194,6 @@ public function add_preview_inputs() { foreach ( $wp->query_vars as $key => $value ) { printf( '', esc_attr( $key ), esc_attr( $value ) ); } - } /** @@ -2143,7 +2215,8 @@ private function get_operator( $get, $key, $allowed, $default ) { $allowed = apply_filters_deprecated( 'gravityview/search/operator_whitelist', array( $allowed, $key ), '2.14', 'gravityview/search/operator_allowlist' ); /** - * @filter `gravityview/search/operator_allowlist` An array of allowed operators for a field. + * An array of allowed operators for a field. + * * @since 2.14 * @param string[] An allowlist of operators. * @param string The filter name. @@ -2156,11 +2229,9 @@ private function get_operator( $get, $key, $allowed, $default ) { return $operator; } - - } // end class -new GravityView_Widget_Search; +new GravityView_Widget_Search(); if ( ! gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { return; @@ -2172,29 +2243,36 @@ private function get_operator( $get, $key, $allowed, $default ) { class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { public function __construct( $filter, $view ) { $this->value = $filter['value']; - $this->view = $view; + $this->view = $view; } public function sql( $query ) { global $wpdb; $user_meta_fields = array( - 'nickname', 'first_name', 'last_name', + 'nickname', + 'first_name', + 'last_name', ); /** - * @filter `gravityview/widgets/search/created_by/user_meta_fields` Filter the user meta fields to search. + * Filter the user meta fields to search. + * * @param array The user meta fields. * @param \GV\View $view The view. */ $user_meta_fields = apply_filters( 'gravityview/widgets/search/created_by/user_meta_fields', $user_meta_fields, $this->view ); $user_fields = array( - 'user_nicename', 'user_login', 'display_name', 'user_email', + 'user_nicename', + 'user_login', + 'display_name', + 'user_email', ); /** - * @filter `gravityview/widgets/search/created_by/user_fields` Filter the user fields to search. + * Filter the user fields to search. + * * @param array The user fields. * @param \GV\View $view The view. */ @@ -2203,11 +2281,11 @@ public function sql( $query ) { $conditions = array(); foreach ( $user_fields as $user_field ) { - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); + $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); } foreach ( $user_meta_fields as $meta_field ) { - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); + $conditions[] = $wpdb->prepare( '(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)', $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); } $conditions = '(' . implode( ' OR ', $conditions ) . ')'; diff --git a/includes/widgets/search-widget/index.php b/includes/widgets/search-widget/index.php index e71af0ef21..8142269b13 100644 --- a/includes/widgets/search-widget/index.php +++ b/includes/widgets/search-widget/index.php @@ -1 +1 @@ -getViewId(); -$search_field = $gravityview_view->search_field; +$view_id = $gravityview_view->getViewId(); +$search_field = $gravityview_view->search_field; if ( ! class_exists( 'GF_Chained_Field_Select' ) ) { gravityview()->log->error( 'The Gravity Forms Chained Select Add-On is not active.' ); @@ -19,7 +19,7 @@ } // Make sure that there are choices to display -if( empty( $search_field['choices'] ) ) { +if ( empty( $search_field['choices'] ) ) { gravityview()->log->debug( 'search-field-chainedselect.php - No choices for field' ); return; } @@ -33,6 +33,7 @@ /** * Prevent Chained Select Search Bar input fields from outputting styles. + * * @since 2.14.4 * @param GravityView_Widget_Search $this GravityView Widget instance * @param array{key:string,label:string,value:string,type:string,choices:array} $search_field @@ -41,6 +42,7 @@ /** * Choose whether to hide inactive dropdowns in the chain. + * * @since 2.14.4 * @param bool $hide_inactive Whether to hide drop-downs that aren't available yet. * @param GravityView_Widget_Search $this GravityView Widget instance @@ -52,16 +54,19 @@ $gf_field->chainedSelectsAlignment = $gravityview_view->search_layout; ?> ', array( + echo strtr( + '
{input}
', + array( '{form_id}' => $form->ID, '{field_id}' => $field->ID, '{input}' => $gf_field->get_field_input( $form->form, GravityView_Plugin_Hooks_Gravity_Forms_Chained_Selects::get_field_values( $gf_field ) ), - ) ); + ) + ); ?>
diff --git a/includes/widgets/search-widget/templates/search-field-checkbox.php b/includes/widgets/search-widget/templates/search-field-checkbox.php index b3249796ff..d57aa4b3ef 100644 --- a/includes/widgets/search-widget/templates/search-field-checkbox.php +++ b/includes/widgets/search-widget/templates/search-field-checkbox.php @@ -6,25 +6,25 @@ */ $gravityview_view = GravityView_View::getInstance(); -$view_id = $gravityview_view->getViewId(); -$search_field = $gravityview_view->search_field; +$view_id = $gravityview_view->getViewId(); +$search_field = $gravityview_view->search_field; // Make sure that there are choices to display -if( empty( $search_field['choices'] ) ) { +if ( empty( $search_field['choices'] ) ) { gravityview()->log->debug( 'search-field-checkbox.php - No choices for field' ); return; } ?>