diff --git a/.circleci/config.yml b/.circleci/config.yml index 16c38cc42..5301267ec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -138,4 +138,3 @@ workflows: - run_php_72_unit_tests - run_php_80_unit_tests # - run_acceptance_tests - diff --git a/assets/css/admin-global.css b/assets/css/admin-global.css index 29220307e..e0c462b78 100644 --- a/assets/css/admin-global.css +++ b/assets/css/admin-global.css @@ -1 +1 @@ -@font-face{font-family:"gravityview";src:url("../fonts/gravityview.eot");src:url("../fonts/gravityview.eot?#iefix") format("embedded-opentype"),url("../fonts/gravityview.woff") format("woff"),url("../fonts/gravityview.ttf") format("truetype"),url("../fonts/gravityview.svg#gravityview") format("svg");font-weight:normal;font-style:normal}a.icon{text-decoration:none}[data-gv-icon]:before{font-family:"gravityview" !important;content:attr(data-gv-icon);font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gv-icon__before,#toplevel_page_gravityview_settings .wp-menu-image:before,#adminmenu .menu-icon-gravityview div.wp-menu-image:before,#available-widgets [class*=gv_recent_entries] .widget-title:before,#available-widgets [class*=gravityview_search] .widget-title:before,[class^="gv-icon-"]:before,[class*=" gv-icon-"]:before{font-family:"gravityview" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gv-icon-astronaut-head__before,#toplevel_page_gravityview_settings .wp-menu-image:before,#adminmenu .menu-icon-gravityview div.wp-menu-image:before,#available-widgets [class*=gv_recent_entries] .widget-title:before,#available-widgets [class*=gravityview_search] .widget-title:before,.gv-icon-astronaut-head:before{content:"\61"}.gv-icon-astronaut:before{content:"\62"}.gv-icon-datatables-icon:before{content:"\63"}.gv-icon-caret-up-down:before{content:"\64"}.gv-icon-minus-square:before{content:"\66"}.gv-icon-plus-square:before{content:"\67"}.gv-icon-level-down:before{content:"\65"}.gv-icon-sort-asc:before{content:"\68"}.gv-icon-sort-desc:before{content:"\69"}.gv-icon-number-one:before{content:"\6a"}.gv-icon-question-circle:before{content:"\6b"}.members-tab-title a[href$="type-gravityview"]{display:none !important}.members-tab-title .gv-icon-astronaut-head{font-size:20px;width:20px;line-height:20px;margin-right:6.25px;display:block;float:left}#hs-beacon iframe[style*="max-height"],#beacon-container iframe[style*="max-height"]{z-index:10010 !important}.admin-bar #hs-beacon iframe[style*="bottom: 0"],.admin-bar #beacon-container iframe[style*="bottom: 0"]{padding-top:32px}#hs-beacon iframe[data-reactid-hs=".0.0"],#beacon-container iframe[data-reactid-hs=".0.0"]{right:-5px !important;bottom:-5px !important}.rtl #hs-beacon iframe[data-reactid-hs=".0.0"],.rtl #beacon-container iframe[data-reactid-hs=".0.0"]{right:auto !important;left:-5px !important}#menu-posts-gravityview .wp-submenu .dashicons{padding:0 .2em}.wp-editor-tools #add_gravityview{width:auto}.gravitykit_page_gv-getting-started .about-wrap .feature-video iframe,.post-type-gravityview .about-wrap .feature-video iframe{width:100%;max-width:560px}.gravitykit_page_gv-getting-started .about-wrap .feature-video .button-hero,.post-type-gravityview .about-wrap .feature-video .button-hero{font-size:22px;max-width:100%;overflow:hidden;-o-text-overflow:ellipsis;text-overflow:ellipsis;height:auto}.gravitykit_page_gv-getting-started .about-wrap .feature-section.three-col .col,.post-type-gravityview .about-wrap .feature-section.three-col .col{-webkit-flex-basis:30%;-ms-flex-preferred-size:30%;flex-basis:30%;max-width:250px}.gravitykit_page_gv-getting-started .about-wrap .feature-section img,.post-type-gravityview .about-wrap .feature-section img{border:1px solid #ccc;max-width:99%}#wpwrap .gv_connected_forms .gv-icon{font-size:19px;height:19px;width:20px;display:inline-block}#wpwrap .gv_connected_forms .gv-create-view:before{content:"\f132";display:inline-block;font-weight:normal;font-size:20px;font-family:dashicons !important;line-height:20px !important;margin:0 auto;padding:0;position:relative;text-align:center;width:20px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpwrap .gv_connected_forms .hidden{display:none !important}#wpwrap .gv_connected_forms .gf_submenu{min-width:150px;max-width:100%}#wpwrap .gv_connected_forms li a{width:auto}.gf-popover__button[data-url="#gravityview-group-heading"]{font-weight:500;color:#40464d;padding-top:12px;padding-bottom:6px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;cursor:default !important}.gf-popover__button__icon:empty{display:none}.gf-popover__button[data-url="#gravityview-group-heading"]:hover{background:white;color:#40464d}.post-type-gravityview .changelog ul,.gravitykit_page_gv-changelog .changelog ul{list-style-type:square}.post-type-gravityview .changelog ul ul,.gravitykit_page_gv-changelog .changelog ul ul{list-style:circle;margin:.5em 0 .5em 1.3em}.gv-entry-creator-dropdown .select2-search__field{padding:0 4px 0 4px}.gv-entry-creator-dropdown.gf25 .select2-search__field{line-height:1.25rem;padding:.6875rem 1rem}.gv-entry-creator-dropdown.gf25.select2-dropdown--below{border-top:initial;margin-top:-8px}.gv-entry-creator-container.select2-container--default.gf25{min-height:4em}.gv-entry-creator-container.select2-container--default.gf25 .select2-selection__arrow{display:none}.gv-entry-creator-container.select2-container--default.gf25 .select2-selection__rendered{margin:-1px}.gv-shortcode{position:relative}.gv-shortcode .dashicons-editor-code{color:#888;left:-1px;font-size:20px;line-height:1}html[dir=rtl] .gv-shortcode .dashicons-editor-code{left:auto;right:-1px}html[dir=rtl] .gv-shortcode .code.widefat{text-align:right}.gv-shortcode input.code{cursor:pointer}.gv-shortcode span.copied{display:none;position:absolute;top:30px;right:15px;background-color:#000;color:#FFF;padding:2px 5px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.wp-list-table .gv-shortcode span.copied{top:3px;right:3px} +@font-face{font-family:"gravityview";src:url("../fonts/gravityview.eot");src:url("../fonts/gravityview.eot?#iefix") format("embedded-opentype"),url("../fonts/gravityview.woff") format("woff"),url("../fonts/gravityview.ttf") format("truetype"),url("../fonts/gravityview.svg#gravityview") format("svg");font-weight:normal;font-style:normal}a.icon{text-decoration:none}[data-gv-icon]:before{font-family:"gravityview" !important;content:attr(data-gv-icon);font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gv-icon__before,#toplevel_page_gravityview_settings .wp-menu-image:before,#adminmenu .menu-icon-gravityview div.wp-menu-image:before,#available-widgets [class*=gv_recent_entries] .widget-title:before,#available-widgets [class*=gravityview_search] .widget-title:before,[class^="gv-icon-"]:before,[class*=" gv-icon-"]:before{font-family:"gravityview" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gv-icon-astronaut-head__before,#toplevel_page_gravityview_settings .wp-menu-image:before,#adminmenu .menu-icon-gravityview div.wp-menu-image:before,#available-widgets [class*=gv_recent_entries] .widget-title:before,#available-widgets [class*=gravityview_search] .widget-title:before,.gv-icon-astronaut-head:before{content:"\61"}.gv-icon-astronaut:before{content:"\62"}.gv-icon-datatables-icon:before{content:"\63"}.gv-icon-caret-up-down:before{content:"\64"}.gv-icon-minus-square:before{content:"\66"}.gv-icon-plus-square:before{content:"\67"}.gv-icon-level-down:before{content:"\65"}.gv-icon-sort-asc:before{content:"\68"}.gv-icon-sort-desc:before{content:"\69"}.gv-icon-number-one:before{content:"\6a"}.gv-icon-question-circle:before{content:"\6b"}.members-tab-title a[href$="type-gravityview"]{display:none !important}.members-tab-title .gv-icon-astronaut-head{font-size:20px;width:20px;line-height:20px;margin-right:6.25px;display:block;float:left}#hs-beacon iframe[style*="max-height"],#beacon-container iframe[style*="max-height"]{z-index:10010 !important}.admin-bar #hs-beacon iframe[style*="bottom: 0"],.admin-bar #beacon-container iframe[style*="bottom: 0"]{padding-top:32px}#hs-beacon iframe[data-reactid-hs=".0.0"],#beacon-container iframe[data-reactid-hs=".0.0"]{right:-5px !important;bottom:-5px !important}.rtl #hs-beacon iframe[data-reactid-hs=".0.0"],.rtl #beacon-container iframe[data-reactid-hs=".0.0"]{right:auto !important;left:-5px !important}#menu-posts-gravityview .wp-submenu .dashicons{padding:0 .2em}.wp-editor-tools #add_gravityview{width:auto}.gravitykit_page_gv-getting-started .about-wrap .feature-video iframe,.post-type-gravityview .about-wrap .feature-video iframe{width:100%;max-width:560px}.gravitykit_page_gv-getting-started .about-wrap .feature-video .button-hero,.post-type-gravityview .about-wrap .feature-video .button-hero{font-size:22px;max-width:100%;overflow:hidden;-o-text-overflow:ellipsis;text-overflow:ellipsis;height:auto}.gravitykit_page_gv-getting-started .about-wrap .feature-section.three-col .col,.post-type-gravityview .about-wrap .feature-section.three-col .col{-webkit-flex-basis:30%;-ms-flex-preferred-size:30%;flex-basis:30%;max-width:250px}.gravitykit_page_gv-getting-started .about-wrap .feature-section img,.post-type-gravityview .about-wrap .feature-section img{border:1px solid #ccc;max-width:99%}#wpwrap .gv_connected_forms .gv-icon{font-size:19px;height:19px;width:20px;display:inline-block}#wpwrap .gv_connected_forms .gv-create-view:before{content:"\f132";display:inline-block;font-weight:normal;font-size:20px;font-family:dashicons !important;line-height:20px !important;margin:0 auto;padding:0;position:relative;text-align:center;width:20px;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpwrap .gv_connected_forms .hidden{display:none !important}#wpwrap .gv_connected_forms .gf_submenu{min-width:150px;max-width:100%}#wpwrap .gv_connected_forms li a{width:auto}.gf-popover__button[data-url="#gravityview-group-heading"]{font-weight:500;color:#40464d;padding-top:12px;padding-bottom:6px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;cursor:default !important}.gf-popover__button__icon:empty{display:none}.gf-popover__button[data-url="#gravityview-group-heading"]:hover{background:white;color:#40464d}.post-type-gravityview .changelog ul,.gravitykit_page_gv-changelog .changelog ul{list-style-type:square}.post-type-gravityview .changelog ul ul,.gravitykit_page_gv-changelog .changelog ul ul{list-style:circle;margin:.5em 0 .5em 1.3em}.gv-entry-creator-dropdown .select2-search__field{padding:0 4px 0 4px}.gv-entry-creator-dropdown.gf25 .select2-search__field{line-height:1.25rem;padding:.6875rem 1rem}.gv-entry-creator-dropdown.gf25.select2-dropdown--below{border-top:initial;margin-top:-8px}.gv-entry-creator-container.select2-container--default.gf25{min-height:4em}.gv-entry-creator-container.select2-container--default.gf25 .select2-selection__arrow{display:none}.gv-entry-creator-container.select2-container--default.gf25 .select2-selection__rendered{margin:-1px}.gv-fields.csv-disabled{cursor:not-allowed}.gv-fields.csv-disabled .csv-disabled-notice{display:block}.gv-fields.csv-disabled .gv-field-label,.gv-fields.csv-disabled .gv-field-controls button{color:#d7dade !important}.ui-tooltip-content .gv-items-picker-container.gv-widget-picker-container .gv-fields.csv-disabled{display:none}.gv-shortcode{position:relative}.gv-shortcode .dashicons-editor-code{color:#888;left:-1px;font-size:20px;line-height:1}html[dir=rtl] .gv-shortcode .dashicons-editor-code{left:auto;right:-1px}html[dir=rtl] .gv-shortcode .code.widefat{text-align:right}.gv-shortcode input.code{cursor:pointer}.gv-shortcode span.copied{display:none;position:absolute;top:30px;right:15px;background-color:#000;color:#FFF;padding:2px 5px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.wp-list-table .gv-shortcode span.copied{top:3px;right:3px} diff --git a/assets/css/scss/admin-global.scss b/assets/css/scss/admin-global.scss index 1c86169b5..d08026d61 100644 --- a/assets/css/scss/admin-global.scss +++ b/assets/css/scss/admin-global.scss @@ -173,6 +173,23 @@ } +.gv-fields.csv-disabled { + cursor: not-allowed; + + .csv-disabled-notice { + display: block; + } + .gv-field-label, + .gv-field-controls button { + color: #d7dade !important; + } + + .ui-tooltip-content .gv-items-picker-container.gv-widget-picker-container & { + display: none; + } +} + + /** The "Embed Shortcode" section in the Publish metabox */ .gv-shortcode { .dashicons-editor-code { diff --git a/assets/js/admin-shortcode.min.js b/assets/js/admin-shortcode.min.js index 68212e853..73bb28334 100644 --- a/assets/js/admin-shortcode.min.js +++ b/assets/js/admin-shortcode.min.js @@ -1 +1 @@ -!function($){$(document).on("ready",function(){new ClipboardJS(".gv-shortcode input.code",{text:function(trigger){return $(trigger).val()}}),$(".gv-shortcode input.code").on("click",function(e){e.preventDefault();var $el=$(this).closest(".gv-shortcode").find(".copied");$el.show(),setTimeout(function(){$el.fadeOut()},1e3)})})}(jQuery); \ No newline at end of file +!function($){$(document).on("ready",function(){new ClipboardJS(".gv-shortcode input.code",{text:function(trigger){return $(trigger).val()}}).on("success",function(e){var $el=$(e.trigger).closest(".gv-shortcode").find(".copied");$el.show(),setTimeout(function(){$el.fadeOut()},1e3)}),$(".gv-shortcode input.code").on("keydown",function(e){"Enter"===e.key&&(e.preventDefault(),$(this).trigger("click"))})})}(jQuery); \ No newline at end of file diff --git a/assets/js/admin-views.js b/assets/js/admin-views.js index 2602f6671..94dd84e5d 100644 --- a/assets/js/admin-views.js +++ b/assets/js/admin-views.js @@ -2815,4 +2815,22 @@ $( document.body ).trigger( 'gravityview/loaded' ); } ); + + /** + * Handles CSV widget classes. + * @since $ver$ + */ + $( function () { + const $csv_enable = $( '#gravityview_se_csv_enable' ); + const update_csv_widget_classes = function () { + $( '[data-fieldid="export_link"]' ) + .toggleClass( 'csv-disabled', !$csv_enable.is( ':checked' ) ) + .attr( 'aria-disabled', $csv_enable.is( ':checked' ) ? 'false' : 'true' ) + ; + }; + + $csv_enable.on( 'change', update_csv_widget_classes ); + update_csv_widget_classes(); + } ); + }(jQuery)); diff --git a/assets/js/admin-views.min.js b/assets/js/admin-views.min.js index 66db2ec66..036765a9d 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),$(document.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-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}),$(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).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-no-link").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||(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-no-link").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||(0custom_label ) ) { - return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ? : null : null, $entry ? $entry->as_entry() : null ); + return \GravityView_API::replace_variables( + $this->custom_label, + $source ? $source->form ?? null : null, + $entry ? $entry->as_entry() : null + ); } return ''; diff --git a/future/includes/rest/class-gv-rest-views-route.php b/future/includes/rest/class-gv-rest-views-route.php index f9204a668..2d735398b 100644 --- a/future/includes/rest/class-gv-rest-views-route.php +++ b/future/includes/rest/class-gv-rest-views-route.php @@ -10,6 +10,9 @@ */ namespace GV\REST; +use GravityView_Widget_Export_Link; +use WP_REST_Request; + /** If this file is called directly, abort. */ if ( ! defined( 'GRAVITYVIEW_DIR' ) ) { die(); @@ -36,6 +39,23 @@ class Views_Route extends Route { protected $sub_type = 'entries'; + /** + * Whether the headers are rendered. + * + * @since $ver$ + * @var bool + */ + private $headers_done; + + /** + * The headers for the output. + * + * @since $ver$ + * @var array + */ + private $headers = []; + + /** * Get a collection of views * @@ -150,8 +170,10 @@ function ( $field ) use ( $allowed_field_ids ) { $used_ids = array(); foreach ( $allowed as $field ) { - $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); + // remove all links from output. + $field->update_configuration( [ 'show_as_link' => '0' ] ); + $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); $field_id = $field->ID; $index = null; @@ -171,14 +193,26 @@ function ( $field ) use ( $allowed_field_ids ) { /** * Filter the key name in the results for JSON output. * - * @param string $field_id The ID. Should be unique or keys will be gobbled up. - * @param \GV\View $view The view. - * @param \GV\Entry $entry The entry. - * @param \WP_REST_Request $request Request object. - * @param string $context The context (directory, single) + * @param string $field_id The ID. Should be unique or keys will be gobbled up. + * @param \GV\View $view The view. + * @param \GV\Entry $entry The entry. + * @param \WP_REST_Request $request Request object. + * @param string $context The context (directory, single) */ $field_id = apply_filters( 'gravityview/api/field/key', $field_id, $view, $entry, $request, $context ); + if ( ! $this->headers_done ) { + $label = $field->get_label( $view, $source, $entry ); + if ( ! $label ) { + $label = $field_id; + } + + $this->headers[] = [ + 'field_id' => $field_id, + 'label' => $label, + ]; + } + if ( ! $class && in_array( $field->ID, array( 'custom' ) ) ) { /** * Custom fields (and perhaps some others) will require rendering as they don't @@ -294,21 +328,25 @@ function ( $context ) use ( &$count, &$total ) { $csv_or_tsv = fopen( 'php://output', 'w' ); + $filename = apply_filters( 'gravityview/output/' . $format . '/filename', get_the_title( $view->post ), $view ); + /** Da' BOM :) */ if ( apply_filters( 'gform_include_bom_export_entries', true, $view->form ? $view->form->form : null ) ) { fputs( $csv_or_tsv, "\xef\xbb\xbf" ); } - $headers_done = false; + $this->headers_done = false; + $this->headers = []; - // If not "tsv" then use comma + // If not "tsv" then use comma. $delimiter = ( 'tsv' === $format ) ? "\t" : ','; foreach ( $entries->all() as $entry ) { $entry = $this->prepare_entry_for_response( $view, $entry, $request, 'directory', '\GV\Field_CSV_Template' ); + $label = $request->get_param( 'use_labels' ) ? 'label' : 'field_id'; - if ( ! $headers_done ) { - $headers_done = fputcsv( $csv_or_tsv, array_map( array( '\GV\Utils', 'strip_excel_formulas' ), array_keys( $entry ) ), $delimiter ); + if ( ! $this->headers_done ) { + $this->headers_done = false !== fputcsv( $csv_or_tsv, array_map( array( '\GV\Utils', 'strip_excel_formulas' ), array_column( $this->headers, $label ) ), $delimiter ); } fputcsv( $csv_or_tsv, array_map( array( '\GV\Utils', 'strip_excel_formulas' ), $entry ), $delimiter ); @@ -318,6 +356,8 @@ function ( $context ) use ( &$count, &$total ) { $response->header( 'X-Item-Count', $entries->count() ); $response->header( 'X-Item-Total', $entries->total() ); $response->header( 'Content-Type', 'text/' . $format ); + $response->header( 'Content-Transfer-Encoding', 'binary' ); + $response->header( 'Content-Disposition', sprintf( 'attachment;filename="%s.%s"', sanitize_file_name( $filename ), $format ) ); fflush( $csv_or_tsv ); @@ -526,8 +566,36 @@ public function get_items_permissions_check( $request ) { return true; } + /** + * Permission check for the REST endpoint. + * + * @param WP_REST_Request $request The request object. + * + * @return bool|\WP_Error The permission result. + */ public function get_sub_items_permissions_check( $request ) { - // Accessing all entries of a View needs the same permissions as accessing the View. + // Make sure to get the format from the URL. + $params = $request->get_url_params(); + $format = strtolower( rgar( $params, 'format', '' ) ); + $nonce = $request->get_param( '_nonce' ); + $view_id = rgar( $params, 'id', 0 ); + + if ( ! $view = \GV\View::by_id( $view_id ) ) { + return new \WP_Error( 'rest_forbidden', __( 'You are not allowed to access this content.', 'gk-gravityview' ) ); + } + + if ( + '1' === $view->settings->get( 'csv_enable' ) + && in_array( $format, [ 'csv', 'tsv' ], true ) + && wp_verify_nonce( $nonce, sprintf( '%s.%d', GravityView_Widget_Export_Link::WIDGET_ID, $view->ID ) ) + ) { + // All results. + $request->set_param( 'limit', 0 ); + + // The current request is a nonce verified CSV download request. + return true; + } + return $this->get_item_permissions_check( $request ); } } diff --git a/includes/plugin-and-theme-hooks/class-gravityview-plugin-hooks-lifterlms.php b/includes/plugin-and-theme-hooks/class-gravityview-plugin-hooks-lifterlms.php index bb0991f98..6d9e6df71 100644 --- a/includes/plugin-and-theme-hooks/class-gravityview-plugin-hooks-lifterlms.php +++ b/includes/plugin-and-theme-hooks/class-gravityview-plugin-hooks-lifterlms.php @@ -364,7 +364,7 @@ public function get_integration_settings() { return [ [ 'type' => 'custom-html', - 'value' => '

' . esc_html__( 'No Views found.', 'gravityview' ) . '

', + 'value' => '

' . esc_html__( 'No Views found.', 'gk-gravityview' ) . '

', ], ]; } diff --git a/includes/widgets/class-gravityview-widget-export-link.php b/includes/widgets/class-gravityview-widget-export-link.php new file mode 100644 index 000000000..4c6793cf9 --- /dev/null +++ b/includes/widgets/class-gravityview-widget-export-link.php @@ -0,0 +1,235 @@ + [ + 'label' => __( 'Type', 'gk-gravityview' ), + 'type' => 'radio', + 'choices' => [ + 'csv' => 'CSV', + 'tsv' => 'TSV', + ], + 'value' => $defaults['type'], + ], + 'title' => [ + 'type' => 'text', + 'class' => 'widefat', + 'label' => __( 'Label', 'gk-gravityview' ), + 'desc' => __( 'Enter the label of the link.', 'gk-gravityview' ), + 'value' => $defaults['title'], + 'merge_tags' => false, + ], + 'in_paragraph' => [ + 'type' => 'checkbox', + 'label' => __( 'Wrap link in paragraph', 'gk-gravityview' ), + // translators: %s is replaced by a code block. + 'desc' => sprintf( esc_html__( 'Will wrap the link in a paragraph HTML tag (%s).', 'gk-gravityview' ), '<p>' ), + ], + 'use_labels' => [ + 'type' => 'checkbox', + 'label' => __( 'Use labels instead of field IDs', 'gk-gravityview' ), + 'desc' => __( 'The headers of the file will use the labels instead of the field IDs', 'gk-gravityview' ), + 'value' => $defaults['use_labels'], + ], + 'classes' => [ + 'type' => 'text', + 'class' => 'widefat', + 'label' => __( 'Custom CSS Class:', 'gk-gravityview' ), + 'desc' => __( 'This class will be added to the widget container', 'gk-gravityview' ), + ], + ]; + } + + /** + * Returns the default settings. + * + * @since $ver$ + */ + private static function defaults(): array { + return [ + 'title' => __( 'Download CSV', 'gk-gravityview' ), + 'type' => 'csv', + 'use_labels' => true, + ]; + } + + /** + * @inheritDoc + * @since $ver$ + */ + public function __construct() { + $this->widget_short = esc_html__( 'Insert a link to download a CSV or TSV of the current View results.', 'gk-gravityview' ); + $disabled_warning = esc_html__( 'To use this feature, you must enable the "Allow Export" setting for this View. This setting is located in the Permissions tab of the Settings section.', 'gk-gravityview' ); + $all_entries_notice = esc_html__( 'Note: All matching entries will be downloaded in the generated file.', 'gk-gravityview' ); + + $this->widget_description = <<{$this->widget_short}

+ +

{$all_entries_notice}

+HTML; + parent::__construct( 'Export Link', self::WIDGET_ID, self::defaults(), self::settings() ); + + add_filter( 'gravityview_admin_label_item_info', [ $this, 'hide_description_picker' ], 10, 2 ); + } + + /** + * Removes the notification part from the description. + * + * @since $ver$ + * + * @param array $items The description items. + * @param GravityView_Admin_View_Item $view_item The view item. + * + * @return array The adjusted description items. + */ + public function hide_description_picker( array $items, GravityView_Admin_View_Item $view_item ): array { + if ( + ! $view_item instanceof GravityView_Admin_View_Widget + || GV\Utils::get( $items[0] ?? [], 'value' ) !== $this->widget_description + ) { + return $items; + } + + $items[0]['value'] = $this->widget_short; + + return $items; + } + + /** + * @inheritDoc + * @since $ver$ + */ + public function render_frontend( $widget_args, $content = '', $context = '' ): void { + global $wp_query; + + if ( + ! $context instanceof Template_Context + || ! $this->pre_render_frontend( $context ) + ) { + return; + } + + $view = $context->view; + $nonce = $this->get_nonce( $view ); + if ( + ! $nonce + || ! $view->settings->get( 'csv_enable' ) + ) { + return; + } + + $available_types = [ 'csv', 'tsv' ]; + $type = strtolower( GV\Utils::get( $widget_args, 'type', 'csv' ) ); + if ( ! in_array( $type, $available_types, true ) ) { + $type = 'csv'; + } + $mime_type = 'csv' === $type ? 'text/csv' : 'text/tab-separated-values'; + + $label = GV\Utils::get( $widget_args, 'title', 'Download CSV' ); + $in_paragraph = (bool) GV\Utils::get( $widget_args, 'in_paragraph', false ); + $use_labels = (bool) GV\Utils::get( $widget_args, 'use_labels', false ); + $classes = (string) GV\Utils::get( $widget_args, 'classes', '' ); + + $page_query_params = array_filter( + $_GET, + static function ( $value, string $key ): bool { + return 'mode' === $key || preg_match( '/^filter_?/i', $key ); + }, + ARRAY_FILTER_USE_BOTH + ); + + /** + * In order to provide easier JS modification of the URL, we provide both the base URL and the full URL. + */ + $rest_nonce_url = sprintf( '%sgravityview/v1/views/%d/entries.%s', get_rest_url(), $view->ID, $type ); + $rest_nonce_url = add_query_arg( [ + '_nonce' => $nonce, + 'use_labels' => $use_labels, + ], $rest_nonce_url ); + + $rest_url = add_query_arg( + $page_query_params, + $rest_nonce_url + ); + + $link = strtr( '{label}', [ + '{url}' => esc_url( $rest_url ), + '{nonce_url}' => esc_url( $rest_nonce_url ), + '{mime_type}' => $mime_type, + '{label}' => esc_html( $label ), + ] ); + + $link = $in_paragraph ? sprintf( '

%s

', $link ) : $link; + + printf( '', gravityview_sanitize_html_class( $classes ) ); + } + + /** + * Create a nonce for a guest, as the REST API is stateless. + * + * @since $ver$ + * + * @param View|null $view The view object. + * + * @return string The nonce. + */ + private function get_nonce( $view ): string { + if ( ! $view instanceof View ) { + return ''; + } + + $user_id = wp_get_current_user()->ID; + if ( $user_id ) { + wp_set_current_user( 0 ); + } + + $nonce = wp_create_nonce( sprintf( '%s.%d', $this->get_widget_id(), $view->ID ) ); + + if ( $user_id ) { + wp_set_current_user( $user_id ); + } + + return $nonce ?: ''; + } +} + +new GravityView_Widget_Export_Link(); diff --git a/includes/widgets/register-gravityview-widgets.php b/includes/widgets/register-gravityview-widgets.php index 6f4482ebb..e71bb813f 100644 --- a/includes/widgets/register-gravityview-widgets.php +++ b/includes/widgets/register-gravityview-widgets.php @@ -21,6 +21,7 @@ function gravityview_register_gravityview_widgets() { include_once GRAVITYVIEW_DIR . 'includes/widgets/search-widget/class-search-widget.php'; include_once GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-custom-content.php'; + include_once GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-export-link.php'; include_once GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-gravityforms.php'; include_once GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-page-size.php'; include_once GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget-pagination-info.php'; diff --git a/readme.txt b/readme.txt index 31f66096a..1946499d0 100644 --- a/readme.txt +++ b/readme.txt @@ -23,11 +23,13 @@ Beautifully display your Gravity Forms entries. Learn more on [gravitykit.com](h = 2.21 [unreleased] = +* Added: A widget to export all entries as CSV or TSV. * Added: Support for SVG images. * Added: Search Bar support for Gravity Flow "Workflow User" and "Workflow Multi-User" fields. * Added: Integration with LifterLMS: Embed Views inside your LifterLMS Student Dashboards. * Fixed: PHP 8.2 deprecation notices. -* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.11 +* Fixed: Entry Link field values were wrapped in `` HTML tags. +* Updated: [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.11. - GravityKit product updates are now showing on the Plugins page. - Database options that are no longer used are now automatically removed. @@ -48,6 +50,9 @@ This release enhances performance by optimizing caching and managing transients #### 🔧 Updated * Updated [Foundation](https://www.gravitykit.com/foundation/) to version 1.2.10. - Transients are no longer autoloaded. +Improved: The database now stores fewer cache records due to enhanced detection of duplicate queries. +Added: a widget to quickly download as a CSV. +Fixed: No entry link on CSV output. = 2.20.1 on February 29, 2024 = diff --git a/tests/unit-tests/GravityView_20_Issues.php b/tests/unit-tests/GravityView_20_Issues.php index cd351c724..3ff72c32e 100644 --- a/tests/unit-tests/GravityView_20_Issues.php +++ b/tests/unit-tests/GravityView_20_Issues.php @@ -79,7 +79,7 @@ public function test_search_widget_embedded() { $content = apply_filters( 'the_content', $post->post_content ); - $this->assertContains( get_permalink( $post->ID ), $content ); + $this->assertStringContainsString( get_permalink( $post->ID ), $content ); } /** @@ -258,8 +258,8 @@ function test_shortcode_search_value_search_filter() { $content = apply_filters( 'the_content', $post->post_content ); - $this->assertContains( 'no-no-no', $content ); - $this->assertNotContains( 'yes-yes-yes', $content ); + $this->assertStringContainsString( 'no-no-no', $content ); + $this->assertStringNotContainsString( 'yes-yes-yes', $content ); } /** @@ -303,9 +303,9 @@ public function test_merge_tags_in_labels() { $output = $renderer->render( $entry, $view ); - $this->assertContains( 'Content: 12345678 Entry: Just some entry', $output ); - $this->assertContains( 'Textarea with entry Just some entry', $output ); - $this->assertContains( 'Label: 12345678 Entry: Just some entry', $output ); + $this->assertStringContainsString( 'Content: 12345678 Entry: Just some entry', $output ); + $this->assertStringContainsString( 'Textarea with entry Just some entry', $output ); + $this->assertStringContainsString( 'Label: 12345678 Entry: Just some entry', $output ); } /** @@ -382,8 +382,8 @@ public function test_hide_until_searched_widgets() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Search Entries', $future ); - $this->assertContains( 'Here we go again! Now', $future ); + $this->assertStringContainsString( 'Search Entries', $future ); + $this->assertStringContainsString( 'Here we go again! Now', $future ); remove_all_filters( 'gravityview/view/anchor_id' ); remove_all_filters( 'gravityview/widget/search/append_view_id_anchor' ); @@ -466,7 +466,7 @@ public function test_view_in_view_embedded() { 'id' => $another_view->ID, ); - $this->assertContains( 'Embed this view', $future->callback( $args ) ); + $this->assertStringContainsString( 'Embed this view', $future->callback( $args ) ); global $post; @@ -474,7 +474,7 @@ public function test_view_in_view_embedded() { gravityview()->request->returns['is_entry'] = $another_entry; - $this->assertContains( 'Embed this view', $future->callback( $args ) ); + $this->assertStringContainsString( 'Embed this view', $future->callback( $args ) ); $this->_reset_context(); } @@ -513,8 +513,8 @@ public function test_is_approved_field_values() { $output = $renderer->render( $entry, $view ); - $this->assertContains( 'Unapproved', $output ); - $this->assertContains( 'Nicht bestätigt', $output ); + $this->assertStringContainsString( 'Unapproved', $output ); + $this->assertStringContainsString( 'Nicht bestätigt', $output ); } /** @@ -591,10 +591,10 @@ public function test_fileupload_download_link_index_php_detection() { $files[0] = $field->field->get_download_url( $files[0] ); $files[1] = $field->field->get_download_url( $files[1] ); - $this->assertContains( 'index.php', $files[0] ); - $this->assertContains( 'one.jpg', $files[0] ); - $this->assertContains( 'index.php', $files[1] ); - $this->assertContains( 'two.mp3', $files[1] ); + $this->assertStringContainsString( 'index.php', $files[0] ); + $this->assertStringContainsString( 'one.jpg', $files[0] ); + $this->assertStringContainsString( 'index.php', $files[1] ); + $this->assertStringContainsString( 'two.mp3', $files[1] ); $output = $renderer->render( $field, $view, $form, $entry, $request ); @@ -602,10 +602,10 @@ public function test_fileupload_download_link_index_php_detection() { $expected .= '
  • '; $expected .= '
  • '; - $this->assertContains( $expected, $output ); - $this->assertContains( '' . esc_html( $files[1] ) . '
  • ', $output ); + $this->assertStringContainsString( $expected, $output ); + $this->assertStringContainsString( '', $output ); } public function test_fileupload_download_link_lightbox() { diff --git a/tests/unit-tests/GravityView_Admin_Test.php b/tests/unit-tests/GravityView_Admin_Test.php index e68c4360d..df4612c92 100644 --- a/tests/unit-tests/GravityView_Admin_Test.php +++ b/tests/unit-tests/GravityView_Admin_Test.php @@ -38,7 +38,7 @@ public function test_change_entry_creator_dropdown() { $admin->add_select( $form['id'], $entry ); $select = ob_get_clean(); - $this->assertNotContains( '251-i-only-see-some-users-in-the-change-entry-creator-dropdown', $select ); + $this->assertStringNotContainsString( '251-i-only-see-some-users-in-the-change-entry-creator-dropdown', $select ); remove_filter( 'gravityview/get_users/change_entry_creator', $callback ); @@ -46,7 +46,7 @@ public function test_change_entry_creator_dropdown() { return $total; } ); - $this->assertNotContains( '251-i-only-see-some-users-in-the-change-entry-creator-dropdown', $select ); + $this->assertStringNotContainsString( '251-i-only-see-some-users-in-the-change-entry-creator-dropdown', $select ); remove_filter( 'gravityview/get_users/change_entry_creator', $callback ); diff --git a/tests/unit-tests/GravityView_Duplicate_Entry_Test.php b/tests/unit-tests/GravityView_Duplicate_Entry_Test.php index d2cd3710d..3d1b43790 100644 --- a/tests/unit-tests/GravityView_Duplicate_Entry_Test.php +++ b/tests/unit-tests/GravityView_Duplicate_Entry_Test.php @@ -103,7 +103,7 @@ public function test_get_confirm_dialog() { $confirm_dialog = GravityView_Duplicate_Entry::get_confirm_dialog(); - $this->assertContains( 'return window.confirm', $confirm_dialog, 'confirm JS is not in the confirm dialog response' ); + $this->assertStringContainsString( 'return window.confirm', $confirm_dialog, 'confirm JS is not in the confirm dialog response' ); add_filter( 'gravityview/duplicate-entry/confirm-text', '__return_empty_string' ); @@ -438,12 +438,12 @@ public function test_duplicate_basic() { $_GET['duplicate'] = wp_create_nonce( GravityView_Duplicate_Entry::get_nonce_key( $_GET['entry_id'] ) ); - $this->assertContains( 'The+entry+does+not+exist', $duplicate->process_duplicate() ); // Invalid entry + $this->assertStringContainsString( 'The+entry+does+not+exist', $duplicate->process_duplicate() ); // Invalid entry $_GET['entry_id'] = $entry['id']; $_GET['duplicate'] = wp_create_nonce( GravityView_Duplicate_Entry::get_nonce_key( $_GET['entry_id'] ) ); - $this->assertContains( 'You+do+not+have+permission+to+duplicate+this+entry', $duplicate->process_duplicate() ); // Not allowed + $this->assertStringContainsString( 'You+do+not+have+permission+to+duplicate+this+entry', $duplicate->process_duplicate() ); // Not allowed $this->factory->user->set( $admin->ID ); @@ -453,7 +453,7 @@ public function test_duplicate_basic() { $wpdb->suppress_errors( true ); - $this->assertContains( 'There+was+an+error+duplicating+the+entry.', $duplicate->process_duplicate() ); // User agent cannot be NULL + $this->assertStringContainsString( 'There+was+an+error+duplicating+the+entry.', $duplicate->process_duplicate() ); // User agent cannot be NULL $wpdb->suppress_errors( false ); @@ -465,7 +465,7 @@ public function test_duplicate_basic() { $this->assertCount( 1, GFAPI::get_entries( $form['id'] ) ); - $this->assertContains( '?status=duplicated', $duplicate->process_duplicate() ); // OK + $this->assertStringContainsString( '?status=duplicated', $duplicate->process_duplicate() ); // OK $this->assertCount( 2, list( $duplicate_entry, $source_entry ) = GFAPI::get_entries( $form['id'] ) ); @@ -478,7 +478,7 @@ public function test_duplicate_basic() { $this->assertNotEquals( $duplicate_entry['id'], $source_entry['id'] ); $this->assertNotEquals( $duplicate_entry['source_url'], $source_entry['source_url'] ); - $this->assertContains( 'tests', $duplicate_entry['source_url'] ); + $this->assertStringContainsString( 'tests', $duplicate_entry['source_url'] ); $this->assertEquals( 'Tests', $duplicate_entry['user_agent'] ); diff --git a/tests/unit-tests/GravityView_Edit_Entry_Test.php b/tests/unit-tests/GravityView_Edit_Entry_Test.php index 924dad322..e16456926 100644 --- a/tests/unit-tests/GravityView_Edit_Entry_Test.php +++ b/tests/unit-tests/GravityView_Edit_Entry_Test.php @@ -593,22 +593,22 @@ public function test_edit_entry_render() { 'entries' => array( $entry ), ) ); ob_start() && $render->init( $data ); - $this->assertContains( 'do not have permission', ob_get_clean() ); + $this->assertStringContainsString( 'do not have permission', ob_get_clean() ); /** Let's try again. */ $subscriber = $this->_generate_user( 'subscriber' ); wp_set_current_user( $subscriber ); ob_start() && $render->init( $data ); - $this->assertContains( 'do not have permission', ob_get_clean() ); + $this->assertStringContainsString( 'do not have permission', ob_get_clean() ); $administrator = $this->_generate_user( 'administrator' ); wp_set_current_user( $administrator ); ob_start() && $render->init( $data ); - $this->assertContains( 'link to edit this entry is not valid', ob_get_clean() ); + $this->assertStringContainsString( 'link to edit this entry is not valid', ob_get_clean() ); $_GET['edit'] = wp_create_nonce( $render::$nonce_key ); /** @todo: also test gravityview/edit_entry/verify_nonce */ ob_start() && $render->init( $data, null, \GV\View::from_post( $view )); - $this->assertContains( 'gv-edit-entry-wrapper', ob_get_clean() ); + $this->assertStringContainsString( 'gv-edit-entry-wrapper', ob_get_clean() ); /** So this is the basic emulation of viewing the edit entry. Let's try something more complex: */ @@ -676,7 +676,7 @@ public function test_edit_entry_simple() { $this->_reset_context(); wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'gform_submit', $output ); + $this->assertStringContainsString( 'gform_submit', $output ); /** Submit an edit */ $this->_reset_context(); @@ -692,7 +692,7 @@ public function test_edit_entry_simple() { $this->assertEquals( $entry['1'], 'we changed it' ); $this->assertEquals( $entry['2'], 102 ); - $this->assertContains( 'Entry Updated', $output ); + $this->assertStringContainsString( 'Entry Updated', $output ); /** Cleanup */ $this->_reset_context(); @@ -720,8 +720,8 @@ public function test_edit_entry_upload() { $this->_reset_context(); wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'gform_submit', $output ); - $this->assertContains( 'upload.txt', $output ); + $this->assertStringContainsString( 'gform_submit', $output ); + $this->assertStringContainsString( 'upload.txt', $output ); /** Try saving a change, but no touching the upload field. */ $_POST = array( @@ -819,14 +819,14 @@ public function test_edit_entry_simple_fails() { /** No permissions to edit this entry */ $this->_reset_context(); $_POST = $post; list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'do not have permission to edit this entry', $output ); + $this->assertStringContainsString( 'do not have permission to edit this entry', $output ); $this->assertEquals( $entry['1'], $entry['1'] ); $this->assertEquals( $entry['2'], $entry['2'] ); /** No permissions to edit this entry, not logged in. */ $this->_reset_context(); $_POST = $post; list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'do not have permission to edit this entry', $output ); + $this->assertStringContainsString( 'do not have permission to edit this entry', $output ); $this->assertEquals( $entry['1'], $entry['1'] ); $this->assertEquals( $entry['2'], $entry['2'] ); @@ -834,7 +834,7 @@ public function test_edit_entry_simple_fails() { $this->_reset_context(); $_POST = $post; wp_set_current_user( $subscriber2 ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'do not have permission to edit this entry', $output ); + $this->assertStringContainsString( 'do not have permission to edit this entry', $output ); $this->assertEquals( $entry['1'], $entry['1'] ); $this->assertEquals( $entry['2'], $entry['2'] ); @@ -857,7 +857,7 @@ public function test_edit_entry_simple_fails() { $_POST['input_2'] = 'this is not a number nanananana'; list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); $this->assertEquals( $entry['2'], $post['input_2'], 'A numeric field was changed! WTF?' ); - $this->assertContains( 'enter a valid number', $output ); + $this->assertStringContainsString( 'enter a valid number', $output ); /** Cleanup */ $this->_reset_context(); @@ -894,15 +894,15 @@ public function test_edit_entry_post_image() { $this->_reset_context(); wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'gform_submit', $output ); - $this->assertContains( "{$input}_1", $output ); - $this->assertContains( 'upload.png', $output ); - $this->assertContains( "{$input}_1_1", $output ); - $this->assertContains( 'this is a title', $output ); - $this->assertContains( "{$input}_1_4", $output ); - $this->assertContains( 'this is a caption', $output ); - $this->assertContains( "{$input}_1_7", $output ); - $this->assertContains( 'this is a description', $output ); + $this->assertStringContainsString( 'gform_submit', $output ); + $this->assertStringContainsString( "{$input}_1", $output ); + $this->assertStringContainsString( 'upload.png', $output ); + $this->assertStringContainsString( "{$input}_1_1", $output ); + $this->assertStringContainsString( 'this is a title', $output ); + $this->assertStringContainsString( "{$input}_1_4", $output ); + $this->assertStringContainsString( 'this is a caption', $output ); + $this->assertStringContainsString( "{$input}_1_7", $output ); + $this->assertStringContainsString( 'this is a description', $output ); /** Try saving a change, but not touching the image upload field. */ $_POST = array( @@ -1207,13 +1207,13 @@ public function test_unapprove_on_edit() { gravityview()->request->returns['is_entry'] = $entry; // The entry is not approved for viewing - $this->assertContains( 'are not allowed', \GV\View::content( 'entry' ) ); + $this->assertStringContainsString( 'are not allowed', \GV\View::content( 'entry' ) ); // Approve the entry gform_update_meta( $entry->ID, \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); // The entry is approved for viewing - $this->assertNotContains( 'are not allowed', \GV\View::content( 'entry' ) ); + $this->assertStringNotContainsString( 'are not allowed', \GV\View::content( 'entry' ) ); wp_set_current_user( $subscriber ); @@ -1224,7 +1224,7 @@ public function test_unapprove_on_edit() { $this->_emulate_render( $form, $view, $entry->as_entry() ); // It's still approved and modified - $this->assertNotContains( 'this is two', \GV\View::content( 'entry' ) ); + $this->assertStringNotContainsString( 'this is two', \GV\View::content( 'entry' ) ); // Update the View settings $view->settings->update( array( 'unapprove_edit' => true ) ); @@ -1238,7 +1238,7 @@ public function test_unapprove_on_edit() { wp_set_current_user( 0 ); // The entry is no longer approved - $this->assertContains( 'are not allowed', \GV\View::content( 'entry' ) ); + $this->assertStringContainsString( 'are not allowed', \GV\View::content( 'entry' ) ); // Approve it gform_update_meta( $entry->ID, \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); @@ -1252,7 +1252,7 @@ public function test_unapprove_on_edit() { $this->_emulate_render( $form, $view, $entry->as_entry() ); // It's still approved and modified - $this->assertNotContains( 'this is four', \GV\View::content( 'entry' ) ); + $this->assertStringNotContainsString( 'this is four', \GV\View::content( 'entry' ) ); $this->_reset_context(); } @@ -1281,7 +1281,7 @@ public function test_form_render_default_fields() { $this->_reset_context(); wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( "value='Much Worse' checked='checked'", $output ); + $this->assertStringNotContainsString( "value='Much Worse' checked='checked'", $output ); $this->_reset_context(); @@ -1303,8 +1303,8 @@ public function test_form_render_default_fields() { $this->_reset_context(); wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( "value='Much Better' checked='checked'", $output ); - $this->assertNotContains( "value='Much Worse' checked='checked'", $output ); + $this->assertStringContainsString( "value='Much Better' checked='checked'", $output ); + $this->assertStringNotContainsString( "value='Much Worse' checked='checked'", $output ); $this->_reset_context(); } @@ -1712,16 +1712,16 @@ public function test_redirect_after_edit( $edit_redirect, $location, $edit_redir list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( 'Entry Updated', $output ); + $this->assertStringContainsString( 'Entry Updated', $output ); if ( false !== $location ) { $output = str_replace( json_encode( get_permalink( $view ) ), '"{permalink}"', $output ); - $this->assertContains( sprintf( 'location.href = %s', json_encode( $location ) ), $output ); + $this->assertStringContainsString( sprintf( 'location.href = %s', json_encode( $location ) ), $output ); $location = str_replace( '{permalink}', get_permalink( $view ), $location ); - $this->assertContains( sprintf( '', esc_attr( $location ) ), $output ); + $this->assertStringContainsString( sprintf( '', esc_attr( $location ) ), $output ); } else { - $this->assertNotContains( 'location.href', $output ); + $this->assertStringNotContainsString( 'location.href', $output ); } $this->_reset_context(); @@ -1931,15 +1931,15 @@ public function test_field_visibility_and_editability_admin() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); remove_filter( 'gravityview/edit_entry/render_hidden_field', '__return_false' ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1], 'The value should not be updated when the Hidden field is not being rendered.' ); $this->assertEquals( 'this is two', $entry[2] ); // Since input 1 is now rendered, the value will be updated by _emulate_render() list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is ' . $random_string, $entry[1] ); $this->assertEquals( 'this is two', $entry[2] ); @@ -1956,8 +1956,8 @@ public function test_field_visibility_and_editability_admin() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( '666', $entry[2] ); @@ -1971,8 +1971,8 @@ public function test_field_visibility_and_editability_admin() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertNotEquals( 'this is one', $entry[1] ); $this->assertEquals( '666', $entry[2] ); @@ -2025,8 +2025,8 @@ public function test_field_visibility_and_editability_caps() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); remove_filter( 'gravityview/edit_entry/render_hidden_field', '__return_false' ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( 'this is two', $entry[2] ); @@ -2041,8 +2041,8 @@ public function test_field_visibility_and_editability_caps() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( 'this is two', $entry[2] ); @@ -2057,8 +2057,8 @@ public function test_field_visibility_and_editability_caps() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertNotContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringNotContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( 'this is two', $entry[2] ); @@ -2073,8 +2073,8 @@ public function test_field_visibility_and_editability_caps() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( "name='input_1'", $output ); - $this->assertContains( "name='input_2'", $output ); + $this->assertStringNotContainsString( "name='input_1'", $output ); + $this->assertStringContainsString( "name='input_2'", $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( '666', $entry[2] ); @@ -2087,8 +2087,8 @@ public function test_field_visibility_and_editability_caps() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertNotContains( 'input_1', $output ); - $this->assertNotContains( 'input_2', $output ); + $this->assertStringNotContainsString( 'input_1', $output ); + $this->assertStringNotContainsString( 'input_2', $output ); $this->assertEquals( 'this is one', $entry[1] ); $this->assertEquals( '666', $entry[2] ); @@ -2492,7 +2492,7 @@ public function test_required_upload_field_with_conditional_logic_and_invalid_ex wp_set_current_user( $administrator ); list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); - $this->assertContains("gfield_validation_message'>The uploaded file type is not allowed. Must be one of the following: pdf", $output); + $this->assertStringContainsString("gfield_validation_message'>The uploaded file type is not allowed. Must be one of the following: pdf", $output); $this->_reset_context(); } @@ -2552,7 +2552,7 @@ public function test_validation_of_required_fields_with_conditional_logic() { list( $output, $render, $entry ) = $this->_emulate_render( $form, $view, $entry ); $this->assertEmpty( $entry['8'] ); - $this->assertContains('This field is required', $output); + $this->assertStringContainsString('This field is required', $output); $this->_reset_context(); } diff --git a/tests/unit-tests/GravityView_Entry_Link_Shortcode_Test.php b/tests/unit-tests/GravityView_Entry_Link_Shortcode_Test.php index 1411057d3..c4c9a1aa7 100644 --- a/tests/unit-tests/GravityView_Entry_Link_Shortcode_Test.php +++ b/tests/unit-tests/GravityView_Entry_Link_Shortcode_Test.php @@ -248,8 +248,8 @@ public function test_entry_link_in_custom_content() { - $this->assertContains( 'entry='.$entry['id'].'">No Attributes Defined', $rendered_view ); - $this->assertContains( 'entry='.$entry['id'].'">Only Entry ID', $rendered_view ); + $this->assertStringContainsString( 'entry='.$entry['id'].'">No Attributes Defined', $rendered_view ); + $this->assertStringContainsString( 'entry='.$entry['id'].'">Only Entry ID', $rendered_view ); $post = $this->factory->post->create_and_get(array( 'post_content' => sprintf( '[gravityview id="%d"]', $view->ID ) diff --git a/tests/unit-tests/GravityView_Field_Test.php b/tests/unit-tests/GravityView_Field_Test.php index 8856d6824..6efa30ab6 100644 --- a/tests/unit-tests/GravityView_Field_Test.php +++ b/tests/unit-tests/GravityView_Field_Test.php @@ -401,8 +401,8 @@ function test_GravityView_Field_Unsubscribe_render_permissions() { $this->assertEquals( 'sentinel', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1 ), array( 'unsub_all' => true ), null ) ); $this->assertEquals( 'sentinel', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'null' ), array( 'unsub_all' => true ), null ) ); - $this->assertContains( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'active' ), array( 'unsub_all' => true ), null ) ); - $this->assertContains( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $administrator, 'id' => 1, 'payment_status' => 'active' ), null, null ) ); + $this->assertStringContainsString( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'active' ), array( 'unsub_all' => true ), null ) ); + $this->assertStringContainsString( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $administrator, 'id' => 1, 'payment_status' => 'active' ), null, null ) ); wp_set_current_user( $author ); @@ -414,7 +414,7 @@ function test_GravityView_Field_Unsubscribe_render_permissions() { $this->assertEquals( 'sentinel', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author ), null, null ) ); $this->assertEquals( 'sentinel', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'null' ), null, null ) ); - $this->assertContains( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'active' ), null, null ) ); + $this->assertStringContainsString( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', array( 'created_by' => $author, 'id' => 1, 'payment_status' => 'active' ), null, null ) ); wp_set_current_user( 0 ); } @@ -445,7 +445,7 @@ function test_GravityView_Field_Unsubscribe_unsubscribe_permissions() { 'payment_status' => 'active', ) ) ); - $this->assertContains( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); + $this->assertStringContainsString( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); $entry = \GV\GF_Entry::by_id( $entry['id'] )->as_entry(); @@ -455,7 +455,7 @@ function test_GravityView_Field_Unsubscribe_unsubscribe_permissions() { 'unsubscribe' => wp_create_nonce( 'unsubscribe_' . $entry['id'] ), ); - $this->assertContains( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); + $this->assertStringContainsString( 'Unsubscribe', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); $entry = \GV\GF_Entry::by_id( $entry['id'] )->as_entry(); @@ -470,7 +470,7 @@ function test_GravityView_Field_Unsubscribe_unsubscribe_permissions() { gform_update_meta( $entry['id'], 'processed_feeds', array( 'gf_paymentaddon_test' => array( $feed_id ) ) ); - $this->assertContains( 'Cancelled', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); + $this->assertStringContainsString( 'Cancelled', $field->modify_entry_value_unsubscribe( 'sentinel', $entry, null, null ) ); $entry = \GV\GF_Entry::by_id( $entry['id'] )->as_entry(); diff --git a/tests/unit-tests/GravityView_Future_Test.php b/tests/unit-tests/GravityView_Future_Test.php index baae6ac5f..df08691bb 100644 --- a/tests/unit-tests/GravityView_Future_Test.php +++ b/tests/unit-tests/GravityView_Future_Test.php @@ -530,7 +530,7 @@ public function test_data_get_views() { $fe = \GravityView_frontend::getInstance(); - $this->assertContains( 'insert_view_in_content( '' ) ); + $this->assertStringContainsString( 'insert_view_in_content( '' ) ); $fe->add_scripts_and_styles(); } @@ -547,12 +547,12 @@ public function test_data_get_views() { gravityview()->request->returns['is_view'] = $and_another_view; $fe->setIsGravityviewPostType( true ); - $this->assertContains( 'not allowed to view this content', $fe->render_view( array( + $this->assertStringContainsString( 'not allowed to view this content', $fe->render_view( array( 'id' => $and_another_view->ID, 'embed_only' => true, /** Check propagation of $passed_args */ ) ) ); - $this->assertContains( 'gv-container-' . $and_another_view->ID, $fe->render_view( array( + $this->assertStringContainsString( 'gv-container-' . $and_another_view->ID, $fe->render_view( array( 'id' => $and_another_view->ID, 'embed_only' => false, /** Check propagation of $passed_args */ ) ) ); @@ -563,7 +563,7 @@ public function test_data_get_views() { /** * The back link. */ - $this->assertContains( sprintf( 'data-viewid="%d"', $and_another_view->ID ), $fe->render_view( array( + $this->assertStringContainsString( sprintf( 'data-viewid="%d"', $and_another_view->ID ), $fe->render_view( array( 'id' => $and_another_view->ID, 'debug' => true, ) ) ); @@ -685,7 +685,7 @@ public function test_view_collection_from_post() { gform_update_meta( $entry['id'], \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); $embed_content = sprintf( "\n%s\n", add_query_arg( 'entry', $entry['id'], get_permalink( $view->ID ) ) ); - $this->assertContains( 'table class="gv-table-view-content"', $GLOBALS['wp_embed']->autoembed( $embed_content ) ); + $this->assertStringContainsString( 'table class="gv-table-view-content"', $GLOBALS['wp_embed']->autoembed( $embed_content ) ); /** Test GravityView_View_Data::is_valid_embed_id regression. */ $this->assertTrue( GravityView_View_Data::is_valid_embed_id( $post->ID, $view->ID ) ); @@ -1685,7 +1685,7 @@ public function test_filter_entries() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'No entries match your request', $future ); + $this->assertStringContainsString( 'No entries match your request', $future ); // Disable caching as we'll be running the same query but after creating new entries. @@ -1708,10 +1708,10 @@ public function test_filter_entries() { $this->assertEquals( 25, $view->get_entries( new GV\Frontend_Request() )->fetch()->count() ); $future = $renderer->render( $view ); - $this->assertContains( '[1] Some text in a textarea', $future ); - $this->assertContains( '[2] Some text in a textarea', $future ); - $this->assertContains( '[24] Some text in a textarea', $future ); - $this->assertContains( '[25] Some text in a textarea', $future ); + $this->assertStringContainsString( '[1] Some text in a textarea', $future ); + $this->assertStringContainsString( '[2] Some text in a textarea', $future ); + $this->assertStringContainsString( '[24] Some text in a textarea', $future ); + $this->assertStringContainsString( '[25] Some text in a textarea', $future ); /** * After filtering the entries. @@ -1721,11 +1721,11 @@ public function test_filter_entries() { $this->assertEquals( 13, $view->get_entries( new GV\Frontend_Request() )->count() ); $future = $renderer->render( $view ); - $this->assertContains( '[1] Some text in a textarea', $future ); - $this->assertNotContains( '[2] Some text in a textarea', $future ); - $this->assertContains( '[3] Some text in a textarea', $future ); - $this->assertNotContains( '[24] Some text in a textarea', $future ); - $this->assertContains( '[25] Some text in a textarea', $future ); + $this->assertStringContainsString( '[1] Some text in a textarea', $future ); + $this->assertStringNotContainsString( '[2] Some text in a textarea', $future ); + $this->assertStringContainsString( '[3] Some text in a textarea', $future ); + $this->assertStringNotContainsString( '[24] Some text in a textarea', $future ); + $this->assertStringContainsString( '[25] Some text in a textarea', $future ); $this->assertTrue( remove_filter( 'gravityview/view/entries', $callback ) ); @@ -1819,7 +1819,7 @@ public function test_frontend_view_renderer_table() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'No entries match your request', $future ); + $this->assertStringContainsString( 'No entries match your request', $future ); /** Some entries */ $entry = $this->factory->entry->create_and_get( array( @@ -1834,7 +1834,7 @@ public function test_frontend_view_renderer_table() { /** One entry */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Some text in a textarea', $future ); + $this->assertStringContainsString( 'Some text in a textarea', $future ); /** Some more */ foreach ( range( 1, 5 ) as $i ) { @@ -1851,8 +1851,8 @@ public function test_frontend_view_renderer_table() { /** Page one */ $this->assertEquals( $legacy, $future ); - $this->assertContains( '[5] Some text in a textarea', $future ); - $this->assertNotContains( '[1] Some text in a textarea', $future ); + $this->assertStringContainsString( '[5] Some text in a textarea', $future ); + $this->assertStringNotContainsString( '[1] Some text in a textarea', $future ); /** Page two? */ $_GET = array( 'pagenum' => 2 ); @@ -1861,7 +1861,7 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( '[1] Some text in a textarea', $future ); + $this->assertStringContainsString( '[1] Some text in a textarea', $future ); /** Some more */ foreach ( range( 1, 5 ) as $i ) { @@ -1878,8 +1878,8 @@ public function test_frontend_view_renderer_table() { /** Page two */ $this->assertEquals( $legacy, $future ); - $this->assertContains( '[5] Some text in a textarea', $future ); - $this->assertNotContains( '[1] Some text in a textarea', $future ); + $this->assertStringContainsString( '[5] Some text in a textarea', $future ); + $this->assertStringNotContainsString( '[1] Some text in a textarea', $future ); /** Search */ $_GET = array( 'pagenum' => 1, 'gv_search' => 'thisissomemoretext' ); @@ -1888,8 +1888,8 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( '[5] thisissomemoretext', $future ); - $this->assertNotContains( 'Some text', $future ); + $this->assertStringContainsString( '[5] thisissomemoretext', $future ); + $this->assertStringNotContainsString( 'Some text', $future ); $_GET = array( 'pagenum' => 2, 'gv_search' => 'thisissomemoretext' ); @@ -1897,14 +1897,14 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( '[1] thisissomemoretext', $future ); - $this->assertNotContains( 'Some text', $future ); + $this->assertStringContainsString( '[1] thisissomemoretext', $future ); + $this->assertStringNotContainsString( 'Some text', $future ); $_GET = array( 'pagenum' => 3, 'gv_search' => 'thisissomemoretext' ); $future = $renderer->render( $view ); - $this->assertContains( 'No entries match your request.', $future ); + $this->assertStringContainsString( 'No entries match your request.', $future ); /** Hide until searched */ $view->settings->update( array( 'hide_until_searched' => true ) ); @@ -1915,7 +1915,7 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'No entries match your request.', $future ); + $this->assertStringContainsString( 'No entries match your request.', $future ); $_GET = array( 'pagenum' => 2, 'gv_search' => 'thisissomemoretext' ); gravityview()->request->returns['is_search'] = true; @@ -1924,8 +1924,8 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( '[1] thisissomemoretext', $future ); - $this->assertNotContains( 'Country', $future ); + $this->assertStringContainsString( '[1] thisissomemoretext', $future ); + $this->assertStringNotContainsString( 'Country', $future ); $_GET = array(); gravityview()->request->returns['is_search'] = false; @@ -1937,7 +1937,7 @@ public function test_frontend_view_renderer_table() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'No entries match your request.', $future ); + $this->assertStringContainsString( 'No entries match your request.', $future ); $_entries = $entries->all(); foreach ( array_rand( $_entries, 5 ) as $entry_num ) { @@ -1949,7 +1949,7 @@ public function test_frontend_view_renderer_table() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertNotContains( 'No entries match your request.', $future ); + $this->assertStringNotContainsString( 'No entries match your request.', $future ); $administrator = $this->factory->user->create( array( 'user_login' => md5( microtime() ), @@ -1965,7 +1965,7 @@ public function test_frontend_view_renderer_table() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Country', $future ); + $this->assertStringContainsString( 'Country', $future ); /** No configuration */ $view->fields = new \GV\Field_Collection(); @@ -1974,7 +1974,7 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'The Multiple Entries layout has not been configured.', $future ); + $this->assertStringContainsString( 'The Multiple Entries layout has not been configured.', $future ); wp_set_current_user( -1 ); @@ -1982,8 +1982,8 @@ public function test_frontend_view_renderer_table() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertNotContains( 'The Multiple Entries layout has not been configured.', $future ); - $this->assertNotContains( 'Textarea', $future ); + $this->assertStringNotContainsString( 'The Multiple Entries layout has not been configured.', $future ); + $this->assertStringNotContainsString( 'Textarea', $future ); remove_all_filters( 'gravityview/view/anchor_id' ); remove_all_filters( 'gravityview/widget/search/append_view_id_anchor' ); @@ -2129,7 +2129,7 @@ public function test_frontend_view_renderer_list() { /** No matching entries... */ $this->assertEquals( $legacy, $future ); - $this->assertContains( 'No entries match your request', $future ); + $this->assertStringContainsString( 'No entries match your request', $future ); /** Some entries */ $entry = $this->factory->entry->create_and_get( array( @@ -2241,10 +2241,10 @@ public function test_frontend_widgets() { $future = $renderer->render( $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Search Entries', $future ); - $this->assertContains( 'Displaying 1 - 3 of 5', $future ); - $this->assertContains( "class='page-numbers'", $future ); - $this->assertContains( 'Here we go again! Now', $future ); + $this->assertStringContainsString( 'Search Entries', $future ); + $this->assertStringContainsString( 'Displaying 1 - 3 of 5', $future ); + $this->assertStringContainsString( "class='page-numbers'", $future ); + $this->assertStringContainsString( 'Here we go again! Now', $future ); remove_all_filters( 'gravityview/view/anchor_id' ); remove_all_filters( 'gravityview/widget/search/append_view_id_anchor' ); @@ -2295,7 +2295,7 @@ public function test_entry_renderer_table() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'The Single Entry layout has not been configured', $future ); + $this->assertStringContainsString( 'The Single Entry layout has not been configured', $future ); $post = $this->factory->view->create_and_get( array( 'form_id' => $form['id'], @@ -2341,7 +2341,7 @@ public function test_entry_renderer_table() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'text in a textarea', $future ); + $this->assertStringContainsString( 'text in a textarea', $future ); wp_set_current_user( -1 ); @@ -2349,9 +2349,9 @@ public function test_entry_renderer_table() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'text in a textarea', $future ); - $this->assertContains( 'Let's go back!', $future ); - $this->assertNotContains( 'Country', $future ); + $this->assertStringContainsString( 'text in a textarea', $future ); + $this->assertStringContainsString( 'Let's go back!', $future ); + $this->assertStringNotContainsString( 'Country', $future ); // Check sorting links @@ -2360,7 +2360,7 @@ public function test_entry_renderer_table() { $legacy = \GravityView_frontend::getInstance()->insert_view_in_content( '' ); $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'class="gv-sort', $future ); + $this->assertStringContainsString( 'class="gv-sort', $future ); // Check sorting links $view->settings->set( 'sort_columns', '0' ); @@ -2368,7 +2368,7 @@ public function test_entry_renderer_table() { $legacy = \GravityView_frontend::getInstance()->insert_view_in_content( '' ); $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertNotContains( 'class="gv-sort', $future ); + $this->assertStringNotContainsString( 'class="gv-sort', $future ); } public function test_entry_renderer_table_hide_empty() { @@ -2421,8 +2421,8 @@ public function test_entry_renderer_table_hide_empty() { $future = $renderer->render( $entry, $view ); - $this->assertNotContains( 'Textarea', $future, 'This field is empty and should not be displayed.' ); - $this->assertNotContains( 'Product', $future, 'This field is empty and should not be displayed.' ); + $this->assertStringNotContainsString( 'Textarea', $future, 'This field is empty and should not be displayed.' ); + $this->assertStringNotContainsString( 'Product', $future, 'This field is empty and should not be displayed.' ); } /** @@ -2469,7 +2469,7 @@ public function test_entry_renderer_list() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'The Single Entry layout has not been configured', $future ); + $this->assertStringContainsString( 'The Single Entry layout has not been configured', $future ); $post = $this->factory->view->create_and_get( array( 'form_id' => $form['id'], @@ -2595,7 +2595,7 @@ public function test_entry_renderer_list() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Country', $future ); + $this->assertStringContainsString( 'Country', $future ); wp_set_current_user( -1 ); @@ -2603,9 +2603,9 @@ public function test_entry_renderer_list() { $future = $renderer->render( $entry, $view ); $this->assertEquals( $legacy, $future ); - $this->assertContains( 'Let's go back!', $future ); - $this->assertContains( 'text in a textarea', $future ); - $this->assertNotContains( 'Country', $future ); + $this->assertStringContainsString( 'Let's go back!', $future ); + $this->assertStringContainsString( 'text in a textarea', $future ); + $this->assertStringNotContainsString( 'Country', $future ); } /** @@ -2778,7 +2778,7 @@ public function test_frontend_field_html_address() { return 'Sentinel Map Link'; } ); - $this->assertContains( 'Sentinel Map Link', $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( 'Sentinel Map Link', $renderer->render( $field, $view, $form, $entry, $request ) ); remove_filter( 'gravityview_map_link', $callback ); } @@ -3089,8 +3089,8 @@ public function test_frontend_field_html_phone() { $field->update_configuration( array( 'link_phone' => true ) ); $output = $renderer->render( $field, $view, $form, $entry, $request ); - $this->assertContains( '93 43A99-392<script>1</script>', $output ); + $this->assertStringContainsString( '93 43A99-392<script>1</script>', $output ); } /** @@ -3593,7 +3593,7 @@ public function test_frontend_field_html_delete_link() { $field = \GV\Internal_Field::by_id( 'delete_link' ); $expected = sprintf( 'Delete Entry', esc_attr( GravityView_Delete_Entry::get_delete_link( $entry->as_entry(), $view->ID ) ), esc_attr( GravityView_Delete_Entry::get_confirm_dialog() ) ); $this->assertEquals( $expected, $renderer->render( $field, $view, null, $entry, $request ) ); - $this->assertContains( 'action=delete', $expected ); + $this->assertStringContainsString( 'action=delete', $expected ); $field->update_configuration( array( 'delete_link' => 'Deletes les Entrios' ) ); $expected = sprintf( 'Deletes les Entrios', esc_attr( GravityView_Delete_Entry::get_delete_link( $entry->as_entry(), $view->ID ) ), esc_attr( GravityView_Delete_Entry::get_confirm_dialog() ) ); @@ -3631,7 +3631,7 @@ public function test_frontend_field_html_edit_link() { $field = \GV\Internal_Field::by_id( 'edit_link' ); $expected = sprintf( 'Edit Entry', esc_attr( GravityView_Edit_Entry::get_edit_link( $entry->as_entry(), $view->ID ) ) ); $this->assertEquals( $expected, $renderer->render( $field, $view, null, $entry, $request ) ); - $this->assertContains( 'edit=', $expected ); + $this->assertStringContainsString( 'edit=', $expected ); $field->update_configuration( array( 'edit_link' => 'Editoriales los Entries', 'new_window' => true ) ); $expected = sprintf( 'Editoriales los Entries', esc_attr( GravityView_Edit_Entry::get_edit_link( $entry->as_entry(), $view->ID ) ) ); @@ -3660,8 +3660,8 @@ public function test_frontend_field_html_notes() { $this->assertEmpty( $renderer->render( $field, $view, null, $entry, $request ) ); $field->update_configuration( array( 'notes' => array( 'view' => true, 'view_loggedout' => true ) ) ); - $this->assertContains( 'There are no notes.', $renderer->render( $field, $view, null, $entry, $request ) ); - $this->assertContains( 'gv-show-notes', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'There are no notes.', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'gv-show-notes', $renderer->render( $field, $view, null, $entry, $request ) ); $administrator = $this->factory->user->create( array( 'user_login' => md5( microtime() ), @@ -3674,14 +3674,14 @@ public function test_frontend_field_html_notes() { $field = \GV\Internal_Field::by_id( 'notes' ); $field->update_configuration( array( 'notes' => array( 'view' => true ) ) ); - $this->assertContains( 'gv-has-notes', $renderer->render( $field, $view, null, $entry, $request ) ); - $this->assertContains( 'this <script>1</script> is a note :) {entry_id}', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'gv-has-notes', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'this <script>1</script> is a note :) {entry_id}', $renderer->render( $field, $view, null, $entry, $request ) ); $field->update_configuration( array( 'notes' => array( 'view' => true, 'add' => true ) ) ); - $this->assertContains( 'gv-add-note-submit', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'gv-add-note-submit', $renderer->render( $field, $view, null, $entry, $request ) ); $field->update_configuration( array( 'notes' => array( 'view' => true, 'delete' => true ) ) ); - $this->assertContains( 'gv-notes-delete', $renderer->render( $field, $view, null, $entry, $request ) ); + $this->assertStringContainsString( 'gv-notes-delete', $renderer->render( $field, $view, null, $entry, $request ) ); } /** @@ -4178,7 +4178,7 @@ public function test_frontend_field_html_post() { ), $expected ); } foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $field->update_configuration( array( 'dynamic_data' => true ) ); @@ -4194,13 +4194,13 @@ public function test_frontend_field_html_post() { } foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $field->update_configuration( array( 'link_to_term' => false ) ); $expected = explode( ', ', '[gvtest_shortcode_p1], hi, more, oh no, some, tag 1' ); foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } /** Post categories */ @@ -4213,7 +4213,7 @@ public function test_frontend_field_html_post() { '', ); foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $this->assertEquals( strlen( implode( '', $expected ) ), strlen( $renderer->render( $field, $view, $form, $entry, $request ) ) ); @@ -4223,7 +4223,7 @@ public function test_frontend_field_html_post() { sprintf( 'Category 6 [gvtest_shortcode_p1] 5', esc_url( get_term_link( $cat_2, 'category' ) ) ), ); foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $this->assertEquals( strlen( implode( ', ', $expected ) ), strlen( $renderer->render( $field, $view, $form, $entry, $request ) ) ); @@ -4233,7 +4233,7 @@ public function test_frontend_field_html_post() { sprintf( '', esc_url( get_term_link( $cat_2, 'category' ) ) ), ); foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $this->assertEquals( strlen( implode( ', ', $expected ) ), strlen( $renderer->render( $field, $view, $form, $entry, $request ) ) ); @@ -4243,7 +4243,7 @@ public function test_frontend_field_html_post() { 'Category 6 [gvtest_shortcode_p1] 5', ); foreach ( $expected as $_expected ) { - $this->assertContains( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( $_expected, $renderer->render( $field, $view, $form, $entry, $request ) ); } $this->assertEquals( strlen( implode( ', ', $expected ) ), strlen( $renderer->render( $field, $view, $form, $entry, $request ) ) ); @@ -4370,9 +4370,9 @@ public function test_frontend_field_html_pipe_recorder() { $field->update_configuration( array( 'embed' => true ) ); - $this->assertContains( 'render( $field, $view, $form, $entry, $request ) ); - $this->assertContains( 'thumb.jpg', $out ); - $this->assertContains( 'video.mp4', $out ); + $this->assertStringContainsString( 'render( $field, $view, $form, $entry, $request ) ); + $this->assertStringContainsString( 'thumb.jpg', $out ); + $this->assertStringContainsString( 'video.mp4', $out ); $this->_reset_context(); } @@ -4608,7 +4608,7 @@ public function test_view_table() { ob_start(); $template->the_entry( $entries[1], $attributes ); $output = ob_get_clean(); - $this->assertContains( '', $output ); + $this->assertStringContainsString( '', $output ); remove_all_filters( 'gravityview/template/table/entry/row/attributes' ); } @@ -5339,7 +5339,7 @@ public function test_shortcodes_gravityview() { $future_output = trim( preg_replace( '#>\s*<#', '><', $future_output ) ); $this->assertEquals( $legacy_output, $future_output ); - $this->assertContains( '] Entry ', $future_output ); + $this->assertStringContainsString( '] Entry ', $future_output ); remove_all_filters( 'gravityview/view/anchor_id' ); remove_all_filters( 'gravityview/widget/search/append_view_id_anchor' ); @@ -5408,15 +5408,15 @@ public function test_oembed_entry() { $future_output = call_user_func_array( $future, $args ); - $this->assertContains( 'gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $entry->ID, $future_output ); + $this->assertStringContainsString( 'gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $entry->ID, $future_output ); - $this->assertNotContains( 'You are not allowed', $future_output ); + $this->assertStringNotContainsString( 'You are not allowed', $future_output ); $args['url'] = add_query_arg( array( 'gravityview' => $post->ID, 'entry' => $entry['id'] ), site_url() ); $future_output = call_user_func_array( $future, $args ); - $this->assertNotContains( 'You are not allowed', $future_output ); + $this->assertStringNotContainsString( 'You are not allowed', $future_output ); wp_set_current_user( 0 ); gravityview()->request = new \GV\Frontend_Request(); @@ -5433,49 +5433,49 @@ public function test_protection_view_content_directory() { /** Post password */ wp_update_post( array( 'ID' => $post->ID, 'post_password' => '123' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'content is password protected', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'content is password protected', \GV\View::content( 'what!?' ) ); /** When the user has added a password, show the content. Requires 4.7.0 or newer. */ if( class_exists( 'WP_Hook' ) ) { add_filter( 'post_password_required', '__return_false' ); - $this->assertContains( 'No entries match your request.', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'No entries match your request.', \GV\View::content( 'what!?' ) ); remove_filter( 'post_password_required', '__return_false' ); } /** Private */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'private', 'post_password' => '' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Pending */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'pending' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Draft */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'draft' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Trash */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'trash' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Scheduled */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'future', 'post_date_gmt' => '2117-11-10 18:02:56' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Regular */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'publish', 'post_date_gmt' => '2017-07-09 00:00:00' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertNotContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringNotContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** embed_only */ $view->settings->update( array( 'embed_only' => true ) ); $request->returns['is_view'] = $view; - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); } public function test_protection_gravityview_shortcode_directory() { @@ -5501,37 +5501,37 @@ public function test_protection_gravityview_shortcode_directory() { /** Post password */ wp_update_post( array( 'ID' => $post->ID, 'post_password' => '123' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'content is password protected', $future->callback( $args ) ); + $this->assertStringContainsString( 'content is password protected', $future->callback( $args ) ); /** Private */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'private', 'post_password' => '' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Pending */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'pending' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Draft */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'draft' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Trash */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'trash' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Scheduled */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'future', 'post_date_gmt' => '2117-11-10 18:02:56' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Regular */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'publish', 'post_date_gmt' => '2017-07-09 00:00:00' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); } public function test_protection_view_content_single() { @@ -5556,7 +5556,7 @@ public function test_protection_view_content_single() { $request->returns['is_view'] = $view; $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Not approved */ $entry = $this->factory->entry->create_and_get( array( @@ -5567,12 +5567,12 @@ public function test_protection_view_content_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Approve */ gform_update_meta( $entry['id'], \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); - $this->assertNotContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringNotContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Slug */ global $wp_query; @@ -5582,19 +5582,19 @@ public function test_protection_view_content_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); - $this->assertContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Good slug */ $wp_query->set( \GV\Entry::get_endpoint_name(), gform_get_meta( $entry['id'], 'gravityview_unique_id' ) ); - $this->assertNotContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringNotContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); remove_all_filters( 'gravityview_custom_entry_slug' ); /** Pagenum stored via query string shouldn't affect the display conditions for the entry */ $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); $_GET['pagenum'] = 1000; - $this->assertNotContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringNotContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); unset( $_GET['pagenum'] ); } @@ -5629,7 +5629,7 @@ public function test_protection_gravityview_shortcode_single() { 'page_size' => 3, ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Not approved */ $entry = $this->factory->entry->create_and_get( array( @@ -5640,12 +5640,12 @@ public function test_protection_gravityview_shortcode_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Approve */ gform_update_meta( $entry['id'], \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); /** Slug */ global $wp_query; @@ -5655,12 +5655,12 @@ public function test_protection_gravityview_shortcode_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); /** Good slug */ $wp_query->set( \GV\Entry::get_endpoint_name(), gform_get_meta( $entry['id'], 'gravityview_unique_id' ) ); - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); remove_all_filters( 'gravityview_custom_entry_slug' ); @@ -5701,24 +5701,24 @@ public function test_protection_gravityview_shortcode_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); // Allowed to view since no filters have been added yet. - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); add_filter( 'gravityview_search_criteria', array( $this, '_filter_created_by_current_user' ), 10, 3 ); // Should work; created_by matches current user. - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); wp_set_current_user( $subscriber ); - $this->assertContains( 'not allowed to view', $future->callback( $args ), 'Should NOT work; created_by is administrator and current user is subscriber' ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ), 'Should NOT work; created_by is administrator and current user is subscriber' ); wp_set_current_user( 0 ); - $this->assertContains( 'not allowed to view', $future->callback( $args ), 'Should NOT work; created_by is administrator and no user is set' ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ), 'Should NOT work; created_by is administrator and no user is set' ); wp_set_current_user( $administrator ); - $this->assertNotContains( 'not allowed to view', $future->callback( $args ), 'Should work; created_by and logged-in user are administrator' ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ), 'Should work; created_by and logged-in user are administrator' ); $entry = $this->factory->entry->create_and_get( array( 'created_by' => $subscriber, @@ -5730,17 +5730,17 @@ public function test_protection_gravityview_shortcode_single() { $request->returns['is_entry'] = \GV\GF_Entry::by_id( $entry['id'] ); // Should NOT work; created_by is subscriber and filter is set to administrator - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); wp_set_current_user( 0 ); // Should NOT work; created_by is subscriber and filter is set to administrator - $this->assertContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringContainsString( 'not allowed to view', $future->callback( $args ) ); wp_set_current_user( $subscriber ); // Should NOT work; created_by is subscriber and filter is set to administrator - $this->assertNotContains( 'not allowed to view', $future->callback( $args ) ); + $this->assertStringNotContainsString( 'not allowed to view', $future->callback( $args ) ); remove_filter( 'gravityview_search_criteria', array( $this, '_filter_created_by_current_user' ), 10 ); } @@ -5793,7 +5793,7 @@ public function test_protection_oembed() { 'rawattr' => '', ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Not approved */ $entry = $this->factory->entry->create_and_get( array( @@ -5813,47 +5813,47 @@ public function test_protection_oembed() { 'rawattr' => '', ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Approve */ gform_update_meta( $entry['id'], \GravityView_Entry_Approval::meta_key, \GravityView_Entry_Approval_Status::APPROVED ); - $this->assertNotContains( 'not allowed to view', \GV\View::content( 'what!?' ) ); + $this->assertStringNotContainsString( 'not allowed to view', \GV\View::content( 'what!?' ) ); /** Post password */ wp_update_post( array( 'ID' => $post->ID, 'post_password' => '123' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'content is password protected', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'content is password protected', call_user_func_array( $future, $args ) ); /** Trash */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'trash' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Private */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'private', 'post_password' => '' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Draft */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'draft' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Pending */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'pending' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Scheduled */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'future', 'post_date_gmt' => '2117-11-10 18:02:56' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'not allowed to view', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'not allowed to view', call_user_func_array( $future, $args ) ); /** Regular */ wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'publish', 'post_date_gmt' => '2017-07-09 00:00:00' ) ); $request->returns['is_view'] = \GV\View::by_id( $post->ID ); - $this->assertContains( 'gravityview-oembed-entry', call_user_func_array( $future, $args ) ); + $this->assertStringContainsString( 'gravityview-oembed-entry', call_user_func_array( $future, $args ) ); } /** @@ -5996,7 +5996,7 @@ public function test_widget_class() { $post->post_content = sprintf( '[gravityview id="%d"]', $view->ID ); $w->add_shortcode(); - $this->assertContains( 'GravityView', $w->maybe_do_shortcode( 'okay [gvfuturetest_widget_test] okay' ) ); + $this->assertStringContainsString( 'GravityView', $w->maybe_do_shortcode( 'okay [gvfuturetest_widget_test] okay' ) ); } public function test_widget_render() { @@ -6053,8 +6053,8 @@ public function test_widget_render() { $future = $renderer->render( $view ); - $this->assertContains( 'GravityViewfoo', $future ); - $this->assertContains( 'GravityViewbar', $future ); + $this->assertStringContainsString( 'GravityViewfoo', $future ); + $this->assertStringContainsString( 'GravityViewbar', $future ); } public function test_template_hooks_compat_table_directory() { @@ -6188,7 +6188,7 @@ public function test_template_hooks_compat_table_directory() { add_filter( 'gravityview/render/container/class', $callbacks []= function( $class, $context ) use ( $view, $test ) { $test->assertSame( $context->view, $view ); - $test->assertContains( "gv-container-{$view->ID}", $class ); + $test->assertStringContainsString( "gv-container-{$view->ID}", $class ); return "$class {{ gravityview/render/container/class }}"; }, 10, 2 ); @@ -6204,18 +6204,18 @@ public function test_template_hooks_compat_table_directory() { $this->assertStringStartsWith( '{{ gravityview/template/before }}{{ gravityview_before }}', $out ); $this->assertStringEndsWith( '{{ gravityview/template/after }}{{ gravityview_after }}', $out ); - $this->assertContains( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); - $this->assertContains( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); - $this->assertContains( '{{ gravityview/template/table/body/before }}{{ gravityview_table_body_before }}', $out ); - $this->assertContains( '{{ gravityview/template/table/body/after }}{{ gravityview_table_body_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/body/before }}{{ gravityview_table_body_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/body/after }}{{ gravityview_table_body_after }}', $out ); - $this->assertContains( 'class="alt gravityview_entry_class gravityview/template/table/entry/class"', $out ); + $this->assertStringContainsString( 'class="alt gravityview_entry_class gravityview/template/table/entry/class"', $out ); - $this->assertContains( '{{ gravityview/template/table/cells/before }}{{ gravityview_table_cells_before }}', $out ); - $this->assertContains( '{{ gravityview/template/table/cells/after }}{{ gravityview_table_cells_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/cells/before }}{{ gravityview_table_cells_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/cells/after }}{{ gravityview_table_cells_after }}', $out ); - $this->assertContains( 'gravityviewrendercontainerclass' /** sanitized */, $out ); + $this->assertStringContainsString( 'gravityviewrendercontainerclass' /** sanitized */, $out ); $removed = array( remove_action( 'gravityview_before', array_shift( $callbacks ) ), @@ -6293,15 +6293,15 @@ public function test_template_hooks_compat_table_directory() { $out = $renderer->render( $view ); - $this->assertContains( '{{ gravityview/template/table/tr/before }}{{ gravityview_table_tr_before }}', $out ); - $this->assertContains( '{{ gravityview/template/table/tr/after }}{{ gravityview_table_tr_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/tr/before }}{{ gravityview_table_tr_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/table/tr/after }}{{ gravityview_table_tr_after }}', $out ); - $this->assertContains( '{{ gravityview/template/text/no_entries }}{{ gravitview_no_entries_text }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/text/no_entries }}{{ gravitview_no_entries_text }}', $out ); - $this->assertContains( '{{ gravityview_render_after_label }}{{ gravityview/template/field_label }}{{ gravityview/template/field/label }}', $out ); + $this->assertStringContainsString( '{{ gravityview_render_after_label }}{{ gravityview/template/field_label }}{{ gravityview/template/field/label }}', $out ); - $this->assertContains( "gv-container-{$view->ID}", $out ); - $this->assertContains( "gv-container-no-results", $out ); + $this->assertStringContainsString( "gv-container-{$view->ID}", $out ); + $this->assertStringContainsString( "gv-container-no-results", $out ); $removed = array( remove_action( 'gravityview_table_tr_before', array_shift( $callbacks ) ), @@ -6434,7 +6434,7 @@ public function test_template_hooks_compat_table_single() { add_filter( 'gravityview/render/container/class', $callbacks []= function( $class, $context ) use ( $view, $test ) { $test->assertSame( $context->view, $view ); - $test->assertContains( "gv-container-{$view->ID}", $class ); + $test->assertStringContainsString( "gv-container-{$view->ID}", $class ); return "$class {{ gravityview/render/container/class }}"; }, 10, 2 ); @@ -6467,21 +6467,21 @@ public function test_template_hooks_compat_table_single() { $this->assertStringStartsWith( '{{ gravityview/template/before }}{{ gravityview_before }}', $out ); $this->assertStringEndsWith( '{{ gravityview/template/after }}{{ gravityview_after }}', $out ); - $this->assertContains( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); - $this->assertContains( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); - $this->assertContains( '{{ gravityview_render_after_label }}{{ gravityview/template/field_label }}{{ gravityview/template/field/label }}', $out ); + $this->assertStringContainsString( '{{ gravityview_render_after_label }}{{ gravityview/template/field_label }}{{ gravityview/template/field/label }}', $out ); - $this->assertContains( '%20gravityview_directory_link%20%20gravityview/view/links/directory%20', $out ); + $this->assertStringContainsString( '%20gravityview_directory_link%20%20gravityview/view/links/directory%20', $out ); - $this->assertContains( 'class="back-links-are-the-best-links"', $out ); - $this->assertContains( 'data-viewid="' . $view->ID . '"', $out ); - $this->assertContains( 'rel="self"', $out ); - $this->assertNotContains( 'should-be-stripped', $out ); - $this->assertContains( 'gravityviewrendercontainerclass' /** sanitized */, $out ); + $this->assertStringContainsString( 'class="back-links-are-the-best-links"', $out ); + $this->assertStringContainsString( 'data-viewid="' . $view->ID . '"', $out ); + $this->assertStringContainsString( 'rel="self"', $out ); + $this->assertStringNotContainsString( 'should-be-stripped', $out ); + $this->assertStringContainsString( 'gravityviewrendercontainerclass' /** sanitized */, $out ); - $this->assertContains( "gv-container-{$view->ID}", $out ); - $this->assertNotContains( "gv-container-no-results", $out ); + $this->assertStringContainsString( "gv-container-{$view->ID}", $out ); + $this->assertStringNotContainsString( "gv-container-no-results", $out ); $removed = array( remove_action( 'gravityview_before', array_shift( $callbacks ) ), @@ -6621,7 +6621,7 @@ public function test_template_hooks_compat_list_directory( $really_directory = t add_filter( 'gravityview/render/container/class', $callbacks []= function( $class, $context ) use ( $view, $test ) { $test->assertSame( $context->view, $view ); - $test->assertContains( "gv-container-{$view->ID}", $class ); + $test->assertStringContainsString( "gv-container-{$view->ID}", $class ); return "$class {{ gravityview/render/container/class }}"; }, 10, 2 ); @@ -6795,27 +6795,27 @@ public function test_template_hooks_compat_list_directory( $really_directory = t if ( 'directory' == $mode ) { - $this->assertContains( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); - $this->assertContains( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/header }}{{ gravityview_header }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/footer }}{{ gravityview_footer }}', $out ); - $this->assertContains( '{{ gravityview/template/list/body/before }}{{ gravityview_list_body_before }}', $out ); - $this->assertContains( '{{ gravityview/template/list/body/after }}{{ gravityview_list_body_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/body/before }}{{ gravityview_list_body_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/body/after }}{{ gravityview_list_body_after }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/before }}{{ gravityview_list_entry_before }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/after }}{{ gravityview_list_entry_after }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/title/before }}{{ gravityview_list_entry_title_before }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/title/after }}{{ gravityview_list_entry_title_after }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/content/before }}{{ gravityview_list_entry_content_before }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/content/after }}{{ gravityview_list_entry_content_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/before }}{{ gravityview_list_entry_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/after }}{{ gravityview_list_entry_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/title/before }}{{ gravityview_list_entry_title_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/title/after }}{{ gravityview_list_entry_title_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/content/before }}{{ gravityview_list_entry_content_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/content/after }}{{ gravityview_list_entry_content_after }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/footer/before }}{{ gravityview_list_entry_footer_before }}', $out ); - $this->assertContains( '{{ gravityview/template/list/entry/footer/after }}{{ gravityview_list_entry_footer_after }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/footer/before }}{{ gravityview_list_entry_footer_before }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/list/entry/footer/after }}{{ gravityview_list_entry_footer_after }}', $out ); - $this->assertContains( 'gravityview_entry_class gravityviewtemplatelistentryclass', $out ); + $this->assertStringContainsString( 'gravityview_entry_class gravityviewtemplatelistentryclass', $out ); } - $this->assertContains( 'gravityviewrendercontainerclass' /** sanitized */, $out ); - $this->assertNotContains( "gv-container-no-results", $out ); + $this->assertStringContainsString( 'gravityviewrendercontainerclass' /** sanitized */, $out ); + $this->assertStringNotContainsString( "gv-container-no-results", $out ); $removed = array( remove_action( 'gravityview_before', array_shift( $callbacks ) ), @@ -6874,10 +6874,10 @@ public function test_template_hooks_compat_list_directory( $really_directory = t $out = $renderer->render( $view ); - $this->assertContains( '{{ gravityview/template/text/no_entries }}{{ gravitview_no_entries_text }}', $out ); + $this->assertStringContainsString( '{{ gravityview/template/text/no_entries }}{{ gravitview_no_entries_text }}', $out ); - $this->assertContains( "gv-container-{$view->ID}", $out ); - $this->assertContains( "gv-container-no-results", $out ); + $this->assertStringContainsString( "gv-container-{$view->ID}", $out ); + $this->assertStringContainsString( "gv-container-no-results", $out ); $removed = array( remove_filter( 'gravitview_no_entries_text', array_shift( $callbacks ) ), @@ -6928,8 +6928,8 @@ public function test_template_hooks_compat_list_single() { $view = $_view; } ); - $this->assertContains( 'gv-list-single-container', $out ); - $this->assertContains( '%20gravityview_directory_link%20%20gravityview/view/links/directory%20', $out ); + $this->assertStringContainsString( 'gv-list-single-container', $out ); + $this->assertStringContainsString( '%20gravityview_directory_link%20%20gravityview/view/links/directory%20', $out ); remove_filter( 'gravityview_directory_link', $callbacks[0] ); remove_filter( 'gravityview/view/links/directory', $callbacks[1] ); @@ -6991,16 +6991,16 @@ public function test_hide_empty_filters_compat() { /** Single table */ $renderer = new \GV\Entry_Renderer(); - $this->assertContains( 'Index', $renderer->render( $entry, $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Index', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $entry, $view ) ); add_filter( 'gravityview/render/hide-empty-zone', $filter = function( $hide, $context ) use ( &$test, &$view ) { $test->assertSame( $context->view, $view ); return true; }, 10, 2 ); - $this->assertNotContains( 'Index', $renderer->render( $entry, $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $entry, $view ) ); + $this->assertStringNotContainsString( 'Index', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $entry, $view ) ); remove_filter( 'gravityview/render/hide-empty-zone', $filter ); @@ -7009,8 +7009,8 @@ public function test_hide_empty_filters_compat() { gravityview()->request->returns['is_view'] = $view; $renderer = new \GV\View_Renderer(); - $this->assertContains( 'Index', $renderer->render( $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $view ) ); + $this->assertStringContainsString( 'Index', $renderer->render( $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $view ) ); add_filter( 'gravityview/render/hide-empty-zone', $filter = function( $hide, $context ) use ( &$test, &$view ) { $test->assertSame( $context->view, $view ); @@ -7018,8 +7018,8 @@ public function test_hide_empty_filters_compat() { }, 10, 2 ); $id = sprintf( 'gv-field-%d-%d', $form['id'], 2 ); - $this->assertContains( "", $renderer->render( $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $view ) ); + $this->assertStringContainsString( "", $renderer->render( $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $view ) ); remove_filter( 'gravityview/render/hide-empty-zone', $filter ); @@ -7089,16 +7089,16 @@ public function test_hide_empty_filters_compat() { /** Single list */ $renderer = new \GV\Entry_Renderer(); - $this->assertContains( 'Index', $renderer->render( $entry, $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Index', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $entry, $view ) ); add_filter( 'gravityview/render/hide-empty-zone', $filter = function( $hide, $context ) use ( &$test, &$view ) { $test->assertSame( $context->view, $view ); return true; }, 10, 2 ); - $this->assertNotContains( 'Index', $renderer->render( $entry, $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $entry, $view ) ); + $this->assertStringNotContainsString( 'Index', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $entry, $view ) ); remove_filter( 'gravityview/render/hide-empty-zone', $filter ); @@ -7107,8 +7107,8 @@ public function test_hide_empty_filters_compat() { gravityview()->request->returns['is_view'] = $view; $renderer = new \GV\View_Renderer(); - $this->assertContains( 'Index', $renderer->render( $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $view ) ); + $this->assertStringContainsString( 'Index', $renderer->render( $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $view ) ); add_filter( 'gravityview/render/hide-empty-zone', $filter = function( $hide, $context ) use ( &$test, &$view ) { $test->assertSame( $context->view, $view ); @@ -7116,8 +7116,8 @@ public function test_hide_empty_filters_compat() { }, 10, 2 ); $id = sprintf( 'gv-field-%d-%d', $form['id'], 2 ); - $this->assertNotContains( 'Index', $renderer->render( $view ) ); - $this->assertContains( 'Microtime', $renderer->render( $view ) ); + $this->assertStringNotContainsString( 'Index', $renderer->render( $view ) ); + $this->assertStringContainsString( 'Microtime', $renderer->render( $view ) ); remove_filter( 'gravityview/render/hide-empty-zone', $filter ); } @@ -7229,11 +7229,11 @@ public function test_field_output_args_filter_compat() { $renderer = new \GV\View_Renderer(); $out = $renderer->render( $view ); - $this->assertContains( '[spAce==value==]', $out ); - $this->assertContains( 'sentinel-class', $out ); - $this->assertContains( '--spAce==value==--', $out ); - $this->assertContains( '{{ gravityview_field_output }}', $out ); - $this->assertContains( '{{ gravityview/field_output/html }}', $out ); + $this->assertStringContainsString( '[spAce==value==]', $out ); + $this->assertStringContainsString( 'sentinel-class', $out ); + $this->assertStringContainsString( '--spAce==value==--', $out ); + $this->assertStringContainsString( '{{ gravityview_field_output }}', $out ); + $this->assertStringContainsString( '{{ gravityview/field_output/html }}', $out ); $removed = array( remove_filter( 'gravityview/field_output/args', array_shift( $callbacks ) ), @@ -7346,10 +7346,10 @@ public function test_field_value_filters_compat_generic() { $field->show_as_link = true; $template = new \GV\Field_HTML_Template( $field, $view, $view->form, $entry, $request ); ob_start(); $template->render(); $output = ob_get_clean(); - $this->assertContains( "

    hello

    \n<< gravityview_field_entry_value_textarea_pre_link >><< gravityview_field_entry_value_pre_link >>", $output ); - $this->assertContains( 'pre_link >>{{ gravityview_field_entry_link }}==gravityview/template/field/entry_link==', $output ); - $this->assertContains( '/entry_link=={{ gravityview_field_entry_value_textarea }}{{ gravityview_field_entry_value }}', $output ); - $this->assertContains( 'field_entry_value }}(__gravityview/template/field/textarea/output__)(__gravityview/template/field/output__)', $output ); + $this->assertStringContainsString( "

    hello

    \n<< gravityview_field_entry_value_textarea_pre_link >><< gravityview_field_entry_value_pre_link >>", $output ); + $this->assertStringContainsString( 'pre_link >>{{ gravityview_field_entry_link }}==gravityview/template/field/entry_link==', $output ); + $this->assertStringContainsString( '/entry_link=={{ gravityview_field_entry_value_textarea }}{{ gravityview_field_entry_value }}', $output ); + $this->assertStringContainsString( 'field_entry_value }}(__gravityview/template/field/textarea/output__)(__gravityview/template/field/output__)', $output ); $removed = array( remove_filter( 'gravityview_empty_value', array_shift( $callbacks ) ), @@ -7500,7 +7500,7 @@ public function test_oembed_in_custom_content() { $renderer = new \GV\Entry_Renderer(); - $this->assertContains( 'You are here.', $renderer->render( $entry, $view ) ); + $this->assertStringContainsString( 'You are here.', $renderer->render( $entry, $view ) ); $this->_reset_context(); } @@ -7669,29 +7669,25 @@ public function test_view_csv_tsv_simple() { ob_start(); $view::template_redirect(); + $expected = array( '"Order ID",Item,"Customer Name","Customer First Name"', $entry2->ID . ',"\'=Broomsticks x 8","Harry Churchill",Harry', $entry->ID . ',"A pair of shoes","Winston Potter",Winston', ); - $this->assertEquals( implode( "\n", $expected ), ob_get_clean() ); + $this->assertEquals( implode( "\n", $expected ), rtrim( ob_get_clean() ) ); remove_filter( 'gform_include_bom_export_entries', '__return_false' ); set_query_var( 'csv', null ); set_query_var( 'tsv', 1 ); - $this->assertNull( $view::template_redirect() ); - gravityview()->request = new \GV\Mock_Request(); gravityview()->request->returns['is_view'] = $view; - $this->assertNull( $view::template_redirect() ); - $view->settings->update( array( 'csv_enable' => '1' ) ); add_filter( 'gform_include_bom_export_entries', '__return_false' ); - ob_start(); $view::template_redirect(); $expected = array( @@ -7699,7 +7695,7 @@ public function test_view_csv_tsv_simple() { $entry2->ID . "\t" . '"\'=Broomsticks x 8"' . "\t" . '"Harry Churchill"' . "\t" . 'Harry', $entry->ID . "\t" . '"A pair of shoes"' . "\t" . '"Winston Potter"' . "\t" . 'Winston', ); - $this->assertEquals( implode( "\n", $expected ), ob_get_clean() ); + $this->assertEquals( implode( "\n", $expected ), rtrim( ob_get_clean() ) ); remove_filter( 'gform_include_bom_export_entries', '__return_false' ); @@ -8146,10 +8142,10 @@ public function test_hide_empty_products() { $future = $renderer->render( $entry, $view ); - $this->assertNotContains( 'Product A', $future ); - $this->assertNotContains( 'Product C', $future ); - $this->assertNotContains( 'Quantity C', $future ); - $this->assertContains( 'Product B', $future ); + $this->assertStringNotContainsString( 'Product A', $future ); + $this->assertStringNotContainsString( 'Product C', $future ); + $this->assertStringNotContainsString( 'Quantity C', $future ); + $this->assertStringContainsString( 'Product B', $future ); $entry = $this->factory->entry->create_and_get( array( 'form_id' => $form['id'], @@ -8172,10 +8168,10 @@ public function test_hide_empty_products() { $future = $renderer->render( $entry, $view ); - $this->assertContains( 'Product A', $future ); - $this->assertContains( 'Product B', $future ); - $this->assertNotContains( 'Product C', $future ); - $this->assertNotContains( 'Quantity C', $future ); + $this->assertStringContainsString( 'Product A', $future ); + $this->assertStringContainsString( 'Product B', $future ); + $this->assertStringNotContainsString( 'Product C', $future ); + $this->assertStringNotContainsString( 'Quantity C', $future ); $entry = $this->factory->entry->create_and_get( array( 'form_id' => $form['id'], @@ -8199,10 +8195,10 @@ public function test_hide_empty_products() { $future = $renderer->render( $entry, $view ); - $this->assertContains( 'Product A', $future ); - $this->assertContains( 'Product B', $future ); - $this->assertContains( 'Product C', $future ); - $this->assertContains( 'Quantity C', $future ); + $this->assertStringContainsString( 'Product A', $future ); + $this->assertStringContainsString( 'Product B', $future ); + $this->assertStringContainsString( 'Product C', $future ); + $this->assertStringContainsString( 'Quantity C', $future ); $form['fields'][0]->inputType = 'price'; $form['fields'][0]->inputs = null; @@ -8225,7 +8221,7 @@ public function test_hide_empty_products() { $future = $renderer->render( $entry, $view ); - $this->assertContains( 'Product A', $future ); + $this->assertStringContainsString( 'Product A', $future ); $this->_reset_context(); } @@ -8276,8 +8272,8 @@ public function test_view_csv_address() { ob_start(); $view::template_redirect(); - $this->assertNotContains( 'google', $out = ob_get_clean() ); - $this->assertContains( "A1\nA2\n", $out ); + $this->assertStringNotContainsString( 'google', $out = ob_get_clean() ); + $this->assertStringContainsString( "A1\nA2\n", $out ); add_filter( 'gravityview/template/field/address/csv/delimiter', $callback = function() { return ', '; @@ -8285,7 +8281,7 @@ public function test_view_csv_address() { ob_start(); $view::template_redirect(); - $this->assertContains( "C, S Z", ob_get_clean()); + $this->assertStringContainsString( "C, S Z", ob_get_clean()); remove_filter( 'gravityview/template/field/address/csv/delimiter', $callback ); @@ -8377,23 +8373,23 @@ public function test_sequence_merge_tag_renders() { $out = $renderer->render( $view ); - $this->assertContains( 'Row 1, yes, 3, 11, 12 12 12', $out ); - $this->assertContains( 'class-1-custom-1', $out ); - $this->assertContains( 'Row 2, yes, 2, 12, 11 11 11', $out ); - $this->assertContains( 'class-2-custom-1', $out ); - $this->assertContains( 'Row 3, yes, 1, 13, 10 10 10', $out ); - $this->assertContains( 'class-3-custom-1', $out ); - $this->assertContains( 'Another row 1, ha, 2, 3 3. This will be the field value: 450.', $out ); - $this->assertContains( 'class-11-custom-2', $out ); - $this->assertContains( 'Another row 2, ha, 3, 2 2. This will be the field value: 300.', $out ); - $this->assertContains( 'class-12-custom-2', $out ); - $this->assertContains( 'Another row 3, ha, 4, 1 1. This will be the field value: 150.', $out ); - $this->assertContains( 'class-13-custom-2', $out ); - $this->assertContains( 'class-3-field-2', $out ); + $this->assertStringContainsString( 'Row 1, yes, 3, 11, 12 12 12', $out ); + $this->assertStringContainsString( 'class-1-custom-1', $out ); + $this->assertStringContainsString( 'Row 2, yes, 2, 12, 11 11 11', $out ); + $this->assertStringContainsString( 'class-2-custom-1', $out ); + $this->assertStringContainsString( 'Row 3, yes, 1, 13, 10 10 10', $out ); + $this->assertStringContainsString( 'class-3-custom-1', $out ); + $this->assertStringContainsString( 'Another row 1, ha, 2, 3 3. This will be the field value: 450.', $out ); + $this->assertStringContainsString( 'class-11-custom-2', $out ); + $this->assertStringContainsString( 'Another row 2, ha, 3, 2 2. This will be the field value: 300.', $out ); + $this->assertStringContainsString( 'class-12-custom-2', $out ); + $this->assertStringContainsString( 'Another row 3, ha, 4, 1 1. This will be the field value: 150.', $out ); + $this->assertStringContainsString( 'class-13-custom-2', $out ); + $this->assertStringContainsString( 'class-3-field-2', $out ); - $this->assertContains( 'Widgets are working.', $out ); - $this->assertContains( 'But as expected, "{sequence}" is not working.', $out ); + $this->assertStringContainsString( 'Widgets are working.', $out ); + $this->assertStringContainsString( 'But as expected, "{sequence}" is not working.', $out ); $this->_reset_context(); } @@ -8449,13 +8445,13 @@ public function test_notice_reserved_slugs() { $this->go_to( get_permalink( $post ) ); // Only admins see the notice - $this->assertNotContains( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); - $this->assertNotContains( 'error', $content ); + $this->assertStringNotContainsString( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); + $this->assertStringNotContainsString( 'error', $content ); wp_set_current_user( $administrator ); - $this->assertContains( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); - $this->assertContains( 'error', $content ); + $this->assertStringContainsString( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); + $this->assertStringContainsString( 'error', $content ); // No permalink should work fine, though $this->set_permalink_structure( '' ); @@ -8464,8 +8460,8 @@ public function test_notice_reserved_slugs() { $this->go_to( get_permalink( $post ) ); - $this->assertNotContains( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); - $this->assertNotContains( 'error', $content ); + $this->assertStringNotContainsString( 'on this page', $content = apply_filters( 'the_content', $post->post_content ) ); + $this->assertStringNotContainsString( 'error', $content ); wp_delete_post( $post->ID ); @@ -8490,8 +8486,8 @@ public function test_notice_reserved_slugs() { foreach ( $posts as $post ) { $this->go_to( get_permalink( $post ) ); - $this->assertContains( 'on this page', $content = apply_filters( 'the_content', $post->post_content ), $post->post_name ); - $this->assertContains( 'error', $content, $post->post_name ); + $this->assertStringContainsString( 'on this page', $content = apply_filters( 'the_content', $post->post_content ), $post->post_name ); + $this->assertStringContainsString( 'error', $content, $post->post_name ); wp_delete_post( $post->ID ); // Remove for next test } @@ -8511,8 +8507,8 @@ public function test_notice_reserved_slugs() { $this->go_to( get_permalink( $post ) ); $content = $GLOBALS['wp_embed']->autoembed( $post->post_content ); - $this->assertContains( 'on this page', $content, $post->post_name ); - $this->assertContains( 'error', $content, $post->post_name ); + $this->assertStringContainsString( 'on this page', $content, $post->post_name ); + $this->assertStringContainsString( 'error', $content, $post->post_name ); wp_delete_post( $post->ID ); // Remove for next test } @@ -8587,22 +8583,22 @@ public function test_sort_reset() { $output = $renderer->render( $view ); - $this->assertContains( 'gv-icon-sort-asc', $output ); - $this->assertContains( urlencode( 'sort[4]' ) . '"', $output ); + $this->assertStringContainsString( 'gv-icon-sort-asc', $output ); + $this->assertStringContainsString( urlencode( 'sort[4]' ) . '"', $output ); $_GET['sort'] = array( '4' => 'ASC', ); $output = $renderer->render( $view ); - $this->assertContains( 'gv-icon-sort-desc', $output ); - $this->assertContains( urlencode( 'sort[4]' ) . '=desc', $output ); + $this->assertStringContainsString( 'gv-icon-sort-desc', $output ); + $this->assertStringContainsString( urlencode( 'sort[4]' ) . '=desc', $output ); $_GET['sort'] = array( '4' => '', ); $output = $renderer->render( $view ); - $this->assertContains( 'gv-icon-caret-up-down', $output ); - $this->assertContains( urlencode( 'sort[4]' ) . '=asc', $output ); + $this->assertStringContainsString( 'gv-icon-caret-up-down', $output ); + $this->assertStringContainsString( urlencode( 'sort[4]' ) . '=asc', $output ); $this->_reset_context(); } diff --git a/tests/unit-tests/GravityView_GVEntry_Shortcode_Test.php b/tests/unit-tests/GravityView_GVEntry_Shortcode_Test.php index 7e1861efe..aab4c02bf 100644 --- a/tests/unit-tests/GravityView_GVEntry_Shortcode_Test.php +++ b/tests/unit-tests/GravityView_GVEntry_Shortcode_Test.php @@ -46,9 +46,9 @@ public function test_shortcode() { $gventry = new \GV\Shortcodes\gventry(); - $this->assertContains( 'Textarea

    hello

    ', $gventry->callback( $atts ) ); + $this->assertStringContainsString( 'Textarea

    hello

    ', $gventry->callback( $atts ) ); - $this->assertContains( 'Textarea

    hello

    ', $gventry->callback( $atts_id ) ); + $this->assertStringContainsString( 'Textarea

    hello

    ', $gventry->callback( $atts_id ) ); $get_atts = array( 'view_id' => '{get:view_id}', @@ -57,7 +57,7 @@ public function test_shortcode() { $_GET = $atts; - $this->assertContains( 'Textarea

    hello

    ', $gventry->callback( $get_atts ), '$_GET merge tags not being replaced' ); + $this->assertStringContainsString( 'Textarea

    hello

    ', $gventry->callback( $get_atts ), '$_GET merge tags not being replaced' ); $_GET = array(); @@ -75,7 +75,7 @@ public function test_shortcode() { return $atts; } ); - $this->assertContains( 'Textarea

    well, o!

    ', $gventry->callback( $atts ) ); + $this->assertStringContainsString( 'Textarea

    well, o!

    ', $gventry->callback( $atts ) ); add_filter( 'gravityview/shortcodes/gventry/output', function( $output ) { return 'heh, o!'; @@ -99,10 +99,10 @@ public function test_shortcode() { * last means the other way around. */ $atts['entry_id'] = 'first'; - $this->assertContains( sprintf( 'Entry ID%d', $and_another_entry['id'] ), $gventry->callback( $atts ) ); + $this->assertStringContainsString( sprintf( 'Entry ID%d', $and_another_entry['id'] ), $gventry->callback( $atts ) ); $atts['entry_id'] = 'last'; - $this->assertContains( sprintf( 'Entry ID%d', $entry['id'] ), $gventry->callback( $atts ) ); + $this->assertStringContainsString( sprintf( 'Entry ID%d', $entry['id'] ), $gventry->callback( $atts ) ); } public function test_failures() { @@ -185,6 +185,6 @@ public function test_failures() { 'entry_id' => $entry['id'], ); - $this->assertContains( 'password', $gventry->callback( $atts ) ); + $this->assertStringContainsString( 'password', $gventry->callback( $atts ) ); } } diff --git a/tests/unit-tests/GravityView_GVLogic_Shortcode_Test.php b/tests/unit-tests/GravityView_GVLogic_Shortcode_Test.php index 072bd6c36..471468af5 100644 --- a/tests/unit-tests/GravityView_GVLogic_Shortcode_Test.php +++ b/tests/unit-tests/GravityView_GVLogic_Shortcode_Test.php @@ -401,7 +401,7 @@ function test_gv_shortcode_texturized_quotes_in_attributes() { $content = apply_filters( 'the_content', $content ); - $this->assertContains( 'CORRECT!', $content ); + $this->assertStringContainsString( 'CORRECT!', $content ); // Now test single quotes. $content = <<assertContains( 'CORRECT!', $content ); + $this->assertStringContainsString( 'CORRECT!', $content ); } function get_test_gv_shortcode_date_comparison() { diff --git a/tests/unit-tests/GravityView_Joins_Test.php b/tests/unit-tests/GravityView_Joins_Test.php index 9a33fb42b..2538b5725 100644 --- a/tests/unit-tests/GravityView_Joins_Test.php +++ b/tests/unit-tests/GravityView_Joins_Test.php @@ -909,47 +909,47 @@ public function test_single_entry_join_permissions() { $output = do_shortcode( '[gravityview id=' . $view->ID . ']' ); - $this->assertContains( 'entry=' . implode( ',', array( $c1['id'], $s1['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c1['id'], $s2['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c2['id'], $s3['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c2['id'], $s4['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c1['id'], $s1['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c1['id'], $s2['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c2['id'], $s3['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c2['id'], $s4['id'] ) ), $output ); $output = $view->content( '' ); - $this->assertContains( 'entry=' . implode( ',', array( $c1['id'], $s1['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c1['id'], $s2['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c2['id'], $s3['id'] ) ), $output ); - $this->assertContains( 'entry=' . implode( ',', array( $c2['id'], $s4['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c1['id'], $s1['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c1['id'], $s2['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c2['id'], $s3['id'] ) ), $output ); + $this->assertStringContainsString( 'entry=' . implode( ',', array( $c2['id'], $s4['id'] ) ), $output ); gravityview()->request->returns['is_entry'] = \GV\Multi_Entry::from_entries( array( \GV\GF_Entry::by_id( $c1['id'] ), \GV\GF_Entry::by_id( $s1['id'] ), ) ); $output = do_shortcode( '[gravityview id=' . $view->ID . ']' ); - $this->assertNotContains( 'not allowed', $output ); + $this->assertStringNotContainsString( 'not allowed', $output ); $output = $view->content( '' ); - $this->assertNotContains( 'not allowed', $output ); + $this->assertStringNotContainsString( 'not allowed', $output ); gravityview()->request->returns['is_entry'] = \GV\Multi_Entry::from_entries( array( \GV\GF_Entry::by_id( $c2['id'] ), \GV\GF_Entry::by_id( $s3['id'] ), ) ); $output = do_shortcode( '[gravityview id=' . $view->ID . ']' ); - $this->assertNotContains( 'not allowed', $output ); + $this->assertStringNotContainsString( 'not allowed', $output ); $output = $view->content( '' ); - $this->assertNotContains( 'not allowed', $output ); + $this->assertStringNotContainsString( 'not allowed', $output ); gravityview()->request->returns['is_entry'] = \GV\Multi_Entry::from_entries( array( \GV\GF_Entry::by_id( $c1['id'] ), \GV\GF_Entry::by_id( $n1['id'] ), ) ); $output = do_shortcode( '[gravityview id=' . $view->ID . ']' ); - $this->assertContains( 'not allowed', $output ); + $this->assertStringContainsString( 'not allowed', $output ); $output = $view->content( '' ); - $this->assertContains( 'not allowed', $output ); + $this->assertStringContainsString( 'not allowed', $output ); } /** @@ -1261,8 +1261,8 @@ public function test_joins_custom_content() { $out = $renderer->render( $view ); - $this->assertContains( sprintf( 'Step 1">%s<', $entry1_1['id'] ), $out ); - $this->assertContains( sprintf( 'Step 2">%s<', $entry1_2['id'] ), $out ); + $this->assertStringContainsString( sprintf( 'Step 1">%s<', $entry1_1['id'] ), $out ); + $this->assertStringContainsString( sprintf( 'Step 2">%s<', $entry1_2['id'] ), $out ); $this->_reset_context(); } diff --git a/tests/unit-tests/GravityView_REST_Test.php b/tests/unit-tests/GravityView_REST_Test.php index 025a595b5..4ede844ea 100644 --- a/tests/unit-tests/GravityView_REST_Test.php +++ b/tests/unit-tests/GravityView_REST_Test.php @@ -22,7 +22,6 @@ public function test_register_routes() { $this->assertEquals( 'gravityview/v1', \GV\REST\Core::get_namespace() ); $routes = rest_get_server()->get_routes(); - $this->assertArrayHasKey( '/' . \GV\REST\Core::get_namespace(), $routes ); $this->assertArrayHasKey( '/' . \GV\REST\Core::get_namespace() . '/views', $routes ); $this->assertArrayHasKey( '/' . \GV\REST\Core::get_namespace() . '/views/(?P[\d]+)', $routes ); @@ -182,16 +181,16 @@ public function test_get_items() { $this->assertEquals( 3, $response->headers['X-Item-Count'] ); $html = $response->get_data(); - $this->assertContains( '', $html ); - $this->assertContains( 'gv-table-view', $html ); - $this->assertContains( 'set all the fields!', $html ); - $this->assertContains( 'set all the fields! 1', $html ); - $this->assertContains( 'set all the fields! 2', $html ); + $this->assertStringContainsString( '', $html ); + $this->assertStringContainsString( 'gv-table-view', $html ); + $this->assertStringContainsString( 'set all the fields!', $html ); + $this->assertStringContainsString( 'set all the fields! 1', $html ); + $this->assertStringContainsString( 'set all the fields! 2', $html ); $this->assertTrue( add_filter( 'gravityview/rest/entries/html/insert_meta', '__return_false' ) ); $response = rest_get_server()->dispatch( $request ); $html = $response->get_data(); - $this->assertNotContains( 'assertStringNotContainsString( 'assertTrue( remove_filter( 'gravityview/rest/entries/html/insert_meta', '__return_false' ) ); $request = new WP_REST_Request( 'GET', '/gravityview/v1/views/' . $view->ID . '/entries.html' ); @@ -203,7 +202,7 @@ public function test_get_items() { $this->assertEquals( 0, $response->headers['X-Item-Count'] ); $html = $response->get_data(); - $this->assertContains( '', $html ); + $this->assertStringContainsString( '', $html ); $request = new WP_REST_Request( 'GET', '/gravityview/v1/views/' . $view->ID . '/entries.csv' ); ob_start(); // CSV binary data is output ad hoc @@ -214,7 +213,7 @@ public function test_get_items() { $this->assertEquals( 'text/csv', $response->headers['Content-Type'] ); $this->assertStringStartsWith( chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ), $csv ); - $this->assertContains( $entry2['id'] . ',"set all the fields! 2"', $csv ); + $this->assertStringContainsString( $entry2['id'] . ',"set all the fields! 2"', $csv ); $request = new WP_REST_Request( 'GET', '/gravityview/v1/views/' . $view->ID . '/entries.tsv' ); ob_start(); // TSV binary data is output ad hoc @@ -225,7 +224,7 @@ public function test_get_items() { $this->assertEquals( 'text/tsv', $response->headers['Content-Type'] ); $this->assertStringStartsWith( chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ), $tsv ); - $this->assertContains( $entry2['id'] . "\t" . '"set all the fields! 2"', $tsv ); + $this->assertStringContainsString( $entry2['id'] . "\t" . '"set all the fields! 2"', $tsv ); } public function test_get_items_csv_complex() { @@ -280,9 +279,9 @@ public function test_get_items_csv_complex() { $this->assertEquals( 2, $response->headers['X-Item-Count'] ); $this->assertStringStartsWith( chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ), $csv ); - $this->assertContains( 'id,16,8', $csv ); - $this->assertContains( $entry2['id'] . ',"\'=Broomsticks x 8","Harry Churchill"', $csv ); - $this->assertContains( $entry['id'] . ',"A pair of shoes","Winston Potter"', $csv ); + $this->assertStringContainsString( 'id,16,8', $csv ); + $this->assertStringContainsString( $entry2['id'] . ',"\'=Broomsticks x 8","Harry Churchill"', $csv ); + $this->assertStringContainsString( $entry['id'] . ',"A pair of shoes","Winston Potter"', $csv ); $this->assertStringEndsWith( '"', $csv ); } @@ -376,8 +375,8 @@ public function test_get_items_custom_content() { $response = rest_get_server()->dispatch( $request ); $csv = ob_get_clean(); - $this->assertContains( 'id,id/2/,custom,custom/2/', $csv ); - $this->assertContains( "{$entry['id']},{$entry['id']},hello,world", $csv ); + $this->assertStringContainsString( 'id,id/2/,custom,custom/2/', $csv ); + $this->assertStringContainsString( "{$entry['id']},{$entry['id']},hello,world", $csv ); remove_filter( 'gravityview/api/field/key', $callback ); } @@ -512,8 +511,8 @@ public function test_get_item() { $this->assertEquals( 200, $response->status ); $html = $response->get_data(); - $this->assertContains( 'gv-table-view', $html ); - $this->assertContains( 'set all the fields!', $html ); + $this->assertStringContainsString( 'gv-table-view', $html ); + $this->assertStringContainsString( 'set all the fields!', $html ); remove_filter( 'gravityview/rest/entry/fields', $callback ); } @@ -786,11 +785,11 @@ public function test_get_items_csv_raw() { $this->assertEquals( 1, $response->headers['X-Item-Count'] ); $this->assertStringStartsWith( chr( 0xEF ) . chr( 0xBB ) . chr( 0xBF ), $csv ); - $this->assertContains( 'one,two', $csv ); - $this->assertNotContains( '<', $csv ); - $this->assertNotContains( '[', $csv ); - $this->assertContains( 'one.jpg', $csv ); - $this->assertContains( 'two.mp3', $csv ); + $this->assertStringContainsString( 'one,two', $csv ); + $this->assertStringNotContainsString( '<', $csv ); + $this->assertStringNotContainsString( '[', $csv ); + $this->assertStringContainsString( 'one.jpg', $csv ); + $this->assertStringContainsString( 'two.mp3', $csv ); } public function test_get_items_raw() { diff --git a/tests/unit-tests/GravityView_Render_Settings_Test.php b/tests/unit-tests/GravityView_Render_Settings_Test.php index 9267a06a7..1f001c152 100644 --- a/tests/unit-tests/GravityView_Render_Settings_Test.php +++ b/tests/unit-tests/GravityView_Render_Settings_Test.php @@ -28,11 +28,11 @@ public function test_render_field_options() { $output = GravityView_Render_Settings::render_field_options( $form['id'], 'field', 'default_table', '12', 'Example Field Label', 'directory_table-columns', 'multiselect', 'UNIQID_EXAMPLE', '', 'single', array() ); #' - $this->assertContains( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][id]" value="12"', $output ); - $this->assertContains( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][label]" value="Example Field Label"', $output ); - $this->assertContains( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][form_id]" value="' . $form['id'] . '"', $output ); - $this->assertContains( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][only_loggedin]" type="hidden" value="0"', $output ); - $this->assertContains( 'show_label" type="checkbox" value="1" checked=\'checked\' />', $output ); + $this->assertStringContainsString( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][id]" value="12"', $output ); + $this->assertStringContainsString( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][label]" value="Example Field Label"', $output ); + $this->assertStringContainsString( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][form_id]" value="' . $form['id'] . '"', $output ); + $this->assertStringContainsString( 'name="fields[directory_table-columns][UNIQID_EXAMPLE][only_loggedin]" type="hidden" value="0"', $output ); + $this->assertStringContainsString( 'show_label" type="checkbox" value="1" checked=\'checked\' />', $output ); add_filter( 'gravityview_template_field_options', $_change_field_options = function ( $default_options = array() ) { @@ -47,8 +47,8 @@ public function test_render_field_options() { $output = GravityView_Render_Settings::render_field_options( $form['id'], 'field', 'default_table', '12', 'Example Field Label', 'directory_table-columns', 'multiselect', 'UNIQID_EXAMPLE', '', 'single', array() ); - $this->assertContains( 'only_loggedin" type="checkbox" value="1" checked=\'checked\' />', $output ); - $this->assertContains( 'show_label" type="checkbox" value="1" />', $output ); + $this->assertStringContainsString( 'only_loggedin" type="checkbox" value="1" checked=\'checked\' />', $output ); + $this->assertStringContainsString( 'show_label" type="checkbox" value="1" />', $output ); $this->assertTrue( remove_filter( 'gravityview_template_field_options', $_change_field_options ) ); } diff --git a/tests/unit-tests/GravityView_Shortcode_Test.php b/tests/unit-tests/GravityView_Shortcode_Test.php index 016cd2bbf..9e1e8eab6 100644 --- a/tests/unit-tests/GravityView_Shortcode_Test.php +++ b/tests/unit-tests/GravityView_Shortcode_Test.php @@ -429,9 +429,9 @@ public function test_shortcode_single_view_from_directory() { $post = $this->factory->post->create_and_get( array( 'post_content' => '[gravityview id="' . $view->ID . '"]' ) ); - $shorcode = new \GV\Shortcodes\gravityview(); + $shortcode = new \GV\Shortcodes\gravityview(); - $this->assertContains( $field, $shorcode->callback( array( 'id' => $view->ID ) ) ); + $this->assertStringContainsString( $field, $shortcode->callback( array( 'id' => $view->ID ) ) ); gravityview()->request = new \GV\Frontend_Request(); } @@ -472,17 +472,17 @@ public function test_shortcode_search() { $shortcode = new \GV\Shortcodes\gravityview(); $content = $shortcode->callback( array( 'id' => $view->ID ) ); - $this->assertContains( 'data-label="Text">abc', $content ); - $this->assertContains( 'data-label="Text">abcxyz', $content ); + $this->assertStringContainsString( 'data-label="Text">abc', $content ); + $this->assertStringContainsString( 'data-label="Text">abcxyz', $content ); $shortcode = new \GV\Shortcodes\gravityview(); $content = $shortcode->callback( array( 'id' => $view->ID, 'search_field' => '1', 'search_value' => 'abcxyz' ) ); - $this->assertNotContains( 'data-label="Text">abc', $content ); - $this->assertContains( 'data-label="Text">abcxyz', $content ); + $this->assertStringNotContainsString( 'data-label="Text">abc', $content ); + $this->assertStringContainsString( 'data-label="Text">abcxyz', $content ); $shortcode = new \GV\Shortcodes\gravityview(); $content = $shortcode->callback( array( 'id' => $view->ID, 'search_field' => '1', 'search_value' => 'abc', 'search_operator' => 'is' ) ); - $this->assertContains( 'data-label="Text">abc', $content ); - $this->assertNotContains( 'data-label="Text">abcxyz', $content ); + $this->assertStringContainsString( 'data-label="Text">abc', $content ); + $this->assertStringNotContainsString( 'data-label="Text">abcxyz', $content ); } } diff --git a/tests/unit-tests/GravityView_Widget_Page_Size_Test.php b/tests/unit-tests/GravityView_Widget_Page_Size_Test.php index 7d9888600..d66a95354 100644 --- a/tests/unit-tests/GravityView_Widget_Page_Size_Test.php +++ b/tests/unit-tests/GravityView_Widget_Page_Size_Test.php @@ -86,18 +86,18 @@ public function test_page_size_widget_output() { } $future = $renderer->render( $view ); - $this->assertContains( 'gv-page_size', $future ); - $this->assertContains( "", $future, 'default page size should be selected' ); + $this->assertStringContainsString( 'gv-page_size', $future ); + $this->assertStringContainsString( "", $future, 'default page size should be selected' ); // Update default page size $view->settings->update( array( 'page_size' => 50 ) ); $future = $renderer->render( $view ); - $this->assertContains( "", $future, 'default page size should be selected' ); + $this->assertStringContainsString( "", $future, 'default page size should be selected' ); $view->settings->update( array( 'page_size' => 1 ) ); $future = $renderer->render( $view ); - $this->assertContains( "