Version Description
Download this release
Release Info
Developer | danieliser |
Plugin | Popup Maker – Popup Forms, Optins & More |
Version | 1.16.10 |
Comparing to | |
See all releases |
Code changes from version 1.16.9 to 1.16.10
- assets/js/admin-popup-editor.js +2 -1
- assets/js/admin-popup-editor.min.js +1 -1
- classes/Abstract/Batch/Process.php +0 -1
- classes/Abstract/Database.php +44 -28
- classes/Abstract/Integration/Form.php +1 -1
- classes/Abstract/Model/Post.php +4 -4
- classes/Abstract/Model/User.php +6 -6
- classes/Abstract/Provider.php +40 -34
- classes/Abstract/Registry.php +2 -2
- classes/Abstract/Repository/Posts.php +37 -31
- classes/Abstract/Upgrade.php +8 -5
- classes/Abstract/Upgrade/Posts.php +35 -28
- classes/Abstract/Upgrade/Settings.php +1 -1
- classes/Admin.php +13 -10
- classes/Admin/Ajax.php +47 -47
- classes/Admin/Assets.php +58 -48
- classes/Admin/BlockEditor.php +1 -2
- classes/Admin/Extend.php +108 -91
- classes/Admin/Helpers.php +109 -95
- classes/Admin/Onboarding.php +139 -114
- classes/Admin/Pages.php +69 -57
- classes/Admin/Popups.php +596 -553
- classes/Admin/Settings.php +380 -359
- classes/Admin/Shortcode/UI.php +35 -25
- classes/Admin/Subscribers.php +11 -8
- classes/Admin/Subscribers/Table.php +120 -84
- classes/Admin/Support.php +10 -10
- classes/Admin/Templates.php +57 -48
- classes/Admin/Themes.php +852 -794
- classes/Admin/Tools.php +20 -20
- classes/Ajax.php +2 -3
- classes/Analytics.php +47 -37
- classes/AssetCache.php +75 -66
- classes/Batch/Process/Registry.php +2 -2
- classes/ConditionCallbacks.php +15 -15
- classes/Conditions.php +120 -108
- classes/Cookies.php +126 -107
- classes/DB/Subscribers.php +28 -25
- classes/Deactivator.php +1 -1
- classes/Extension/Activator.php +18 -15
- classes/Extension/License.php +66 -59
- classes/Extension/Updater.php +99 -69
- classes/GA.php +17 -11
- classes/Helpers.php +63 -55
- classes/Install.php +21 -18
- classes/Integration/Form/CalderaForms.php +8 -6
- classes/Integration/Form/ContactForm7.php +14 -10
- classes/Integration/Form/FormidableForms.php +1 -1
- classes/Integration/Form/GravityForms.php +8 -6
- classes/Integration/Form/NinjaForms.php +16 -12
- classes/Integration/Form/PirateForms.php +13 -11
- classes/Integration/Form/WPForms.php +13 -11
- classes/Integration/GoogleFonts.php +9 -11
- classes/Integrations.php +81 -62
- classes/Interface/CSV/Importer.php +1 -1
- classes/Interface/Provider.php +5 -5
- classes/Interface/Repository.php +2 -2
- classes/Licensing.php +27 -28
- classes/ListTable.php +232 -153
- classes/Model/Popup.php +231 -184
- classes/Model/Post.php +1 -1
- classes/Model/Theme.php +53 -55
- classes/Newsletter/Provider.php +3 -3
- classes/Newsletter/Providers.php +4 -4
- classes/Newsletters.php +75 -62
- classes/Popup.php +1 -1
- classes/Popups.php +8 -5
- classes/Previews.php +74 -69
- classes/Privacy.php +89 -77
- classes/Repository/Popups.php +8 -8
- classes/Repository/Themes.php +8 -8
- classes/Shortcode.php +51 -48
- classes/Shortcode/Popup.php +159 -145
- classes/Shortcode/PopupClose.php +48 -47
- classes/Shortcode/PopupCookie.php +16 -13
- classes/Shortcode/PopupTrigger.php +45 -41
- classes/Shortcode/Subscribe.php +434 -391
- classes/Shortcodes.php +2 -2
- classes/Site.php +9 -9
- classes/Site/Assets.php +128 -86
- classes/Telemetry.php +26 -26
- classes/Triggers.php +60 -61
- classes/Types.php +95 -71
- classes/Upgrade/Registry.php +10 -7
- classes/Upsell.php +29 -29
- classes/Utils/Alerts.php +123 -84
- classes/Utils/CSS.php +4 -4
- classes/Utils/Config.php +1 -1
- classes/Utils/Cron.php +6 -6
- classes/Utils/DataStorage.php +9 -9
- classes/Utils/Fields.php +88 -84
- classes/Utils/Format.php +4 -4
- classes/Utils/I10n.php +6 -6
- classes/Utils/Logging.php +2 -2
- classes/Utils/Options.php +7 -7
- classes/Utils/Prerequisites.php +8 -4
- classes/Utils/Sanitize.php +4 -4
- classes/Utils/Template.php +18 -16
- classes/Utils/Upgrades.php +103 -78
- includes/admin/class-pum-admin-upgrades.php +627 -629
- includes/admin/upgrades/class-pum-admin-upgrade-routine-2.php +18 -17
- includes/admin/upgrades/class-pum-admin-upgrade-routine-3.php +33 -33
- includes/admin/upgrades/class-pum-admin-upgrade-routine-4.php +57 -59
- includes/admin/upgrades/class-pum-admin-upgrade-routine-5.php +13 -12
- includes/admin/upgrades/class-pum-admin-upgrade-routine-6.php +30 -28
- includes/admin/upgrades/class-pum-admin-upgrade-routine.php +14 -10
- includes/batch/upgrade/class-upgrade-v1_7-settings.php +3 -3
- includes/batch/upgrade/class-upgrade-v1_8-themes.php +8 -8
- includes/class-popmake-fields.php +174 -147
- includes/class-pum-fields.php +320 -239
- includes/class-pum-form.php +1 -1
- includes/compat.php +48 -47
- includes/compatibility/function-wp_removable_query_args.php +2 -2
- includes/defaults.php +43 -37
- includes/deprecated-classes.php +11 -11
- includes/deprecated-filters.php +3 -3
- includes/failsafes.php +2 -2
- includes/functions-backcompat.php +3 -3
- includes/functions-deprecated.php +37 -30
- includes/functions/admin/conditionals.php +12 -12
- includes/functions/admin/general.php +5 -5
- includes/functions/developers.php +24 -21
- includes/functions/extensions.php +1 -1
- includes/functions/general.php +6 -6
- includes/functions/newsletter.php +14 -14
- includes/functions/popups/conditionals.php +1 -1
- includes/functions/popups/deprecated.php +10 -11
- includes/functions/popups/getters.php +2 -3
- includes/functions/popups/migrations.php +38 -29
- includes/functions/popups/queries.php +9 -6
- includes/functions/themes/deprecated.php +31 -30
- includes/functions/themes/getters.php +1 -1
- includes/functions/themes/migrations.php +9 -8
- includes/functions/themes/portability.php +35 -22
- includes/functions/themes/queries.php +9 -6
- includes/functions/themes/template.php +4 -5
- includes/functions/utils/cache.php +5 -5
- includes/functions/utils/format.php +2 -2
- includes/functions/utils/options.php +5 -5
- includes/functions/utils/template.php +8 -8
- includes/functions/utils/upgrades.php +2 -2
- includes/importer/easy-modal-v2.php +158 -143
- includes/importer/easy-modal-v2/functions.php +11 -11
- includes/importer/easy-modal-v2/model.php +13 -13
- includes/importer/easy-modal-v2/model/modal.php +16 -16
- includes/importer/easy-modal-v2/model/modal/meta.php +10 -10
- includes/importer/easy-modal-v2/model/theme.php +16 -16
- includes/importer/easy-modal-v2/model/theme/meta.php +13 -13
- includes/input-options.php +111 -84
- includes/integrations/class-pum-buddypress-integration.php +112 -110
- includes/integrations/class-pum-cf7.php +115 -108
- includes/integrations/class-pum-gravity-forms.php +114 -111
- includes/integrations/class-pum-ninja-forms.php +9 -9
- includes/integrations/class-pum-woocommerce-integration.php +26 -26
- includes/integrations/class-pum-wpml.php +54 -48
- includes/integrations/ninja-forms/Actions/ClosePopup.php +5 -5
- includes/integrations/ninja-forms/Actions/OpenPopup.php +28 -31
- includes/modules/admin-bar.php +136 -111
- includes/modules/menus.php +24 -22
assets/js/admin-popup-editor.js
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
window.pum_popup_settings_editor = window.pum_popup_settings_editor || {
|
10 |
form_args: {},
|
11 |
current_values: {},
|
|
|
12 |
};
|
13 |
|
14 |
$( document )
|
@@ -67,7 +68,7 @@
|
|
67 |
.attr(
|
68 |
'href',
|
69 |
pum_admin_vars.homeurl +
|
70 |
-
'?popup_preview=
|
71 |
$( '#post_ID' ).val()
|
72 |
)
|
73 |
.text( pum_admin_vars.I10n.preview_popup )
|
9 |
window.pum_popup_settings_editor = window.pum_popup_settings_editor || {
|
10 |
form_args: {},
|
11 |
current_values: {},
|
12 |
+
preview_nonce: null,
|
13 |
};
|
14 |
|
15 |
$( document )
|
68 |
.attr(
|
69 |
'href',
|
70 |
pum_admin_vars.homeurl +
|
71 |
+
'?popup_preview=' + pum_popup_settings_editor.preview_nonce + '&popup=' +
|
72 |
$( '#post_ID' ).val()
|
73 |
)
|
74 |
.text( pum_admin_vars.I10n.preview_popup )
|
assets/js/admin-popup-editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var cookies;!function(n){"use strict";window.PUM_Admin=window.PUM_Admin||{},window.pum_popup_settings_editor=window.pum_popup_settings_editor||{form_args:{},current_values:{}},n(document).on("keydown","#popup-title",function(e){9===(e.keyCode||e.which)&&(e.preventDefault(),n("#title").focus())}).on("keydown","#title, #popup-title",function(e){var t=e.keyCode||e.which;e.shiftKey||9!==t||(e.preventDefault(),e="title"===n(this).attr("id")?"#popup-title":"#insert-media-button",n(e).focus())}).on("keydown","#popup-title, #insert-media-button",function(e){var t=e.keyCode||e.which;e.shiftKey&&9===t&&(e.preventDefault(),e="popup-title"===n(this).attr("id")?"#title":"#popup-title",n(e).focus())}),n(function(){n(this).trigger("pum_init"),n("#title").prop("required",!0);var e=n("#pum-popup-settings-container"),t=pum_popup_settings_editor.form_args||{},i=pum_popup_settings_editor.current_values||{};e.length&&(e.find(".pum-no-js").hide(),PUM_Admin.forms.render(t,i,e)),n("a.page-title-action").clone().attr("target","_blank").attr("href",pum_admin_vars.homeurl+"?popup_preview=true&popup="+n("#post_ID").val()).text(pum_admin_vars.I10n.preview_popup).insertAfter("a.page-title-action"),n("#pum-first-condition, #pum-first-trigger, #pum-first-cookie").val(null).trigger("change"),document.querySelector("#pum-popup-settings-container").addEventListener("change",function(e){"open_sound"!==e.target.id||-1===["none","custom"].indexOf(e.target.value)&&((e=new Audio(pum_admin_vars.pm_dir_url+"/assets/sounds/"+e.target.value)).addEventListener("canplaythrough",function(){this.play().catch(function(e){console.warn("Sound was not able to play when selected. Reason: "+e)})}),e.addEventListener("error",function(){console.warn("Error occurred when trying to load popup opening sound.")}))}),n(document).on("pum_init",function(){n("#pum-default-click-trigger-class:not(.pum-click-trigger-initialized)").each(function(){n(this).addClass("pum-click-trigger-initialized").text(n("#popup-id").data("popup-id"))})}),document.querySelector("#pum-popup-settings-container").addEventListener("click",function(e){if(Array.from(e.target.classList).includes("popup-type")||Array.from(e.target.parentElement.classList).includes("popup-type")){var t=jQuery("#pum-popup-settings-container");if(1===t.length){var i={"center-popup":{size:"medium",responsive_min_width:"0%",responsive_max_width:"100%",animation_type:"fade",animation_speed:350,location:"center",position_fixed:!1,position_from_trigger:!1,overlay_disabled:!1,stackable:!1,disable_reposition:!1},"left-bottom-notice":{size:"tiny",responsive_min_width:"0%",responsive_max_width:"100%",animation_type:"fade",animation_speed:350,animation_origin:"left bottom",location:"left bottom",position_bottom:10,position_left:10,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1},"top-bar":{size:"custom",custom_width:"100%",custom_height_auto:!0,animation_type:"fadeAndSlide",animation_speed:300,animation_origin:"top",location:"center top",position_top:0,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1},"right-bottom-slidein":{size:"custom",custom_width:"300px",custom_height_auto:!0,animation_type:"slide",animation_speed:350,animation_origin:"bottom",location:"right bottom",position_bottom:10,position_right:10,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1}},n=e.target.dataset.popupType||e.target.parentElement.dataset.popupType||"",o=i.hasOwnProperty(n)?i[n]:{},e=pum_popup_settings_editor.form_args||{},i=pum_popup_settings_editor.current_values||{},r=t.pumSerializeObject();if(r.popup_settings.triggers)for(var s=0;s<r.popup_settings.triggers.length;s++)r.popup_settings.triggers[s].settings=JSON.parse(r.popup_settings.triggers[s].settings);if(r.popup_settings.cookies)for(var d=0;d<r.popup_settings.cookies.length;d++)r.popup_settings.cookies[d].settings=JSON.parse(r.popup_settings.cookies[d].settings);o=Object.assign({},i,r.popup_settings,o);PUM_Admin.forms.render(e,o,t),document.querySelector('a[href="#pum-popup-settings_display"]').click();t=document.createElement("div");t.classList.add("notice","updated"),t.insertBefore(document.createElement("p"),t.firstChild),t.firstChild.innerText="Display settings have been updated with the "+n+" preset";n=document.querySelector("#pum-popup-settings-display-subtabs_preset");n.insertBefore(t,n.firstChild)}}})})}(jQuery),function(t,e){"use strict";t(e).on("click","#popup_reset_open_count",function(){var e=t(this);e.is(":checked")&&!confirm(pum_admin_vars.I10n.confirm_count_reset)&&e.prop("checked",!1)})}(jQuery,document),function(s){"use strict";var d={get_conditions:function(){return window.pum_popup_settings_editor.conditions_selectlist},not_operand_checkbox:function(e){return(e=e||s(".pum-not-operand")).each(function(){var e=s(this),t=e.find("input");t.prop("checked",!t.is(":checked")),d.toggle_not_operand(e)})},toggle_not_operand:function(e){return(e=e||s(".pum-not-operand")).each(function(){var e=s(this),t=e.find("input"),e=e.parents(".facet-target");t.is(":checked")?e.addClass("not-operand-checked"):e.removeClass("not-operand-checked")})},template:{editor:function(e){e=s.extend(!0,{},{groups:[]},e);return e.groups=PUM_Admin.utils.object_to_array(e.groups),PUM_Admin.templates.render("pum-condition-editor",e)},group:function(e){var t,i=s.extend(!0,{},{index:"",facets:[]},e);for(i.facets=PUM_Admin.utils.object_to_array(i.facets),t=0;i.facets.length>t;t++)i.facets[t].index=t,i.facets[t].group=i.index;return PUM_Admin.templates.render("pum-condition-group",i)},facet:function(e){e=s.extend(!0,{},{group:"",index:"",target:"",not_operand:!1,settings:{}},e);return PUM_Admin.templates.render("pum-condition-facet",e)},settings:function(e,i){var n=[],o=s.extend(!0,{},{index:"",group:"",target:null,fields:[]},e);return o.fields.length||void 0===pum_popup_settings_editor.conditions[e.target]||(o.fields=pum_popup_settings_editor.conditions[e.target].fields),void 0===i&&(i={}),_.each(o.fields,function(e,t){"object"!=typeof(e=PUM_Admin.models.field(e)).meta&&(e.meta={}),void 0!==i[t]&&(e.value=i[t]),e.name="popup_settings[conditions]["+o.group+"]["+o.index+"][settings]["+t+"]",""===e.id&&(e.id="popup_settings_conditions_"+o.group+"_"+o.index+"_settings_"+t),n.push(PUM_Admin.templates.field(e))}),PUM_Admin.templates.section({fields:n})},selectbox:function(e){e=s.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:d.get_conditions()},e);return null===e.id&&(e.id="popup_settings_conditions_"+e.group+"_"+e.index+"_target"),null===e.name&&(e.name="popup_settings[conditions]["+e.group+"]["+e.index+"][target]"),PUM_Admin.templates.field(e)}},groups:{add:function(e,t,i){e=s(e),i={index:e.find(".facet-group-wrap").length,facets:[{target:t||null,not_operand:i||!1,settings:{}}]};e.find(".facet-groups").append(d.template.group(i)),e.addClass("has-conditions")},remove:function(e){var t=e.parents(".facet-builder");e.prev(".facet-group-wrap").find(".and .add-facet").removeClass("disabled"),e.remove(),d.renumber(),0===t.find(".facet-group-wrap").length&&(t.removeClass("has-conditions"),s("#pum-first-condition").val(null).trigger("change"))}},facets:{add:function(e,t,i){i={group:e.data("index"),index:e.find(".facet").length,target:t||null,not_operand:i||!1,settings:{}};e.find(".facet-list").append(d.template.facet(i))},remove:function(e){var t=e.parents(".facet-group-wrap");e.remove(),0===t.find(".facet").length?d.groups.remove(t):d.renumber()}},renumber:function(){s(".facet-builder .facet-group-wrap").each(function(){var e=s(this),i=e.parent().children().index(e);e.data("index",i).find(".facet").each(function(){var e=s(this),t=e.parent().children().index(e);e.data("index",t).find("[name]").each(function(){this.name=this.name.replace(/popup_settings\[conditions\]\[\d*?\]\[\d*?\]/,"popup_settings[conditions]["+i+"]["+t+"]"),this.id=this.id.replace(/popup_settings_conditions_\d*?_\d*?_/,"popup_settings_conditions_"+i+"_"+t+"_")})})})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.conditions=d,s(document).on("pum_init",function(){d.renumber(),d.toggle_not_operand()}).on("select2:select pumselect2:select","#pum-first-condition",function(e){var t=s(this),i=t.parents(".facet-builder").eq(0),n=t.val(),o=i.find("#pum-first-facet-operand"),r=o.is(":checked");d.groups.add(i,n,r),t.val(null).trigger("change"),o.prop("checked",!1).parents(".facet-target").removeClass("not-operand-checked"),s(document).trigger("pum_init")}).on("click",".facet-builder .pum-not-operand",function(){d.not_operand_checkbox(s(this))}).on("change",".facet-builder .facet-target select",function(e){var t=s(this),i=t.parents(".facet"),n=t.val(),t={target:n};""!==n&&n!==i.data("target")&&(i.data("target",n).find(".facet-settings").html(d.template.settings(t)),s(document).trigger("pum_init"))}).on("click",".facet-builder .facet-group-wrap:last-child .and .add-facet",function(){d.groups.add(s(this).parents(".facet-builder").eq(0)),s(document).trigger("pum_init")}).on("click",".facet-builder .add-or .add-facet:not(.disabled)",function(){d.facets.add(s(this).parents(".facet-group-wrap").eq(0)),s(document).trigger("pum_init")}).on("click",".facet-builder .remove-facet",function(){d.facets.remove(s(this).parents(".facet").eq(0)),s(document).trigger("pum_init")})}(jQuery),function(s,e){"use strict";var n,d=pum_admin_vars.I10n,a={get_cookies:function(){return window.pum_popup_settings_editor.cookies},get_cookie:function(e){var t=this.get_cookies(),e="undefined"!==t[e]&&t[e];return!!e&&(e&&"object"==typeof e&&"object"==typeof e.fields&&Object.keys(e.fields).length?this.parseFields(e):e)},getCookieDefaults:function(e){var t,i=a.get_cookie(e),n={};for(t in i.fields)if(i.fields.hasOwnProperty(t))for(var o in i.fields[t])i.fields[t].hasOwnProperty(o)&&(n[o]=i.fields[t][o].std);return n.name="pum-"+s("#post_ID").val(),n},parseFields:function(n){return _.each(n.fields,function(e,i){_.each(e,function(e,t){n.fields[i][t].name="cookie_settings["+t+"]",""===n.fields[i][t].id&&(n.fields[i][t].id="cookie_settings_"+t)})}),n},parseValues:function(e,t){return e},select_list:function(){for(var e=PUM_Admin.utils.object_to_array(a.get_cookies()),t={},i=0;i<e.length;i++)t[e[i].id]=e[i].name;return t},getLabel:function(e){e=a.get_cookie(e);return!!e&&e.name},getSettingsDesc:function(e,t){e=a.get_cookie(e);return!!e&&PUM_Admin.templates.renderInline(e.settings_column,t)},refreshDescriptions:function(){s(".pum-popup-cookie-editor table.list-table tbody tr").each(function(){var e=s(this),t=e.find(".popup_cookies_field_event").val(),i=JSON.parse(e.find(".popup_cookies_field_settings:first").val());e.find("td.settings-column").html(a.getSettingsDesc(t,i))})},insertCookie:function(e,t){var i=a.getCookieDefaults(t.event);t=s.extend(!0,{},{event:"on_popup_close",settings:i},t),a.rows.add(e,t)},template:{form:function(e,t,i){var n=a.get_cookie(e),o="pum_cookie_settings",r=Object.keys(n.fields)[0];(t=t||{}).event=e,t.index=0<=t.index?t.index:null,n.fields[r]=s.extend(!0,n.fields[r],{index:{type:"hidden",name:"index"},event:{type:"hidden",name:"event"}}),"string"==typeof t.key&&""!==t.key||delete n.fields.advanced.key,PUM_Admin.modals.reload("#"+o,PUM_Admin.templates.modal({id:o,title:n.modal_title||n.name,classes:"tabbed-content",save_button:null!==t.index?d.update:d.add,content:PUM_Admin.forms.render({id:"pum_cookie_settings_form",tabs:n.tabs||{},fields:n.fields||{}},t||{})})),s("#"+o+" form").on("submit",i||function(e){e.preventDefault(),PUM_Admin.modals.closeAll()})},editor:function(e){e=s.extend(!0,{},{cookies:[],name:""},e);return e.cookies=PUM_Admin.utils.object_to_array(e.cookies),PUM_Admin.templates.render("pum-cookie-editor",e)},row:function(e){e=s.extend(!0,{},{index:"",event:"",name:"",settings:{name:"",key:"",session:null,path:null,time:"30 days"}},e);return PUM_Admin.templates.render("pum-cookie-row",e)},selectbox:function(e){e=s.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:a.select_list()},e);return null===e.id&&(e.id="popup_settings_cookies_"+e.index+"_event"),null===e.name&&(e.name="popup_settings[cookies]["+e.index+"][event]"),PUM_Admin.templates.field(e)}},rows:{add:function(e,t){var i=s(e),e={index:null!==t.index&&0<=t.index?t.index:i.find("table.list-table tbody tr").length,event:t.event,name:i.data("field_name"),settings:t.settings||{}},t=i.find("tbody tr").eq(e.index),e=PUM_Admin.templates.render("pum-cookie-row",e);t.length?t.replaceWith(e):i.find("tbody").append(e),i.addClass("has-list-items"),a.rows.renumber(),a.refreshDescriptions()},remove:function(e){var t=e.parents(".pum-popup-cookie-editor");e.remove(),a.rows.renumber(),0===t.find("table.list-table tbody tr").length&&(t.removeClass("has-list-items"),s("#pum-first-cookie").val(null).trigger("change"))},renumber:function(){s(".pum-popup-cookie-editor table.list-table tbody tr").each(function(){var e=s(this),t=e.parent().children().index(e);e.attr("data-index",t).data("index",t),e.find(":input, [name]").each(function(){this.name&&""!==this.name&&(this.name=this.name.replace(/\[\d*?\]/,"["+t+"]"))})})}}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.cookies=a,s(e).on("pum_init",function(){a.refreshDescriptions()}).on("select2:select pumselect2:select","#pum-first-cookie",function(){var e=s(this),o=e.parents(".pum-popup-cookie-editor"),t=e.val(),i={indes:o.find("table.list-table tbody tr").length,name:"pum-"+s("#post_ID").val()};e.val(null).trigger("change"),a.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!n||n<0)&&(n=o.find("tbody tr").length),a.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll()})}).on("click",".pum-popup-cookie-editor .pum-add-new",function(){n=s(this).parents(".pum-popup-cookie-editor");var e=wp.template("pum-cookie-add-event");PUM_Admin.modals.reload("#pum_cookie_add_event_modal",e({I10n:d}))}).on("click",".pum-popup-cookie-editor .edit",function(e){var t=s(this),o=t.parents(".pum-popup-cookie-editor"),i=t.parents("tr:first"),t=i.find(".popup_cookies_field_event").val(),i=_.extend({},JSON.parse(i.find(".popup_cookies_field_settings:first").val()),{index:i.parent().children().index(i),event:t});e.preventDefault(),a.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!1===n||n<0)&&(n=o.find("tbody tr").length),a.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll()})}).on("click",".pum-popup-cookie-editor .remove",function(e){var t=s(this).parents("tr:first");e.preventDefault(),window.confirm(d.confirm_delete_cookie)&&a.rows.remove(t)}).on("click",".pum-field-cookie_key button.reset",function(e){var t=s(this),i=(new Date).getTime().toString(16);t.siblings('input[type="text"]:first').val(i)}).on("submit","#pum_cookie_add_event_modal .pum-form",function(e){var o=n,t=s("#popup_cookie_add_event").val(),i={index:o.find("table.list-table tbody tr").length,name:"pum-"+s("#post_ID").val(),path:"1"};e.preventDefault(),a.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!1===n||n<0)&&(n=o.find("tbody tr").length),a.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll(),void 0!==PUM_Admin.triggers&&!1!==PUM_Admin.triggers.new_cookie&&0<=PUM_Admin.triggers.new_cookie&&(n=PUM_Admin.triggers.current_editor.find("tbody tr").eq(PUM_Admin.triggers.new_cookie).find(".popup_triggers_field_settings:first"),"string"==typeof(i=JSON.parse(n.val())).cookie_name?i.cookie_name=i.cookie_name.replace("add_new",t.cookie_settings.name):(i.cookie_name[i.cookie_name.indexOf("add_new")]=t.cookie_settings.name,i.cookie_name=i.cookie_name.filter(function(e,t,i){return!(e in this)&&(this[e]=!0)},{})),n.val(JSON.stringify(i)),PUM_Admin.triggers.new_cookie=!1,PUM_Admin.triggers.refreshDescriptions())})})}(jQuery,document),function(d,e,a){"use strict";var p=pum_admin_vars.I10n,c={current_editor:null,new_cookie:!1,get_triggers:function(){return window.pum_popup_settings_editor.triggers},get_trigger:function(e){var t=this.get_triggers(),e="undefined"!==t[e]&&t[e];return!!e&&(e&&"object"==typeof e&&"object"==typeof e.fields&&Object.keys(e.fields).length?this.parseFields(e):e)},parseFields:function(n){return _.each(n.fields,function(e,i){_.each(e,function(e,t){n.fields[i][t].name="trigger_settings["+t+"]",""===n.fields[i][t].id&&(n.fields[i][t].id="trigger_settings_"+t)})}),n},parseValues:function(e,t){for(var i in e)e.hasOwnProperty(i)&&e.hasOwnProperty(i+"_unit")&&(e[i]+=e[i+"_unit"],delete e[i+"_unit"]);return e},select_list:function(){for(var e=PUM_Admin.utils.object_to_array(c.get_triggers()),t={},i=0;i<e.length;i++)t[e[i].id]=e[i].name;return t},rows:{add:function(e,t){var i=d(e),e={index:null!==t.index&&0<=t.index?t.index:i.find("table.list-table tbody tr").length,type:t.type,name:i.data("field_name"),settings:t.settings||{}},t=i.find("tbody tr").eq(e.index),e=PUM_Admin.templates.render("pum-trigger-row",e);t.length?t.replaceWith(e):i.find("tbody").append(e),i.addClass("has-list-items"),c.renumber(),c.refreshDescriptions()},remove:function(e){var t=e.parents(".pum-popup-trigger-editor");e.remove(),c.renumber(),0===t.find("table.list-table tbody tr").length&&(t.removeClass("has-list-items"),d("#pum-first-trigger").val(null).trigger("change"))}},template:{form:function(e,t,i){var n=c.get_trigger(e),o="pum_trigger_settings",r=Object.keys(n.fields)[0],s=d(".pum-field-cookies .list-table tbody tr");(t=t||{}).type=e,t.index=0<=t.index?t.index:null,n.fields[r]=d.extend(!0,n.fields[r],{index:{type:"hidden",name:"index"},type:{type:"hidden",name:"type"}}),s.each(function(){var e=JSON.parse(d(this).find(".popup_cookies_field_settings:first").val());void 0===n.fields[r].cookie_name.options[e.name]&&(n.fields[r].cookie_name.options[e.name]=e.name)}),PUM_Admin.modals.reload("#"+o,PUM_Admin.templates.modal({id:o,title:n.modal_title||n.name,classes:"tabbed-content",save_button:null!==t.index?p.update:p.add,content:PUM_Admin.forms.render({id:"pum_trigger_settings_form",tabs:n.tabs||{},fields:n.fields||{}},t||{})})),d("#"+o+" form").on("submit",i||function(e){e.preventDefault(),PUM_Admin.modals.closeAll()})},editor:function(e){e=d.extend(!0,{},{triggers:[],name:""},e);return e.triggers=PUM_Admin.utils.object_to_array(e.triggers),PUM_Admin.templates.render("pum-trigger-editor",e)},row:function(e){e=d.extend(!0,{},{index:"",type:"",name:"",settings:{cookie_name:""}},e);return PUM_Admin.templates.render("pum-trigger-row",e)},selectbox:function(e){e=d.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:c.select_list()},e);return null===e.id&&(e.id="popup_settings_triggers_"+e.index+"_type"),null===e.name&&(e.name="popup_settings[triggers]["+e.index+"][type]"),PUM_Admin.templates.field(e)}},getLabel:function(e){e=c.get_trigger(e);return!!e&&e.name},getSettingsDesc:function(e,t){e=c.get_trigger(e);return!!e&&PUM_Admin.templates.renderInline(e.settings_column,t)},renumber:function(){d(".pum-popup-trigger-editor table.list-table tbody tr").each(function(){var e=d(this),t=e.parent().children().index(e);e.attr("data-index",t).data("index",t),e.find(":input, [name]").each(function(){this.name&&""!==this.name&&(this.name=this.name.replace(/\[\d*?\]/,"["+t+"]"))})})},refreshDescriptions:function(){d(".pum-popup-trigger-editor table.list-table tbody tr").each(function(){var e=d(this),t=e.find(".popup_triggers_field_type").val(),i=JSON.parse(e.find(".popup_triggers_field_settings:first").val()),n=PUM_Admin.triggers.cookie_column_value(i.cookie_name);e.find("td.settings-column").html(PUM_Admin.triggers.getSettingsDesc(t,i)),e.find("td.cookie-column code").text(n)})},cookie_column_value:function(e){var t=p.no_cookie;return e instanceof Array?t=e.join(", "):null!==e&&e!==a&&""!==e&&(t=e),t},append_click_selector_presets:function(){var e,t,i=d("#extra_selectors");i.length&&!i.hasClass("pum-click-selector-presets-initialized")&&(e=PUM_Admin.templates.render("pum-click-selector-presets"),(t=i.parents(".pum-field").find(".pum-click-selector-presets")).length||(i.before(e),i.addClass("pum-click-selector-presets-initialized"),t=i.parents(".pum-field").find(".pum-click-selector-presets")),t.position({my:"right center",at:"right center",of:i}))},toggle_click_selector_presets:function(){d(this).parent().toggleClass("open")},reset_click_selector_presets:function(e){e!==a&&d(e.target).parents(".pum-click-selector-presets").length||d(".pum-click-selector-presets").removeClass("open")},insert_click_selector_preset:function(){var e=d(this),t=d("#extra_selectors"),i=t.val();""!==i&&(i+=", "),t.val(i+e.data("preset")),PUM_Admin.triggers.reset_click_selector_presets()}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.triggers=c,d(e).on("pum_init",function(){PUM_Admin.triggers.append_click_selector_presets(),PUM_Admin.triggers.refreshDescriptions()}).on("click",".pum-click-selector-presets > span",PUM_Admin.triggers.toggle_click_selector_presets).on("click",".pum-click-selector-presets li",PUM_Admin.triggers.insert_click_selector_preset).on("click",PUM_Admin.triggers.reset_click_selector_presets).on("select2:select pumselect2:select","#pum-first-trigger",function(){var e=d(this),r=e.parents(".pum-popup-trigger-editor"),t=e.val(),i={};PUM_Admin.triggers.current_editor=r,"click_open"!==t&&(i.cookie_name="pum-"+d("#post_ID").val()),c.template.form(t,i,function(e){var t=d(this),i=t.find("input#type").val(),n=t.pumSerializeObject(),o=c.parseValues(n.trigger_settings||{}),t=parseInt(n.index);e.preventDefault(),(!1===t||t<0)&&(t=r.find("tbody tr").length),c.rows.add(r,{index:t,type:i,settings:o}),PUM_Admin.modals.closeAll(),o.cookie_name!==a&&null!==o.cookie_name&&("add_new"===o.cookie_name||0<=o.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=n.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))}),e.val(null).trigger("change")}).on("click",".pum-popup-trigger-editor .pum-add-new",function(){PUM_Admin.triggers.current_editor=d(this).parents(".pum-popup-trigger-editor");var e=wp.template("pum-trigger-add-type");PUM_Admin.modals.reload("#pum_trigger_add_type_modal",e({I10n:p}))}).on("click",".pum-popup-trigger-editor .edit",function(e){var t=d(this),r=t.parents(".pum-popup-trigger-editor"),i=t.parents("tr:first"),t=i.find(".popup_triggers_field_type").val(),i=_.extend({},JSON.parse(i.find(".popup_triggers_field_settings:first").val()),{index:i.parent().children().index(i),type:t});e.preventDefault(),c.template.form(t,i,function(e){var t=d(this),i=t.find("input#type").val(),n=t.find("input#index").val(),o=t.pumSerializeObject(),t=c.parseValues(o.trigger_settings||{});PUM_Admin.triggers.current_editor=r,e.preventDefault(),(!1===n||n<0)&&(n=r.find("tbody tr").length),c.rows.add(r,{index:n,type:i,settings:t}),PUM_Admin.modals.closeAll(),t.cookie_name!==a&&null!==t.cookie_name&&("add_new"===t.cookie_name||0<=t.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=o.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))})}).on("click",".pum-popup-trigger-editor .remove",function(e){var t=d(this),i=t.parents(".pum-popup-trigger-editor"),t=t.parents("tr:first");PUM_Admin.triggers.current_editor=i,e.preventDefault(),window.confirm(p.confirm_delete_trigger)&&c.rows.remove(t)}).on("submit","#pum_trigger_add_type_modal .pum-form",function(e){var r=PUM_Admin.triggers.current_editor,t=r.parents("#pum-popup-settings-triggers-subtabs_main").find(".pum-field-cookies .pum-popup-cookie-editor"),i=d("#popup_trigger_add_type").val(),n=d("#popup_trigger_add_cookie").is(":checked"),o=d("#popup_trigger_add_cookie_event").val(),s={};e.preventDefault(),n&&(s.cookie_name="pum-"+d("#post_ID").val(),PUM_Admin.cookies.insertCookie(t,{event:o,settings:{time:"1 month",path:"1",name:s.cookie_name}})),c.template.form(i,s,function(e){var t=d(this),i=t.find("input#type").val(),n=t.pumSerializeObject(),o=c.parseValues(n.trigger_settings||{}),t=parseInt(n.index);PUM_Admin.triggers.current_editor=r,e.preventDefault(),(!t||t<0)&&(t=r.find("tbody tr").length),c.rows.add(r,{index:t,type:i,settings:o}),PUM_Admin.modals.closeAll(),o.cookie_name!==a&&null!==o.cookie_name&&("add_new"===o.cookie_name||0<=o.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=n.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))})})}(jQuery,document);
|
1 |
+
var cookies;!function(n){"use strict";window.PUM_Admin=window.PUM_Admin||{},window.pum_popup_settings_editor=window.pum_popup_settings_editor||{form_args:{},current_values:{},preview_nonce:null},n(document).on("keydown","#popup-title",function(e){9===(e.keyCode||e.which)&&(e.preventDefault(),n("#title").focus())}).on("keydown","#title, #popup-title",function(e){var t=e.keyCode||e.which;e.shiftKey||9!==t||(e.preventDefault(),e="title"===n(this).attr("id")?"#popup-title":"#insert-media-button",n(e).focus())}).on("keydown","#popup-title, #insert-media-button",function(e){var t=e.keyCode||e.which;e.shiftKey&&9===t&&(e.preventDefault(),e="popup-title"===n(this).attr("id")?"#title":"#popup-title",n(e).focus())}),n(function(){n(this).trigger("pum_init"),n("#title").prop("required",!0);var e=n("#pum-popup-settings-container"),t=pum_popup_settings_editor.form_args||{},i=pum_popup_settings_editor.current_values||{};e.length&&(e.find(".pum-no-js").hide(),PUM_Admin.forms.render(t,i,e)),n("a.page-title-action").clone().attr("target","_blank").attr("href",pum_admin_vars.homeurl+"?popup_preview="+pum_popup_settings_editor.preview_nonce+"&popup="+n("#post_ID").val()).text(pum_admin_vars.I10n.preview_popup).insertAfter("a.page-title-action"),n("#pum-first-condition, #pum-first-trigger, #pum-first-cookie").val(null).trigger("change"),document.querySelector("#pum-popup-settings-container").addEventListener("change",function(e){"open_sound"!==e.target.id||-1===["none","custom"].indexOf(e.target.value)&&((e=new Audio(pum_admin_vars.pm_dir_url+"/assets/sounds/"+e.target.value)).addEventListener("canplaythrough",function(){this.play().catch(function(e){console.warn("Sound was not able to play when selected. Reason: "+e)})}),e.addEventListener("error",function(){console.warn("Error occurred when trying to load popup opening sound.")}))}),n(document).on("pum_init",function(){n("#pum-default-click-trigger-class:not(.pum-click-trigger-initialized)").each(function(){n(this).addClass("pum-click-trigger-initialized").text(n("#popup-id").data("popup-id"))})}),document.querySelector("#pum-popup-settings-container").addEventListener("click",function(e){if(Array.from(e.target.classList).includes("popup-type")||Array.from(e.target.parentElement.classList).includes("popup-type")){var t=jQuery("#pum-popup-settings-container");if(1===t.length){var i={"center-popup":{size:"medium",responsive_min_width:"0%",responsive_max_width:"100%",animation_type:"fade",animation_speed:350,location:"center",position_fixed:!1,position_from_trigger:!1,overlay_disabled:!1,stackable:!1,disable_reposition:!1},"left-bottom-notice":{size:"tiny",responsive_min_width:"0%",responsive_max_width:"100%",animation_type:"fade",animation_speed:350,animation_origin:"left bottom",location:"left bottom",position_bottom:10,position_left:10,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1},"top-bar":{size:"custom",custom_width:"100%",custom_height_auto:!0,animation_type:"fadeAndSlide",animation_speed:300,animation_origin:"top",location:"center top",position_top:0,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1},"right-bottom-slidein":{size:"custom",custom_width:"300px",custom_height_auto:!0,animation_type:"slide",animation_speed:350,animation_origin:"bottom",location:"right bottom",position_bottom:10,position_right:10,position_from_trigger:!1,position_fixed:!0,overlay_disabled:!0,stackable:!0,disable_reposition:!1}},n=e.target.dataset.popupType||e.target.parentElement.dataset.popupType||"",o=i.hasOwnProperty(n)?i[n]:{},e=pum_popup_settings_editor.form_args||{},i=pum_popup_settings_editor.current_values||{},r=t.pumSerializeObject();if(r.popup_settings.triggers)for(var s=0;s<r.popup_settings.triggers.length;s++)r.popup_settings.triggers[s].settings=JSON.parse(r.popup_settings.triggers[s].settings);if(r.popup_settings.cookies)for(var d=0;d<r.popup_settings.cookies.length;d++)r.popup_settings.cookies[d].settings=JSON.parse(r.popup_settings.cookies[d].settings);o=Object.assign({},i,r.popup_settings,o);PUM_Admin.forms.render(e,o,t),document.querySelector('a[href="#pum-popup-settings_display"]').click();t=document.createElement("div");t.classList.add("notice","updated"),t.insertBefore(document.createElement("p"),t.firstChild),t.firstChild.innerText="Display settings have been updated with the "+n+" preset";n=document.querySelector("#pum-popup-settings-display-subtabs_preset");n.insertBefore(t,n.firstChild)}}})})}(jQuery),function(t,e){"use strict";t(e).on("click","#popup_reset_open_count",function(){var e=t(this);e.is(":checked")&&!confirm(pum_admin_vars.I10n.confirm_count_reset)&&e.prop("checked",!1)})}(jQuery,document),function(s){"use strict";var d={get_conditions:function(){return window.pum_popup_settings_editor.conditions_selectlist},not_operand_checkbox:function(e){return(e=e||s(".pum-not-operand")).each(function(){var e=s(this),t=e.find("input");t.prop("checked",!t.is(":checked")),d.toggle_not_operand(e)})},toggle_not_operand:function(e){return(e=e||s(".pum-not-operand")).each(function(){var e=s(this),t=e.find("input"),e=e.parents(".facet-target");t.is(":checked")?e.addClass("not-operand-checked"):e.removeClass("not-operand-checked")})},template:{editor:function(e){e=s.extend(!0,{},{groups:[]},e);return e.groups=PUM_Admin.utils.object_to_array(e.groups),PUM_Admin.templates.render("pum-condition-editor",e)},group:function(e){var t,i=s.extend(!0,{},{index:"",facets:[]},e);for(i.facets=PUM_Admin.utils.object_to_array(i.facets),t=0;i.facets.length>t;t++)i.facets[t].index=t,i.facets[t].group=i.index;return PUM_Admin.templates.render("pum-condition-group",i)},facet:function(e){e=s.extend(!0,{},{group:"",index:"",target:"",not_operand:!1,settings:{}},e);return PUM_Admin.templates.render("pum-condition-facet",e)},settings:function(e,i){var n=[],o=s.extend(!0,{},{index:"",group:"",target:null,fields:[]},e);return o.fields.length||void 0===pum_popup_settings_editor.conditions[e.target]||(o.fields=pum_popup_settings_editor.conditions[e.target].fields),void 0===i&&(i={}),_.each(o.fields,function(e,t){"object"!=typeof(e=PUM_Admin.models.field(e)).meta&&(e.meta={}),void 0!==i[t]&&(e.value=i[t]),e.name="popup_settings[conditions]["+o.group+"]["+o.index+"][settings]["+t+"]",""===e.id&&(e.id="popup_settings_conditions_"+o.group+"_"+o.index+"_settings_"+t),n.push(PUM_Admin.templates.field(e))}),PUM_Admin.templates.section({fields:n})},selectbox:function(e){e=s.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:d.get_conditions()},e);return null===e.id&&(e.id="popup_settings_conditions_"+e.group+"_"+e.index+"_target"),null===e.name&&(e.name="popup_settings[conditions]["+e.group+"]["+e.index+"][target]"),PUM_Admin.templates.field(e)}},groups:{add:function(e,t,i){e=s(e),i={index:e.find(".facet-group-wrap").length,facets:[{target:t||null,not_operand:i||!1,settings:{}}]};e.find(".facet-groups").append(d.template.group(i)),e.addClass("has-conditions")},remove:function(e){var t=e.parents(".facet-builder");e.prev(".facet-group-wrap").find(".and .add-facet").removeClass("disabled"),e.remove(),d.renumber(),0===t.find(".facet-group-wrap").length&&(t.removeClass("has-conditions"),s("#pum-first-condition").val(null).trigger("change"))}},facets:{add:function(e,t,i){i={group:e.data("index"),index:e.find(".facet").length,target:t||null,not_operand:i||!1,settings:{}};e.find(".facet-list").append(d.template.facet(i))},remove:function(e){var t=e.parents(".facet-group-wrap");e.remove(),0===t.find(".facet").length?d.groups.remove(t):d.renumber()}},renumber:function(){s(".facet-builder .facet-group-wrap").each(function(){var e=s(this),i=e.parent().children().index(e);e.data("index",i).find(".facet").each(function(){var e=s(this),t=e.parent().children().index(e);e.data("index",t).find("[name]").each(function(){this.name=this.name.replace(/popup_settings\[conditions\]\[\d*?\]\[\d*?\]/,"popup_settings[conditions]["+i+"]["+t+"]"),this.id=this.id.replace(/popup_settings_conditions_\d*?_\d*?_/,"popup_settings_conditions_"+i+"_"+t+"_")})})})}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.conditions=d,s(document).on("pum_init",function(){d.renumber(),d.toggle_not_operand()}).on("select2:select pumselect2:select","#pum-first-condition",function(e){var t=s(this),i=t.parents(".facet-builder").eq(0),n=t.val(),o=i.find("#pum-first-facet-operand"),r=o.is(":checked");d.groups.add(i,n,r),t.val(null).trigger("change"),o.prop("checked",!1).parents(".facet-target").removeClass("not-operand-checked"),s(document).trigger("pum_init")}).on("click",".facet-builder .pum-not-operand",function(){d.not_operand_checkbox(s(this))}).on("change",".facet-builder .facet-target select",function(e){var t=s(this),i=t.parents(".facet"),n=t.val(),t={target:n};""!==n&&n!==i.data("target")&&(i.data("target",n).find(".facet-settings").html(d.template.settings(t)),s(document).trigger("pum_init"))}).on("click",".facet-builder .facet-group-wrap:last-child .and .add-facet",function(){d.groups.add(s(this).parents(".facet-builder").eq(0)),s(document).trigger("pum_init")}).on("click",".facet-builder .add-or .add-facet:not(.disabled)",function(){d.facets.add(s(this).parents(".facet-group-wrap").eq(0)),s(document).trigger("pum_init")}).on("click",".facet-builder .remove-facet",function(){d.facets.remove(s(this).parents(".facet").eq(0)),s(document).trigger("pum_init")})}(jQuery),function(s,e){"use strict";var n,d=pum_admin_vars.I10n,p={get_cookies:function(){return window.pum_popup_settings_editor.cookies},get_cookie:function(e){var t=this.get_cookies(),e="undefined"!==t[e]&&t[e];return!!e&&(e&&"object"==typeof e&&"object"==typeof e.fields&&Object.keys(e.fields).length?this.parseFields(e):e)},getCookieDefaults:function(e){var t,i=p.get_cookie(e),n={};for(t in i.fields)if(i.fields.hasOwnProperty(t))for(var o in i.fields[t])i.fields[t].hasOwnProperty(o)&&(n[o]=i.fields[t][o].std);return n.name="pum-"+s("#post_ID").val(),n},parseFields:function(n){return _.each(n.fields,function(e,i){_.each(e,function(e,t){n.fields[i][t].name="cookie_settings["+t+"]",""===n.fields[i][t].id&&(n.fields[i][t].id="cookie_settings_"+t)})}),n},parseValues:function(e,t){return e},select_list:function(){for(var e=PUM_Admin.utils.object_to_array(p.get_cookies()),t={},i=0;i<e.length;i++)t[e[i].id]=e[i].name;return t},getLabel:function(e){e=p.get_cookie(e);return!!e&&e.name},getSettingsDesc:function(e,t){e=p.get_cookie(e);return!!e&&PUM_Admin.templates.renderInline(e.settings_column,t)},refreshDescriptions:function(){s(".pum-popup-cookie-editor table.list-table tbody tr").each(function(){var e=s(this),t=e.find(".popup_cookies_field_event").val(),i=JSON.parse(e.find(".popup_cookies_field_settings:first").val());e.find("td.settings-column").html(p.getSettingsDesc(t,i))})},insertCookie:function(e,t){var i=p.getCookieDefaults(t.event);t=s.extend(!0,{},{event:"on_popup_close",settings:i},t),p.rows.add(e,t)},template:{form:function(e,t,i){var n=p.get_cookie(e),o="pum_cookie_settings",r=Object.keys(n.fields)[0];(t=t||{}).event=e,t.index=0<=t.index?t.index:null,n.fields[r]=s.extend(!0,n.fields[r],{index:{type:"hidden",name:"index"},event:{type:"hidden",name:"event"}}),"string"==typeof t.key&&""!==t.key||delete n.fields.advanced.key,PUM_Admin.modals.reload("#"+o,PUM_Admin.templates.modal({id:o,title:n.modal_title||n.name,classes:"tabbed-content",save_button:null!==t.index?d.update:d.add,content:PUM_Admin.forms.render({id:"pum_cookie_settings_form",tabs:n.tabs||{},fields:n.fields||{}},t||{})})),s("#"+o+" form").on("submit",i||function(e){e.preventDefault(),PUM_Admin.modals.closeAll()})},editor:function(e){e=s.extend(!0,{},{cookies:[],name:""},e);return e.cookies=PUM_Admin.utils.object_to_array(e.cookies),PUM_Admin.templates.render("pum-cookie-editor",e)},row:function(e){e=s.extend(!0,{},{index:"",event:"",name:"",settings:{name:"",key:"",session:null,path:null,time:"30 days"}},e);return PUM_Admin.templates.render("pum-cookie-row",e)},selectbox:function(e){e=s.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:p.select_list()},e);return null===e.id&&(e.id="popup_settings_cookies_"+e.index+"_event"),null===e.name&&(e.name="popup_settings[cookies]["+e.index+"][event]"),PUM_Admin.templates.field(e)}},rows:{add:function(e,t){var i=s(e),e={index:null!==t.index&&0<=t.index?t.index:i.find("table.list-table tbody tr").length,event:t.event,name:i.data("field_name"),settings:t.settings||{}},t=i.find("tbody tr").eq(e.index),e=PUM_Admin.templates.render("pum-cookie-row",e);t.length?t.replaceWith(e):i.find("tbody").append(e),i.addClass("has-list-items"),p.rows.renumber(),p.refreshDescriptions()},remove:function(e){var t=e.parents(".pum-popup-cookie-editor");e.remove(),p.rows.renumber(),0===t.find("table.list-table tbody tr").length&&(t.removeClass("has-list-items"),s("#pum-first-cookie").val(null).trigger("change"))},renumber:function(){s(".pum-popup-cookie-editor table.list-table tbody tr").each(function(){var e=s(this),t=e.parent().children().index(e);e.attr("data-index",t).data("index",t),e.find(":input, [name]").each(function(){this.name&&""!==this.name&&(this.name=this.name.replace(/\[\d*?\]/,"["+t+"]"))})})}}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.cookies=p,s(e).on("pum_init",function(){p.refreshDescriptions()}).on("select2:select pumselect2:select","#pum-first-cookie",function(){var e=s(this),o=e.parents(".pum-popup-cookie-editor"),t=e.val(),i={indes:o.find("table.list-table tbody tr").length,name:"pum-"+s("#post_ID").val()};e.val(null).trigger("change"),p.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!n||n<0)&&(n=o.find("tbody tr").length),p.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll()})}).on("click",".pum-popup-cookie-editor .pum-add-new",function(){n=s(this).parents(".pum-popup-cookie-editor");var e=wp.template("pum-cookie-add-event");PUM_Admin.modals.reload("#pum_cookie_add_event_modal",e({I10n:d}))}).on("click",".pum-popup-cookie-editor .edit",function(e){var t=s(this),o=t.parents(".pum-popup-cookie-editor"),i=t.parents("tr:first"),t=i.find(".popup_cookies_field_event").val(),i=_.extend({},JSON.parse(i.find(".popup_cookies_field_settings:first").val()),{index:i.parent().children().index(i),event:t});e.preventDefault(),p.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!1===n||n<0)&&(n=o.find("tbody tr").length),p.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll()})}).on("click",".pum-popup-cookie-editor .remove",function(e){var t=s(this).parents("tr:first");e.preventDefault(),window.confirm(d.confirm_delete_cookie)&&p.rows.remove(t)}).on("click",".pum-field-cookie_key button.reset",function(e){var t=s(this),i=(new Date).getTime().toString(16);t.siblings('input[type="text"]:first').val(i)}).on("submit","#pum_cookie_add_event_modal .pum-form",function(e){var o=n,t=s("#popup_cookie_add_event").val(),i={index:o.find("table.list-table tbody tr").length,name:"pum-"+s("#post_ID").val(),path:"1"};e.preventDefault(),p.template.form(t,i,function(e){var t=s(this),i=t.find("input#event").val(),n=t.find("input#index").val(),t=t.pumSerializeObject();e.preventDefault(),(!1===n||n<0)&&(n=o.find("tbody tr").length),p.rows.add(o,{index:n,event:i,settings:t.cookie_settings}),PUM_Admin.modals.closeAll(),void 0!==PUM_Admin.triggers&&!1!==PUM_Admin.triggers.new_cookie&&0<=PUM_Admin.triggers.new_cookie&&(n=PUM_Admin.triggers.current_editor.find("tbody tr").eq(PUM_Admin.triggers.new_cookie).find(".popup_triggers_field_settings:first"),"string"==typeof(i=JSON.parse(n.val())).cookie_name?i.cookie_name=i.cookie_name.replace("add_new",t.cookie_settings.name):(i.cookie_name[i.cookie_name.indexOf("add_new")]=t.cookie_settings.name,i.cookie_name=i.cookie_name.filter(function(e,t,i){return!(e in this)&&(this[e]=!0)},{})),n.val(JSON.stringify(i)),PUM_Admin.triggers.new_cookie=!1,PUM_Admin.triggers.refreshDescriptions())})})}(jQuery,document),function(d,e,p){"use strict";var a=pum_admin_vars.I10n,c={current_editor:null,new_cookie:!1,get_triggers:function(){return window.pum_popup_settings_editor.triggers},get_trigger:function(e){var t=this.get_triggers(),e="undefined"!==t[e]&&t[e];return!!e&&(e&&"object"==typeof e&&"object"==typeof e.fields&&Object.keys(e.fields).length?this.parseFields(e):e)},parseFields:function(n){return _.each(n.fields,function(e,i){_.each(e,function(e,t){n.fields[i][t].name="trigger_settings["+t+"]",""===n.fields[i][t].id&&(n.fields[i][t].id="trigger_settings_"+t)})}),n},parseValues:function(e,t){for(var i in e)e.hasOwnProperty(i)&&e.hasOwnProperty(i+"_unit")&&(e[i]+=e[i+"_unit"],delete e[i+"_unit"]);return e},select_list:function(){for(var e=PUM_Admin.utils.object_to_array(c.get_triggers()),t={},i=0;i<e.length;i++)t[e[i].id]=e[i].name;return t},rows:{add:function(e,t){var i=d(e),e={index:null!==t.index&&0<=t.index?t.index:i.find("table.list-table tbody tr").length,type:t.type,name:i.data("field_name"),settings:t.settings||{}},t=i.find("tbody tr").eq(e.index),e=PUM_Admin.templates.render("pum-trigger-row",e);t.length?t.replaceWith(e):i.find("tbody").append(e),i.addClass("has-list-items"),c.renumber(),c.refreshDescriptions()},remove:function(e){var t=e.parents(".pum-popup-trigger-editor");e.remove(),c.renumber(),0===t.find("table.list-table tbody tr").length&&(t.removeClass("has-list-items"),d("#pum-first-trigger").val(null).trigger("change"))}},template:{form:function(e,t,i){var n=c.get_trigger(e),o="pum_trigger_settings",r=Object.keys(n.fields)[0],s=d(".pum-field-cookies .list-table tbody tr");(t=t||{}).type=e,t.index=0<=t.index?t.index:null,n.fields[r]=d.extend(!0,n.fields[r],{index:{type:"hidden",name:"index"},type:{type:"hidden",name:"type"}}),s.each(function(){var e=JSON.parse(d(this).find(".popup_cookies_field_settings:first").val());void 0===n.fields[r].cookie_name.options[e.name]&&(n.fields[r].cookie_name.options[e.name]=e.name)}),PUM_Admin.modals.reload("#"+o,PUM_Admin.templates.modal({id:o,title:n.modal_title||n.name,classes:"tabbed-content",save_button:null!==t.index?a.update:a.add,content:PUM_Admin.forms.render({id:"pum_trigger_settings_form",tabs:n.tabs||{},fields:n.fields||{}},t||{})})),d("#"+o+" form").on("submit",i||function(e){e.preventDefault(),PUM_Admin.modals.closeAll()})},editor:function(e){e=d.extend(!0,{},{triggers:[],name:""},e);return e.triggers=PUM_Admin.utils.object_to_array(e.triggers),PUM_Admin.templates.render("pum-trigger-editor",e)},row:function(e){e=d.extend(!0,{},{index:"",type:"",name:"",settings:{cookie_name:""}},e);return PUM_Admin.templates.render("pum-trigger-row",e)},selectbox:function(e){e=d.extend(!0,{},{id:null,name:null,type:"select",group:"",index:"",value:null,select2:!0,classes:[],options:c.select_list()},e);return null===e.id&&(e.id="popup_settings_triggers_"+e.index+"_type"),null===e.name&&(e.name="popup_settings[triggers]["+e.index+"][type]"),PUM_Admin.templates.field(e)}},getLabel:function(e){e=c.get_trigger(e);return!!e&&e.name},getSettingsDesc:function(e,t){e=c.get_trigger(e);return!!e&&PUM_Admin.templates.renderInline(e.settings_column,t)},renumber:function(){d(".pum-popup-trigger-editor table.list-table tbody tr").each(function(){var e=d(this),t=e.parent().children().index(e);e.attr("data-index",t).data("index",t),e.find(":input, [name]").each(function(){this.name&&""!==this.name&&(this.name=this.name.replace(/\[\d*?\]/,"["+t+"]"))})})},refreshDescriptions:function(){d(".pum-popup-trigger-editor table.list-table tbody tr").each(function(){var e=d(this),t=e.find(".popup_triggers_field_type").val(),i=JSON.parse(e.find(".popup_triggers_field_settings:first").val()),n=PUM_Admin.triggers.cookie_column_value(i.cookie_name);e.find("td.settings-column").html(PUM_Admin.triggers.getSettingsDesc(t,i)),e.find("td.cookie-column code").text(n)})},cookie_column_value:function(e){var t=a.no_cookie;return e instanceof Array?t=e.join(", "):null!==e&&e!==p&&""!==e&&(t=e),t},append_click_selector_presets:function(){var e,t,i=d("#extra_selectors");i.length&&!i.hasClass("pum-click-selector-presets-initialized")&&(e=PUM_Admin.templates.render("pum-click-selector-presets"),(t=i.parents(".pum-field").find(".pum-click-selector-presets")).length||(i.before(e),i.addClass("pum-click-selector-presets-initialized"),t=i.parents(".pum-field").find(".pum-click-selector-presets")),t.position({my:"right center",at:"right center",of:i}))},toggle_click_selector_presets:function(){d(this).parent().toggleClass("open")},reset_click_selector_presets:function(e){e!==p&&d(e.target).parents(".pum-click-selector-presets").length||d(".pum-click-selector-presets").removeClass("open")},insert_click_selector_preset:function(){var e=d(this),t=d("#extra_selectors"),i=t.val();""!==i&&(i+=", "),t.val(i+e.data("preset")),PUM_Admin.triggers.reset_click_selector_presets()}};window.PUM_Admin=window.PUM_Admin||{},window.PUM_Admin.triggers=c,d(e).on("pum_init",function(){PUM_Admin.triggers.append_click_selector_presets(),PUM_Admin.triggers.refreshDescriptions()}).on("click",".pum-click-selector-presets > span",PUM_Admin.triggers.toggle_click_selector_presets).on("click",".pum-click-selector-presets li",PUM_Admin.triggers.insert_click_selector_preset).on("click",PUM_Admin.triggers.reset_click_selector_presets).on("select2:select pumselect2:select","#pum-first-trigger",function(){var e=d(this),r=e.parents(".pum-popup-trigger-editor"),t=e.val(),i={};PUM_Admin.triggers.current_editor=r,"click_open"!==t&&(i.cookie_name="pum-"+d("#post_ID").val()),c.template.form(t,i,function(e){var t=d(this),i=t.find("input#type").val(),n=t.pumSerializeObject(),o=c.parseValues(n.trigger_settings||{}),t=parseInt(n.index);e.preventDefault(),(!1===t||t<0)&&(t=r.find("tbody tr").length),c.rows.add(r,{index:t,type:i,settings:o}),PUM_Admin.modals.closeAll(),o.cookie_name!==p&&null!==o.cookie_name&&("add_new"===o.cookie_name||0<=o.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=n.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))}),e.val(null).trigger("change")}).on("click",".pum-popup-trigger-editor .pum-add-new",function(){PUM_Admin.triggers.current_editor=d(this).parents(".pum-popup-trigger-editor");var e=wp.template("pum-trigger-add-type");PUM_Admin.modals.reload("#pum_trigger_add_type_modal",e({I10n:a}))}).on("click",".pum-popup-trigger-editor .edit",function(e){var t=d(this),r=t.parents(".pum-popup-trigger-editor"),i=t.parents("tr:first"),t=i.find(".popup_triggers_field_type").val(),i=_.extend({},JSON.parse(i.find(".popup_triggers_field_settings:first").val()),{index:i.parent().children().index(i),type:t});e.preventDefault(),c.template.form(t,i,function(e){var t=d(this),i=t.find("input#type").val(),n=t.find("input#index").val(),o=t.pumSerializeObject(),t=c.parseValues(o.trigger_settings||{});PUM_Admin.triggers.current_editor=r,e.preventDefault(),(!1===n||n<0)&&(n=r.find("tbody tr").length),c.rows.add(r,{index:n,type:i,settings:t}),PUM_Admin.modals.closeAll(),t.cookie_name!==p&&null!==t.cookie_name&&("add_new"===t.cookie_name||0<=t.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=o.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))})}).on("click",".pum-popup-trigger-editor .remove",function(e){var t=d(this),i=t.parents(".pum-popup-trigger-editor"),t=t.parents("tr:first");PUM_Admin.triggers.current_editor=i,e.preventDefault(),window.confirm(a.confirm_delete_trigger)&&c.rows.remove(t)}).on("submit","#pum_trigger_add_type_modal .pum-form",function(e){var r=PUM_Admin.triggers.current_editor,t=r.parents("#pum-popup-settings-triggers-subtabs_main").find(".pum-field-cookies .pum-popup-cookie-editor"),i=d("#popup_trigger_add_type").val(),n=d("#popup_trigger_add_cookie").is(":checked"),o=d("#popup_trigger_add_cookie_event").val(),s={};e.preventDefault(),n&&(s.cookie_name="pum-"+d("#post_ID").val(),PUM_Admin.cookies.insertCookie(t,{event:o,settings:{time:"1 month",path:"1",name:s.cookie_name}})),c.template.form(i,s,function(e){var t=d(this),i=t.find("input#type").val(),n=t.pumSerializeObject(),o=c.parseValues(n.trigger_settings||{}),t=parseInt(n.index);PUM_Admin.triggers.current_editor=r,e.preventDefault(),(!t||t<0)&&(t=r.find("tbody tr").length),c.rows.add(r,{index:t,type:i,settings:o}),PUM_Admin.modals.closeAll(),o.cookie_name!==p&&null!==o.cookie_name&&("add_new"===o.cookie_name||0<=o.cookie_name.indexOf("add_new"))&&(PUM_Admin.triggers.new_cookie=n.index,d("#pum-popup-settings-container .pum-popup-cookie-editor button.pum-add-new").trigger("click"))})})}(jQuery,document);
|
classes/Abstract/Batch/Process.php
CHANGED
@@ -131,7 +131,6 @@ abstract class PUM_Abstract_Batch_Process implements PUM_Interface_Batch_Process
|
|
131 |
|
132 |
/**
|
133 |
* Defines logic to execute once batch processing is complete.
|
134 |
-
*
|
135 |
*/
|
136 |
public function finish() {
|
137 |
PUM_DataStorage::delete_by_match( "^{$this->batch_id}[0-9a-z\_]+" );
|
131 |
|
132 |
/**
|
133 |
* Defines logic to execute once batch processing is complete.
|
|
|
134 |
*/
|
135 |
public function finish() {
|
136 |
PUM_DataStorage::delete_by_match( "^{$this->batch_id}[0-9a-z\_]+" );
|
classes/Abstract/Database.php
CHANGED
@@ -7,25 +7,38 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit;
|
8 |
}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
abstract class PUM_Abstract_Database {
|
11 |
|
12 |
/**
|
|
|
|
|
13 |
* @var static
|
14 |
*/
|
15 |
public static $instance;
|
16 |
|
17 |
/**
|
18 |
-
* The name of our database table
|
|
|
|
|
19 |
*/
|
20 |
public $table_name = '';
|
21 |
|
22 |
/**
|
23 |
-
* The version of our database table
|
|
|
|
|
24 |
*/
|
25 |
public $version = 1;
|
26 |
|
27 |
/**
|
28 |
-
* The name of the primary column
|
|
|
|
|
29 |
*/
|
30 |
public $primary_key = 'ID';
|
31 |
|
@@ -99,7 +112,7 @@ abstract class PUM_Abstract_Database {
|
|
99 |
$class = get_called_class();
|
100 |
|
101 |
if ( ! isset( self::$instance[ $class ] ) ) {
|
102 |
-
self::$instance[ $class ] = new $class;
|
103 |
}
|
104 |
|
105 |
return self::$instance[ $class ];
|
@@ -260,7 +273,7 @@ abstract class PUM_Abstract_Database {
|
|
260 |
* @return array
|
261 |
*/
|
262 |
public function get_column_defaults() {
|
263 |
-
return
|
264 |
}
|
265 |
|
266 |
/**
|
@@ -269,7 +282,7 @@ abstract class PUM_Abstract_Database {
|
|
269 |
* @return array
|
270 |
*/
|
271 |
public function get_columns() {
|
272 |
-
return
|
273 |
}
|
274 |
|
275 |
/**
|
@@ -281,7 +294,7 @@ abstract class PUM_Abstract_Database {
|
|
281 |
*
|
282 |
* @return bool
|
283 |
*/
|
284 |
-
public function update( $row_id, $data =
|
285 |
|
286 |
global $wpdb;
|
287 |
|
@@ -315,7 +328,7 @@ abstract class PUM_Abstract_Database {
|
|
315 |
$data_keys = array_keys( $data );
|
316 |
$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
|
317 |
|
318 |
-
if ( false === $wpdb->update( $this->table_name(), $data,
|
319 |
return false;
|
320 |
}
|
321 |
|
@@ -375,7 +388,7 @@ abstract class PUM_Abstract_Database {
|
|
375 |
*
|
376 |
* @return string
|
377 |
*/
|
378 |
-
public function prepare_query( $query, $args =
|
379 |
|
380 |
if ( $args['orderby'] ) {
|
381 |
$query .= " ORDER BY {$args['orderby']} {$args['order']}";
|
@@ -399,18 +412,21 @@ abstract class PUM_Abstract_Database {
|
|
399 |
*
|
400 |
* @return array|mixed|object[]
|
401 |
*/
|
402 |
-
public function query( $args =
|
403 |
global $wpdb;
|
404 |
|
405 |
-
$args = wp_parse_args(
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
|
|
|
|
|
|
414 |
|
415 |
$columns = $this->get_columns();
|
416 |
|
@@ -430,17 +446,17 @@ abstract class PUM_Abstract_Database {
|
|
430 |
$query = "SELECT `$select_fields` FROM {$this->table_name()}";
|
431 |
|
432 |
// Set up $values array for wpdb::prepare
|
433 |
-
$values =
|
434 |
|
435 |
// Define an empty WHERE clause to start from.
|
436 |
-
$where =
|
437 |
|
438 |
// Build search query.
|
439 |
if ( $args['s'] && ! empty( $args['s'] ) ) {
|
440 |
|
441 |
$search = wp_unslash( trim( $args['s'] ) );
|
442 |
|
443 |
-
$search_where =
|
444 |
|
445 |
foreach ( $columns as $key => $type ) {
|
446 |
if ( in_array( $key, $fields ) ) {
|
@@ -459,24 +475,24 @@ abstract class PUM_Abstract_Database {
|
|
459 |
$query .= " $where";
|
460 |
|
461 |
if ( ! empty( $args['orderby'] ) ) {
|
462 |
-
$query
|
463 |
$values[] = wp_unslash( trim( $args['orderby'] ) );
|
464 |
|
465 |
switch ( $args['order'] ) {
|
466 |
case 'asc':
|
467 |
case 'ASC':
|
468 |
-
$query .=
|
469 |
break;
|
470 |
case 'desc':
|
471 |
case 'DESC':
|
472 |
default:
|
473 |
-
$query .=
|
474 |
break;
|
475 |
}
|
476 |
}
|
477 |
|
478 |
if ( ! empty( $args['limit'] ) ) {
|
479 |
-
$query
|
480 |
$values[] = absint( $args['limit'] );
|
481 |
}
|
482 |
|
@@ -486,7 +502,7 @@ abstract class PUM_Abstract_Database {
|
|
486 |
}
|
487 |
|
488 |
if ( ! empty( $args['offset'] ) ) {
|
489 |
-
$query
|
490 |
$values[] = absint( $args['offset'] );
|
491 |
}
|
492 |
|
@@ -514,4 +530,4 @@ abstract class PUM_Abstract_Database {
|
|
514 |
|
515 |
return $results ? count( $results ) : 0;
|
516 |
}
|
517 |
-
}
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
/**
|
11 |
+
* Abstract database class.
|
12 |
+
*
|
13 |
+
* @package PopupMaker
|
14 |
+
*/
|
15 |
abstract class PUM_Abstract_Database {
|
16 |
|
17 |
/**
|
18 |
+
* Instance of the class.
|
19 |
+
*
|
20 |
* @var static
|
21 |
*/
|
22 |
public static $instance;
|
23 |
|
24 |
/**
|
25 |
+
* The name of our database table.
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
*/
|
29 |
public $table_name = '';
|
30 |
|
31 |
/**
|
32 |
+
* The version of our database table.
|
33 |
+
*
|
34 |
+
* @var integer
|
35 |
*/
|
36 |
public $version = 1;
|
37 |
|
38 |
/**
|
39 |
+
* The name of the primary column.
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
*/
|
43 |
public $primary_key = 'ID';
|
44 |
|
112 |
$class = get_called_class();
|
113 |
|
114 |
if ( ! isset( self::$instance[ $class ] ) ) {
|
115 |
+
self::$instance[ $class ] = new $class();
|
116 |
}
|
117 |
|
118 |
return self::$instance[ $class ];
|
273 |
* @return array
|
274 |
*/
|
275 |
public function get_column_defaults() {
|
276 |
+
return [];
|
277 |
}
|
278 |
|
279 |
/**
|
282 |
* @return array
|
283 |
*/
|
284 |
public function get_columns() {
|
285 |
+
return [];
|
286 |
}
|
287 |
|
288 |
/**
|
294 |
*
|
295 |
* @return bool
|
296 |
*/
|
297 |
+
public function update( $row_id, $data = [], $where = '' ) {
|
298 |
|
299 |
global $wpdb;
|
300 |
|
328 |
$data_keys = array_keys( $data );
|
329 |
$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
|
330 |
|
331 |
+
if ( false === $wpdb->update( $this->table_name(), $data, [ $where => $row_id ], $column_formats ) ) {
|
332 |
return false;
|
333 |
}
|
334 |
|
388 |
*
|
389 |
* @return string
|
390 |
*/
|
391 |
+
public function prepare_query( $query, $args = [] ) {
|
392 |
|
393 |
if ( $args['orderby'] ) {
|
394 |
$query .= " ORDER BY {$args['orderby']} {$args['order']}";
|
412 |
*
|
413 |
* @return array|mixed|object[]
|
414 |
*/
|
415 |
+
public function query( $args = [], $return_type = OBJECT ) {
|
416 |
global $wpdb;
|
417 |
|
418 |
+
$args = wp_parse_args(
|
419 |
+
$args,
|
420 |
+
[
|
421 |
+
'fields' => '*',
|
422 |
+
'page' => null,
|
423 |
+
'limit' => null,
|
424 |
+
'offset' => null,
|
425 |
+
's' => null,
|
426 |
+
'orderby' => null,
|
427 |
+
'order' => null,
|
428 |
+
]
|
429 |
+
);
|
430 |
|
431 |
$columns = $this->get_columns();
|
432 |
|
446 |
$query = "SELECT `$select_fields` FROM {$this->table_name()}";
|
447 |
|
448 |
// Set up $values array for wpdb::prepare
|
449 |
+
$values = [];
|
450 |
|
451 |
// Define an empty WHERE clause to start from.
|
452 |
+
$where = 'WHERE 1=1';
|
453 |
|
454 |
// Build search query.
|
455 |
if ( $args['s'] && ! empty( $args['s'] ) ) {
|
456 |
|
457 |
$search = wp_unslash( trim( $args['s'] ) );
|
458 |
|
459 |
+
$search_where = [];
|
460 |
|
461 |
foreach ( $columns as $key => $type ) {
|
462 |
if ( in_array( $key, $fields ) ) {
|
475 |
$query .= " $where";
|
476 |
|
477 |
if ( ! empty( $args['orderby'] ) ) {
|
478 |
+
$query .= ' ORDER BY %s';
|
479 |
$values[] = wp_unslash( trim( $args['orderby'] ) );
|
480 |
|
481 |
switch ( $args['order'] ) {
|
482 |
case 'asc':
|
483 |
case 'ASC':
|
484 |
+
$query .= ' ASC';
|
485 |
break;
|
486 |
case 'desc':
|
487 |
case 'DESC':
|
488 |
default:
|
489 |
+
$query .= ' DESC';
|
490 |
break;
|
491 |
}
|
492 |
}
|
493 |
|
494 |
if ( ! empty( $args['limit'] ) ) {
|
495 |
+
$query .= ' LIMIT %d';
|
496 |
$values[] = absint( $args['limit'] );
|
497 |
}
|
498 |
|
502 |
}
|
503 |
|
504 |
if ( ! empty( $args['offset'] ) ) {
|
505 |
+
$query .= ' OFFSET %d';
|
506 |
$values[] = absint( $args['offset'] );
|
507 |
}
|
508 |
|
530 |
|
531 |
return $results ? count( $results ) : 0;
|
532 |
}
|
533 |
+
}
|
classes/Abstract/Integration/Form.php
CHANGED
@@ -32,7 +32,7 @@ abstract class PUM_Abstract_Integration_Form extends PUM_Abstract_Integration im
|
|
32 |
*
|
33 |
* @return array
|
34 |
*/
|
35 |
-
public function custom_scripts( $js = []) {
|
36 |
return $js;
|
37 |
}
|
38 |
|
32 |
*
|
33 |
* @return array
|
34 |
*/
|
35 |
+
public function custom_scripts( $js = [] ) {
|
36 |
return $js;
|
37 |
}
|
38 |
|
classes/Abstract/Model/Post.php
CHANGED
@@ -209,7 +209,7 @@ abstract class PUM_Abstract_Model_Post {
|
|
209 |
if ( is_array( $this->required_post_type ) && ! in_array( $post->post_type, $this->required_post_type ) ) {
|
210 |
|
211 |
return false;
|
212 |
-
}
|
213 |
|
214 |
return false;
|
215 |
}
|
@@ -229,7 +229,7 @@ abstract class PUM_Abstract_Model_Post {
|
|
229 |
*/
|
230 |
public function __call( $name, $arguments ) {
|
231 |
if ( method_exists( $this, 'get_' . $name ) ) {
|
232 |
-
return call_user_func_array(
|
233 |
}
|
234 |
}
|
235 |
|
@@ -244,7 +244,7 @@ abstract class PUM_Abstract_Model_Post {
|
|
244 |
|
245 |
if ( method_exists( $this, 'get_' . $key ) ) {
|
246 |
|
247 |
-
return call_user_func(
|
248 |
|
249 |
} else {
|
250 |
|
@@ -380,4 +380,4 @@ abstract class PUM_Abstract_Model_Post {
|
|
380 |
return get_post_status( $this->ID ) == 'pending';
|
381 |
|
382 |
}
|
383 |
-
}
|
209 |
if ( is_array( $this->required_post_type ) && ! in_array( $post->post_type, $this->required_post_type ) ) {
|
210 |
|
211 |
return false;
|
212 |
+
} elseif ( is_string( $this->required_post_type ) && $this->required_post_type !== $post->post_type ) {
|
213 |
|
214 |
return false;
|
215 |
}
|
229 |
*/
|
230 |
public function __call( $name, $arguments ) {
|
231 |
if ( method_exists( $this, 'get_' . $name ) ) {
|
232 |
+
return call_user_func_array( [ $this, 'get_' . $name ], $arguments );
|
233 |
}
|
234 |
}
|
235 |
|
244 |
|
245 |
if ( method_exists( $this, 'get_' . $key ) ) {
|
246 |
|
247 |
+
return call_user_func( [ $this, 'get_' . $key ] );
|
248 |
|
249 |
} else {
|
250 |
|
380 |
return get_post_status( $this->ID ) == 'pending';
|
381 |
|
382 |
}
|
383 |
+
}
|
classes/Abstract/Model/User.php
CHANGED
@@ -67,7 +67,7 @@ abstract class PUM_Abstract_Model_User {
|
|
67 |
/**
|
68 |
* @var array An array of keys that can be accessed via the $this->user (WP_User) object.
|
69 |
*/
|
70 |
-
public $core_data_keys =
|
71 |
'nickname',
|
72 |
'description',
|
73 |
'user_description',
|
@@ -95,7 +95,7 @@ abstract class PUM_Abstract_Model_User {
|
|
95 |
'roles',
|
96 |
'allcaps',
|
97 |
'filter',
|
98 |
-
|
99 |
|
100 |
/**
|
101 |
* The required permission|user_role|capability|user_level of the user.
|
@@ -169,7 +169,7 @@ abstract class PUM_Abstract_Model_User {
|
|
169 |
|
170 |
} elseif ( method_exists( $this, 'get_' . $key ) ) {
|
171 |
|
172 |
-
return call_user_func(
|
173 |
|
174 |
} else {
|
175 |
|
@@ -192,7 +192,7 @@ abstract class PUM_Abstract_Model_User {
|
|
192 |
*/
|
193 |
public function __call( $name, $arguments ) {
|
194 |
if ( method_exists( $this->user, $name ) ) {
|
195 |
-
return call_user_func_array(
|
196 |
}
|
197 |
}
|
198 |
|
@@ -212,7 +212,7 @@ abstract class PUM_Abstract_Model_User {
|
|
212 |
*
|
213 |
* @param $key
|
214 |
* @param $value
|
215 |
-
* @param bool
|
216 |
*
|
217 |
* @return bool|int
|
218 |
*/
|
@@ -276,7 +276,7 @@ abstract class PUM_Abstract_Model_User {
|
|
276 |
*
|
277 |
* @return bool|int
|
278 |
*/
|
279 |
-
public function delete_meta( $key, $value =
|
280 |
return delete_user_meta( $this->ID, $key, $value );
|
281 |
}
|
282 |
|
67 |
/**
|
68 |
* @var array An array of keys that can be accessed via the $this->user (WP_User) object.
|
69 |
*/
|
70 |
+
public $core_data_keys = [
|
71 |
'nickname',
|
72 |
'description',
|
73 |
'user_description',
|
95 |
'roles',
|
96 |
'allcaps',
|
97 |
'filter',
|
98 |
+
];
|
99 |
|
100 |
/**
|
101 |
* The required permission|user_role|capability|user_level of the user.
|
169 |
|
170 |
} elseif ( method_exists( $this, 'get_' . $key ) ) {
|
171 |
|
172 |
+
return call_user_func( [ $this, 'get_' . $key ] );
|
173 |
|
174 |
} else {
|
175 |
|
192 |
*/
|
193 |
public function __call( $name, $arguments ) {
|
194 |
if ( method_exists( $this->user, $name ) ) {
|
195 |
+
return call_user_func_array( [ $this->user, $name ], $arguments );
|
196 |
}
|
197 |
}
|
198 |
|
212 |
*
|
213 |
* @param $key
|
214 |
* @param $value
|
215 |
+
* @param bool $global
|
216 |
*
|
217 |
* @return bool|int
|
218 |
*/
|
276 |
*
|
277 |
* @return bool|int
|
278 |
*/
|
279 |
+
public function delete_meta( $key, $value = '' ) {
|
280 |
return delete_user_meta( $this->ID, $key, $value );
|
281 |
}
|
282 |
|
classes/Abstract/Provider.php
CHANGED
@@ -55,8 +55,8 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
55 |
PUM_Newsletter_Providers::instance()->add_provider( $this );
|
56 |
|
57 |
/** Settings */
|
58 |
-
add_filter( 'pum_settings_fields',
|
59 |
-
add_filter( 'pum_settings_tab_sections',
|
60 |
|
61 |
/**
|
62 |
* Don't add the shortcodes or default options or process anything if the provider is disabled.
|
@@ -66,18 +66,18 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
66 |
}
|
67 |
|
68 |
/** Shortcodes Fields */
|
69 |
-
add_filter( 'pum_sub_form_shortcode_tabs',
|
70 |
-
add_filter( 'pum_sub_form_shortcode_subtabs',
|
71 |
-
add_filter( 'pum_sub_form_shortcode_fields',
|
72 |
-
add_filter( 'pum_sub_form_shortcode_defaults',
|
73 |
|
74 |
/** Forms Processing & AJAX */
|
75 |
-
add_filter( 'pum_sub_form_sanitization',
|
76 |
-
add_filter( 'pum_sub_form_validation',
|
77 |
-
add_action( 'pum_sub_form_submission',
|
78 |
|
79 |
/** Form Rendering */
|
80 |
-
add_action( 'pum_sub_form_fields',
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -113,7 +113,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
113 |
*
|
114 |
* @return array
|
115 |
*/
|
116 |
-
public function register_settings_tab_section( $sections =
|
117 |
$sections['subscriptions'][ $this->id ] = $this->name;
|
118 |
|
119 |
return $sections;
|
@@ -143,7 +143,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
143 |
*
|
144 |
* @return array $values
|
145 |
*/
|
146 |
-
public function form_sanitization( $values =
|
147 |
return $values;
|
148 |
}
|
149 |
|
@@ -155,7 +155,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
155 |
*
|
156 |
* @return WP_Error
|
157 |
*/
|
158 |
-
public function form_validation( WP_Error $errors, $values =
|
159 |
return $errors;
|
160 |
}
|
161 |
|
@@ -176,7 +176,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
176 |
*
|
177 |
* @return array $values
|
178 |
*/
|
179 |
-
public function process_form_sanitization( $values =
|
180 |
if ( $this->id !== $values['provider'] && ( 'none' === $values['provider'] && PUM_Utils_Options::get( 'newsletter_default_provider' ) !== $this->id ) ) {
|
181 |
return $values;
|
182 |
}
|
@@ -192,7 +192,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
192 |
*
|
193 |
* @return WP_Error
|
194 |
*/
|
195 |
-
public function process_form_validation( WP_Error $errors, $values =
|
196 |
if ( $this->id !== $values['provider'] && ( 'none' === $values['provider'] && PUM_Utils_Options::get( 'newsletter_default_provider' ) !== $this->id ) ) {
|
197 |
return $errors;
|
198 |
}
|
@@ -231,8 +231,8 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
231 |
*
|
232 |
* @return array
|
233 |
*/
|
234 |
-
public function shortcode_tabs( $tabs =
|
235 |
-
$resorted_tabs =
|
236 |
|
237 |
foreach ( $tabs as $tab_id => $label ) {
|
238 |
$resorted_tabs[ $tab_id ] = $label;
|
@@ -252,12 +252,15 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
252 |
*
|
253 |
* @return array
|
254 |
*/
|
255 |
-
public function shortcode_subtabs( $subtabs =
|
256 |
-
return array_merge(
|
257 |
-
$
|
258 |
-
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
261 |
}
|
262 |
|
263 |
/**
|
@@ -267,9 +270,9 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
267 |
*
|
268 |
* @return array
|
269 |
*/
|
270 |
-
public function shortcode_fields( $fields =
|
271 |
|
272 |
-
$new_fields = $this->version < 2 ? PUM_Admin_Helpers::flatten_fields_array( $this->fields() ) :
|
273 |
|
274 |
foreach ( $new_fields as $field_id => $field ) {
|
275 |
if ( isset( $field['options'] ) ) {
|
@@ -277,11 +280,14 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
277 |
}
|
278 |
}
|
279 |
|
280 |
-
return array_merge(
|
281 |
-
$
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
285 |
}
|
286 |
|
287 |
/**
|
@@ -317,7 +323,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
317 |
*
|
318 |
* @return string
|
319 |
*/
|
320 |
-
public function get_message( $context, $values =
|
321 |
$message = PUM_Utils_Options::get( "{$this->opt_prefix}{$context}_message", '' );
|
322 |
|
323 |
if ( empty( $message ) ) {
|
@@ -340,7 +346,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
340 |
*
|
341 |
* @return mixed|string
|
342 |
*/
|
343 |
-
protected function dynamic_message( $message = '', $values =
|
344 |
|
345 |
preg_match_all( '/{(.*?)}/', $message, $found );
|
346 |
|
@@ -366,7 +372,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
366 |
*
|
367 |
* @return mixed|string
|
368 |
*/
|
369 |
-
protected function message_text_replace( $message = '', $match = '', $values =
|
370 |
|
371 |
if ( empty( $match ) ) {
|
372 |
return $message;
|
@@ -375,7 +381,7 @@ abstract class PUM_Abstract_Provider implements PUM_Interface_Provider {
|
|
375 |
if ( strpos( $match, '||' ) !== false ) {
|
376 |
$matches = explode( '||', $match );
|
377 |
} else {
|
378 |
-
$matches =
|
379 |
}
|
380 |
|
381 |
$replace = '';
|
55 |
PUM_Newsletter_Providers::instance()->add_provider( $this );
|
56 |
|
57 |
/** Settings */
|
58 |
+
add_filter( 'pum_settings_fields', [ $this, 'register_settings' ] );
|
59 |
+
add_filter( 'pum_settings_tab_sections', [ $this, 'register_settings_tab_section' ] );
|
60 |
|
61 |
/**
|
62 |
* Don't add the shortcodes or default options or process anything if the provider is disabled.
|
66 |
}
|
67 |
|
68 |
/** Shortcodes Fields */
|
69 |
+
add_filter( 'pum_sub_form_shortcode_tabs', [ $this, 'shortcode_tabs' ] );
|
70 |
+
add_filter( 'pum_sub_form_shortcode_subtabs', [ $this, 'shortcode_subtabs' ] );
|
71 |
+
add_filter( 'pum_sub_form_shortcode_fields', [ $this, 'shortcode_fields' ] );
|
72 |
+
add_filter( 'pum_sub_form_shortcode_defaults', [ $this, 'shortcode_defaults' ] );
|
73 |
|
74 |
/** Forms Processing & AJAX */
|
75 |
+
add_filter( 'pum_sub_form_sanitization', [ $this, 'process_form_sanitization' ], 10 );
|
76 |
+
add_filter( 'pum_sub_form_validation', [ $this, 'process_form_validation' ], 10, 2 );
|
77 |
+
add_action( 'pum_sub_form_submission', [ $this, 'process_form_submission' ], 10, 3 );
|
78 |
|
79 |
/** Form Rendering */
|
80 |
+
add_action( 'pum_sub_form_fields', [ $this, 'render_fields' ] );
|
81 |
}
|
82 |
|
83 |
/**
|
113 |
*
|
114 |
* @return array
|
115 |
*/
|
116 |
+
public function register_settings_tab_section( $sections = [] ) {
|
117 |
$sections['subscriptions'][ $this->id ] = $this->name;
|
118 |
|
119 |
return $sections;
|
143 |
*
|
144 |
* @return array $values
|
145 |
*/
|
146 |
+
public function form_sanitization( $values = [] ) {
|
147 |
return $values;
|
148 |
}
|
149 |
|
155 |
*
|
156 |
* @return WP_Error
|
157 |
*/
|
158 |
+
public function form_validation( WP_Error $errors, $values = [] ) {
|
159 |
return $errors;
|
160 |
}
|
161 |
|
176 |
*
|
177 |
* @return array $values
|
178 |
*/
|
179 |
+
public function process_form_sanitization( $values = [] ) {
|
180 |
if ( $this->id !== $values['provider'] && ( 'none' === $values['provider'] && PUM_Utils_Options::get( 'newsletter_default_provider' ) !== $this->id ) ) {
|
181 |
return $values;
|
182 |
}
|
192 |
*
|
193 |
* @return WP_Error
|
194 |
*/
|
195 |
+
public function process_form_validation( WP_Error $errors, $values = [] ) {
|
196 |
if ( $this->id !== $values['provider'] && ( 'none' === $values['provider'] && PUM_Utils_Options::get( 'newsletter_default_provider' ) !== $this->id ) ) {
|
197 |
return $errors;
|
198 |
}
|
231 |
*
|
232 |
* @return array
|
233 |
*/
|
234 |
+
public function shortcode_tabs( $tabs = [] ) {
|
235 |
+
$resorted_tabs = [];
|
236 |
|
237 |
foreach ( $tabs as $tab_id => $label ) {
|
238 |
$resorted_tabs[ $tab_id ] = $label;
|
252 |
*
|
253 |
* @return array
|
254 |
*/
|
255 |
+
public function shortcode_subtabs( $subtabs = [] ) {
|
256 |
+
return array_merge(
|
257 |
+
$subtabs,
|
258 |
+
[
|
259 |
+
$this->shortcode_tab_id() => [
|
260 |
+
'main' => $this->name,
|
261 |
+
],
|
262 |
+
]
|
263 |
+
);
|
264 |
}
|
265 |
|
266 |
/**
|
270 |
*
|
271 |
* @return array
|
272 |
*/
|
273 |
+
public function shortcode_fields( $fields = [] ) {
|
274 |
|
275 |
+
$new_fields = $this->version < 2 ? PUM_Admin_Helpers::flatten_fields_array( $this->fields() ) : [];
|
276 |
|
277 |
foreach ( $new_fields as $field_id => $field ) {
|
278 |
if ( isset( $field['options'] ) ) {
|
280 |
}
|
281 |
}
|
282 |
|
283 |
+
return array_merge(
|
284 |
+
$fields,
|
285 |
+
[
|
286 |
+
$this->shortcode_tab_id() => [
|
287 |
+
'main' => $new_fields,
|
288 |
+
],
|
289 |
+
]
|
290 |
+
);
|
291 |
}
|
292 |
|
293 |
/**
|
323 |
*
|
324 |
* @return string
|
325 |
*/
|
326 |
+
public function get_message( $context, $values = [] ) {
|
327 |
$message = PUM_Utils_Options::get( "{$this->opt_prefix}{$context}_message", '' );
|
328 |
|
329 |
if ( empty( $message ) ) {
|
346 |
*
|
347 |
* @return mixed|string
|
348 |
*/
|
349 |
+
protected function dynamic_message( $message = '', $values = [] ) {
|
350 |
|
351 |
preg_match_all( '/{(.*?)}/', $message, $found );
|
352 |
|
372 |
*
|
373 |
* @return mixed|string
|
374 |
*/
|
375 |
+
protected function message_text_replace( $message = '', $match = '', $values = [] ) {
|
376 |
|
377 |
if ( empty( $match ) ) {
|
378 |
return $message;
|
381 |
if ( strpos( $match, '||' ) !== false ) {
|
382 |
$matches = explode( '||', $match );
|
383 |
} else {
|
384 |
+
$matches = [ $match ];
|
385 |
}
|
386 |
|
387 |
$replace = '';
|
classes/Abstract/Registry.php
CHANGED
@@ -19,7 +19,7 @@ abstract class PUM_Abstract_Registry {
|
|
19 |
*
|
20 |
* @var array
|
21 |
*/
|
22 |
-
protected $items =
|
23 |
|
24 |
/**
|
25 |
* Adds an item to the registry.
|
@@ -82,7 +82,7 @@ abstract class PUM_Abstract_Registry {
|
|
82 |
if ( ! defined( 'WP_TESTS_DOMAIN' ) ) {
|
83 |
_doing_it_wrong( 'PUM_Abstract_Registry::_reset_items', 'This method is only intended for use in phpunit tests', '1.7.0' );
|
84 |
} else {
|
85 |
-
$this->items =
|
86 |
}
|
87 |
}
|
88 |
}
|
19 |
*
|
20 |
* @var array
|
21 |
*/
|
22 |
+
protected $items = [];
|
23 |
|
24 |
/**
|
25 |
* Adds an item to the registry.
|
82 |
if ( ! defined( 'WP_TESTS_DOMAIN' ) ) {
|
83 |
_doing_it_wrong( 'PUM_Abstract_Registry::_reset_items', 'This method is only intended for use in phpunit tests', '1.7.0' );
|
84 |
} else {
|
85 |
+
$this->items = [];
|
86 |
}
|
87 |
}
|
88 |
}
|
classes/Abstract/Repository/Posts.php
CHANGED
@@ -26,10 +26,10 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
26 |
*
|
27 |
* @var array
|
28 |
*/
|
29 |
-
protected $cache =
|
30 |
-
'objects' =>
|
31 |
-
'queries' =>
|
32 |
-
|
33 |
|
34 |
/**
|
35 |
* @var string
|
@@ -49,7 +49,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
49 |
* Initialize the repository.
|
50 |
*/
|
51 |
protected function init() {
|
52 |
-
$this->query = new WP_Query;
|
53 |
$this->reset_strict_query_args();
|
54 |
}
|
55 |
|
@@ -61,13 +61,13 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
61 |
* @return array
|
62 |
*/
|
63 |
public function default_query_args() {
|
64 |
-
return
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* @var array
|
69 |
*/
|
70 |
-
protected $strict_query_args =
|
71 |
|
72 |
/**
|
73 |
* Returns an array of default strict query args that can't be over ridden, such as post type.
|
@@ -75,9 +75,9 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
75 |
* @return array
|
76 |
*/
|
77 |
protected function default_strict_query_args() {
|
78 |
-
return
|
79 |
'post_type' => $this->get_post_type(),
|
80 |
-
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -115,7 +115,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
115 |
*
|
116 |
* @return array
|
117 |
*/
|
118 |
-
protected function _build_wp_query_args( $args =
|
119 |
$args = wp_parse_args( $args, $this->default_query_args() );
|
120 |
|
121 |
$args = $this->build_wp_query_args( $args );
|
@@ -128,7 +128,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
128 |
*
|
129 |
* @return array
|
130 |
*/
|
131 |
-
protected function build_wp_query_args( $args =
|
132 |
return $args;
|
133 |
}
|
134 |
|
@@ -140,7 +140,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
140 |
*/
|
141 |
public function get_item( $id ) {
|
142 |
if ( ! $this->has_item( $id ) ) {
|
143 |
-
throw new InvalidArgumentException( sprintf( __( 'No %s found with id %d.', 'popup-maker' ), $this->get_post_type(), $id ) );
|
144 |
}
|
145 |
|
146 |
return $this->get_model( $id );
|
@@ -158,7 +158,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
158 |
$id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE %s = %s", $field, $value ) );
|
159 |
|
160 |
if ( ! $id || ! $this->has_item( $id ) ) {
|
161 |
-
throw new InvalidArgumentException( sprintf( __( 'No user found with %s %s.', 'popup-maker' ), $field, $value ) );
|
162 |
}
|
163 |
|
164 |
return $this->get_model( $id );
|
@@ -187,7 +187,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
187 |
*
|
188 |
* @return WP_Post[]|PUM_Abstract_Model_Post[]
|
189 |
*/
|
190 |
-
public function get_items( $args =
|
191 |
/** Reset default strict query args. */
|
192 |
$this->reset_strict_query_args();
|
193 |
|
@@ -225,7 +225,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
225 |
*
|
226 |
* @return int
|
227 |
*/
|
228 |
-
public function count_items( $args =
|
229 |
/** Reset default strict query args. */
|
230 |
$this->reset_strict_query_args();
|
231 |
|
@@ -271,21 +271,27 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
271 |
*/
|
272 |
public function create_item( $data ) {
|
273 |
|
274 |
-
$data = wp_parse_args(
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
279 |
|
280 |
$this->assert_data( $data );
|
281 |
|
282 |
-
$post_id = wp_insert_post(
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
289 |
|
290 |
if ( is_wp_error( $post_id ) ) {
|
291 |
throw new InvalidArgumentException( $post_id->get_error_message() );
|
@@ -308,7 +314,7 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
308 |
/** @var WP_Post|PUM_Abstract_Model_Post $original */
|
309 |
$original = $this->get_item( $id );
|
310 |
|
311 |
-
$post_update =
|
312 |
|
313 |
foreach ( $data as $key => $value ) {
|
314 |
if ( $original->$key === $value ) {
|
@@ -376,10 +382,10 @@ abstract class PUM_Abstract_Repository_Posts implements PUM_Interface_Repository
|
|
376 |
if ( ! $this->cached_model_exists( $post ) ) {
|
377 |
$object = new $model( $post );
|
378 |
|
379 |
-
$this->cache['objects'][ $post->ID ] =
|
380 |
'object' => $object,
|
381 |
-
'hash'
|
382 |
-
|
383 |
}
|
384 |
|
385 |
return $this->cache['objects'][ $post->ID ]['object'];
|
26 |
*
|
27 |
* @var array
|
28 |
*/
|
29 |
+
protected $cache = [
|
30 |
+
'objects' => [],
|
31 |
+
'queries' => [],
|
32 |
+
];
|
33 |
|
34 |
/**
|
35 |
* @var string
|
49 |
* Initialize the repository.
|
50 |
*/
|
51 |
protected function init() {
|
52 |
+
$this->query = new WP_Query();
|
53 |
$this->reset_strict_query_args();
|
54 |
}
|
55 |
|
61 |
* @return array
|
62 |
*/
|
63 |
public function default_query_args() {
|
64 |
+
return [];
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
* @var array
|
69 |
*/
|
70 |
+
protected $strict_query_args = [];
|
71 |
|
72 |
/**
|
73 |
* Returns an array of default strict query args that can't be over ridden, such as post type.
|
75 |
* @return array
|
76 |
*/
|
77 |
protected function default_strict_query_args() {
|
78 |
+
return [
|
79 |
'post_type' => $this->get_post_type(),
|
80 |
+
];
|
81 |
}
|
82 |
|
83 |
/**
|
115 |
*
|
116 |
* @return array
|
117 |
*/
|
118 |
+
protected function _build_wp_query_args( $args = [] ) {
|
119 |
$args = wp_parse_args( $args, $this->default_query_args() );
|
120 |
|
121 |
$args = $this->build_wp_query_args( $args );
|
128 |
*
|
129 |
* @return array
|
130 |
*/
|
131 |
+
protected function build_wp_query_args( $args = [] ) {
|
132 |
return $args;
|
133 |
}
|
134 |
|
140 |
*/
|
141 |
public function get_item( $id ) {
|
142 |
if ( ! $this->has_item( $id ) ) {
|
143 |
+
throw new InvalidArgumentException( sprintf( __( 'No %1$s found with id %2$d.', 'popup-maker' ), $this->get_post_type(), $id ) );
|
144 |
}
|
145 |
|
146 |
return $this->get_model( $id );
|
158 |
$id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE %s = %s", $field, $value ) );
|
159 |
|
160 |
if ( ! $id || ! $this->has_item( $id ) ) {
|
161 |
+
throw new InvalidArgumentException( sprintf( __( 'No user found with %1$s %2$s.', 'popup-maker' ), $field, $value ) );
|
162 |
}
|
163 |
|
164 |
return $this->get_model( $id );
|
187 |
*
|
188 |
* @return WP_Post[]|PUM_Abstract_Model_Post[]
|
189 |
*/
|
190 |
+
public function get_items( $args = [] ) {
|
191 |
/** Reset default strict query args. */
|
192 |
$this->reset_strict_query_args();
|
193 |
|
225 |
*
|
226 |
* @return int
|
227 |
*/
|
228 |
+
public function count_items( $args = [] ) {
|
229 |
/** Reset default strict query args. */
|
230 |
$this->reset_strict_query_args();
|
231 |
|
271 |
*/
|
272 |
public function create_item( $data ) {
|
273 |
|
274 |
+
$data = wp_parse_args(
|
275 |
+
$data,
|
276 |
+
[
|
277 |
+
'content' => '',
|
278 |
+
'title' => '',
|
279 |
+
'meta_input' => [],
|
280 |
+
]
|
281 |
+
);
|
282 |
|
283 |
$this->assert_data( $data );
|
284 |
|
285 |
+
$post_id = wp_insert_post(
|
286 |
+
[
|
287 |
+
'post_type' => $this->get_post_type(),
|
288 |
+
'post_status' => 'publish',
|
289 |
+
'post_title' => $data['title'],
|
290 |
+
'post_content' => $data['content'],
|
291 |
+
'meta_input' => $data['meta_input'],
|
292 |
+
],
|
293 |
+
true
|
294 |
+
);
|
295 |
|
296 |
if ( is_wp_error( $post_id ) ) {
|
297 |
throw new InvalidArgumentException( $post_id->get_error_message() );
|
314 |
/** @var WP_Post|PUM_Abstract_Model_Post $original */
|
315 |
$original = $this->get_item( $id );
|
316 |
|
317 |
+
$post_update = [];
|
318 |
|
319 |
foreach ( $data as $key => $value ) {
|
320 |
if ( $original->$key === $value ) {
|
382 |
if ( ! $this->cached_model_exists( $post ) ) {
|
383 |
$object = new $model( $post );
|
384 |
|
385 |
+
$this->cache['objects'][ $post->ID ] = [
|
386 |
'object' => $object,
|
387 |
+
'hash' => $this->get_post_hash( $post ),
|
388 |
+
];
|
389 |
}
|
390 |
|
391 |
return $this->cache['objects'][ $post->ID ]['object'];
|
classes/Abstract/Upgrade.php
CHANGED
@@ -22,10 +22,13 @@ abstract class PUM_Abstract_Upgrade extends PUM_Abstract_Batch_Process {
|
|
22 |
* @param int $step
|
23 |
*/
|
24 |
public function __construct( $step = 1 ) {
|
25 |
-
update_option(
|
26 |
-
'
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
parent::__construct( $step );
|
31 |
}
|
@@ -44,4 +47,4 @@ abstract class PUM_Abstract_Upgrade extends PUM_Abstract_Batch_Process {
|
|
44 |
}
|
45 |
|
46 |
|
47 |
-
}
|
22 |
* @param int $step
|
23 |
*/
|
24 |
public function __construct( $step = 1 ) {
|
25 |
+
update_option(
|
26 |
+
'pum_doing_upgrade',
|
27 |
+
[
|
28 |
+
'upgrade_id' => $this->batch_id,
|
29 |
+
'step' => $step,
|
30 |
+
]
|
31 |
+
);
|
32 |
|
33 |
parent::__construct( $step );
|
34 |
}
|
47 |
}
|
48 |
|
49 |
|
50 |
+
}
|
classes/Abstract/Upgrade/Posts.php
CHANGED
@@ -37,7 +37,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
37 |
*
|
38 |
* @var array
|
39 |
*/
|
40 |
-
public $post_status =
|
41 |
|
42 |
/**
|
43 |
* Number of posts to migrate per step.
|
@@ -81,10 +81,12 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
81 |
$total_to_migrate = $this->get_total_count();
|
82 |
|
83 |
if ( ! $total_to_migrate ) {
|
84 |
-
$posts = $this->get_posts(
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
$posts = wp_parse_id_list( $posts );
|
90 |
|
@@ -105,7 +107,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
105 |
*
|
106 |
* @return array
|
107 |
*/
|
108 |
-
public function get_posts( $args =
|
109 |
return get_posts( $this->query_args( $args ) );
|
110 |
}
|
111 |
|
@@ -118,12 +120,15 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
118 |
*
|
119 |
* @return array
|
120 |
*/
|
121 |
-
public function query_args( $args =
|
122 |
|
123 |
-
$defaults = wp_parse_args(
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
127 |
|
128 |
return wp_parse_args( $args, $defaults );
|
129 |
}
|
@@ -133,7 +138,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
133 |
* @return array
|
134 |
*/
|
135 |
public function custom_query_args() {
|
136 |
-
return
|
137 |
}
|
138 |
|
139 |
/**
|
@@ -145,17 +150,19 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
145 |
$completed_post_ids = $this->get_completed_post_ids();
|
146 |
|
147 |
if ( $this->prefetch_ids ) {
|
148 |
-
$all_posts
|
149 |
$remaining_post_ids = array_diff( $all_posts, $completed_post_ids );
|
150 |
-
$posts
|
151 |
} else {
|
152 |
-
$posts = $this->get_posts(
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
159 |
}
|
160 |
|
161 |
if ( empty( $posts ) ) {
|
@@ -185,9 +192,9 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
185 |
*/
|
186 |
public function get_message( $code ) {
|
187 |
$post_type = get_post_type_object( $this->post_type );
|
188 |
-
$labels
|
189 |
-
$singular
|
190 |
-
$plural
|
191 |
|
192 |
switch ( $code ) {
|
193 |
|
@@ -225,7 +232,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
225 |
*/
|
226 |
protected function get_post_ids() {
|
227 |
if ( ! isset( $this->post_ids ) || ! $this->post_ids ) {
|
228 |
-
$this->post_ids =
|
229 |
|
230 |
if ( is_array( $this->post_ids ) ) {
|
231 |
$this->post_ids = wp_parse_id_list( $this->post_ids );
|
@@ -240,7 +247,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
240 |
*
|
241 |
* @param array $post_ids Full list of post_ids to be processed.
|
242 |
*/
|
243 |
-
protected function set_post_ids( $post_ids =
|
244 |
$this->post_ids = $post_ids;
|
245 |
|
246 |
PUM_DataStorage::write( "{$this->batch_id}_post_ids", $post_ids );
|
@@ -262,7 +269,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
262 |
*/
|
263 |
protected function get_completed_post_ids() {
|
264 |
if ( ! isset( $this->completed_post_ids ) || ! $this->completed_post_ids ) {
|
265 |
-
$completed_post_ids
|
266 |
$this->completed_post_ids = wp_parse_id_list( $completed_post_ids );
|
267 |
}
|
268 |
|
@@ -274,7 +281,7 @@ abstract class PUM_Abstract_Upgrade_Posts extends PUM_Abstract_Upgrade implement
|
|
274 |
*
|
275 |
* @param array $completed_post_ids Full list of post_ids to be processed.
|
276 |
*/
|
277 |
-
protected function set_completed_post_ids( $completed_post_ids =
|
278 |
$this->completed_post_ids = wp_parse_id_list( $completed_post_ids );
|
279 |
|
280 |
PUM_DataStorage::write( "{$this->batch_id}_completed_post_ids", $completed_post_ids );
|
37 |
*
|
38 |
* @var array
|
39 |
*/
|
40 |
+
public $post_status = [ 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ];
|
41 |
|
42 |
/**
|
43 |
* Number of posts to migrate per step.
|
81 |
$total_to_migrate = $this->get_total_count();
|
82 |
|
83 |
if ( ! $total_to_migrate ) {
|
84 |
+
$posts = $this->get_posts(
|
85 |
+
[
|
86 |
+
'fields' => 'ids',
|
87 |
+
'posts_per_page' => - 1,
|
88 |
+
]
|
89 |
+
);
|
90 |
|
91 |
$posts = wp_parse_id_list( $posts );
|
92 |
|
107 |
*
|
108 |
* @return array
|
109 |
*/
|
110 |
+
public function get_posts( $args = [] ) {
|
111 |
return get_posts( $this->query_args( $args ) );
|
112 |
}
|
113 |
|
120 |
*
|
121 |
* @return array
|
122 |
*/
|
123 |
+
public function query_args( $args = [] ) {
|
124 |
|
125 |
+
$defaults = wp_parse_args(
|
126 |
+
$this->custom_query_args(),
|
127 |
+
[
|
128 |
+
'post_status' => $this->post_status,
|
129 |
+
'post_type' => $this->post_type,
|
130 |
+
]
|
131 |
+
);
|
132 |
|
133 |
return wp_parse_args( $args, $defaults );
|
134 |
}
|
138 |
* @return array
|
139 |
*/
|
140 |
public function custom_query_args() {
|
141 |
+
return [];
|
142 |
}
|
143 |
|
144 |
/**
|
150 |
$completed_post_ids = $this->get_completed_post_ids();
|
151 |
|
152 |
if ( $this->prefetch_ids ) {
|
153 |
+
$all_posts = $this->get_post_ids();
|
154 |
$remaining_post_ids = array_diff( $all_posts, $completed_post_ids );
|
155 |
+
$posts = array_slice( $remaining_post_ids, 0, $this->per_step );
|
156 |
} else {
|
157 |
+
$posts = $this->get_posts(
|
158 |
+
[
|
159 |
+
'fields' => 'ids',
|
160 |
+
'posts_per_page' => $this->per_step,
|
161 |
+
'offset' => $this->get_offset(),
|
162 |
+
'orderby' => 'ID',
|
163 |
+
'order' => 'ASC',
|
164 |
+
]
|
165 |
+
);
|
166 |
}
|
167 |
|
168 |
if ( empty( $posts ) ) {
|
192 |
*/
|
193 |
public function get_message( $code ) {
|
194 |
$post_type = get_post_type_object( $this->post_type );
|
195 |
+
$labels = get_post_type_labels( $post_type );
|
196 |
+
$singular = strtolower( $labels->singular_name );
|
197 |
+
$plural = strtolower( $labels->name );
|
198 |
|
199 |
switch ( $code ) {
|
200 |
|
232 |
*/
|
233 |
protected function get_post_ids() {
|
234 |
if ( ! isset( $this->post_ids ) || ! $this->post_ids ) {
|
235 |
+
$this->post_ids = PUM_DataStorage::get( "{$this->batch_id}_post_ids", false );
|
236 |
|
237 |
if ( is_array( $this->post_ids ) ) {
|
238 |
$this->post_ids = wp_parse_id_list( $this->post_ids );
|
247 |
*
|
248 |
* @param array $post_ids Full list of post_ids to be processed.
|
249 |
*/
|
250 |
+
protected function set_post_ids( $post_ids = [] ) {
|
251 |
$this->post_ids = $post_ids;
|
252 |
|
253 |
PUM_DataStorage::write( "{$this->batch_id}_post_ids", $post_ids );
|
269 |
*/
|
270 |
protected function get_completed_post_ids() {
|
271 |
if ( ! isset( $this->completed_post_ids ) || ! $this->completed_post_ids ) {
|
272 |
+
$completed_post_ids = PUM_DataStorage::get( "{$this->batch_id}_completed_post_ids", [] );
|
273 |
$this->completed_post_ids = wp_parse_id_list( $completed_post_ids );
|
274 |
}
|
275 |
|
281 |
*
|
282 |
* @param array $completed_post_ids Full list of post_ids to be processed.
|
283 |
*/
|
284 |
+
protected function set_completed_post_ids( $completed_post_ids = [] ) {
|
285 |
$this->completed_post_ids = wp_parse_id_list( $completed_post_ids );
|
286 |
|
287 |
PUM_DataStorage::write( "{$this->batch_id}_completed_post_ids", $completed_post_ids );
|
classes/Abstract/Upgrade/Settings.php
CHANGED
@@ -76,5 +76,5 @@ abstract class PUM_Abstract_Upgrade_Settings extends PUM_Abstract_Upgrade {
|
|
76 |
*
|
77 |
* @param array $settings
|
78 |
*/
|
79 |
-
abstract public function process_settings( $settings =
|
80 |
}
|
76 |
*
|
77 |
* @param array $settings
|
78 |
*/
|
79 |
+
abstract public function process_settings( $settings = [] );
|
80 |
}
|
classes/Admin.php
CHANGED
@@ -19,10 +19,10 @@ class PUM_Admin {
|
|
19 |
PUM_Upsell::init();
|
20 |
PUM_Admin_Onboarding::init();
|
21 |
|
22 |
-
add_filter( 'user_has_cap',
|
23 |
-
add_filter( 'plugin_action_links',
|
24 |
-
add_action( 'admin_init',
|
25 |
-
add_action( 'admin_head',
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -54,14 +54,17 @@ class PUM_Admin {
|
|
54 |
public static function plugin_action_links( $links, $file ) {
|
55 |
|
56 |
if ( $file == plugin_basename( POPMAKE ) ) {
|
57 |
-
$plugin_action_links = apply_filters(
|
58 |
-
'
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
61 |
|
62 |
// TODO Rewrite this to take full advantage of our polyglot detection code in Alerts for translation requests.
|
63 |
if ( substr( get_locale(), 0, 2 ) != 'en' ) {
|
64 |
-
$plugin_action_links = array_merge(
|
65 |
}
|
66 |
|
67 |
foreach ( $plugin_action_links as $link ) {
|
@@ -109,7 +112,7 @@ class PUM_Admin {
|
|
109 |
if ( isset( $instance->admin ) && is_a( $instance->admin, '\Elementor\Core\Admin\Admin' ) && method_exists( $instance->admin, 'get_component' ) ) {
|
110 |
$notices = $instance->admin->get_component( 'admin-notices' );
|
111 |
if ( false !== $notices && is_a( $notices, '\Elementor\Core\Admin\Admin_Notices' ) ) {
|
112 |
-
remove_action( 'admin_notices',
|
113 |
}
|
114 |
}
|
115 |
}
|
19 |
PUM_Upsell::init();
|
20 |
PUM_Admin_Onboarding::init();
|
21 |
|
22 |
+
add_filter( 'user_has_cap', [ __CLASS__, 'prevent_default_theme_deletion' ], 10, 3 );
|
23 |
+
add_filter( 'plugin_action_links', [ __CLASS__, 'plugin_action_links' ], 10, 2 );
|
24 |
+
add_action( 'admin_init', [ __CLASS__, 'after_install' ] );
|
25 |
+
add_action( 'admin_head', [ __CLASS__, 'clean_ui' ] );
|
26 |
}
|
27 |
|
28 |
/**
|
54 |
public static function plugin_action_links( $links, $file ) {
|
55 |
|
56 |
if ( $file == plugin_basename( POPMAKE ) ) {
|
57 |
+
$plugin_action_links = apply_filters(
|
58 |
+
'pum_plugin_action_links',
|
59 |
+
[
|
60 |
+
'extend' => '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-extensions' ) . '">' . __( 'Integrations', 'popup-maker' ) . '</a>',
|
61 |
+
'settings' => '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings' ) . '">' . __( 'Settings', 'popup-maker' ) . '</a>',
|
62 |
+
]
|
63 |
+
);
|
64 |
|
65 |
// TODO Rewrite this to take full advantage of our polyglot detection code in Alerts for translation requests.
|
66 |
if ( substr( get_locale(), 0, 2 ) != 'en' ) {
|
67 |
+
$plugin_action_links = array_merge( [ 'translate' => '<a href="' . sprintf( 'https://translate.wordpress.org/locale/%s/default/wp-plugins/popup-maker', substr( get_locale(), 0, 2 ) ) . '" target="_blank">' . __( 'Translate', 'popup-maker' ) . '</a>' ], $plugin_action_links );
|
68 |
}
|
69 |
|
70 |
foreach ( $plugin_action_links as $link ) {
|
112 |
if ( isset( $instance->admin ) && is_a( $instance->admin, '\Elementor\Core\Admin\Admin' ) && method_exists( $instance->admin, 'get_component' ) ) {
|
113 |
$notices = $instance->admin->get_component( 'admin-notices' );
|
114 |
if ( false !== $notices && is_a( $notices, '\Elementor\Core\Admin\Admin_Notices' ) ) {
|
115 |
+
remove_action( 'admin_notices', [ $notices, 'admin_notices' ], 20 );
|
116 |
}
|
117 |
}
|
118 |
}
|
classes/Admin/Ajax.php
CHANGED
@@ -18,9 +18,9 @@ class PUM_Admin_Ajax {
|
|
18 |
* Hooks our methods into AJAX actions.
|
19 |
*/
|
20 |
public static function init() {
|
21 |
-
add_action( 'wp_ajax_pum_object_search',
|
22 |
-
add_action( 'wp_ajax_pum_process_batch_request',
|
23 |
-
add_action( 'wp_ajax_pum_save_enabled_state',
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -31,10 +31,10 @@ class PUM_Admin_Ajax {
|
|
31 |
public static function save_popup_enabled_state() {
|
32 |
$args = wp_parse_args(
|
33 |
$_REQUEST,
|
34 |
-
|
35 |
'popupID' => 0,
|
36 |
'active' => 1,
|
37 |
-
|
38 |
);
|
39 |
|
40 |
// Ensures Popup ID is an int and not 0.
|
@@ -45,7 +45,7 @@ class PUM_Admin_Ajax {
|
|
45 |
|
46 |
// Ensures active state is 0 or 1.
|
47 |
$enabled = intval( $args['enabled'] );
|
48 |
-
if ( ! in_array( $enabled,
|
49 |
wp_send_json_error( 'Invalid enabled state provided.' );
|
50 |
}
|
51 |
|
@@ -80,10 +80,10 @@ class PUM_Admin_Ajax {
|
|
80 |
* Uses passed array with keys of object_type, object_key, include, exclude. Echos our results as JSON.
|
81 |
*/
|
82 |
public static function object_search() {
|
83 |
-
$results =
|
84 |
-
'items' =>
|
85 |
'total_count' => 0,
|
86 |
-
|
87 |
|
88 |
$object_type = sanitize_text_field( $_REQUEST['object_type'] );
|
89 |
$include = ! empty( $_REQUEST['include'] ) ? wp_parse_id_list( $_REQUEST['include'] ) : [];
|
@@ -100,18 +100,18 @@ class PUM_Admin_Ajax {
|
|
100 |
if ( ! empty( $include ) ) {
|
101 |
$include_query = PUM_Helpers::post_type_selectlist_query(
|
102 |
$post_type,
|
103 |
-
|
104 |
'post__in' => $include,
|
105 |
'posts_per_page' => - 1,
|
106 |
-
|
107 |
true
|
108 |
);
|
109 |
|
110 |
foreach ( $include_query['items'] as $id => $name ) {
|
111 |
-
$results['items'][] =
|
112 |
'id' => $id,
|
113 |
'text' => "$name (ID: $id)",
|
114 |
-
|
115 |
}
|
116 |
|
117 |
$results['total_count'] += (int) $include_query['total_count'];
|
@@ -119,20 +119,20 @@ class PUM_Admin_Ajax {
|
|
119 |
|
120 |
$query = PUM_Helpers::post_type_selectlist_query(
|
121 |
$post_type,
|
122 |
-
|
123 |
's' => ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
124 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
125 |
'post__not_in' => $exclude,
|
126 |
'posts_per_page' => 10,
|
127 |
-
|
128 |
true
|
129 |
);
|
130 |
|
131 |
foreach ( $query['items'] as $id => $name ) {
|
132 |
-
$results['items'][] =
|
133 |
'id' => $id,
|
134 |
'text' => "$name (ID: $id)",
|
135 |
-
|
136 |
}
|
137 |
|
138 |
$results['total_count'] += (int) $query['total_count'];
|
@@ -144,18 +144,18 @@ class PUM_Admin_Ajax {
|
|
144 |
if ( ! empty( $include ) ) {
|
145 |
$include_query = PUM_Helpers::taxonomy_selectlist_query(
|
146 |
$taxonomy,
|
147 |
-
|
148 |
'include' => $include,
|
149 |
'number' => 0,
|
150 |
-
|
151 |
true
|
152 |
);
|
153 |
|
154 |
foreach ( $include_query['items'] as $id => $name ) {
|
155 |
-
$results['items'][] =
|
156 |
'id' => $id,
|
157 |
'text' => "$name (ID: $id)",
|
158 |
-
|
159 |
}
|
160 |
|
161 |
$results['total_count'] += (int) $include_query['total_count'];
|
@@ -163,20 +163,20 @@ class PUM_Admin_Ajax {
|
|
163 |
|
164 |
$query = PUM_Helpers::taxonomy_selectlist_query(
|
165 |
$taxonomy,
|
166 |
-
|
167 |
'search' => ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
168 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
169 |
'exclude' => $exclude,
|
170 |
'number' => 10,
|
171 |
-
|
172 |
true
|
173 |
);
|
174 |
|
175 |
foreach ( $query['items'] as $id => $name ) {
|
176 |
-
$results['items'][] =
|
177 |
'id' => $id,
|
178 |
'text' => "$name (ID: $id)",
|
179 |
-
|
180 |
}
|
181 |
|
182 |
$results['total_count'] += (int) $query['total_count'];
|
@@ -186,40 +186,40 @@ class PUM_Admin_Ajax {
|
|
186 |
|
187 |
if ( ! empty( $include ) ) {
|
188 |
$include_query = PUM_Helpers::user_selectlist_query(
|
189 |
-
|
190 |
'role' => $user_role,
|
191 |
'include' => $include,
|
192 |
'number' => - 1,
|
193 |
-
|
194 |
true
|
195 |
);
|
196 |
|
197 |
foreach ( $include_query['items'] as $id => $name ) {
|
198 |
-
$results['items'][] =
|
199 |
'id' => $id,
|
200 |
'text' => "$name (ID: $id)",
|
201 |
-
|
202 |
}
|
203 |
|
204 |
$results['total_count'] += (int) $include_query['total_count'];
|
205 |
}
|
206 |
|
207 |
$query = PUM_Helpers::user_selectlist_query(
|
208 |
-
|
209 |
'role' => $user_role,
|
210 |
'search' => ! empty( $_REQUEST['s'] ) ? '*' . $_REQUEST['s'] . '*' : null,
|
211 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
212 |
'exclude' => $exclude,
|
213 |
'number' => 10,
|
214 |
-
|
215 |
true
|
216 |
);
|
217 |
|
218 |
foreach ( $query['items'] as $id => $name ) {
|
219 |
-
$results['items'][] =
|
220 |
'id' => $id,
|
221 |
'text' => "$name (ID: $id)",
|
222 |
-
|
223 |
}
|
224 |
|
225 |
$results['total_count'] += (int) $query['total_count'];
|
@@ -243,18 +243,18 @@ class PUM_Admin_Ajax {
|
|
243 |
|
244 |
if ( ! $batch_id ) {
|
245 |
wp_send_json_error(
|
246 |
-
|
247 |
'error' => __( 'A batch process ID must be present to continue.', 'popup-maker' ),
|
248 |
-
|
249 |
);
|
250 |
}
|
251 |
|
252 |
// Nonce.
|
253 |
if ( ! isset( $_REQUEST['nonce'] ) || ( isset( $_REQUEST['nonce'] ) && false === wp_verify_nonce( $_REQUEST['nonce'], "{$batch_id}_step_nonce" ) ) ) {
|
254 |
wp_send_json_error(
|
255 |
-
|
256 |
'error' => __( 'You do not have permission to initiate this request. Contact an administrator for more information.', 'popup-maker' ),
|
257 |
-
|
258 |
);
|
259 |
}
|
260 |
|
@@ -263,9 +263,9 @@ class PUM_Admin_Ajax {
|
|
263 |
|
264 |
if ( false === $batch ) {
|
265 |
wp_send_json_error(
|
266 |
-
|
267 |
'error' => sprintf( __( '%s is an invalid batch process ID.', 'popup-maker' ), esc_html( $_REQUEST['batch_id'] ) ),
|
268 |
-
|
269 |
);
|
270 |
}
|
271 |
|
@@ -274,9 +274,9 @@ class PUM_Admin_Ajax {
|
|
274 |
|
275 |
if ( empty( $class_file ) || ! file_exists( $class_file ) ) {
|
276 |
wp_send_json_error(
|
277 |
-
|
278 |
'error' => sprintf( __( 'An invalid file path is registered for the %1$s batch process handler.', 'popup-maker' ), "<code>{$batch_id}</code>" ),
|
279 |
-
|
280 |
);
|
281 |
} else {
|
282 |
require_once $class_file;
|
@@ -284,9 +284,9 @@ class PUM_Admin_Ajax {
|
|
284 |
|
285 |
if ( empty( $class ) || ! class_exists( $class ) ) {
|
286 |
wp_send_json_error(
|
287 |
-
|
288 |
'error' => sprintf( __( '%1$s is an invalid handler for the %2$s batch process. Please try again.', 'popup-maker' ), "<code>{$class}</code>", "<code>{$batch_id}</code>" ),
|
289 |
-
|
290 |
);
|
291 |
}
|
292 |
|
@@ -321,7 +321,7 @@ class PUM_Admin_Ajax {
|
|
321 |
// Handle pre-fetching data.
|
322 |
if ( $using_prefetch ) {
|
323 |
// Initialize any data needed to process a step.
|
324 |
-
$data = isset( $_REQUEST['form'] ) ? $_REQUEST['form'] :
|
325 |
|
326 |
$process->init( $data );
|
327 |
$process->pre_fetch();
|
@@ -333,7 +333,7 @@ class PUM_Admin_Ajax {
|
|
333 |
if ( is_wp_error( $step ) ) {
|
334 |
wp_send_json_error( $step );
|
335 |
} else {
|
336 |
-
$response_data =
|
337 |
|
338 |
// Map fields if this is an import.
|
339 |
if ( isset( $process->field_mapping ) && ( $process instanceof PUM_Interface_CSV_Importer ) ) {
|
@@ -352,12 +352,12 @@ class PUM_Admin_Ajax {
|
|
352 |
if ( ! $process->is_empty ) {
|
353 |
$response_data['url'] = pum_admin_url(
|
354 |
'tools',
|
355 |
-
|
356 |
'step' => $step,
|
357 |
'nonce' => wp_create_nonce( 'pum-batch-export' ),
|
358 |
'batch_id' => $batch_id,
|
359 |
'pum_action' => 'download_batch_export',
|
360 |
-
|
361 |
);
|
362 |
}
|
363 |
}
|
18 |
* Hooks our methods into AJAX actions.
|
19 |
*/
|
20 |
public static function init() {
|
21 |
+
add_action( 'wp_ajax_pum_object_search', [ __CLASS__, 'object_search' ] );
|
22 |
+
add_action( 'wp_ajax_pum_process_batch_request', [ __CLASS__, 'process_batch_request' ] );
|
23 |
+
add_action( 'wp_ajax_pum_save_enabled_state', [ __CLASS__, 'save_popup_enabled_state' ] );
|
24 |
}
|
25 |
|
26 |
/**
|
31 |
public static function save_popup_enabled_state() {
|
32 |
$args = wp_parse_args(
|
33 |
$_REQUEST,
|
34 |
+
[
|
35 |
'popupID' => 0,
|
36 |
'active' => 1,
|
37 |
+
]
|
38 |
);
|
39 |
|
40 |
// Ensures Popup ID is an int and not 0.
|
45 |
|
46 |
// Ensures active state is 0 or 1.
|
47 |
$enabled = intval( $args['enabled'] );
|
48 |
+
if ( ! in_array( $enabled, [ 0, 1 ], true ) ) {
|
49 |
wp_send_json_error( 'Invalid enabled state provided.' );
|
50 |
}
|
51 |
|
80 |
* Uses passed array with keys of object_type, object_key, include, exclude. Echos our results as JSON.
|
81 |
*/
|
82 |
public static function object_search() {
|
83 |
+
$results = [
|
84 |
+
'items' => [],
|
85 |
'total_count' => 0,
|
86 |
+
];
|
87 |
|
88 |
$object_type = sanitize_text_field( $_REQUEST['object_type'] );
|
89 |
$include = ! empty( $_REQUEST['include'] ) ? wp_parse_id_list( $_REQUEST['include'] ) : [];
|
100 |
if ( ! empty( $include ) ) {
|
101 |
$include_query = PUM_Helpers::post_type_selectlist_query(
|
102 |
$post_type,
|
103 |
+
[
|
104 |
'post__in' => $include,
|
105 |
'posts_per_page' => - 1,
|
106 |
+
],
|
107 |
true
|
108 |
);
|
109 |
|
110 |
foreach ( $include_query['items'] as $id => $name ) {
|
111 |
+
$results['items'][] = [
|
112 |
'id' => $id,
|
113 |
'text' => "$name (ID: $id)",
|
114 |
+
];
|
115 |
}
|
116 |
|
117 |
$results['total_count'] += (int) $include_query['total_count'];
|
119 |
|
120 |
$query = PUM_Helpers::post_type_selectlist_query(
|
121 |
$post_type,
|
122 |
+
[
|
123 |
's' => ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
124 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
125 |
'post__not_in' => $exclude,
|
126 |
'posts_per_page' => 10,
|
127 |
+
],
|
128 |
true
|
129 |
);
|
130 |
|
131 |
foreach ( $query['items'] as $id => $name ) {
|
132 |
+
$results['items'][] = [
|
133 |
'id' => $id,
|
134 |
'text' => "$name (ID: $id)",
|
135 |
+
];
|
136 |
}
|
137 |
|
138 |
$results['total_count'] += (int) $query['total_count'];
|
144 |
if ( ! empty( $include ) ) {
|
145 |
$include_query = PUM_Helpers::taxonomy_selectlist_query(
|
146 |
$taxonomy,
|
147 |
+
[
|
148 |
'include' => $include,
|
149 |
'number' => 0,
|
150 |
+
],
|
151 |
true
|
152 |
);
|
153 |
|
154 |
foreach ( $include_query['items'] as $id => $name ) {
|
155 |
+
$results['items'][] = [
|
156 |
'id' => $id,
|
157 |
'text' => "$name (ID: $id)",
|
158 |
+
];
|
159 |
}
|
160 |
|
161 |
$results['total_count'] += (int) $include_query['total_count'];
|
163 |
|
164 |
$query = PUM_Helpers::taxonomy_selectlist_query(
|
165 |
$taxonomy,
|
166 |
+
[
|
167 |
'search' => ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
168 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
169 |
'exclude' => $exclude,
|
170 |
'number' => 10,
|
171 |
+
],
|
172 |
true
|
173 |
);
|
174 |
|
175 |
foreach ( $query['items'] as $id => $name ) {
|
176 |
+
$results['items'][] = [
|
177 |
'id' => $id,
|
178 |
'text' => "$name (ID: $id)",
|
179 |
+
];
|
180 |
}
|
181 |
|
182 |
$results['total_count'] += (int) $query['total_count'];
|
186 |
|
187 |
if ( ! empty( $include ) ) {
|
188 |
$include_query = PUM_Helpers::user_selectlist_query(
|
189 |
+
[
|
190 |
'role' => $user_role,
|
191 |
'include' => $include,
|
192 |
'number' => - 1,
|
193 |
+
],
|
194 |
true
|
195 |
);
|
196 |
|
197 |
foreach ( $include_query['items'] as $id => $name ) {
|
198 |
+
$results['items'][] = [
|
199 |
'id' => $id,
|
200 |
'text' => "$name (ID: $id)",
|
201 |
+
];
|
202 |
}
|
203 |
|
204 |
$results['total_count'] += (int) $include_query['total_count'];
|
205 |
}
|
206 |
|
207 |
$query = PUM_Helpers::user_selectlist_query(
|
208 |
+
[
|
209 |
'role' => $user_role,
|
210 |
'search' => ! empty( $_REQUEST['s'] ) ? '*' . $_REQUEST['s'] . '*' : null,
|
211 |
'paged' => ! empty( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : null,
|
212 |
'exclude' => $exclude,
|
213 |
'number' => 10,
|
214 |
+
],
|
215 |
true
|
216 |
);
|
217 |
|
218 |
foreach ( $query['items'] as $id => $name ) {
|
219 |
+
$results['items'][] = [
|
220 |
'id' => $id,
|
221 |
'text' => "$name (ID: $id)",
|
222 |
+
];
|
223 |
}
|
224 |
|
225 |
$results['total_count'] += (int) $query['total_count'];
|
243 |
|
244 |
if ( ! $batch_id ) {
|
245 |
wp_send_json_error(
|
246 |
+
[
|
247 |
'error' => __( 'A batch process ID must be present to continue.', 'popup-maker' ),
|
248 |
+
]
|
249 |
);
|
250 |
}
|
251 |
|
252 |
// Nonce.
|
253 |
if ( ! isset( $_REQUEST['nonce'] ) || ( isset( $_REQUEST['nonce'] ) && false === wp_verify_nonce( $_REQUEST['nonce'], "{$batch_id}_step_nonce" ) ) ) {
|
254 |
wp_send_json_error(
|
255 |
+
[
|
256 |
'error' => __( 'You do not have permission to initiate this request. Contact an administrator for more information.', 'popup-maker' ),
|
257 |
+
]
|
258 |
);
|
259 |
}
|
260 |
|
263 |
|
264 |
if ( false === $batch ) {
|
265 |
wp_send_json_error(
|
266 |
+
[
|
267 |
'error' => sprintf( __( '%s is an invalid batch process ID.', 'popup-maker' ), esc_html( $_REQUEST['batch_id'] ) ),
|
268 |
+
]
|
269 |
);
|
270 |
}
|
271 |
|
274 |
|
275 |
if ( empty( $class_file ) || ! file_exists( $class_file ) ) {
|
276 |
wp_send_json_error(
|
277 |
+
[
|
278 |
'error' => sprintf( __( 'An invalid file path is registered for the %1$s batch process handler.', 'popup-maker' ), "<code>{$batch_id}</code>" ),
|
279 |
+
]
|
280 |
);
|
281 |
} else {
|
282 |
require_once $class_file;
|
284 |
|
285 |
if ( empty( $class ) || ! class_exists( $class ) ) {
|
286 |
wp_send_json_error(
|
287 |
+
[
|
288 |
'error' => sprintf( __( '%1$s is an invalid handler for the %2$s batch process. Please try again.', 'popup-maker' ), "<code>{$class}</code>", "<code>{$batch_id}</code>" ),
|
289 |
+
]
|
290 |
);
|
291 |
}
|
292 |
|
321 |
// Handle pre-fetching data.
|
322 |
if ( $using_prefetch ) {
|
323 |
// Initialize any data needed to process a step.
|
324 |
+
$data = isset( $_REQUEST['form'] ) ? $_REQUEST['form'] : [];
|
325 |
|
326 |
$process->init( $data );
|
327 |
$process->pre_fetch();
|
333 |
if ( is_wp_error( $step ) ) {
|
334 |
wp_send_json_error( $step );
|
335 |
} else {
|
336 |
+
$response_data = [ 'step' => $step ];
|
337 |
|
338 |
// Map fields if this is an import.
|
339 |
if ( isset( $process->field_mapping ) && ( $process instanceof PUM_Interface_CSV_Importer ) ) {
|
352 |
if ( ! $process->is_empty ) {
|
353 |
$response_data['url'] = pum_admin_url(
|
354 |
'tools',
|
355 |
+
[
|
356 |
'step' => $step,
|
357 |
'nonce' => wp_create_nonce( 'pum-batch-export' ),
|
358 |
'batch_id' => $batch_id,
|
359 |
'pum_action' => 'download_batch_export',
|
360 |
+
]
|
361 |
);
|
362 |
}
|
363 |
}
|
classes/Admin/Assets.php
CHANGED
@@ -39,11 +39,11 @@ class PUM_Admin_Assets {
|
|
39 |
self::$js_url = Popup_Maker::$URL . 'assets/js/';
|
40 |
self::$css_url = Popup_Maker::$URL . 'assets/css/';
|
41 |
|
42 |
-
add_action( 'admin_enqueue_scripts',
|
43 |
-
add_action( 'admin_print_footer_scripts',
|
44 |
-
add_action( 'admin_enqueue_scripts',
|
45 |
|
46 |
-
add_action( 'admin_enqueue_scripts',
|
47 |
}
|
48 |
|
49 |
public static function fix_broken_extension_scripts() {
|
@@ -58,40 +58,46 @@ class PUM_Admin_Assets {
|
|
58 |
*/
|
59 |
public static function register_admin_scripts() {
|
60 |
|
61 |
-
$admin_vars = apply_filters(
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
wp_localize_script( 'pum-admin-general', 'pum_admin_vars', $admin_vars );
|
84 |
|
85 |
-
wp_register_script( 'pum-admin-batch', self::$js_url . 'admin-batch' . self::$suffix . '.js',
|
86 |
wp_register_script( 'pum-admin-marketing', self::$js_url . 'admin-marketing' . self::$suffix . '.js', null, Popup_Maker::$VER, true );
|
87 |
-
wp_register_script( 'pum-admin-popup-editor', self::$js_url . 'admin-popup-editor' . self::$suffix . '.js',
|
88 |
-
wp_register_script( 'pum-admin-theme-editor', self::$js_url . 'admin-theme-editor' . self::$suffix . '.js',
|
89 |
-
wp_register_script( 'pum-admin-settings-page', self::$js_url . 'admin-settings-page' . self::$suffix . '.js',
|
90 |
-
wp_register_script( 'pum-admin-shortcode-ui', self::$js_url . 'admin-shortcode-ui' . self::$suffix . '.js',
|
91 |
-
wp_register_script( 'iframe-resizer', self::$js_url . 'vendor/iframeResizer.min.js',
|
92 |
|
93 |
// @deprecated handle. Currently loads empty file and admin-general as dependency.
|
94 |
-
wp_register_script( 'popup-maker-admin', self::$js_url . 'pum-admin-deprecated' . self::$suffix . '.js',
|
95 |
wp_localize_script( 'pum-admin-general', 'pum_admin', $admin_vars );
|
96 |
|
97 |
wp_enqueue_script( 'pum-admin-marketing' );
|
@@ -132,11 +138,15 @@ class PUM_Admin_Assets {
|
|
132 |
}
|
133 |
|
134 |
if ( wp_script_is( 'pum-admin-batch' ) ) {
|
135 |
-
wp_localize_script(
|
136 |
-
'
|
137 |
-
'
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
}
|
142 |
|
@@ -146,17 +156,17 @@ class PUM_Admin_Assets {
|
|
146 |
public static function register_admin_styles() {
|
147 |
$suffix = ( is_rtl() ? '-rtl' : '' ) . self::$suffix;
|
148 |
|
149 |
-
wp_register_style( 'pum-admin-general', self::$css_url . 'pum-admin-general' . $suffix . '.css',
|
150 |
-
wp_register_style( 'pum-admin-batch', self::$css_url . 'pum-admin-batch' . $suffix . '.css',
|
151 |
-
wp_register_style( 'pum-admin-popup-editor', self::$css_url . 'pum-admin-popup-editor' . $suffix . '.css',
|
152 |
-
wp_register_style( 'pum-admin-theme-editor', self::$css_url . 'pum-admin-theme-editor' . $suffix . '.css',
|
153 |
-
wp_register_style( 'pum-admin-extensions-page', self::$css_url . 'pum-admin-extensions-page' . $suffix . '.css',
|
154 |
-
wp_register_style( 'pum-admin-settings-page', self::$css_url . 'pum-admin-settings-page' . $suffix . '.css',
|
155 |
-
wp_register_style( 'pum-admin-support-page', self::$css_url . 'pum-admin-support-page' . $suffix . '.css',
|
156 |
-
wp_register_style( 'pum-admin-shortcode-ui', self::$css_url . 'pum-admin-shortcode-ui' . $suffix . '.css',
|
157 |
|
158 |
// @deprecated handle. Currently loads empty file and admin-general as dependency.
|
159 |
-
wp_register_style( 'popup-maker-admin', self::$css_url . 'pum-admin-deprecated' . $suffix . '.css',
|
160 |
|
161 |
if ( PUM_Utils_Upgrades::instance()->has_uncomplete_upgrades() ) {
|
162 |
wp_enqueue_style( 'pum-admin-batch' );
|
@@ -189,7 +199,7 @@ class PUM_Admin_Assets {
|
|
189 |
*/
|
190 |
public static function should_load() {
|
191 |
|
192 |
-
if ( defined(
|
193 |
return true;
|
194 |
}
|
195 |
|
39 |
self::$js_url = Popup_Maker::$URL . 'assets/js/';
|
40 |
self::$css_url = Popup_Maker::$URL . 'assets/css/';
|
41 |
|
42 |
+
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'register_admin_scripts' ] );
|
43 |
+
add_action( 'admin_print_footer_scripts', [ __CLASS__, 'maybe_localize_and_templates' ], - 1 );
|
44 |
+
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'register_admin_styles' ], 100 );
|
45 |
|
46 |
+
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'fix_broken_extension_scripts' ], 100 );
|
47 |
}
|
48 |
|
49 |
public static function fix_broken_extension_scripts() {
|
58 |
*/
|
59 |
public static function register_admin_scripts() {
|
60 |
|
61 |
+
$admin_vars = apply_filters(
|
62 |
+
'pum_admin_vars',
|
63 |
+
apply_filters(
|
64 |
+
'pum_admin_var',
|
65 |
+
[
|
66 |
+
'post_id' => ! empty( $_GET['post'] ) ? intval( $_GET['post'] ) : null,
|
67 |
+
'pm_dir_url' => Popup_Maker::$URL,
|
68 |
+
'default_provider' => pum_get_option( 'newsletter_default_provider', 'none' ),
|
69 |
+
'homeurl' => home_url(),
|
70 |
+
'I10n' => [
|
71 |
+
'preview_popup' => __( 'Preview', 'popup-maker' ),
|
72 |
+
'add' => __( 'Add', 'popup-maker' ),
|
73 |
+
'save' => __( 'Save', 'popup-maker' ),
|
74 |
+
'update' => __( 'Update', 'popup-maker' ),
|
75 |
+
'insert' => __( 'Insert', 'popup-maker' ),
|
76 |
+
'cancel' => __( 'Cancel', 'popup-maker' ),
|
77 |
+
'confirm_delete_trigger' => __( 'Are you sure you want to delete this trigger?', 'popup-maker' ),
|
78 |
+
'confirm_delete_cookie' => __( 'Are you sure you want to delete this cookie?', 'popup-maker' ),
|
79 |
+
'no_cookie' => __( 'None', 'popup-maker' ),
|
80 |
+
'confirm_count_reset' => __( 'Are you sure you want to reset the open count?', 'popup-maker' ),
|
81 |
+
'shortcode_ui_button_tooltip' => __( 'Popup Maker Shortcodes', 'popup-maker' ),
|
82 |
+
'error_loading_shortcode_preview' => __( 'There was an error in generating the preview', 'popup-maker' ),
|
83 |
+
],
|
84 |
+
]
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
wp_register_script( 'pum-admin-general', self::$js_url . 'admin-general' . self::$suffix . '.js', [ 'jquery', 'wp-color-picker', 'jquery-ui-slider', 'wp-util' ], Popup_Maker::$VER, true );
|
89 |
wp_localize_script( 'pum-admin-general', 'pum_admin_vars', $admin_vars );
|
90 |
|
91 |
+
wp_register_script( 'pum-admin-batch', self::$js_url . 'admin-batch' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
92 |
wp_register_script( 'pum-admin-marketing', self::$js_url . 'admin-marketing' . self::$suffix . '.js', null, Popup_Maker::$VER, true );
|
93 |
+
wp_register_script( 'pum-admin-popup-editor', self::$js_url . 'admin-popup-editor' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
94 |
+
wp_register_script( 'pum-admin-theme-editor', self::$js_url . 'admin-theme-editor' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
95 |
+
wp_register_script( 'pum-admin-settings-page', self::$js_url . 'admin-settings-page' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
96 |
+
wp_register_script( 'pum-admin-shortcode-ui', self::$js_url . 'admin-shortcode-ui' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
97 |
+
wp_register_script( 'iframe-resizer', self::$js_url . 'vendor/iframeResizer.min.js', [ 'jquery' ] );
|
98 |
|
99 |
// @deprecated handle. Currently loads empty file and admin-general as dependency.
|
100 |
+
wp_register_script( 'popup-maker-admin', self::$js_url . 'pum-admin-deprecated' . self::$suffix . '.js', [ 'pum-admin-general' ], Popup_Maker::$VER, true );
|
101 |
wp_localize_script( 'pum-admin-general', 'pum_admin', $admin_vars );
|
102 |
|
103 |
wp_enqueue_script( 'pum-admin-marketing' );
|
138 |
}
|
139 |
|
140 |
if ( wp_script_is( 'pum-admin-batch' ) ) {
|
141 |
+
wp_localize_script(
|
142 |
+
'pum-admin-batch',
|
143 |
+
'pum_batch_vars',
|
144 |
+
[
|
145 |
+
'complete' => __( 'Your all set, the upgrades completed successfully!', 'popup-maker' ),
|
146 |
+
'unsupported_browser' => __( 'We are sorry but your browser is not compatible with this kind of file upload. Please upgrade your browser.', 'popup-maker' ),
|
147 |
+
'import_field_required' => 'This field must be mapped for the import to proceed.',
|
148 |
+
]
|
149 |
+
);
|
150 |
}
|
151 |
}
|
152 |
|
156 |
public static function register_admin_styles() {
|
157 |
$suffix = ( is_rtl() ? '-rtl' : '' ) . self::$suffix;
|
158 |
|
159 |
+
wp_register_style( 'pum-admin-general', self::$css_url . 'pum-admin-general' . $suffix . '.css', [ 'dashicons', 'wp-color-picker' ], Popup_Maker::$VER );
|
160 |
+
wp_register_style( 'pum-admin-batch', self::$css_url . 'pum-admin-batch' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
161 |
+
wp_register_style( 'pum-admin-popup-editor', self::$css_url . 'pum-admin-popup-editor' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
162 |
+
wp_register_style( 'pum-admin-theme-editor', self::$css_url . 'pum-admin-theme-editor' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
163 |
+
wp_register_style( 'pum-admin-extensions-page', self::$css_url . 'pum-admin-extensions-page' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
164 |
+
wp_register_style( 'pum-admin-settings-page', self::$css_url . 'pum-admin-settings-page' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
165 |
+
wp_register_style( 'pum-admin-support-page', self::$css_url . 'pum-admin-support-page' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
166 |
+
wp_register_style( 'pum-admin-shortcode-ui', self::$css_url . 'pum-admin-shortcode-ui' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
167 |
|
168 |
// @deprecated handle. Currently loads empty file and admin-general as dependency.
|
169 |
+
wp_register_style( 'popup-maker-admin', self::$css_url . 'pum-admin-deprecated' . $suffix . '.css', [ 'pum-admin-general' ], Popup_Maker::$VER );
|
170 |
|
171 |
if ( PUM_Utils_Upgrades::instance()->has_uncomplete_upgrades() ) {
|
172 |
wp_enqueue_style( 'pum-admin-batch' );
|
199 |
*/
|
200 |
public static function should_load() {
|
201 |
|
202 |
+
if ( defined( 'PUM_FORCE_ADMIN_SCRIPTS_LOAD' ) && PUM_FORCE_ADMIN_SCRIPTS_LOAD ) {
|
203 |
return true;
|
204 |
}
|
205 |
|
classes/Admin/BlockEditor.php
CHANGED
@@ -52,13 +52,12 @@ class PUM_Admin_BlockEditor {
|
|
52 |
'version' => Popup_Maker::$VER,
|
53 |
];
|
54 |
$script_url = plugins_url( $script_path, Popup_Maker::$FILE );
|
55 |
-
$script_deps
|
56 |
|
57 |
if ( $screen->id !== 'widgets' ) {
|
58 |
$script_deps = array_merge( $script_deps, [ 'wp-edit-post' ] );
|
59 |
}
|
60 |
|
61 |
-
|
62 |
wp_enqueue_script( 'popup-maker-block-editor', $script_url, $script_deps, $script_asset['version'] );
|
63 |
|
64 |
wp_localize_script(
|
52 |
'version' => Popup_Maker::$VER,
|
53 |
];
|
54 |
$script_url = plugins_url( $script_path, Popup_Maker::$FILE );
|
55 |
+
$script_deps = $script_asset['dependencies'];
|
56 |
|
57 |
if ( $screen->id !== 'widgets' ) {
|
58 |
$script_deps = array_merge( $script_deps, [ 'wp-edit-post' ] );
|
59 |
}
|
60 |
|
|
|
61 |
wp_enqueue_script( 'popup-maker-block-editor', $script_url, $script_deps, $script_asset['version'] );
|
62 |
|
63 |
wp_localize_script(
|
classes/Admin/Extend.php
CHANGED
@@ -30,7 +30,7 @@ class PUM_Admin_Extend {
|
|
30 |
public static function page() {
|
31 |
?>
|
32 |
<div class="wrap">
|
33 |
-
<h1><?php _e( 'Upgrade', 'popup-maker' ) ?></h1>
|
34 |
<?php PUM_Upsell::display_addon_tabs(); ?>
|
35 |
<article class="upgrade-wrapper">
|
36 |
<section class="upgrade-wrapper-hero">
|
@@ -64,33 +64,33 @@ class PUM_Admin_Extend {
|
|
64 |
$extensions = self::available_extensions();
|
65 |
|
66 |
?>
|
67 |
-
|
68 |
<?php
|
69 |
-
//
|
70 |
-
//
|
71 |
-
//
|
72 |
-
//
|
73 |
-
//
|
74 |
-
//
|
75 |
-
//
|
76 |
-
//
|
77 |
-
//
|
78 |
-
//
|
79 |
-
//
|
80 |
-
//
|
81 |
-
//
|
82 |
-
//
|
83 |
//
|
84 |
//
|
85 |
-
//
|
86 |
-
//
|
87 |
-
//
|
88 |
-
//
|
89 |
-
//
|
90 |
-
//
|
91 |
-
//
|
92 |
-
//
|
93 |
-
//
|
94 |
|
95 |
$existing_extension_images = self::extensions_with_local_image();
|
96 |
|
@@ -105,62 +105,76 @@ class PUM_Admin_Extend {
|
|
105 |
|
106 |
$i = 0;
|
107 |
|
108 |
-
foreach ( $extensions as $extension ) :
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
115 |
<?php $image = in_array( $extension['slug'], $existing_extension_images ) ? POPMAKE_URL . '/assets/images/extensions/' . $extension['slug'] . '.png' : $extension['image']; ?>
|
116 |
-
|
117 |
|
118 |
-
|
119 |
|
120 |
-
|
121 |
<a class="button" target="_blank" href="<?php echo esc_url( $extension['homepage'] ); ?>?utm_source=plugin-extension-page&utm_medium=plugin&utm_campaign=upsell&utm_content=<?php echo esc_attr( urlencode( str_replace( ' ', '+', $extension['name'] ) ) ); ?>-<?php echo esc_attr( $i ); ?>"><?php _e( 'Learn more', 'popup-maker' ); ?></a>
|
122 |
</span>
|
123 |
|
124 |
-
|
|
|
125 |
//
|
126 |
-
//
|
127 |
-
//
|
128 |
-
//
|
129 |
-
//
|
130 |
-
//
|
131 |
-
//
|
132 |
-
//
|
133 |
-
//
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
//
|
144 |
-
// printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]["activation_url"] ), __( 'Activate' ) );
|
145 |
//
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
//
|
152 |
-
//
|
153 |
-
|
154 |
-
|
155 |
-
//
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
<?php
|
160 |
$i ++;
|
161 |
endforeach;
|
162 |
-
}
|
163 |
-
|
|
|
164 |
|
165 |
<?php
|
166 |
}
|
@@ -169,27 +183,30 @@ class PUM_Admin_Extend {
|
|
169 |
* @return array
|
170 |
*/
|
171 |
public static function extensions_with_local_image() {
|
172 |
-
return apply_filters(
|
173 |
-
'
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
|
|
|
|
|
|
193 |
}
|
194 |
|
195 |
}
|
30 |
public static function page() {
|
31 |
?>
|
32 |
<div class="wrap">
|
33 |
+
<h1><?php _e( 'Upgrade', 'popup-maker' ); ?></h1>
|
34 |
<?php PUM_Upsell::display_addon_tabs(); ?>
|
35 |
<article class="upgrade-wrapper">
|
36 |
<section class="upgrade-wrapper-hero">
|
64 |
$extensions = self::available_extensions();
|
65 |
|
66 |
?>
|
67 |
+
<ul class="extensions-available">
|
68 |
<?php
|
69 |
+
// $plugins = get_plugins();
|
70 |
+
// $installed_plugins = array();
|
71 |
+
// foreach ( $plugins as $key => $plugin ) {
|
72 |
+
// $is_active = is_plugin_active( $key );
|
73 |
+
// $installed_plugin = array(
|
74 |
+
// 'is_active' => $is_active,
|
75 |
+
// );
|
76 |
+
// $installerUrl = add_query_arg( array(
|
77 |
+
// 'action' => 'activate',
|
78 |
+
// 'plugin' => $key,
|
79 |
+
// 'em' => 1,
|
80 |
+
// ), network_admin_url( 'plugins.php' ) //admin_url('update.php')
|
81 |
+
// );
|
82 |
+
// $installed_plugin["activation_url"] = $is_active ? "" : wp_nonce_url( $installerUrl, 'activate-plugin_' . $key );
|
83 |
//
|
84 |
//
|
85 |
+
// $installerUrl = add_query_arg( array(
|
86 |
+
// 'action' => 'deactivate',
|
87 |
+
// 'plugin' => $key,
|
88 |
+
// 'em' => 1,
|
89 |
+
// ), network_admin_url( 'plugins.php' ) //admin_url('update.php')
|
90 |
+
// );
|
91 |
+
// $installed_plugin["deactivation_url"] = ! $is_active ? "" : wp_nonce_url( $installerUrl, 'deactivate-plugin_' . $key );
|
92 |
+
// $installed_plugins[ $key ] = $installed_plugin;
|
93 |
+
// }
|
94 |
|
95 |
$existing_extension_images = self::extensions_with_local_image();
|
96 |
|
105 |
|
106 |
$i = 0;
|
107 |
|
108 |
+
foreach ( $extensions as $extension ) :
|
109 |
+
?>
|
110 |
+
<li class="available-extension-inner <?php echo esc_attr( $extension['slug'] ); ?>">
|
111 |
+
<h3>
|
112 |
+
<a target="_blank" href="<?php echo esc_url( $extension['homepage'] ); ?>?utm_source=plugin-extension-page&utm_medium=plugin&utm_campaign=upsell&utm_content=<?php echo esc_attr( urlencode( str_replace( ' ', '+', $extension['name'] ) ) ); ?>-<?php echo esc_attr( $i ); ?>">
|
113 |
+
<?php echo esc_html( $extension['name'] ); ?>
|
114 |
+
</a>
|
115 |
+
</h3>
|
116 |
<?php $image = in_array( $extension['slug'], $existing_extension_images ) ? POPMAKE_URL . '/assets/images/extensions/' . $extension['slug'] . '.png' : $extension['image']; ?>
|
117 |
+
<img class="extension-thumbnail" src="<?php echo esc_attr( $image ); ?>" />
|
118 |
|
119 |
+
<p><?php echo esc_html( $extension['excerpt'] ); ?></p>
|
120 |
|
121 |
+
<span class="action-links">
|
122 |
<a class="button" target="_blank" href="<?php echo esc_url( $extension['homepage'] ); ?>?utm_source=plugin-extension-page&utm_medium=plugin&utm_campaign=upsell&utm_content=<?php echo esc_attr( urlencode( str_replace( ' ', '+', $extension['name'] ) ) ); ?>-<?php echo esc_attr( $i ); ?>"><?php _e( 'Learn more', 'popup-maker' ); ?></a>
|
123 |
</span>
|
124 |
|
125 |
+
<!-- -->
|
126 |
+
<?php
|
127 |
//
|
128 |
+
// if ( ! empty( $extension->download_link ) && ! isset( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ] ) ) {
|
129 |
+
// $installerUrl = add_query_arg( array(
|
130 |
+
// 'action' => 'install-plugin',
|
131 |
+
// 'plugin' => $extension->slug,
|
132 |
+
// 'edd_sample_plugin' => 1,
|
133 |
+
// ), network_admin_url( 'update.php' ) //admin_url('update.php')
|
134 |
+
// );
|
135 |
+
// $installerUrl = wp_nonce_url( $installerUrl, 'install-plugin_' . $extension->slug )
|
136 |
+
?>
|
137 |
+
<!-- <span class="action-links">-->
|
138 |
+
<!-- -->
|
139 |
+
<?php
|
140 |
+
// printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installerUrl ), __( 'Install' ) );
|
141 |
+
?>
|
142 |
+
<!-- </span>-->
|
143 |
+
<!-- -->
|
144 |
+
<?php
|
145 |
+
// } elseif ( isset( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]['is_active'] ) ) {
|
|
|
146 |
//
|
147 |
+
?>
|
148 |
+
<!-- <span class="action-links">-->
|
149 |
+
<!-- -->
|
150 |
+
<?php
|
151 |
+
// if ( ! $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]['is_active'] ) {
|
152 |
+
// printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]["activation_url"] ), __( 'Activate' ) );
|
153 |
+
//
|
154 |
+
// } else {
|
155 |
+
// printf( '<a class="button install" href="%s">%s</a>', esc_attr( $installed_plugins[ $extension->slug . '/' . $extension->slug . '.php' ]["deactivation_url"] ), __( 'Deactivate' ) );
|
156 |
+
// }
|
157 |
+
?>
|
158 |
+
<!-- </span>-->
|
159 |
+
<!-- -->
|
160 |
+
<?php
|
161 |
+
// } else {
|
162 |
+
//
|
163 |
+
?>
|
164 |
+
<!-- <span class="action-links"><a class="button" target="_blank" href="--><?php // esc_attr_e( $extension->homepage ); ?><!--">--><?php // _e( 'Get It Now' ); ?><!--</a></span>-->
|
165 |
+
<!-- -->
|
166 |
+
<?php
|
167 |
+
// }
|
168 |
+
//
|
169 |
+
?>
|
170 |
+
|
171 |
+
</li>
|
172 |
<?php
|
173 |
$i ++;
|
174 |
endforeach;
|
175 |
+
}
|
176 |
+
?>
|
177 |
+
</ul>
|
178 |
|
179 |
<?php
|
180 |
}
|
183 |
* @return array
|
184 |
*/
|
185 |
public static function extensions_with_local_image() {
|
186 |
+
return apply_filters(
|
187 |
+
'pum_extensions_with_local_image',
|
188 |
+
[
|
189 |
+
'core-extensions-bundle',
|
190 |
+
'aweber-integration',
|
191 |
+
'mailchimp-integration',
|
192 |
+
'remote-content',
|
193 |
+
'scroll-triggered-popups',
|
194 |
+
'popup-analytics',
|
195 |
+
'forced-interaction',
|
196 |
+
'age-verification-modals',
|
197 |
+
'advanced-theme-builder',
|
198 |
+
'exit-intent-popups',
|
199 |
+
'ajax-login-modals',
|
200 |
+
'advanced-targeting-conditions',
|
201 |
+
'secure-idle-user-logout',
|
202 |
+
'terms-conditions-popups',
|
203 |
+
'videos',
|
204 |
+
'edd-pro',
|
205 |
+
'woocommerce-pro',
|
206 |
+
'geotargeting',
|
207 |
+
'scheduling',
|
208 |
+
]
|
209 |
+
);
|
210 |
}
|
211 |
|
212 |
}
|
classes/Admin/Helpers.php
CHANGED
@@ -18,32 +18,35 @@ class PUM_Admin_Helpers {
|
|
18 |
*
|
19 |
* @return array
|
20 |
*/
|
21 |
-
public static function post_type_dropdown_options( $args =
|
22 |
-
$args = wp_parse_args(
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
if ( $value === null ) {
|
39 |
unset( $args[ $key ] );
|
40 |
}
|
41 |
}
|
42 |
|
43 |
-
$options =
|
44 |
|
45 |
foreach ( get_post_types( $args, 'objects', $compare ) as $post_type ) {
|
46 |
-
if ( in_array( $post_type->name,
|
47 |
// continue;
|
48 |
}
|
49 |
|
@@ -89,7 +92,7 @@ class PUM_Admin_Helpers {
|
|
89 |
* @see PUM_Helper_Array::sort_by_sort
|
90 |
*
|
91 |
* @param array $a
|
92 |
-
* @param array
|
93 |
*
|
94 |
* @return array
|
95 |
*/
|
@@ -102,8 +105,8 @@ class PUM_Admin_Helpers {
|
|
102 |
*
|
103 |
* @return array
|
104 |
*/
|
105 |
-
public static function get_field_defaults( $fields =
|
106 |
-
$defaults =
|
107 |
|
108 |
foreach ( $fields as $field_id => $field ) {
|
109 |
if ( isset( $field['std'] ) ) {
|
@@ -138,7 +141,7 @@ class PUM_Admin_Helpers {
|
|
138 |
* @return array
|
139 |
*/
|
140 |
public static function flatten_fields_array( $tabs ) {
|
141 |
-
$fields =
|
142 |
|
143 |
foreach ( $tabs as $tab_id => $tab_sections ) {
|
144 |
|
@@ -170,66 +173,72 @@ class PUM_Admin_Helpers {
|
|
170 |
* @return array
|
171 |
*/
|
172 |
public static function parse_field( $field ) {
|
173 |
-
return wp_parse_args(
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
'
|
208 |
-
'
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
* @param $fields
|
224 |
-
* @param array
|
225 |
*
|
226 |
* @return mixed
|
227 |
*/
|
228 |
-
public static function parse_tab_fields( $fields, $args =
|
229 |
-
$args = wp_parse_args(
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
233 |
|
234 |
if ( $args['has_subtabs'] ) {
|
235 |
foreach ( $fields as $tab_id => $tab_sections ) {
|
@@ -237,14 +246,13 @@ class PUM_Admin_Helpers {
|
|
237 |
if ( self::is_field( $section_fields ) ) {
|
238 |
// Allow for flat tabs with no sections.
|
239 |
$section_id = 'main';
|
240 |
-
$section_fields =
|
241 |
$section_id => $section_fields,
|
242 |
-
|
243 |
}
|
244 |
|
245 |
$fields[ $tab_id ][ $section_id ] = self::parse_fields( $section_fields, $args['name'] );
|
246 |
}
|
247 |
-
|
248 |
}
|
249 |
} else {
|
250 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
@@ -321,11 +329,11 @@ class PUM_Admin_Helpers {
|
|
321 |
*
|
322 |
* @return bool
|
323 |
*/
|
324 |
-
public static function is_field( $array =
|
325 |
-
$field_tests =
|
326 |
! isset( $array['type'] ) && ( isset( $array['label'] ) || isset( $array['desc'] ) ),
|
327 |
isset( $array['type'] ) && is_string( $array['type'] ),
|
328 |
-
|
329 |
|
330 |
return in_array( true, $field_tests );
|
331 |
}
|
@@ -337,7 +345,7 @@ class PUM_Admin_Helpers {
|
|
337 |
*
|
338 |
* @return bool
|
339 |
*/
|
340 |
-
public static function is_section( $array =
|
341 |
return ! self::is_field( $array );
|
342 |
}
|
343 |
|
@@ -346,20 +354,26 @@ class PUM_Admin_Helpers {
|
|
346 |
*
|
347 |
* @param array $args
|
348 |
*/
|
349 |
-
public static function modal( $args =
|
350 |
-
$args = wp_parse_args(
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
360 |
?>
|
361 |
<div id="<?php echo $args['id']; ?>" class="pum-modal-background <?php echo esc_attr( $args['class'] ); ?>" role="dialog" aria-hidden="true" aria-labelledby="<?php echo $args['id']; ?>-title"
|
362 |
-
<?php
|
|
|
|
|
|
|
363 |
|
364 |
<div class="pum-modal-wrap">
|
365 |
|
18 |
*
|
19 |
* @return array
|
20 |
*/
|
21 |
+
public static function post_type_dropdown_options( $args = [], $compare = 'and' ) {
|
22 |
+
$args = wp_parse_args(
|
23 |
+
$args,
|
24 |
+
[
|
25 |
+
'public' => null,
|
26 |
+
'publicly_queryable' => null,
|
27 |
+
'exclude_from_search' => null,
|
28 |
+
'show_ui' => null,
|
29 |
+
'capability_type' => null,
|
30 |
+
'hierarchical' => null,
|
31 |
+
'menu_position' => null,
|
32 |
+
'menu_icon' => null,
|
33 |
+
'permalink_epmask' => null,
|
34 |
+
'rewrite' => null,
|
35 |
+
'query_var' => null,
|
36 |
+
'_builtin' => null,
|
37 |
+
]
|
38 |
+
);
|
39 |
+
|
40 |
+
foreach ( $args as $key => $value ) {
|
41 |
if ( $value === null ) {
|
42 |
unset( $args[ $key ] );
|
43 |
}
|
44 |
}
|
45 |
|
46 |
+
$options = [];
|
47 |
|
48 |
foreach ( get_post_types( $args, 'objects', $compare ) as $post_type ) {
|
49 |
+
if ( in_array( $post_type->name, [ 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'popup_theme', 'nf_sub' ] ) ) {
|
50 |
// continue;
|
51 |
}
|
52 |
|
92 |
* @see PUM_Helper_Array::sort_by_sort
|
93 |
*
|
94 |
* @param array $a
|
95 |
+
* @param array $b
|
96 |
*
|
97 |
* @return array
|
98 |
*/
|
105 |
*
|
106 |
* @return array
|
107 |
*/
|
108 |
+
public static function get_field_defaults( $fields = [] ) {
|
109 |
+
$defaults = [];
|
110 |
|
111 |
foreach ( $fields as $field_id => $field ) {
|
112 |
if ( isset( $field['std'] ) ) {
|
141 |
* @return array
|
142 |
*/
|
143 |
public static function flatten_fields_array( $tabs ) {
|
144 |
+
$fields = [];
|
145 |
|
146 |
foreach ( $tabs as $tab_id => $tab_sections ) {
|
147 |
|
173 |
* @return array
|
174 |
*/
|
175 |
public static function parse_field( $field ) {
|
176 |
+
return wp_parse_args(
|
177 |
+
$field,
|
178 |
+
[
|
179 |
+
'section' => 'main',
|
180 |
+
'type' => 'text',
|
181 |
+
'id' => null,
|
182 |
+
'label' => '',
|
183 |
+
'desc' => '',
|
184 |
+
'name' => null,
|
185 |
+
'templ_name' => null,
|
186 |
+
'size' => 'regular',
|
187 |
+
'options' => [],
|
188 |
+
'std' => null,
|
189 |
+
'rows' => 5,
|
190 |
+
'cols' => 50,
|
191 |
+
'min' => 0,
|
192 |
+
'max' => 50,
|
193 |
+
'force_minmax' => false,
|
194 |
+
'step' => 1,
|
195 |
+
'select2' => null,
|
196 |
+
'object_type' => 'post_type',
|
197 |
+
'object_key' => 'post',
|
198 |
+
'post_type' => null,
|
199 |
+
'taxonomy' => null,
|
200 |
+
'multiple' => null,
|
201 |
+
'as_array' => false,
|
202 |
+
'placeholder' => null,
|
203 |
+
'checkbox_val' => 1,
|
204 |
+
'allow_blank' => true,
|
205 |
+
'readonly' => false,
|
206 |
+
'required' => false,
|
207 |
+
'disabled' => false,
|
208 |
+
'hook' => null,
|
209 |
+
'unit' => __( 'ms', 'popup-maker' ),
|
210 |
+
'desc_position' => 'bottom',
|
211 |
+
'units' => [
|
212 |
+
'px' => 'px',
|
213 |
+
'%' => '%',
|
214 |
+
'em' => 'em',
|
215 |
+
'rem' => 'rem',
|
216 |
+
],
|
217 |
+
'priority' => 10,
|
218 |
+
'doclink' => '',
|
219 |
+
'button_type' => 'submit',
|
220 |
+
'class' => '',
|
221 |
+
'messages' => [],
|
222 |
+
'license_status' => '',
|
223 |
+
'private' => false,
|
224 |
+
]
|
225 |
+
);
|
226 |
}
|
227 |
|
228 |
/**
|
229 |
* @param $fields
|
230 |
+
* @param array $args
|
231 |
*
|
232 |
* @return mixed
|
233 |
*/
|
234 |
+
public static function parse_tab_fields( $fields, $args = [] ) {
|
235 |
+
$args = wp_parse_args(
|
236 |
+
$args,
|
237 |
+
[
|
238 |
+
'has_subtabs' => false,
|
239 |
+
'name' => '%s',
|
240 |
+
]
|
241 |
+
);
|
242 |
|
243 |
if ( $args['has_subtabs'] ) {
|
244 |
foreach ( $fields as $tab_id => $tab_sections ) {
|
246 |
if ( self::is_field( $section_fields ) ) {
|
247 |
// Allow for flat tabs with no sections.
|
248 |
$section_id = 'main';
|
249 |
+
$section_fields = [
|
250 |
$section_id => $section_fields,
|
251 |
+
];
|
252 |
}
|
253 |
|
254 |
$fields[ $tab_id ][ $section_id ] = self::parse_fields( $section_fields, $args['name'] );
|
255 |
}
|
|
|
256 |
}
|
257 |
} else {
|
258 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
329 |
*
|
330 |
* @return bool
|
331 |
*/
|
332 |
+
public static function is_field( $array = [] ) {
|
333 |
+
$field_tests = [
|
334 |
! isset( $array['type'] ) && ( isset( $array['label'] ) || isset( $array['desc'] ) ),
|
335 |
isset( $array['type'] ) && is_string( $array['type'] ),
|
336 |
+
];
|
337 |
|
338 |
return in_array( true, $field_tests );
|
339 |
}
|
345 |
*
|
346 |
* @return bool
|
347 |
*/
|
348 |
+
public static function is_section( $array = [] ) {
|
349 |
return ! self::is_field( $array );
|
350 |
}
|
351 |
|
354 |
*
|
355 |
* @param array $args
|
356 |
*/
|
357 |
+
public static function modal( $args = [] ) {
|
358 |
+
$args = wp_parse_args(
|
359 |
+
$args,
|
360 |
+
[
|
361 |
+
'id' => 'default',
|
362 |
+
'title' => '',
|
363 |
+
'description' => '',
|
364 |
+
'class' => '',
|
365 |
+
'cancel_button' => true,
|
366 |
+
'cancel_button_text' => __( 'Cancel', 'popup-maker' ),
|
367 |
+
'save_button' => true,
|
368 |
+
'save_button_text' => __( 'Add', 'popup-maker' ),
|
369 |
+
]
|
370 |
+
);
|
371 |
?>
|
372 |
<div id="<?php echo $args['id']; ?>" class="pum-modal-background <?php echo esc_attr( $args['class'] ); ?>" role="dialog" aria-hidden="true" aria-labelledby="<?php echo $args['id']; ?>-title"
|
373 |
+
<?php
|
374 |
+
if ( '' != $args['description'] ) {
|
375 |
+
?>
|
376 |
+
aria-describedby="<?php echo $args['id']; ?>-description"<?php } ?>>
|
377 |
|
378 |
<div class="pum-modal-wrap">
|
379 |
|
classes/Admin/Onboarding.php
CHANGED
@@ -16,16 +16,16 @@ class PUM_Admin_Onboarding {
|
|
16 |
*/
|
17 |
public static function init() {
|
18 |
if ( is_admin() && current_user_can( 'manage_options' ) ) {
|
19 |
-
add_filter( 'pum_alert_list',
|
20 |
-
add_action( 'pum_alert_dismissed',
|
21 |
}
|
22 |
-
add_filter( 'pum_admin_pointers-popup',
|
23 |
-
add_filter( 'pum_admin_pointers-edit-popup',
|
24 |
-
add_action( 'admin_enqueue_scripts',
|
25 |
|
26 |
-
add_action( 'admin_init',
|
27 |
if ( ! empty( $_GET['page'] ) && 'pum-welcome' === $_GET['page'] ) {
|
28 |
-
add_action( 'admin_menu',
|
29 |
}
|
30 |
}
|
31 |
|
@@ -43,35 +43,35 @@ class PUM_Admin_Onboarding {
|
|
43 |
|
44 |
$tip = self::get_random_tip();
|
45 |
|
46 |
-
$alerts[] =
|
47 |
'code' => 'pum_tip_alert',
|
48 |
'type' => 'info',
|
49 |
'message' => $tip['msg'],
|
50 |
'priority' => 10,
|
51 |
'dismissible' => '1 month',
|
52 |
'global' => false,
|
53 |
-
'actions' =>
|
54 |
-
|
55 |
'primary' => true,
|
56 |
'type' => 'link',
|
57 |
'action' => '',
|
58 |
'href' => $tip['link'],
|
59 |
'text' => __( 'Learn more', 'popup-maker' ),
|
60 |
-
|
61 |
-
|
62 |
'primary' => false,
|
63 |
'type' => 'action',
|
64 |
'action' => 'dismiss',
|
65 |
'text' => __( 'Dismiss', 'popup-maker' ),
|
66 |
-
|
67 |
-
|
68 |
'primary' => false,
|
69 |
'type' => 'action',
|
70 |
'action' => 'disable_tips',
|
71 |
'text' => __( 'Turn off these occasional tips', 'popup-maker' ),
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
return $alerts;
|
77 |
}
|
@@ -105,7 +105,7 @@ class PUM_Admin_Onboarding {
|
|
105 |
|
106 |
// Get dismissed pointers.
|
107 |
$dismissed = self::get_dismissed_pointers();
|
108 |
-
$valid_pointers =
|
109 |
|
110 |
// Cycles through pointers and only add valid ones.
|
111 |
foreach ( $pointers as $pointer_id => $pointer ) {
|
@@ -123,8 +123,9 @@ class PUM_Admin_Onboarding {
|
|
123 |
}
|
124 |
|
125 |
// Skip if pointer has already been dismissed.
|
126 |
-
if ( in_array( $pointer_id, $dismissed ) )
|
127 |
continue;
|
|
|
128 |
|
129 |
// Add the pointer to $valid_pointers array.
|
130 |
$valid_pointers['pointers'][] = $pointer;
|
@@ -139,7 +140,7 @@ class PUM_Admin_Onboarding {
|
|
139 |
wp_enqueue_style( 'wp-pointer' );
|
140 |
|
141 |
// Add pointers script to queue. Add custom script.
|
142 |
-
wp_enqueue_script( 'pum-pointer', Popup_Maker::$URL . 'assets/js/admin-pointer.js',
|
143 |
|
144 |
// Add pointer options to script.
|
145 |
wp_localize_script( 'pum-pointer', 'pumPointers', $valid_pointers );
|
@@ -157,10 +158,10 @@ class PUM_Admin_Onboarding {
|
|
157 |
$screen = get_current_screen();
|
158 |
}
|
159 |
$screen_id = $screen->id;
|
160 |
-
$pointers = apply_filters( 'pum_admin_pointers-' . $screen_id,
|
161 |
|
162 |
if ( ! $pointers || ! is_array( $pointers ) ) {
|
163 |
-
return
|
164 |
}
|
165 |
|
166 |
return $pointers;
|
@@ -183,72 +184,96 @@ class PUM_Admin_Onboarding {
|
|
183 |
* @see https://jqueryui.com/position/
|
184 |
*/
|
185 |
|
186 |
-
$pointers['popup-editor-1'] =
|
187 |
'target' => '#title',
|
188 |
-
'options' =>
|
189 |
-
'content' => sprintf(
|
190 |
-
|
191 |
-
__( 'Name
|
|
|
192 |
),
|
193 |
-
'position' =>
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
197 |
'target' => '#wp-content-editor-container',
|
198 |
-
'options' =>
|
199 |
-
'content' => sprintf(
|
200 |
-
|
201 |
-
__( '
|
|
|
202 |
),
|
203 |
-
'position' =>
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
|
|
207 |
'target' => 'a[href="#pum-popup-settings_triggers"]',
|
208 |
-
'options' =>
|
209 |
-
'content' => sprintf(
|
210 |
-
|
211 |
-
__( '
|
|
|
212 |
),
|
213 |
-
'position' =>
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
217 |
'target' => 'a[href="#pum-popup-settings_targeting"]',
|
218 |
-
'options' =>
|
219 |
-
'content' => sprintf(
|
220 |
-
|
221 |
-
__( '
|
|
|
222 |
),
|
223 |
-
'position' =>
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
227 |
'target' => 'a[href="#pum-popup-settings_display"]',
|
228 |
-
'options' =>
|
229 |
-
'content' => sprintf(
|
230 |
-
|
231 |
-
__( '
|
|
|
232 |
),
|
233 |
-
'position' =>
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
237 |
'target' => 'select#theme_id',
|
238 |
-
'options' =>
|
239 |
-
'content' => sprintf(
|
240 |
-
|
241 |
-
__( '
|
|
|
242 |
),
|
243 |
-
'position' =>
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
247 |
'a[href="#pum-popup-settings_display"]',
|
248 |
'a[href="#pum-popup-settings-display-subtabs_main"]',
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
return $pointers;
|
253 |
}
|
254 |
|
@@ -260,59 +285,59 @@ class PUM_Admin_Onboarding {
|
|
260 |
* @since 1.11.0
|
261 |
*/
|
262 |
public static function all_popups_main_tour( $pointers ) {
|
263 |
-
$pointers['all-popups-1'] =
|
264 |
'target' => 'nav.nav-tab-wrapper a:nth-child(4)',
|
265 |
-
'options' =>
|
266 |
'content' => sprintf(
|
267 |
'<h3> %s </h3> <p> %s </p>',
|
268 |
__( 'Welcome to Popup Maker!', 'popup-maker' ),
|
269 |
__( 'Click the "Create New Popup" button to create your first popup.', 'popup-maker' )
|
270 |
),
|
271 |
-
'position' =>
|
272 |
-
|
273 |
-
|
274 |
-
$pointers['all-popups-2'] =
|
275 |
'target' => '.wp-list-table #the-list tr:first-child .column-enabled',
|
276 |
-
'options' =>
|
277 |
'content' => sprintf(
|
278 |
'<h3> %s </h3> <p> %s </p>',
|
279 |
__( 'Enable Popups', 'popup-maker' ),
|
280 |
__( 'You can enable or disable your popups at any time using this toggle.', 'popup-maker' )
|
281 |
),
|
282 |
-
'position' =>
|
283 |
'edge' => 'top',
|
284 |
'align' => 'left',
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$pointers['all-popups-3'] =
|
289 |
'target' => '.wp-list-table #the-list tr:first-child .column-conversions',
|
290 |
-
'options' =>
|
291 |
'content' => sprintf(
|
292 |
'<h3> %s </h3> <p> %s </p>',
|
293 |
__( 'Review Popup Metrics', 'popup-maker' ),
|
294 |
__( 'Popup Maker will automatically track opens and conversions so you can easily see which popups convert the best.', 'popup-maker' )
|
295 |
),
|
296 |
-
'position' =>
|
297 |
'edge' => 'top',
|
298 |
'align' => 'left',
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
$pointers['all-popups-4'] =
|
303 |
'target' => '#screen-options-link-wrap #show-settings-link',
|
304 |
-
'options' =>
|
305 |
'content' => sprintf(
|
306 |
'<h3> %s </h3> <p> %s </p>',
|
307 |
__( 'Adjust Columns', 'popup-maker' ),
|
308 |
__( 'You can show or hide columns from the table on this page using the Screen Options. Popup Heading and Published Date are hidden by default.', 'popup-maker' )
|
309 |
),
|
310 |
-
'position' =>
|
311 |
'edge' => 'top',
|
312 |
'align' => 'center',
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
|
317 |
return $pointers;
|
318 |
}
|
@@ -324,30 +349,30 @@ class PUM_Admin_Onboarding {
|
|
324 |
* @since 1.13.0
|
325 |
*/
|
326 |
public static function get_random_tip() {
|
327 |
-
$tips =
|
328 |
-
|
329 |
'msg' => 'Did you know: Popup Maker has a setting to let you try to bypass adblockers? Enabling it randomizes cache filenames and other endpoints to try to get around adblockers.',
|
330 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=pum-settings_misc' ),
|
331 |
-
|
332 |
-
|
333 |
'msg' => "Want to use the block editor to create your popups? Enable it over on Popup Maker's settings page.",
|
334 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings' ),
|
335 |
-
|
336 |
-
|
337 |
'msg' => 'Using the Popup Maker menu in your admin bar, you can open and close popups, check conditions, reseet cookies, and more!',
|
338 |
'link' => 'https://docs.wppopupmaker.com/article/300-the-popup-maker-admin-toolbar',
|
339 |
-
|
340 |
-
|
341 |
'msg' => "Did you know: You can easily customize your site's navigation to have a link open a popup by using the 'Trigger a Popup' option when editing your menus?",
|
342 |
'link' => 'https://docs.wppopupmaker.com/article/51-open-a-popup-from-a-wordpress-nav-menu',
|
343 |
-
|
344 |
-
|
345 |
|
346 |
if ( 7 < pum_count_popups() ) {
|
347 |
-
$tips[] =
|
348 |
'msg' => 'Want to organize your popups? Enable categories on the settings page to group similar popups together!',
|
349 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=pum-settings_misc' ),
|
350 |
-
|
351 |
}
|
352 |
|
353 |
$random_tip = array_rand( $tips );
|
@@ -363,7 +388,7 @@ class PUM_Admin_Onboarding {
|
|
363 |
// Redirect idea from Better Click To Tweet's welcome screen. Thanks Ben!
|
364 |
if ( get_transient( 'pum_activation_redirect' ) ) {
|
365 |
$do_redirect = true;
|
366 |
-
$current_page = isset( $_GET['page'] ) ? wp_unslash( $_GET['page'] ) : false;
|
367 |
// Bailout redirect during these events.
|
368 |
if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_options' ) ) {
|
369 |
$do_redirect = false;
|
@@ -388,7 +413,7 @@ class PUM_Admin_Onboarding {
|
|
388 |
* @since 1.14.0
|
389 |
*/
|
390 |
public static function set_up_welcome_page() {
|
391 |
-
add_dashboard_page( '', '', 'manage_options', 'pum-welcome',
|
392 |
}
|
393 |
|
394 |
/**
|
@@ -398,7 +423,7 @@ class PUM_Admin_Onboarding {
|
|
398 |
*/
|
399 |
public static function display_welcome_page() {
|
400 |
wp_enqueue_style( 'pum-admin-general' );
|
401 |
-
$gravatar_url = get_avatar_url( 'danieliser@wizardinternetsolutions.com',
|
402 |
?>
|
403 |
<div class="pum-welcome-wrapper">
|
404 |
<div>
|
@@ -443,11 +468,11 @@ class PUM_Admin_Onboarding {
|
|
443 |
$user_id = get_current_user_id();
|
444 |
}
|
445 |
if ( 0 === intval( $user_id ) ) {
|
446 |
-
return
|
447 |
}
|
448 |
$pointers = explode( ',', (string) get_user_meta( $user_id, 'dismissed_wp_pointers', true ) );
|
449 |
if ( ! is_array( $pointers ) ) {
|
450 |
-
return
|
451 |
}
|
452 |
return $pointers;
|
453 |
}
|
16 |
*/
|
17 |
public static function init() {
|
18 |
if ( is_admin() && current_user_can( 'manage_options' ) ) {
|
19 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'tips_alert' ] );
|
20 |
+
add_action( 'pum_alert_dismissed', [ __CLASS__, 'alert_handler' ], 10, 2 );
|
21 |
}
|
22 |
+
add_filter( 'pum_admin_pointers-popup', [ __CLASS__, 'popup_editor_main_tour' ] );
|
23 |
+
add_filter( 'pum_admin_pointers-edit-popup', [ __CLASS__, 'all_popups_main_tour' ] );
|
24 |
+
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'set_up_pointers' ] );
|
25 |
|
26 |
+
add_action( 'admin_init', [ __CLASS__, 'welcome_redirect' ] );
|
27 |
if ( ! empty( $_GET['page'] ) && 'pum-welcome' === $_GET['page'] ) {
|
28 |
+
add_action( 'admin_menu', [ __CLASS__, 'set_up_welcome_page' ] );
|
29 |
}
|
30 |
}
|
31 |
|
43 |
|
44 |
$tip = self::get_random_tip();
|
45 |
|
46 |
+
$alerts[] = [
|
47 |
'code' => 'pum_tip_alert',
|
48 |
'type' => 'info',
|
49 |
'message' => $tip['msg'],
|
50 |
'priority' => 10,
|
51 |
'dismissible' => '1 month',
|
52 |
'global' => false,
|
53 |
+
'actions' => [
|
54 |
+
[
|
55 |
'primary' => true,
|
56 |
'type' => 'link',
|
57 |
'action' => '',
|
58 |
'href' => $tip['link'],
|
59 |
'text' => __( 'Learn more', 'popup-maker' ),
|
60 |
+
],
|
61 |
+
[
|
62 |
'primary' => false,
|
63 |
'type' => 'action',
|
64 |
'action' => 'dismiss',
|
65 |
'text' => __( 'Dismiss', 'popup-maker' ),
|
66 |
+
],
|
67 |
+
[
|
68 |
'primary' => false,
|
69 |
'type' => 'action',
|
70 |
'action' => 'disable_tips',
|
71 |
'text' => __( 'Turn off these occasional tips', 'popup-maker' ),
|
72 |
+
],
|
73 |
+
],
|
74 |
+
];
|
75 |
|
76 |
return $alerts;
|
77 |
}
|
105 |
|
106 |
// Get dismissed pointers.
|
107 |
$dismissed = self::get_dismissed_pointers();
|
108 |
+
$valid_pointers = [];
|
109 |
|
110 |
// Cycles through pointers and only add valid ones.
|
111 |
foreach ( $pointers as $pointer_id => $pointer ) {
|
123 |
}
|
124 |
|
125 |
// Skip if pointer has already been dismissed.
|
126 |
+
if ( in_array( $pointer_id, $dismissed ) ) {
|
127 |
continue;
|
128 |
+
}
|
129 |
|
130 |
// Add the pointer to $valid_pointers array.
|
131 |
$valid_pointers['pointers'][] = $pointer;
|
140 |
wp_enqueue_style( 'wp-pointer' );
|
141 |
|
142 |
// Add pointers script to queue. Add custom script.
|
143 |
+
wp_enqueue_script( 'pum-pointer', Popup_Maker::$URL . 'assets/js/admin-pointer.js', [ 'wp-pointer' ], Popup_Maker::$VER, true );
|
144 |
|
145 |
// Add pointer options to script.
|
146 |
wp_localize_script( 'pum-pointer', 'pumPointers', $valid_pointers );
|
158 |
$screen = get_current_screen();
|
159 |
}
|
160 |
$screen_id = $screen->id;
|
161 |
+
$pointers = apply_filters( 'pum_admin_pointers-' . $screen_id, [] );
|
162 |
|
163 |
if ( ! $pointers || ! is_array( $pointers ) ) {
|
164 |
+
return [];
|
165 |
}
|
166 |
|
167 |
return $pointers;
|
184 |
* @see https://jqueryui.com/position/
|
185 |
*/
|
186 |
|
187 |
+
$pointers['popup-editor-1'] = [
|
188 |
'target' => '#title',
|
189 |
+
'options' => [
|
190 |
+
'content' => sprintf(
|
191 |
+
'<h3> %s </h3> <p> %s </p>',
|
192 |
+
__( 'Popup Name', 'popup-maker' ),
|
193 |
+
__( 'Name your popup so you can find it later. Site visitors will not see this.', 'popup-maker' )
|
194 |
),
|
195 |
+
'position' => [
|
196 |
+
'edge' => 'top',
|
197 |
+
'align' => 'center',
|
198 |
+
],
|
199 |
+
],
|
200 |
+
];
|
201 |
+
$pointers['popup-editor-2'] = [
|
202 |
'target' => '#wp-content-editor-container',
|
203 |
+
'options' => [
|
204 |
+
'content' => sprintf(
|
205 |
+
'<h3> %s </h3> <p> %s </p>',
|
206 |
+
__( 'Popup Content', 'popup-maker' ),
|
207 |
+
__( 'Add content for your popup here.', 'popup-maker' )
|
208 |
),
|
209 |
+
'position' => [
|
210 |
+
'edge' => 'bottom',
|
211 |
+
'align' => 'center',
|
212 |
+
],
|
213 |
+
],
|
214 |
+
];
|
215 |
+
$pointers['popup-editor-3'] = [
|
216 |
'target' => 'a[href="#pum-popup-settings_triggers"]',
|
217 |
+
'options' => [
|
218 |
+
'content' => sprintf(
|
219 |
+
'<h3> %s </h3> <p> %s </p>',
|
220 |
+
__( 'Popup Triggers', 'popup-maker' ),
|
221 |
+
__( 'Use triggers to choose what causes the popup to open.', 'popup-maker' )
|
222 |
),
|
223 |
+
'position' => [
|
224 |
+
'edge' => 'left',
|
225 |
+
'align' => 'center',
|
226 |
+
],
|
227 |
+
],
|
228 |
+
];
|
229 |
+
$pointers['popup-editor-4'] = [
|
230 |
'target' => 'a[href="#pum-popup-settings_targeting"]',
|
231 |
+
'options' => [
|
232 |
+
'content' => sprintf(
|
233 |
+
'<h3> %s </h3> <p> %s </p>',
|
234 |
+
__( 'Popup Targeting', 'popup-maker' ),
|
235 |
+
__( 'Use targeting to choose where on your site the popup should load and who to show the popup to.', 'popup-maker' )
|
236 |
),
|
237 |
+
'position' => [
|
238 |
+
'edge' => 'left',
|
239 |
+
'align' => 'center',
|
240 |
+
],
|
241 |
+
],
|
242 |
+
];
|
243 |
+
$pointers['popup-editor-5'] = [
|
244 |
'target' => 'a[href="#pum-popup-settings_display"]',
|
245 |
+
'options' => [
|
246 |
+
'content' => sprintf(
|
247 |
+
'<h3> %s </h3> <p> %s </p>',
|
248 |
+
__( 'Popup Display', 'popup-maker' ),
|
249 |
+
__( 'Use display settings to choose where on the screen the popup appears and what it looks like.', 'popup-maker' )
|
250 |
),
|
251 |
+
'position' => [
|
252 |
+
'edge' => 'left',
|
253 |
+
'align' => 'center',
|
254 |
+
],
|
255 |
+
],
|
256 |
+
];
|
257 |
+
$pointers['popup-editor-6'] = [
|
258 |
'target' => 'select#theme_id',
|
259 |
+
'options' => [
|
260 |
+
'content' => sprintf(
|
261 |
+
'<h3> %s </h3> <p> %s </p>',
|
262 |
+
__( 'Popup Theme', 'popup-maker' ),
|
263 |
+
__( 'Choose the popup theme which controls the visual appearance of your popup including; colors, spacing, and fonts.', 'popup-maker' )
|
264 |
),
|
265 |
+
'position' => [
|
266 |
+
'edge' => 'bottom',
|
267 |
+
'align' => 'left',
|
268 |
+
],
|
269 |
+
],
|
270 |
+
'pre' => [
|
271 |
+
'clicks' => [
|
272 |
'a[href="#pum-popup-settings_display"]',
|
273 |
'a[href="#pum-popup-settings-display-subtabs_main"]',
|
274 |
+
],
|
275 |
+
],
|
276 |
+
];
|
277 |
return $pointers;
|
278 |
}
|
279 |
|
285 |
* @since 1.11.0
|
286 |
*/
|
287 |
public static function all_popups_main_tour( $pointers ) {
|
288 |
+
$pointers['all-popups-1'] = [
|
289 |
'target' => 'nav.nav-tab-wrapper a:nth-child(4)',
|
290 |
+
'options' => [
|
291 |
'content' => sprintf(
|
292 |
'<h3> %s </h3> <p> %s </p>',
|
293 |
__( 'Welcome to Popup Maker!', 'popup-maker' ),
|
294 |
__( 'Click the "Create New Popup" button to create your first popup.', 'popup-maker' )
|
295 |
),
|
296 |
+
'position' => [ 'edge' => 'top' ],
|
297 |
+
],
|
298 |
+
];
|
299 |
+
$pointers['all-popups-2'] = [
|
300 |
'target' => '.wp-list-table #the-list tr:first-child .column-enabled',
|
301 |
+
'options' => [
|
302 |
'content' => sprintf(
|
303 |
'<h3> %s </h3> <p> %s </p>',
|
304 |
__( 'Enable Popups', 'popup-maker' ),
|
305 |
__( 'You can enable or disable your popups at any time using this toggle.', 'popup-maker' )
|
306 |
),
|
307 |
+
'position' => [
|
308 |
'edge' => 'top',
|
309 |
'align' => 'left',
|
310 |
+
],
|
311 |
+
],
|
312 |
+
];
|
313 |
+
$pointers['all-popups-3'] = [
|
314 |
'target' => '.wp-list-table #the-list tr:first-child .column-conversions',
|
315 |
+
'options' => [
|
316 |
'content' => sprintf(
|
317 |
'<h3> %s </h3> <p> %s </p>',
|
318 |
__( 'Review Popup Metrics', 'popup-maker' ),
|
319 |
__( 'Popup Maker will automatically track opens and conversions so you can easily see which popups convert the best.', 'popup-maker' )
|
320 |
),
|
321 |
+
'position' => [
|
322 |
'edge' => 'top',
|
323 |
'align' => 'left',
|
324 |
+
],
|
325 |
+
],
|
326 |
+
];
|
327 |
+
$pointers['all-popups-4'] = [
|
328 |
'target' => '#screen-options-link-wrap #show-settings-link',
|
329 |
+
'options' => [
|
330 |
'content' => sprintf(
|
331 |
'<h3> %s </h3> <p> %s </p>',
|
332 |
__( 'Adjust Columns', 'popup-maker' ),
|
333 |
__( 'You can show or hide columns from the table on this page using the Screen Options. Popup Heading and Published Date are hidden by default.', 'popup-maker' )
|
334 |
),
|
335 |
+
'position' => [
|
336 |
'edge' => 'top',
|
337 |
'align' => 'center',
|
338 |
+
],
|
339 |
+
],
|
340 |
+
];
|
341 |
|
342 |
return $pointers;
|
343 |
}
|
349 |
* @since 1.13.0
|
350 |
*/
|
351 |
public static function get_random_tip() {
|
352 |
+
$tips = [
|
353 |
+
[
|
354 |
'msg' => 'Did you know: Popup Maker has a setting to let you try to bypass adblockers? Enabling it randomizes cache filenames and other endpoints to try to get around adblockers.',
|
355 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=pum-settings_misc' ),
|
356 |
+
],
|
357 |
+
[
|
358 |
'msg' => "Want to use the block editor to create your popups? Enable it over on Popup Maker's settings page.",
|
359 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings' ),
|
360 |
+
],
|
361 |
+
[
|
362 |
'msg' => 'Using the Popup Maker menu in your admin bar, you can open and close popups, check conditions, reseet cookies, and more!',
|
363 |
'link' => 'https://docs.wppopupmaker.com/article/300-the-popup-maker-admin-toolbar',
|
364 |
+
],
|
365 |
+
[
|
366 |
'msg' => "Did you know: You can easily customize your site's navigation to have a link open a popup by using the 'Trigger a Popup' option when editing your menus?",
|
367 |
'link' => 'https://docs.wppopupmaker.com/article/51-open-a-popup-from-a-wordpress-nav-menu',
|
368 |
+
],
|
369 |
+
];
|
370 |
|
371 |
if ( 7 < pum_count_popups() ) {
|
372 |
+
$tips[] = [
|
373 |
'msg' => 'Want to organize your popups? Enable categories on the settings page to group similar popups together!',
|
374 |
'link' => admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=pum-settings_misc' ),
|
375 |
+
];
|
376 |
}
|
377 |
|
378 |
$random_tip = array_rand( $tips );
|
388 |
// Redirect idea from Better Click To Tweet's welcome screen. Thanks Ben!
|
389 |
if ( get_transient( 'pum_activation_redirect' ) ) {
|
390 |
$do_redirect = true;
|
391 |
+
$current_page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : false;
|
392 |
// Bailout redirect during these events.
|
393 |
if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_options' ) ) {
|
394 |
$do_redirect = false;
|
413 |
* @since 1.14.0
|
414 |
*/
|
415 |
public static function set_up_welcome_page() {
|
416 |
+
add_dashboard_page( '', '', 'manage_options', 'pum-welcome', [ __CLASS__, 'display_welcome_page' ] );
|
417 |
}
|
418 |
|
419 |
/**
|
423 |
*/
|
424 |
public static function display_welcome_page() {
|
425 |
wp_enqueue_style( 'pum-admin-general' );
|
426 |
+
$gravatar_url = get_avatar_url( 'danieliser@wizardinternetsolutions.com', [ 'size' => 60 ] );
|
427 |
?>
|
428 |
<div class="pum-welcome-wrapper">
|
429 |
<div>
|
468 |
$user_id = get_current_user_id();
|
469 |
}
|
470 |
if ( 0 === intval( $user_id ) ) {
|
471 |
+
return [];
|
472 |
}
|
473 |
$pointers = explode( ',', (string) get_user_meta( $user_id, 'dismissed_wp_pointers', true ) );
|
474 |
if ( ! is_array( $pointers ) ) {
|
475 |
+
return [];
|
476 |
}
|
477 |
return $pointers;
|
478 |
}
|
classes/Admin/Pages.php
CHANGED
@@ -19,14 +19,14 @@ class PUM_Admin_Pages {
|
|
19 |
/**
|
20 |
* @var array
|
21 |
*/
|
22 |
-
public static $pages =
|
23 |
|
24 |
/**
|
25 |
*
|
26 |
*/
|
27 |
public static function init() {
|
28 |
-
add_action( 'admin_menu',
|
29 |
-
add_action( 'admin_head',
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -46,43 +46,49 @@ class PUM_Admin_Pages {
|
|
46 |
*/
|
47 |
public static function register_pages() {
|
48 |
|
49 |
-
$admin_pages = apply_filters(
|
50 |
-
'
|
51 |
-
|
52 |
-
'
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
|
77 |
foreach ( $admin_pages as $key => $page ) {
|
78 |
-
$page = wp_parse_args(
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
86 |
|
87 |
// Backward compatibility.
|
88 |
$page['capability'] = apply_filters( 'popmake_admin_submenu_' . $key . '_capability', $page['capability'] );
|
@@ -99,7 +105,7 @@ class PUM_Admin_Pages {
|
|
99 |
|
100 |
self::$pages[ $key ] = add_submenu_page( $page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], $page['callback'] );
|
101 |
// For backward compatibility.
|
102 |
-
$GLOBALS[
|
103 |
}
|
104 |
|
105 |
// Add shortcut to theme editor from Appearance menu.
|
@@ -108,7 +114,7 @@ class PUM_Admin_Pages {
|
|
108 |
|
109 |
|
110 |
/**
|
111 |
-
* Submenu filter function. Tested with
|
112 |
* Sort and order submenu positions to match our custom order.
|
113 |
*
|
114 |
* @since 1.4
|
@@ -118,7 +124,7 @@ class PUM_Admin_Pages {
|
|
118 |
|
119 |
if ( isset( $submenu['edit.php?post_type=popup'] ) ) {
|
120 |
// Sort the menu according to your preferences
|
121 |
-
usort( $submenu['edit.php?post_type=popup'],
|
122 |
}
|
123 |
}
|
124 |
|
@@ -137,22 +143,28 @@ class PUM_Admin_Pages {
|
|
137 |
* @return int
|
138 |
*/
|
139 |
public static function reorder_submenu_array( $a, $b ) {
|
140 |
-
$first_pages = apply_filters(
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
$a_val = strip_tags( $a[0], false );
|
158 |
$b_val = strip_tags( $b[0], false );
|
19 |
/**
|
20 |
* @var array
|
21 |
*/
|
22 |
+
public static $pages = [];
|
23 |
|
24 |
/**
|
25 |
*
|
26 |
*/
|
27 |
public static function init() {
|
28 |
+
add_action( 'admin_menu', [ __CLASS__, 'register_pages' ] );
|
29 |
+
add_action( 'admin_head', [ __CLASS__, 'reorder_admin_submenu' ] );
|
30 |
}
|
31 |
|
32 |
/**
|
46 |
*/
|
47 |
public static function register_pages() {
|
48 |
|
49 |
+
$admin_pages = apply_filters(
|
50 |
+
'pum_admin_pages',
|
51 |
+
[
|
52 |
+
'subscribers' => [
|
53 |
+
'page_title' => __( 'Subscribers', 'popup-maker' ),
|
54 |
+
'capability' => 'manage_options',
|
55 |
+
'callback' => [ 'PUM_Admin_Subscribers', 'page' ],
|
56 |
+
],
|
57 |
+
'settings' => [
|
58 |
+
'page_title' => __( 'Settings', 'popup-maker' ),
|
59 |
+
'capability' => 'manage_options',
|
60 |
+
'callback' => [ 'PUM_Admin_Settings', 'page' ],
|
61 |
+
],
|
62 |
+
'extensions' => [
|
63 |
+
'page_title' => __( 'Upgrade', 'popup-maker' ),
|
64 |
+
'capability' => 'edit_posts',
|
65 |
+
'callback' => [ 'PUM_Admin_Extend', 'page' ],
|
66 |
+
],
|
67 |
+
'support' => [
|
68 |
+
'page_title' => __( 'Help & Support', 'popup-maker' ),
|
69 |
+
'capability' => 'edit_posts',
|
70 |
+
'callback' => [ 'PUM_Admin_Support', 'page' ],
|
71 |
+
],
|
72 |
+
'tools' => [
|
73 |
+
'page_title' => __( 'Tools', 'popup-maker' ),
|
74 |
+
'capability' => 'manage_options',
|
75 |
+
'callback' => [ 'PUM_Admin_Tools', 'page' ],
|
76 |
+
],
|
77 |
+
]
|
78 |
+
);
|
79 |
|
80 |
foreach ( $admin_pages as $key => $page ) {
|
81 |
+
$page = wp_parse_args(
|
82 |
+
$page,
|
83 |
+
[
|
84 |
+
'parent_slug' => 'edit.php?post_type=popup',
|
85 |
+
'page_title' => '',
|
86 |
+
'menu_title' => '',
|
87 |
+
'capability' => 'manage_options',
|
88 |
+
'menu_slug' => '',
|
89 |
+
'callback' => '',
|
90 |
+
]
|
91 |
+
);
|
92 |
|
93 |
// Backward compatibility.
|
94 |
$page['capability'] = apply_filters( 'popmake_admin_submenu_' . $key . '_capability', $page['capability'] );
|
105 |
|
106 |
self::$pages[ $key ] = add_submenu_page( $page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], $page['callback'] );
|
107 |
// For backward compatibility.
|
108 |
+
$GLOBALS[ 'popmake_' . $key . '_page' ] = self::$pages[ $key ];
|
109 |
}
|
110 |
|
111 |
// Add shortcut to theme editor from Appearance menu.
|
114 |
|
115 |
|
116 |
/**
|
117 |
+
* Submenu filter function. Tested with WordPress 4.1.1
|
118 |
* Sort and order submenu positions to match our custom order.
|
119 |
*
|
120 |
* @since 1.4
|
124 |
|
125 |
if ( isset( $submenu['edit.php?post_type=popup'] ) ) {
|
126 |
// Sort the menu according to your preferences
|
127 |
+
usort( $submenu['edit.php?post_type=popup'], [ __CLASS__, 'reorder_submenu_array' ] );
|
128 |
}
|
129 |
}
|
130 |
|
143 |
* @return int
|
144 |
*/
|
145 |
public static function reorder_submenu_array( $a, $b ) {
|
146 |
+
$first_pages = apply_filters(
|
147 |
+
'pum_admin_submenu_first_pages',
|
148 |
+
[
|
149 |
+
__( 'All Popups', 'popup-maker' ),
|
150 |
+
__( 'Add New', 'popup-maker' ),
|
151 |
+
__( 'All Themes', 'popup-maker' ),
|
152 |
+
__( 'Categories', 'popup-maker' ),
|
153 |
+
__( 'Tags', 'popup-maker' ),
|
154 |
+
]
|
155 |
+
);
|
156 |
+
$last_pages = apply_filters(
|
157 |
+
'pum_admin_submenu_last_pages',
|
158 |
+
[
|
159 |
+
__( 'Extend', 'popup-maker' ),
|
160 |
+
__( 'Settings', 'popup-maker' ),
|
161 |
+
__( 'Tools', 'popup-maker' ),
|
162 |
+
__( 'Support Forum', 'popup-maker' ),
|
163 |
+
__( 'Account', 'popup-maker' ),
|
164 |
+
__( 'Contact Us', 'popup-maker' ),
|
165 |
+
__( 'Help & Support', 'popup-maker' ),
|
166 |
+
]
|
167 |
+
);
|
168 |
|
169 |
$a_val = strip_tags( $a[0], false );
|
170 |
$b_val = strip_tags( $b[0], false );
|
classes/Admin/Popups.php
CHANGED
@@ -20,37 +20,36 @@ class PUM_Admin_Popups {
|
|
20 |
public static function init() {
|
21 |
|
22 |
// Adds ID to top of popup editor.
|
23 |
-
add_action( 'edit_form_top',
|
24 |
|
25 |
// Change title to popup name.
|
26 |
-
add_filter( 'enter_title_here',
|
27 |
|
28 |
// Add popup title field.
|
29 |
-
add_action( 'edit_form_advanced',
|
30 |
|
31 |
// Add Contextual help to post_name field.
|
32 |
-
add_action( 'edit_form_before_permalink',
|
33 |
|
34 |
// Register Metaboxes.
|
35 |
-
add_action( 'add_meta_boxes',
|
36 |
|
37 |
// Process meta saving.
|
38 |
-
add_action( 'save_post',
|
39 |
-
|
40 |
|
41 |
// Set the slug properly on save.
|
42 |
-
add_filter( 'wp_insert_post_data',
|
43 |
|
44 |
// Dashboard columns & filters.
|
45 |
-
add_filter( 'manage_edit-popup_columns',
|
46 |
-
add_action( 'manage_posts_custom_column',
|
47 |
-
add_filter( 'manage_edit-popup_sortable_columns',
|
48 |
-
add_filter( 'default_hidden_columns',
|
49 |
-
add_action( 'load-edit.php',
|
50 |
-
add_action( 'restrict_manage_posts',
|
51 |
-
add_filter( 'post_row_actions',
|
52 |
-
|
53 |
-
add_action( 'post_submitbox_misc_actions',
|
54 |
}
|
55 |
|
56 |
/**
|
@@ -132,7 +131,8 @@ class PUM_Admin_Popups {
|
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
-
if ( 'popup' == $typenow && in_array( $pagenow,
|
|
|
136 |
|
137 |
<div id="popup-titlediv" class="pum-form">
|
138 |
<div id="popup-titlewrap">
|
@@ -163,7 +163,8 @@ class PUM_Admin_Popups {
|
|
163 |
return;
|
164 |
}
|
165 |
|
166 |
-
if ( 'popup' == $typenow && in_array( $pagenow,
|
|
|
167 |
<p class="pum-desc"><?php echo '(' . esc_html__( 'Required', 'popup-maker' ) . ') ' . esc_html__( 'Enter a name to help you remember what this popup is about. Only you will see this.', 'popup-maker' ); ?></p>
|
168 |
<?php
|
169 |
}
|
@@ -173,8 +174,8 @@ class PUM_Admin_Popups {
|
|
173 |
* Registers popup metaboxes.
|
174 |
*/
|
175 |
public static function meta_box() {
|
176 |
-
add_meta_box( 'pum_popup_settings', __( 'Popup Settings', 'popup-maker' ),
|
177 |
-
add_meta_box( 'pum_popup_analytics', __( 'Analytics', 'popup-maker' ),
|
178 |
}
|
179 |
|
180 |
/**
|
@@ -183,7 +184,7 @@ class PUM_Admin_Popups {
|
|
183 |
* @param array $values Array of settings.
|
184 |
* @return array
|
185 |
*/
|
186 |
-
public static function parse_values( $values =
|
187 |
$defaults = self::defaults();
|
188 |
|
189 |
if ( empty( $values ) ) {
|
@@ -210,24 +211,34 @@ class PUM_Admin_Popups {
|
|
210 |
wp_enqueue_script( 'popup-maker-admin' );
|
211 |
?>
|
212 |
<script type="text/javascript">
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
'
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
</script>
|
227 |
|
228 |
<div id="pum-popup-settings-container" class="pum-popup-settings-container">
|
229 |
<div class="pum-no-js" style="padding: 0 12px;">
|
230 |
-
<p><?php printf( esc_html__( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %sView troubleshooting guide%s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
231 |
</div>
|
232 |
</div>
|
233 |
<?php
|
@@ -241,9 +252,9 @@ class PUM_Admin_Popups {
|
|
241 |
* @return mixed
|
242 |
*/
|
243 |
public static function deprecated_meta_fields() {
|
244 |
-
$fields =
|
245 |
foreach ( self::deprecated_meta_field_groups() as $group ) {
|
246 |
-
foreach ( apply_filters( 'popmake_popup_meta_field_group_' . $group,
|
247 |
$fields[] = 'popup_' . $group . '_' . $field;
|
248 |
}
|
249 |
}
|
@@ -259,7 +270,7 @@ class PUM_Admin_Popups {
|
|
259 |
* @return mixed
|
260 |
*/
|
261 |
public static function deprecated_meta_field_groups() {
|
262 |
-
return apply_filters( 'popmake_popup_meta_field_groups',
|
263 |
}
|
264 |
|
265 |
/**
|
@@ -297,16 +308,15 @@ class PUM_Admin_Popups {
|
|
297 |
$popup->reset_counts();
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
$title = ! empty ( $_POST['popup_title'] ) ? trim( sanitize_text_field( $_POST['popup_title'] ) ) : '';
|
302 |
$popup->update_meta( 'popup_title', $title );
|
303 |
|
304 |
-
$settings = ! empty( $_POST['popup_settings'] ) ? $_POST['popup_settings'] :
|
305 |
|
306 |
// Sanitize JSON values.
|
307 |
-
$settings['conditions'] = isset( $settings['conditions'] ) ? self::sanitize_meta( $settings['conditions'] ) :
|
308 |
-
$settings['triggers'] = isset( $settings['triggers'] ) ? self::sanitize_meta( $settings['triggers'] ) :
|
309 |
-
$settings['cookies'] = isset( $settings['cookies'] ) ? self::sanitize_meta( $settings['cookies'] ) :
|
310 |
|
311 |
$settings = apply_filters( 'pum_popup_setting_pre_save', $settings, $post->ID );
|
312 |
|
@@ -341,7 +351,6 @@ class PUM_Admin_Popups {
|
|
341 |
foreach ( $settings as $key => $value ) {
|
342 |
$field = self::get_field( $key );
|
343 |
|
344 |
-
|
345 |
if ( $field ) {
|
346 |
switch ( $field['type'] ) {
|
347 |
case 'measure':
|
@@ -359,14 +368,17 @@ class PUM_Admin_Popups {
|
|
359 |
* @return array
|
360 |
*/
|
361 |
public static function tabs() {
|
362 |
-
return apply_filters(
|
363 |
-
'
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
|
|
|
|
|
|
370 |
}
|
371 |
|
372 |
/**
|
@@ -375,34 +387,37 @@ class PUM_Admin_Popups {
|
|
375 |
* @return array
|
376 |
*/
|
377 |
public static function sections() {
|
378 |
-
return apply_filters(
|
379 |
-
'
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
'
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
'
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
|
|
|
|
|
|
406 |
}
|
407 |
|
408 |
/**
|
@@ -415,448 +430,468 @@ class PUM_Admin_Popups {
|
|
415 |
static $tabs;
|
416 |
|
417 |
if ( ! isset( $tabs ) ) {
|
418 |
-
$tabs = apply_filters(
|
419 |
-
'
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
'std' => array(),
|
427 |
-
'priority' => 10,
|
428 |
-
),
|
429 |
-
'separator1' => array(
|
430 |
-
'type' => 'separator',
|
431 |
-
'private' => true,
|
432 |
-
),
|
433 |
-
'cookies' => array(
|
434 |
-
'type' => 'cookies',
|
435 |
-
'std' => array(),
|
436 |
-
'priority' => 20,
|
437 |
-
),
|
438 |
-
),
|
439 |
-
) ),
|
440 |
-
'targeting' => apply_filters( 'pum_popup_targeting_settings_fields', array(
|
441 |
-
'main' => array(
|
442 |
-
'conditions' => array(
|
443 |
-
'type' => 'conditions',
|
444 |
-
'std' => array(),
|
445 |
-
'priority' => 10,
|
446 |
-
'private' => true,
|
447 |
-
),
|
448 |
-
'disable_on_mobile' => array(
|
449 |
-
'label' => __( 'Disable this popup on mobile devices.', 'popup-maker' ),
|
450 |
-
'type' => 'checkbox',
|
451 |
-
'priority' => 20,
|
452 |
-
),
|
453 |
-
'disable_on_tablet' => array(
|
454 |
-
'label' => __( 'Disable this popup on tablet devices.', 'popup-maker' ),
|
455 |
-
'type' => 'checkbox',
|
456 |
-
'priority' => 20,
|
457 |
-
),
|
458 |
-
),
|
459 |
-
) ),
|
460 |
-
'display' => apply_filters( 'pum_popup_display_settings_fields', array(
|
461 |
-
'preset' => array(
|
462 |
-
'explain' => array(
|
463 |
-
'type' => 'html',
|
464 |
-
'content' => '<p>Select one of the types below to get started! Once selected, you can adjust the display settings using the tabs above.</p>'
|
465 |
-
),
|
466 |
-
'type_section' => array(
|
467 |
-
'type' => 'section',
|
468 |
-
'classes' => 'popup-types',
|
469 |
-
'fields' => array(
|
470 |
-
'<div class="popup-type" data-popup-type="center-popup"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/center-popup.png" alt="' . __( 'Center Popup', 'popup-maker' ) . '"/><button class="button">' . __( 'Center Popup', 'popup-maker' ) . '</button></div>',
|
471 |
-
'<div class="popup-type" data-popup-type="right-bottom-slidein"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/right-bottom-slidein.png" alt="' . __( 'Right Bottom Slide-in', 'popup-maker' ) . '"/><button class="button">' . __( 'Right Bottom Slide-in', 'popup-maker' ) . '</button></div>',
|
472 |
-
'<div class="popup-type" data-popup-type="top-bar"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/top-bar.png" alt="' . __( 'Top Bar', 'popup-maker' ) . '"/><button class="button">' . __( 'Top Bar', 'popup-maker' ) . '</button></div>',
|
473 |
-
'<div class="popup-type" data-popup-type="left-bottom-notice"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/left-bottom-notice.png" alt="' . __( 'Left Bottom Notice', 'popup-maker' ) . '"/><button class="button">' . __( 'Left Bottom Notice', 'popup-maker' ) . '</button></div>',
|
474 |
-
),
|
475 |
-
),
|
476 |
-
),
|
477 |
-
'main' => array(
|
478 |
-
'theme_id' => array(
|
479 |
-
'label' => __( 'Popup Theme', 'popup-maker' ),
|
480 |
-
'dynamic_desc' => sprintf( '%1$s<br/><a id="edit_theme_link" href="%3$s">%2$s</a>', __( 'Choose a theme for this popup.', 'popup-maker' ), __( 'Customize This Theme', 'popup-maker' ), admin_url( "post.php?action=edit&post={{data.value}}" ) ),
|
481 |
-
'type' => 'select',
|
482 |
-
'options' => pum_is_popup_editor() ? PUM_Helpers::popup_theme_selectlist() : null,
|
483 |
-
'std' => pum_get_default_theme_id(),
|
484 |
-
),
|
485 |
-
),
|
486 |
-
'size' => array(
|
487 |
-
'size' => array(
|
488 |
-
'label' => __( 'Size', 'popup-maker' ),
|
489 |
-
'desc' => __( 'Select the size of the popup.', 'popup-maker' ),
|
490 |
-
'type' => 'select',
|
491 |
-
'std' => 'medium',
|
492 |
-
'priority' => 10,
|
493 |
-
'options' => array(
|
494 |
-
__( 'Responsive Sizes', 'popup-maker' ) => array(
|
495 |
-
'nano' => __( 'Nano - 10%', 'popup-maker' ),
|
496 |
-
'micro' => __( 'Micro - 20%', 'popup-maker' ),
|
497 |
-
'tiny' => __( 'Tiny - 30%', 'popup-maker' ),
|
498 |
-
'small' => __( 'Small - 40%', 'popup-maker' ),
|
499 |
-
'medium' => __( 'Medium - 60%', 'popup-maker' ),
|
500 |
-
'normal' => __( 'Normal - 70%', 'popup-maker' ),
|
501 |
-
'large' => __( 'Large - 80%', 'popup-maker' ),
|
502 |
-
'xlarge' => __( 'X Large - 95%', 'popup-maker' ),
|
503 |
-
),
|
504 |
-
__( 'Other Sizes', 'popup-maker' ) => array(
|
505 |
-
'auto' => __( 'Auto', 'popup-maker' ),
|
506 |
-
'custom' => __( 'Custom', 'popup-maker' ),
|
507 |
-
),
|
508 |
-
),
|
509 |
-
),
|
510 |
-
'responsive_min_width' => array(
|
511 |
-
'label' => __( 'Min Width', 'popup-maker' ),
|
512 |
-
'desc' => __( 'Set a minimum width for the popup.', 'popup-maker' ),
|
513 |
-
'type' => 'measure',
|
514 |
-
'std' => '0%',
|
515 |
-
'priority' => 20,
|
516 |
-
'dependencies' => array(
|
517 |
-
'size' => array( 'nano', 'micro', 'tiny', 'small', 'medium', 'normal', 'large', 'xlarge' ),
|
518 |
-
),
|
519 |
-
),
|
520 |
-
'responsive_max_width' => array(
|
521 |
-
'label' => __( 'Max Width', 'popup-maker' ),
|
522 |
-
'desc' => __( 'Set a maximum width for the popup.', 'popup-maker' ),
|
523 |
-
'type' => 'measure',
|
524 |
-
'std' => '100%',
|
525 |
-
'priority' => 30,
|
526 |
-
'dependencies' => array(
|
527 |
-
'size' => array( 'nano', 'micro', 'tiny', 'small', 'medium', 'normal', 'large', 'xlarge' ),
|
528 |
-
),
|
529 |
-
),
|
530 |
-
'custom_width' => array(
|
531 |
-
'label' => __( 'Width', 'popup-maker' ),
|
532 |
-
'desc' => __( 'Set a custom width for the popup.', 'popup-maker' ),
|
533 |
-
'type' => 'measure',
|
534 |
-
'std' => '640px',
|
535 |
-
'priority' => 40,
|
536 |
-
'dependencies' => array(
|
537 |
-
'size' => 'custom',
|
538 |
-
),
|
539 |
-
),
|
540 |
-
'custom_height_auto' => array(
|
541 |
-
'label' => __( 'Auto Adjusted Height', 'popup-maker' ),
|
542 |
-
'desc' => __( 'Checking this option will set height to fit the content.', 'popup-maker' ),
|
543 |
-
'type' => 'checkbox',
|
544 |
-
'priority' => 50,
|
545 |
-
'dependencies' => array(
|
546 |
-
'size' => 'custom',
|
547 |
-
),
|
548 |
-
),
|
549 |
-
'custom_height' => array(
|
550 |
-
'label' => __( 'Height', 'popup-maker' ),
|
551 |
-
'desc' => __( 'Set a custom height for the popup.', 'popup-maker' ),
|
552 |
-
'type' => 'measure',
|
553 |
-
'std' => '380px',
|
554 |
-
'priority' => 60,
|
555 |
-
'dependencies' => array(
|
556 |
-
'size' => 'custom',
|
557 |
-
'custom_height_auto' => false,
|
558 |
-
),
|
559 |
-
),
|
560 |
-
'scrollable_content' => array(
|
561 |
-
'label' => __( 'Scrollable Content', 'popup-maker' ),
|
562 |
-
'desc' => __( 'Checking this option will add a scroll bar to your content.', 'popup-maker' ),
|
563 |
-
'type' => 'checkbox',
|
564 |
-
'std' => false,
|
565 |
-
'priority' => 70,
|
566 |
-
'dependencies' => array(
|
567 |
-
'size' => 'custom',
|
568 |
-
'custom_height_auto' => false,
|
569 |
-
),
|
570 |
-
),
|
571 |
-
),
|
572 |
-
'animation' => array(
|
573 |
-
'animation_type' => array(
|
574 |
-
'label' => __( 'Animation Type', 'popup-maker' ),
|
575 |
-
'desc' => __( 'Select an animation type for your popup.', 'popup-maker' ),
|
576 |
-
'type' => 'select',
|
577 |
-
'std' => 'fade',
|
578 |
-
'priority' => 10,
|
579 |
-
'options' => array(
|
580 |
-
'none' => __( 'None', 'popup-maker' ),
|
581 |
-
'slide' => __( 'Slide', 'popup-maker' ),
|
582 |
-
'fade' => __( 'Fade', 'popup-maker' ),
|
583 |
-
'fadeAndSlide' => __( 'Fade and Slide', 'popup-maker' ),
|
584 |
-
// 'grow' => __( 'Grow', 'popup-maker' ),
|
585 |
-
// 'growAndSlide' => __( 'Grow and Slide', 'popup-maker' ),
|
586 |
-
),
|
587 |
-
),
|
588 |
-
'animation_speed' => array(
|
589 |
-
'label' => __( 'Animation Speed', 'popup-maker' ),
|
590 |
-
'desc' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
|
591 |
-
'type' => 'rangeslider',
|
592 |
-
'std' => 350,
|
593 |
-
'step' => 10,
|
594 |
-
'min' => 50,
|
595 |
-
'max' => 1000,
|
596 |
-
'unit' => __( 'ms', 'popup-maker' ),
|
597 |
-
'priority' => 20,
|
598 |
-
'dependencies' => array(
|
599 |
-
'animation_type' => array( 'slide', 'fade', 'fadeAndSlide', 'grow', 'growAndSlide' ),
|
600 |
-
),
|
601 |
-
),
|
602 |
-
'animation_origin' => array(
|
603 |
-
'label' => __( 'Animation Origin', 'popup-maker' ),
|
604 |
-
'desc' => __( 'Choose where the animation will begin.', 'popup-maker' ),
|
605 |
-
'type' => 'select',
|
606 |
-
'std' => 'center top',
|
607 |
-
'options' => array(
|
608 |
-
'top' => __( 'Top', 'popup-maker' ),
|
609 |
-
'left' => __( 'Left', 'popup-maker' ),
|
610 |
-
'bottom' => __( 'Bottom', 'popup-maker' ),
|
611 |
-
'right' => __( 'Right', 'popup-maker' ),
|
612 |
-
'left top' => __( 'Top Left', 'popup-maker' ),
|
613 |
-
'center top' => __( 'Top Center', 'popup-maker' ),
|
614 |
-
'right top' => __( 'Top Right', 'popup-maker' ),
|
615 |
-
'left center' => __( 'Middle Left', 'popup-maker' ),
|
616 |
-
'center center' => __( 'Middle Center', 'popup-maker' ),
|
617 |
-
'right center' => __( 'Middle Right', 'popup-maker' ),
|
618 |
-
'left bottom' => __( 'Bottom Left', 'popup-maker' ),
|
619 |
-
'center bottom' => __( 'Bottom Center', 'popup-maker' ),
|
620 |
-
'right bottom' => __( 'Bottom Right', 'popup-maker' ),
|
621 |
-
),
|
622 |
-
'priority' => 30,
|
623 |
-
'dependencies' => array(
|
624 |
-
'animation_type' => array( 'slide', 'fadeAndSlide', 'grow', 'growAndSlide' ),
|
625 |
-
),
|
626 |
-
),
|
627 |
-
),
|
628 |
-
'sound' => array(
|
629 |
-
'open_sound' => array(
|
630 |
-
'label' => __( 'Opening Sound', 'popup-maker' ),
|
631 |
-
'desc' => __( 'Select a sound to play when the popup opens.', 'popup-maker' ),
|
632 |
-
'type' => 'select',
|
633 |
-
'std' => 'none',
|
634 |
-
'priority' => 10,
|
635 |
-
'options' => array(
|
636 |
-
'none' => __( 'None', 'popup-maker' ),
|
637 |
-
'beep.mp3' => __( 'Beep', 'popup-maker' ),
|
638 |
-
'beep-two.mp3' => __( 'Beep 2', 'popup-maker' ),
|
639 |
-
'beep-up.mp3' => __( 'Beep Up', 'popup-maker' ),
|
640 |
-
'chimes.mp3' => __( 'Chimes', 'popup-maker' ),
|
641 |
-
'correct.mp3' => __( 'Correct', 'popup-maker' ),
|
642 |
-
'custom' => __( 'Custom Sound', 'popup-maker' ),
|
643 |
-
),
|
644 |
-
),
|
645 |
-
'custom_sound' => array(
|
646 |
-
'label' => __( 'Custom Sound URL', 'popup-maker' ),
|
647 |
-
'desc' => __( 'Enter URL to sound file.', 'popup-maker' ),
|
648 |
-
'type' => 'text',
|
649 |
-
'std' => '',
|
650 |
-
'priority' => 10,
|
651 |
-
'dependencies' => array(
|
652 |
-
'open_sound' => array( 'custom' ),
|
653 |
-
),
|
654 |
-
),
|
655 |
),
|
656 |
-
'
|
657 |
-
'
|
658 |
-
|
659 |
-
'
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
'
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
'
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
'label' => __( 'Top', 'popup-maker' ),
|
677 |
-
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
|
678 |
-
'type' => 'rangeslider',
|
679 |
-
'std' => 100,
|
680 |
-
'step' => 1,
|
681 |
-
'min' => 0,
|
682 |
-
'max' => 500,
|
683 |
-
'unit' => 'px',
|
684 |
-
'priority' => 20,
|
685 |
-
'dependencies' => array(
|
686 |
-
'location' => array( 'left top', 'center top', 'right top' ),
|
687 |
-
),
|
688 |
-
),
|
689 |
-
'position_bottom' => array(
|
690 |
-
'label' => __( 'Bottom', 'popup-maker' ),
|
691 |
-
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
|
692 |
-
'type' => 'rangeslider',
|
693 |
-
'std' => 0,
|
694 |
-
'step' => 1,
|
695 |
-
'min' => 0,
|
696 |
-
'max' => 500,
|
697 |
-
'unit' => 'px',
|
698 |
-
'priority' => 20,
|
699 |
-
'dependencies' => array(
|
700 |
-
'location' => array( 'left bottom', 'center bottom', 'right bottom' ),
|
701 |
-
),
|
702 |
-
),
|
703 |
-
'position_left' => array(
|
704 |
-
'label' => __( 'Left', 'popup-maker' ),
|
705 |
-
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
|
706 |
-
'type' => 'rangeslider',
|
707 |
-
'std' => 0,
|
708 |
-
'step' => 1,
|
709 |
-
'min' => 0,
|
710 |
-
'max' => 500,
|
711 |
-
'unit' => 'px',
|
712 |
-
'priority' => 30,
|
713 |
-
'dependencies' => array(
|
714 |
-
'location' => array( 'left top', 'left center', 'left bottom' ),
|
715 |
-
),
|
716 |
-
),
|
717 |
-
'position_right' => array(
|
718 |
-
'label' => __( 'Right', 'popup-maker' ),
|
719 |
-
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
|
720 |
-
'type' => 'rangeslider',
|
721 |
-
'std' => 0,
|
722 |
-
'step' => 1,
|
723 |
-
'min' => 0,
|
724 |
-
'max' => 500,
|
725 |
-
'unit' => 'px',
|
726 |
-
'priority' => 30,
|
727 |
-
'dependencies' => array(
|
728 |
-
'location' => array( 'right top', 'right center', 'right bottom' ),
|
729 |
-
),
|
730 |
-
),
|
731 |
-
'position_from_trigger' => array(
|
732 |
-
'label' => __( 'Position from Trigger', 'popup-maker' ),
|
733 |
-
'desc' => sprintf( __( 'This will position the popup in relation to the %sClick Trigger%s.', 'popup-maker' ), '<a target="_blank" href="https://docs.wppopupmaker.com/article/395-trigger-click-open-overview-methods?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=position-from-trigger">', '</a>' ),
|
734 |
-
'type' => 'checkbox',
|
735 |
-
'std' => false,
|
736 |
-
'priority' => 40,
|
737 |
-
),
|
738 |
-
'position_fixed' => array(
|
739 |
-
'label' => __( 'Fixed Postioning', 'popup-maker' ),
|
740 |
-
'desc' => __( 'Checking this sets the positioning of the popup to fixed.', 'popup-maker' ),
|
741 |
-
'type' => 'checkbox',
|
742 |
-
'priority' => 50,
|
743 |
-
),
|
744 |
),
|
745 |
-
'
|
746 |
-
'
|
747 |
-
|
748 |
-
'
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
'type' => 'number',
|
768 |
-
'min' => 999,
|
769 |
-
'max' => 2147483647,
|
770 |
-
'std' => 1999999999,
|
771 |
-
'priority' => 40,
|
772 |
-
),
|
773 |
),
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
'
|
794 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
795 |
),
|
796 |
-
'
|
797 |
-
'
|
798 |
-
|
799 |
-
'
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
|
|
|
|
|
|
|
|
|
|
813 |
],
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
835 |
),
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
|
|
|
|
|
|
850 |
),
|
851 |
-
|
852 |
-
)
|
853 |
-
|
854 |
|
855 |
$tabs = PUM_Admin_Helpers::parse_tab_fields(
|
856 |
$tabs,
|
857 |
[
|
858 |
'has_subtabs' => true,
|
859 |
-
'name'
|
860 |
]
|
861 |
);
|
862 |
}
|
@@ -870,11 +905,11 @@ class PUM_Admin_Popups {
|
|
870 |
foreach ( $tabs as $tab => $sections ) {
|
871 |
|
872 |
if ( PUM_Admin_Helpers::is_field( $sections ) ) {
|
873 |
-
$sections =
|
874 |
-
'main' =>
|
875 |
$tab => $sections,
|
876 |
-
|
877 |
-
|
878 |
}
|
879 |
|
880 |
foreach ( $sections as $section => $fields ) {
|
@@ -899,7 +934,7 @@ class PUM_Admin_Popups {
|
|
899 |
*
|
900 |
* @return array
|
901 |
*/
|
902 |
-
public static function sanitize_settings( $settings =
|
903 |
|
904 |
$fields = self::fields();
|
905 |
$fields = PUM_Admin_Helpers::flatten_fields_array( $fields );
|
@@ -907,7 +942,6 @@ class PUM_Admin_Popups {
|
|
907 |
foreach ( $fields as $field_id => $field ) {
|
908 |
switch ( $field['type'] ) {
|
909 |
case 'checkbox':
|
910 |
-
|
911 |
if ( ! isset( $settings[ $field_id ] ) ) {
|
912 |
$settings[ $field_id ] = false;
|
913 |
}
|
@@ -930,7 +964,6 @@ class PUM_Admin_Popups {
|
|
930 |
$settings[ $key ] = is_string( $value ) ? trim( $value ) : $value;
|
931 |
break;
|
932 |
|
933 |
-
|
934 |
case 'measure':
|
935 |
$settings[ $key ] .= $settings[ $key . '_unit' ];
|
936 |
break;
|
@@ -939,8 +972,6 @@ class PUM_Admin_Popups {
|
|
939 |
// Some custom field types include multiple additional fields that do not need to be saved, strip out any non-whitelisted fields.
|
940 |
unset( $settings[ $key ] );
|
941 |
}
|
942 |
-
|
943 |
-
|
944 |
}
|
945 |
|
946 |
return $settings;
|
@@ -952,7 +983,7 @@ class PUM_Admin_Popups {
|
|
952 |
public static function defaults() {
|
953 |
$tabs = self::fields();
|
954 |
|
955 |
-
$defaults =
|
956 |
|
957 |
foreach ( $tabs as $tab_id => $sections ) {
|
958 |
foreach ( $sections as $section_id => $fields ) {
|
@@ -1032,7 +1063,10 @@ class PUM_Admin_Popups {
|
|
1032 |
<label> <input type="checkbox" name="popup_reset_counts" id="popup_reset_counts" value="1" />
|
1033 |
<?php esc_html_e( 'Reset Counts', 'popup-maker' ); ?>
|
1034 |
</label>
|
1035 |
-
<?php
|
|
|
|
|
|
|
1036 |
<small>
|
1037 |
<strong><?php esc_html_e( 'Last Reset', 'popup-maker' ); ?>:</strong> <?php echo esc_html( date( 'm-d-Y H:i', $reset['timestamp'] ) ); ?>
|
1038 |
<br /> <strong><?php esc_html_e( 'Previous Opens', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $reset['opens'] ); ?>
|
@@ -1068,14 +1102,14 @@ class PUM_Admin_Popups {
|
|
1068 |
*
|
1069 |
* @return array
|
1070 |
*/
|
1071 |
-
public static function sanitize_meta( $meta =
|
1072 |
if ( ! empty( $meta ) ) {
|
1073 |
|
1074 |
foreach ( $meta as $key => $value ) {
|
1075 |
|
1076 |
if ( is_array( $value ) ) {
|
1077 |
$meta[ $key ] = self::sanitize_meta( $value );
|
1078 |
-
}
|
1079 |
try {
|
1080 |
$value = json_decode( stripslashes( $value ) );
|
1081 |
if ( is_object( $value ) || is_array( $value ) ) {
|
@@ -1084,7 +1118,6 @@ class PUM_Admin_Popups {
|
|
1084 |
} catch ( Exception $e ) {
|
1085 |
}
|
1086 |
}
|
1087 |
-
|
1088 |
}
|
1089 |
}
|
1090 |
|
@@ -1119,16 +1152,16 @@ class PUM_Admin_Popups {
|
|
1119 |
*/
|
1120 |
public static function dashboard_columns( $_columns ) {
|
1121 |
wp_enqueue_style( 'pum-admin-general' );
|
1122 |
-
$columns =
|
1123 |
-
'cb'
|
1124 |
-
'title'
|
1125 |
-
'enabled'
|
1126 |
-
'popup_title'
|
1127 |
-
'class'
|
1128 |
-
'opens'
|
1129 |
'conversions' => __( 'Conversions', 'popup-maker' ),
|
1130 |
'conversion_rate' => __( 'Conversion Rate', 'popup-maker' ),
|
1131 |
-
|
1132 |
|
1133 |
// Add the date column preventing our own translation.
|
1134 |
if ( ! empty( $_columns['date'] ) ) {
|
@@ -1268,25 +1301,34 @@ class PUM_Admin_Popups {
|
|
1268 |
if ( isset( $vars['orderby'] ) ) {
|
1269 |
switch ( $vars['orderby'] ) {
|
1270 |
case 'popup_title':
|
1271 |
-
$vars = array_merge(
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
|
|
|
|
|
|
1275 |
break;
|
1276 |
case 'opens':
|
1277 |
if ( ! pum_extension_enabled( 'popup-analytics' ) ) {
|
1278 |
-
$vars = array_merge(
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
|
|
|
|
|
|
1282 |
}
|
1283 |
break;
|
1284 |
case 'conversions':
|
1285 |
if ( ! pum_extension_enabled( 'popup-analytics' ) ) {
|
1286 |
-
$vars = array_merge(
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
|
|
|
|
|
|
1290 |
}
|
1291 |
break;
|
1292 |
}
|
@@ -1300,7 +1342,7 @@ class PUM_Admin_Popups {
|
|
1300 |
* Initialize sorting
|
1301 |
*/
|
1302 |
public static function load() {
|
1303 |
-
add_filter( 'request',
|
1304 |
}
|
1305 |
|
1306 |
/**
|
@@ -1318,12 +1360,12 @@ class PUM_Admin_Popups {
|
|
1318 |
$terms = get_terms( 'popup_category' );
|
1319 |
if ( count( $terms ) > 0 ) {
|
1320 |
echo "<select name='popup_category' id='popup_category' class='postform'>";
|
1321 |
-
echo "<option value=''>" . __( 'Show all categories', 'popup-maker' ) .
|
1322 |
foreach ( $terms as $term ) {
|
1323 |
$selected = isset( $_GET['popup_category'] ) && $_GET['popup_category'] == $term->slug ? 'selected="selected"' : '';
|
1324 |
echo '<option value="' . esc_attr( $term->slug ) . '" ' . $selected . '>' . esc_html( $term->name ) . ' (' . $term->count . ')</option>';
|
1325 |
}
|
1326 |
-
echo
|
1327 |
}
|
1328 |
}
|
1329 |
|
@@ -1331,12 +1373,12 @@ class PUM_Admin_Popups {
|
|
1331 |
$terms = get_terms( 'popup_tag' );
|
1332 |
if ( count( $terms ) > 0 ) {
|
1333 |
echo "<select name='popup_tag' id='popup_tag' class='postform'>";
|
1334 |
-
echo "<option value=''>" . __( 'Show all tags', 'popup-maker' ) .
|
1335 |
foreach ( $terms as $term ) {
|
1336 |
$selected = isset( $_GET['popup_tag'] ) && $_GET['popup_tag'] == $term->slug ? 'selected="selected"' : '';
|
1337 |
echo '<option value="' . esc_attr( $term->slug ) . '" ' . $selected . '>' . esc_html( $term->name ) . ' (' . $term->count . ')</option>';
|
1338 |
}
|
1339 |
-
echo
|
1340 |
}
|
1341 |
}
|
1342 |
}
|
@@ -1345,7 +1387,8 @@ class PUM_Admin_Popups {
|
|
1345 |
|
1346 |
/**
|
1347 |
* Prepends Popup ID to the action row on All Popups
|
1348 |
-
*
|
|
|
1349 |
* @param $post The post
|
1350 |
*
|
1351 |
* @return array The new actions.
|
@@ -1353,7 +1396,7 @@ class PUM_Admin_Popups {
|
|
1353 |
public static function add_id_row_actions( $actions, $post ) {
|
1354 |
// Only adjust if we are dealing with our popups.
|
1355 |
if ( 'popup' === $post->post_type ) {
|
1356 |
-
return array_merge(
|
1357 |
}
|
1358 |
|
1359 |
return $actions;
|
20 |
public static function init() {
|
21 |
|
22 |
// Adds ID to top of popup editor.
|
23 |
+
add_action( 'edit_form_top', [ __CLASS__, 'add_popup_id' ] );
|
24 |
|
25 |
// Change title to popup name.
|
26 |
+
add_filter( 'enter_title_here', [ __CLASS__, '_default_title' ] );
|
27 |
|
28 |
// Add popup title field.
|
29 |
+
add_action( 'edit_form_advanced', [ __CLASS__, 'title_meta_field' ] );
|
30 |
|
31 |
// Add Contextual help to post_name field.
|
32 |
+
add_action( 'edit_form_before_permalink', [ __CLASS__, 'popup_post_title_contextual_message' ] );
|
33 |
|
34 |
// Register Metaboxes.
|
35 |
+
add_action( 'add_meta_boxes', [ __CLASS__, 'meta_box' ] );
|
36 |
|
37 |
// Process meta saving.
|
38 |
+
add_action( 'save_post', [ __CLASS__, 'save' ], 10, 2 );
|
|
|
39 |
|
40 |
// Set the slug properly on save.
|
41 |
+
add_filter( 'wp_insert_post_data', [ __CLASS__, 'set_slug' ], 99, 2 );
|
42 |
|
43 |
// Dashboard columns & filters.
|
44 |
+
add_filter( 'manage_edit-popup_columns', [ __CLASS__, 'dashboard_columns' ] );
|
45 |
+
add_action( 'manage_posts_custom_column', [ __CLASS__, 'render_columns' ], 10, 2 );
|
46 |
+
add_filter( 'manage_edit-popup_sortable_columns', [ __CLASS__, 'sortable_columns' ] );
|
47 |
+
add_filter( 'default_hidden_columns', [ __CLASS__, 'hide_columns' ], 10, 2 );
|
48 |
+
add_action( 'load-edit.php', [ __CLASS__, 'load' ], 9999 );
|
49 |
+
add_action( 'restrict_manage_posts', [ __CLASS__, 'add_popup_filters' ], 100 );
|
50 |
+
add_filter( 'post_row_actions', [ __CLASS__, 'add_id_row_actions' ], 2, 100 );
|
51 |
+
|
52 |
+
add_action( 'post_submitbox_misc_actions', [ __CLASS__, 'add_enabled_toggle_editor' ], 10, 1 );
|
53 |
}
|
54 |
|
55 |
/**
|
131 |
return;
|
132 |
}
|
133 |
|
134 |
+
if ( 'popup' == $typenow && in_array( $pagenow, [ 'post-new.php', 'post.php' ] ) ) {
|
135 |
+
?>
|
136 |
|
137 |
<div id="popup-titlediv" class="pum-form">
|
138 |
<div id="popup-titlewrap">
|
163 |
return;
|
164 |
}
|
165 |
|
166 |
+
if ( 'popup' == $typenow && in_array( $pagenow, [ 'post-new.php', 'post.php' ] ) ) {
|
167 |
+
?>
|
168 |
<p class="pum-desc"><?php echo '(' . esc_html__( 'Required', 'popup-maker' ) . ') ' . esc_html__( 'Enter a name to help you remember what this popup is about. Only you will see this.', 'popup-maker' ); ?></p>
|
169 |
<?php
|
170 |
}
|
174 |
* Registers popup metaboxes.
|
175 |
*/
|
176 |
public static function meta_box() {
|
177 |
+
add_meta_box( 'pum_popup_settings', __( 'Popup Settings', 'popup-maker' ), [ __CLASS__, 'render_settings_meta_box' ], 'popup', 'normal', 'high' );
|
178 |
+
add_meta_box( 'pum_popup_analytics', __( 'Analytics', 'popup-maker' ), [ __CLASS__, 'render_analytics_meta_box' ], 'popup', 'side', 'high' );
|
179 |
}
|
180 |
|
181 |
/**
|
184 |
* @param array $values Array of settings.
|
185 |
* @return array
|
186 |
*/
|
187 |
+
public static function parse_values( $values = [] ) {
|
188 |
$defaults = self::defaults();
|
189 |
|
190 |
if ( empty( $values ) ) {
|
211 |
wp_enqueue_script( 'popup-maker-admin' );
|
212 |
?>
|
213 |
<script type="text/javascript">
|
214 |
+
window.pum_popup_settings_editor =
|
215 |
+
<?php
|
216 |
+
echo PUM_Utils_Array::safe_json_encode(
|
217 |
+
apply_filters(
|
218 |
+
'pum_popup_settings_editor_var',
|
219 |
+
[
|
220 |
+
'form_args' => [
|
221 |
+
'id' => 'pum-popup-settings',
|
222 |
+
'tabs' => self::tabs(),
|
223 |
+
'sections' => self::sections(),
|
224 |
+
'fields' => self::fields(),
|
225 |
+
],
|
226 |
+
'conditions' => PUM_Conditions::instance()->get_conditions(),
|
227 |
+
'conditions_selectlist' => PUM_Conditions::instance()->dropdown_list(),
|
228 |
+
'triggers' => PUM_Triggers::instance()->get_triggers(),
|
229 |
+
'cookies' => PUM_Cookies::instance()->get_cookies(),
|
230 |
+
'current_values' => self::render_form_values( $settings ),
|
231 |
+
'preview_nonce' => wp_create_nonce( 'popup-preview' ),
|
232 |
+
]
|
233 |
+
)
|
234 |
+
);
|
235 |
+
?>
|
236 |
+
;
|
237 |
</script>
|
238 |
|
239 |
<div id="pum-popup-settings-container" class="pum-popup-settings-container">
|
240 |
<div class="pum-no-js" style="padding: 0 12px;">
|
241 |
+
<p><?php printf( esc_html__( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %1$sView troubleshooting guide%2$s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
242 |
</div>
|
243 |
</div>
|
244 |
<?php
|
252 |
* @return mixed
|
253 |
*/
|
254 |
public static function deprecated_meta_fields() {
|
255 |
+
$fields = [];
|
256 |
foreach ( self::deprecated_meta_field_groups() as $group ) {
|
257 |
+
foreach ( apply_filters( 'popmake_popup_meta_field_group_' . $group, [] ) as $field ) {
|
258 |
$fields[] = 'popup_' . $group . '_' . $field;
|
259 |
}
|
260 |
}
|
270 |
* @return mixed
|
271 |
*/
|
272 |
public static function deprecated_meta_field_groups() {
|
273 |
+
return apply_filters( 'popmake_popup_meta_field_groups', [ 'display', 'close' ] );
|
274 |
}
|
275 |
|
276 |
/**
|
308 |
$popup->reset_counts();
|
309 |
}
|
310 |
|
311 |
+
$title = ! empty( $_POST['popup_title'] ) ? trim( sanitize_text_field( $_POST['popup_title'] ) ) : '';
|
|
|
312 |
$popup->update_meta( 'popup_title', $title );
|
313 |
|
314 |
+
$settings = ! empty( $_POST['popup_settings'] ) ? $_POST['popup_settings'] : [];
|
315 |
|
316 |
// Sanitize JSON values.
|
317 |
+
$settings['conditions'] = isset( $settings['conditions'] ) ? self::sanitize_meta( $settings['conditions'] ) : [];
|
318 |
+
$settings['triggers'] = isset( $settings['triggers'] ) ? self::sanitize_meta( $settings['triggers'] ) : [];
|
319 |
+
$settings['cookies'] = isset( $settings['cookies'] ) ? self::sanitize_meta( $settings['cookies'] ) : [];
|
320 |
|
321 |
$settings = apply_filters( 'pum_popup_setting_pre_save', $settings, $post->ID );
|
322 |
|
351 |
foreach ( $settings as $key => $value ) {
|
352 |
$field = self::get_field( $key );
|
353 |
|
|
|
354 |
if ( $field ) {
|
355 |
switch ( $field['type'] ) {
|
356 |
case 'measure':
|
368 |
* @return array
|
369 |
*/
|
370 |
public static function tabs() {
|
371 |
+
return apply_filters(
|
372 |
+
'pum_popup_settings_tabs',
|
373 |
+
[
|
374 |
+
'general' => __( 'General', 'popup-maker' ),
|
375 |
+
'display' => __( 'Display', 'popup-maker' ),
|
376 |
+
'close' => __( 'Close', 'popup-maker' ),
|
377 |
+
'triggers' => __( 'Triggers', 'popup-maker' ),
|
378 |
+
'targeting' => __( 'Targeting', 'popup-maker' ),
|
379 |
+
'advanced' => __( 'Advanced', 'popup-maker' ),
|
380 |
+
]
|
381 |
+
);
|
382 |
}
|
383 |
|
384 |
/**
|
387 |
* @return array
|
388 |
*/
|
389 |
public static function sections() {
|
390 |
+
return apply_filters(
|
391 |
+
'pum_popup_settings_sections',
|
392 |
+
[
|
393 |
+
'general' => [
|
394 |
+
'main' => __( 'General Settings', 'popup-maker' ),
|
395 |
+
],
|
396 |
+
'triggers' => [
|
397 |
+
'main' => __( 'Triggers & Cookies', 'popup-maker' ),
|
398 |
+
],
|
399 |
+
'targeting' => [
|
400 |
+
'main' => __( 'Conditions', 'popup-maker' ),
|
401 |
+
],
|
402 |
+
'display' => [
|
403 |
+
'preset' => __( 'Display Presets', 'popup-maker' ),
|
404 |
+
'main' => __( 'Appearance', 'popup-maker' ),
|
405 |
+
'size' => __( 'Size', 'popup-maker' ),
|
406 |
+
'animation' => __( 'Animation', 'popup-maker' ),
|
407 |
+
'sound' => __( 'Sounds', 'popup-maker' ),
|
408 |
+
'position' => __( 'Position', 'popup-maker' ),
|
409 |
+
'advanced' => __( 'Advanced', 'popup-maker' ),
|
410 |
+
],
|
411 |
+
'close' => [
|
412 |
+
'button' => __( 'Button', 'popup-maker' ),
|
413 |
+
'forms' => __( 'Form Submission', 'popup-maker' ),
|
414 |
+
'alternate_methods' => __( 'Alternate Methods', 'popup-maker' ),
|
415 |
+
],
|
416 |
+
'advanced' => [
|
417 |
+
'main' => __( 'Advanced', 'popup-maker' ),
|
418 |
+
],
|
419 |
+
]
|
420 |
+
);
|
421 |
}
|
422 |
|
423 |
/**
|
430 |
static $tabs;
|
431 |
|
432 |
if ( ! isset( $tabs ) ) {
|
433 |
+
$tabs = apply_filters(
|
434 |
+
'pum_popup_settings_fields',
|
435 |
+
[
|
436 |
+
'general' => apply_filters(
|
437 |
+
'pum_popup_general_settings_fields',
|
438 |
+
[
|
439 |
+
'main' => [],
|
440 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
),
|
442 |
+
'triggers' => apply_filters(
|
443 |
+
'pum_popup_triggers_settings_fields',
|
444 |
+
[
|
445 |
+
'main' => [
|
446 |
+
'triggers' => [
|
447 |
+
'type' => 'triggers',
|
448 |
+
'std' => [],
|
449 |
+
'priority' => 10,
|
450 |
+
],
|
451 |
+
'separator1' => [
|
452 |
+
'type' => 'separator',
|
453 |
+
'private' => true,
|
454 |
+
],
|
455 |
+
'cookies' => [
|
456 |
+
'type' => 'cookies',
|
457 |
+
'std' => [],
|
458 |
+
'priority' => 20,
|
459 |
+
],
|
460 |
+
],
|
461 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
),
|
463 |
+
'targeting' => apply_filters(
|
464 |
+
'pum_popup_targeting_settings_fields',
|
465 |
+
[
|
466 |
+
'main' => [
|
467 |
+
'conditions' => [
|
468 |
+
'type' => 'conditions',
|
469 |
+
'std' => [],
|
470 |
+
'priority' => 10,
|
471 |
+
'private' => true,
|
472 |
+
],
|
473 |
+
'disable_on_mobile' => [
|
474 |
+
'label' => __( 'Disable this popup on mobile devices.', 'popup-maker' ),
|
475 |
+
'type' => 'checkbox',
|
476 |
+
'priority' => 20,
|
477 |
+
],
|
478 |
+
'disable_on_tablet' => [
|
479 |
+
'label' => __( 'Disable this popup on tablet devices.', 'popup-maker' ),
|
480 |
+
'type' => 'checkbox',
|
481 |
+
'priority' => 20,
|
482 |
+
],
|
483 |
+
],
|
484 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
),
|
486 |
+
'display' => apply_filters(
|
487 |
+
'pum_popup_display_settings_fields',
|
488 |
+
[
|
489 |
+
'preset' => [
|
490 |
+
'explain' => [
|
491 |
+
'type' => 'html',
|
492 |
+
'content' => '<p>Select one of the types below to get started! Once selected, you can adjust the display settings using the tabs above.</p>',
|
493 |
+
],
|
494 |
+
'type_section' => [
|
495 |
+
'type' => 'section',
|
496 |
+
'classes' => 'popup-types',
|
497 |
+
'fields' => [
|
498 |
+
'<div class="popup-type" data-popup-type="center-popup"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/center-popup.png" alt="' . __( 'Center Popup', 'popup-maker' ) . '"/><button class="button">' . __( 'Center Popup', 'popup-maker' ) . '</button></div>',
|
499 |
+
'<div class="popup-type" data-popup-type="right-bottom-slidein"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/right-bottom-slidein.png" alt="' . __( 'Right Bottom Slide-in', 'popup-maker' ) . '"/><button class="button">' . __( 'Right Bottom Slide-in', 'popup-maker' ) . '</button></div>',
|
500 |
+
'<div class="popup-type" data-popup-type="top-bar"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/top-bar.png" alt="' . __( 'Top Bar', 'popup-maker' ) . '"/><button class="button">' . __( 'Top Bar', 'popup-maker' ) . '</button></div>',
|
501 |
+
'<div class="popup-type" data-popup-type="left-bottom-notice"><img src="' . Popup_Maker::$URL . 'assets/images/admin/display-switcher/left-bottom-notice.png" alt="' . __( 'Left Bottom Notice', 'popup-maker' ) . '"/><button class="button">' . __( 'Left Bottom Notice', 'popup-maker' ) . '</button></div>',
|
502 |
+
],
|
503 |
+
],
|
504 |
+
],
|
505 |
+
'main' => [
|
506 |
+
'theme_id' => [
|
507 |
+
'label' => __( 'Popup Theme', 'popup-maker' ),
|
508 |
+
'dynamic_desc' => sprintf( '%1$s<br/><a id="edit_theme_link" href="%3$s">%2$s</a>', __( 'Choose a theme for this popup.', 'popup-maker' ), __( 'Customize This Theme', 'popup-maker' ), admin_url( 'post.php?action=edit&post={{data.value}}' ) ),
|
509 |
+
'type' => 'select',
|
510 |
+
'options' => pum_is_popup_editor() ? PUM_Helpers::popup_theme_selectlist() : null,
|
511 |
+
'std' => pum_get_default_theme_id(),
|
512 |
+
],
|
513 |
+
],
|
514 |
+
'size' => [
|
515 |
+
'size' => [
|
516 |
+
'label' => __( 'Size', 'popup-maker' ),
|
517 |
+
'desc' => __( 'Select the size of the popup.', 'popup-maker' ),
|
518 |
+
'type' => 'select',
|
519 |
+
'std' => 'medium',
|
520 |
+
'priority' => 10,
|
521 |
+
'options' => [
|
522 |
+
__( 'Responsive Sizes', 'popup-maker' ) => [
|
523 |
+
'nano' => __( 'Nano - 10%', 'popup-maker' ),
|
524 |
+
'micro' => __( 'Micro - 20%', 'popup-maker' ),
|
525 |
+
'tiny' => __( 'Tiny - 30%', 'popup-maker' ),
|
526 |
+
'small' => __( 'Small - 40%', 'popup-maker' ),
|
527 |
+
'medium' => __( 'Medium - 60%', 'popup-maker' ),
|
528 |
+
'normal' => __( 'Normal - 70%', 'popup-maker' ),
|
529 |
+
'large' => __( 'Large - 80%', 'popup-maker' ),
|
530 |
+
'xlarge' => __( 'X Large - 95%', 'popup-maker' ),
|
531 |
+
],
|
532 |
+
__( 'Other Sizes', 'popup-maker' ) => [
|
533 |
+
'auto' => __( 'Auto', 'popup-maker' ),
|
534 |
+
'custom' => __( 'Custom', 'popup-maker' ),
|
535 |
+
],
|
536 |
+
],
|
537 |
+
],
|
538 |
+
'responsive_min_width' => [
|
539 |
+
'label' => __( 'Min Width', 'popup-maker' ),
|
540 |
+
'desc' => __( 'Set a minimum width for the popup.', 'popup-maker' ),
|
541 |
+
'type' => 'measure',
|
542 |
+
'std' => '0%',
|
543 |
+
'priority' => 20,
|
544 |
+
'dependencies' => [
|
545 |
+
'size' => [ 'nano', 'micro', 'tiny', 'small', 'medium', 'normal', 'large', 'xlarge' ],
|
546 |
+
],
|
547 |
+
],
|
548 |
+
'responsive_max_width' => [
|
549 |
+
'label' => __( 'Max Width', 'popup-maker' ),
|
550 |
+
'desc' => __( 'Set a maximum width for the popup.', 'popup-maker' ),
|
551 |
+
'type' => 'measure',
|
552 |
+
'std' => '100%',
|
553 |
+
'priority' => 30,
|
554 |
+
'dependencies' => [
|
555 |
+
'size' => [ 'nano', 'micro', 'tiny', 'small', 'medium', 'normal', 'large', 'xlarge' ],
|
556 |
+
],
|
557 |
+
],
|
558 |
+
'custom_width' => [
|
559 |
+
'label' => __( 'Width', 'popup-maker' ),
|
560 |
+
'desc' => __( 'Set a custom width for the popup.', 'popup-maker' ),
|
561 |
+
'type' => 'measure',
|
562 |
+
'std' => '640px',
|
563 |
+
'priority' => 40,
|
564 |
+
'dependencies' => [
|
565 |
+
'size' => 'custom',
|
566 |
+
],
|
567 |
+
],
|
568 |
+
'custom_height_auto' => [
|
569 |
+
'label' => __( 'Auto Adjusted Height', 'popup-maker' ),
|
570 |
+
'desc' => __( 'Checking this option will set height to fit the content.', 'popup-maker' ),
|
571 |
+
'type' => 'checkbox',
|
572 |
+
'priority' => 50,
|
573 |
+
'dependencies' => [
|
574 |
+
'size' => 'custom',
|
575 |
+
],
|
576 |
+
],
|
577 |
+
'custom_height' => [
|
578 |
+
'label' => __( 'Height', 'popup-maker' ),
|
579 |
+
'desc' => __( 'Set a custom height for the popup.', 'popup-maker' ),
|
580 |
+
'type' => 'measure',
|
581 |
+
'std' => '380px',
|
582 |
+
'priority' => 60,
|
583 |
+
'dependencies' => [
|
584 |
+
'size' => 'custom',
|
585 |
+
'custom_height_auto' => false,
|
586 |
+
],
|
587 |
+
],
|
588 |
+
'scrollable_content' => [
|
589 |
+
'label' => __( 'Scrollable Content', 'popup-maker' ),
|
590 |
+
'desc' => __( 'Checking this option will add a scroll bar to your content.', 'popup-maker' ),
|
591 |
+
'type' => 'checkbox',
|
592 |
+
'std' => false,
|
593 |
+
'priority' => 70,
|
594 |
+
'dependencies' => [
|
595 |
+
'size' => 'custom',
|
596 |
+
'custom_height_auto' => false,
|
597 |
+
],
|
598 |
+
],
|
599 |
+
],
|
600 |
+
'animation' => [
|
601 |
+
'animation_type' => [
|
602 |
+
'label' => __( 'Animation Type', 'popup-maker' ),
|
603 |
+
'desc' => __( 'Select an animation type for your popup.', 'popup-maker' ),
|
604 |
+
'type' => 'select',
|
605 |
+
'std' => 'fade',
|
606 |
+
'priority' => 10,
|
607 |
+
'options' => [
|
608 |
+
'none' => __( 'None', 'popup-maker' ),
|
609 |
+
'slide' => __( 'Slide', 'popup-maker' ),
|
610 |
+
'fade' => __( 'Fade', 'popup-maker' ),
|
611 |
+
'fadeAndSlide' => __( 'Fade and Slide', 'popup-maker' ),
|
612 |
+
// 'grow' => __( 'Grow', 'popup-maker' ),
|
613 |
+
// 'growAndSlide' => __( 'Grow and Slide', 'popup-maker' ),
|
614 |
+
],
|
615 |
+
],
|
616 |
+
'animation_speed' => [
|
617 |
+
'label' => __( 'Animation Speed', 'popup-maker' ),
|
618 |
+
'desc' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
|
619 |
+
'type' => 'rangeslider',
|
620 |
+
'std' => 350,
|
621 |
+
'step' => 10,
|
622 |
+
'min' => 50,
|
623 |
+
'max' => 1000,
|
624 |
+
'unit' => __( 'ms', 'popup-maker' ),
|
625 |
+
'priority' => 20,
|
626 |
+
'dependencies' => [
|
627 |
+
'animation_type' => [ 'slide', 'fade', 'fadeAndSlide', 'grow', 'growAndSlide' ],
|
628 |
+
],
|
629 |
+
],
|
630 |
+
'animation_origin' => [
|
631 |
+
'label' => __( 'Animation Origin', 'popup-maker' ),
|
632 |
+
'desc' => __( 'Choose where the animation will begin.', 'popup-maker' ),
|
633 |
+
'type' => 'select',
|
634 |
+
'std' => 'center top',
|
635 |
+
'options' => [
|
636 |
+
'top' => __( 'Top', 'popup-maker' ),
|
637 |
+
'left' => __( 'Left', 'popup-maker' ),
|
638 |
+
'bottom' => __( 'Bottom', 'popup-maker' ),
|
639 |
+
'right' => __( 'Right', 'popup-maker' ),
|
640 |
+
'left top' => __( 'Top Left', 'popup-maker' ),
|
641 |
+
'center top' => __( 'Top Center', 'popup-maker' ),
|
642 |
+
'right top' => __( 'Top Right', 'popup-maker' ),
|
643 |
+
'left center' => __( 'Middle Left', 'popup-maker' ),
|
644 |
+
'center center' => __( 'Middle Center', 'popup-maker' ),
|
645 |
+
'right center' => __( 'Middle Right', 'popup-maker' ),
|
646 |
+
'left bottom' => __( 'Bottom Left', 'popup-maker' ),
|
647 |
+
'center bottom' => __( 'Bottom Center', 'popup-maker' ),
|
648 |
+
'right bottom' => __( 'Bottom Right', 'popup-maker' ),
|
649 |
+
],
|
650 |
+
'priority' => 30,
|
651 |
+
'dependencies' => [
|
652 |
+
'animation_type' => [ 'slide', 'fadeAndSlide', 'grow', 'growAndSlide' ],
|
653 |
+
],
|
654 |
+
],
|
655 |
+
],
|
656 |
+
'sound' => [
|
657 |
+
'open_sound' => [
|
658 |
+
'label' => __( 'Opening Sound', 'popup-maker' ),
|
659 |
+
'desc' => __( 'Select a sound to play when the popup opens.', 'popup-maker' ),
|
660 |
+
'type' => 'select',
|
661 |
+
'std' => 'none',
|
662 |
+
'priority' => 10,
|
663 |
+
'options' => [
|
664 |
+
'none' => __( 'None', 'popup-maker' ),
|
665 |
+
'beep.mp3' => __( 'Beep', 'popup-maker' ),
|
666 |
+
'beep-two.mp3' => __( 'Beep 2', 'popup-maker' ),
|
667 |
+
'beep-up.mp3' => __( 'Beep Up', 'popup-maker' ),
|
668 |
+
'chimes.mp3' => __( 'Chimes', 'popup-maker' ),
|
669 |
+
'correct.mp3' => __( 'Correct', 'popup-maker' ),
|
670 |
+
'custom' => __( 'Custom Sound', 'popup-maker' ),
|
671 |
+
],
|
672 |
+
],
|
673 |
+
'custom_sound' => [
|
674 |
+
'label' => __( 'Custom Sound URL', 'popup-maker' ),
|
675 |
+
'desc' => __( 'Enter URL to sound file.', 'popup-maker' ),
|
676 |
+
'type' => 'text',
|
677 |
+
'std' => '',
|
678 |
+
'priority' => 10,
|
679 |
+
'dependencies' => [
|
680 |
+
'open_sound' => [ 'custom' ],
|
681 |
+
],
|
682 |
+
],
|
683 |
+
],
|
684 |
+
'position' => [
|
685 |
+
'location' => [
|
686 |
+
'label' => __( 'Location', 'popup-maker' ),
|
687 |
+
'desc' => __( 'Choose where the popup will be displayed.', 'popup-maker' ),
|
688 |
+
'type' => 'select',
|
689 |
+
'std' => 'center top',
|
690 |
+
'priority' => 10,
|
691 |
+
'options' => [
|
692 |
+
'left top' => __( 'Top Left', 'popup-maker' ),
|
693 |
+
'center top' => __( 'Top Center', 'popup-maker' ),
|
694 |
+
'right top' => __( 'Top Right', 'popup-maker' ),
|
695 |
+
'left center' => __( 'Middle Left', 'popup-maker' ),
|
696 |
+
'center' => __( 'Middle Center', 'popup-maker' ),
|
697 |
+
'right center' => __( 'Middle Right', 'popup-maker' ),
|
698 |
+
'left bottom' => __( 'Bottom Left', 'popup-maker' ),
|
699 |
+
'center bottom' => __( 'Bottom Center', 'popup-maker' ),
|
700 |
+
'right bottom' => __( 'Bottom Right', 'popup-maker' ),
|
701 |
+
],
|
702 |
+
],
|
703 |
+
'position_top' => [
|
704 |
+
'label' => __( 'Top', 'popup-maker' ),
|
705 |
+
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
|
706 |
+
'type' => 'rangeslider',
|
707 |
+
'std' => 100,
|
708 |
+
'step' => 1,
|
709 |
+
'min' => 0,
|
710 |
+
'max' => 500,
|
711 |
+
'unit' => 'px',
|
712 |
+
'priority' => 20,
|
713 |
+
'dependencies' => [
|
714 |
+
'location' => [ 'left top', 'center top', 'right top' ],
|
715 |
+
],
|
716 |
+
],
|
717 |
+
'position_bottom' => [
|
718 |
+
'label' => __( 'Bottom', 'popup-maker' ),
|
719 |
+
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
|
720 |
+
'type' => 'rangeslider',
|
721 |
+
'std' => 0,
|
722 |
+
'step' => 1,
|
723 |
+
'min' => 0,
|
724 |
+
'max' => 500,
|
725 |
+
'unit' => 'px',
|
726 |
+
'priority' => 20,
|
727 |
+
'dependencies' => [
|
728 |
+
'location' => [ 'left bottom', 'center bottom', 'right bottom' ],
|
729 |
+
],
|
730 |
+
],
|
731 |
+
'position_left' => [
|
732 |
+
'label' => __( 'Left', 'popup-maker' ),
|
733 |
+
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
|
734 |
+
'type' => 'rangeslider',
|
735 |
+
'std' => 0,
|
736 |
+
'step' => 1,
|
737 |
+
'min' => 0,
|
738 |
+
'max' => 500,
|
739 |
+
'unit' => 'px',
|
740 |
+
'priority' => 30,
|
741 |
+
'dependencies' => [
|
742 |
+
'location' => [ 'left top', 'left center', 'left bottom' ],
|
743 |
+
],
|
744 |
+
],
|
745 |
+
'position_right' => [
|
746 |
+
'label' => __( 'Right', 'popup-maker' ),
|
747 |
+
'desc' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
|
748 |
+
'type' => 'rangeslider',
|
749 |
+
'std' => 0,
|
750 |
+
'step' => 1,
|
751 |
+
'min' => 0,
|
752 |
+
'max' => 500,
|
753 |
+
'unit' => 'px',
|
754 |
+
'priority' => 30,
|
755 |
+
'dependencies' => [
|
756 |
+
'location' => [ 'right top', 'right center', 'right bottom' ],
|
757 |
+
],
|
758 |
+
],
|
759 |
+
'position_from_trigger' => [
|
760 |
+
'label' => __( 'Position from Trigger', 'popup-maker' ),
|
761 |
+
'desc' => sprintf( __( 'This will position the popup in relation to the %1$sClick Trigger%2$s.', 'popup-maker' ), '<a target="_blank" href="https://docs.wppopupmaker.com/article/395-trigger-click-open-overview-methods?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=position-from-trigger">', '</a>' ),
|
762 |
+
'type' => 'checkbox',
|
763 |
+
'std' => false,
|
764 |
+
'priority' => 40,
|
765 |
+
],
|
766 |
+
'position_fixed' => [
|
767 |
+
'label' => __( 'Fixed Postioning', 'popup-maker' ),
|
768 |
+
'desc' => __( 'Checking this sets the positioning of the popup to fixed.', 'popup-maker' ),
|
769 |
+
'type' => 'checkbox',
|
770 |
+
'priority' => 50,
|
771 |
+
],
|
772 |
+
],
|
773 |
+
'advanced' => [
|
774 |
+
'overlay_disabled' => [
|
775 |
+
'label' => __( 'Disable Overlay', 'popup-maker' ),
|
776 |
+
'desc' => __( 'Checking this will disable and hide the overlay for this popup.', 'popup-maker' ),
|
777 |
+
'type' => 'checkbox',
|
778 |
+
'priority' => 10,
|
779 |
+
],
|
780 |
+
'stackable' => [
|
781 |
+
'label' => __( 'Stackable', 'popup-maker' ),
|
782 |
+
'desc' => __( 'This enables other popups to remain open.', 'popup-maker' ),
|
783 |
+
'type' => 'checkbox',
|
784 |
+
'priority' => 20,
|
785 |
+
],
|
786 |
+
'disable_reposition' => [
|
787 |
+
'label' => __( 'Disable Repositioning', 'popup-maker' ),
|
788 |
+
'desc' => __( 'This will disable automatic repositioning of the popup on window resizing.', 'popup-maker' ),
|
789 |
+
'type' => 'checkbox',
|
790 |
+
'priority' => 30,
|
791 |
+
],
|
792 |
+
'zindex' => [
|
793 |
+
'label' => __( 'Popup Z-Index', 'popup-maker' ),
|
794 |
+
'desc' => __( 'Change the z-index layer level for the popup.', 'popup-maker' ),
|
795 |
+
'type' => 'number',
|
796 |
+
'min' => 999,
|
797 |
+
'max' => 2147483647,
|
798 |
+
'std' => 1999999999,
|
799 |
+
'priority' => 40,
|
800 |
+
],
|
801 |
+
],
|
802 |
+
]
|
803 |
),
|
804 |
+
'close' => apply_filters(
|
805 |
+
'pum_popup_close_settings_fields',
|
806 |
+
[
|
807 |
+
'button' => [
|
808 |
+
'close_text' => [
|
809 |
+
'label' => __( 'Close Text', 'popup-maker' ),
|
810 |
+
'placeholder' => __( 'Close', 'popup-maker' ),
|
811 |
+
'desc' => __( 'Override the default close text. To use a Font Awesome icon instead of text, enter the CSS classes such as "fas fa-camera".', 'popup-maker' ),
|
812 |
+
'priority' => 10,
|
813 |
+
'private' => true,
|
814 |
+
],
|
815 |
+
'close_button_delay' => [
|
816 |
+
'label' => __( 'Close Button Delay', 'popup-maker' ),
|
817 |
+
'desc' => __( 'This delays the display of the close button.', 'popup-maker' ),
|
818 |
+
'type' => 'rangeslider',
|
819 |
+
'std' => 0,
|
820 |
+
'step' => 100,
|
821 |
+
'min' => 0,
|
822 |
+
'max' => 3000,
|
823 |
+
'unit' => __( 'ms', 'popup-maker' ),
|
824 |
+
'priority' => 20,
|
825 |
+
],
|
826 |
],
|
827 |
+
'forms' => [
|
828 |
+
'close_on_form_submission' => [
|
829 |
+
'label' => __( 'Close on Form Submission', 'popup-maker' ),
|
830 |
+
'desc' => __( 'Close the popup automatically after integrated form plugin submissions.', 'popup-maker' ),
|
831 |
+
'type' => 'checkbox',
|
832 |
+
],
|
833 |
+
'close_on_form_submission_delay' => [
|
834 |
+
'type' => 'rangeslider',
|
835 |
+
'label' => __( 'Delay', 'popup-maker' ),
|
836 |
+
'desc' => __( 'The delay before the popup will close after submission (in milliseconds).', 'popup-maker' ),
|
837 |
+
'std' => 0,
|
838 |
+
'min' => 0,
|
839 |
+
'max' => 10000,
|
840 |
+
'step' => 500,
|
841 |
+
'unit' => 'ms',
|
842 |
+
'dependencies' => [
|
843 |
+
'close_on_form_submission' => true,
|
844 |
+
],
|
845 |
+
],
|
846 |
+
],
|
847 |
+
'alternate_methods' => [
|
848 |
+
'close_on_overlay_click' => [
|
849 |
+
'label' => __( 'Click Overlay to Close', 'popup-maker' ),
|
850 |
+
'desc' => __( 'Checking this will cause popup to close when user clicks on overlay.', 'popup-maker' ),
|
851 |
+
'type' => 'checkbox',
|
852 |
+
'priority' => 10,
|
853 |
+
],
|
854 |
+
'close_on_esc_press' => [
|
855 |
+
'label' => __( 'Press ESC to Close', 'popup-maker' ),
|
856 |
+
'desc' => __( 'Checking this will cause popup to close when user presses ESC key.', 'popup-maker' ),
|
857 |
+
'type' => 'checkbox',
|
858 |
+
'priority' => 20,
|
859 |
+
],
|
860 |
+
'close_on_f4_press' => [
|
861 |
+
'label' => __( 'Press F4 to Close', 'popup-maker' ),
|
862 |
+
'desc' => __( 'Checking this will cause popup to close when user presses F4 key.', 'popup-maker' ),
|
863 |
+
'type' => 'checkbox',
|
864 |
+
'priority' => 30,
|
865 |
+
],
|
866 |
+
],
|
867 |
+
]
|
868 |
),
|
869 |
+
'advanced' => apply_filters(
|
870 |
+
'pum_popup_advanced_settings_fields',
|
871 |
+
[
|
872 |
+
'main' => [
|
873 |
+
'disable_form_reopen' => [
|
874 |
+
'label' => __( 'Disable automatic re-triggering of popup after non-ajax form submission.', 'popup-maker' ),
|
875 |
+
'type' => 'checkbox',
|
876 |
+
'priority' => 10,
|
877 |
+
],
|
878 |
+
'disable_accessibility' => [
|
879 |
+
'label' => __( 'Disable accessibility features.', 'popup-maker' ),
|
880 |
+
'desc' => __( 'This includes trapping the tab key & focus inside popup while open, force focus the first element when popup open, and refocus last click trigger when closed.', 'popup-maker' ),
|
881 |
+
'type' => 'checkbox',
|
882 |
+
'priority' => 10,
|
883 |
+
],
|
884 |
+
],
|
885 |
+
]
|
886 |
),
|
887 |
+
]
|
888 |
+
);
|
|
|
889 |
|
890 |
$tabs = PUM_Admin_Helpers::parse_tab_fields(
|
891 |
$tabs,
|
892 |
[
|
893 |
'has_subtabs' => true,
|
894 |
+
'name' => 'popup_settings[%s]',
|
895 |
]
|
896 |
);
|
897 |
}
|
905 |
foreach ( $tabs as $tab => $sections ) {
|
906 |
|
907 |
if ( PUM_Admin_Helpers::is_field( $sections ) ) {
|
908 |
+
$sections = [
|
909 |
+
'main' => [
|
910 |
$tab => $sections,
|
911 |
+
],
|
912 |
+
];
|
913 |
}
|
914 |
|
915 |
foreach ( $sections as $section => $fields ) {
|
934 |
*
|
935 |
* @return array
|
936 |
*/
|
937 |
+
public static function sanitize_settings( $settings = [] ) {
|
938 |
|
939 |
$fields = self::fields();
|
940 |
$fields = PUM_Admin_Helpers::flatten_fields_array( $fields );
|
942 |
foreach ( $fields as $field_id => $field ) {
|
943 |
switch ( $field['type'] ) {
|
944 |
case 'checkbox':
|
|
|
945 |
if ( ! isset( $settings[ $field_id ] ) ) {
|
946 |
$settings[ $field_id ] = false;
|
947 |
}
|
964 |
$settings[ $key ] = is_string( $value ) ? trim( $value ) : $value;
|
965 |
break;
|
966 |
|
|
|
967 |
case 'measure':
|
968 |
$settings[ $key ] .= $settings[ $key . '_unit' ];
|
969 |
break;
|
972 |
// Some custom field types include multiple additional fields that do not need to be saved, strip out any non-whitelisted fields.
|
973 |
unset( $settings[ $key ] );
|
974 |
}
|
|
|
|
|
975 |
}
|
976 |
|
977 |
return $settings;
|
983 |
public static function defaults() {
|
984 |
$tabs = self::fields();
|
985 |
|
986 |
+
$defaults = [];
|
987 |
|
988 |
foreach ( $tabs as $tab_id => $sections ) {
|
989 |
foreach ( $sections as $section_id => $fields ) {
|
1063 |
<label> <input type="checkbox" name="popup_reset_counts" id="popup_reset_counts" value="1" />
|
1064 |
<?php esc_html_e( 'Reset Counts', 'popup-maker' ); ?>
|
1065 |
</label>
|
1066 |
+
<?php
|
1067 |
+
if ( ( $reset = $popup->get_last_count_reset() ) ) :
|
1068 |
+
?>
|
1069 |
+
<br />
|
1070 |
<small>
|
1071 |
<strong><?php esc_html_e( 'Last Reset', 'popup-maker' ); ?>:</strong> <?php echo esc_html( date( 'm-d-Y H:i', $reset['timestamp'] ) ); ?>
|
1072 |
<br /> <strong><?php esc_html_e( 'Previous Opens', 'popup-maker' ); ?>:</strong> <?php echo esc_html( $reset['opens'] ); ?>
|
1102 |
*
|
1103 |
* @return array
|
1104 |
*/
|
1105 |
+
public static function sanitize_meta( $meta = [] ) {
|
1106 |
if ( ! empty( $meta ) ) {
|
1107 |
|
1108 |
foreach ( $meta as $key => $value ) {
|
1109 |
|
1110 |
if ( is_array( $value ) ) {
|
1111 |
$meta[ $key ] = self::sanitize_meta( $value );
|
1112 |
+
} elseif ( is_string( $value ) ) {
|
1113 |
try {
|
1114 |
$value = json_decode( stripslashes( $value ) );
|
1115 |
if ( is_object( $value ) || is_array( $value ) ) {
|
1118 |
} catch ( Exception $e ) {
|
1119 |
}
|
1120 |
}
|
|
|
1121 |
}
|
1122 |
}
|
1123 |
|
1152 |
*/
|
1153 |
public static function dashboard_columns( $_columns ) {
|
1154 |
wp_enqueue_style( 'pum-admin-general' );
|
1155 |
+
$columns = [
|
1156 |
+
'cb' => '<input type="checkbox"/>',
|
1157 |
+
'title' => __( 'Name', 'popup-maker' ),
|
1158 |
+
'enabled' => __( 'Enabled', 'popup-maker' ),
|
1159 |
+
'popup_title' => __( 'Title', 'popup-maker' ),
|
1160 |
+
'class' => __( 'CSS Class', 'popup-maker' ),
|
1161 |
+
'opens' => __( 'Opens', 'popup-maker' ),
|
1162 |
'conversions' => __( 'Conversions', 'popup-maker' ),
|
1163 |
'conversion_rate' => __( 'Conversion Rate', 'popup-maker' ),
|
1164 |
+
];
|
1165 |
|
1166 |
// Add the date column preventing our own translation.
|
1167 |
if ( ! empty( $_columns['date'] ) ) {
|
1301 |
if ( isset( $vars['orderby'] ) ) {
|
1302 |
switch ( $vars['orderby'] ) {
|
1303 |
case 'popup_title':
|
1304 |
+
$vars = array_merge(
|
1305 |
+
$vars,
|
1306 |
+
[
|
1307 |
+
'meta_key' => 'popup_title',
|
1308 |
+
'orderby' => 'meta_value',
|
1309 |
+
]
|
1310 |
+
);
|
1311 |
break;
|
1312 |
case 'opens':
|
1313 |
if ( ! pum_extension_enabled( 'popup-analytics' ) ) {
|
1314 |
+
$vars = array_merge(
|
1315 |
+
$vars,
|
1316 |
+
[
|
1317 |
+
'meta_key' => 'popup_open_count',
|
1318 |
+
'orderby' => 'meta_value_num',
|
1319 |
+
]
|
1320 |
+
);
|
1321 |
}
|
1322 |
break;
|
1323 |
case 'conversions':
|
1324 |
if ( ! pum_extension_enabled( 'popup-analytics' ) ) {
|
1325 |
+
$vars = array_merge(
|
1326 |
+
$vars,
|
1327 |
+
[
|
1328 |
+
'meta_key' => 'popup_conversion_count',
|
1329 |
+
'orderby' => 'meta_value_num',
|
1330 |
+
]
|
1331 |
+
);
|
1332 |
}
|
1333 |
break;
|
1334 |
}
|
1342 |
* Initialize sorting
|
1343 |
*/
|
1344 |
public static function load() {
|
1345 |
+
add_filter( 'request', [ __CLASS__, 'sort_columns' ] );
|
1346 |
}
|
1347 |
|
1348 |
/**
|
1360 |
$terms = get_terms( 'popup_category' );
|
1361 |
if ( count( $terms ) > 0 ) {
|
1362 |
echo "<select name='popup_category' id='popup_category' class='postform'>";
|
1363 |
+
echo "<option value=''>" . __( 'Show all categories', 'popup-maker' ) . '</option>';
|
1364 |
foreach ( $terms as $term ) {
|
1365 |
$selected = isset( $_GET['popup_category'] ) && $_GET['popup_category'] == $term->slug ? 'selected="selected"' : '';
|
1366 |
echo '<option value="' . esc_attr( $term->slug ) . '" ' . $selected . '>' . esc_html( $term->name ) . ' (' . $term->count . ')</option>';
|
1367 |
}
|
1368 |
+
echo '</select>';
|
1369 |
}
|
1370 |
}
|
1371 |
|
1373 |
$terms = get_terms( 'popup_tag' );
|
1374 |
if ( count( $terms ) > 0 ) {
|
1375 |
echo "<select name='popup_tag' id='popup_tag' class='postform'>";
|
1376 |
+
echo "<option value=''>" . __( 'Show all tags', 'popup-maker' ) . '</option>';
|
1377 |
foreach ( $terms as $term ) {
|
1378 |
$selected = isset( $_GET['popup_tag'] ) && $_GET['popup_tag'] == $term->slug ? 'selected="selected"' : '';
|
1379 |
echo '<option value="' . esc_attr( $term->slug ) . '" ' . $selected . '>' . esc_html( $term->name ) . ' (' . $term->count . ')</option>';
|
1380 |
}
|
1381 |
+
echo '</select>';
|
1382 |
}
|
1383 |
}
|
1384 |
}
|
1387 |
|
1388 |
/**
|
1389 |
* Prepends Popup ID to the action row on All Popups
|
1390 |
+
*
|
1391 |
+
* @param array $actions The row actions.
|
1392 |
* @param $post The post
|
1393 |
*
|
1394 |
* @return array The new actions.
|
1396 |
public static function add_id_row_actions( $actions, $post ) {
|
1397 |
// Only adjust if we are dealing with our popups.
|
1398 |
if ( 'popup' === $post->post_type ) {
|
1399 |
+
return array_merge( [ 'id' => 'ID: ' . $post->ID ], $actions );
|
1400 |
}
|
1401 |
|
1402 |
return $actions;
|
classes/Admin/Settings.php
CHANGED
@@ -15,16 +15,16 @@ class PUM_Admin_Settings {
|
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
-
public static $notices =
|
19 |
|
20 |
/**
|
21 |
*
|
22 |
*/
|
23 |
public static function init() {
|
24 |
-
add_action( 'admin_notices',
|
25 |
-
add_action( 'admin_init',
|
26 |
-
//add_action( 'pum_license_deactivated', array( __CLASS__, 'license_deactivated' ) );
|
27 |
-
//add_action( 'pum_license_check_failed', array( __CLASS__, 'license_deactivated' ) );
|
28 |
}
|
29 |
|
30 |
// display default admin notice
|
@@ -35,10 +35,10 @@ class PUM_Admin_Settings {
|
|
35 |
public static function notices() {
|
36 |
|
37 |
if ( isset( $_GET['success'] ) && get_option( 'pum_settings_admin_notice' ) ) {
|
38 |
-
self::$notices[] =
|
39 |
'type' => $_GET['success'] ? 'success' : 'error',
|
40 |
'message' => get_option( 'pum_settings_admin_notice' ),
|
41 |
-
|
42 |
|
43 |
delete_option( 'pum_settings_admin_notice' );
|
44 |
}
|
@@ -51,7 +51,8 @@ class PUM_Admin_Settings {
|
|
51 |
<span class="screen-reader-text"><?php _e( 'Dismiss this notice.', 'popup-maker' ); ?></span>
|
52 |
</button>
|
53 |
</div>
|
54 |
-
|
|
|
55 |
}
|
56 |
}
|
57 |
|
@@ -75,17 +76,17 @@ class PUM_Admin_Settings {
|
|
75 |
$settings = apply_filters( 'pum_sanitize_settings', $settings );
|
76 |
|
77 |
if ( PUM_Utils_Options::update_all( $settings ) ) {
|
78 |
-
self::$notices[] =
|
79 |
'type' => 'success',
|
80 |
'message' => __( 'Settings saved successfully!', 'popup-maker' ),
|
81 |
-
|
82 |
|
83 |
do_action( 'pum_save_settings', $settings );
|
84 |
} else {
|
85 |
-
self::$notices[] =
|
86 |
'type' => 'error',
|
87 |
'message' => __( 'There must have been an error, settings not saved successfully!', 'popup-maker' ),
|
88 |
-
|
89 |
}
|
90 |
|
91 |
return;
|
@@ -123,7 +124,6 @@ class PUM_Admin_Settings {
|
|
123 |
*/
|
124 |
}
|
125 |
|
126 |
-
|
127 |
}
|
128 |
|
129 |
/**
|
@@ -131,7 +131,7 @@ class PUM_Admin_Settings {
|
|
131 |
*
|
132 |
* @return array
|
133 |
*/
|
134 |
-
public static function sanitize_settings( $settings =
|
135 |
|
136 |
$fields = self::fields();
|
137 |
|
@@ -140,7 +140,6 @@ class PUM_Admin_Settings {
|
|
140 |
foreach ( $fields as $field_id => $field ) {
|
141 |
switch ( $field['type'] ) {
|
142 |
case 'checkbox':
|
143 |
-
|
144 |
if ( ! isset( $settings[ $field_id ] ) ) {
|
145 |
$settings[ $field_id ] = false;
|
146 |
}
|
@@ -163,7 +162,6 @@ class PUM_Admin_Settings {
|
|
163 |
$settings[ $key ] = is_string( $value ) ? trim( $value ) : $value;
|
164 |
break;
|
165 |
|
166 |
-
|
167 |
case 'measure':
|
168 |
$settings[ $key ] .= $settings[ $key . '_unit' ];
|
169 |
break;
|
@@ -201,11 +199,11 @@ class PUM_Admin_Settings {
|
|
201 |
foreach ( $tabs as $tab => $sections ) {
|
202 |
|
203 |
if ( PUM_Admin_Helpers::is_field( $sections ) ) {
|
204 |
-
$sections =
|
205 |
-
'main' =>
|
206 |
$tab => $sections,
|
207 |
-
|
208 |
-
|
209 |
}
|
210 |
|
211 |
foreach ( $sections as $section => $fields ) {
|
@@ -232,28 +230,27 @@ class PUM_Admin_Settings {
|
|
232 |
|
233 |
if ( ! isset( $fields ) ) {
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
'default_theme_id' => array(
|
240 |
'label' => __( 'Default Popup Theme', 'popup-maker' ),
|
241 |
-
'dynamic_desc' => sprintf( '%1$s<br/><a id="edit_theme_link" href="%3$s">%2$s</a>', __( 'Choose the default theme used for new popups', 'popup-maker' ), __( 'Customize This Theme', 'popup-maker' ), admin_url(
|
242 |
'type' => 'select',
|
243 |
'options' => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
|
244 |
'std' => pum_get_default_theme_id(),
|
245 |
-
|
246 |
-
'gutenberg_support_enabled' =>
|
247 |
'label' => __( 'Enable Block Editor Support', 'popup-maker' ),
|
248 |
'desc' => __( 'Enable experimental support for using the block editor to edit popups.', 'popup-maker' ),
|
249 |
'type' => 'checkbox',
|
250 |
-
|
251 |
-
'google_fonts_api_key' =>
|
252 |
'type' => 'text',
|
253 |
'label' => __( 'Google Fonts API Key *optional', 'popup-maker' ),
|
254 |
'desc' => __( 'Enter your own Google Fonts API key to always get the latest fonts available.', 'popup-maker' ),
|
255 |
-
|
256 |
-
'telemetry'
|
257 |
'type' => 'checkbox',
|
258 |
'label' => __( 'Allow usage tracking?', 'popup-maker' ),
|
259 |
'desc' => sprintf(
|
@@ -262,285 +259,297 @@ class PUM_Admin_Settings {
|
|
262 |
' <a target="_blank" rel="noreferrer noopener" href="https://docs.wppopupmaker.com/article/528-the-data-the-popup-maker-plugin-collects?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=settings-page&utm_content=telemetry-setting">',
|
263 |
'</a>'
|
264 |
),
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
|
270 |
// TODO Remove or move externally of this location later.
|
271 |
if ( ! ( class_exists( 'PUM_MCI' ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) ) {
|
272 |
-
$fields['subscriptions'] =
|
273 |
-
'main' => apply_filters(
|
274 |
-
'
|
275 |
-
|
276 |
-
'
|
277 |
-
|
278 |
-
|
279 |
-
'
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
'main' => array(),
|
325 |
-
),
|
326 |
-
'licenses' => array(
|
327 |
-
'main' => array(),
|
328 |
-
),
|
329 |
-
'privacy' => array(
|
330 |
-
'main' => array(
|
331 |
-
'disable_popup_open_tracking' => array(
|
332 |
-
'type' => 'checkbox',
|
333 |
-
'label' => __( 'Disables popup open tracking?', 'popup-maker' ),
|
334 |
-
'desc' => __( 'This will disable the built in analytics functionality.', 'popup-maker' ),
|
335 |
-
),
|
336 |
-
),
|
337 |
-
'forms' => array(
|
338 |
-
'forms_disclaimer' => array(
|
339 |
-
'type' => 'html',
|
340 |
-
'content' => "<strong>" . __( 'Disclaimer', 'popup-maker' ) . ":</strong> " . __( 'These settings only pertain to usage of the Popup Maker built in subscription form shortcode, not 3rd party form plugins.', 'popup-maker' ),
|
341 |
-
),
|
342 |
-
'privacy_consent_always_enabled' => array(
|
343 |
-
'label' => __( 'Always enable consent field on subscription forms.', 'popup-maker' ),
|
344 |
-
'type' => 'select',
|
345 |
-
'options' => array(
|
346 |
-
'yes' => __( 'Yes', 'popup-maker' ),
|
347 |
-
'no' => __( 'No', 'popup-maker' ),
|
348 |
-
),
|
349 |
-
'std' => 'yes',
|
350 |
-
),
|
351 |
-
'default_privacy_consent_label' => array(
|
352 |
-
'label' => __( 'Consent Text', 'popup-maker' ),
|
353 |
-
'type' => 'text',
|
354 |
-
'std' => __( 'Notify me about related content and special offers.', 'popup-maker' ),
|
355 |
-
'dependencies' => array(
|
356 |
-
'privacy_consent_always_enabled' => 'yes',
|
357 |
-
),
|
358 |
-
),
|
359 |
-
'default_privacy_consent_type' => array(
|
360 |
-
'label' => __( 'Consent Field Type', 'popup-maker' ),
|
361 |
-
'desc' => __( 'Radio forces the user to make a choice, often resulting in more opt-ins.', 'popup-maker' ),
|
362 |
-
'type' => 'select',
|
363 |
-
'options' => array(
|
364 |
-
'radio' => __( 'Radio', 'popup-maker' ),
|
365 |
-
'checkbox' => __( 'Checkbox', 'popup-maker' ),
|
366 |
-
),
|
367 |
-
'std' => 'radio',
|
368 |
-
'dependencies' => array(
|
369 |
-
'privacy_consent_always_enabled' => 'yes',
|
370 |
-
),
|
371 |
-
),
|
372 |
-
'default_privacy_consent_required' => array(
|
373 |
-
'label' => __( 'Consent Required', 'popup-maker' ),
|
374 |
-
'type' => 'checkbox',
|
375 |
-
'std' => pum_get_option( 'default_privacy_consent_required' ),
|
376 |
-
'private' => true,
|
377 |
-
'dependencies' => array(
|
378 |
-
'privacy_consent_always_enabled' => 'yes',
|
379 |
-
),
|
380 |
-
),
|
381 |
-
'default_privacy_consent_radio_layout' => array(
|
382 |
-
'label' => __( 'Consent Radio Layout', 'popup-maker' ),
|
383 |
-
'type' => 'select',
|
384 |
-
'options' => array(
|
385 |
-
'inline' => __( 'Inline', 'popup-maker' ),
|
386 |
-
'stacked' => __( 'Stacked', 'popup-maker' ),
|
387 |
-
),
|
388 |
-
'std' => __( 'Yes', 'popup-maker' ),
|
389 |
-
'dependencies' => array(
|
390 |
-
'privacy_consent_always_enabled' => 'yes',
|
391 |
-
'default_privacy_consent_type' => 'radio',
|
392 |
-
),
|
393 |
-
),
|
394 |
-
'default_privacy_consent_yes_label' => array(
|
395 |
-
'label' => __( 'Consent Yes Label', 'popup-maker' ),
|
396 |
-
'type' => 'text',
|
397 |
-
'std' => __( 'Yes', 'popup-maker' ),
|
398 |
-
'dependencies' => array(
|
399 |
-
'privacy_consent_always_enabled' => 'yes',
|
400 |
-
'default_privacy_consent_type' => 'radio',
|
401 |
-
),
|
402 |
-
),
|
403 |
-
'default_privacy_consent_no_label' => array(
|
404 |
-
'label' => __( 'Consent No Label', 'popup-maker' ),
|
405 |
-
'type' => 'text',
|
406 |
-
'std' => __( 'No', 'popup-maker' ),
|
407 |
-
'dependencies' => array(
|
408 |
-
'privacy_consent_always_enabled' => 'yes',
|
409 |
-
'default_privacy_consent_type' => 'radio',
|
410 |
-
),
|
411 |
-
),
|
412 |
-
'default_privacy_usage_text' => array(
|
413 |
-
'label' => __( 'Consent Usage Text', 'popup-maker' ),
|
414 |
-
'desc' => function_exists( 'get_privacy_policy_url' ) ? sprintf( __( 'You can use %1$s%2$s to insert a link to your privacy policy. To customize the link text use %1$s:Link Text%2$s', 'popup-maker' ), '{{privacy_link', '}}' ) : '',
|
415 |
-
'type' => 'text',
|
416 |
-
'std' => __( 'If you opt in above we use this information send related content, discounts and other special offers.', 'popup-maker' ),
|
417 |
-
'dependencies' => array(
|
418 |
-
'privacy_consent_always_enabled' => 'yes',
|
419 |
-
),
|
420 |
-
),
|
421 |
),
|
422 |
-
|
423 |
-
|
424 |
-
'misc' => array(
|
425 |
-
'main' => array(
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
'
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
'
|
442 |
-
|
443 |
-
|
444 |
-
'
|
445 |
-
'
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
'
|
450 |
-
'
|
451 |
-
'
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
'
|
461 |
-
'
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
'
|
467 |
-
|
468 |
-
|
469 |
-
'
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
'
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
'
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
|
538 |
$fields = apply_filters( 'pum_settings_fields', $fields );
|
539 |
|
540 |
-
$fields = PUM_Admin_Helpers::parse_tab_fields(
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
|
|
|
|
544 |
}
|
545 |
|
546 |
return $fields;
|
@@ -550,7 +559,7 @@ class PUM_Admin_Settings {
|
|
550 |
* @return string
|
551 |
*/
|
552 |
public static function field_pum_styles() {
|
553 |
-
$core_styles = file_get_contents( Popup_Maker::$DIR . 'assets/css/pum-site' . (is_rtl() ? '-rtl' : '') . PUM_Site_Assets::$suffix . '.css' );
|
554 |
|
555 |
$user_styles = PUM_AssetCache::generate_font_imports() . PUM_AssetCache::generate_popup_theme_styles() . PUM_AssetCache::generate_popup_styles();
|
556 |
|
@@ -584,7 +593,7 @@ class PUM_Admin_Settings {
|
|
584 |
public static function user_role_options() {
|
585 |
global $wp_roles;
|
586 |
|
587 |
-
$options =
|
588 |
foreach ( $wp_roles->roles as $role => $labels ) {
|
589 |
$options[ $role ] = $labels['name'];
|
590 |
}
|
@@ -613,27 +622,36 @@ class PUM_Admin_Settings {
|
|
613 |
<h1><?php _e( 'Popup Maker Settings', 'popup-maker' ); ?></h1>
|
614 |
<div id="pum-settings-container" class="pum-settings-container">
|
615 |
<div class="pum-no-js" style="padding: 0 12px;">
|
616 |
-
<p><?php printf( __( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %sView troubleshooting guide%s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
617 |
</div>
|
618 |
</div>
|
619 |
|
620 |
<script type="text/javascript">
|
621 |
-
window.pum_settings_editor =
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
'
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
'
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
</script>
|
638 |
|
639 |
<button class="button-primary bottom" style="margin-left: 156px;"><?php _e( 'Save', 'popup-maker' ); ?></button>
|
@@ -651,7 +669,7 @@ class PUM_Admin_Settings {
|
|
651 |
public static function defaults() {
|
652 |
$tabs = self::fields();
|
653 |
|
654 |
-
$defaults =
|
655 |
|
656 |
foreach ( $tabs as $section_id => $fields ) {
|
657 |
foreach ( $fields as $key => $field ) {
|
@@ -671,20 +689,22 @@ class PUM_Admin_Settings {
|
|
671 |
static $tabs;
|
672 |
|
673 |
if ( ! isset( $tabs ) ) {
|
674 |
-
$tabs = apply_filters(
|
675 |
-
'
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
|
|
|
|
|
|
682 |
|
683 |
/** @deprecated 1.7.0 */
|
684 |
$tabs = apply_filters( 'popmake_settings_tabs', $tabs );
|
685 |
}
|
686 |
|
687 |
-
|
688 |
return $tabs;
|
689 |
}
|
690 |
|
@@ -694,28 +714,31 @@ class PUM_Admin_Settings {
|
|
694 |
* @return array
|
695 |
*/
|
696 |
public static function sections() {
|
697 |
-
return apply_filters(
|
698 |
-
'
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
'
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
'
|
717 |
-
|
718 |
-
|
|
|
|
|
|
|
719 |
}
|
720 |
|
721 |
/**
|
@@ -757,7 +780,6 @@ class PUM_Admin_Settings {
|
|
757 |
foreach ( $settings as $key => $value ) {
|
758 |
$field = self::get_field( $key );
|
759 |
|
760 |
-
|
761 |
if ( $field ) {
|
762 |
|
763 |
/**
|
@@ -769,13 +791,13 @@ class PUM_Admin_Settings {
|
|
769 |
case 'license_key':
|
770 |
$license = get_option( $field['options']['is_valid_license_option'] );
|
771 |
|
772 |
-
$settings[ $key ] =
|
773 |
'key' => trim( $value ),
|
774 |
'status' => PUM_Licensing::get_status( $license, ! empty( $value ) ),
|
775 |
'messages' => PUM_Licensing::get_status_messages( $license, trim( $value ) ),
|
776 |
'expires' => PUM_Licensing::get_license_expiration( $license ),
|
777 |
'classes' => PUM_Licensing::get_status_classes( $license ),
|
778 |
-
|
779 |
break;
|
780 |
}
|
781 |
|
@@ -789,7 +811,6 @@ class PUM_Admin_Settings {
|
|
789 |
break;
|
790 |
*/
|
791 |
}
|
792 |
-
|
793 |
}
|
794 |
}
|
795 |
|
@@ -808,7 +829,7 @@ class PUM_Admin_Settings {
|
|
808 |
*
|
809 |
* @return array
|
810 |
*/
|
811 |
-
public static function sanitize_objects( $meta =
|
812 |
if ( ! empty( $meta ) ) {
|
813 |
|
814 |
foreach ( $meta as $key => $value ) {
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
+
public static $notices = [];
|
19 |
|
20 |
/**
|
21 |
*
|
22 |
*/
|
23 |
public static function init() {
|
24 |
+
add_action( 'admin_notices', [ __CLASS__, 'notices' ] );
|
25 |
+
add_action( 'admin_init', [ __CLASS__, 'save' ] );
|
26 |
+
// add_action( 'pum_license_deactivated', array( __CLASS__, 'license_deactivated' ) );
|
27 |
+
// add_action( 'pum_license_check_failed', array( __CLASS__, 'license_deactivated' ) );
|
28 |
}
|
29 |
|
30 |
// display default admin notice
|
35 |
public static function notices() {
|
36 |
|
37 |
if ( isset( $_GET['success'] ) && get_option( 'pum_settings_admin_notice' ) ) {
|
38 |
+
self::$notices[] = [
|
39 |
'type' => $_GET['success'] ? 'success' : 'error',
|
40 |
'message' => get_option( 'pum_settings_admin_notice' ),
|
41 |
+
];
|
42 |
|
43 |
delete_option( 'pum_settings_admin_notice' );
|
44 |
}
|
51 |
<span class="screen-reader-text"><?php _e( 'Dismiss this notice.', 'popup-maker' ); ?></span>
|
52 |
</button>
|
53 |
</div>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
}
|
57 |
}
|
58 |
|
76 |
$settings = apply_filters( 'pum_sanitize_settings', $settings );
|
77 |
|
78 |
if ( PUM_Utils_Options::update_all( $settings ) ) {
|
79 |
+
self::$notices[] = [
|
80 |
'type' => 'success',
|
81 |
'message' => __( 'Settings saved successfully!', 'popup-maker' ),
|
82 |
+
];
|
83 |
|
84 |
do_action( 'pum_save_settings', $settings );
|
85 |
} else {
|
86 |
+
self::$notices[] = [
|
87 |
'type' => 'error',
|
88 |
'message' => __( 'There must have been an error, settings not saved successfully!', 'popup-maker' ),
|
89 |
+
];
|
90 |
}
|
91 |
|
92 |
return;
|
124 |
*/
|
125 |
}
|
126 |
|
|
|
127 |
}
|
128 |
|
129 |
/**
|
131 |
*
|
132 |
* @return array
|
133 |
*/
|
134 |
+
public static function sanitize_settings( $settings = [] ) {
|
135 |
|
136 |
$fields = self::fields();
|
137 |
|
140 |
foreach ( $fields as $field_id => $field ) {
|
141 |
switch ( $field['type'] ) {
|
142 |
case 'checkbox':
|
|
|
143 |
if ( ! isset( $settings[ $field_id ] ) ) {
|
144 |
$settings[ $field_id ] = false;
|
145 |
}
|
162 |
$settings[ $key ] = is_string( $value ) ? trim( $value ) : $value;
|
163 |
break;
|
164 |
|
|
|
165 |
case 'measure':
|
166 |
$settings[ $key ] .= $settings[ $key . '_unit' ];
|
167 |
break;
|
199 |
foreach ( $tabs as $tab => $sections ) {
|
200 |
|
201 |
if ( PUM_Admin_Helpers::is_field( $sections ) ) {
|
202 |
+
$sections = [
|
203 |
+
'main' => [
|
204 |
$tab => $sections,
|
205 |
+
],
|
206 |
+
];
|
207 |
}
|
208 |
|
209 |
foreach ( $sections as $section => $fields ) {
|
230 |
|
231 |
if ( ! isset( $fields ) ) {
|
232 |
|
233 |
+
$fields = [
|
234 |
+
'general' => [
|
235 |
+
'main' => [
|
236 |
+
'default_theme_id' => [
|
|
|
237 |
'label' => __( 'Default Popup Theme', 'popup-maker' ),
|
238 |
+
'dynamic_desc' => sprintf( '%1$s<br/><a id="edit_theme_link" href="%3$s">%2$s</a>', __( 'Choose the default theme used for new popups', 'popup-maker' ), __( 'Customize This Theme', 'popup-maker' ), admin_url( 'post.php?action=edit&post={{data.value}}' ) ),
|
239 |
'type' => 'select',
|
240 |
'options' => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
|
241 |
'std' => pum_get_default_theme_id(),
|
242 |
+
],
|
243 |
+
'gutenberg_support_enabled' => [
|
244 |
'label' => __( 'Enable Block Editor Support', 'popup-maker' ),
|
245 |
'desc' => __( 'Enable experimental support for using the block editor to edit popups.', 'popup-maker' ),
|
246 |
'type' => 'checkbox',
|
247 |
+
],
|
248 |
+
'google_fonts_api_key' => [
|
249 |
'type' => 'text',
|
250 |
'label' => __( 'Google Fonts API Key *optional', 'popup-maker' ),
|
251 |
'desc' => __( 'Enter your own Google Fonts API key to always get the latest fonts available.', 'popup-maker' ),
|
252 |
+
],
|
253 |
+
'telemetry' => [
|
254 |
'type' => 'checkbox',
|
255 |
'label' => __( 'Allow usage tracking?', 'popup-maker' ),
|
256 |
'desc' => sprintf(
|
259 |
' <a target="_blank" rel="noreferrer noopener" href="https://docs.wppopupmaker.com/article/528-the-data-the-popup-maker-plugin-collects?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=settings-page&utm_content=telemetry-setting">',
|
260 |
'</a>'
|
261 |
),
|
262 |
+
],
|
263 |
+
],
|
264 |
+
],
|
265 |
+
];
|
266 |
|
267 |
// TODO Remove or move externally of this location later.
|
268 |
if ( ! ( class_exists( 'PUM_MCI' ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) ) {
|
269 |
+
$fields['subscriptions'] = [
|
270 |
+
'main' => apply_filters(
|
271 |
+
'pum_newsletter_settings',
|
272 |
+
[
|
273 |
+
'newsletter_default_provider' => [
|
274 |
+
'label' => __( 'Default Newsletter Provider', 'popup-maker' ),
|
275 |
+
'desc' => __( 'The default mailing provider used for the subscription form.', 'popup-maker' ),
|
276 |
+
'type' => 'select',
|
277 |
+
'options' => array_merge(
|
278 |
+
PUM_Newsletter_Providers::dropdown_list(),
|
279 |
+
[
|
280 |
+
'none' => __( 'None', 'popup-maker' ),
|
281 |
+
]
|
282 |
+
),
|
283 |
+
],
|
284 |
+
'default_success_message' => [
|
285 |
+
'label' => __( 'Success Message', 'popup-maker' ),
|
286 |
+
'desc' => __( 'Message to show user when successfuly subscribed.', 'popup-maker' ),
|
287 |
+
'type' => 'text',
|
288 |
+
'std' => __( 'You have been subscribed!', 'popup-maker' ),
|
289 |
+
],
|
290 |
+
'default_empty_email_message' => [
|
291 |
+
'label' => __( 'Empty Email Message', 'popup-maker' ),
|
292 |
+
'desc' => __( 'Message to show user when no email is entered.', 'popup-maker' ),
|
293 |
+
'type' => 'text',
|
294 |
+
'std' => __( 'Please enter a valid email.', 'popup-maker' ),
|
295 |
+
],
|
296 |
+
'default_invalid_email_message' => [
|
297 |
+
'label' => __( 'Invalid Email Message', 'popup-maker' ),
|
298 |
+
'desc' => __( 'Message to show user when an invalid email is entered.', 'popup-maker' ),
|
299 |
+
'type' => 'text',
|
300 |
+
'std' => __( 'Email provided is not a valid email address.', 'popup-maker' ),
|
301 |
+
],
|
302 |
+
'default_error_message' => [
|
303 |
+
'label' => __( 'Error Message', 'popup-maker' ),
|
304 |
+
'desc' => __( 'Message to show user when an error has occurred.', 'popup-maker' ),
|
305 |
+
'type' => 'text',
|
306 |
+
'std' => __( 'Error occurred when subscribing. Please try again.', 'popup-maker' ),
|
307 |
+
],
|
308 |
+
'default_already_subscribed_message' => [
|
309 |
+
'label' => __( 'Already Subscribed Message', 'popup-maker' ),
|
310 |
+
'desc' => __( 'Message to show user who is already subscribed.', 'popup-maker' ),
|
311 |
+
'type' => 'text',
|
312 |
+
'std' => __( 'You are already a subscriber.', 'popup-maker' ),
|
313 |
+
],
|
314 |
+
'default_consent_required_message' => [
|
315 |
+
'label' => __( 'Consent Required Message', 'popup-maker' ),
|
316 |
+
'desc' => __( 'Message to show user who is already subscribed.', 'popup-maker' ),
|
317 |
+
'type' => 'text',
|
318 |
+
'std' => __( 'You must agree to continue.', 'popup-maker' ),
|
319 |
+
],
|
320 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
),
|
322 |
+
];
|
323 |
+
}
|
|
|
|
|
324 |
|
325 |
+
$fields = array_merge(
|
326 |
+
$fields,
|
327 |
+
[
|
328 |
+
'extensions' => [
|
329 |
+
'main' => [],
|
330 |
+
],
|
331 |
+
'licenses' => [
|
332 |
+
'main' => [],
|
333 |
+
],
|
334 |
+
'privacy' => [
|
335 |
+
'main' => [
|
336 |
+
'disable_popup_open_tracking' => [
|
337 |
+
'type' => 'checkbox',
|
338 |
+
'label' => __( 'Disables popup open tracking?', 'popup-maker' ),
|
339 |
+
'desc' => __( 'This will disable the built in analytics functionality.', 'popup-maker' ),
|
340 |
+
],
|
341 |
+
],
|
342 |
+
'forms' => [
|
343 |
+
'forms_disclaimer' => [
|
344 |
+
'type' => 'html',
|
345 |
+
'content' => '<strong>' . __( 'Disclaimer', 'popup-maker' ) . ':</strong> ' . __( 'These settings only pertain to usage of the Popup Maker built in subscription form shortcode, not 3rd party form plugins.', 'popup-maker' ),
|
346 |
+
],
|
347 |
+
'privacy_consent_always_enabled' => [
|
348 |
+
'label' => __( 'Always enable consent field on subscription forms.', 'popup-maker' ),
|
349 |
+
'type' => 'select',
|
350 |
+
'options' => [
|
351 |
+
'yes' => __( 'Yes', 'popup-maker' ),
|
352 |
+
'no' => __( 'No', 'popup-maker' ),
|
353 |
+
],
|
354 |
+
'std' => 'yes',
|
355 |
+
],
|
356 |
+
'default_privacy_consent_label' => [
|
357 |
+
'label' => __( 'Consent Text', 'popup-maker' ),
|
358 |
+
'type' => 'text',
|
359 |
+
'std' => __( 'Notify me about related content and special offers.', 'popup-maker' ),
|
360 |
+
'dependencies' => [
|
361 |
+
'privacy_consent_always_enabled' => 'yes',
|
362 |
+
],
|
363 |
+
],
|
364 |
+
'default_privacy_consent_type' => [
|
365 |
+
'label' => __( 'Consent Field Type', 'popup-maker' ),
|
366 |
+
'desc' => __( 'Radio forces the user to make a choice, often resulting in more opt-ins.', 'popup-maker' ),
|
367 |
+
'type' => 'select',
|
368 |
+
'options' => [
|
369 |
+
'radio' => __( 'Radio', 'popup-maker' ),
|
370 |
+
'checkbox' => __( 'Checkbox', 'popup-maker' ),
|
371 |
+
],
|
372 |
+
'std' => 'radio',
|
373 |
+
'dependencies' => [
|
374 |
+
'privacy_consent_always_enabled' => 'yes',
|
375 |
+
],
|
376 |
+
],
|
377 |
+
'default_privacy_consent_required' => [
|
378 |
+
'label' => __( 'Consent Required', 'popup-maker' ),
|
379 |
+
'type' => 'checkbox',
|
380 |
+
'std' => pum_get_option( 'default_privacy_consent_required' ),
|
381 |
+
'private' => true,
|
382 |
+
'dependencies' => [
|
383 |
+
'privacy_consent_always_enabled' => 'yes',
|
384 |
+
],
|
385 |
+
],
|
386 |
+
'default_privacy_consent_radio_layout' => [
|
387 |
+
'label' => __( 'Consent Radio Layout', 'popup-maker' ),
|
388 |
+
'type' => 'select',
|
389 |
+
'options' => [
|
390 |
+
'inline' => __( 'Inline', 'popup-maker' ),
|
391 |
+
'stacked' => __( 'Stacked', 'popup-maker' ),
|
392 |
+
],
|
393 |
+
'std' => __( 'Yes', 'popup-maker' ),
|
394 |
+
'dependencies' => [
|
395 |
+
'privacy_consent_always_enabled' => 'yes',
|
396 |
+
'default_privacy_consent_type' => 'radio',
|
397 |
+
],
|
398 |
+
],
|
399 |
+
'default_privacy_consent_yes_label' => [
|
400 |
+
'label' => __( 'Consent Yes Label', 'popup-maker' ),
|
401 |
+
'type' => 'text',
|
402 |
+
'std' => __( 'Yes', 'popup-maker' ),
|
403 |
+
'dependencies' => [
|
404 |
+
'privacy_consent_always_enabled' => 'yes',
|
405 |
+
'default_privacy_consent_type' => 'radio',
|
406 |
+
],
|
407 |
+
],
|
408 |
+
'default_privacy_consent_no_label' => [
|
409 |
+
'label' => __( 'Consent No Label', 'popup-maker' ),
|
410 |
+
'type' => 'text',
|
411 |
+
'std' => __( 'No', 'popup-maker' ),
|
412 |
+
'dependencies' => [
|
413 |
+
'privacy_consent_always_enabled' => 'yes',
|
414 |
+
'default_privacy_consent_type' => 'radio',
|
415 |
+
],
|
416 |
+
],
|
417 |
+
'default_privacy_usage_text' => [
|
418 |
+
'label' => __( 'Consent Usage Text', 'popup-maker' ),
|
419 |
+
'desc' => function_exists( 'get_privacy_policy_url' ) ? sprintf( __( 'You can use %1$s%2$s to insert a link to your privacy policy. To customize the link text use %1$s:Link Text%2$s', 'popup-maker' ), '{{privacy_link', '}}' ) : '',
|
420 |
+
'type' => 'text',
|
421 |
+
'std' => __( 'If you opt in above we use this information send related content, discounts and other special offers.', 'popup-maker' ),
|
422 |
+
'dependencies' => [
|
423 |
+
'privacy_consent_always_enabled' => 'yes',
|
424 |
+
],
|
425 |
+
],
|
426 |
+
],
|
427 |
+
],
|
428 |
+
|
429 |
+
'misc' => [
|
430 |
+
'main' => [
|
431 |
+
|
432 |
+
'bypass_adblockers' => [
|
433 |
+
'label' => __( 'Try to bypass ad blockers.', 'popup-maker' ),
|
434 |
+
'type' => 'checkbox',
|
435 |
+
],
|
436 |
+
'adblock_bypass_url_method' => [
|
437 |
+
'label' => __( 'Ad blocker: Naming method', 'popup-maker' ),
|
438 |
+
'desc' => __( 'This will help generate unique names for our JavaScript files and the analytics routes.', 'popup-maker' ),
|
439 |
+
'type' => 'select',
|
440 |
+
'options' => [
|
441 |
+
'random' => __( 'Randomize Names', 'popup-maker' ),
|
442 |
+
'custom' => __( 'Custom Names', 'popup-maker' ),
|
443 |
+
],
|
444 |
+
'std' => 'random',
|
445 |
+
'dependencies' => [
|
446 |
+
'bypass_adblockers' => true,
|
447 |
+
],
|
448 |
+
],
|
449 |
+
'adblock_bypass_custom_filename' => [
|
450 |
+
'type' => 'text',
|
451 |
+
'placeholder' => 'my-awesome-popups',
|
452 |
+
'label' => __( 'Ad blocker: Custom Name', 'popup-maker' ),
|
453 |
+
'desc' => __( 'A custom & recognizable name to use for our assets.', 'popup-maker' ),
|
454 |
+
'dependencies' => [
|
455 |
+
'bypass_adblockers' => true,
|
456 |
+
'adblock_bypass_url_method' => 'custom',
|
457 |
+
],
|
458 |
+
],
|
459 |
+
'adjust_body_padding' => [
|
460 |
+
'type' => 'checkbox',
|
461 |
+
'label' => __( 'Adjust the right padding added to the body when popups are shown with an overlay.', 'popup-maker' ),
|
462 |
+
'desc' => sprintf(
|
463 |
+
/* translators: 1 & 2 are opening and closing HTML of the link around "Learn more" */
|
464 |
+
esc_html__( 'Use this if your popups "jump" or "shift" when opened. %1$sLearn more%2$s', 'popup-maker' ),
|
465 |
+
'<a target="_blank" rel="noreferrer noopener" href="https://docs.wppopupmaker.com/article/314-why-does-my-site-shift-jump-or-skip-when-a-popup-is-triggered?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=settings-page&utm_content=adjust-right-padding">',
|
466 |
+
'</a>'
|
467 |
+
),
|
468 |
+
],
|
469 |
+
'body_padding_override' => [
|
470 |
+
'type' => 'text',
|
471 |
+
'placeholder' => '15px',
|
472 |
+
'label' => __( 'Body Padding Override', 'popup-maker' ),
|
473 |
+
'dependencies' => [
|
474 |
+
'adjust_body_padding' => true,
|
475 |
+
],
|
476 |
+
'std' => '15px',
|
477 |
+
],
|
478 |
+
'disabled_admin_bar' => [
|
479 |
+
'type' => 'checkbox',
|
480 |
+
'label' => __( 'Disable Popups Admin Bar', 'popup-maker' ),
|
481 |
+
'desc' => __( 'This will disable the admin Popups menu item.', 'popup-maker' ),
|
482 |
+
],
|
483 |
+
'debug_mode' => [
|
484 |
+
'type' => 'checkbox',
|
485 |
+
'label' => __( 'Enable Debug Mode', 'popup-maker' ),
|
486 |
+
'desc' => __( 'This will turn on multiple debug tools used to quickly find issues.', 'popup-maker' ),
|
487 |
+
],
|
488 |
+
'enable_easy_modal_compatibility_mode' => [
|
489 |
+
'type' => 'checkbox',
|
490 |
+
'label' => __( 'Enable Easy Modal v2 Compatibility Mode', 'popup-maker' ),
|
491 |
+
'desc' => __( 'This will automatically make any eModal classes you have added to your site launch the appropriate Popup after import.', 'popup-maker' ),
|
492 |
+
],
|
493 |
+
'disable_popup_category_tag' => [
|
494 |
+
'type' => 'checkbox',
|
495 |
+
'label' => __( 'Disable categories & tags?', 'popup-maker' ),
|
496 |
+
'desc' => __( 'This will disable the popup tags & categories.', 'popup-maker' ),
|
497 |
+
],
|
498 |
+
'disable_asset_caching' => [
|
499 |
+
'type' => 'checkbox',
|
500 |
+
'label' => __( 'Disable asset caching.', 'popup-maker' ),
|
501 |
+
'desc' => __( 'By default Popup Maker caches a single JS & CSS file in your Uploads folder. These files include core, extension & user customized styles & scripts in a single set of files.', 'popup-maker' ),
|
502 |
+
],
|
503 |
+
'disable_shortcode_ui' => [
|
504 |
+
'type' => 'checkbox',
|
505 |
+
'label' => __( 'Disable the Popup Maker shortcode button', 'popup-maker' ),
|
506 |
+
],
|
507 |
+
'disable_tips' => [
|
508 |
+
'type' => 'checkbox',
|
509 |
+
'label' => __( 'Disable Popup Maker occasionally showing random tips to improve your popups.', 'popup-maker' ),
|
510 |
+
],
|
511 |
+
'complete_uninstall' => [
|
512 |
+
'type' => 'checkbox',
|
513 |
+
'label' => __( 'Delete all Popup Maker data on deactivation', 'popup-maker' ),
|
514 |
+
'desc' => __( 'Check this to completely uninstall Popup Maker.', 'popup-maker' ),
|
515 |
+
'priority' => 1000,
|
516 |
+
],
|
517 |
+
],
|
518 |
+
'assets' => [
|
519 |
+
'disable_google_font_loading' => [
|
520 |
+
'type' => 'checkbox',
|
521 |
+
'label' => __( "Don't Load Google Fonts", 'popup-maker' ),
|
522 |
+
'desc' => __( 'Check this disable loading of google fonts, useful if the fonts you chose are already loaded with your theme.', 'popup-maker' ),
|
523 |
+
],
|
524 |
+
'disable_popup_maker_core_styles' => [
|
525 |
+
'type' => 'checkbox',
|
526 |
+
'label' => __( 'Don\'t load Popup Maker core stylesheet.', 'popup-maker' ),
|
527 |
+
'desc' => __( 'Check this if you have copied the Popup Maker core styles to your own stylesheet or are using custom styles.', 'popup-maker' ),
|
528 |
+
],
|
529 |
+
'disable_popup_theme_styles' => [
|
530 |
+
'type' => 'checkbox',
|
531 |
+
'label' => __( 'Don\'t load popup theme styles to the head.', 'popup-maker' ),
|
532 |
+
'desc' => __( 'Check this if you have copied the popup theme styles to your own stylesheet or are using custom styles.', 'popup-maker' ),
|
533 |
+
],
|
534 |
+
'output_pum_styles' => [
|
535 |
+
'id' => 'output_pum_styles',
|
536 |
+
'type' => 'html',
|
537 |
+
'content' => self::field_pum_styles(),
|
538 |
+
],
|
539 |
+
],
|
540 |
+
],
|
541 |
+
]
|
542 |
+
);
|
543 |
|
544 |
$fields = apply_filters( 'pum_settings_fields', $fields );
|
545 |
|
546 |
+
$fields = PUM_Admin_Helpers::parse_tab_fields(
|
547 |
+
$fields,
|
548 |
+
[
|
549 |
+
'has_subtabs' => true,
|
550 |
+
'name' => 'pum_settings[%s]',
|
551 |
+
]
|
552 |
+
);
|
553 |
}
|
554 |
|
555 |
return $fields;
|
559 |
* @return string
|
560 |
*/
|
561 |
public static function field_pum_styles() {
|
562 |
+
$core_styles = file_get_contents( Popup_Maker::$DIR . 'assets/css/pum-site' . ( is_rtl() ? '-rtl' : '' ) . PUM_Site_Assets::$suffix . '.css' );
|
563 |
|
564 |
$user_styles = PUM_AssetCache::generate_font_imports() . PUM_AssetCache::generate_popup_theme_styles() . PUM_AssetCache::generate_popup_styles();
|
565 |
|
593 |
public static function user_role_options() {
|
594 |
global $wp_roles;
|
595 |
|
596 |
+
$options = [];
|
597 |
foreach ( $wp_roles->roles as $role => $labels ) {
|
598 |
$options[ $role ] = $labels['name'];
|
599 |
}
|
622 |
<h1><?php _e( 'Popup Maker Settings', 'popup-maker' ); ?></h1>
|
623 |
<div id="pum-settings-container" class="pum-settings-container">
|
624 |
<div class="pum-no-js" style="padding: 0 12px;">
|
625 |
+
<p><?php printf( __( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %1$sView troubleshooting guide%2$s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
626 |
</div>
|
627 |
</div>
|
628 |
|
629 |
<script type="text/javascript">
|
630 |
+
window.pum_settings_editor =
|
631 |
+
<?php
|
632 |
+
echo PUM_Utils_Array::safe_json_encode(
|
633 |
+
apply_filters(
|
634 |
+
'pum_settings_editor_args',
|
635 |
+
[
|
636 |
+
'form_args' => [
|
637 |
+
'id' => 'pum-settings',
|
638 |
+
'tabs' => self::tabs(),
|
639 |
+
'sections' => self::sections(),
|
640 |
+
'fields' => self::fields(),
|
641 |
+
'maintabs' => [
|
642 |
+
'meta' => [
|
643 |
+
'data-min-height' => 0,
|
644 |
+
],
|
645 |
+
],
|
646 |
+
],
|
647 |
+
'active_tab' => self::get_active_tab(),
|
648 |
+
'active_section' => self::get_active_section(),
|
649 |
+
'current_values' => self::parse_values( $settings ),
|
650 |
+
]
|
651 |
+
)
|
652 |
+
);
|
653 |
+
?>
|
654 |
+
;
|
655 |
</script>
|
656 |
|
657 |
<button class="button-primary bottom" style="margin-left: 156px;"><?php _e( 'Save', 'popup-maker' ); ?></button>
|
669 |
public static function defaults() {
|
670 |
$tabs = self::fields();
|
671 |
|
672 |
+
$defaults = [];
|
673 |
|
674 |
foreach ( $tabs as $section_id => $fields ) {
|
675 |
foreach ( $fields as $key => $field ) {
|
689 |
static $tabs;
|
690 |
|
691 |
if ( ! isset( $tabs ) ) {
|
692 |
+
$tabs = apply_filters(
|
693 |
+
'pum_settings_tabs',
|
694 |
+
[
|
695 |
+
'general' => __( 'General', 'popup-maker' ),
|
696 |
+
'subscriptions' => __( 'Subscriptions', 'popup-maker' ),
|
697 |
+
'extensions' => __( 'Extensions', 'popup-maker' ),
|
698 |
+
'licenses' => __( 'Licenses', 'popup-maker' ),
|
699 |
+
'privacy' => __( 'Privacy', 'popup-maker' ),
|
700 |
+
'misc' => __( 'Misc', 'popup-maker' ),
|
701 |
+
]
|
702 |
+
);
|
703 |
|
704 |
/** @deprecated 1.7.0 */
|
705 |
$tabs = apply_filters( 'popmake_settings_tabs', $tabs );
|
706 |
}
|
707 |
|
|
|
708 |
return $tabs;
|
709 |
}
|
710 |
|
714 |
* @return array
|
715 |
*/
|
716 |
public static function sections() {
|
717 |
+
return apply_filters(
|
718 |
+
'pum_settings_tab_sections',
|
719 |
+
[
|
720 |
+
'general' => [
|
721 |
+
'main' => __( 'General', 'popup-maker' ),
|
722 |
+
],
|
723 |
+
'subscriptions' => [
|
724 |
+
'main' => __( 'General', 'popup-maker' ),
|
725 |
+
],
|
726 |
+
'extensions' => [
|
727 |
+
'main' => __( 'Extension Settings', 'popup-maker' ),
|
728 |
+
],
|
729 |
+
'licenses' => [
|
730 |
+
'main' => __( 'Licenses', 'popup-maker' ),
|
731 |
+
],
|
732 |
+
'privacy' => [
|
733 |
+
'main' => __( 'General', 'popup-maker' ),
|
734 |
+
'forms' => __( 'Subscription Forms', 'popup-maker' ),
|
735 |
+
],
|
736 |
+
'misc' => [
|
737 |
+
'main' => __( 'Misc', 'popup-maker' ),
|
738 |
+
'assets' => __( 'Assets', 'popup-maker' ),
|
739 |
+
],
|
740 |
+
]
|
741 |
+
);
|
742 |
}
|
743 |
|
744 |
/**
|
780 |
foreach ( $settings as $key => $value ) {
|
781 |
$field = self::get_field( $key );
|
782 |
|
|
|
783 |
if ( $field ) {
|
784 |
|
785 |
/**
|
791 |
case 'license_key':
|
792 |
$license = get_option( $field['options']['is_valid_license_option'] );
|
793 |
|
794 |
+
$settings[ $key ] = [
|
795 |
'key' => trim( $value ),
|
796 |
'status' => PUM_Licensing::get_status( $license, ! empty( $value ) ),
|
797 |
'messages' => PUM_Licensing::get_status_messages( $license, trim( $value ) ),
|
798 |
'expires' => PUM_Licensing::get_license_expiration( $license ),
|
799 |
'classes' => PUM_Licensing::get_status_classes( $license ),
|
800 |
+
];
|
801 |
break;
|
802 |
}
|
803 |
|
811 |
break;
|
812 |
*/
|
813 |
}
|
|
|
814 |
}
|
815 |
}
|
816 |
|
829 |
*
|
830 |
* @return array
|
831 |
*/
|
832 |
+
public static function sanitize_objects( $meta = [] ) {
|
833 |
if ( ! empty( $meta ) ) {
|
834 |
|
835 |
foreach ( $meta as $key => $value ) {
|
classes/Admin/Shortcode/UI.php
CHANGED
@@ -29,7 +29,7 @@ class PUM_Admin_Shortcode_UI {
|
|
29 |
|
30 |
public static function init() {
|
31 |
if ( ! self::$initialized ) {
|
32 |
-
add_action( 'admin_init',
|
33 |
self::$initialized = true;
|
34 |
}
|
35 |
}
|
@@ -60,15 +60,15 @@ class PUM_Admin_Shortcode_UI {
|
|
60 |
}
|
61 |
|
62 |
// Add shortcode ui button & js.
|
63 |
-
add_filter( 'mce_buttons',
|
64 |
-
add_filter( 'mce_external_plugins',
|
65 |
|
66 |
// Add core site styles for form previews.
|
67 |
add_editor_style( Popup_Maker::$URL . 'assets/css/pum-site.min.css' );
|
68 |
|
69 |
// Process live previews.
|
70 |
-
add_action( 'wp_ajax_pum_do_shortcode',
|
71 |
-
//add_action( 'wp_ajax_pum_do_shortcode', array( __CLASS__, 'wp_ajax_pum_do_shortcode' ) );
|
72 |
}
|
73 |
|
74 |
/**
|
@@ -82,7 +82,7 @@ class PUM_Admin_Shortcode_UI {
|
|
82 |
// Enqueue scripts when editor is detected.
|
83 |
|
84 |
if ( ! did_action( 'admin_enqueue_scripts' ) ) {
|
85 |
-
add_action( 'admin_enqueue_scripts',
|
86 |
} else {
|
87 |
self::enqueue_scripts();
|
88 |
}
|
@@ -101,16 +101,23 @@ class PUM_Admin_Shortcode_UI {
|
|
101 |
|
102 |
wp_enqueue_style( 'pum-admin-shortcode-ui' );
|
103 |
wp_enqueue_script( 'pum-admin-shortcode-ui' );
|
104 |
-
wp_localize_script(
|
105 |
-
'
|
106 |
-
'
|
107 |
-
|
108 |
-
'
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
/**
|
@@ -121,7 +128,7 @@ class PUM_Admin_Shortcode_UI {
|
|
121 |
public static function shortcode_ui_var() {
|
122 |
$type = pum_typenow();
|
123 |
|
124 |
-
$shortcodes =
|
125 |
|
126 |
foreach ( PUM_Shortcodes::instance()->get_shortcodes() as $tag => $shortcode ) {
|
127 |
|
@@ -134,16 +141,16 @@ class PUM_Admin_Shortcode_UI {
|
|
134 |
continue;
|
135 |
}
|
136 |
|
137 |
-
$shortcodes[ $tag ] =
|
138 |
'version' => $shortcode->version,
|
139 |
'label' => $shortcode->label(),
|
140 |
'description' => $shortcode->description(),
|
141 |
'tabs' => $shortcode->_tabs(),
|
142 |
-
'sections'
|
143 |
'fields' => $shortcode->_fields(),
|
144 |
'has_content' => $shortcode->has_content,
|
145 |
'ajax_rendering' => $shortcode->ajax_rendering === true,
|
146 |
-
|
147 |
}
|
148 |
|
149 |
return $shortcodes;
|
@@ -157,9 +164,12 @@ class PUM_Admin_Shortcode_UI {
|
|
157 |
* @return array
|
158 |
*/
|
159 |
public static function mce_external_plugins( $plugin_array ) {
|
160 |
-
return array_merge(
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
public static function do_shortcode() {
|
@@ -171,7 +181,7 @@ class PUM_Admin_Shortcode_UI {
|
|
171 |
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : null;
|
172 |
|
173 |
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
174 |
-
return esc_html__(
|
175 |
}
|
176 |
|
177 |
/** @var PUM_Shortcode $shortcode */
|
@@ -199,7 +209,7 @@ class PUM_Admin_Shortcode_UI {
|
|
199 |
}
|
200 |
|
201 |
/** Generate inline styles when needed. */
|
202 |
-
$styles =
|
203 |
|
204 |
wp_send_json_success( $styles . $content );
|
205 |
}
|
29 |
|
30 |
public static function init() {
|
31 |
if ( ! self::$initialized ) {
|
32 |
+
add_action( 'admin_init', [ __CLASS__, 'init_editor' ], 20 );
|
33 |
self::$initialized = true;
|
34 |
}
|
35 |
}
|
60 |
}
|
61 |
|
62 |
// Add shortcode ui button & js.
|
63 |
+
add_filter( 'mce_buttons', [ __CLASS__, 'mce_buttons' ] );
|
64 |
+
add_filter( 'mce_external_plugins', [ __CLASS__, 'mce_external_plugins' ] );
|
65 |
|
66 |
// Add core site styles for form previews.
|
67 |
add_editor_style( Popup_Maker::$URL . 'assets/css/pum-site.min.css' );
|
68 |
|
69 |
// Process live previews.
|
70 |
+
add_action( 'wp_ajax_pum_do_shortcode', [ __CLASS__, 'do_shortcode' ] );
|
71 |
+
// add_action( 'wp_ajax_pum_do_shortcode', array( __CLASS__, 'wp_ajax_pum_do_shortcode' ) );
|
72 |
}
|
73 |
|
74 |
/**
|
82 |
// Enqueue scripts when editor is detected.
|
83 |
|
84 |
if ( ! did_action( 'admin_enqueue_scripts' ) ) {
|
85 |
+
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_scripts' ], 120 ); // 120 because core styles are registered at 100 for some reason.
|
86 |
} else {
|
87 |
self::enqueue_scripts();
|
88 |
}
|
101 |
|
102 |
wp_enqueue_style( 'pum-admin-shortcode-ui' );
|
103 |
wp_enqueue_script( 'pum-admin-shortcode-ui' );
|
104 |
+
wp_localize_script(
|
105 |
+
'pum-admin-shortcode-ui',
|
106 |
+
'pum_shortcode_ui_vars',
|
107 |
+
apply_filters(
|
108 |
+
'pum_shortcode_ui_vars',
|
109 |
+
[
|
110 |
+
'nonce' => wp_create_nonce( 'pum-shortcode-ui-nonce' ),
|
111 |
+
'I10n' => [
|
112 |
+
'insert' => __( 'Insert', 'popup-maker' ),
|
113 |
+
'cancel' => __( 'Cancel', 'popup-maker' ),
|
114 |
+
'shortcode_ui_button_tooltip' => __( 'Popup Maker Shortcodes', 'popup-maker' ),
|
115 |
+
'error_loading_shortcode_preview' => __( 'There was an error in generating the preview', 'popup-maker' ),
|
116 |
+
],
|
117 |
+
'shortcodes' => self::shortcode_ui_var(),
|
118 |
+
]
|
119 |
+
)
|
120 |
+
);
|
121 |
}
|
122 |
|
123 |
/**
|
128 |
public static function shortcode_ui_var() {
|
129 |
$type = pum_typenow();
|
130 |
|
131 |
+
$shortcodes = [];
|
132 |
|
133 |
foreach ( PUM_Shortcodes::instance()->get_shortcodes() as $tag => $shortcode ) {
|
134 |
|
141 |
continue;
|
142 |
}
|
143 |
|
144 |
+
$shortcodes[ $tag ] = [
|
145 |
'version' => $shortcode->version,
|
146 |
'label' => $shortcode->label(),
|
147 |
'description' => $shortcode->description(),
|
148 |
'tabs' => $shortcode->_tabs(),
|
149 |
+
'sections' => $shortcode->_subtabs(),
|
150 |
'fields' => $shortcode->_fields(),
|
151 |
'has_content' => $shortcode->has_content,
|
152 |
'ajax_rendering' => $shortcode->ajax_rendering === true,
|
153 |
+
];
|
154 |
}
|
155 |
|
156 |
return $shortcodes;
|
164 |
* @return array
|
165 |
*/
|
166 |
public static function mce_external_plugins( $plugin_array ) {
|
167 |
+
return array_merge(
|
168 |
+
$plugin_array,
|
169 |
+
[
|
170 |
+
'pum_shortcodes' => add_query_arg( [ 'version' => Popup_Maker::$VER ], PUM_Admin_Assets::$js_url . 'mce-buttons' . PUM_Admin_Assets::$suffix . '.js' ),
|
171 |
+
]
|
172 |
+
);
|
173 |
}
|
174 |
|
175 |
public static function do_shortcode() {
|
181 |
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : null;
|
182 |
|
183 |
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
184 |
+
return esc_html__( 'You do not have access to preview this post.', 'popup-maker' );
|
185 |
}
|
186 |
|
187 |
/** @var PUM_Shortcode $shortcode */
|
209 |
}
|
210 |
|
211 |
/** Generate inline styles when needed. */
|
212 |
+
$styles = '<style>' . $shortcode_object->get_template_styles() . '</style>';
|
213 |
|
214 |
wp_send_json_success( $styles . $content );
|
215 |
}
|
classes/Admin/Subscribers.php
CHANGED
@@ -16,8 +16,8 @@ class PUM_Admin_Subscribers {
|
|
16 |
*
|
17 |
*/
|
18 |
public static function init() {
|
19 |
-
add_action( 'admin_menu',
|
20 |
-
add_filter( 'set-screen-option',
|
21 |
}
|
22 |
|
23 |
/**
|
@@ -59,15 +59,18 @@ class PUM_Admin_Subscribers {
|
|
59 |
}
|
60 |
|
61 |
public static function after_page_registration() {
|
62 |
-
add_action( 'load-' . PUM_Admin_Pages::$pages['subscribers'],
|
63 |
}
|
64 |
|
65 |
public static function load_user_list_table_screen_options() {
|
66 |
-
add_screen_option(
|
67 |
-
'
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
71 |
|
72 |
/*
|
73 |
* Instantiate the User List Table. Creating an instance here will allow the core WP_List_Table class to automatically
|
16 |
*
|
17 |
*/
|
18 |
public static function init() {
|
19 |
+
add_action( 'admin_menu', [ __CLASS__, 'after_page_registration' ], 11 );
|
20 |
+
add_filter( 'set-screen-option', [ __CLASS__, 'set_option' ], 10, 3 );
|
21 |
}
|
22 |
|
23 |
/**
|
59 |
}
|
60 |
|
61 |
public static function after_page_registration() {
|
62 |
+
add_action( 'load-' . PUM_Admin_Pages::$pages['subscribers'], [ 'PUM_Admin_Subscribers', 'load_user_list_table_screen_options' ] );
|
63 |
}
|
64 |
|
65 |
public static function load_user_list_table_screen_options() {
|
66 |
+
add_screen_option(
|
67 |
+
'per_page',
|
68 |
+
[
|
69 |
+
'label' => __( 'Subscribers Per Page', 'popup-maker' ),
|
70 |
+
'default' => 20,
|
71 |
+
'option' => 'pum_subscribers_per_page',
|
72 |
+
]
|
73 |
+
);
|
74 |
|
75 |
/*
|
76 |
* Instantiate the User List Table. Creating an instance here will allow the core WP_List_Table class to automatically
|
classes/Admin/Subscribers/Table.php
CHANGED
@@ -35,12 +35,15 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
35 |
* Default null.
|
36 |
* }
|
37 |
*/
|
38 |
-
public function __construct( $args =
|
39 |
-
$args = wp_parse_args(
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
parent::__construct( $args );
|
46 |
}
|
@@ -58,23 +61,25 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
58 |
|
59 |
$limit = $this->get_items_per_page( 'pum_subscribers_per_page' );
|
60 |
|
61 |
-
$query_args =
|
62 |
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
63 |
'limit' => $limit,
|
64 |
'page' => $this->get_pagenum(),
|
65 |
'orderby' => isset( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : null,
|
66 |
'order' => isset( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : null,
|
67 |
-
|
68 |
|
69 |
$this->items = PUM_DB_Subscribers::instance()->query( $query_args, 'ARRAY_A' );
|
70 |
|
71 |
$total_subscribers = PUM_DB_Subscribers::instance()->total_rows( $query_args );
|
72 |
|
73 |
-
$this->set_pagination_args(
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
}
|
79 |
|
80 |
|
@@ -85,16 +90,19 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
85 |
* @return array
|
86 |
*/
|
87 |
public function get_columns() {
|
88 |
-
return apply_filters(
|
89 |
-
'
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -109,13 +117,16 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
109 |
* @return array
|
110 |
*/
|
111 |
protected function get_sortable_columns() {
|
112 |
-
return apply_filters(
|
113 |
-
'
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
@@ -180,7 +191,6 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
180 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
181 |
* will need to generate the URLs yourself. You could even ensure the links
|
182 |
*
|
183 |
-
*
|
184 |
* @see WP_List_Table::::single_row_columns()
|
185 |
*
|
186 |
* @param array $item A singular item (one full row's worth of data)
|
@@ -189,31 +199,42 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
189 |
**************************************************************************/
|
190 |
function column_email( $item ) {
|
191 |
|
192 |
-
$url = add_query_arg(
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
197 |
|
198 |
-
$edit_url = add_query_arg(
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
-
$delete_url = add_query_arg(
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
205 |
|
206 |
-
//Build row actions
|
207 |
-
$actions =
|
208 |
-
//'edit' => sprintf( '<a href="%s">Edit</a>', $edit_url ),
|
209 |
'delete' => sprintf( '<a href="%s">Delete</a>', $delete_url ),
|
210 |
-
|
211 |
|
212 |
-
//Return the title contents
|
213 |
-
return sprintf(
|
|
|
214 |
$item['email'], /*$2%s*/
|
215 |
$item['ID'], /*$3%s*/
|
216 |
-
$this->row_actions( $actions )
|
|
|
217 |
}
|
218 |
|
219 |
|
@@ -228,7 +249,6 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
228 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
229 |
* will need to generate the URLs yourself. You could even ensure the links
|
230 |
*
|
231 |
-
*
|
232 |
* @see WP_List_Table::::single_row_columns()
|
233 |
*
|
234 |
* @param array $item A singular item (one full row's worth of data)
|
@@ -241,7 +261,7 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
241 |
if ( $user_id ) {
|
242 |
$url = admin_url( "user-edit.php?user_id=$user_id" );
|
243 |
|
244 |
-
//Return the title contents
|
245 |
return sprintf( '%s<br/><small style="color:silver">(%s: <a href="%s">#%s</a>)</small>', $item['name'], __( 'User ID', 'popup-maker' ), $url, $item['user_id'] );
|
246 |
} else {
|
247 |
return $item['name'];
|
@@ -260,7 +280,6 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
260 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
261 |
* will need to generate the URLs yourself. You could even ensure the links
|
262 |
*
|
263 |
-
*
|
264 |
* @see WP_List_Table::::single_row_columns()
|
265 |
*
|
266 |
* @param array $item A singular item (one full row's worth of data)
|
@@ -273,9 +292,9 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
273 |
$popup = pum_get_popup( $popup_id );
|
274 |
|
275 |
if ( $popup_id && pum_is_popup( $popup ) ) {
|
276 |
-
$url = admin_url( "post.php?post={$popup_id}&action=edit" )
|
277 |
|
278 |
-
//Return the title contents
|
279 |
return sprintf( '%s<br/><small style="color:silver">(%s: <a href="%s">#%s</a>)</small>', $popup->post_title, __( 'ID', 'popup-maker' ), $url, $item['popup_id'] );
|
280 |
} else {
|
281 |
return __( 'N/A', 'popup-maker' );
|
@@ -295,9 +314,9 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
295 |
*
|
296 |
* action and action2 are set based on the triggers above or below the table
|
297 |
*/
|
298 |
-
$actions =
|
299 |
'bulk-delete' => __( 'Delete', 'popup-maker' ),
|
300 |
-
|
301 |
|
302 |
return $actions;
|
303 |
}
|
@@ -306,69 +325,82 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
306 |
* Process actions triggered by the user
|
307 |
*
|
308 |
* @since 1.0.0
|
309 |
-
*
|
310 |
*/
|
311 |
public function handle_table_actions() {
|
312 |
|
313 |
-
//Detect when a bulk action is being triggered...
|
314 |
$action1 = $this->current_action();
|
315 |
|
316 |
-
if ( in_array( $action1,
|
317 |
|
318 |
// verify the nonce.
|
319 |
if ( ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), $action1 == 'delete' ? 'pum_subscribers_table_action_nonce' : 'bulk-subscribers' ) ) {
|
320 |
$this->invalid_nonce_redirect();
|
321 |
} else {
|
322 |
|
323 |
-
$subscribers = isset( $_REQUEST['subscriber'] ) ? $_REQUEST['subscriber'] :
|
324 |
|
325 |
if ( is_numeric( $subscribers ) ) {
|
326 |
-
$subscribers =
|
327 |
}
|
328 |
|
329 |
$subscribers = wp_parse_id_list( $subscribers );
|
330 |
|
331 |
if ( $subscribers ) {
|
332 |
|
333 |
-
$status =
|
334 |
|
335 |
foreach ( $subscribers as $subscriber_id ) {
|
336 |
$status[] = PUM_DB_Subscribers::instance()->delete( $subscriber_id );
|
337 |
}
|
338 |
|
339 |
if ( ! in_array( false, $status ) ) {
|
340 |
-
wp_die(
|
341 |
-
'
|
342 |
-
'
|
343 |
-
|
|
|
|
|
|
|
|
|
344 |
} else {
|
345 |
$succeeded = count( array_filter( $status ) );
|
346 |
$failed = count( $subscribers ) - $succeeded;
|
347 |
|
348 |
if ( count( $subscribers ) == 1 ) {
|
349 |
-
wp_die(
|
350 |
-
'
|
351 |
-
'
|
352 |
-
|
|
|
|
|
|
|
|
|
353 |
|
354 |
} else {
|
355 |
-
wp_die(
|
356 |
-
'
|
357 |
-
'
|
358 |
-
|
|
|
|
|
|
|
|
|
359 |
}
|
360 |
-
|
361 |
}
|
362 |
}
|
363 |
|
364 |
-
wp_die(
|
365 |
-
'
|
366 |
-
'
|
367 |
-
|
|
|
|
|
|
|
|
|
368 |
|
369 |
exit;
|
370 |
}
|
371 |
-
|
372 |
}
|
373 |
|
374 |
/*
|
@@ -427,10 +459,14 @@ class PUM_Admin_Subscribers_Table extends PUM_ListTable {
|
|
427 |
* Die when the nonce check fails.
|
428 |
*/
|
429 |
public function invalid_nonce_redirect() {
|
430 |
-
wp_die(
|
431 |
-
'
|
432 |
-
'
|
433 |
-
|
|
|
|
|
|
|
|
|
434 |
}
|
435 |
}
|
436 |
|
35 |
* Default null.
|
36 |
* }
|
37 |
*/
|
38 |
+
public function __construct( $args = [] ) {
|
39 |
+
$args = wp_parse_args(
|
40 |
+
$args,
|
41 |
+
[
|
42 |
+
'plural' => 'subscribers', // Plural value used for labels and the objects being listed.
|
43 |
+
'singular' => 'subscriber', // Singular label for an object being listed, e.g. 'post'.
|
44 |
+
'ajax' => false, // If true, the parent class will call the _js_vars() method in the footer
|
45 |
+
]
|
46 |
+
);
|
47 |
|
48 |
parent::__construct( $args );
|
49 |
}
|
61 |
|
62 |
$limit = $this->get_items_per_page( 'pum_subscribers_per_page' );
|
63 |
|
64 |
+
$query_args = [
|
65 |
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null,
|
66 |
'limit' => $limit,
|
67 |
'page' => $this->get_pagenum(),
|
68 |
'orderby' => isset( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : null,
|
69 |
'order' => isset( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : null,
|
70 |
+
];
|
71 |
|
72 |
$this->items = PUM_DB_Subscribers::instance()->query( $query_args, 'ARRAY_A' );
|
73 |
|
74 |
$total_subscribers = PUM_DB_Subscribers::instance()->total_rows( $query_args );
|
75 |
|
76 |
+
$this->set_pagination_args(
|
77 |
+
[
|
78 |
+
'total_items' => $total_subscribers,
|
79 |
+
'per_page' => $limit,
|
80 |
+
'total_pages' => ceil( $total_subscribers / $limit ),
|
81 |
+
]
|
82 |
+
);
|
83 |
}
|
84 |
|
85 |
|
90 |
* @return array
|
91 |
*/
|
92 |
public function get_columns() {
|
93 |
+
return apply_filters(
|
94 |
+
'pum_subscribers_table_columns',
|
95 |
+
[
|
96 |
+
'cb' => '<input type="checkbox" />', // to display the checkbox.
|
97 |
+
'email' => __( 'Email', 'popup-maker' ),
|
98 |
+
'name' => __( 'Full Name', 'popup-maker' ),
|
99 |
+
'fname' => __( 'First Name', 'popup-maker' ),
|
100 |
+
'lname' => __( 'Last Name', 'popup-maker' ),
|
101 |
+
'popup_id' => __( 'Popup', 'popup-maker' ),
|
102 |
+
// 'user_id' => __( 'User ID', 'popup-maker' ),
|
103 |
+
'created' => _x( 'Subscribed On', 'column name', 'popup-maker' ),
|
104 |
+
]
|
105 |
+
);
|
106 |
}
|
107 |
|
108 |
/**
|
117 |
* @return array
|
118 |
*/
|
119 |
protected function get_sortable_columns() {
|
120 |
+
return apply_filters(
|
121 |
+
'pum_subscribers_table_columns',
|
122 |
+
[
|
123 |
+
'email' => 'email',
|
124 |
+
'fname' => 'fname',
|
125 |
+
'lname' => 'lname',
|
126 |
+
'popup_id' => 'popup_id',
|
127 |
+
'created' => 'created',
|
128 |
+
]
|
129 |
+
);
|
130 |
}
|
131 |
|
132 |
/**
|
191 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
192 |
* will need to generate the URLs yourself. You could even ensure the links
|
193 |
*
|
|
|
194 |
* @see WP_List_Table::::single_row_columns()
|
195 |
*
|
196 |
* @param array $item A singular item (one full row's worth of data)
|
199 |
**************************************************************************/
|
200 |
function column_email( $item ) {
|
201 |
|
202 |
+
$url = add_query_arg(
|
203 |
+
[
|
204 |
+
'page' => $_REQUEST['page'],
|
205 |
+
'subscriber' => $item['ID'],
|
206 |
+
'_wpnonce' => wp_create_nonce( 'pum_subscribers_table_action_nonce' ),
|
207 |
+
],
|
208 |
+
admin_url( 'edit.php?page=pum-subscribers&post_type=popup' )
|
209 |
+
);
|
210 |
|
211 |
+
$edit_url = add_query_arg(
|
212 |
+
[
|
213 |
+
'action' => 'edit',
|
214 |
+
],
|
215 |
+
$url
|
216 |
+
);
|
217 |
|
218 |
+
$delete_url = add_query_arg(
|
219 |
+
[
|
220 |
+
'action' => 'delete',
|
221 |
+
],
|
222 |
+
$url
|
223 |
+
);
|
224 |
|
225 |
+
// Build row actions
|
226 |
+
$actions = [
|
227 |
+
// 'edit' => sprintf( '<a href="%s">Edit</a>', $edit_url ),
|
228 |
'delete' => sprintf( '<a href="%s">Delete</a>', $delete_url ),
|
229 |
+
];
|
230 |
|
231 |
+
// Return the title contents
|
232 |
+
return sprintf(
|
233 |
+
'%1$s <span style="color:silver">(id:%2$s)</span>%3$s', /*$1%s*/
|
234 |
$item['email'], /*$2%s*/
|
235 |
$item['ID'], /*$3%s*/
|
236 |
+
$this->row_actions( $actions )
|
237 |
+
);
|
238 |
}
|
239 |
|
240 |
|
249 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
250 |
* will need to generate the URLs yourself. You could even ensure the links
|
251 |
*
|
|
|
252 |
* @see WP_List_Table::::single_row_columns()
|
253 |
*
|
254 |
* @param array $item A singular item (one full row's worth of data)
|
261 |
if ( $user_id ) {
|
262 |
$url = admin_url( "user-edit.php?user_id=$user_id" );
|
263 |
|
264 |
+
// Return the title contents
|
265 |
return sprintf( '%s<br/><small style="color:silver">(%s: <a href="%s">#%s</a>)</small>', $item['name'], __( 'User ID', 'popup-maker' ), $url, $item['user_id'] );
|
266 |
} else {
|
267 |
return $item['name'];
|
280 |
* should be an associative array formatted as 'slug'=>'link html' - and you
|
281 |
* will need to generate the URLs yourself. You could even ensure the links
|
282 |
*
|
|
|
283 |
* @see WP_List_Table::::single_row_columns()
|
284 |
*
|
285 |
* @param array $item A singular item (one full row's worth of data)
|
292 |
$popup = pum_get_popup( $popup_id );
|
293 |
|
294 |
if ( $popup_id && pum_is_popup( $popup ) ) {
|
295 |
+
$url = admin_url( "post.php?post={$popup_id}&action=edit" );
|
296 |
|
297 |
+
// Return the title contents
|
298 |
return sprintf( '%s<br/><small style="color:silver">(%s: <a href="%s">#%s</a>)</small>', $popup->post_title, __( 'ID', 'popup-maker' ), $url, $item['popup_id'] );
|
299 |
} else {
|
300 |
return __( 'N/A', 'popup-maker' );
|
314 |
*
|
315 |
* action and action2 are set based on the triggers above or below the table
|
316 |
*/
|
317 |
+
$actions = [
|
318 |
'bulk-delete' => __( 'Delete', 'popup-maker' ),
|
319 |
+
];
|
320 |
|
321 |
return $actions;
|
322 |
}
|
325 |
* Process actions triggered by the user
|
326 |
*
|
327 |
* @since 1.0.0
|
|
|
328 |
*/
|
329 |
public function handle_table_actions() {
|
330 |
|
331 |
+
// Detect when a bulk action is being triggered...
|
332 |
$action1 = $this->current_action();
|
333 |
|
334 |
+
if ( in_array( $action1, [ 'delete', 'bulk-delete' ] ) ) {
|
335 |
|
336 |
// verify the nonce.
|
337 |
if ( ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), $action1 == 'delete' ? 'pum_subscribers_table_action_nonce' : 'bulk-subscribers' ) ) {
|
338 |
$this->invalid_nonce_redirect();
|
339 |
} else {
|
340 |
|
341 |
+
$subscribers = isset( $_REQUEST['subscriber'] ) ? $_REQUEST['subscriber'] : [];
|
342 |
|
343 |
if ( is_numeric( $subscribers ) ) {
|
344 |
+
$subscribers = [ $subscribers ];
|
345 |
}
|
346 |
|
347 |
$subscribers = wp_parse_id_list( $subscribers );
|
348 |
|
349 |
if ( $subscribers ) {
|
350 |
|
351 |
+
$status = [];
|
352 |
|
353 |
foreach ( $subscribers as $subscriber_id ) {
|
354 |
$status[] = PUM_DB_Subscribers::instance()->delete( $subscriber_id );
|
355 |
}
|
356 |
|
357 |
if ( ! in_array( false, $status ) ) {
|
358 |
+
wp_die(
|
359 |
+
sprintf( _n( 'Subscriber deleted!', '%d Subscribers deleted!', count( $subscribers ), 'popup-maker' ), count( $subscribers ) ),
|
360 |
+
__( 'Success', 'popup-maker' ),
|
361 |
+
[
|
362 |
+
'response' => 200,
|
363 |
+
'back_link' => esc_url( admin_url( 'edit.php?page=pum-subscribers&post_type=popup' ) ),
|
364 |
+
]
|
365 |
+
);
|
366 |
} else {
|
367 |
$succeeded = count( array_filter( $status ) );
|
368 |
$failed = count( $subscribers ) - $succeeded;
|
369 |
|
370 |
if ( count( $subscribers ) == 1 ) {
|
371 |
+
wp_die(
|
372 |
+
__( 'Deleting subscriber failed.', 'popup-maker' ),
|
373 |
+
__( 'Error', 'popup-maker' ),
|
374 |
+
[
|
375 |
+
'response' => 200,
|
376 |
+
'back_link' => esc_url( admin_url( 'edit.php?page=pum-subscribers&post_type=popup' ) ),
|
377 |
+
]
|
378 |
+
);
|
379 |
|
380 |
} else {
|
381 |
+
wp_die(
|
382 |
+
sprintf( __( '%1$d Subscribers deleted, %2$d failed', 'popup-maker' ), $succeeded, $failed ),
|
383 |
+
__( 'Error', 'popup-maker' ),
|
384 |
+
[
|
385 |
+
'response' => 200,
|
386 |
+
'back_link' => esc_url( admin_url( 'edit.php?page=pum-subscribers&post_type=popup' ) ),
|
387 |
+
]
|
388 |
+
);
|
389 |
}
|
|
|
390 |
}
|
391 |
}
|
392 |
|
393 |
+
wp_die(
|
394 |
+
__( 'Uh oh, the subscribers was not deleted successfully!', 'popup-maker' ),
|
395 |
+
__( 'Error', 'popup-maker' ),
|
396 |
+
[
|
397 |
+
'response' => 200,
|
398 |
+
'back_link' => esc_url( admin_url( 'edit.php?page=pum-subscribers&post_type=popup' ) ),
|
399 |
+
]
|
400 |
+
);
|
401 |
|
402 |
exit;
|
403 |
}
|
|
|
404 |
}
|
405 |
|
406 |
/*
|
459 |
* Die when the nonce check fails.
|
460 |
*/
|
461 |
public function invalid_nonce_redirect() {
|
462 |
+
wp_die(
|
463 |
+
__( 'Invalid Nonce', 'popup-maker' ),
|
464 |
+
__( 'Error', 'popup-maker' ),
|
465 |
+
[
|
466 |
+
'response' => 403,
|
467 |
+
'back_link' => esc_url( admin_url( 'edit.php?page=pum-subscribers&post_type=popup' ) ),
|
468 |
+
]
|
469 |
+
);
|
470 |
}
|
471 |
}
|
472 |
|
classes/Admin/Support.php
CHANGED
@@ -50,20 +50,20 @@ class PUM_Admin_Support {
|
|
50 |
</div>
|
51 |
<div id="pum-support-frame" class="wrap">
|
52 |
<script type="text/javascript">
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
</script>
|
64 |
</div>
|
65 |
|
66 |
<?php
|
67 |
}
|
68 |
|
69 |
-
}
|
50 |
</div>
|
51 |
<div id="pum-support-frame" class="wrap">
|
52 |
<script type="text/javascript">
|
53 |
+
(function ($) {
|
54 |
+
var frame = $('<iframe scrolling="no">')
|
55 |
+
.css({height: '535px'})
|
56 |
+
.attr('src', '<?php echo 'https://api.wppopupmaker.com/dashboard-support/?' . build_query( pum_support_assist_args() ); ?>')
|
57 |
+
.appendTo('#pum-support-frame');
|
58 |
|
59 |
+
frame.iFrameResize({
|
60 |
+
checkOrigin: false
|
61 |
+
});
|
62 |
+
})(jQuery);
|
63 |
</script>
|
64 |
</div>
|
65 |
|
66 |
<?php
|
67 |
}
|
68 |
|
69 |
+
}
|
classes/Admin/Templates.php
CHANGED
@@ -22,7 +22,7 @@ class PUM_Admin_Templates {
|
|
22 |
if ( did_action( 'admin_footer' ) || doing_action( 'admin_footer' ) ) {
|
23 |
self::render();
|
24 |
} else {
|
25 |
-
add_action( 'admin_footer',
|
26 |
}
|
27 |
}
|
28 |
|
@@ -278,7 +278,7 @@ class PUM_Admin_Templates {
|
|
278 |
|
279 |
<script type="text/html" id="tmpl-pum-field-wrapper">
|
280 |
<div class="pum-field pum-field-{{data.type}} {{data.id}}-wrapper {{data.classes}}"
|
281 |
-
|
282 |
<# if (typeof data.label === 'string' && data.label.length > 0) { #>
|
283 |
<label for="{{data.id}}">
|
284 |
{{{data.label}}}
|
@@ -432,8 +432,8 @@ class PUM_Admin_Templates {
|
|
432 |
|
433 |
<!-- <div class="no-triggers no-list-items">-->
|
434 |
<!-- <div class="pum-field pum-field-select pum-field-select2">-->
|
435 |
-
<!-- <label for="pum-first-trigger">--><?php //_e( 'Choose a type of trigger to get started.', 'popup-maker' ); ?><!--</label>-->
|
436 |
-
<!-- <# print(PUM_Admin.triggers.template.selectbox({id: 'pum-first-trigger', name: "", placeholder: "--><?php //_e( 'Select a trigger type.', 'popup-maker' ); ?><!--"})); #>-->
|
437 |
<!-- </div>-->
|
438 |
<!-- </div>-->
|
439 |
</div>
|
@@ -458,12 +458,15 @@ class PUM_Admin_Templates {
|
|
458 |
</script>
|
459 |
|
460 |
<?php
|
461 |
-
$presets = apply_filters(
|
462 |
-
'
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
|
|
|
|
|
|
467 |
?>
|
468 |
|
469 |
<script type="text/html" id="tmpl-pum-click-selector-presets">
|
@@ -481,41 +484,47 @@ class PUM_Admin_Templates {
|
|
481 |
|
482 |
<script type="text/html" id="tmpl-pum-trigger-add-type">
|
483 |
<#
|
484 |
-
var form_args =
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
'
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
'
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
'
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
'
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
'
|
516 |
-
|
517 |
-
|
518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
content = PUM_Admin.forms.render(form_args, {});
|
520 |
|
521 |
print(PUM_Admin.templates.modal({
|
@@ -553,7 +562,7 @@ class PUM_Admin_Templates {
|
|
553 |
<ul class="ul-disc">
|
554 |
<li><?php _e( 'By default, this popup will be loaded on every page of your site for all users.', 'popup-maker' ); ?></li>
|
555 |
<li><?php _e( 'Target the popup to a specific segment by adding conditions below.', 'popup-maker' ); ?></li>
|
556 |
-
<li><?php printf( __( 'Click the %s button for any condition to check the opposite of the chosen condition. The button will turn red %s when active.', 'popup-maker' ), '<i style="font-size: 1em; width: 1em; height: 1em; line-height:1.5em;" class="dashicons dashicons-warning"></i>', '<i style="width: 1em; height: 1em; font-size: 1em; line-height:1.5em; color:#a00;" class="dashicons dashicons-warning"></i>' ); ?></li>
|
557 |
</ul>
|
558 |
|
559 |
<section class="pum-alert-box" style="display:none"></section>
|
@@ -667,8 +676,8 @@ class PUM_Admin_Templates {
|
|
667 |
|
668 |
<!-- <div class="no-cookies no-list-items">-->
|
669 |
<!-- <div class="pum-field pum-field-select pum-field-select2">-->
|
670 |
-
<!-- <label for="pum-first-cookie">--><?php //_e( 'Choose when you want to set a cookie to get started.', 'popup-maker' ); ?><!--</label>-->
|
671 |
-
<!-- <# print(PUM_Admin.cookies.template.selectbox({id: 'pum-first-cookie', name: "", placeholder: "--><?php //_e( 'Select an event.', 'popup-maker' ); ?><!--"})); #>-->
|
672 |
<!-- </div>-->
|
673 |
<!-- </div>-->
|
674 |
</div>
|
22 |
if ( did_action( 'admin_footer' ) || doing_action( 'admin_footer' ) ) {
|
23 |
self::render();
|
24 |
} else {
|
25 |
+
add_action( 'admin_footer', [ __CLASS__, 'render' ] );
|
26 |
}
|
27 |
}
|
28 |
|
278 |
|
279 |
<script type="text/html" id="tmpl-pum-field-wrapper">
|
280 |
<div class="pum-field pum-field-{{data.type}} {{data.id}}-wrapper {{data.classes}}"
|
281 |
+
data-id="{{data.id}}" <# print( data.dependencies !== '' ? "data-pum-dependencies='" + data.dependencies + "'" : ''); #> <# print( data.dynamic_desc !== '' ? "data-pum-dynamic-desc='" + data.dynamic_desc + "'" : ''); #>>
|
282 |
<# if (typeof data.label === 'string' && data.label.length > 0) { #>
|
283 |
<label for="{{data.id}}">
|
284 |
{{{data.label}}}
|
432 |
|
433 |
<!-- <div class="no-triggers no-list-items">-->
|
434 |
<!-- <div class="pum-field pum-field-select pum-field-select2">-->
|
435 |
+
<!-- <label for="pum-first-trigger">--><?php // _e( 'Choose a type of trigger to get started.', 'popup-maker' ); ?><!--</label>-->
|
436 |
+
<!-- <# print(PUM_Admin.triggers.template.selectbox({id: 'pum-first-trigger', name: "", placeholder: "--><?php // _e( 'Select a trigger type.', 'popup-maker' ); ?><!--"})); #>-->
|
437 |
<!-- </div>-->
|
438 |
<!-- </div>-->
|
439 |
</div>
|
458 |
</script>
|
459 |
|
460 |
<?php
|
461 |
+
$presets = apply_filters(
|
462 |
+
'pum_click_selector_presets',
|
463 |
+
[
|
464 |
+
'a[href="exact_url"]' => __( 'Link: Exact Match', 'popup-maker' ),
|
465 |
+
'a[href*="contains"]' => __( 'Link: Containing', 'popup-maker' ),
|
466 |
+
'a[href^="begins_with"]' => __( 'Link: Begins With', 'popup-maker' ),
|
467 |
+
'a[href$="ends_with"]' => __( 'Link: Ends With', 'popup-maker' ),
|
468 |
+
]
|
469 |
+
);
|
470 |
?>
|
471 |
|
472 |
<script type="text/html" id="tmpl-pum-click-selector-presets">
|
484 |
|
485 |
<script type="text/html" id="tmpl-pum-trigger-add-type">
|
486 |
<#
|
487 |
+
var form_args =
|
488 |
+
<?php
|
489 |
+
echo PUM_Utils_Array::safe_json_encode(
|
490 |
+
[
|
491 |
+
'id' => 'pum-add-trigger',
|
492 |
+
'fields' => [
|
493 |
+
'popup_trigger_add_type' => [
|
494 |
+
'id' => 'popup_trigger_add_type',
|
495 |
+
'name' => '',
|
496 |
+
'label' => __( 'What kind of trigger do you want?', 'popup-maker' ),
|
497 |
+
'type' => 'select',
|
498 |
+
'options' => PUM_Triggers::instance()->dropdown_list(),
|
499 |
+
],
|
500 |
+
'popup_trigger_add_cookie' => [
|
501 |
+
'id' => 'popup_trigger_add_cookie',
|
502 |
+
'name' => '',
|
503 |
+
'type' => 'checkbox',
|
504 |
+
'std' => true,
|
505 |
+
'label' => __( 'Prevent popup from showing to visitor again using a cookie?', 'popup-maker' ),
|
506 |
+
'meta' => [ 'checked' => 'checked' ],
|
507 |
+
],
|
508 |
+
'popup_trigger_add_cookie_event' => [
|
509 |
+
'id' => 'popup_trigger_add_cookie_event',
|
510 |
+
'name' => '',
|
511 |
+
'type' => 'select',
|
512 |
+
'label' => __( 'Stop showing popup once visitor takes this action:', 'popup-maker' ),
|
513 |
+
'options' => PUM_Cookies::instance()->dropdown_list(),
|
514 |
+
'dependencies' => [
|
515 |
+
'popup_trigger_add_cookie' => true,
|
516 |
+
],
|
517 |
+
],
|
518 |
+
'popup_trigger_add_cookie_info' => [
|
519 |
+
'id' => 'popup_trigger_add_cookie_info',
|
520 |
+
'type' => 'html',
|
521 |
+
'content' => '<p>Learn more about <a href="https://docs.wppopupmaker.com/article/358-popup-settings-box-cookies-option-settings?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=new-trigger-cookie-info">how Popup Maker cookies work</a>.</p>',
|
522 |
+
],
|
523 |
+
],
|
524 |
+
]
|
525 |
+
);
|
526 |
+
?>
|
527 |
+
,
|
528 |
content = PUM_Admin.forms.render(form_args, {});
|
529 |
|
530 |
print(PUM_Admin.templates.modal({
|
562 |
<ul class="ul-disc">
|
563 |
<li><?php _e( 'By default, this popup will be loaded on every page of your site for all users.', 'popup-maker' ); ?></li>
|
564 |
<li><?php _e( 'Target the popup to a specific segment by adding conditions below.', 'popup-maker' ); ?></li>
|
565 |
+
<li><?php printf( __( 'Click the %1$s button for any condition to check the opposite of the chosen condition. The button will turn red %2$s when active.', 'popup-maker' ), '<i style="font-size: 1em; width: 1em; height: 1em; line-height:1.5em;" class="dashicons dashicons-warning"></i>', '<i style="width: 1em; height: 1em; font-size: 1em; line-height:1.5em; color:#a00;" class="dashicons dashicons-warning"></i>' ); ?></li>
|
566 |
</ul>
|
567 |
|
568 |
<section class="pum-alert-box" style="display:none"></section>
|
676 |
|
677 |
<!-- <div class="no-cookies no-list-items">-->
|
678 |
<!-- <div class="pum-field pum-field-select pum-field-select2">-->
|
679 |
+
<!-- <label for="pum-first-cookie">--><?php // _e( 'Choose when you want to set a cookie to get started.', 'popup-maker' ); ?><!--</label>-->
|
680 |
+
<!-- <# print(PUM_Admin.cookies.template.selectbox({id: 'pum-first-cookie', name: "", placeholder: "--><?php // _e( 'Select an event.', 'popup-maker' ); ?><!--"})); #>-->
|
681 |
<!-- </div>-->
|
682 |
<!-- </div>-->
|
683 |
</div>
|
classes/Admin/Themes.php
CHANGED
@@ -17,21 +17,21 @@ class PUM_Admin_Themes {
|
|
17 |
*/
|
18 |
public static function init() {
|
19 |
/** Regitster Metaboxes */
|
20 |
-
add_action( 'add_meta_boxes',
|
21 |
|
22 |
/** Process meta saving. */
|
23 |
-
add_action( 'save_post',
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
* Registers popup metaboxes.
|
28 |
*/
|
29 |
public static function meta_box() {
|
30 |
-
/** Settings Box
|
31 |
-
add_meta_box( 'pum_theme_settings', __( 'Theme Settings', 'popup-maker' ),
|
32 |
|
33 |
-
/** Preview Window
|
34 |
-
add_meta_box( 'pum_theme_preview', __( 'Theme Preview', 'popup-maker' ),
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -92,7 +92,6 @@ class PUM_Admin_Themes {
|
|
92 |
foreach ( $settings as $key => $value ) {
|
93 |
$field = PUM_Utils_Fields::get_field( self::fields(), $key );
|
94 |
|
95 |
-
|
96 |
if ( $field ) {
|
97 |
switch ( $field['type'] ) {
|
98 |
case 'measure':
|
@@ -119,20 +118,29 @@ class PUM_Admin_Themes {
|
|
119 |
wp_enqueue_script( 'popup-maker-admin' );
|
120 |
?>
|
121 |
<script type="text/javascript">
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
'
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
</script>
|
132 |
|
133 |
<div id="pum-theme-settings-container" class="pum-theme-settings-container">
|
134 |
<div class="pum-no-js" style="padding: 0 12px;">
|
135 |
-
<p><?php printf( __( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %sView troubleshooting guide%s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
136 |
</div>
|
137 |
</div>
|
138 |
<?php
|
@@ -156,22 +164,24 @@ class PUM_Admin_Themes {
|
|
156 |
?>
|
157 |
|
158 |
<div class="pum-theme-preview">
|
159 |
-
<div class="pum-popup-overlay <?php echo $deprecated_atb_enabled ? 'example-popup-overlay' : ''
|
160 |
-
<div class="pum-popup-container <?php echo $deprecated_atb_enabled ? 'example-popup' : ''
|
161 |
<div class="pum-popup-title"><?php _e( 'Title Text', 'popup-maker' ); ?></div>
|
162 |
<div class="pum-popup-content">
|
163 |
<?php echo apply_filters( 'pum_example_popup_content', '<p>Suspendisse ipsum eros, tincidunt sed commodo ut, viverra vitae ipsum. Etiam non porta neque. Pellentesque nulla elit, aliquam in ullamcorper at, bibendum sed eros. Morbi non sapien tellus, ac vestibulum eros. In hac habitasse platea dictumst. Nulla vestibulum, diam vel porttitor placerat, eros tortor ultrices lectus, eget faucibus arcu justo eget massa. Maecenas id tellus vitae justo posuere hendrerit aliquet ut dolor.</p>' ); ?>
|
164 |
</div>
|
165 |
-
<button type="button" class="pum-popup-close <?php echo $deprecated_atb_enabled ? 'close-popup' : ''
|
166 |
<?php echo $theme->get_setting( 'close_text', '×' ); ?>
|
167 |
</button>
|
168 |
</div>
|
169 |
-
<p class="pum-desc"
|
170 |
-
|
|
|
171 |
__( 'If you move this theme preview to the bottom of your sidebar here it will follow you down the page?', 'popup-maker' ),
|
172 |
__( 'Clicking on an element in this theme preview will take you to its relevant settings in the editor?', 'popup-maker' ),
|
173 |
-
|
174 |
-
$key = array_rand( $tips, 1 );
|
|
|
175 |
<i class="dashicons dashicons-info"></i> <?php echo '<strong>' . __( 'Did you know:', 'popup-maker' ) . '</strong> ' . $tips[ $key ]; ?>
|
176 |
</p>
|
177 |
</div>
|
@@ -191,9 +201,9 @@ class PUM_Admin_Themes {
|
|
191 |
* @return mixed
|
192 |
*/
|
193 |
public static function deprecated_meta_fields() {
|
194 |
-
$fields =
|
195 |
foreach ( self::deprecated_meta_field_groups() as $group ) {
|
196 |
-
foreach ( apply_filters( 'popmake_popup_theme_meta_field_group_' . $group,
|
197 |
$fields[] = 'popup_theme_' . $group . '_' . $field;
|
198 |
}
|
199 |
}
|
@@ -209,7 +219,7 @@ class PUM_Admin_Themes {
|
|
209 |
* @return mixed
|
210 |
*/
|
211 |
public static function deprecated_meta_field_groups() {
|
212 |
-
return apply_filters( 'popmake_popup_theme_meta_field_groups',
|
213 |
}
|
214 |
|
215 |
/**
|
@@ -254,7 +264,7 @@ class PUM_Admin_Themes {
|
|
254 |
|
255 |
$theme = pum_get_theme( $post_id );
|
256 |
|
257 |
-
$settings = ! empty( $_POST['theme_settings'] ) ? $_POST['theme_settings'] :
|
258 |
|
259 |
$settings = wp_parse_args( $settings, self::defaults() );
|
260 |
|
@@ -266,7 +276,7 @@ class PUM_Admin_Themes {
|
|
266 |
// Ensure data integrity.
|
267 |
$settings = self::parse_values( $settings );
|
268 |
|
269 |
-
|
270 |
$theme->update_settings( $settings );
|
271 |
|
272 |
// If this is a built in theme and the user has modified it set a key so that we know not to make automatic upgrades to it in the future.
|
@@ -287,17 +297,20 @@ class PUM_Admin_Themes {
|
|
287 |
|
288 |
$field_prefix = 'popup_theme_';
|
289 |
|
290 |
-
$old_fields = (array) apply_filters(
|
291 |
-
'
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
297 |
|
298 |
foreach ( $old_fields as $section => $fields ) {
|
299 |
$section_prefix = "{$field_prefix}{$section}";
|
300 |
-
$meta_values =
|
301 |
|
302 |
foreach ( $fields as $field => $args ) {
|
303 |
$field_name = "{$section_prefix}_{$field}";
|
@@ -326,15 +339,18 @@ class PUM_Admin_Themes {
|
|
326 |
* @return array
|
327 |
*/
|
328 |
public static function tabs() {
|
329 |
-
return apply_filters(
|
330 |
-
'
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
338 |
}
|
339 |
|
340 |
/**
|
@@ -343,78 +359,87 @@ class PUM_Admin_Themes {
|
|
343 |
* @return array
|
344 |
*/
|
345 |
public static function sections() {
|
346 |
-
return apply_filters(
|
347 |
-
'
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
'
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
'
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
'
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
|
|
|
|
|
|
380 |
}
|
381 |
|
382 |
/**
|
383 |
* @return mixed
|
384 |
*/
|
385 |
public static function border_style_options() {
|
386 |
-
return apply_filters(
|
387 |
-
'
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
|
|
|
|
|
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* @return mixed
|
401 |
*/
|
402 |
public static function size_unit_options() {
|
403 |
-
return apply_filters(
|
404 |
-
'
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
|
|
|
|
|
|
409 |
}
|
410 |
|
411 |
/**
|
412 |
* @return mixed
|
413 |
*/
|
414 |
public static function font_family_options() {
|
415 |
-
$fonts =
|
416 |
'inherit' => __( 'Use Your Themes', 'popup-maker' ),
|
417 |
-
__( 'System Fonts', 'popup-maker' ) =>
|
418 |
'Sans-Serif' => 'Sans-Serif',
|
419 |
'Tahoma' => 'Tahoma',
|
420 |
'Georgia' => 'Georgia',
|
@@ -422,11 +447,11 @@ class PUM_Admin_Themes {
|
|
422 |
'Arial' => 'Arial',
|
423 |
'Lucida Grande' => 'Lucida Grande',
|
424 |
'Times New Roman' => 'Times New Roman',
|
425 |
-
|
426 |
-
|
427 |
|
428 |
/** @deprecated 1.8.0 This filter is no longer in use */
|
429 |
-
$old_fonts = apply_filters( 'popmake_font_family_options',
|
430 |
|
431 |
$fonts = array_merge( $fonts, array_flip( $old_fonts ) );
|
432 |
|
@@ -437,17 +462,20 @@ class PUM_Admin_Themes {
|
|
437 |
* @return mixed
|
438 |
*/
|
439 |
public static function font_weight_options() {
|
440 |
-
return apply_filters(
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
|
|
|
|
|
|
451 |
}
|
452 |
|
453 |
/**
|
@@ -465,693 +493,720 @@ class PUM_Admin_Themes {
|
|
465 |
$font_family_options = self::font_family_options();
|
466 |
$font_weight_options = self::font_weight_options();
|
467 |
|
468 |
-
$fields = apply_filters(
|
469 |
-
'
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
'type' => 'color',
|
477 |
-
'std' => '#ffffff',
|
478 |
-
'priority' => 10,
|
479 |
-
),
|
480 |
-
'overlay_background_opacity' => array(
|
481 |
-
'label' => __( 'Opacity', 'popup-maker' ),
|
482 |
-
'type' => 'rangeslider',
|
483 |
-
'force_minmax' => true,
|
484 |
-
'std' => 100,
|
485 |
-
'step' => 1,
|
486 |
-
'min' => 0,
|
487 |
-
'max' => 100,
|
488 |
-
'unit' => '%',
|
489 |
-
'priority' => 20,
|
490 |
-
),
|
491 |
-
),
|
492 |
-
) ),
|
493 |
-
'container' => apply_filters( 'pum_theme_container_settings_fields', array(
|
494 |
-
'main' => array(
|
495 |
-
'container_padding' => array(
|
496 |
-
'label' => __( 'Padding', 'popup-maker' ),
|
497 |
-
'type' => 'rangeslider',
|
498 |
-
'std' => 18,
|
499 |
-
'priority' => 10,
|
500 |
-
'step' => 1,
|
501 |
-
'min' => 1,
|
502 |
-
'max' => 100,
|
503 |
-
'unit' => 'px',
|
504 |
-
),
|
505 |
-
'container_border_radius' => array(
|
506 |
-
'label' => __( 'Border Radius', 'popup-maker' ),
|
507 |
-
'type' => 'rangeslider',
|
508 |
-
'std' => 0,
|
509 |
-
'priority' => 20,
|
510 |
-
'step' => 1,
|
511 |
-
'min' => 1,
|
512 |
-
'max' => 80,
|
513 |
-
'unit' => 'px',
|
514 |
-
),
|
515 |
),
|
516 |
-
'
|
517 |
-
'
|
518 |
-
|
519 |
-
'
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
534 |
),
|
535 |
-
'
|
536 |
-
'
|
537 |
-
|
538 |
-
'
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
'
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
'
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
),
|
566 |
-
'
|
567 |
-
'
|
568 |
-
|
569 |
-
'
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
634 |
),
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
'title_font_weight' => array(
|
673 |
-
'label' => __( 'Font Weight', 'popup-maker' ),
|
674 |
-
'type' => 'select',
|
675 |
-
'std' => 400,
|
676 |
-
'priority' => 50,
|
677 |
-
'options' => $font_weight_options,
|
678 |
-
),
|
679 |
-
'title_font_style' => array(
|
680 |
-
'label' => __( 'Style', 'popup-maker' ),
|
681 |
-
'type' => 'select',
|
682 |
-
'std' => 'normal',
|
683 |
-
'priority' => 60,
|
684 |
-
'options' => array(
|
685 |
-
'' => __( 'Normal', 'popup-maker' ),
|
686 |
-
'italic' => __( 'Italic', 'popup-maker' ),
|
687 |
-
),
|
688 |
-
),
|
689 |
-
'title_text_align' => array(
|
690 |
-
'label' => __( 'Alignment', 'popup-maker' ),
|
691 |
-
'type' => 'select',
|
692 |
-
'std' => 'left',
|
693 |
-
'priority' => 70,
|
694 |
-
'options' => array(
|
695 |
-
'left' => __( 'Left', 'popup-maker' ),
|
696 |
-
'center' => __( 'Center', 'popup-maker' ),
|
697 |
-
'right' => __( 'Right', 'popup-maker' ),
|
698 |
-
'justify' => __( 'Justify', 'popup-maker' ),
|
699 |
-
),
|
700 |
-
),
|
701 |
),
|
702 |
-
'
|
703 |
-
'
|
704 |
-
|
705 |
-
'
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
'
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
'
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
'
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
'
|
869 |
-
|
870 |
-
|
871 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
872 |
),
|
873 |
-
'
|
874 |
-
'
|
875 |
-
|
876 |
-
'
|
877 |
-
|
878 |
-
'priority' => 10,
|
879 |
-
'step' => 1,
|
880 |
-
'min' => 0,
|
881 |
-
'max' => 100,
|
882 |
-
'unit' => 'px',
|
883 |
-
),
|
884 |
-
'close_height' => array(
|
885 |
-
'label' => __( 'Height', 'popup-maker' ),
|
886 |
-
'type' => 'rangeslider',
|
887 |
-
'std' => 0,
|
888 |
-
'priority' => 20,
|
889 |
-
'step' => 1,
|
890 |
-
'min' => 0,
|
891 |
-
'max' => 100,
|
892 |
-
'unit' => 'px',
|
893 |
-
),
|
894 |
-
'close_width' => array(
|
895 |
-
'label' => __( 'Width', 'popup-maker' ),
|
896 |
-
'type' => 'rangeslider',
|
897 |
-
'std' => 0,
|
898 |
-
'priority' => 30,
|
899 |
-
'step' => 1,
|
900 |
-
'min' => 0,
|
901 |
-
'max' => 100,
|
902 |
-
'unit' => 'px',
|
903 |
-
),
|
904 |
-
'close_border_radius' => array(
|
905 |
-
'label' => __( 'Border Radius', 'popup-maker' ),
|
906 |
-
'type' => 'rangeslider',
|
907 |
-
'std' => 0,
|
908 |
-
'priority' => 40,
|
909 |
-
'step' => 1,
|
910 |
-
'min' => 1,
|
911 |
-
'max' => 28,
|
912 |
-
'unit' => 'px',
|
913 |
-
),
|
914 |
),
|
915 |
-
|
916 |
-
|
917 |
-
'label' => __( 'Color', 'popup-maker' ),
|
918 |
-
'type' => 'color',
|
919 |
-
'std' => '#00b7cd',
|
920 |
-
'priority' => 10,
|
921 |
-
),
|
922 |
-
'close_background_opacity' => array(
|
923 |
-
'label' => __( 'Opacity', 'popup-maker' ),
|
924 |
-
'type' => 'rangeslider',
|
925 |
-
'std' => 100,
|
926 |
-
'priority' => 20,
|
927 |
-
'step' => 1,
|
928 |
-
'min' => 0,
|
929 |
-
'max' => 100,
|
930 |
-
'unit' => '%',
|
931 |
-
'force_minmax' => true,
|
932 |
-
),
|
933 |
-
),
|
934 |
-
'typography' => array(
|
935 |
-
'close_font_color' => array(
|
936 |
-
'label' => __( 'Color', 'popup-maker' ),
|
937 |
-
'type' => 'color',
|
938 |
-
'std' => '#ffffff',
|
939 |
-
'priority' => 10,
|
940 |
-
),
|
941 |
-
'close_font_size' => array(
|
942 |
-
'label' => __( 'Font Size', 'popup-maker' ),
|
943 |
-
'type' => 'rangeslider',
|
944 |
-
'std' => 12,
|
945 |
-
'priority' => 20,
|
946 |
-
'step' => 1,
|
947 |
-
'min' => 8,
|
948 |
-
'max' => 32,
|
949 |
-
'unit' => 'px',
|
950 |
-
),
|
951 |
-
'close_line_height' => array(
|
952 |
-
'label' => __( 'Line Height', 'popup-maker' ),
|
953 |
-
'type' => 'rangeslider',
|
954 |
-
'std' => 36,
|
955 |
-
'priority' => 30,
|
956 |
-
'step' => 1,
|
957 |
-
'min' => 8,
|
958 |
-
'max' => 54,
|
959 |
-
'unit' => 'px',
|
960 |
-
),
|
961 |
-
'close_font_family' => array(
|
962 |
-
'label' => __( 'Font Family', 'popup-maker' ),
|
963 |
-
'type' => 'select',
|
964 |
-
'select2' => true,
|
965 |
-
'std' => 'inherit',
|
966 |
-
'priority' => 40,
|
967 |
-
'options' => $font_family_options,
|
968 |
-
),
|
969 |
-
'close_font_weight' => array(
|
970 |
-
'label' => __( 'Font Weight', 'popup-maker' ),
|
971 |
-
'type' => 'select',
|
972 |
-
'std' => 400,
|
973 |
-
'priority' => 50,
|
974 |
-
'options' => $font_weight_options,
|
975 |
-
),
|
976 |
-
'close_font_style' => array(
|
977 |
-
'label' => __( 'Style', 'popup-maker' ),
|
978 |
-
'type' => 'select',
|
979 |
-
'std' => 'inherit',
|
980 |
-
'priority' => 60,
|
981 |
-
'options' => array(
|
982 |
-
'' => __( 'Normal', 'popup-maker' ),
|
983 |
-
'italic' => __( 'Italic', 'popup-maker' ),
|
984 |
-
),
|
985 |
-
),
|
986 |
-
),
|
987 |
-
'border' => array(
|
988 |
-
'close_border_style' => array(
|
989 |
-
'label' => __( 'Style', 'popup-maker' ),
|
990 |
-
'type' => 'select',
|
991 |
-
'std' => 'none',
|
992 |
-
'priority' => 10,
|
993 |
-
'options' => $border_style_options,
|
994 |
-
),
|
995 |
-
'close_border_color' => array(
|
996 |
-
'label' => __( 'Color', 'popup-maker' ),
|
997 |
-
'type' => 'color',
|
998 |
-
'std' => '#ffffff',
|
999 |
-
'priority' => 20,
|
1000 |
-
'dependencies' => array(
|
1001 |
-
'close_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, array( 'none' ) ) ),
|
1002 |
-
),
|
1003 |
-
),
|
1004 |
-
'close_border_width' => array(
|
1005 |
-
'label' => __( 'Thickness', 'popup-maker' ),
|
1006 |
-
'type' => 'rangeslider',
|
1007 |
-
'std' => 1,
|
1008 |
-
'priority' => 30,
|
1009 |
-
'step' => 1,
|
1010 |
-
'min' => 1,
|
1011 |
-
'max' => 5,
|
1012 |
-
'unit' => 'px',
|
1013 |
-
'dependencies' => array(
|
1014 |
-
'close_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, array( 'none' ) ) ),
|
1015 |
-
),
|
1016 |
-
),
|
1017 |
-
),
|
1018 |
-
'boxshadow' => array(
|
1019 |
-
'close_boxshadow_color' => array(
|
1020 |
-
'label' => __( 'Color', 'popup-maker' ),
|
1021 |
-
'type' => 'color',
|
1022 |
-
'std' => '#020202',
|
1023 |
-
'priority' => 10,
|
1024 |
-
),
|
1025 |
-
'close_boxshadow_opacity' => array(
|
1026 |
-
'label' => __( 'Opacity', 'popup-maker' ),
|
1027 |
-
'type' => 'rangeslider',
|
1028 |
-
'std' => 23,
|
1029 |
-
'priority' => 20,
|
1030 |
-
'step' => 1,
|
1031 |
-
'min' => 0,
|
1032 |
-
'max' => 100,
|
1033 |
-
'unit' => '%',
|
1034 |
-
'force_minmax' => true,
|
1035 |
-
),
|
1036 |
-
'close_boxshadow_horizontal' => array(
|
1037 |
-
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
1038 |
-
'type' => 'rangeslider',
|
1039 |
-
'std' => 1,
|
1040 |
-
'priority' => 30,
|
1041 |
-
'step' => 1,
|
1042 |
-
'min' => - 50,
|
1043 |
-
'max' => 50,
|
1044 |
-
'unit' => 'px',
|
1045 |
-
),
|
1046 |
-
'close_boxshadow_vertical' => array(
|
1047 |
-
'label' => __( 'Vertical Position', 'popup-maker' ),
|
1048 |
-
'type' => 'rangeslider',
|
1049 |
-
'std' => 1,
|
1050 |
-
'priority' => 40,
|
1051 |
-
'step' => 1,
|
1052 |
-
'min' => - 50,
|
1053 |
-
'max' => 50,
|
1054 |
-
'unit' => 'px',
|
1055 |
-
),
|
1056 |
-
'close_boxshadow_blur' => array(
|
1057 |
-
'label' => __( 'Blur Radius', 'popup-maker' ),
|
1058 |
-
'type' => 'rangeslider',
|
1059 |
-
'std' => 3,
|
1060 |
-
'priority' => 50,
|
1061 |
-
'step' => 1,
|
1062 |
-
'min' => 0,
|
1063 |
-
'max' => 100,
|
1064 |
-
'unit' => 'px',
|
1065 |
-
),
|
1066 |
-
'close_boxshadow_spread' => array(
|
1067 |
-
'label' => __( 'Spread', 'popup-maker' ),
|
1068 |
-
'type' => 'rangeslider',
|
1069 |
-
'std' => 0,
|
1070 |
-
'priority' => 60,
|
1071 |
-
'step' => 1,
|
1072 |
-
'min' => - 100,
|
1073 |
-
'max' => 100,
|
1074 |
-
'unit' => 'px',
|
1075 |
-
),
|
1076 |
-
'close_boxshadow_inset' => array(
|
1077 |
-
'label' => __( 'Inset (inner shadow)', 'popup-maker' ),
|
1078 |
-
'type' => 'select',
|
1079 |
-
'std' => 'no',
|
1080 |
-
'priority' => 70,
|
1081 |
-
'options' => array(
|
1082 |
-
'no' => __( 'No', 'popup-maker' ),
|
1083 |
-
'yes' => __( 'Yes', 'popup-maker' ),
|
1084 |
-
),
|
1085 |
-
),
|
1086 |
-
),
|
1087 |
-
'textshadow' => array(
|
1088 |
-
'close_textshadow_color' => array(
|
1089 |
-
'label' => __( 'Color', 'popup-maker' ),
|
1090 |
-
'type' => 'color',
|
1091 |
-
'std' => '#000000',
|
1092 |
-
'priority' => 10,
|
1093 |
-
),
|
1094 |
-
'close_textshadow_opacity' => array(
|
1095 |
-
'label' => __( 'Opacity', 'popup-maker' ),
|
1096 |
-
'type' => 'rangeslider',
|
1097 |
-
'std' => 23,
|
1098 |
-
'priority' => 20,
|
1099 |
-
'step' => 1,
|
1100 |
-
'min' => 0,
|
1101 |
-
'max' => 100,
|
1102 |
-
'force_minmax' => true,
|
1103 |
-
'unit' => '%',
|
1104 |
-
),
|
1105 |
-
'close_textshadow_horizontal' => array(
|
1106 |
-
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
1107 |
-
'type' => 'rangeslider',
|
1108 |
-
'std' => 0,
|
1109 |
-
'priority' => 30,
|
1110 |
-
'step' => 1,
|
1111 |
-
'min' => - 50,
|
1112 |
-
'max' => 50,
|
1113 |
-
'unit' => 'px',
|
1114 |
-
),
|
1115 |
-
'close_textshadow_vertical' => array(
|
1116 |
-
'label' => __( 'Vertical Position', 'popup-maker' ),
|
1117 |
-
'type' => 'rangeslider',
|
1118 |
-
'std' => 0,
|
1119 |
-
'priority' => 40,
|
1120 |
-
'step' => 1,
|
1121 |
-
'min' => - 50,
|
1122 |
-
'max' => 50,
|
1123 |
-
'unit' => 'px',
|
1124 |
-
),
|
1125 |
-
'close_textshadow_blur' => array(
|
1126 |
-
'label' => __( 'Blur Radius', 'popup-maker' ),
|
1127 |
-
'type' => 'rangeslider',
|
1128 |
-
'std' => 0,
|
1129 |
-
'priority' => 50,
|
1130 |
-
'step' => 1,
|
1131 |
-
'min' => 0,
|
1132 |
-
'max' => 100,
|
1133 |
-
'unit' => 'px',
|
1134 |
-
),
|
1135 |
-
),
|
1136 |
-
) ),
|
1137 |
-
'advanced' => apply_filters( 'pum_theme_advanced_settings_fields', array(
|
1138 |
-
'main' => array(),
|
1139 |
-
) ),
|
1140 |
-
) );
|
1141 |
|
1142 |
$fields = self::append_deprecated_fields( $fields );
|
1143 |
|
1144 |
-
$fields = PUM_Utils_Fields::parse_tab_fields(
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
|
|
|
|
|
|
1148 |
|
1149 |
}
|
1150 |
|
1151 |
return $fields;
|
1152 |
}
|
1153 |
|
1154 |
-
public static function append_deprecated_fields( $fields =
|
1155 |
global $post;
|
1156 |
|
1157 |
if ( class_exists( 'PUM_ATB' ) && has_action( 'popmake_popup_theme_overlay_meta_box_fields' ) ) {
|
@@ -1161,11 +1216,11 @@ class PUM_Admin_Themes {
|
|
1161 |
|
1162 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1163 |
|
1164 |
-
$fields['overlay']['background']['deprecated_fields'] =
|
1165 |
'type' => 'html',
|
1166 |
'content' => $content,
|
1167 |
'priority' => 999,
|
1168 |
-
|
1169 |
|
1170 |
// Remove duplicate fields.
|
1171 |
unset( $fields['overlay']['background']['overlay_background_color'] );
|
@@ -1179,11 +1234,11 @@ class PUM_Admin_Themes {
|
|
1179 |
|
1180 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1181 |
|
1182 |
-
$fields['container']['background']['deprecated_fields'] =
|
1183 |
'type' => 'html',
|
1184 |
'content' => $content,
|
1185 |
'priority' => 999,
|
1186 |
-
|
1187 |
|
1188 |
// Remove duplicate fields.
|
1189 |
unset( $fields['container']['background']['container_background_color'] );
|
@@ -1197,11 +1252,11 @@ class PUM_Admin_Themes {
|
|
1197 |
|
1198 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1199 |
|
1200 |
-
$fields['close']['background']['deprecated_fields'] =
|
1201 |
'type' => 'html',
|
1202 |
'content' => $content,
|
1203 |
'priority' => 999,
|
1204 |
-
|
1205 |
|
1206 |
// Remove duplicate fields.
|
1207 |
unset( $fields['close']['background']['close_background_color'] );
|
@@ -1214,21 +1269,24 @@ class PUM_Admin_Themes {
|
|
1214 |
public static function fix_deprecated_fields( $content = '' ) {
|
1215 |
|
1216 |
// Remove "Background" heading.
|
1217 |
-
$content = str_replace(
|
|
|
1218 |
<th colspan="2">
|
1219 |
<h3 class="title">Background</h3>
|
1220 |
</th>
|
1221 |
-
</tr>',
|
|
|
|
|
|
|
1222 |
|
1223 |
// Fix broken opacity fields.
|
1224 |
-
$content = str_replace(
|
1225 |
|
1226 |
// TEMPORARY. REMOVE THIS
|
1227 |
$content = '<table class="form-table"><tbody>' . $content . '</tbody></table>';
|
1228 |
|
1229 |
return $content;
|
1230 |
|
1231 |
-
|
1232 |
}
|
1233 |
|
1234 |
/**
|
17 |
*/
|
18 |
public static function init() {
|
19 |
/** Regitster Metaboxes */
|
20 |
+
add_action( 'add_meta_boxes', [ __CLASS__, 'meta_box' ] );
|
21 |
|
22 |
/** Process meta saving. */
|
23 |
+
add_action( 'save_post', [ __CLASS__, 'save' ], 10, 2 );
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
* Registers popup metaboxes.
|
28 |
*/
|
29 |
public static function meta_box() {
|
30 |
+
/** Settings Box */
|
31 |
+
add_meta_box( 'pum_theme_settings', __( 'Theme Settings', 'popup-maker' ), [ __CLASS__, 'render_settings_meta_box' ], 'popup_theme', 'normal', 'high' );
|
32 |
|
33 |
+
/** Preview Window */
|
34 |
+
add_meta_box( 'pum_theme_preview', __( 'Theme Preview', 'popup-maker' ), [ __CLASS__, 'render_preview_meta_box' ], 'popup_theme', 'side', 'high' );
|
35 |
}
|
36 |
|
37 |
/**
|
92 |
foreach ( $settings as $key => $value ) {
|
93 |
$field = PUM_Utils_Fields::get_field( self::fields(), $key );
|
94 |
|
|
|
95 |
if ( $field ) {
|
96 |
switch ( $field['type'] ) {
|
97 |
case 'measure':
|
118 |
wp_enqueue_script( 'popup-maker-admin' );
|
119 |
?>
|
120 |
<script type="text/javascript">
|
121 |
+
window.pum_theme_settings_editor =
|
122 |
+
<?php
|
123 |
+
echo PUM_Utils_Array::safe_json_encode(
|
124 |
+
apply_filters(
|
125 |
+
'pum_theme_settings_editor_var',
|
126 |
+
[
|
127 |
+
'form_args' => [
|
128 |
+
'id' => 'pum-theme-settings',
|
129 |
+
'tabs' => self::tabs(),
|
130 |
+
'sections' => self::sections(),
|
131 |
+
'fields' => self::fields(),
|
132 |
+
],
|
133 |
+
'current_values' => self::render_form_values( $settings ),
|
134 |
+
]
|
135 |
+
)
|
136 |
+
);
|
137 |
+
?>
|
138 |
+
;
|
139 |
</script>
|
140 |
|
141 |
<div id="pum-theme-settings-container" class="pum-theme-settings-container">
|
142 |
<div class="pum-no-js" style="padding: 0 12px;">
|
143 |
+
<p><?php printf( __( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %1$sView troubleshooting guide%2$s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
|
144 |
</div>
|
145 |
</div>
|
146 |
<?php
|
164 |
?>
|
165 |
|
166 |
<div class="pum-theme-preview">
|
167 |
+
<div class="pum-popup-overlay <?php echo $deprecated_atb_enabled ? 'example-popup-overlay' : ''; ?>"></div>
|
168 |
+
<div class="pum-popup-container <?php echo $deprecated_atb_enabled ? 'example-popup' : ''; ?>">
|
169 |
<div class="pum-popup-title"><?php _e( 'Title Text', 'popup-maker' ); ?></div>
|
170 |
<div class="pum-popup-content">
|
171 |
<?php echo apply_filters( 'pum_example_popup_content', '<p>Suspendisse ipsum eros, tincidunt sed commodo ut, viverra vitae ipsum. Etiam non porta neque. Pellentesque nulla elit, aliquam in ullamcorper at, bibendum sed eros. Morbi non sapien tellus, ac vestibulum eros. In hac habitasse platea dictumst. Nulla vestibulum, diam vel porttitor placerat, eros tortor ultrices lectus, eget faucibus arcu justo eget massa. Maecenas id tellus vitae justo posuere hendrerit aliquet ut dolor.</p>' ); ?>
|
172 |
</div>
|
173 |
+
<button type="button" class="pum-popup-close <?php echo $deprecated_atb_enabled ? 'close-popup' : ''; ?>" aria-label="<?php _e( 'Close', 'popup-maker' ); ?>">
|
174 |
<?php echo $theme->get_setting( 'close_text', '×' ); ?>
|
175 |
</button>
|
176 |
</div>
|
177 |
+
<p class="pum-desc">
|
178 |
+
<?php
|
179 |
+
$tips = [
|
180 |
__( 'If you move this theme preview to the bottom of your sidebar here it will follow you down the page?', 'popup-maker' ),
|
181 |
__( 'Clicking on an element in this theme preview will take you to its relevant settings in the editor?', 'popup-maker' ),
|
182 |
+
];
|
183 |
+
$key = array_rand( $tips, 1 );
|
184 |
+
?>
|
185 |
<i class="dashicons dashicons-info"></i> <?php echo '<strong>' . __( 'Did you know:', 'popup-maker' ) . '</strong> ' . $tips[ $key ]; ?>
|
186 |
</p>
|
187 |
</div>
|
201 |
* @return mixed
|
202 |
*/
|
203 |
public static function deprecated_meta_fields() {
|
204 |
+
$fields = [];
|
205 |
foreach ( self::deprecated_meta_field_groups() as $group ) {
|
206 |
+
foreach ( apply_filters( 'popmake_popup_theme_meta_field_group_' . $group, [] ) as $field ) {
|
207 |
$fields[] = 'popup_theme_' . $group . '_' . $field;
|
208 |
}
|
209 |
}
|
219 |
* @return mixed
|
220 |
*/
|
221 |
public static function deprecated_meta_field_groups() {
|
222 |
+
return apply_filters( 'popmake_popup_theme_meta_field_groups', [ 'display', 'close' ] );
|
223 |
}
|
224 |
|
225 |
/**
|
264 |
|
265 |
$theme = pum_get_theme( $post_id );
|
266 |
|
267 |
+
$settings = ! empty( $_POST['theme_settings'] ) ? $_POST['theme_settings'] : [];
|
268 |
|
269 |
$settings = wp_parse_args( $settings, self::defaults() );
|
270 |
|
276 |
// Ensure data integrity.
|
277 |
$settings = self::parse_values( $settings );
|
278 |
|
279 |
+
// $theme->update_meta( 'popup_theme_settings', $settings );
|
280 |
$theme->update_settings( $settings );
|
281 |
|
282 |
// If this is a built in theme and the user has modified it set a key so that we know not to make automatic upgrades to it in the future.
|
297 |
|
298 |
$field_prefix = 'popup_theme_';
|
299 |
|
300 |
+
$old_fields = (array) apply_filters(
|
301 |
+
'popmake_popup_theme_fields',
|
302 |
+
[
|
303 |
+
'overlay' => [],
|
304 |
+
'container' => [],
|
305 |
+
'title' => [],
|
306 |
+
'content' => [],
|
307 |
+
'close' => [],
|
308 |
+
]
|
309 |
+
);
|
310 |
|
311 |
foreach ( $old_fields as $section => $fields ) {
|
312 |
$section_prefix = "{$field_prefix}{$section}";
|
313 |
+
$meta_values = [];
|
314 |
|
315 |
foreach ( $fields as $field => $args ) {
|
316 |
$field_name = "{$section_prefix}_{$field}";
|
339 |
* @return array
|
340 |
*/
|
341 |
public static function tabs() {
|
342 |
+
return apply_filters(
|
343 |
+
'pum_theme_settings_tabs',
|
344 |
+
[
|
345 |
+
'general' => __( 'General', 'popup-maker' ),
|
346 |
+
'overlay' => __( 'Overlay', 'popup-maker' ),
|
347 |
+
'container' => __( 'Container', 'popup-maker' ),
|
348 |
+
'title' => __( 'Title', 'popup-maker' ),
|
349 |
+
'content' => __( 'Content', 'popup-maker' ),
|
350 |
+
'close' => __( 'Close', 'popup-maker' ),
|
351 |
+
'advanced' => __( 'Advanced', 'popup-maker' ),
|
352 |
+
]
|
353 |
+
);
|
354 |
}
|
355 |
|
356 |
/**
|
359 |
* @return array
|
360 |
*/
|
361 |
public static function sections() {
|
362 |
+
return apply_filters(
|
363 |
+
'pum_theme_settings_sections',
|
364 |
+
[
|
365 |
+
'general' => [
|
366 |
+
'main' => __( 'General', 'popup-maker' ),
|
367 |
+
],
|
368 |
+
'overlay' => [
|
369 |
+
'background' => __( 'Background', 'popup-maker' ),
|
370 |
+
],
|
371 |
+
'container' => [
|
372 |
+
'main' => __( 'Container', 'popup-maker' ),
|
373 |
+
'background' => __( 'Background', 'popup-maker' ),
|
374 |
+
'border' => __( 'Border', 'popup-maker' ),
|
375 |
+
'boxshadow' => __( 'Drop Shadow', 'popup-maker' ),
|
376 |
+
],
|
377 |
+
'title' => [
|
378 |
+
'typography' => __( 'Font', 'popup-maker' ),
|
379 |
+
'textshadow' => __( 'Text Shadow', 'popup-maker' ),
|
380 |
+
],
|
381 |
+
'content' => [
|
382 |
+
'typography' => __( 'Text', 'popup-maker' ),
|
383 |
+
],
|
384 |
+
'close' => [
|
385 |
+
'main' => __( 'General', 'popup-maker' ),
|
386 |
+
'size' => __( 'Size', 'popup-maker' ),
|
387 |
+
'position' => __( 'Position', 'popup-maker' ),
|
388 |
+
'background' => __( 'Background', 'popup-maker' ),
|
389 |
+
'border' => __( 'Border', 'popup-maker' ),
|
390 |
+
'boxshadow' => __( 'Drop Shadow', 'popup-maker' ),
|
391 |
+
'typography' => __( 'Font', 'popup-maker' ),
|
392 |
+
'textshadow' => __( 'Text Shadow', 'popup-maker' ),
|
393 |
+
],
|
394 |
+
'advanced' => [
|
395 |
+
'main' => __( 'Advanced', 'popup-maker' ),
|
396 |
+
],
|
397 |
+
]
|
398 |
+
);
|
399 |
}
|
400 |
|
401 |
/**
|
402 |
* @return mixed
|
403 |
*/
|
404 |
public static function border_style_options() {
|
405 |
+
return apply_filters(
|
406 |
+
'pum_theme_border_style_options',
|
407 |
+
[
|
408 |
+
'none' => __( 'None', 'popup-maker' ),
|
409 |
+
'solid' => __( 'Solid', 'popup-maker' ),
|
410 |
+
'dotted' => __( 'Dotted', 'popup-maker' ),
|
411 |
+
'dashed' => __( 'Dashed', 'popup-maker' ),
|
412 |
+
'double' => __( 'Double', 'popup-maker' ),
|
413 |
+
'groove' => __( 'Groove', 'popup-maker' ),
|
414 |
+
'inset' => __( 'Inset (inner shadow)', 'popup-maker' ),
|
415 |
+
'outset' => __( 'Outset', 'popup-maker' ),
|
416 |
+
'ridge' => __( 'Ridge', 'popup-maker' ),
|
417 |
+
]
|
418 |
+
);
|
419 |
}
|
420 |
|
421 |
/**
|
422 |
* @return mixed
|
423 |
*/
|
424 |
public static function size_unit_options() {
|
425 |
+
return apply_filters(
|
426 |
+
'pum_theme_size_unit_options',
|
427 |
+
[
|
428 |
+
'px' => 'px',
|
429 |
+
'%' => '%',
|
430 |
+
'em' => 'em',
|
431 |
+
'rem' => 'rem',
|
432 |
+
]
|
433 |
+
);
|
434 |
}
|
435 |
|
436 |
/**
|
437 |
* @return mixed
|
438 |
*/
|
439 |
public static function font_family_options() {
|
440 |
+
$fonts = [
|
441 |
'inherit' => __( 'Use Your Themes', 'popup-maker' ),
|
442 |
+
__( 'System Fonts', 'popup-maker' ) => [
|
443 |
'Sans-Serif' => 'Sans-Serif',
|
444 |
'Tahoma' => 'Tahoma',
|
445 |
'Georgia' => 'Georgia',
|
447 |
'Arial' => 'Arial',
|
448 |
'Lucida Grande' => 'Lucida Grande',
|
449 |
'Times New Roman' => 'Times New Roman',
|
450 |
+
],
|
451 |
+
];
|
452 |
|
453 |
/** @deprecated 1.8.0 This filter is no longer in use */
|
454 |
+
$old_fonts = apply_filters( 'popmake_font_family_options', [] );
|
455 |
|
456 |
$fonts = array_merge( $fonts, array_flip( $old_fonts ) );
|
457 |
|
462 |
* @return mixed
|
463 |
*/
|
464 |
public static function font_weight_options() {
|
465 |
+
return apply_filters(
|
466 |
+
'pum_theme_font_weight_options',
|
467 |
+
[
|
468 |
+
100 => 100,
|
469 |
+
200 => 200,
|
470 |
+
300 => 300,
|
471 |
+
400 => __( 'Normal', 'popup-maker' ) . ' (400)',
|
472 |
+
500 => 500,
|
473 |
+
600 => 600,
|
474 |
+
700 => __( 'Bold', 'popup-maker' ) . ' (700)',
|
475 |
+
800 => 800,
|
476 |
+
900 => 900,
|
477 |
+
]
|
478 |
+
);
|
479 |
}
|
480 |
|
481 |
/**
|
493 |
$font_family_options = self::font_family_options();
|
494 |
$font_weight_options = self::font_weight_options();
|
495 |
|
496 |
+
$fields = apply_filters(
|
497 |
+
'pum_theme_settings_fields',
|
498 |
+
[
|
499 |
+
'general' => apply_filters(
|
500 |
+
'pum_theme_general_settings_fields',
|
501 |
+
[
|
502 |
+
'main' => [],
|
503 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
),
|
505 |
+
'overlay' => apply_filters(
|
506 |
+
'pum_theme_overlay_settings_fields',
|
507 |
+
[
|
508 |
+
'background' => [
|
509 |
+
'overlay_background_color' => [
|
510 |
+
'label' => __( 'Color', 'popup-maker' ),
|
511 |
+
'type' => 'color',
|
512 |
+
'std' => '#ffffff',
|
513 |
+
'priority' => 10,
|
514 |
+
],
|
515 |
+
'overlay_background_opacity' => [
|
516 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
517 |
+
'type' => 'rangeslider',
|
518 |
+
'force_minmax' => true,
|
519 |
+
'std' => 100,
|
520 |
+
'step' => 1,
|
521 |
+
'min' => 0,
|
522 |
+
'max' => 100,
|
523 |
+
'unit' => '%',
|
524 |
+
'priority' => 20,
|
525 |
+
],
|
526 |
+
],
|
527 |
+
]
|
528 |
),
|
529 |
+
'container' => apply_filters(
|
530 |
+
'pum_theme_container_settings_fields',
|
531 |
+
[
|
532 |
+
'main' => [
|
533 |
+
'container_padding' => [
|
534 |
+
'label' => __( 'Padding', 'popup-maker' ),
|
535 |
+
'type' => 'rangeslider',
|
536 |
+
'std' => 18,
|
537 |
+
'priority' => 10,
|
538 |
+
'step' => 1,
|
539 |
+
'min' => 1,
|
540 |
+
'max' => 100,
|
541 |
+
'unit' => 'px',
|
542 |
+
],
|
543 |
+
'container_border_radius' => [
|
544 |
+
'label' => __( 'Border Radius', 'popup-maker' ),
|
545 |
+
'type' => 'rangeslider',
|
546 |
+
'std' => 0,
|
547 |
+
'priority' => 20,
|
548 |
+
'step' => 1,
|
549 |
+
'min' => 1,
|
550 |
+
'max' => 80,
|
551 |
+
'unit' => 'px',
|
552 |
+
],
|
553 |
+
],
|
554 |
+
'background' => [
|
555 |
+
'container_background_color' => [
|
556 |
+
'label' => __( 'Color', 'popup-maker' ),
|
557 |
+
'type' => 'color',
|
558 |
+
'std' => '#f9f9f9',
|
559 |
+
'priority' => 10,
|
560 |
+
],
|
561 |
+
'container_background_opacity' => [
|
562 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
563 |
+
'type' => 'rangeslider',
|
564 |
+
'force_minmax' => true,
|
565 |
+
'std' => 100,
|
566 |
+
'priority' => 20,
|
567 |
+
'step' => 1,
|
568 |
+
'min' => 0,
|
569 |
+
'max' => 100,
|
570 |
+
'unit' => '%',
|
571 |
+
],
|
572 |
+
],
|
573 |
+
'border' => [
|
574 |
+
'container_border_style' => [
|
575 |
+
'label' => __( 'Style', 'popup-maker' ),
|
576 |
+
'type' => 'select',
|
577 |
+
'std' => 'none',
|
578 |
+
'priority' => 10,
|
579 |
+
'options' => $border_style_options,
|
580 |
+
],
|
581 |
+
'container_border_color' => [
|
582 |
+
'label' => __( 'Color', 'popup-maker' ),
|
583 |
+
'type' => 'color',
|
584 |
+
'std' => '#000000',
|
585 |
+
'priority' => 20,
|
586 |
+
'dependencies' => [
|
587 |
+
'container_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, [ 'none' ] ) ),
|
588 |
+
],
|
589 |
+
],
|
590 |
+
'container_border_width' => [
|
591 |
+
'label' => __( 'Thickness', 'popup-maker' ),
|
592 |
+
'type' => 'rangeslider',
|
593 |
+
'std' => 1,
|
594 |
+
'priority' => 30,
|
595 |
+
'step' => 1,
|
596 |
+
'min' => 1,
|
597 |
+
'max' => 5,
|
598 |
+
'unit' => 'px',
|
599 |
+
'dependencies' => [
|
600 |
+
'container_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, [ 'none' ] ) ),
|
601 |
+
],
|
602 |
+
],
|
603 |
+
],
|
604 |
+
'boxshadow' => [
|
605 |
+
'container_boxshadow_color' => [
|
606 |
+
'label' => __( 'Color', 'popup-maker' ),
|
607 |
+
'type' => 'color',
|
608 |
+
'std' => '#020202',
|
609 |
+
'priority' => 10,
|
610 |
+
],
|
611 |
+
'container_boxshadow_opacity' => [
|
612 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
613 |
+
'type' => 'rangeslider',
|
614 |
+
'std' => 23,
|
615 |
+
'priority' => 20,
|
616 |
+
'step' => 1,
|
617 |
+
'min' => 0,
|
618 |
+
'max' => 100,
|
619 |
+
'force_minmax' => true,
|
620 |
+
'unit' => '%',
|
621 |
+
],
|
622 |
+
'container_boxshadow_horizontal' => [
|
623 |
+
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
624 |
+
'type' => 'rangeslider',
|
625 |
+
'std' => 1,
|
626 |
+
'priority' => 30,
|
627 |
+
'step' => 1,
|
628 |
+
'min' => - 50,
|
629 |
+
'max' => 50,
|
630 |
+
'unit' => 'px',
|
631 |
+
],
|
632 |
+
'container_boxshadow_vertical' => [
|
633 |
+
'label' => __( 'Vertical Position', 'popup-maker' ),
|
634 |
+
'type' => 'rangeslider',
|
635 |
+
'std' => 1,
|
636 |
+
'priority' => 40,
|
637 |
+
'step' => 1,
|
638 |
+
'min' => - 50,
|
639 |
+
'max' => 50,
|
640 |
+
'unit' => 'px',
|
641 |
+
],
|
642 |
+
'container_boxshadow_blur' => [
|
643 |
+
'label' => __( 'Blur Radius', 'popup-maker' ),
|
644 |
+
'type' => 'rangeslider',
|
645 |
+
'std' => 3,
|
646 |
+
'priority' => 50,
|
647 |
+
'step' => 1,
|
648 |
+
'min' => 0,
|
649 |
+
'max' => 100,
|
650 |
+
'unit' => 'px',
|
651 |
+
],
|
652 |
+
'container_boxshadow_spread' => [
|
653 |
+
'label' => __( 'Spread', 'popup-maker' ),
|
654 |
+
'type' => 'rangeslider',
|
655 |
+
'std' => 0,
|
656 |
+
'priority' => 60,
|
657 |
+
'step' => 1,
|
658 |
+
'min' => - 100,
|
659 |
+
'max' => 100,
|
660 |
+
'unit' => 'px',
|
661 |
+
],
|
662 |
+
'container_boxshadow_inset' => [
|
663 |
+
'label' => __( 'Inset (inner shadow)', 'popup-maker' ),
|
664 |
+
'type' => 'select',
|
665 |
+
'std' => 'no',
|
666 |
+
'priority' => 70,
|
667 |
+
'options' => [
|
668 |
+
'no' => __( 'No', 'popup-maker' ),
|
669 |
+
'yes' => __( 'Yes', 'popup-maker' ),
|
670 |
+
],
|
671 |
+
],
|
672 |
+
],
|
673 |
+
]
|
674 |
),
|
675 |
+
'title' => apply_filters(
|
676 |
+
'pum_theme_title_settings_fields',
|
677 |
+
[
|
678 |
+
'typography' => [
|
679 |
+
'title_font_color' => [
|
680 |
+
'label' => __( 'Color', 'popup-maker' ),
|
681 |
+
'type' => 'color',
|
682 |
+
'std' => '#000000',
|
683 |
+
'priority' => 10,
|
684 |
+
],
|
685 |
+
'title_font_size' => [
|
686 |
+
'label' => __( 'Font Size', 'popup-maker' ),
|
687 |
+
'type' => 'rangeslider',
|
688 |
+
'std' => 32,
|
689 |
+
'priority' => 20,
|
690 |
+
'step' => 1,
|
691 |
+
'min' => 8,
|
692 |
+
'max' => 48,
|
693 |
+
'unit' => 'px',
|
694 |
+
],
|
695 |
+
'title_line_height' => [
|
696 |
+
'label' => __( 'Line Height', 'popup-maker' ),
|
697 |
+
'type' => 'rangeslider',
|
698 |
+
'std' => 36,
|
699 |
+
'priority' => 30,
|
700 |
+
'step' => 1,
|
701 |
+
'min' => 8,
|
702 |
+
'max' => 54,
|
703 |
+
'unit' => 'px',
|
704 |
+
],
|
705 |
+
'title_font_family' => [
|
706 |
+
'label' => __( 'Font Family', 'popup-maker' ),
|
707 |
+
'type' => 'select',
|
708 |
+
'select2' => true,
|
709 |
+
'std' => 'inherit',
|
710 |
+
'priority' => 40,
|
711 |
+
'options' => $font_family_options,
|
712 |
+
],
|
713 |
+
'title_font_weight' => [
|
714 |
+
'label' => __( 'Font Weight', 'popup-maker' ),
|
715 |
+
'type' => 'select',
|
716 |
+
'std' => 400,
|
717 |
+
'priority' => 50,
|
718 |
+
'options' => $font_weight_options,
|
719 |
+
],
|
720 |
+
'title_font_style' => [
|
721 |
+
'label' => __( 'Style', 'popup-maker' ),
|
722 |
+
'type' => 'select',
|
723 |
+
'std' => 'normal',
|
724 |
+
'priority' => 60,
|
725 |
+
'options' => [
|
726 |
+
'' => __( 'Normal', 'popup-maker' ),
|
727 |
+
'italic' => __( 'Italic', 'popup-maker' ),
|
728 |
+
],
|
729 |
+
],
|
730 |
+
'title_text_align' => [
|
731 |
+
'label' => __( 'Alignment', 'popup-maker' ),
|
732 |
+
'type' => 'select',
|
733 |
+
'std' => 'left',
|
734 |
+
'priority' => 70,
|
735 |
+
'options' => [
|
736 |
+
'left' => __( 'Left', 'popup-maker' ),
|
737 |
+
'center' => __( 'Center', 'popup-maker' ),
|
738 |
+
'right' => __( 'Right', 'popup-maker' ),
|
739 |
+
'justify' => __( 'Justify', 'popup-maker' ),
|
740 |
+
],
|
741 |
+
],
|
742 |
+
],
|
743 |
+
'textshadow' => [
|
744 |
+
'title_textshadow_color' => [
|
745 |
+
'label' => __( 'Color', 'popup-maker' ),
|
746 |
+
'type' => 'color',
|
747 |
+
'std' => '#020202',
|
748 |
+
'priority' => 10,
|
749 |
+
],
|
750 |
+
'title_textshadow_opacity' => [
|
751 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
752 |
+
'type' => 'rangeslider',
|
753 |
+
'std' => 23,
|
754 |
+
'priority' => 20,
|
755 |
+
'step' => 1,
|
756 |
+
'min' => 0,
|
757 |
+
'max' => 100,
|
758 |
+
'force_minmax' => true,
|
759 |
+
'unit' => '%',
|
760 |
+
],
|
761 |
+
'title_textshadow_horizontal' => [
|
762 |
+
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
763 |
+
'type' => 'rangeslider',
|
764 |
+
'std' => 0,
|
765 |
+
'priority' => 30,
|
766 |
+
'step' => 1,
|
767 |
+
'min' => - 50,
|
768 |
+
'max' => 50,
|
769 |
+
'unit' => 'px',
|
770 |
+
],
|
771 |
+
'title_textshadow_vertical' => [
|
772 |
+
'label' => __( 'Vertical Position', 'popup-maker' ),
|
773 |
+
'type' => 'rangeslider',
|
774 |
+
'std' => 0,
|
775 |
+
'priority' => 40,
|
776 |
+
'step' => 1,
|
777 |
+
'min' => - 50,
|
778 |
+
'max' => 50,
|
779 |
+
'unit' => 'px',
|
780 |
+
],
|
781 |
+
'title_textshadow_blur' => [
|
782 |
+
'label' => __( 'Blur Radius', 'popup-maker' ),
|
783 |
+
'type' => 'rangeslider',
|
784 |
+
'std' => 0,
|
785 |
+
'priority' => 50,
|
786 |
+
'step' => 1,
|
787 |
+
'min' => 0,
|
788 |
+
'max' => 100,
|
789 |
+
'unit' => 'px',
|
790 |
+
],
|
791 |
+
],
|
792 |
+
]
|
793 |
),
|
794 |
+
'content' => apply_filters(
|
795 |
+
'pum_theme_content_settings_fields',
|
796 |
+
[
|
797 |
+
'typography' => [
|
798 |
+
'content_font_color' => [
|
799 |
+
'label' => __( 'Color', 'popup-maker' ),
|
800 |
+
'type' => 'color',
|
801 |
+
'std' => '#8c8c8c',
|
802 |
+
'priority' => 10,
|
803 |
+
],
|
804 |
+
'content_font_family' => [
|
805 |
+
'label' => __( 'Font Family', 'popup-maker' ),
|
806 |
+
'type' => 'select',
|
807 |
+
'select2' => true,
|
808 |
+
'std' => 'inherit',
|
809 |
+
'priority' => 20,
|
810 |
+
'options' => $font_family_options,
|
811 |
+
],
|
812 |
+
'content_font_weight' => [
|
813 |
+
'label' => __( 'Font Weight', 'popup-maker' ),
|
814 |
+
'type' => 'select',
|
815 |
+
'std' => 400,
|
816 |
+
'priority' => 30,
|
817 |
+
'options' => $font_weight_options,
|
818 |
+
],
|
819 |
+
'content_font_style' => [
|
820 |
+
'label' => __( 'Style', 'popup-maker' ),
|
821 |
+
'type' => 'select',
|
822 |
+
'std' => 'inherit',
|
823 |
+
'priority' => 40,
|
824 |
+
'options' => [
|
825 |
+
'' => __( 'Normal', 'popup-maker' ),
|
826 |
+
'italic' => __( 'Italic', 'popup-maker' ),
|
827 |
+
],
|
828 |
+
],
|
829 |
+
],
|
830 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
),
|
832 |
+
'close' => apply_filters(
|
833 |
+
'pum_theme_close_settings_fields',
|
834 |
+
[
|
835 |
+
'main' => [
|
836 |
+
'close_text' => [
|
837 |
+
'label' => __( 'Close Button Text', 'popup-maker' ),
|
838 |
+
'desc' => __( 'To use a Font Awesome icon instead of text, enter the CSS classes such as "fas fa-camera".', 'popup-maker' ),
|
839 |
+
'placeholder' => __( 'CLOSE', 'popup-maker' ),
|
840 |
+
'std' => __( 'CLOSE', 'popup-maker' ),
|
841 |
+
'priority' => 10,
|
842 |
+
],
|
843 |
+
'close_position_outside' => [
|
844 |
+
'label' => __( 'Position Outside Container', 'popup-maker' ),
|
845 |
+
'desc' => __( 'This moves the position of the close button outside the popup.', 'popup-maker' ),
|
846 |
+
'type' => 'checkbox',
|
847 |
+
'priority' => 20,
|
848 |
+
],
|
849 |
+
'close_location' => [
|
850 |
+
'label' => __( 'Location', 'popup-maker' ),
|
851 |
+
'type' => 'select',
|
852 |
+
'std' => 'topright',
|
853 |
+
'priority' => 30,
|
854 |
+
'options' => [
|
855 |
+
'topleft' => __( 'Top Left', 'popup-maker' ),
|
856 |
+
'topcenter' => __( 'Top Center', 'popup-maker' ),
|
857 |
+
'topright' => __( 'Top Right', 'popup-maker' ),
|
858 |
+
'middleleft' => __( 'Middle Left', 'popup-maker' ),
|
859 |
+
'middleright' => __( 'Middle Right', 'popup-maker' ),
|
860 |
+
'bottomleft' => __( 'Bottom Left', 'popup-maker' ),
|
861 |
+
'bottomcenter' => __( 'Bottom Center', 'popup-maker' ),
|
862 |
+
'bottomright' => __( 'Bottom Right', 'popup-maker' ),
|
863 |
+
],
|
864 |
+
],
|
865 |
+
'close_position_top' => [
|
866 |
+
'label' => __( 'Top', 'popup-maker' ),
|
867 |
+
'type' => 'rangeslider',
|
868 |
+
'std' => 0,
|
869 |
+
'priority' => 40,
|
870 |
+
'step' => 1,
|
871 |
+
'min' => - 100,
|
872 |
+
'max' => 100,
|
873 |
+
'unit' => 'px',
|
874 |
+
'dependencies' => [
|
875 |
+
'close_location' => [ 'topleft', 'topcenter', 'topright' ],
|
876 |
+
],
|
877 |
+
],
|
878 |
+
|
879 |
+
'close_position_bottom' => [
|
880 |
+
'label' => __( 'Bottom', 'popup-maker' ),
|
881 |
+
'type' => 'rangeslider',
|
882 |
+
'std' => 0,
|
883 |
+
'priority' => 50,
|
884 |
+
'step' => 1,
|
885 |
+
'min' => - 100,
|
886 |
+
'max' => 100,
|
887 |
+
'unit' => 'px',
|
888 |
+
'dependencies' => [
|
889 |
+
'close_location' => [ 'bottomleft', 'bottomcenter', 'bottomright' ],
|
890 |
+
],
|
891 |
+
],
|
892 |
+
'close_position_left' => [
|
893 |
+
'label' => __( 'Left', 'popup-maker' ),
|
894 |
+
'type' => 'rangeslider',
|
895 |
+
'std' => 0,
|
896 |
+
'priority' => 60,
|
897 |
+
'step' => 1,
|
898 |
+
'min' => - 100,
|
899 |
+
'max' => 100,
|
900 |
+
'unit' => 'px',
|
901 |
+
'dependencies' => [
|
902 |
+
'close_location' => [ 'topleft', 'middleleft', 'bottomleft' ],
|
903 |
+
],
|
904 |
+
],
|
905 |
+
'close_position_right' => [
|
906 |
+
'label' => __( 'Right', 'popup-maker' ),
|
907 |
+
'type' => 'rangeslider',
|
908 |
+
'std' => 0,
|
909 |
+
'priority' => 70,
|
910 |
+
'step' => 1,
|
911 |
+
'min' => - 100,
|
912 |
+
'max' => 100,
|
913 |
+
'unit' => 'px',
|
914 |
+
'dependencies' => [
|
915 |
+
'close_location' => [ 'topright', 'middleright', 'bottomright' ],
|
916 |
+
],
|
917 |
+
],
|
918 |
+
|
919 |
+
],
|
920 |
+
'size' => [
|
921 |
+
'close_padding' => [
|
922 |
+
'label' => __( 'Padding', 'popup-maker' ),
|
923 |
+
'type' => 'rangeslider',
|
924 |
+
'std' => 8,
|
925 |
+
'priority' => 10,
|
926 |
+
'step' => 1,
|
927 |
+
'min' => 0,
|
928 |
+
'max' => 100,
|
929 |
+
'unit' => 'px',
|
930 |
+
],
|
931 |
+
'close_height' => [
|
932 |
+
'label' => __( 'Height', 'popup-maker' ),
|
933 |
+
'type' => 'rangeslider',
|
934 |
+
'std' => 0,
|
935 |
+
'priority' => 20,
|
936 |
+
'step' => 1,
|
937 |
+
'min' => 0,
|
938 |
+
'max' => 100,
|
939 |
+
'unit' => 'px',
|
940 |
+
],
|
941 |
+
'close_width' => [
|
942 |
+
'label' => __( 'Width', 'popup-maker' ),
|
943 |
+
'type' => 'rangeslider',
|
944 |
+
'std' => 0,
|
945 |
+
'priority' => 30,
|
946 |
+
'step' => 1,
|
947 |
+
'min' => 0,
|
948 |
+
'max' => 100,
|
949 |
+
'unit' => 'px',
|
950 |
+
],
|
951 |
+
'close_border_radius' => [
|
952 |
+
'label' => __( 'Border Radius', 'popup-maker' ),
|
953 |
+
'type' => 'rangeslider',
|
954 |
+
'std' => 0,
|
955 |
+
'priority' => 40,
|
956 |
+
'step' => 1,
|
957 |
+
'min' => 1,
|
958 |
+
'max' => 28,
|
959 |
+
'unit' => 'px',
|
960 |
+
],
|
961 |
+
],
|
962 |
+
'background' => [
|
963 |
+
'close_background_color' => [
|
964 |
+
'label' => __( 'Color', 'popup-maker' ),
|
965 |
+
'type' => 'color',
|
966 |
+
'std' => '#00b7cd',
|
967 |
+
'priority' => 10,
|
968 |
+
],
|
969 |
+
'close_background_opacity' => [
|
970 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
971 |
+
'type' => 'rangeslider',
|
972 |
+
'std' => 100,
|
973 |
+
'priority' => 20,
|
974 |
+
'step' => 1,
|
975 |
+
'min' => 0,
|
976 |
+
'max' => 100,
|
977 |
+
'unit' => '%',
|
978 |
+
'force_minmax' => true,
|
979 |
+
],
|
980 |
+
],
|
981 |
+
'typography' => [
|
982 |
+
'close_font_color' => [
|
983 |
+
'label' => __( 'Color', 'popup-maker' ),
|
984 |
+
'type' => 'color',
|
985 |
+
'std' => '#ffffff',
|
986 |
+
'priority' => 10,
|
987 |
+
],
|
988 |
+
'close_font_size' => [
|
989 |
+
'label' => __( 'Font Size', 'popup-maker' ),
|
990 |
+
'type' => 'rangeslider',
|
991 |
+
'std' => 12,
|
992 |
+
'priority' => 20,
|
993 |
+
'step' => 1,
|
994 |
+
'min' => 8,
|
995 |
+
'max' => 32,
|
996 |
+
'unit' => 'px',
|
997 |
+
],
|
998 |
+
'close_line_height' => [
|
999 |
+
'label' => __( 'Line Height', 'popup-maker' ),
|
1000 |
+
'type' => 'rangeslider',
|
1001 |
+
'std' => 36,
|
1002 |
+
'priority' => 30,
|
1003 |
+
'step' => 1,
|
1004 |
+
'min' => 8,
|
1005 |
+
'max' => 54,
|
1006 |
+
'unit' => 'px',
|
1007 |
+
],
|
1008 |
+
'close_font_family' => [
|
1009 |
+
'label' => __( 'Font Family', 'popup-maker' ),
|
1010 |
+
'type' => 'select',
|
1011 |
+
'select2' => true,
|
1012 |
+
'std' => 'inherit',
|
1013 |
+
'priority' => 40,
|
1014 |
+
'options' => $font_family_options,
|
1015 |
+
],
|
1016 |
+
'close_font_weight' => [
|
1017 |
+
'label' => __( 'Font Weight', 'popup-maker' ),
|
1018 |
+
'type' => 'select',
|
1019 |
+
'std' => 400,
|
1020 |
+
'priority' => 50,
|
1021 |
+
'options' => $font_weight_options,
|
1022 |
+
],
|
1023 |
+
'close_font_style' => [
|
1024 |
+
'label' => __( 'Style', 'popup-maker' ),
|
1025 |
+
'type' => 'select',
|
1026 |
+
'std' => 'inherit',
|
1027 |
+
'priority' => 60,
|
1028 |
+
'options' => [
|
1029 |
+
'' => __( 'Normal', 'popup-maker' ),
|
1030 |
+
'italic' => __( 'Italic', 'popup-maker' ),
|
1031 |
+
],
|
1032 |
+
],
|
1033 |
+
],
|
1034 |
+
'border' => [
|
1035 |
+
'close_border_style' => [
|
1036 |
+
'label' => __( 'Style', 'popup-maker' ),
|
1037 |
+
'type' => 'select',
|
1038 |
+
'std' => 'none',
|
1039 |
+
'priority' => 10,
|
1040 |
+
'options' => $border_style_options,
|
1041 |
+
],
|
1042 |
+
'close_border_color' => [
|
1043 |
+
'label' => __( 'Color', 'popup-maker' ),
|
1044 |
+
'type' => 'color',
|
1045 |
+
'std' => '#ffffff',
|
1046 |
+
'priority' => 20,
|
1047 |
+
'dependencies' => [
|
1048 |
+
'close_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, [ 'none' ] ) ),
|
1049 |
+
],
|
1050 |
+
],
|
1051 |
+
'close_border_width' => [
|
1052 |
+
'label' => __( 'Thickness', 'popup-maker' ),
|
1053 |
+
'type' => 'rangeslider',
|
1054 |
+
'std' => 1,
|
1055 |
+
'priority' => 30,
|
1056 |
+
'step' => 1,
|
1057 |
+
'min' => 1,
|
1058 |
+
'max' => 5,
|
1059 |
+
'unit' => 'px',
|
1060 |
+
'dependencies' => [
|
1061 |
+
'close_border_style' => array_keys( PUM_Utils_Array::remove_keys( $border_style_options, [ 'none' ] ) ),
|
1062 |
+
],
|
1063 |
+
],
|
1064 |
+
],
|
1065 |
+
'boxshadow' => [
|
1066 |
+
'close_boxshadow_color' => [
|
1067 |
+
'label' => __( 'Color', 'popup-maker' ),
|
1068 |
+
'type' => 'color',
|
1069 |
+
'std' => '#020202',
|
1070 |
+
'priority' => 10,
|
1071 |
+
],
|
1072 |
+
'close_boxshadow_opacity' => [
|
1073 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
1074 |
+
'type' => 'rangeslider',
|
1075 |
+
'std' => 23,
|
1076 |
+
'priority' => 20,
|
1077 |
+
'step' => 1,
|
1078 |
+
'min' => 0,
|
1079 |
+
'max' => 100,
|
1080 |
+
'unit' => '%',
|
1081 |
+
'force_minmax' => true,
|
1082 |
+
],
|
1083 |
+
'close_boxshadow_horizontal' => [
|
1084 |
+
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
1085 |
+
'type' => 'rangeslider',
|
1086 |
+
'std' => 1,
|
1087 |
+
'priority' => 30,
|
1088 |
+
'step' => 1,
|
1089 |
+
'min' => - 50,
|
1090 |
+
'max' => 50,
|
1091 |
+
'unit' => 'px',
|
1092 |
+
],
|
1093 |
+
'close_boxshadow_vertical' => [
|
1094 |
+
'label' => __( 'Vertical Position', 'popup-maker' ),
|
1095 |
+
'type' => 'rangeslider',
|
1096 |
+
'std' => 1,
|
1097 |
+
'priority' => 40,
|
1098 |
+
'step' => 1,
|
1099 |
+
'min' => - 50,
|
1100 |
+
'max' => 50,
|
1101 |
+
'unit' => 'px',
|
1102 |
+
],
|
1103 |
+
'close_boxshadow_blur' => [
|
1104 |
+
'label' => __( 'Blur Radius', 'popup-maker' ),
|
1105 |
+
'type' => 'rangeslider',
|
1106 |
+
'std' => 3,
|
1107 |
+
'priority' => 50,
|
1108 |
+
'step' => 1,
|
1109 |
+
'min' => 0,
|
1110 |
+
'max' => 100,
|
1111 |
+
'unit' => 'px',
|
1112 |
+
],
|
1113 |
+
'close_boxshadow_spread' => [
|
1114 |
+
'label' => __( 'Spread', 'popup-maker' ),
|
1115 |
+
'type' => 'rangeslider',
|
1116 |
+
'std' => 0,
|
1117 |
+
'priority' => 60,
|
1118 |
+
'step' => 1,
|
1119 |
+
'min' => - 100,
|
1120 |
+
'max' => 100,
|
1121 |
+
'unit' => 'px',
|
1122 |
+
],
|
1123 |
+
'close_boxshadow_inset' => [
|
1124 |
+
'label' => __( 'Inset (inner shadow)', 'popup-maker' ),
|
1125 |
+
'type' => 'select',
|
1126 |
+
'std' => 'no',
|
1127 |
+
'priority' => 70,
|
1128 |
+
'options' => [
|
1129 |
+
'no' => __( 'No', 'popup-maker' ),
|
1130 |
+
'yes' => __( 'Yes', 'popup-maker' ),
|
1131 |
+
],
|
1132 |
+
],
|
1133 |
+
],
|
1134 |
+
'textshadow' => [
|
1135 |
+
'close_textshadow_color' => [
|
1136 |
+
'label' => __( 'Color', 'popup-maker' ),
|
1137 |
+
'type' => 'color',
|
1138 |
+
'std' => '#000000',
|
1139 |
+
'priority' => 10,
|
1140 |
+
],
|
1141 |
+
'close_textshadow_opacity' => [
|
1142 |
+
'label' => __( 'Opacity', 'popup-maker' ),
|
1143 |
+
'type' => 'rangeslider',
|
1144 |
+
'std' => 23,
|
1145 |
+
'priority' => 20,
|
1146 |
+
'step' => 1,
|
1147 |
+
'min' => 0,
|
1148 |
+
'max' => 100,
|
1149 |
+
'force_minmax' => true,
|
1150 |
+
'unit' => '%',
|
1151 |
+
],
|
1152 |
+
'close_textshadow_horizontal' => [
|
1153 |
+
'label' => __( 'Horizontal Position', 'popup-maker' ),
|
1154 |
+
'type' => 'rangeslider',
|
1155 |
+
'std' => 0,
|
1156 |
+
'priority' => 30,
|
1157 |
+
'step' => 1,
|
1158 |
+
'min' => - 50,
|
1159 |
+
'max' => 50,
|
1160 |
+
'unit' => 'px',
|
1161 |
+
],
|
1162 |
+
'close_textshadow_vertical' => [
|
1163 |
+
'label' => __( 'Vertical Position', 'popup-maker' ),
|
1164 |
+
'type' => 'rangeslider',
|
1165 |
+
'std' => 0,
|
1166 |
+
'priority' => 40,
|
1167 |
+
'step' => 1,
|
1168 |
+
'min' => - 50,
|
1169 |
+
'max' => 50,
|
1170 |
+
'unit' => 'px',
|
1171 |
+
],
|
1172 |
+
'close_textshadow_blur' => [
|
1173 |
+
'label' => __( 'Blur Radius', 'popup-maker' ),
|
1174 |
+
'type' => 'rangeslider',
|
1175 |
+
'std' => 0,
|
1176 |
+
'priority' => 50,
|
1177 |
+
'step' => 1,
|
1178 |
+
'min' => 0,
|
1179 |
+
'max' => 100,
|
1180 |
+
'unit' => 'px',
|
1181 |
+
],
|
1182 |
+
],
|
1183 |
+
]
|
1184 |
),
|
1185 |
+
'advanced' => apply_filters(
|
1186 |
+
'pum_theme_advanced_settings_fields',
|
1187 |
+
[
|
1188 |
+
'main' => [],
|
1189 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1190 |
),
|
1191 |
+
]
|
1192 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1193 |
|
1194 |
$fields = self::append_deprecated_fields( $fields );
|
1195 |
|
1196 |
+
$fields = PUM_Utils_Fields::parse_tab_fields(
|
1197 |
+
$fields,
|
1198 |
+
[
|
1199 |
+
'has_sections' => true,
|
1200 |
+
'name' => 'theme_settings[%s]',
|
1201 |
+
]
|
1202 |
+
);
|
1203 |
|
1204 |
}
|
1205 |
|
1206 |
return $fields;
|
1207 |
}
|
1208 |
|
1209 |
+
public static function append_deprecated_fields( $fields = [] ) {
|
1210 |
global $post;
|
1211 |
|
1212 |
if ( class_exists( 'PUM_ATB' ) && has_action( 'popmake_popup_theme_overlay_meta_box_fields' ) ) {
|
1216 |
|
1217 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1218 |
|
1219 |
+
$fields['overlay']['background']['deprecated_fields'] = [
|
1220 |
'type' => 'html',
|
1221 |
'content' => $content,
|
1222 |
'priority' => 999,
|
1223 |
+
];
|
1224 |
|
1225 |
// Remove duplicate fields.
|
1226 |
unset( $fields['overlay']['background']['overlay_background_color'] );
|
1234 |
|
1235 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1236 |
|
1237 |
+
$fields['container']['background']['deprecated_fields'] = [
|
1238 |
'type' => 'html',
|
1239 |
'content' => $content,
|
1240 |
'priority' => 999,
|
1241 |
+
];
|
1242 |
|
1243 |
// Remove duplicate fields.
|
1244 |
unset( $fields['container']['background']['container_background_color'] );
|
1252 |
|
1253 |
$content = self::fix_deprecated_fields( ob_get_clean() );
|
1254 |
|
1255 |
+
$fields['close']['background']['deprecated_fields'] = [
|
1256 |
'type' => 'html',
|
1257 |
'content' => $content,
|
1258 |
'priority' => 999,
|
1259 |
+
];
|
1260 |
|
1261 |
// Remove duplicate fields.
|
1262 |
unset( $fields['close']['background']['close_background_color'] );
|
1269 |
public static function fix_deprecated_fields( $content = '' ) {
|
1270 |
|
1271 |
// Remove "Background" heading.
|
1272 |
+
$content = str_replace(
|
1273 |
+
'<tr class="title-divider">
|
1274 |
<th colspan="2">
|
1275 |
<h3 class="title">Background</h3>
|
1276 |
</th>
|
1277 |
+
</tr>',
|
1278 |
+
'',
|
1279 |
+
$content
|
1280 |
+
);
|
1281 |
|
1282 |
// Fix broken opacity fields.
|
1283 |
+
$content = str_replace( [ 'class="bg_opacity"', 'class="bg_overlay_opacity"' ], [ 'class="bg_opacity pum-field-rangeslider"', 'class="bg_overlay_opacity pum-field-rangeslider"' ], $content );
|
1284 |
|
1285 |
// TEMPORARY. REMOVE THIS
|
1286 |
$content = '<table class="form-table"><tbody>' . $content . '</tbody></table>';
|
1287 |
|
1288 |
return $content;
|
1289 |
|
|
|
1290 |
}
|
1291 |
|
1292 |
/**
|
classes/Admin/Tools.php
CHANGED
@@ -15,20 +15,20 @@ class PUM_Admin_Tools {
|
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
-
public static $notices =
|
19 |
|
20 |
/**
|
21 |
* Initializes the "Tools" page.
|
22 |
*/
|
23 |
public static function init() {
|
24 |
-
add_action( 'admin_notices',
|
25 |
-
add_action( 'admin_init',
|
26 |
-
add_action( 'pum_tools_page_tab_betas',
|
27 |
-
add_action( 'pum_tools_page_tab_error_log',
|
28 |
-
add_action( 'pum_tools_page_tab_action_scheduler',
|
29 |
-
add_action( 'pum_tools_page_tab_import',
|
30 |
-
add_action( 'pum_save_enabled_betas',
|
31 |
-
add_action( 'pum_empty_error_log',
|
32 |
}
|
33 |
|
34 |
/**
|
@@ -45,10 +45,10 @@ class PUM_Admin_Tools {
|
|
45 |
}
|
46 |
|
47 |
if ( isset( $_GET['success'] ) && get_option( 'pum_settings_admin_notice' ) ) {
|
48 |
-
self::$notices[] =
|
49 |
'type' => $_GET['success'] ? 'success' : 'error',
|
50 |
'message' => get_option( 'pum_settings_admin_notice' ),
|
51 |
-
|
52 |
|
53 |
delete_option( 'pum_settings_admin_notice' );
|
54 |
}
|
@@ -87,10 +87,10 @@ class PUM_Admin_Tools {
|
|
87 |
<?php
|
88 |
foreach ( self::tabs() as $tab_id => $tab_name ) {
|
89 |
$tab_url = add_query_arg(
|
90 |
-
|
91 |
'tools-updated' => false,
|
92 |
'tab' => $tab_id,
|
93 |
-
|
94 |
);
|
95 |
|
96 |
printf( '<a href="%s" title="%s" class="nav-tab %s">%s</a>', esc_url( $tab_url ), esc_attr( $tab_name ), $active_tab == $tab_id ? ' nav-tab-active' : '', esc_html( $tab_name ) );
|
@@ -121,12 +121,12 @@ class PUM_Admin_Tools {
|
|
121 |
if ( ! isset( $tabs ) ) {
|
122 |
$tabs = apply_filters(
|
123 |
'pum_tools_tabs',
|
124 |
-
|
125 |
'betas' => __( 'Beta Versions', 'popup-maker' ),
|
126 |
'error_log' => __( 'Error Log', 'popup-maker' ),
|
127 |
'action_scheduler' => __( 'Scheduled Actions', 'popup-maker' ),
|
128 |
'import' => __( 'Import / Export', 'popup-maker' ),
|
129 |
-
|
130 |
);
|
131 |
|
132 |
/** @deprecated 1.7.0 */
|
@@ -145,7 +145,7 @@ class PUM_Admin_Tools {
|
|
145 |
* @since 1.5
|
146 |
*/
|
147 |
public static function get_beta_enabled_extensions() {
|
148 |
-
return apply_filters( 'pum_beta_enabled_extensions',
|
149 |
}
|
150 |
|
151 |
/**
|
@@ -277,7 +277,7 @@ class PUM_Admin_Tools {
|
|
277 |
return;
|
278 |
}
|
279 |
popmake_emodal_v2_import();
|
280 |
-
|
281 |
}
|
282 |
|
283 |
/**
|
@@ -297,10 +297,10 @@ class PUM_Admin_Tools {
|
|
297 |
if ( ! empty( $_POST['enabled_betas'] ) ) {
|
298 |
$enabled_betas = array_filter(
|
299 |
array_map(
|
300 |
-
|
301 |
__CLASS__,
|
302 |
'enabled_betas_sanitize_value',
|
303 |
-
|
304 |
$_POST['enabled_betas']
|
305 |
)
|
306 |
);
|
@@ -331,7 +331,7 @@ class PUM_Admin_Tools {
|
|
331 |
* @since 1.5
|
332 |
*/
|
333 |
public static function extension_has_beta_support( $slug ) {
|
334 |
-
$enabled_betas = PUM_Utils_Options::get( 'enabled_betas',
|
335 |
$return = false;
|
336 |
|
337 |
if ( array_key_exists( $slug, $enabled_betas ) ) {
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
+
public static $notices = [];
|
19 |
|
20 |
/**
|
21 |
* Initializes the "Tools" page.
|
22 |
*/
|
23 |
public static function init() {
|
24 |
+
add_action( 'admin_notices', [ __CLASS__, 'notices' ] );
|
25 |
+
add_action( 'admin_init', [ __CLASS__, 'emodal_process_import' ] );
|
26 |
+
add_action( 'pum_tools_page_tab_betas', [ __CLASS__, 'betas_display' ] );
|
27 |
+
add_action( 'pum_tools_page_tab_error_log', [ __CLASS__, 'errorlog_display' ] );
|
28 |
+
add_action( 'pum_tools_page_tab_action_scheduler', [ __CLASS__, 'action_scheduler_display' ] );
|
29 |
+
add_action( 'pum_tools_page_tab_import', [ __CLASS__, 'import_display' ] );
|
30 |
+
add_action( 'pum_save_enabled_betas', [ __CLASS__, 'save_enabled_betas' ] );
|
31 |
+
add_action( 'pum_empty_error_log', [ __CLASS__, 'error_log_empty' ] );
|
32 |
}
|
33 |
|
34 |
/**
|
45 |
}
|
46 |
|
47 |
if ( isset( $_GET['success'] ) && get_option( 'pum_settings_admin_notice' ) ) {
|
48 |
+
self::$notices[] = [
|
49 |
'type' => $_GET['success'] ? 'success' : 'error',
|
50 |
'message' => get_option( 'pum_settings_admin_notice' ),
|
51 |
+
];
|
52 |
|
53 |
delete_option( 'pum_settings_admin_notice' );
|
54 |
}
|
87 |
<?php
|
88 |
foreach ( self::tabs() as $tab_id => $tab_name ) {
|
89 |
$tab_url = add_query_arg(
|
90 |
+
[
|
91 |
'tools-updated' => false,
|
92 |
'tab' => $tab_id,
|
93 |
+
]
|
94 |
);
|
95 |
|
96 |
printf( '<a href="%s" title="%s" class="nav-tab %s">%s</a>', esc_url( $tab_url ), esc_attr( $tab_name ), $active_tab == $tab_id ? ' nav-tab-active' : '', esc_html( $tab_name ) );
|
121 |
if ( ! isset( $tabs ) ) {
|
122 |
$tabs = apply_filters(
|
123 |
'pum_tools_tabs',
|
124 |
+
[
|
125 |
'betas' => __( 'Beta Versions', 'popup-maker' ),
|
126 |
'error_log' => __( 'Error Log', 'popup-maker' ),
|
127 |
'action_scheduler' => __( 'Scheduled Actions', 'popup-maker' ),
|
128 |
'import' => __( 'Import / Export', 'popup-maker' ),
|
129 |
+
]
|
130 |
);
|
131 |
|
132 |
/** @deprecated 1.7.0 */
|
145 |
* @since 1.5
|
146 |
*/
|
147 |
public static function get_beta_enabled_extensions() {
|
148 |
+
return apply_filters( 'pum_beta_enabled_extensions', [] );
|
149 |
}
|
150 |
|
151 |
/**
|
277 |
return;
|
278 |
}
|
279 |
popmake_emodal_v2_import();
|
280 |
+
wp_safe_redirect( admin_url( 'edit.php?post_type=popup&page=pum-tools&imported=1' ), 302 );
|
281 |
}
|
282 |
|
283 |
/**
|
297 |
if ( ! empty( $_POST['enabled_betas'] ) ) {
|
298 |
$enabled_betas = array_filter(
|
299 |
array_map(
|
300 |
+
[
|
301 |
__CLASS__,
|
302 |
'enabled_betas_sanitize_value',
|
303 |
+
],
|
304 |
$_POST['enabled_betas']
|
305 |
)
|
306 |
);
|
331 |
* @since 1.5
|
332 |
*/
|
333 |
public static function extension_has_beta_support( $slug ) {
|
334 |
+
$enabled_betas = PUM_Utils_Options::get( 'enabled_betas', [] );
|
335 |
$return = false;
|
336 |
|
337 |
if ( array_key_exists( $slug, $enabled_betas ) ) {
|
classes/Ajax.php
CHANGED
@@ -18,7 +18,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
18 |
|
19 |
/**
|
20 |
* Controls the basic analytics methods for Popup Maker
|
21 |
-
*
|
22 |
*/
|
23 |
class PUM_Ajax {
|
24 |
|
@@ -26,7 +25,7 @@ class PUM_Ajax {
|
|
26 |
* Creates and returns a 1x1 tracking gif to the browser.
|
27 |
*/
|
28 |
public static function serve_pixel() {
|
29 |
-
$gif =
|
30 |
header( 'Content-Type: image/gif' );
|
31 |
header( 'Content-Length: ' . strlen( $gif ) );
|
32 |
exit( $gif );
|
@@ -49,7 +48,7 @@ class PUM_Ajax {
|
|
49 |
* Returns a 204 no content header.
|
50 |
*/
|
51 |
public static function serve_no_content() {
|
52 |
-
header(
|
53 |
header( 'Content-Type: image/gif' );
|
54 |
header( 'Content-Length: 0' );
|
55 |
exit;
|
18 |
|
19 |
/**
|
20 |
* Controls the basic analytics methods for Popup Maker
|
|
|
21 |
*/
|
22 |
class PUM_Ajax {
|
23 |
|
25 |
* Creates and returns a 1x1 tracking gif to the browser.
|
26 |
*/
|
27 |
public static function serve_pixel() {
|
28 |
+
$gif = self::get_file( POPMAKE_DIR . 'assets/images/beacon.gif' );
|
29 |
header( 'Content-Type: image/gif' );
|
30 |
header( 'Content-Length: ' . strlen( $gif ) );
|
31 |
exit( $gif );
|
48 |
* Returns a 204 no content header.
|
49 |
*/
|
50 |
public static function serve_no_content() {
|
51 |
+
header( 'HTTP/1.0 204 No Content' );
|
52 |
header( 'Content-Type: image/gif' );
|
53 |
header( 'Content-Length: 0' );
|
54 |
exit;
|
classes/Analytics.php
CHANGED
@@ -20,10 +20,10 @@ class PUM_Analytics {
|
|
20 |
return;
|
21 |
}
|
22 |
|
23 |
-
add_action( 'rest_api_init',
|
24 |
-
add_action( 'wp_ajax_pum_analytics',
|
25 |
-
add_action( 'wp_ajax_nopriv_pum_analytics',
|
26 |
-
add_filter( 'pum_vars',
|
27 |
}
|
28 |
|
29 |
/**
|
@@ -52,7 +52,7 @@ class PUM_Analytics {
|
|
52 |
* @return mixed
|
53 |
*/
|
54 |
public static function event_keys( $event ) {
|
55 |
-
$keys =
|
56 |
|
57 |
if ( 'conversion' === $event ) {
|
58 |
$keys[1] = 'conversion';
|
@@ -67,7 +67,7 @@ class PUM_Analytics {
|
|
67 |
* @return string[]
|
68 |
*/
|
69 |
public static function valid_events() {
|
70 |
-
return apply_filters( 'pum_analytics_valid_events',
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -79,13 +79,13 @@ class PUM_Analytics {
|
|
79 |
*
|
80 |
* @param array $args
|
81 |
*/
|
82 |
-
public static function track( $args =
|
83 |
-
if ( empty
|
84 |
return;
|
85 |
}
|
86 |
|
87 |
-
//
|
88 |
-
//
|
89 |
|
90 |
$event = sanitize_text_field( $args['event'] );
|
91 |
|
@@ -111,11 +111,14 @@ class PUM_Analytics {
|
|
111 |
*/
|
112 |
public static function ajax_request() {
|
113 |
|
114 |
-
$args = wp_parse_args(
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
119 |
|
120 |
self::track( $args );
|
121 |
|
@@ -144,7 +147,7 @@ class PUM_Analytics {
|
|
144 |
$args = $request->get_params();
|
145 |
|
146 |
if ( ! $args || empty( $args['pid'] ) ) {
|
147 |
-
return new WP_Error( 'missing_params', __( 'Missing Parameters.' ),
|
148 |
}
|
149 |
|
150 |
self::track( $args );
|
@@ -167,25 +170,32 @@ class PUM_Analytics {
|
|
167 |
* Registers the analytics endpoints
|
168 |
*/
|
169 |
public static function register_endpoints() {
|
170 |
-
register_rest_route(
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -194,7 +204,7 @@ class PUM_Analytics {
|
|
194 |
* @param array $vars The current pum_vars.
|
195 |
* @return array The updates pum_vars
|
196 |
*/
|
197 |
-
public static function pum_vars( $vars =
|
198 |
$vars['analytics_route'] = self::get_analytics_route();
|
199 |
if ( function_exists( 'rest_url' ) ) {
|
200 |
$vars['analytics_api'] = esc_url_raw( rest_url( self::get_analytics_namespace() ) );
|
@@ -289,7 +299,7 @@ class PUM_Analytics {
|
|
289 |
* Returns a 204 no content header.
|
290 |
*/
|
291 |
public static function serve_no_content() {
|
292 |
-
header(
|
293 |
header( 'Content-Type: image/gif' );
|
294 |
header( 'Content-Length: 0' );
|
295 |
exit;
|
20 |
return;
|
21 |
}
|
22 |
|
23 |
+
add_action( 'rest_api_init', [ __CLASS__, 'register_endpoints' ] );
|
24 |
+
add_action( 'wp_ajax_pum_analytics', [ __CLASS__, 'ajax_request' ] );
|
25 |
+
add_action( 'wp_ajax_nopriv_pum_analytics', [ __CLASS__, 'ajax_request' ] );
|
26 |
+
add_filter( 'pum_vars', [ __CLASS__, 'pum_vars' ] );
|
27 |
}
|
28 |
|
29 |
/**
|
52 |
* @return mixed
|
53 |
*/
|
54 |
public static function event_keys( $event ) {
|
55 |
+
$keys = [ $event, rtrim( $event, 'e' ) . 'ed' ];
|
56 |
|
57 |
if ( 'conversion' === $event ) {
|
58 |
$keys[1] = 'conversion';
|
67 |
* @return string[]
|
68 |
*/
|
69 |
public static function valid_events() {
|
70 |
+
return apply_filters( 'pum_analytics_valid_events', [ 'open', 'conversion' ] );
|
71 |
}
|
72 |
|
73 |
/**
|
79 |
*
|
80 |
* @param array $args
|
81 |
*/
|
82 |
+
public static function track( $args = [] ) {
|
83 |
+
if ( empty( $args['pid'] ) || $args['pid'] <= 0 ) {
|
84 |
return;
|
85 |
}
|
86 |
|
87 |
+
// $uuid = isset( $_COOKIE['__pum'] ) ? sanitize_text_field( $_COOKIE['__pum'] ) : false;
|
88 |
+
// $session = $uuid && isset( $_COOKIE[ $uuid ] ) ? PUM_Utils_Array::safe_json_decode( $_COOKIE[ $uuid ] ) : false;
|
89 |
|
90 |
$event = sanitize_text_field( $args['event'] );
|
91 |
|
111 |
*/
|
112 |
public static function ajax_request() {
|
113 |
|
114 |
+
$args = wp_parse_args(
|
115 |
+
$_REQUEST,
|
116 |
+
[
|
117 |
+
'event' => null,
|
118 |
+
'pid' => null,
|
119 |
+
'method' => null,
|
120 |
+
]
|
121 |
+
);
|
122 |
|
123 |
self::track( $args );
|
124 |
|
147 |
$args = $request->get_params();
|
148 |
|
149 |
if ( ! $args || empty( $args['pid'] ) ) {
|
150 |
+
return new WP_Error( 'missing_params', __( 'Missing Parameters.' ), [ 'status' => 404 ] );
|
151 |
}
|
152 |
|
153 |
self::track( $args );
|
170 |
* Registers the analytics endpoints
|
171 |
*/
|
172 |
public static function register_endpoints() {
|
173 |
+
register_rest_route(
|
174 |
+
self::get_analytics_namespace(),
|
175 |
+
self::get_analytics_route(),
|
176 |
+
apply_filters(
|
177 |
+
'pum_analytics_rest_route_args',
|
178 |
+
[
|
179 |
+
'methods' => 'GET',
|
180 |
+
'callback' => [ __CLASS__, 'analytics_endpoint' ],
|
181 |
+
'permission_callback' => '__return_true',
|
182 |
+
'args' => [
|
183 |
+
'event' => [
|
184 |
+
'required' => true,
|
185 |
+
'description' => __( 'Event Type', 'popup-maker' ),
|
186 |
+
'type' => 'string',
|
187 |
+
],
|
188 |
+
'pid' => [
|
189 |
+
'required' => true,
|
190 |
+
'description' => __( 'Popup ID', 'popup-maker' ),
|
191 |
+
'type' => 'integer',
|
192 |
+
'validation_callback' => [ __CLASS__, 'endpoint_absint' ],
|
193 |
+
'sanitize_callback' => 'absint',
|
194 |
+
],
|
195 |
+
],
|
196 |
+
]
|
197 |
+
)
|
198 |
+
);
|
199 |
}
|
200 |
|
201 |
/**
|
204 |
* @param array $vars The current pum_vars.
|
205 |
* @return array The updates pum_vars
|
206 |
*/
|
207 |
+
public static function pum_vars( $vars = [] ) {
|
208 |
$vars['analytics_route'] = self::get_analytics_route();
|
209 |
if ( function_exists( 'rest_url' ) ) {
|
210 |
$vars['analytics_api'] = esc_url_raw( rest_url( self::get_analytics_namespace() ) );
|
299 |
* Returns a 204 no content header.
|
300 |
*/
|
301 |
public static function serve_no_content() {
|
302 |
+
header( 'HTTP/1.0 204 No Content' );
|
303 |
header( 'Content-Type: image/gif' );
|
304 |
header( 'Content-Length: 0' );
|
305 |
exit;
|
classes/AssetCache.php
CHANGED
@@ -60,25 +60,25 @@ class PUM_AssetCache {
|
|
60 |
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
|
61 |
self::$disabled = true;
|
62 |
} else {
|
63 |
-
self::$disabled
|
64 |
}
|
65 |
|
66 |
-
add_action( 'pum_extension_updated',
|
67 |
-
add_action( 'pum_extension_deactivated',
|
68 |
-
add_action( 'pum_extension_activated',
|
69 |
-
add_action( 'pum_regenerate_asset_cache',
|
70 |
-
add_action( 'pum_save_settings',
|
71 |
-
add_action( 'pum_save_popup',
|
72 |
-
add_action( 'pum_save_theme',
|
73 |
-
add_action( 'pum_update_core_version',
|
74 |
|
75 |
if ( isset( $_GET['flush_popup_cache'] ) ) {
|
76 |
-
add_action( 'init',
|
77 |
}
|
78 |
|
79 |
-
add_filter( 'pum_alert_list',
|
80 |
|
81 |
-
add_action( 'pum_styles',
|
82 |
|
83 |
if ( null === get_option( 'pum_files_writeable', null ) ) {
|
84 |
add_option( 'pum_files_writeable', true );
|
@@ -87,7 +87,7 @@ class PUM_AssetCache {
|
|
87 |
}
|
88 |
|
89 |
if ( is_admin() && current_user_can( 'edit_posts' ) ) {
|
90 |
-
add_action( 'init',
|
91 |
}
|
92 |
|
93 |
// Prevent reinitialization.
|
@@ -126,7 +126,7 @@ class PUM_AssetCache {
|
|
126 |
global $wp_filesystem;
|
127 |
|
128 |
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
129 |
-
require_once
|
130 |
}
|
131 |
|
132 |
$results = WP_Filesystem();
|
@@ -220,9 +220,9 @@ class PUM_AssetCache {
|
|
220 |
}
|
221 |
$js_file = self::generate_cache_filename( 'pum-site-scripts' ) . '.js';
|
222 |
|
223 |
-
$js
|
224 |
$js .= " * Do not touch this file! This file created by the Popup Maker plugin using PHP\n";
|
225 |
-
$js .=
|
226 |
$js .= " */\n\n\n";
|
227 |
$js .= self::generate_js();
|
228 |
|
@@ -242,9 +242,9 @@ class PUM_AssetCache {
|
|
242 |
}
|
243 |
$css_file = self::generate_cache_filename( 'pum-site-styles' ) . '.css';
|
244 |
|
245 |
-
$css
|
246 |
$css .= " * Do not touch this file! This file created by the Popup Maker plugin using PHP\n";
|
247 |
-
$css .=
|
248 |
$css .= " */\n\n\n";
|
249 |
$css .= self::generate_css();
|
250 |
|
@@ -270,12 +270,12 @@ class PUM_AssetCache {
|
|
270 |
* 8 Integrations
|
271 |
* 10 Per Popup JS
|
272 |
*/
|
273 |
-
$js =
|
274 |
-
'core' =>
|
275 |
'content' => $core_js,
|
276 |
'priority' => 0,
|
277 |
-
|
278 |
-
|
279 |
|
280 |
$popups = pum_get_all_popups();
|
281 |
|
@@ -295,9 +295,9 @@ class PUM_AssetCache {
|
|
295 |
$popup_js = ob_get_clean();
|
296 |
|
297 |
if ( ! empty( $popup_js ) ) {
|
298 |
-
$js[ 'popup-' . $popup->ID ] =
|
299 |
'content' => $popup_js,
|
300 |
-
|
301 |
}
|
302 |
}
|
303 |
|
@@ -309,13 +309,16 @@ class PUM_AssetCache {
|
|
309 |
$js = apply_filters( 'pum_generated_js', $js );
|
310 |
|
311 |
foreach ( $js as $key => $code ) {
|
312 |
-
$js[ $key ] = wp_parse_args(
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
316 |
}
|
317 |
|
318 |
-
uasort( $js,
|
319 |
|
320 |
$js_code = '';
|
321 |
foreach ( $js as $key => $code ) {
|
@@ -340,7 +343,7 @@ class PUM_AssetCache {
|
|
340 |
return false;
|
341 |
}
|
342 |
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
343 |
-
require_once
|
344 |
}
|
345 |
|
346 |
$file = trailingslashit( self::$cache_dir ) . $filename;
|
@@ -370,7 +373,7 @@ class PUM_AssetCache {
|
|
370 |
*/
|
371 |
public static function generate_css() {
|
372 |
// Include core styles so we can eliminate another stylesheet.
|
373 |
-
$core_css = file_get_contents( Popup_Maker::$DIR . 'assets/css/pum-site' . (is_rtl() ? '-rtl' : '') . self::$suffix . '.css' );
|
374 |
|
375 |
/**
|
376 |
* 0 Core
|
@@ -378,39 +381,42 @@ class PUM_AssetCache {
|
|
378 |
* 5 Extensions
|
379 |
* 10 Per Popup CSS
|
380 |
*/
|
381 |
-
$css =
|
382 |
-
'imports' =>
|
383 |
'content' => self::generate_font_imports(),
|
384 |
'priority' => - 1,
|
385 |
-
|
386 |
-
'core' =>
|
387 |
'content' => $core_css,
|
388 |
'priority' => 0,
|
389 |
-
|
390 |
-
'themes' =>
|
391 |
'content' => self::generate_popup_theme_styles(),
|
392 |
'priority' => 1,
|
393 |
-
|
394 |
-
'popups' =>
|
395 |
'content' => self::generate_popup_styles(),
|
396 |
'priority' => 15,
|
397 |
-
|
398 |
-
'custom' =>
|
399 |
'content' => self::custom_css(),
|
400 |
'priority' => 20,
|
401 |
-
|
402 |
-
|
403 |
|
404 |
$css = apply_filters( 'pum_generated_css', $css );
|
405 |
|
406 |
foreach ( $css as $key => $code ) {
|
407 |
-
$css[ $key ] = wp_parse_args(
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
411 |
}
|
412 |
|
413 |
-
uasort( $css,
|
414 |
|
415 |
$css_code = '';
|
416 |
foreach ( $css as $key => $code ) {
|
@@ -425,7 +431,7 @@ class PUM_AssetCache {
|
|
425 |
public static function global_custom_styles() {
|
426 |
|
427 |
if ( pum_get_option( 'adjust_body_padding' ) ) {
|
428 |
-
echo
|
429 |
}
|
430 |
|
431 |
}
|
@@ -525,22 +531,22 @@ class PUM_AssetCache {
|
|
525 |
public static function generate_font_imports() {
|
526 |
$imports = '';
|
527 |
|
528 |
-
$google_fonts =
|
529 |
|
530 |
foreach ( pum_get_all_themes() as $theme ) {
|
531 |
$google_fonts = array_merge( $google_fonts, pum_get_theme( $theme->ID )->get_google_fonts_used() );
|
532 |
}
|
533 |
|
534 |
if ( ! empty( $google_fonts ) && ! pum_get_option( 'disable_google_font_loading', false ) ) {
|
535 |
-
$link =
|
536 |
foreach ( $google_fonts as $font_family => $variants ) {
|
537 |
-
if ( $link !=
|
538 |
-
$link .=
|
539 |
}
|
540 |
$link .= $font_family;
|
541 |
if ( is_array( $variants ) ) {
|
542 |
if ( implode( ',', $variants ) != '' ) {
|
543 |
-
$link .=
|
544 |
$link .= trim( implode( ',', $variants ), ':' );
|
545 |
}
|
546 |
}
|
@@ -569,7 +575,7 @@ class PUM_AssetCache {
|
|
569 |
$theme_styles = pum_get_rendered_theme_styles( $theme->ID );
|
570 |
|
571 |
if ( $theme_styles != '' ) {
|
572 |
-
$styles .=
|
573 |
$styles .= $theme_styles . "\r\n";
|
574 |
}
|
575 |
}
|
@@ -602,8 +608,8 @@ class PUM_AssetCache {
|
|
602 |
return $alerts;
|
603 |
}
|
604 |
|
605 |
-
$undo_url
|
606 |
-
$dismiss_url
|
607 |
|
608 |
ob_start();
|
609 |
?>
|
@@ -613,8 +619,8 @@ class PUM_AssetCache {
|
|
613 |
<li><a href="https://docs.wppopupmaker.com/article/521-debugging-filesystem-errors?utm_source=filesystem-error-alert&utm_medium=inline-doclink&utm_campaign=filesystem-error" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'popup-maker' ); ?></a></li>
|
614 |
</ul>
|
615 |
<?php
|
616 |
-
$html
|
617 |
-
$alerts[] =
|
618 |
'code' => 'pum_writeable_notice',
|
619 |
'type' => 'warning',
|
620 |
'message' => esc_html__( "Popup Maker detected an issue with your file system's ability and is unable to create & save cached assets for your popup styling and settings. This may lead to suboptimal performance. Please check your filesystem and contact your hosting provide to ensure Popup Maker can create and write to cache files.", 'popup-maker' ),
|
@@ -622,7 +628,7 @@ class PUM_AssetCache {
|
|
622 |
'priority' => 1000,
|
623 |
'dismissible' => '2 weeks',
|
624 |
'global' => true,
|
625 |
-
|
626 |
return $alerts;
|
627 |
}
|
628 |
|
@@ -669,12 +675,15 @@ class PUM_AssetCache {
|
|
669 |
if ( false === $cache_url ) {
|
670 |
PUM_Utils_Logging::instance()->log( 'Cannot access cache file when tested. Cache URL returned false.' );
|
671 |
}
|
672 |
-
$protocol
|
673 |
-
$file
|
674 |
-
$results
|
675 |
-
|
676 |
-
|
677 |
-
|
|
|
|
|
|
|
678 |
|
679 |
// If it returned a WP_Error, let's log its error message.
|
680 |
if ( is_wp_error( $results ) ) {
|
60 |
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
|
61 |
self::$disabled = true;
|
62 |
} else {
|
63 |
+
self::$disabled = pum_get_option( 'disable_asset_caching', false );
|
64 |
}
|
65 |
|
66 |
+
add_action( 'pum_extension_updated', [ __CLASS__, 'reset_cache' ] );
|
67 |
+
add_action( 'pum_extension_deactivated', [ __CLASS__, 'reset_cache' ] );
|
68 |
+
add_action( 'pum_extension_activated', [ __CLASS__, 'reset_cache' ] );
|
69 |
+
add_action( 'pum_regenerate_asset_cache', [ __CLASS__, 'reset_cache' ] );
|
70 |
+
add_action( 'pum_save_settings', [ __CLASS__, 'reset_cache' ] );
|
71 |
+
add_action( 'pum_save_popup', [ __CLASS__, 'reset_cache' ] );
|
72 |
+
add_action( 'pum_save_theme', [ __CLASS__, 'reset_cache' ] );
|
73 |
+
add_action( 'pum_update_core_version', [ __CLASS__, 'reset_cache' ] );
|
74 |
|
75 |
if ( isset( $_GET['flush_popup_cache'] ) ) {
|
76 |
+
add_action( 'init', [ __CLASS__, 'reset_cache' ] );
|
77 |
}
|
78 |
|
79 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'cache_alert' ] );
|
80 |
|
81 |
+
add_action( 'pum_styles', [ __CLASS__, 'global_custom_styles' ] );
|
82 |
|
83 |
if ( null === get_option( 'pum_files_writeable', null ) ) {
|
84 |
add_option( 'pum_files_writeable', true );
|
87 |
}
|
88 |
|
89 |
if ( is_admin() && current_user_can( 'edit_posts' ) ) {
|
90 |
+
add_action( 'init', [ __CLASS__, 'admin_notice_check' ] );
|
91 |
}
|
92 |
|
93 |
// Prevent reinitialization.
|
126 |
global $wp_filesystem;
|
127 |
|
128 |
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
129 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
130 |
}
|
131 |
|
132 |
$results = WP_Filesystem();
|
220 |
}
|
221 |
$js_file = self::generate_cache_filename( 'pum-site-scripts' ) . '.js';
|
222 |
|
223 |
+
$js = "/**\n";
|
224 |
$js .= " * Do not touch this file! This file created by the Popup Maker plugin using PHP\n";
|
225 |
+
$js .= ' * Last modified time: ' . date( 'M d Y, h:i:s' ) . "\n";
|
226 |
$js .= " */\n\n\n";
|
227 |
$js .= self::generate_js();
|
228 |
|
242 |
}
|
243 |
$css_file = self::generate_cache_filename( 'pum-site-styles' ) . '.css';
|
244 |
|
245 |
+
$css = "/**\n";
|
246 |
$css .= " * Do not touch this file! This file created by the Popup Maker plugin using PHP\n";
|
247 |
+
$css .= ' * Last modified time: ' . date( 'M d Y, h:i:s' ) . "\n";
|
248 |
$css .= " */\n\n\n";
|
249 |
$css .= self::generate_css();
|
250 |
|
270 |
* 8 Integrations
|
271 |
* 10 Per Popup JS
|
272 |
*/
|
273 |
+
$js = [
|
274 |
+
'core' => [
|
275 |
'content' => $core_js,
|
276 |
'priority' => 0,
|
277 |
+
],
|
278 |
+
];
|
279 |
|
280 |
$popups = pum_get_all_popups();
|
281 |
|
295 |
$popup_js = ob_get_clean();
|
296 |
|
297 |
if ( ! empty( $popup_js ) ) {
|
298 |
+
$js[ 'popup-' . $popup->ID ] = [
|
299 |
'content' => $popup_js,
|
300 |
+
];
|
301 |
}
|
302 |
}
|
303 |
|
309 |
$js = apply_filters( 'pum_generated_js', $js );
|
310 |
|
311 |
foreach ( $js as $key => $code ) {
|
312 |
+
$js[ $key ] = wp_parse_args(
|
313 |
+
$code,
|
314 |
+
[
|
315 |
+
'content' => '',
|
316 |
+
'priority' => 10,
|
317 |
+
]
|
318 |
+
);
|
319 |
}
|
320 |
|
321 |
+
uasort( $js, [ 'PUM_Helpers', 'sort_by_priority' ] );
|
322 |
|
323 |
$js_code = '';
|
324 |
foreach ( $js as $key => $code ) {
|
343 |
return false;
|
344 |
}
|
345 |
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
346 |
+
require_once ABSPATH . 'wp-admin/includes/file.php';
|
347 |
}
|
348 |
|
349 |
$file = trailingslashit( self::$cache_dir ) . $filename;
|
373 |
*/
|
374 |
public static function generate_css() {
|
375 |
// Include core styles so we can eliminate another stylesheet.
|
376 |
+
$core_css = file_get_contents( Popup_Maker::$DIR . 'assets/css/pum-site' . ( is_rtl() ? '-rtl' : '' ) . self::$suffix . '.css' );
|
377 |
|
378 |
/**
|
379 |
* 0 Core
|
381 |
* 5 Extensions
|
382 |
* 10 Per Popup CSS
|
383 |
*/
|
384 |
+
$css = [
|
385 |
+
'imports' => [
|
386 |
'content' => self::generate_font_imports(),
|
387 |
'priority' => - 1,
|
388 |
+
],
|
389 |
+
'core' => [
|
390 |
'content' => $core_css,
|
391 |
'priority' => 0,
|
392 |
+
],
|
393 |
+
'themes' => [
|
394 |
'content' => self::generate_popup_theme_styles(),
|
395 |
'priority' => 1,
|
396 |
+
],
|
397 |
+
'popups' => [
|
398 |
'content' => self::generate_popup_styles(),
|
399 |
'priority' => 15,
|
400 |
+
],
|
401 |
+
'custom' => [
|
402 |
'content' => self::custom_css(),
|
403 |
'priority' => 20,
|
404 |
+
],
|
405 |
+
];
|
406 |
|
407 |
$css = apply_filters( 'pum_generated_css', $css );
|
408 |
|
409 |
foreach ( $css as $key => $code ) {
|
410 |
+
$css[ $key ] = wp_parse_args(
|
411 |
+
$code,
|
412 |
+
[
|
413 |
+
'content' => '',
|
414 |
+
'priority' => 10,
|
415 |
+
]
|
416 |
+
);
|
417 |
}
|
418 |
|
419 |
+
uasort( $css, [ 'PUM_Helpers', 'sort_by_priority' ] );
|
420 |
|
421 |
$css_code = '';
|
422 |
foreach ( $css as $key => $code ) {
|
431 |
public static function global_custom_styles() {
|
432 |
|
433 |
if ( pum_get_option( 'adjust_body_padding' ) ) {
|
434 |
+
echo 'html.pum-open.pum-open-overlay.pum-open-scrollable body > *[aria-hidden] { padding-right: ' . pum_get_option( 'body_padding_override', '15px' ) . '!important; }';
|
435 |
}
|
436 |
|
437 |
}
|
531 |
public static function generate_font_imports() {
|
532 |
$imports = '';
|
533 |
|
534 |
+
$google_fonts = [];
|
535 |
|
536 |
foreach ( pum_get_all_themes() as $theme ) {
|
537 |
$google_fonts = array_merge( $google_fonts, pum_get_theme( $theme->ID )->get_google_fonts_used() );
|
538 |
}
|
539 |
|
540 |
if ( ! empty( $google_fonts ) && ! pum_get_option( 'disable_google_font_loading', false ) ) {
|
541 |
+
$link = '//fonts.googleapis.com/css?family=';
|
542 |
foreach ( $google_fonts as $font_family => $variants ) {
|
543 |
+
if ( $link != '//fonts.googleapis.com/css?family=' ) {
|
544 |
+
$link .= '|';
|
545 |
}
|
546 |
$link .= $font_family;
|
547 |
if ( is_array( $variants ) ) {
|
548 |
if ( implode( ',', $variants ) != '' ) {
|
549 |
+
$link .= ':';
|
550 |
$link .= trim( implode( ',', $variants ), ':' );
|
551 |
}
|
552 |
}
|
575 |
$theme_styles = pum_get_rendered_theme_styles( $theme->ID );
|
576 |
|
577 |
if ( $theme_styles != '' ) {
|
578 |
+
$styles .= '/* Popup Theme ' . $theme->ID . ': ' . $theme->post_title . " */\r\n";
|
579 |
$styles .= $theme_styles . "\r\n";
|
580 |
}
|
581 |
}
|
608 |
return $alerts;
|
609 |
}
|
610 |
|
611 |
+
$undo_url = add_query_arg( 'pum_writeable_notice_check', 'undo' );
|
612 |
+
$dismiss_url = add_query_arg( 'pum_writeable_notice_check', 'dismiss' );
|
613 |
|
614 |
ob_start();
|
615 |
?>
|
619 |
<li><a href="https://docs.wppopupmaker.com/article/521-debugging-filesystem-errors?utm_source=filesystem-error-alert&utm_medium=inline-doclink&utm_campaign=filesystem-error" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'popup-maker' ); ?></a></li>
|
620 |
</ul>
|
621 |
<?php
|
622 |
+
$html = ob_get_clean();
|
623 |
+
$alerts[] = [
|
624 |
'code' => 'pum_writeable_notice',
|
625 |
'type' => 'warning',
|
626 |
'message' => esc_html__( "Popup Maker detected an issue with your file system's ability and is unable to create & save cached assets for your popup styling and settings. This may lead to suboptimal performance. Please check your filesystem and contact your hosting provide to ensure Popup Maker can create and write to cache files.", 'popup-maker' ),
|
628 |
'priority' => 1000,
|
629 |
'dismissible' => '2 weeks',
|
630 |
'global' => true,
|
631 |
+
];
|
632 |
return $alerts;
|
633 |
}
|
634 |
|
675 |
if ( false === $cache_url ) {
|
676 |
PUM_Utils_Logging::instance()->log( 'Cannot access cache file when tested. Cache URL returned false.' );
|
677 |
}
|
678 |
+
$protocol = is_ssl() ? 'https:' : 'http:';
|
679 |
+
$file = $protocol . $cache_url . '/' . $filename;
|
680 |
+
$results = wp_remote_request(
|
681 |
+
$file,
|
682 |
+
[
|
683 |
+
'method' => 'HEAD',
|
684 |
+
'sslverify' => false,
|
685 |
+
]
|
686 |
+
);
|
687 |
|
688 |
// If it returned a WP_Error, let's log its error message.
|
689 |
if ( is_wp_error( $results ) ) {
|
classes/Batch/Process/Registry.php
CHANGED
@@ -69,7 +69,7 @@ class PUM_Batch_Process_Registry extends PUM_Abstract_Registry {
|
|
69 |
* @return WP_Error|true True on successful registration, otherwise a WP_Error object.
|
70 |
*/
|
71 |
public function register_process( $batch_id, $process_args ) {
|
72 |
-
$process_args = wp_parse_args( $process_args,
|
73 |
|
74 |
if ( empty( $process_args['class'] ) ) {
|
75 |
return new WP_Error( 'invalid_batch_class', __( 'A batch process class must be specified.', 'popup-maker' ) );
|
@@ -80,7 +80,7 @@ class PUM_Batch_Process_Registry extends PUM_Abstract_Registry {
|
|
80 |
}
|
81 |
|
82 |
// 2 if Windows path.
|
83 |
-
if ( ! in_array( validate_file( $process_args['file'] ),
|
84 |
return new WP_Error( 'invalid_batch_class_file', __( 'An invalid batch class handler file has been supplied.', 'popup-maker' ) );
|
85 |
}
|
86 |
|
69 |
* @return WP_Error|true True on successful registration, otherwise a WP_Error object.
|
70 |
*/
|
71 |
public function register_process( $batch_id, $process_args ) {
|
72 |
+
$process_args = wp_parse_args( $process_args, array_fill_keys( [ 'class', 'file' ], '' ) );
|
73 |
|
74 |
if ( empty( $process_args['class'] ) ) {
|
75 |
return new WP_Error( 'invalid_batch_class', __( 'A batch process class must be specified.', 'popup-maker' ) );
|
80 |
}
|
81 |
|
82 |
// 2 if Windows path.
|
83 |
+
if ( ! in_array( validate_file( $process_args['file'] ), [ 0, 2 ], true ) ) {
|
84 |
return new WP_Error( 'invalid_batch_class_file', __( 'An invalid batch class handler file has been supplied.', 'popup-maker' ) );
|
85 |
}
|
86 |
|
classes/ConditionCallbacks.php
CHANGED
@@ -12,7 +12,7 @@ class PUM_ConditionCallbacks {
|
|
12 |
*
|
13 |
* @return bool
|
14 |
*/
|
15 |
-
public static function post_type( $condition =
|
16 |
global $post;
|
17 |
|
18 |
$target = explode( '_', $condition['target'] );
|
@@ -23,7 +23,7 @@ class PUM_ConditionCallbacks {
|
|
23 |
// Post type is the remaining keys combined.
|
24 |
$post_type = implode( '_', $target );
|
25 |
|
26 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
27 |
|
28 |
switch ( $modifier ) {
|
29 |
case 'index':
|
@@ -96,7 +96,7 @@ class PUM_ConditionCallbacks {
|
|
96 |
*
|
97 |
* @return bool
|
98 |
*/
|
99 |
-
public static function taxonomy( $condition =
|
100 |
|
101 |
$target = explode( '_', $condition['target'] );
|
102 |
|
@@ -124,7 +124,7 @@ class PUM_ConditionCallbacks {
|
|
124 |
|
125 |
case 'ID':
|
126 |
case 'selected':
|
127 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
128 |
|
129 |
if ( is_tax( $taxonomy, wp_parse_id_list( $selected ) ) ) {
|
130 |
return true;
|
@@ -142,7 +142,7 @@ class PUM_ConditionCallbacks {
|
|
142 |
*
|
143 |
* @return bool
|
144 |
*/
|
145 |
-
public static function category( $condition =
|
146 |
|
147 |
$target = explode( '_', $condition['target'] );
|
148 |
|
@@ -157,7 +157,7 @@ class PUM_ConditionCallbacks {
|
|
157 |
break;
|
158 |
|
159 |
case 'selected':
|
160 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
161 |
if ( is_category( wp_parse_id_list( $selected ) ) ) {
|
162 |
return true;
|
163 |
}
|
@@ -174,7 +174,7 @@ class PUM_ConditionCallbacks {
|
|
174 |
*
|
175 |
* @return bool
|
176 |
*/
|
177 |
-
public static function post_tag( $condition =
|
178 |
|
179 |
$target = explode( '_', $condition['target'] );
|
180 |
|
@@ -189,7 +189,7 @@ class PUM_ConditionCallbacks {
|
|
189 |
break;
|
190 |
|
191 |
case 'selected':
|
192 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
193 |
if ( is_tag( wp_parse_id_list( $selected ) ) ) {
|
194 |
return true;
|
195 |
}
|
@@ -206,7 +206,7 @@ class PUM_ConditionCallbacks {
|
|
206 |
*
|
207 |
* @return bool
|
208 |
*/
|
209 |
-
public static function post_type_tax( $condition =
|
210 |
|
211 |
$target = explode( '_w_', $condition['target'] );
|
212 |
|
@@ -222,7 +222,7 @@ class PUM_ConditionCallbacks {
|
|
222 |
return self::post_type_tag( $condition );
|
223 |
}
|
224 |
|
225 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
226 |
if ( self::is_post_type( $post_type ) && has_term( wp_parse_id_list( $selected ), $taxonomy ) ) {
|
227 |
return true;
|
228 |
}
|
@@ -237,14 +237,14 @@ class PUM_ConditionCallbacks {
|
|
237 |
*
|
238 |
* @return bool
|
239 |
*/
|
240 |
-
public static function post_type_category( $condition =
|
241 |
|
242 |
$target = explode( '_w_', $condition['target'] );
|
243 |
|
244 |
// First key is the post type.
|
245 |
$post_type = array_shift( $target );
|
246 |
|
247 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
248 |
if ( self::is_post_type( $post_type ) && has_category( wp_parse_id_list( $selected ) ) ) {
|
249 |
return true;
|
250 |
}
|
@@ -259,14 +259,14 @@ class PUM_ConditionCallbacks {
|
|
259 |
*
|
260 |
* @return bool
|
261 |
*/
|
262 |
-
public static function post_type_tag( $condition =
|
263 |
|
264 |
$target = explode( '_w_', $condition['target'] );
|
265 |
|
266 |
// First key is the post type.
|
267 |
$post_type = array_shift( $target );
|
268 |
|
269 |
-
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] :
|
270 |
if ( self::is_post_type( $post_type ) && has_tag( wp_parse_id_list( $selected ) ) ) {
|
271 |
return true;
|
272 |
}
|
@@ -279,4 +279,4 @@ class PUM_ConditionCallbacks {
|
|
279 |
return is_object( $post ) && ( is_singular( $post_type ) || $post->post_type == $post_type );
|
280 |
}
|
281 |
|
282 |
-
}
|
12 |
*
|
13 |
* @return bool
|
14 |
*/
|
15 |
+
public static function post_type( $condition = [] ) {
|
16 |
global $post;
|
17 |
|
18 |
$target = explode( '_', $condition['target'] );
|
23 |
// Post type is the remaining keys combined.
|
24 |
$post_type = implode( '_', $target );
|
25 |
|
26 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
27 |
|
28 |
switch ( $modifier ) {
|
29 |
case 'index':
|
96 |
*
|
97 |
* @return bool
|
98 |
*/
|
99 |
+
public static function taxonomy( $condition = [] ) {
|
100 |
|
101 |
$target = explode( '_', $condition['target'] );
|
102 |
|
124 |
|
125 |
case 'ID':
|
126 |
case 'selected':
|
127 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
128 |
|
129 |
if ( is_tax( $taxonomy, wp_parse_id_list( $selected ) ) ) {
|
130 |
return true;
|
142 |
*
|
143 |
* @return bool
|
144 |
*/
|
145 |
+
public static function category( $condition = [] ) {
|
146 |
|
147 |
$target = explode( '_', $condition['target'] );
|
148 |
|
157 |
break;
|
158 |
|
159 |
case 'selected':
|
160 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
161 |
if ( is_category( wp_parse_id_list( $selected ) ) ) {
|
162 |
return true;
|
163 |
}
|
174 |
*
|
175 |
* @return bool
|
176 |
*/
|
177 |
+
public static function post_tag( $condition = [] ) {
|
178 |
|
179 |
$target = explode( '_', $condition['target'] );
|
180 |
|
189 |
break;
|
190 |
|
191 |
case 'selected':
|
192 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
193 |
if ( is_tag( wp_parse_id_list( $selected ) ) ) {
|
194 |
return true;
|
195 |
}
|
206 |
*
|
207 |
* @return bool
|
208 |
*/
|
209 |
+
public static function post_type_tax( $condition = [] ) {
|
210 |
|
211 |
$target = explode( '_w_', $condition['target'] );
|
212 |
|
222 |
return self::post_type_tag( $condition );
|
223 |
}
|
224 |
|
225 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
226 |
if ( self::is_post_type( $post_type ) && has_term( wp_parse_id_list( $selected ), $taxonomy ) ) {
|
227 |
return true;
|
228 |
}
|
237 |
*
|
238 |
* @return bool
|
239 |
*/
|
240 |
+
public static function post_type_category( $condition = [] ) {
|
241 |
|
242 |
$target = explode( '_w_', $condition['target'] );
|
243 |
|
244 |
// First key is the post type.
|
245 |
$post_type = array_shift( $target );
|
246 |
|
247 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
248 |
if ( self::is_post_type( $post_type ) && has_category( wp_parse_id_list( $selected ) ) ) {
|
249 |
return true;
|
250 |
}
|
259 |
*
|
260 |
* @return bool
|
261 |
*/
|
262 |
+
public static function post_type_tag( $condition = [] ) {
|
263 |
|
264 |
$target = explode( '_w_', $condition['target'] );
|
265 |
|
266 |
// First key is the post type.
|
267 |
$post_type = array_shift( $target );
|
268 |
|
269 |
+
$selected = ! empty( $condition['settings']['selected'] ) ? $condition['settings']['selected'] : [];
|
270 |
if ( self::is_post_type( $post_type ) && has_tag( wp_parse_id_list( $selected ) ) ) {
|
271 |
return true;
|
272 |
}
|
279 |
return is_object( $post ) && ( is_singular( $post_type ) || $post->post_type == $post_type );
|
280 |
}
|
281 |
|
282 |
+
}
|
classes/Conditions.php
CHANGED
@@ -30,7 +30,7 @@ class PUM_Conditions {
|
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
-
public $condition_sort_order =
|
34 |
|
35 |
/**
|
36 |
*
|
@@ -44,7 +44,7 @@ class PUM_Conditions {
|
|
44 |
*/
|
45 |
public static function instance() {
|
46 |
if ( ! isset( self::$instance ) ) {
|
47 |
-
self::$instance = new self;
|
48 |
self::$instance->preload_posts = popmake_is_admin_popup_page();
|
49 |
}
|
50 |
|
@@ -54,7 +54,7 @@ class PUM_Conditions {
|
|
54 |
/**
|
55 |
* @param array $conditions
|
56 |
*/
|
57 |
-
public function add_conditions( $conditions =
|
58 |
foreach ( $conditions as $key => $condition ) {
|
59 |
if ( empty( $condition['id'] ) && ! is_numeric( $key ) ) {
|
60 |
$condition['id'] = $key;
|
@@ -67,17 +67,20 @@ class PUM_Conditions {
|
|
67 |
/**
|
68 |
* @param array $condition
|
69 |
*/
|
70 |
-
public function add_condition( $condition =
|
71 |
-
if ( ! empty( $condition['id'] ) && ! isset
|
72 |
-
$condition = wp_parse_args(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
81 |
|
82 |
$this->conditions[ $condition['id'] ] = $condition;
|
83 |
}
|
@@ -93,7 +96,6 @@ class PUM_Conditions {
|
|
93 |
$this->register_conditions();
|
94 |
}
|
95 |
|
96 |
-
|
97 |
return $this->conditions;
|
98 |
}
|
99 |
|
@@ -103,21 +105,33 @@ class PUM_Conditions {
|
|
103 |
public function condition_sort_order() {
|
104 |
if ( ! $this->condition_sort_order ) {
|
105 |
|
106 |
-
$order =
|
107 |
__( 'General', 'popup-maker' ) => 1,
|
108 |
__( 'Pages', 'popup-maker' ) => 5,
|
109 |
__( 'Posts', 'popup-maker' ) => 5,
|
110 |
__( 'Categories', 'popup-maker' ) => 14,
|
111 |
__( 'Tags', 'popup-maker' ) => 14,
|
112 |
__( 'Format', 'popup-maker' ) => 16,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
);
|
114 |
-
|
115 |
-
$post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'objects' );
|
116 |
foreach ( $post_types as $name => $post_type ) {
|
117 |
$order[ $post_type->labels->name ] = 10;
|
118 |
}
|
119 |
|
120 |
-
$taxonomies = get_taxonomies(
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
122 |
$order[ $taxonomy->labels->name ] = 15;
|
123 |
}
|
@@ -158,13 +172,13 @@ class PUM_Conditions {
|
|
158 |
|
159 |
if ( ! isset( $groups ) ) {
|
160 |
|
161 |
-
$groups =
|
162 |
|
163 |
foreach ( $this->get_conditions() as $condition ) {
|
164 |
$groups[ $condition['group'] ][ $condition['id'] ] = $condition;
|
165 |
}
|
166 |
|
167 |
-
uksort( $groups,
|
168 |
|
169 |
}
|
170 |
|
@@ -175,13 +189,13 @@ class PUM_Conditions {
|
|
175 |
* @return array
|
176 |
*/
|
177 |
public function dropdown_list() {
|
178 |
-
$groups =
|
179 |
|
180 |
$conditions_by_group = $this->get_conditions_by_group();
|
181 |
|
182 |
foreach ( $conditions_by_group as $group => $_conditions ) {
|
183 |
|
184 |
-
$conditions =
|
185 |
|
186 |
foreach ( $_conditions as $id => $condition ) {
|
187 |
$conditions[ $id ] = $condition['name'];
|
@@ -208,8 +222,8 @@ class PUM_Conditions {
|
|
208 |
* @return array
|
209 |
*/
|
210 |
public function generate_post_type_conditions() {
|
211 |
-
$conditions =
|
212 |
-
$post_types = get_post_types(
|
213 |
|
214 |
foreach ( $post_types as $name => $post_type ) {
|
215 |
|
@@ -218,99 +232,98 @@ class PUM_Conditions {
|
|
218 |
}
|
219 |
|
220 |
if ( $post_type->has_archive ) {
|
221 |
-
$conditions[ $name . '_index' ] =
|
222 |
'group' => $post_type->labels->name,
|
223 |
'name' => sprintf( _x( '%s Archive', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
|
224 |
-
'callback' =>
|
225 |
'priority' => 5,
|
226 |
-
|
227 |
}
|
228 |
|
229 |
-
$conditions[ $name . '_all' ] =
|
230 |
'group' => $post_type->labels->name,
|
231 |
'name' => sprintf( _x( 'All %s', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
|
232 |
-
'callback' =>
|
233 |
-
|
234 |
|
235 |
-
$conditions[ $name . '_selected' ] =
|
236 |
'group' => $post_type->labels->name,
|
237 |
'name' => sprintf( _x( '%s: Selected', 'condition: post type plural label ie. Posts: Selected', 'popup-maker' ), $post_type->labels->name ),
|
238 |
-
'fields' =>
|
239 |
-
'selected' =>
|
240 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
241 |
'type' => 'postselect',
|
242 |
'post_type' => $name,
|
243 |
'multiple' => true,
|
244 |
'as_array' => true,
|
245 |
-
'std' =>
|
246 |
-
|
247 |
-
|
248 |
-
'callback' =>
|
249 |
-
|
250 |
|
251 |
-
$conditions[ $name . '_ID' ] =
|
252 |
'group' => $post_type->labels->name,
|
253 |
'name' => sprintf( _x( '%s: ID', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
254 |
-
'fields' =>
|
255 |
-
'selected' =>
|
256 |
'placeholder' => sprintf( _x( '%s IDs: 128, 129', 'condition: post type singular label ie. Posts IDs', 'popup-maker' ), strtolower( $post_type->labels->singular_name ) ),
|
257 |
'type' => 'text',
|
258 |
-
|
259 |
-
|
260 |
-
'callback' =>
|
261 |
-
|
262 |
|
263 |
if ( is_post_type_hierarchical( $name ) ) {
|
264 |
-
$conditions[ $name . '_children' ] =
|
265 |
'group' => $post_type->labels->name,
|
266 |
'name' => sprintf( _x( '%s: Child Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
267 |
-
'fields' =>
|
268 |
-
'selected' =>
|
269 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
270 |
'type' => 'postselect',
|
271 |
'post_type' => $name,
|
272 |
'multiple' => true,
|
273 |
'as_array' => true,
|
274 |
-
|
275 |
-
|
276 |
-
'callback' =>
|
277 |
-
|
278 |
|
279 |
-
$conditions[ $name . '_ancestors' ] =
|
280 |
'group' => $post_type->labels->name,
|
281 |
'name' => sprintf( _x( '%s: Ancestor Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
282 |
-
'fields' =>
|
283 |
-
'selected' =>
|
284 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
285 |
'type' => 'postselect',
|
286 |
'post_type' => $name,
|
287 |
'multiple' => true,
|
288 |
'as_array' => true,
|
289 |
-
|
290 |
-
|
291 |
-
'callback' =>
|
292 |
-
|
293 |
|
294 |
}
|
295 |
|
296 |
-
|
297 |
$templates = wp_get_theme()->get_page_templates();
|
298 |
|
299 |
if ( $name == 'page' && ! empty( $templates ) ) {
|
300 |
-
$conditions[ $name . '_template' ] =
|
301 |
'group' => $post_type->labels->name,
|
302 |
'name' => sprintf( _x( '%s: With Template', 'condition: post type plural label ie. Pages: With Template', 'popup-maker' ), $post_type->labels->name ),
|
303 |
-
'fields' =>
|
304 |
-
'selected' =>
|
305 |
'type' => 'select',
|
306 |
'select2' => true,
|
307 |
'multiple' => true,
|
308 |
'as_array' => true,
|
309 |
-
'options' => array_merge(
|
310 |
-
|
311 |
-
|
312 |
-
'callback' =>
|
313 |
-
|
314 |
}
|
315 |
|
316 |
$conditions = array_merge( $conditions, $this->generate_post_type_tax_conditions( $name ) );
|
@@ -328,23 +341,23 @@ class PUM_Conditions {
|
|
328 |
public function generate_post_type_tax_conditions( $name ) {
|
329 |
$post_type = get_post_type_object( $name );
|
330 |
$taxonomies = get_object_taxonomies( $name, 'object' );
|
331 |
-
$conditions =
|
332 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
333 |
|
334 |
-
$conditions[ $name . '_w_' . $tax_name ] =
|
335 |
'group' => $post_type->labels->name,
|
336 |
'name' => sprintf( _x( '%1$s: With %2$s', 'condition: post type plural and taxonomy singular label ie. Posts: With Category', 'popup-maker' ), $post_type->labels->name, $taxonomy->labels->singular_name ),
|
337 |
-
'fields' =>
|
338 |
-
'selected' =>
|
339 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select categories', 'popup-maker' ), strtolower( $taxonomy->labels->name ) ),
|
340 |
'type' => 'taxonomyselect',
|
341 |
'taxonomy' => $tax_name,
|
342 |
'multiple' => true,
|
343 |
'as_array' => true,
|
344 |
-
|
345 |
-
|
346 |
-
'callback' =>
|
347 |
-
|
348 |
}
|
349 |
|
350 |
return $conditions;
|
@@ -356,43 +369,43 @@ class PUM_Conditions {
|
|
356 |
* @return array
|
357 |
*/
|
358 |
public function generate_taxonomy_conditions() {
|
359 |
-
$conditions =
|
360 |
-
$taxonomies = get_taxonomies(
|
361 |
|
362 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
363 |
|
364 |
-
$conditions[ 'tax_' . $tax_name . '_all' ] =
|
365 |
'group' => $taxonomy->labels->name,
|
366 |
'name' => sprintf( _x( '%s: All', 'condition: taxonomy plural label ie. Categories: All', 'popup-maker' ), $taxonomy->labels->name ),
|
367 |
-
'callback' =>
|
368 |
-
|
369 |
|
370 |
-
$conditions[ 'tax_' . $tax_name . '_selected' ] =
|
371 |
'group' => $taxonomy->labels->name,
|
372 |
'name' => sprintf( _x( '%s: Selected', 'condition: taxonomy plural label ie. Categories: Selected', 'popup-maker' ), $taxonomy->labels->name ),
|
373 |
-
'fields' =>
|
374 |
-
'selected' =>
|
375 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: taxonomy plural label ie. Select Categories', 'popup-maker' ), strtolower( $taxonomy->labels->name ) ),
|
376 |
'type' => 'taxonomyselect',
|
377 |
'taxonomy' => $tax_name,
|
378 |
'multiple' => true,
|
379 |
'as_array' => true,
|
380 |
-
|
381 |
-
|
382 |
-
'callback' =>
|
383 |
-
|
384 |
|
385 |
-
$conditions[ 'tax_' . $tax_name . '_ID' ] =
|
386 |
'group' => $taxonomy->labels->name,
|
387 |
'name' => sprintf( _x( '%s: IDs', 'condition: taxonomy plural label ie. Categories: Selected', 'popup-maker' ), $taxonomy->labels->name ),
|
388 |
-
'fields' =>
|
389 |
-
'selected' =>
|
390 |
'placeholder' => sprintf( _x( '%s IDs: 128, 129', 'condition: taxonomy plural label ie. Category IDs', 'popup-maker' ), strtolower( $taxonomy->labels->singular_name ) ),
|
391 |
'type' => 'text',
|
392 |
-
|
393 |
-
|
394 |
-
'callback' =>
|
395 |
-
|
396 |
|
397 |
}
|
398 |
|
@@ -405,36 +418,36 @@ class PUM_Conditions {
|
|
405 |
public function register_conditions() {
|
406 |
$conditions = array_merge( $this->generate_post_type_conditions(), $this->generate_taxonomy_conditions() );
|
407 |
|
408 |
-
$conditions['is_front_page'] =
|
409 |
'group' => __( 'General', 'popup-maker' ),
|
410 |
'name' => __( 'Home Page', 'popup-maker' ),
|
411 |
'callback' => 'is_front_page',
|
412 |
'priority' => 2,
|
413 |
-
|
414 |
|
415 |
-
$conditions['is_home'] =
|
416 |
'group' => __( 'Posts', 'popup-maker' ),
|
417 |
'name' => __( 'Blog Index', 'popup-maker' ),
|
418 |
'callback' => 'is_home',
|
419 |
'priority' => 1,
|
420 |
-
|
421 |
|
422 |
-
$conditions['is_search'] =
|
423 |
'group' => __( 'General', 'popup-maker' ),
|
424 |
'name' => __( 'Search Result Page', 'popup-maker' ),
|
425 |
'callback' => 'is_search',
|
426 |
-
|
427 |
|
428 |
-
$conditions['is_404'] =
|
429 |
'group' => __( 'General', 'popup-maker' ),
|
430 |
'name' => __( '404 Error Page', 'popup-maker' ),
|
431 |
'callback' => 'is_404',
|
432 |
-
|
433 |
|
434 |
$conditions = apply_filters( 'pum_registered_conditions', $conditions );
|
435 |
|
436 |
// @deprecated filter.
|
437 |
-
$old_conditions = apply_filters( 'pum_get_conditions',
|
438 |
|
439 |
foreach ( $old_conditions as $id => $condition ) {
|
440 |
if ( ! empty( $condition['labels'] ) && ! empty( $condition['labels']['name'] ) ) {
|
@@ -463,11 +476,10 @@ class PUM_Conditions {
|
|
463 |
$roles = apply_filters( 'pum_user_roles', $wp_roles->role_names );
|
464 |
|
465 |
if ( ! is_array( $roles ) || empty( $roles ) ) {
|
466 |
-
$roles =
|
467 |
}
|
468 |
-
|
469 |
} else {
|
470 |
-
return
|
471 |
}
|
472 |
|
473 |
return $roles;
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
+
public $condition_sort_order = [];
|
34 |
|
35 |
/**
|
36 |
*
|
44 |
*/
|
45 |
public static function instance() {
|
46 |
if ( ! isset( self::$instance ) ) {
|
47 |
+
self::$instance = new self();
|
48 |
self::$instance->preload_posts = popmake_is_admin_popup_page();
|
49 |
}
|
50 |
|
54 |
/**
|
55 |
* @param array $conditions
|
56 |
*/
|
57 |
+
public function add_conditions( $conditions = [] ) {
|
58 |
foreach ( $conditions as $key => $condition ) {
|
59 |
if ( empty( $condition['id'] ) && ! is_numeric( $key ) ) {
|
60 |
$condition['id'] = $key;
|
67 |
/**
|
68 |
* @param array $condition
|
69 |
*/
|
70 |
+
public function add_condition( $condition = [] ) {
|
71 |
+
if ( ! empty( $condition['id'] ) && ! isset( $this->conditions[ $condition['id'] ] ) ) {
|
72 |
+
$condition = wp_parse_args(
|
73 |
+
$condition,
|
74 |
+
[
|
75 |
+
'id' => '',
|
76 |
+
'callback' => null,
|
77 |
+
'group' => '',
|
78 |
+
'name' => '',
|
79 |
+
'priority' => 10,
|
80 |
+
'fields' => [],
|
81 |
+
'advanced' => false,
|
82 |
+
]
|
83 |
+
);
|
84 |
|
85 |
$this->conditions[ $condition['id'] ] = $condition;
|
86 |
}
|
96 |
$this->register_conditions();
|
97 |
}
|
98 |
|
|
|
99 |
return $this->conditions;
|
100 |
}
|
101 |
|
105 |
public function condition_sort_order() {
|
106 |
if ( ! $this->condition_sort_order ) {
|
107 |
|
108 |
+
$order = [
|
109 |
__( 'General', 'popup-maker' ) => 1,
|
110 |
__( 'Pages', 'popup-maker' ) => 5,
|
111 |
__( 'Posts', 'popup-maker' ) => 5,
|
112 |
__( 'Categories', 'popup-maker' ) => 14,
|
113 |
__( 'Tags', 'popup-maker' ) => 14,
|
114 |
__( 'Format', 'popup-maker' ) => 16,
|
115 |
+
];
|
116 |
+
|
117 |
+
$post_types = get_post_types(
|
118 |
+
[
|
119 |
+
'public' => true,
|
120 |
+
'_builtin' => false,
|
121 |
+
],
|
122 |
+
'objects'
|
123 |
);
|
|
|
|
|
124 |
foreach ( $post_types as $name => $post_type ) {
|
125 |
$order[ $post_type->labels->name ] = 10;
|
126 |
}
|
127 |
|
128 |
+
$taxonomies = get_taxonomies(
|
129 |
+
[
|
130 |
+
'public' => true,
|
131 |
+
'_builtin' => false,
|
132 |
+
],
|
133 |
+
'objects'
|
134 |
+
);
|
135 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
136 |
$order[ $taxonomy->labels->name ] = 15;
|
137 |
}
|
172 |
|
173 |
if ( ! isset( $groups ) ) {
|
174 |
|
175 |
+
$groups = [];
|
176 |
|
177 |
foreach ( $this->get_conditions() as $condition ) {
|
178 |
$groups[ $condition['group'] ][ $condition['id'] ] = $condition;
|
179 |
}
|
180 |
|
181 |
+
uksort( $groups, [ $this, 'sort_condition_groups' ] );
|
182 |
|
183 |
}
|
184 |
|
189 |
* @return array
|
190 |
*/
|
191 |
public function dropdown_list() {
|
192 |
+
$groups = [];
|
193 |
|
194 |
$conditions_by_group = $this->get_conditions_by_group();
|
195 |
|
196 |
foreach ( $conditions_by_group as $group => $_conditions ) {
|
197 |
|
198 |
+
$conditions = [];
|
199 |
|
200 |
foreach ( $_conditions as $id => $condition ) {
|
201 |
$conditions[ $id ] = $condition['name'];
|
222 |
* @return array
|
223 |
*/
|
224 |
public function generate_post_type_conditions() {
|
225 |
+
$conditions = [];
|
226 |
+
$post_types = get_post_types( [ 'public' => true ], 'objects' );
|
227 |
|
228 |
foreach ( $post_types as $name => $post_type ) {
|
229 |
|
232 |
}
|
233 |
|
234 |
if ( $post_type->has_archive ) {
|
235 |
+
$conditions[ $name . '_index' ] = [
|
236 |
'group' => $post_type->labels->name,
|
237 |
'name' => sprintf( _x( '%s Archive', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
|
238 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
239 |
'priority' => 5,
|
240 |
+
];
|
241 |
}
|
242 |
|
243 |
+
$conditions[ $name . '_all' ] = [
|
244 |
'group' => $post_type->labels->name,
|
245 |
'name' => sprintf( _x( 'All %s', 'condition: post type plural label ie. Posts: All', 'popup-maker' ), $post_type->labels->name ),
|
246 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
247 |
+
];
|
248 |
|
249 |
+
$conditions[ $name . '_selected' ] = [
|
250 |
'group' => $post_type->labels->name,
|
251 |
'name' => sprintf( _x( '%s: Selected', 'condition: post type plural label ie. Posts: Selected', 'popup-maker' ), $post_type->labels->name ),
|
252 |
+
'fields' => [
|
253 |
+
'selected' => [
|
254 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
255 |
'type' => 'postselect',
|
256 |
'post_type' => $name,
|
257 |
'multiple' => true,
|
258 |
'as_array' => true,
|
259 |
+
'std' => [],
|
260 |
+
],
|
261 |
+
],
|
262 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
263 |
+
];
|
264 |
|
265 |
+
$conditions[ $name . '_ID' ] = [
|
266 |
'group' => $post_type->labels->name,
|
267 |
'name' => sprintf( _x( '%s: ID', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
268 |
+
'fields' => [
|
269 |
+
'selected' => [
|
270 |
'placeholder' => sprintf( _x( '%s IDs: 128, 129', 'condition: post type singular label ie. Posts IDs', 'popup-maker' ), strtolower( $post_type->labels->singular_name ) ),
|
271 |
'type' => 'text',
|
272 |
+
],
|
273 |
+
],
|
274 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
275 |
+
];
|
276 |
|
277 |
if ( is_post_type_hierarchical( $name ) ) {
|
278 |
+
$conditions[ $name . '_children' ] = [
|
279 |
'group' => $post_type->labels->name,
|
280 |
'name' => sprintf( _x( '%s: Child Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
281 |
+
'fields' => [
|
282 |
+
'selected' => [
|
283 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
284 |
'type' => 'postselect',
|
285 |
'post_type' => $name,
|
286 |
'multiple' => true,
|
287 |
'as_array' => true,
|
288 |
+
],
|
289 |
+
],
|
290 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
291 |
+
];
|
292 |
|
293 |
+
$conditions[ $name . '_ancestors' ] = [
|
294 |
'group' => $post_type->labels->name,
|
295 |
'name' => sprintf( _x( '%s: Ancestor Of', 'condition: post type plural label ie. Posts: ID', 'popup-maker' ), $post_type->labels->name ),
|
296 |
+
'fields' => [
|
297 |
+
'selected' => [
|
298 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select Posts', 'popup-maker' ), strtolower( $post_type->labels->name ) ),
|
299 |
'type' => 'postselect',
|
300 |
'post_type' => $name,
|
301 |
'multiple' => true,
|
302 |
'as_array' => true,
|
303 |
+
],
|
304 |
+
],
|
305 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
306 |
+
];
|
307 |
|
308 |
}
|
309 |
|
|
|
310 |
$templates = wp_get_theme()->get_page_templates();
|
311 |
|
312 |
if ( $name == 'page' && ! empty( $templates ) ) {
|
313 |
+
$conditions[ $name . '_template' ] = [
|
314 |
'group' => $post_type->labels->name,
|
315 |
'name' => sprintf( _x( '%s: With Template', 'condition: post type plural label ie. Pages: With Template', 'popup-maker' ), $post_type->labels->name ),
|
316 |
+
'fields' => [
|
317 |
+
'selected' => [
|
318 |
'type' => 'select',
|
319 |
'select2' => true,
|
320 |
'multiple' => true,
|
321 |
'as_array' => true,
|
322 |
+
'options' => array_merge( [ 'default' => __( 'Default', 'popup-maker' ) ], $templates ),
|
323 |
+
],
|
324 |
+
],
|
325 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type' ],
|
326 |
+
];
|
327 |
}
|
328 |
|
329 |
$conditions = array_merge( $conditions, $this->generate_post_type_tax_conditions( $name ) );
|
341 |
public function generate_post_type_tax_conditions( $name ) {
|
342 |
$post_type = get_post_type_object( $name );
|
343 |
$taxonomies = get_object_taxonomies( $name, 'object' );
|
344 |
+
$conditions = [];
|
345 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
346 |
|
347 |
+
$conditions[ $name . '_w_' . $tax_name ] = [
|
348 |
'group' => $post_type->labels->name,
|
349 |
'name' => sprintf( _x( '%1$s: With %2$s', 'condition: post type plural and taxonomy singular label ie. Posts: With Category', 'popup-maker' ), $post_type->labels->name, $taxonomy->labels->singular_name ),
|
350 |
+
'fields' => [
|
351 |
+
'selected' => [
|
352 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: post type plural label ie. Select categories', 'popup-maker' ), strtolower( $taxonomy->labels->name ) ),
|
353 |
'type' => 'taxonomyselect',
|
354 |
'taxonomy' => $tax_name,
|
355 |
'multiple' => true,
|
356 |
'as_array' => true,
|
357 |
+
],
|
358 |
+
],
|
359 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'post_type_tax' ],
|
360 |
+
];
|
361 |
}
|
362 |
|
363 |
return $conditions;
|
369 |
* @return array
|
370 |
*/
|
371 |
public function generate_taxonomy_conditions() {
|
372 |
+
$conditions = [];
|
373 |
+
$taxonomies = get_taxonomies( [ 'public' => true ], 'objects' );
|
374 |
|
375 |
foreach ( $taxonomies as $tax_name => $taxonomy ) {
|
376 |
|
377 |
+
$conditions[ 'tax_' . $tax_name . '_all' ] = [
|
378 |
'group' => $taxonomy->labels->name,
|
379 |
'name' => sprintf( _x( '%s: All', 'condition: taxonomy plural label ie. Categories: All', 'popup-maker' ), $taxonomy->labels->name ),
|
380 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'taxonomy' ],
|
381 |
+
];
|
382 |
|
383 |
+
$conditions[ 'tax_' . $tax_name . '_selected' ] = [
|
384 |
'group' => $taxonomy->labels->name,
|
385 |
'name' => sprintf( _x( '%s: Selected', 'condition: taxonomy plural label ie. Categories: Selected', 'popup-maker' ), $taxonomy->labels->name ),
|
386 |
+
'fields' => [
|
387 |
+
'selected' => [
|
388 |
'placeholder' => sprintf( _x( 'Select %s.', 'condition: taxonomy plural label ie. Select Categories', 'popup-maker' ), strtolower( $taxonomy->labels->name ) ),
|
389 |
'type' => 'taxonomyselect',
|
390 |
'taxonomy' => $tax_name,
|
391 |
'multiple' => true,
|
392 |
'as_array' => true,
|
393 |
+
],
|
394 |
+
],
|
395 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'taxonomy' ],
|
396 |
+
];
|
397 |
|
398 |
+
$conditions[ 'tax_' . $tax_name . '_ID' ] = [
|
399 |
'group' => $taxonomy->labels->name,
|
400 |
'name' => sprintf( _x( '%s: IDs', 'condition: taxonomy plural label ie. Categories: Selected', 'popup-maker' ), $taxonomy->labels->name ),
|
401 |
+
'fields' => [
|
402 |
+
'selected' => [
|
403 |
'placeholder' => sprintf( _x( '%s IDs: 128, 129', 'condition: taxonomy plural label ie. Category IDs', 'popup-maker' ), strtolower( $taxonomy->labels->singular_name ) ),
|
404 |
'type' => 'text',
|
405 |
+
],
|
406 |
+
],
|
407 |
+
'callback' => [ 'PUM_ConditionCallbacks', 'taxonomy' ],
|
408 |
+
];
|
409 |
|
410 |
}
|
411 |
|
418 |
public function register_conditions() {
|
419 |
$conditions = array_merge( $this->generate_post_type_conditions(), $this->generate_taxonomy_conditions() );
|
420 |
|
421 |
+
$conditions['is_front_page'] = [
|
422 |
'group' => __( 'General', 'popup-maker' ),
|
423 |
'name' => __( 'Home Page', 'popup-maker' ),
|
424 |
'callback' => 'is_front_page',
|
425 |
'priority' => 2,
|
426 |
+
];
|
427 |
|
428 |
+
$conditions['is_home'] = [
|
429 |
'group' => __( 'Posts', 'popup-maker' ),
|
430 |
'name' => __( 'Blog Index', 'popup-maker' ),
|
431 |
'callback' => 'is_home',
|
432 |
'priority' => 1,
|
433 |
+
];
|
434 |
|
435 |
+
$conditions['is_search'] = [
|
436 |
'group' => __( 'General', 'popup-maker' ),
|
437 |
'name' => __( 'Search Result Page', 'popup-maker' ),
|
438 |
'callback' => 'is_search',
|
439 |
+
];
|
440 |
|
441 |
+
$conditions['is_404'] = [
|
442 |
'group' => __( 'General', 'popup-maker' ),
|
443 |
'name' => __( '404 Error Page', 'popup-maker' ),
|
444 |
'callback' => 'is_404',
|
445 |
+
];
|
446 |
|
447 |
$conditions = apply_filters( 'pum_registered_conditions', $conditions );
|
448 |
|
449 |
// @deprecated filter.
|
450 |
+
$old_conditions = apply_filters( 'pum_get_conditions', [] );
|
451 |
|
452 |
foreach ( $old_conditions as $id => $condition ) {
|
453 |
if ( ! empty( $condition['labels'] ) && ! empty( $condition['labels']['name'] ) ) {
|
476 |
$roles = apply_filters( 'pum_user_roles', $wp_roles->role_names );
|
477 |
|
478 |
if ( ! is_array( $roles ) || empty( $roles ) ) {
|
479 |
+
$roles = [];
|
480 |
}
|
|
|
481 |
} else {
|
482 |
+
return [];
|
483 |
}
|
484 |
|
485 |
return $roles;
|
classes/Cookies.php
CHANGED
@@ -40,7 +40,7 @@ class PUM_Cookies {
|
|
40 |
*/
|
41 |
public static function instance() {
|
42 |
if ( ! isset( self::$instance ) ) {
|
43 |
-
self::$instance = new self;
|
44 |
self::$instance->preload_posts = pum_is_popup_editor();
|
45 |
}
|
46 |
|
@@ -73,48 +73,57 @@ class PUM_Cookies {
|
|
73 |
* Registers all known cookies when called.
|
74 |
*/
|
75 |
public function register_cookies() {
|
76 |
-
$cookies = apply_filters(
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
'
|
86 |
-
'
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
'
|
92 |
-
|
93 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
],
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
),
|
117 |
-
) );
|
118 |
|
119 |
// @deprecated filter.
|
120 |
$cookies = apply_filters( 'pum_get_cookies', $cookies );
|
@@ -125,7 +134,7 @@ class PUM_Cookies {
|
|
125 |
/**
|
126 |
* @param array $cookies
|
127 |
*/
|
128 |
-
public function add_cookies( $cookies =
|
129 |
foreach ( $cookies as $key => $cookie ) {
|
130 |
if ( empty( $cookie['id'] ) && ! is_numeric( $key ) ) {
|
131 |
$cookie['id'] = $key;
|
@@ -139,16 +148,19 @@ class PUM_Cookies {
|
|
139 |
* @param null $cookie
|
140 |
*/
|
141 |
public function add_cookie( $cookie = null ) {
|
142 |
-
if ( ! empty( $cookie['id'] ) && ! isset
|
143 |
-
$cookie = wp_parse_args(
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
152 |
|
153 |
// Here for backward compatibility to merge in labels properly.
|
154 |
if ( ! empty( $cookie['labels'] ) ) {
|
@@ -164,10 +176,13 @@ class PUM_Cookies {
|
|
164 |
$cookie['fields'] = $this->cookie_fields();
|
165 |
}
|
166 |
|
167 |
-
$cookie['fields'] = PUM_Admin_Helpers::parse_tab_fields(
|
168 |
-
'
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
171 |
|
172 |
$this->cookies[ $cookie['id'] ] = $cookie;
|
173 |
}
|
@@ -189,10 +204,13 @@ class PUM_Cookies {
|
|
189 |
*
|
190 |
* @param array $to_do The list of trigger section labels.
|
191 |
*/
|
192 |
-
return apply_filters(
|
193 |
-
'
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
196 |
}
|
197 |
|
198 |
/**
|
@@ -201,50 +219,52 @@ class PUM_Cookies {
|
|
201 |
* @return array
|
202 |
*
|
203 |
* @uses filter pum_get_cookie_fields
|
204 |
-
*
|
205 |
*/
|
206 |
public function cookie_fields() {
|
207 |
-
return apply_filters(
|
208 |
-
'
|
209 |
-
|
210 |
-
|
211 |
-
'
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
'
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
'
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
'
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
'
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
248 |
}
|
249 |
|
250 |
/**
|
@@ -259,7 +279,7 @@ class PUM_Cookies {
|
|
259 |
*
|
260 |
* @param array $to_do The list of cookie labels.
|
261 |
*/
|
262 |
-
$labels = apply_filters( 'pum_get_cookie_labels',
|
263 |
}
|
264 |
|
265 |
return $labels;
|
@@ -271,9 +291,8 @@ class PUM_Cookies {
|
|
271 |
*
|
272 |
* @return array
|
273 |
* @deprecated
|
274 |
-
*
|
275 |
*/
|
276 |
-
public function validate_cookie( $cookie = null, $settings =
|
277 |
return $settings;
|
278 |
}
|
279 |
|
@@ -283,7 +302,7 @@ class PUM_Cookies {
|
|
283 |
*/
|
284 |
public function dropdown_list() {
|
285 |
$_cookies = $this->get_cookies();
|
286 |
-
$cookies =
|
287 |
|
288 |
foreach ( $_cookies as $id => $cookie ) {
|
289 |
$cookies[ $id ] = $cookie['name'];
|
40 |
*/
|
41 |
public static function instance() {
|
42 |
if ( ! isset( self::$instance ) ) {
|
43 |
+
self::$instance = new self();
|
44 |
self::$instance->preload_posts = pum_is_popup_editor();
|
45 |
}
|
46 |
|
73 |
* Registers all known cookies when called.
|
74 |
*/
|
75 |
public function register_cookies() {
|
76 |
+
$cookies = apply_filters(
|
77 |
+
'pum_registered_cookies',
|
78 |
+
[
|
79 |
+
'on_popup_close' => [
|
80 |
+
'name' => __( 'On Popup Close', 'popup-maker' ),
|
81 |
+
],
|
82 |
+
'on_popup_open' => [
|
83 |
+
'name' => __( 'On Popup Open', 'popup-maker' ),
|
84 |
+
],
|
85 |
+
'form_submission' => [
|
86 |
+
'name' => __( 'Form Submission', 'popup-maker' ),
|
87 |
+
'fields' => array_merge_recursive(
|
88 |
+
$this->cookie_fields(),
|
89 |
+
[
|
90 |
+
'general' => [
|
91 |
+
'form' => [
|
92 |
+
'type' => 'select',
|
93 |
+
'label' => __( 'Form', 'popup-maker' ),
|
94 |
+
'options' => $this->preload_posts ? array_merge(
|
95 |
+
[
|
96 |
+
'any' => __( 'Any Supported Form*', 'popup-maker' ),
|
97 |
+
__( 'Popup Maker', 'popup-maker' ) => [
|
98 |
+
'pumsubform' => __( 'Subscription Form', 'popup-maker' ),
|
99 |
+
],
|
100 |
+
],
|
101 |
+
PUM_Integrations::get_integrated_forms_selectlist()
|
102 |
+
) : [],
|
103 |
+
'pri' => - 1,
|
104 |
+
'std' => 'any',
|
105 |
],
|
106 |
+
'only_in_popup' => [
|
107 |
+
'type' => 'checkbox',
|
108 |
+
'label' => __( 'Only in this popup', 'popup-maker' ),
|
109 |
+
'std' => '1',
|
110 |
+
],
|
111 |
+
],
|
112 |
+
]
|
113 |
+
),
|
114 |
+
],
|
115 |
+
'pum_sub_form_success' => [
|
116 |
+
'name' => __( 'Subscription Form: Successful', 'popup-maker' ),
|
117 |
+
],
|
118 |
+
'pum_sub_form_already_subscribed' => [
|
119 |
+
'name' => __( 'Subscription Form: Already Subscribed', 'popup-maker' ),
|
120 |
+
],
|
121 |
+
'manual' => [
|
122 |
+
'name' => __( 'Manual', 'popup-maker' ),
|
123 |
+
'settings_column' => '<pre class="manual-cookie-shortcode"><code>[popup_cookie name="{{data.name}}" expires="{{data.time}}" sitewide="{{data.path ? 1 : 0}}"]</code></pre>',
|
124 |
+
],
|
125 |
+
]
|
126 |
+
);
|
|
|
|
|
127 |
|
128 |
// @deprecated filter.
|
129 |
$cookies = apply_filters( 'pum_get_cookies', $cookies );
|
134 |
/**
|
135 |
* @param array $cookies
|
136 |
*/
|
137 |
+
public function add_cookies( $cookies = [] ) {
|
138 |
foreach ( $cookies as $key => $cookie ) {
|
139 |
if ( empty( $cookie['id'] ) && ! is_numeric( $key ) ) {
|
140 |
$cookie['id'] = $key;
|
148 |
* @param null $cookie
|
149 |
*/
|
150 |
public function add_cookie( $cookie = null ) {
|
151 |
+
if ( ! empty( $cookie['id'] ) && ! isset( $this->cookies[ $cookie['id'] ] ) ) {
|
152 |
+
$cookie = wp_parse_args(
|
153 |
+
$cookie,
|
154 |
+
[
|
155 |
+
'id' => '',
|
156 |
+
'name' => '',
|
157 |
+
'modal_title' => __( 'Cookie Settings', 'popup-maker' ),
|
158 |
+
'settings_column' => sprintf( '%s%s%s', '{{ (typeof data.session === "undefined" || data.session !== "1") ? data.time : "', __( 'Sessions', 'popup-maker' ), '" }}' ),
|
159 |
+
'priority' => 10,
|
160 |
+
'tabs' => $this->get_tabs(),
|
161 |
+
'fields' => $this->cookie_fields(),
|
162 |
+
]
|
163 |
+
);
|
164 |
|
165 |
// Here for backward compatibility to merge in labels properly.
|
166 |
if ( ! empty( $cookie['labels'] ) ) {
|
176 |
$cookie['fields'] = $this->cookie_fields();
|
177 |
}
|
178 |
|
179 |
+
$cookie['fields'] = PUM_Admin_Helpers::parse_tab_fields(
|
180 |
+
$cookie['fields'],
|
181 |
+
[
|
182 |
+
'has_subtabs' => false,
|
183 |
+
'name' => '%s',
|
184 |
+
]
|
185 |
+
);
|
186 |
|
187 |
$this->cookies[ $cookie['id'] ] = $cookie;
|
188 |
}
|
204 |
*
|
205 |
* @param array $to_do The list of trigger section labels.
|
206 |
*/
|
207 |
+
return apply_filters(
|
208 |
+
'pum_get_trigger_tabs',
|
209 |
+
[
|
210 |
+
'general' => __( 'General', 'popup-maker' ),
|
211 |
+
'advanced' => __( 'Advanced', 'popup-maker' ),
|
212 |
+
]
|
213 |
+
);
|
214 |
}
|
215 |
|
216 |
/**
|
219 |
* @return array
|
220 |
*
|
221 |
* @uses filter pum_get_cookie_fields
|
|
|
222 |
*/
|
223 |
public function cookie_fields() {
|
224 |
+
return apply_filters(
|
225 |
+
'pum_get_cookie_fields',
|
226 |
+
[
|
227 |
+
'general' => [
|
228 |
+
'name' => [
|
229 |
+
'label' => __( 'Cookie Name', 'popup-maker' ),
|
230 |
+
'placeholder' => __( 'Cookie Name ex. popmaker-123', 'popup-maker' ),
|
231 |
+
'desc' => __( 'The name that will be used when checking for or saving this cookie.', 'popup-maker' ),
|
232 |
+
'std' => '',
|
233 |
+
'priority' => 1,
|
234 |
+
],
|
235 |
+
'time' => [
|
236 |
+
'label' => __( 'Cookie Time', 'popup-maker' ),
|
237 |
+
'placeholder' => __( '364 days 23 hours 59 minutes 59 seconds', 'popup-maker' ),
|
238 |
+
'desc' => __( 'Enter a plain english time before cookie expires.', 'popup-maker' ),
|
239 |
+
'std' => '1 month',
|
240 |
+
'priority' => 2,
|
241 |
+
],
|
242 |
+
],
|
243 |
+
'advanced' => [
|
244 |
+
'session' => [
|
245 |
+
'label' => __( 'Use Session Cookie?', 'popup-maker' ),
|
246 |
+
'desc' => __( 'Session cookies expire when the user closes their browser.', 'popup-maker' ) . ' ' . sprintf( __( '%1$sNote%2$s: Modern browsers that reopen your last browser session\'s tabs do not properly clear session cookies', 'popup-maker' ), '<strong>', '</strong>' ),
|
247 |
+
'type' => 'checkbox',
|
248 |
+
'std' => false,
|
249 |
+
'priority' => 1,
|
250 |
+
],
|
251 |
+
'path' => [
|
252 |
+
'label' => __( 'Sitewide Cookie', 'popup-maker' ),
|
253 |
+
'desc' => __( 'This will prevent the popup from triggering on all pages until the cookie expires.', 'popup-maker' ),
|
254 |
+
'type' => 'checkbox',
|
255 |
+
'std' => true,
|
256 |
+
'priority' => 2,
|
257 |
+
],
|
258 |
+
'key' => [
|
259 |
+
'label' => __( 'Cookie Key', 'popup-maker' ),
|
260 |
+
'desc' => __( 'Changing this will cause all existing cookies to be invalid.', 'popup-maker' ),
|
261 |
+
'type' => 'cookie_key',
|
262 |
+
'std' => '',
|
263 |
+
'priority' => 3,
|
264 |
+
],
|
265 |
+
],
|
266 |
+
]
|
267 |
+
);
|
268 |
}
|
269 |
|
270 |
/**
|
279 |
*
|
280 |
* @param array $to_do The list of cookie labels.
|
281 |
*/
|
282 |
+
$labels = apply_filters( 'pum_get_cookie_labels', [] );
|
283 |
}
|
284 |
|
285 |
return $labels;
|
291 |
*
|
292 |
* @return array
|
293 |
* @deprecated
|
|
|
294 |
*/
|
295 |
+
public function validate_cookie( $cookie = null, $settings = [] ) {
|
296 |
return $settings;
|
297 |
}
|
298 |
|
302 |
*/
|
303 |
public function dropdown_list() {
|
304 |
$_cookies = $this->get_cookies();
|
305 |
+
$cookies = [];
|
306 |
|
307 |
foreach ( $_cookies as $id => $cookie ) {
|
308 |
$cookies[ $id ] = $cookie['name'];
|
classes/DB/Subscribers.php
CHANGED
@@ -33,7 +33,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
33 |
* Get columns and formats
|
34 |
*/
|
35 |
public function get_columns() {
|
36 |
-
return
|
37 |
'ID' => '%d',
|
38 |
'uuid' => '%s',
|
39 |
'popup_id' => '%d',
|
@@ -46,14 +46,14 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
46 |
'consent_args' => '%s',
|
47 |
'consent' => '%s',
|
48 |
'created' => '%s',
|
49 |
-
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Get default column values
|
54 |
*/
|
55 |
public function get_column_defaults() {
|
56 |
-
return
|
57 |
'uuid' => '',
|
58 |
'popup_id' => 0,
|
59 |
'email_hash' => '',
|
@@ -65,7 +65,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
65 |
'consent_args' => '',
|
66 |
'consent' => 'no',
|
67 |
'created' => current_time( 'mysql', 0 ),
|
68 |
-
|
69 |
|
70 |
}
|
71 |
|
@@ -77,7 +77,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
77 |
global $wpdb;
|
78 |
|
79 |
if ( ! function_exists( 'dbDelta' ) ) {
|
80 |
-
require_once
|
81 |
}
|
82 |
|
83 |
$charset_collate = $wpdb->get_charset_collate();
|
@@ -92,7 +92,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
92 |
* - [x] SQL keywords, like CREATE TABLE and UPDATE, must be uppercase.
|
93 |
* - [x] You must specify the length of all fields that accept a length parameter. int(11), for example.
|
94 |
*/
|
95 |
-
$sql =
|
96 |
ID bigint(20) NOT NULL AUTO_INCREMENT,
|
97 |
email_hash varchar(32) NOT NULL,
|
98 |
popup_id bigint(20) NOT NULL,
|
@@ -116,7 +116,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
116 |
PUM_Utils_Logging::instance()->log( 'Subscriber table results: ' . implode( ',', $results ) );
|
117 |
|
118 |
$previous_error = $wpdb->last_error; // The show tables query will erase the last error. So, record it now in case we need it.
|
119 |
-
if ( $wpdb->get_var("SHOW TABLES LIKE '{$this->table_name()}'") !== $this->table_name() ) {
|
120 |
PUM_Utils_Logging::instance()->log( "Subscriber table exists check failed! Last error from wpdb: $previous_error." );
|
121 |
}
|
122 |
|
@@ -128,18 +128,21 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
128 |
}
|
129 |
|
130 |
|
131 |
-
public function query( $args =
|
132 |
global $wpdb;
|
133 |
|
134 |
-
$args = wp_parse_args(
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
143 |
|
144 |
$columns = $this->get_columns();
|
145 |
|
@@ -159,17 +162,17 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
159 |
$query = "SELECT `$select_fields` FROM {$this->table_name()}";
|
160 |
|
161 |
// Set up $values array for wpdb::prepare
|
162 |
-
$values =
|
163 |
|
164 |
// Define an empty WHERE clause to start from.
|
165 |
-
$where =
|
166 |
|
167 |
// Build search query.
|
168 |
if ( $args['s'] && ! empty( $args['s'] ) ) {
|
169 |
|
170 |
$search = wp_unslash( trim( $args['s'] ) );
|
171 |
|
172 |
-
$search_where =
|
173 |
|
174 |
foreach ( $columns as $key => $type ) {
|
175 |
if ( in_array( $key, $fields ) ) {
|
@@ -188,24 +191,24 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
188 |
$query .= " $where";
|
189 |
|
190 |
if ( ! empty( $args['orderby'] ) ) {
|
191 |
-
$query
|
192 |
$values[] = wp_unslash( trim( $args['orderby'] ) );
|
193 |
|
194 |
switch ( $args['order'] ) {
|
195 |
case 'asc':
|
196 |
case 'ASC':
|
197 |
-
$query .=
|
198 |
break;
|
199 |
case 'desc':
|
200 |
case 'DESC':
|
201 |
default:
|
202 |
-
$query .=
|
203 |
break;
|
204 |
}
|
205 |
}
|
206 |
|
207 |
if ( ! empty( $args['limit'] ) ) {
|
208 |
-
$query
|
209 |
$values[] = absint( $args['limit'] );
|
210 |
}
|
211 |
|
@@ -215,7 +218,7 @@ class PUM_DB_Subscribers extends PUM_Abstract_Database {
|
|
215 |
}
|
216 |
|
217 |
if ( ! empty( $args['offset'] ) ) {
|
218 |
-
$query
|
219 |
$values[] = absint( $args['offset'] );
|
220 |
}
|
221 |
|
33 |
* Get columns and formats
|
34 |
*/
|
35 |
public function get_columns() {
|
36 |
+
return [
|
37 |
'ID' => '%d',
|
38 |
'uuid' => '%s',
|
39 |
'popup_id' => '%d',
|
46 |
'consent_args' => '%s',
|
47 |
'consent' => '%s',
|
48 |
'created' => '%s',
|
49 |
+
];
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
* Get default column values
|
54 |
*/
|
55 |
public function get_column_defaults() {
|
56 |
+
return [
|
57 |
'uuid' => '',
|
58 |
'popup_id' => 0,
|
59 |
'email_hash' => '',
|
65 |
'consent_args' => '',
|
66 |
'consent' => 'no',
|
67 |
'created' => current_time( 'mysql', 0 ),
|
68 |
+
];
|
69 |
|
70 |
}
|
71 |
|
77 |
global $wpdb;
|
78 |
|
79 |
if ( ! function_exists( 'dbDelta' ) ) {
|
80 |
+
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
81 |
}
|
82 |
|
83 |
$charset_collate = $wpdb->get_charset_collate();
|
92 |
* - [x] SQL keywords, like CREATE TABLE and UPDATE, must be uppercase.
|
93 |
* - [x] You must specify the length of all fields that accept a length parameter. int(11), for example.
|
94 |
*/
|
95 |
+
$sql = 'CREATE TABLE ' . $this->table_name() . " (
|
96 |
ID bigint(20) NOT NULL AUTO_INCREMENT,
|
97 |
email_hash varchar(32) NOT NULL,
|
98 |
popup_id bigint(20) NOT NULL,
|
116 |
PUM_Utils_Logging::instance()->log( 'Subscriber table results: ' . implode( ',', $results ) );
|
117 |
|
118 |
$previous_error = $wpdb->last_error; // The show tables query will erase the last error. So, record it now in case we need it.
|
119 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->table_name()}'" ) !== $this->table_name() ) {
|
120 |
PUM_Utils_Logging::instance()->log( "Subscriber table exists check failed! Last error from wpdb: $previous_error." );
|
121 |
}
|
122 |
|
128 |
}
|
129 |
|
130 |
|
131 |
+
public function query( $args = [], $return_type = 'OBJECT' ) {
|
132 |
global $wpdb;
|
133 |
|
134 |
+
$args = wp_parse_args(
|
135 |
+
$args,
|
136 |
+
[
|
137 |
+
'fields' => '*',
|
138 |
+
'page' => null,
|
139 |
+
'limit' => null,
|
140 |
+
'offset' => null,
|
141 |
+
's' => null,
|
142 |
+
'orderby' => null,
|
143 |
+
'order' => null,
|
144 |
+
]
|
145 |
+
);
|
146 |
|
147 |
$columns = $this->get_columns();
|
148 |
|
162 |
$query = "SELECT `$select_fields` FROM {$this->table_name()}";
|
163 |
|
164 |
// Set up $values array for wpdb::prepare
|
165 |
+
$values = [];
|
166 |
|
167 |
// Define an empty WHERE clause to start from.
|
168 |
+
$where = 'WHERE 1=1';
|
169 |
|
170 |
// Build search query.
|
171 |
if ( $args['s'] && ! empty( $args['s'] ) ) {
|
172 |
|
173 |
$search = wp_unslash( trim( $args['s'] ) );
|
174 |
|
175 |
+
$search_where = [];
|
176 |
|
177 |
foreach ( $columns as $key => $type ) {
|
178 |
if ( in_array( $key, $fields ) ) {
|
191 |
$query .= " $where";
|
192 |
|
193 |
if ( ! empty( $args['orderby'] ) ) {
|
194 |
+
$query .= ' ORDER BY %s';
|
195 |
$values[] = wp_unslash( trim( $args['orderby'] ) );
|
196 |
|
197 |
switch ( $args['order'] ) {
|
198 |
case 'asc':
|
199 |
case 'ASC':
|
200 |
+
$query .= ' ASC';
|
201 |
break;
|
202 |
case 'desc':
|
203 |
case 'DESC':
|
204 |
default:
|
205 |
+
$query .= ' DESC';
|
206 |
break;
|
207 |
}
|
208 |
}
|
209 |
|
210 |
if ( ! empty( $args['limit'] ) ) {
|
211 |
+
$query .= ' LIMIT %d';
|
212 |
$values[] = absint( $args['limit'] );
|
213 |
}
|
214 |
|
218 |
}
|
219 |
|
220 |
if ( ! empty( $args['offset'] ) ) {
|
221 |
+
$query .= ' OFFSET %d';
|
222 |
$values[] = absint( $args['offset'] );
|
223 |
}
|
224 |
|
classes/Deactivator.php
CHANGED
@@ -25,4 +25,4 @@ class PUM_Deactivator extends PUM_Install {
|
|
25 |
parent::deactivate_plugin( $network_wide );
|
26 |
}
|
27 |
|
28 |
-
|
25 |
parent::deactivate_plugin( $network_wide );
|
26 |
}
|
27 |
|
28 |
+
}
|
classes/Extension/Activator.php
CHANGED
@@ -83,15 +83,18 @@ class PUM_Extension_Activator {
|
|
83 |
*/
|
84 |
public function __construct( $class_name ) {
|
85 |
// We need plugin.php!
|
86 |
-
require_once
|
87 |
|
88 |
// Validate extension class is valid.
|
89 |
-
if ( in_array(
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
95 |
return;
|
96 |
}
|
97 |
|
@@ -133,24 +136,24 @@ class PUM_Extension_Activator {
|
|
133 |
public function run() {
|
134 |
if ( $this->get_status() != 'active' ) {
|
135 |
// Display notice
|
136 |
-
add_action( 'admin_notices',
|
137 |
} else {
|
138 |
$class_name = $this->extension_class_name;
|
139 |
|
140 |
// Generate an instance of the extension class in a PHP 5.2 compatible way.
|
141 |
-
call_user_func(
|
142 |
|
143 |
$this->extension_file = $this->get_static_prop( $class_name, 'FILE' );
|
144 |
|
145 |
$plugin_slug = explode( '/', plugin_basename( $this->extension_file ), 2 );
|
146 |
-
$this->extension_slug = str_replace(
|
147 |
|
148 |
// Handle licensing for extensions with valid ID & not wp repo extensions.
|
149 |
if ( $this->extension_id > 0 && ! $this->extension_wp_repo && class_exists( 'PUM_Extension_License' ) ) {
|
150 |
new PUM_Extension_License( $this->extension_file, $this->extension_name, $this->extension_version, 'Popup Maker', null, null, $this->extension_id );
|
151 |
}
|
152 |
|
153 |
-
add_filter( 'pum_enabled_extensions',
|
154 |
}
|
155 |
}
|
156 |
|
@@ -163,19 +166,19 @@ class PUM_Extension_Activator {
|
|
163 |
case 'not_activated':
|
164 |
$url = esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $this->core_path ), 'activate-plugin_' . $this->core_path ) );
|
165 |
$link = '<a href="' . $url . '">' . __( 'activate it' ) . '</a>';
|
166 |
-
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%s" requires %s! Please %s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', $link ) . '</p></div>';
|
167 |
|
168 |
break;
|
169 |
case 'not_updated':
|
170 |
$url = esc_url( wp_nonce_url( admin_url( 'update.php?action=upgrade-plugin&plugin=' . $this->core_path ), 'upgrade-plugin_' . $this->core_path ) );
|
171 |
$link = '<a href="' . $url . '">' . __( 'update it' ) . '</a>';
|
172 |
-
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%s" requires %s v%s or higher! Please %s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', '<strong>' . $this->required_core_version . '</strong>', $link ) . '</p></div>';
|
173 |
|
174 |
break;
|
175 |
case 'not_installed':
|
176 |
$url = esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker' ), 'install-plugin_popup-maker' ) );
|
177 |
$link = '<a href="' . $url . '">' . __( 'install it' ) . '</a>';
|
178 |
-
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%s" requires %s! Please %s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', $link ) . '</p></div>';
|
179 |
|
180 |
break;
|
181 |
case 'active':
|
@@ -189,7 +192,7 @@ class PUM_Extension_Activator {
|
|
189 |
*
|
190 |
* @return array
|
191 |
*/
|
192 |
-
public function enabled_extensions( $enabled_extensions =
|
193 |
$enabled_extensions[ $this->extension_slug ] = $this->extension_class_name;
|
194 |
|
195 |
return $enabled_extensions;
|
83 |
*/
|
84 |
public function __construct( $class_name ) {
|
85 |
// We need plugin.php!
|
86 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
87 |
|
88 |
// Validate extension class is valid.
|
89 |
+
if ( in_array(
|
90 |
+
false,
|
91 |
+
[
|
92 |
+
class_exists( $class_name ),
|
93 |
+
property_exists( $class_name, 'NAME' ),
|
94 |
+
property_exists( $class_name, 'REQUIRED_CORE_VER' ),
|
95 |
+
method_exists( $class_name, 'instance' ),
|
96 |
+
]
|
97 |
+
) ) {
|
98 |
return;
|
99 |
}
|
100 |
|
136 |
public function run() {
|
137 |
if ( $this->get_status() != 'active' ) {
|
138 |
// Display notice
|
139 |
+
add_action( 'admin_notices', [ $this, 'missing_popmake_notice' ] );
|
140 |
} else {
|
141 |
$class_name = $this->extension_class_name;
|
142 |
|
143 |
// Generate an instance of the extension class in a PHP 5.2 compatible way.
|
144 |
+
call_user_func( [ $class_name, 'instance' ] );
|
145 |
|
146 |
$this->extension_file = $this->get_static_prop( $class_name, 'FILE' );
|
147 |
|
148 |
$plugin_slug = explode( '/', plugin_basename( $this->extension_file ), 2 );
|
149 |
+
$this->extension_slug = str_replace( [ 'popup-maker-', 'pum-' ], '', $plugin_slug[0] );
|
150 |
|
151 |
// Handle licensing for extensions with valid ID & not wp repo extensions.
|
152 |
if ( $this->extension_id > 0 && ! $this->extension_wp_repo && class_exists( 'PUM_Extension_License' ) ) {
|
153 |
new PUM_Extension_License( $this->extension_file, $this->extension_name, $this->extension_version, 'Popup Maker', null, null, $this->extension_id );
|
154 |
}
|
155 |
|
156 |
+
add_filter( 'pum_enabled_extensions', [ $this, 'enabled_extensions' ] );
|
157 |
}
|
158 |
}
|
159 |
|
166 |
case 'not_activated':
|
167 |
$url = esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $this->core_path ), 'activate-plugin_' . $this->core_path ) );
|
168 |
$link = '<a href="' . $url . '">' . __( 'activate it' ) . '</a>';
|
169 |
+
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%1$s" requires %2$s! Please %3$s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', $link ) . '</p></div>';
|
170 |
|
171 |
break;
|
172 |
case 'not_updated':
|
173 |
$url = esc_url( wp_nonce_url( admin_url( 'update.php?action=upgrade-plugin&plugin=' . $this->core_path ), 'upgrade-plugin_' . $this->core_path ) );
|
174 |
$link = '<a href="' . $url . '">' . __( 'update it' ) . '</a>';
|
175 |
+
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%1$s" requires %2$s v%3$s or higher! Please %4$s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', '<strong>' . $this->required_core_version . '</strong>', $link ) . '</p></div>';
|
176 |
|
177 |
break;
|
178 |
case 'not_installed':
|
179 |
$url = esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker' ), 'install-plugin_popup-maker' ) );
|
180 |
$link = '<a href="' . $url . '">' . __( 'install it' ) . '</a>';
|
181 |
+
echo '<div class="error"><p>' . sprintf( __( 'The plugin "%1$s" requires %2$s! Please %3$s to continue!' ), $this->extension_name, '<strong>' . __( 'Popup Maker' ) . '</strong>', $link ) . '</p></div>';
|
182 |
|
183 |
break;
|
184 |
case 'active':
|
192 |
*
|
193 |
* @return array
|
194 |
*/
|
195 |
+
public function enabled_extensions( $enabled_extensions = [] ) {
|
196 |
$enabled_extensions[ $this->extension_slug ] = $this->extension_class_name;
|
197 |
|
198 |
return $enabled_extensions;
|
classes/Extension/License.php
CHANGED
@@ -96,33 +96,33 @@ class PUM_Extension_License {
|
|
96 |
private function hooks() {
|
97 |
|
98 |
// Register settings
|
99 |
-
add_filter( 'pum_settings_fields',
|
100 |
|
101 |
// Activate license key on settings save
|
102 |
-
add_action( 'admin_init',
|
103 |
|
104 |
// Deactivate license key
|
105 |
-
add_action( 'admin_init',
|
106 |
|
107 |
// Check that license is valid once per week
|
108 |
-
add_action( 'popmake_weekly_scheduled_events',
|
109 |
|
110 |
// For testing license notices, uncomment this line to force checks on every page load
|
111 |
-
//add_action( 'admin_init', array( $this, 'weekly_license_check' ) );
|
112 |
|
113 |
// Updater
|
114 |
-
add_action( 'admin_init',
|
115 |
|
116 |
// Display notices to admins
|
117 |
// add_action( 'admin_notices', array( $this, 'notices' ) );
|
118 |
|
119 |
// Display notices to admins
|
120 |
-
add_filter( 'pum_alert_list',
|
121 |
|
122 |
-
add_action( 'in_plugin_update_message-' . plugin_basename( $this->file ),
|
123 |
|
124 |
// Register plugins for beta support
|
125 |
-
add_filter( 'pum_beta_enabled_extensions',
|
126 |
}
|
127 |
|
128 |
/**
|
@@ -132,12 +132,12 @@ class PUM_Extension_License {
|
|
132 |
* @return void
|
133 |
*/
|
134 |
public function auto_updater() {
|
135 |
-
$args =
|
136 |
'version' => $this->version,
|
137 |
'license' => $this->license,
|
138 |
'author' => $this->author,
|
139 |
'beta' => PUM_Admin_Tools::extension_has_beta_support( $this->item_shortname ),
|
140 |
-
|
141 |
|
142 |
if ( ! empty( $this->item_id ) ) {
|
143 |
$args['item_id'] = $this->item_id;
|
@@ -159,27 +159,27 @@ class PUM_Extension_License {
|
|
159 |
*
|
160 |
* @return array
|
161 |
*/
|
162 |
-
public function settings( $tabs =
|
163 |
static $license_help_text = false;
|
164 |
|
165 |
if ( ! $license_help_text && ! isset( $tabs['licenses']['main']['license_help_text'] ) ) {
|
166 |
$license_help_text = true;
|
167 |
|
168 |
-
$tabs['licenses']['main']['license_help_text'] =
|
169 |
'type' => 'html',
|
170 |
-
'content' => '<p><strong>' . sprintf( __( 'Enter your extension license keys here to receive updates for purchased extensions. If your license key has expired, please %srenew your license%s.', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/177-license-renewal?utm_medium=license-help-text&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab" target="_blank">', '</a>' ) . '</strong></p>',
|
171 |
'priority' => 0,
|
172 |
-
|
173 |
}
|
174 |
|
175 |
-
$tabs['licenses']['main'][ $this->item_shortname . '_license_key' ] =
|
176 |
'type' => 'license_key',
|
177 |
'label' => sprintf( __( '%1$s', 'popup-maker' ), $this->item_name ),
|
178 |
-
'options' =>
|
179 |
'is_valid_license_option' => $this->item_shortname . '_license_active',
|
180 |
-
'activation_callback' =>
|
181 |
-
|
182 |
-
|
183 |
|
184 |
return $tabs;
|
185 |
}
|
@@ -221,21 +221,24 @@ class PUM_Extension_License {
|
|
221 |
}
|
222 |
|
223 |
// Data to send to the API
|
224 |
-
$api_params =
|
225 |
-
'edd_action'
|
226 |
-
'license'
|
227 |
-
'item_id'
|
228 |
-
'item_name'
|
229 |
-
'url'
|
230 |
'environment' => function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production',
|
231 |
-
|
232 |
|
233 |
// Call the API
|
234 |
-
$response = wp_remote_post(
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
|
|
|
|
|
|
239 |
|
240 |
// Make sure there are no errors
|
241 |
if ( is_wp_error( $response ) ) {
|
@@ -276,19 +279,22 @@ class PUM_Extension_License {
|
|
276 |
if ( isset( $_POST['pum_license_deactivate'][ $this->item_shortname . '_license_key' ] ) ) {
|
277 |
|
278 |
// Data to send to the API
|
279 |
-
$api_params =
|
280 |
'edd_action' => 'deactivate_license',
|
281 |
'license' => $this->license,
|
282 |
'item_name' => urlencode( $this->item_name ),
|
283 |
'url' => home_url(),
|
284 |
-
|
285 |
|
286 |
// Call the API
|
287 |
-
$response = wp_remote_post(
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
292 |
|
293 |
// Make sure there are no errors
|
294 |
if ( is_wp_error( $response ) ) {
|
@@ -322,19 +328,22 @@ class PUM_Extension_License {
|
|
322 |
}
|
323 |
|
324 |
// data to send in our API request
|
325 |
-
$api_params =
|
326 |
'edd_action' => 'check_license',
|
327 |
'license' => $this->license,
|
328 |
'item_name' => urlencode( $this->item_name ),
|
329 |
'url' => home_url(),
|
330 |
-
|
331 |
|
332 |
// Call the API
|
333 |
-
$response = wp_remote_post(
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
338 |
|
339 |
// make sure the response came back okay
|
340 |
if ( is_wp_error( $response ) ) {
|
@@ -353,12 +362,12 @@ class PUM_Extension_License {
|
|
353 |
* @param array $alerts The existing alerts from the pum_alert_list filter
|
354 |
* @return array Our modified array of alerts
|
355 |
*/
|
356 |
-
public function alerts( $alerts =
|
357 |
|
358 |
static $showed_invalid_message;
|
359 |
|
360 |
// If user can't manage it, or we already showed this alert abort.
|
361 |
-
if (
|
362 |
return $alerts;
|
363 |
}
|
364 |
|
@@ -381,21 +390,21 @@ class PUM_Extension_License {
|
|
381 |
$showed_invalid_message = true;
|
382 |
|
383 |
if ( empty( $this->license ) ) {
|
384 |
-
$alerts[] =
|
385 |
'code' => 'license_not_valid',
|
386 |
-
'message' => sprintf( __( 'One or more of your extensions are missing license keys. You will not be able to receive updates until the extension has a valid license key entered. Please go to the %sLicenses page%s to add your license keys.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' ),
|
387 |
'type' => 'error',
|
388 |
'dismissible' => '4 weeks',
|
389 |
'priority' => 0,
|
390 |
-
|
391 |
} else {
|
392 |
-
$alerts[] =
|
393 |
'code' => 'license_not_valid',
|
394 |
-
'message' => sprintf( __( 'You have invalid or expired license keys for Popup Maker. Please go to the %sLicenses page%s to correct this issue.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' ),
|
395 |
'type' => 'error',
|
396 |
'dismissible' => '4 weeks',
|
397 |
'priority' => 0,
|
398 |
-
|
399 |
}
|
400 |
|
401 |
return $alerts;
|
@@ -419,7 +428,7 @@ class PUM_Extension_License {
|
|
419 |
return;
|
420 |
}
|
421 |
|
422 |
-
$messages =
|
423 |
|
424 |
$license = get_option( $this->item_shortname . '_license_active' );
|
425 |
|
@@ -427,12 +436,11 @@ class PUM_Extension_License {
|
|
427 |
|
428 |
if ( empty( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) {
|
429 |
|
430 |
-
$messages[] = sprintf( __( 'You have invalid or expired license keys for Popup Maker. Please go to the %sLicenses page%s to correct this issue.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' );
|
431 |
|
432 |
$showed_invalid_message = true;
|
433 |
|
434 |
}
|
435 |
-
|
436 |
}
|
437 |
|
438 |
if ( ! empty( $messages ) ) {
|
@@ -440,11 +448,10 @@ class PUM_Extension_License {
|
|
440 |
foreach ( $messages as $message ) {
|
441 |
|
442 |
echo '<div class="error">';
|
443 |
-
echo '<p>' . $message . '</p>';
|
444 |
echo '</div>';
|
445 |
|
446 |
}
|
447 |
-
|
448 |
}
|
449 |
|
450 |
}
|
96 |
private function hooks() {
|
97 |
|
98 |
// Register settings
|
99 |
+
add_filter( 'pum_settings_fields', [ $this, 'settings' ], 1 );
|
100 |
|
101 |
// Activate license key on settings save
|
102 |
+
add_action( 'admin_init', [ $this, 'activate_license' ] );
|
103 |
|
104 |
// Deactivate license key
|
105 |
+
add_action( 'admin_init', [ $this, 'deactivate_license' ] );
|
106 |
|
107 |
// Check that license is valid once per week
|
108 |
+
add_action( 'popmake_weekly_scheduled_events', [ $this, 'weekly_license_check' ] );
|
109 |
|
110 |
// For testing license notices, uncomment this line to force checks on every page load
|
111 |
+
// add_action( 'admin_init', array( $this, 'weekly_license_check' ) );
|
112 |
|
113 |
// Updater
|
114 |
+
add_action( 'admin_init', [ $this, 'auto_updater' ], 0 );
|
115 |
|
116 |
// Display notices to admins
|
117 |
// add_action( 'admin_notices', array( $this, 'notices' ) );
|
118 |
|
119 |
// Display notices to admins
|
120 |
+
add_filter( 'pum_alert_list', [ $this, 'alerts' ] );
|
121 |
|
122 |
+
add_action( 'in_plugin_update_message-' . plugin_basename( $this->file ), [ $this, 'plugin_row_license_missing' ], 10, 2 );
|
123 |
|
124 |
// Register plugins for beta support
|
125 |
+
add_filter( 'pum_beta_enabled_extensions', [ $this, 'register_beta_support' ] );
|
126 |
}
|
127 |
|
128 |
/**
|
132 |
* @return void
|
133 |
*/
|
134 |
public function auto_updater() {
|
135 |
+
$args = [
|
136 |
'version' => $this->version,
|
137 |
'license' => $this->license,
|
138 |
'author' => $this->author,
|
139 |
'beta' => PUM_Admin_Tools::extension_has_beta_support( $this->item_shortname ),
|
140 |
+
];
|
141 |
|
142 |
if ( ! empty( $this->item_id ) ) {
|
143 |
$args['item_id'] = $this->item_id;
|
159 |
*
|
160 |
* @return array
|
161 |
*/
|
162 |
+
public function settings( $tabs = [] ) {
|
163 |
static $license_help_text = false;
|
164 |
|
165 |
if ( ! $license_help_text && ! isset( $tabs['licenses']['main']['license_help_text'] ) ) {
|
166 |
$license_help_text = true;
|
167 |
|
168 |
+
$tabs['licenses']['main']['license_help_text'] = [
|
169 |
'type' => 'html',
|
170 |
+
'content' => '<p><strong>' . sprintf( __( 'Enter your extension license keys here to receive updates for purchased extensions. If your license key has expired, please %1$srenew your license%2$s.', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/177-license-renewal?utm_medium=license-help-text&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab" target="_blank">', '</a>' ) . '</strong></p>',
|
171 |
'priority' => 0,
|
172 |
+
];
|
173 |
}
|
174 |
|
175 |
+
$tabs['licenses']['main'][ $this->item_shortname . '_license_key' ] = [
|
176 |
'type' => 'license_key',
|
177 |
'label' => sprintf( __( '%1$s', 'popup-maker' ), $this->item_name ),
|
178 |
+
'options' => [
|
179 |
'is_valid_license_option' => $this->item_shortname . '_license_active',
|
180 |
+
'activation_callback' => [ $this, 'activate_license' ],
|
181 |
+
],
|
182 |
+
];
|
183 |
|
184 |
return $tabs;
|
185 |
}
|
221 |
}
|
222 |
|
223 |
// Data to send to the API
|
224 |
+
$api_params = [
|
225 |
+
'edd_action' => 'activate_license',
|
226 |
+
'license' => $license,
|
227 |
+
'item_id' => $this->item_id,
|
228 |
+
'item_name' => rawurlencode( $this->item_name ),
|
229 |
+
'url' => home_url(),
|
230 |
'environment' => function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production',
|
231 |
+
];
|
232 |
|
233 |
// Call the API
|
234 |
+
$response = wp_remote_post(
|
235 |
+
$this->api_url,
|
236 |
+
[
|
237 |
+
'timeout' => 15,
|
238 |
+
'sslverify' => false,
|
239 |
+
'body' => $api_params,
|
240 |
+
]
|
241 |
+
);
|
242 |
|
243 |
// Make sure there are no errors
|
244 |
if ( is_wp_error( $response ) ) {
|
279 |
if ( isset( $_POST['pum_license_deactivate'][ $this->item_shortname . '_license_key' ] ) ) {
|
280 |
|
281 |
// Data to send to the API
|
282 |
+
$api_params = [
|
283 |
'edd_action' => 'deactivate_license',
|
284 |
'license' => $this->license,
|
285 |
'item_name' => urlencode( $this->item_name ),
|
286 |
'url' => home_url(),
|
287 |
+
];
|
288 |
|
289 |
// Call the API
|
290 |
+
$response = wp_remote_post(
|
291 |
+
$this->api_url,
|
292 |
+
[
|
293 |
+
'timeout' => 15,
|
294 |
+
'sslverify' => false,
|
295 |
+
'body' => $api_params,
|
296 |
+
]
|
297 |
+
);
|
298 |
|
299 |
// Make sure there are no errors
|
300 |
if ( is_wp_error( $response ) ) {
|
328 |
}
|
329 |
|
330 |
// data to send in our API request
|
331 |
+
$api_params = [
|
332 |
'edd_action' => 'check_license',
|
333 |
'license' => $this->license,
|
334 |
'item_name' => urlencode( $this->item_name ),
|
335 |
'url' => home_url(),
|
336 |
+
];
|
337 |
|
338 |
// Call the API
|
339 |
+
$response = wp_remote_post(
|
340 |
+
$this->api_url,
|
341 |
+
[
|
342 |
+
'timeout' => 15,
|
343 |
+
'sslverify' => false,
|
344 |
+
'body' => $api_params,
|
345 |
+
]
|
346 |
+
);
|
347 |
|
348 |
// make sure the response came back okay
|
349 |
if ( is_wp_error( $response ) ) {
|
362 |
* @param array $alerts The existing alerts from the pum_alert_list filter
|
363 |
* @return array Our modified array of alerts
|
364 |
*/
|
365 |
+
public function alerts( $alerts = [] ) {
|
366 |
|
367 |
static $showed_invalid_message;
|
368 |
|
369 |
// If user can't manage it, or we already showed this alert abort.
|
370 |
+
if ( ! current_user_can( 'manage_options' ) || $showed_invalid_message ) {
|
371 |
return $alerts;
|
372 |
}
|
373 |
|
390 |
$showed_invalid_message = true;
|
391 |
|
392 |
if ( empty( $this->license ) ) {
|
393 |
+
$alerts[] = [
|
394 |
'code' => 'license_not_valid',
|
395 |
+
'message' => sprintf( __( 'One or more of your extensions are missing license keys. You will not be able to receive updates until the extension has a valid license key entered. Please go to the %1$sLicenses page%2$s to add your license keys.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' ),
|
396 |
'type' => 'error',
|
397 |
'dismissible' => '4 weeks',
|
398 |
'priority' => 0,
|
399 |
+
];
|
400 |
} else {
|
401 |
+
$alerts[] = [
|
402 |
'code' => 'license_not_valid',
|
403 |
+
'message' => sprintf( __( 'You have invalid or expired license keys for Popup Maker. Please go to the %1$sLicenses page%2$s to correct this issue.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' ),
|
404 |
'type' => 'error',
|
405 |
'dismissible' => '4 weeks',
|
406 |
'priority' => 0,
|
407 |
+
];
|
408 |
}
|
409 |
|
410 |
return $alerts;
|
428 |
return;
|
429 |
}
|
430 |
|
431 |
+
$messages = [];
|
432 |
|
433 |
$license = get_option( $this->item_shortname . '_license_active' );
|
434 |
|
436 |
|
437 |
if ( empty( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) {
|
438 |
|
439 |
+
$messages[] = sprintf( __( 'You have invalid or expired license keys for Popup Maker. Please go to the %1$sLicenses page%2$s to correct this issue.', 'popup-maker' ), '<a href="' . admin_url( 'edit.php?post_type=popup&page=pum-settings&tab=licenses' ) . '">', '</a>' );
|
440 |
|
441 |
$showed_invalid_message = true;
|
442 |
|
443 |
}
|
|
|
444 |
}
|
445 |
|
446 |
if ( ! empty( $messages ) ) {
|
448 |
foreach ( $messages as $message ) {
|
449 |
|
450 |
echo '<div class="error">';
|
451 |
+
echo '<p>' . esc_html( $message ) . '</p>';
|
452 |
echo '</div>';
|
453 |
|
454 |
}
|
|
|
455 |
}
|
456 |
|
457 |
}
|
classes/Extension/Updater.php
CHANGED
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
19 |
class PUM_Extension_Updater {
|
20 |
|
21 |
private $api_url = '';
|
22 |
-
private $api_data =
|
23 |
private $name = '';
|
24 |
private $slug = '';
|
25 |
private $version = '';
|
@@ -34,9 +34,9 @@ class PUM_Extension_Updater {
|
|
34 |
* @uses plugin_basename()
|
35 |
* @uses hook()
|
36 |
*
|
37 |
-
* @param string
|
38 |
-
* @param string
|
39 |
-
* @param array
|
40 |
*/
|
41 |
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
42 |
|
@@ -76,11 +76,11 @@ class PUM_Extension_Updater {
|
|
76 |
*/
|
77 |
public function init() {
|
78 |
|
79 |
-
add_filter( 'pre_set_site_transient_update_plugins',
|
80 |
-
add_filter( 'plugins_api',
|
81 |
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
82 |
-
add_action( 'after_plugin_row_' . $this->name,
|
83 |
-
add_action( 'admin_init',
|
84 |
|
85 |
}
|
86 |
|
@@ -94,7 +94,7 @@ class PUM_Extension_Updater {
|
|
94 |
*
|
95 |
* @uses api_request()
|
96 |
*
|
97 |
-
* @param array
|
98 |
* @return array Modified update array with custom plugin data.
|
99 |
*/
|
100 |
public function check_update( $_transient_data ) {
|
@@ -102,7 +102,7 @@ class PUM_Extension_Updater {
|
|
102 |
global $pagenow;
|
103 |
|
104 |
if ( ! is_object( $_transient_data ) ) {
|
105 |
-
$_transient_data = new stdClass;
|
106 |
}
|
107 |
|
108 |
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
@@ -116,7 +116,13 @@ class PUM_Extension_Updater {
|
|
116 |
$version_info = $this->get_cached_version_info();
|
117 |
|
118 |
if ( false === $version_info ) {
|
119 |
-
$version_info = $this->api_request(
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
$this->set_version_info_cache( $version_info );
|
122 |
|
@@ -144,8 +150,8 @@ class PUM_Extension_Updater {
|
|
144 |
/**
|
145 |
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
146 |
*
|
147 |
-
* @param string
|
148 |
-
* @param array
|
149 |
*/
|
150 |
public function show_update_notification( $file, $plugin ) {
|
151 |
|
@@ -153,11 +159,11 @@ class PUM_Extension_Updater {
|
|
153 |
return;
|
154 |
}
|
155 |
|
156 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
157 |
return;
|
158 |
}
|
159 |
|
160 |
-
if( ! is_multisite() ) {
|
161 |
return;
|
162 |
}
|
163 |
|
@@ -166,7 +172,7 @@ class PUM_Extension_Updater {
|
|
166 |
}
|
167 |
|
168 |
// Remove our filter on the site transient
|
169 |
-
remove_filter( 'pre_set_site_transient_update_plugins',
|
170 |
|
171 |
$update_cache = get_site_transient( 'update_plugins' );
|
172 |
|
@@ -177,7 +183,13 @@ class PUM_Extension_Updater {
|
|
177 |
$version_info = $this->get_cached_version_info();
|
178 |
|
179 |
if ( false === $version_info ) {
|
180 |
-
$version_info = $this->api_request(
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
|
183 |
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
|
@@ -205,7 +217,7 @@ class PUM_Extension_Updater {
|
|
205 |
|
206 |
}
|
207 |
|
208 |
-
$update_cache->last_checked
|
209 |
$update_cache->checked[ $this->name ] = $this->version;
|
210 |
|
211 |
set_site_transient( 'update_plugins', $update_cache );
|
@@ -217,13 +229,13 @@ class PUM_Extension_Updater {
|
|
217 |
}
|
218 |
|
219 |
// Restore our filter
|
220 |
-
add_filter( 'pre_set_site_transient_update_plugins',
|
221 |
|
222 |
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
223 |
|
224 |
// build a plugin list row, with update notification
|
225 |
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
226 |
-
|
227 |
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
228 |
echo '<td colspan="3" class="plugin-update colspanchange">';
|
229 |
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
@@ -245,7 +257,7 @@ class PUM_Extension_Updater {
|
|
245 |
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
246 |
esc_html( $version_info->new_version ),
|
247 |
'</a>',
|
248 |
-
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
249 |
'</a>'
|
250 |
);
|
251 |
}
|
@@ -261,9 +273,9 @@ class PUM_Extension_Updater {
|
|
261 |
*
|
262 |
* @uses api_request()
|
263 |
*
|
264 |
-
* @param mixed
|
265 |
-
* @param string
|
266 |
-
* @param object
|
267 |
* @return object $_data
|
268 |
*/
|
269 |
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
@@ -280,22 +292,22 @@ class PUM_Extension_Updater {
|
|
280 |
|
281 |
}
|
282 |
|
283 |
-
$to_send =
|
284 |
'slug' => $this->slug,
|
285 |
'is_ssl' => is_ssl(),
|
286 |
-
'fields' =>
|
287 |
-
'banners' =>
|
288 |
'reviews' => false,
|
289 |
-
'icons' =>
|
290 |
-
|
291 |
-
|
292 |
|
293 |
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
294 |
|
295 |
// Get the transient where we store the api request for this plugin for 24 hours
|
296 |
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
297 |
|
298 |
-
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
|
299 |
if ( empty( $edd_api_request_transient ) ) {
|
300 |
|
301 |
$api_response = $this->api_request( 'plugin_information', $to_send );
|
@@ -306,7 +318,6 @@ class PUM_Extension_Updater {
|
|
306 |
if ( false !== $api_response ) {
|
307 |
$_data = $api_response;
|
308 |
}
|
309 |
-
|
310 |
} else {
|
311 |
$_data = $edd_api_request_transient;
|
312 |
}
|
@@ -326,7 +337,7 @@ class PUM_Extension_Updater {
|
|
326 |
$_data->icons = $this->convert_object_to_array( $_data->icons );
|
327 |
}
|
328 |
|
329 |
-
if( ! isset( $_data->plugin ) ) {
|
330 |
$_data->plugin = $this->name;
|
331 |
}
|
332 |
|
@@ -346,7 +357,7 @@ class PUM_Extension_Updater {
|
|
346 |
* @return array
|
347 |
*/
|
348 |
private function convert_object_to_array( $data ) {
|
349 |
-
$new_data =
|
350 |
foreach ( $data as $key => $value ) {
|
351 |
$new_data[ $key ] = $value;
|
352 |
}
|
@@ -357,8 +368,8 @@ class PUM_Extension_Updater {
|
|
357 |
/**
|
358 |
* Disable SSL verification in order to prevent download update failures
|
359 |
*
|
360 |
-
* @param array
|
361 |
-
* @param string
|
362 |
* @return object $array
|
363 |
*/
|
364 |
public function http_request_args( $args, $url ) {
|
@@ -378,8 +389,8 @@ class PUM_Extension_Updater {
|
|
378 |
* @uses wp_remote_post()
|
379 |
* @uses is_wp_error()
|
380 |
*
|
381 |
-
* @param string
|
382 |
-
* @param array
|
383 |
* @return false|object
|
384 |
*/
|
385 |
private function api_request( $_action, $_data ) {
|
@@ -393,15 +404,21 @@ class PUM_Extension_Updater {
|
|
393 |
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
|
394 |
$test_url_parts = parse_url( $this->api_url );
|
395 |
|
396 |
-
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme']
|
397 |
-
$host = ! empty( $test_url_parts['host'] )
|
398 |
-
$port = ! empty( $test_url_parts['port'] )
|
399 |
|
400 |
if ( empty( $host ) ) {
|
401 |
$edd_plugin_url_available[ $store_hash ] = false;
|
402 |
} else {
|
403 |
-
$test_url
|
404 |
-
$response
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
|
406 |
}
|
407 |
}
|
@@ -416,11 +433,11 @@ class PUM_Extension_Updater {
|
|
416 |
return;
|
417 |
}
|
418 |
|
419 |
-
if( $this->api_url == trailingslashit
|
420 |
return false; // Don't allow a plugin to ping itself
|
421 |
}
|
422 |
|
423 |
-
$api_params =
|
424 |
'edd_action' => 'get_version',
|
425 |
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
426 |
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
@@ -430,10 +447,17 @@ class PUM_Extension_Updater {
|
|
430 |
'author' => $data['author'],
|
431 |
'url' => home_url(),
|
432 |
'beta' => ! empty( $data['beta'] ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
);
|
434 |
|
435 |
-
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
436 |
-
|
437 |
if ( ! is_wp_error( $request ) ) {
|
438 |
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
439 |
}
|
@@ -452,8 +476,8 @@ class PUM_Extension_Updater {
|
|
452 |
$request->icons = maybe_unserialize( $request->icons );
|
453 |
}
|
454 |
|
455 |
-
if( ! empty( $request->sections ) ) {
|
456 |
-
foreach( $request->sections as $key => $section ) {
|
457 |
$request->$key = (array) $section;
|
458 |
}
|
459 |
}
|
@@ -465,20 +489,20 @@ class PUM_Extension_Updater {
|
|
465 |
|
466 |
global $edd_plugin_data;
|
467 |
|
468 |
-
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
469 |
return;
|
470 |
}
|
471 |
|
472 |
-
if( empty( $_REQUEST['plugin'] ) ) {
|
473 |
return;
|
474 |
}
|
475 |
|
476 |
-
if( empty( $_REQUEST['slug'] ) ) {
|
477 |
return;
|
478 |
}
|
479 |
|
480 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
481 |
-
wp_die( __( 'You do not have permission to install plugin updates', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
482 |
}
|
483 |
|
484 |
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
@@ -486,34 +510,40 @@ class PUM_Extension_Updater {
|
|
486 |
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
487 |
$version_info = $this->get_cached_version_info( $cache_key );
|
488 |
|
489 |
-
if( false === $version_info ) {
|
490 |
|
491 |
-
$api_params =
|
492 |
'edd_action' => 'get_version',
|
493 |
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
494 |
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
495 |
'slug' => $_REQUEST['slug'],
|
496 |
'author' => $data['author'],
|
497 |
'url' => home_url(),
|
498 |
-
'beta' => ! empty( $data['beta'] )
|
499 |
-
|
500 |
|
501 |
$verify_ssl = $this->verify_ssl();
|
502 |
-
$request = wp_remote_post(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
|
504 |
if ( ! is_wp_error( $request ) ) {
|
505 |
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
506 |
}
|
507 |
|
508 |
-
|
509 |
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
510 |
$version_info->sections = maybe_unserialize( $version_info->sections );
|
511 |
} else {
|
512 |
$version_info = false;
|
513 |
}
|
514 |
|
515 |
-
if( ! empty( $version_info ) ) {
|
516 |
-
foreach( $version_info->sections as $key => $section ) {
|
517 |
$version_info->$key = (array) $section;
|
518 |
}
|
519 |
}
|
@@ -522,7 +552,7 @@ class PUM_Extension_Updater {
|
|
522 |
|
523 |
}
|
524 |
|
525 |
-
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
526 |
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
527 |
}
|
528 |
|
@@ -531,13 +561,13 @@ class PUM_Extension_Updater {
|
|
531 |
|
532 |
public function get_cached_version_info( $cache_key = '' ) {
|
533 |
|
534 |
-
if( empty( $cache_key ) ) {
|
535 |
$cache_key = $this->cache_key;
|
536 |
}
|
537 |
|
538 |
$cache = get_option( $cache_key );
|
539 |
|
540 |
-
if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
|
541 |
return false; // Cache is expired
|
542 |
}
|
543 |
|
@@ -553,14 +583,14 @@ class PUM_Extension_Updater {
|
|
553 |
|
554 |
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
555 |
|
556 |
-
if( empty( $cache_key ) ) {
|
557 |
$cache_key = $this->cache_key;
|
558 |
}
|
559 |
|
560 |
-
$data =
|
561 |
'timeout' => strtotime( '+3 hours', time() ),
|
562 |
-
'value' => json_encode( $value )
|
563 |
-
|
564 |
|
565 |
update_option( $cache_key, $data, 'no' );
|
566 |
|
19 |
class PUM_Extension_Updater {
|
20 |
|
21 |
private $api_url = '';
|
22 |
+
private $api_data = [];
|
23 |
private $name = '';
|
24 |
private $slug = '';
|
25 |
private $version = '';
|
34 |
* @uses plugin_basename()
|
35 |
* @uses hook()
|
36 |
*
|
37 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
38 |
+
* @param string $_plugin_file Path to the plugin file.
|
39 |
+
* @param array $_api_data Optional data to send with API calls.
|
40 |
*/
|
41 |
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
42 |
|
76 |
*/
|
77 |
public function init() {
|
78 |
|
79 |
+
add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ] );
|
80 |
+
add_filter( 'plugins_api', [ $this, 'plugins_api_filter' ], 10, 3 );
|
81 |
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
82 |
+
add_action( 'after_plugin_row_' . $this->name, [ $this, 'show_update_notification' ], 10, 2 );
|
83 |
+
add_action( 'admin_init', [ $this, 'show_changelog' ] );
|
84 |
|
85 |
}
|
86 |
|
94 |
*
|
95 |
* @uses api_request()
|
96 |
*
|
97 |
+
* @param array $_transient_data Update array build by WordPress.
|
98 |
* @return array Modified update array with custom plugin data.
|
99 |
*/
|
100 |
public function check_update( $_transient_data ) {
|
102 |
global $pagenow;
|
103 |
|
104 |
if ( ! is_object( $_transient_data ) ) {
|
105 |
+
$_transient_data = new stdClass();
|
106 |
}
|
107 |
|
108 |
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
116 |
$version_info = $this->get_cached_version_info();
|
117 |
|
118 |
if ( false === $version_info ) {
|
119 |
+
$version_info = $this->api_request(
|
120 |
+
'plugin_latest_version',
|
121 |
+
[
|
122 |
+
'slug' => $this->slug,
|
123 |
+
'beta' => $this->beta,
|
124 |
+
]
|
125 |
+
);
|
126 |
|
127 |
$this->set_version_info_cache( $version_info );
|
128 |
|
150 |
/**
|
151 |
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
152 |
*
|
153 |
+
* @param string $file
|
154 |
+
* @param array $plugin
|
155 |
*/
|
156 |
public function show_update_notification( $file, $plugin ) {
|
157 |
|
159 |
return;
|
160 |
}
|
161 |
|
162 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
163 |
return;
|
164 |
}
|
165 |
|
166 |
+
if ( ! is_multisite() ) {
|
167 |
return;
|
168 |
}
|
169 |
|
172 |
}
|
173 |
|
174 |
// Remove our filter on the site transient
|
175 |
+
remove_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ], 10 );
|
176 |
|
177 |
$update_cache = get_site_transient( 'update_plugins' );
|
178 |
|
183 |
$version_info = $this->get_cached_version_info();
|
184 |
|
185 |
if ( false === $version_info ) {
|
186 |
+
$version_info = $this->api_request(
|
187 |
+
'plugin_latest_version',
|
188 |
+
[
|
189 |
+
'slug' => $this->slug,
|
190 |
+
'beta' => $this->beta,
|
191 |
+
]
|
192 |
+
);
|
193 |
|
194 |
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
|
195 |
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
|
217 |
|
218 |
}
|
219 |
|
220 |
+
$update_cache->last_checked = time();
|
221 |
$update_cache->checked[ $this->name ] = $this->version;
|
222 |
|
223 |
set_site_transient( 'update_plugins', $update_cache );
|
229 |
}
|
230 |
|
231 |
// Restore our filter
|
232 |
+
add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ] );
|
233 |
|
234 |
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
235 |
|
236 |
// build a plugin list row, with update notification
|
237 |
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
238 |
+
// <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
|
239 |
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
240 |
echo '<td colspan="3" class="plugin-update colspanchange">';
|
241 |
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
257 |
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
258 |
esc_html( $version_info->new_version ),
|
259 |
'</a>',
|
260 |
+
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">',
|
261 |
'</a>'
|
262 |
);
|
263 |
}
|
273 |
*
|
274 |
* @uses api_request()
|
275 |
*
|
276 |
+
* @param mixed $_data
|
277 |
+
* @param string $_action
|
278 |
+
* @param object $_args
|
279 |
* @return object $_data
|
280 |
*/
|
281 |
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
292 |
|
293 |
}
|
294 |
|
295 |
+
$to_send = [
|
296 |
'slug' => $this->slug,
|
297 |
'is_ssl' => is_ssl(),
|
298 |
+
'fields' => [
|
299 |
+
'banners' => [],
|
300 |
'reviews' => false,
|
301 |
+
'icons' => [],
|
302 |
+
],
|
303 |
+
];
|
304 |
|
305 |
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
306 |
|
307 |
// Get the transient where we store the api request for this plugin for 24 hours
|
308 |
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
309 |
|
310 |
+
// If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
|
311 |
if ( empty( $edd_api_request_transient ) ) {
|
312 |
|
313 |
$api_response = $this->api_request( 'plugin_information', $to_send );
|
318 |
if ( false !== $api_response ) {
|
319 |
$_data = $api_response;
|
320 |
}
|
|
|
321 |
} else {
|
322 |
$_data = $edd_api_request_transient;
|
323 |
}
|
337 |
$_data->icons = $this->convert_object_to_array( $_data->icons );
|
338 |
}
|
339 |
|
340 |
+
if ( ! isset( $_data->plugin ) ) {
|
341 |
$_data->plugin = $this->name;
|
342 |
}
|
343 |
|
357 |
* @return array
|
358 |
*/
|
359 |
private function convert_object_to_array( $data ) {
|
360 |
+
$new_data = [];
|
361 |
foreach ( $data as $key => $value ) {
|
362 |
$new_data[ $key ] = $value;
|
363 |
}
|
368 |
/**
|
369 |
* Disable SSL verification in order to prevent download update failures
|
370 |
*
|
371 |
+
* @param array $args
|
372 |
+
* @param string $url
|
373 |
* @return object $array
|
374 |
*/
|
375 |
public function http_request_args( $args, $url ) {
|
389 |
* @uses wp_remote_post()
|
390 |
* @uses is_wp_error()
|
391 |
*
|
392 |
+
* @param string $_action The requested action.
|
393 |
+
* @param array $_data Parameters for the API action.
|
394 |
* @return false|object
|
395 |
*/
|
396 |
private function api_request( $_action, $_data ) {
|
404 |
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
|
405 |
$test_url_parts = parse_url( $this->api_url );
|
406 |
|
407 |
+
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
|
408 |
+
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
|
409 |
+
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
|
410 |
|
411 |
if ( empty( $host ) ) {
|
412 |
$edd_plugin_url_available[ $store_hash ] = false;
|
413 |
} else {
|
414 |
+
$test_url = $scheme . '://' . $host . $port;
|
415 |
+
$response = wp_remote_get(
|
416 |
+
$test_url,
|
417 |
+
[
|
418 |
+
'timeout' => $this->health_check_timeout,
|
419 |
+
'sslverify' => $verify_ssl,
|
420 |
+
]
|
421 |
+
);
|
422 |
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
|
423 |
}
|
424 |
}
|
433 |
return;
|
434 |
}
|
435 |
|
436 |
+
if ( $this->api_url == trailingslashit( home_url() ) ) {
|
437 |
return false; // Don't allow a plugin to ping itself
|
438 |
}
|
439 |
|
440 |
+
$api_params = [
|
441 |
'edd_action' => 'get_version',
|
442 |
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
443 |
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
447 |
'author' => $data['author'],
|
448 |
'url' => home_url(),
|
449 |
'beta' => ! empty( $data['beta'] ),
|
450 |
+
];
|
451 |
+
|
452 |
+
$request = wp_remote_post(
|
453 |
+
$this->api_url,
|
454 |
+
[
|
455 |
+
'timeout' => 15,
|
456 |
+
'sslverify' => $verify_ssl,
|
457 |
+
'body' => $api_params,
|
458 |
+
]
|
459 |
);
|
460 |
|
|
|
|
|
461 |
if ( ! is_wp_error( $request ) ) {
|
462 |
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
463 |
}
|
476 |
$request->icons = maybe_unserialize( $request->icons );
|
477 |
}
|
478 |
|
479 |
+
if ( ! empty( $request->sections ) ) {
|
480 |
+
foreach ( $request->sections as $key => $section ) {
|
481 |
$request->$key = (array) $section;
|
482 |
}
|
483 |
}
|
489 |
|
490 |
global $edd_plugin_data;
|
491 |
|
492 |
+
if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
493 |
return;
|
494 |
}
|
495 |
|
496 |
+
if ( empty( $_REQUEST['plugin'] ) ) {
|
497 |
return;
|
498 |
}
|
499 |
|
500 |
+
if ( empty( $_REQUEST['slug'] ) ) {
|
501 |
return;
|
502 |
}
|
503 |
|
504 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
505 |
+
wp_die( __( 'You do not have permission to install plugin updates', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
506 |
}
|
507 |
|
508 |
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
510 |
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
511 |
$version_info = $this->get_cached_version_info( $cache_key );
|
512 |
|
513 |
+
if ( false === $version_info ) {
|
514 |
|
515 |
+
$api_params = [
|
516 |
'edd_action' => 'get_version',
|
517 |
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
518 |
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
519 |
'slug' => $_REQUEST['slug'],
|
520 |
'author' => $data['author'],
|
521 |
'url' => home_url(),
|
522 |
+
'beta' => ! empty( $data['beta'] ),
|
523 |
+
];
|
524 |
|
525 |
$verify_ssl = $this->verify_ssl();
|
526 |
+
$request = wp_remote_post(
|
527 |
+
$this->api_url,
|
528 |
+
[
|
529 |
+
'timeout' => 15,
|
530 |
+
'sslverify' => $verify_ssl,
|
531 |
+
'body' => $api_params,
|
532 |
+
]
|
533 |
+
);
|
534 |
|
535 |
if ( ! is_wp_error( $request ) ) {
|
536 |
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
537 |
}
|
538 |
|
|
|
539 |
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
540 |
$version_info->sections = maybe_unserialize( $version_info->sections );
|
541 |
} else {
|
542 |
$version_info = false;
|
543 |
}
|
544 |
|
545 |
+
if ( ! empty( $version_info ) ) {
|
546 |
+
foreach ( $version_info->sections as $key => $section ) {
|
547 |
$version_info->$key = (array) $section;
|
548 |
}
|
549 |
}
|
552 |
|
553 |
}
|
554 |
|
555 |
+
if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
556 |
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
557 |
}
|
558 |
|
561 |
|
562 |
public function get_cached_version_info( $cache_key = '' ) {
|
563 |
|
564 |
+
if ( empty( $cache_key ) ) {
|
565 |
$cache_key = $this->cache_key;
|
566 |
}
|
567 |
|
568 |
$cache = get_option( $cache_key );
|
569 |
|
570 |
+
if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
|
571 |
return false; // Cache is expired
|
572 |
}
|
573 |
|
583 |
|
584 |
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
585 |
|
586 |
+
if ( empty( $cache_key ) ) {
|
587 |
$cache_key = $this->cache_key;
|
588 |
}
|
589 |
|
590 |
+
$data = [
|
591 |
'timeout' => strtotime( '+3 hours', time() ),
|
592 |
+
'value' => json_encode( $value ),
|
593 |
+
];
|
594 |
|
595 |
update_option( $cache_key, $data, 'no' );
|
596 |
|
classes/GA.php
CHANGED
@@ -9,6 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
|
10 |
/**
|
11 |
* Class PUM_GA
|
|
|
12 |
* @package Ahoy
|
13 |
*/
|
14 |
class PUM_GA {
|
@@ -41,8 +42,12 @@ class PUM_GA {
|
|
41 |
static $cookie = false;
|
42 |
|
43 |
if ( ! $cookie && isset( $_COOKIE['_ga'] ) ) {
|
44 |
-
list( $version, $domainDepth, $cid1, $cid2 ) = preg_split( '[\.]', $_COOKIE[
|
45 |
-
$cookie
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
return $cookie;
|
@@ -52,23 +57,24 @@ class PUM_GA {
|
|
52 |
* Generate UUID v4 function - needed to generate a CID when one isn't available
|
53 |
*/
|
54 |
public static function generate_uuid() {
|
55 |
-
return sprintf(
|
56 |
-
|
57 |
-
|
|
|
58 |
// 16 bits for "time_mid"
|
59 |
mt_rand( 0, 0xffff ),
|
60 |
-
|
61 |
// 16 bits for "time_hi_and_version",
|
62 |
// four most significant bits holds version number 4
|
63 |
mt_rand( 0, 0x0fff ) | 0x4000,
|
64 |
-
|
65 |
// 16 bits, 8 bits for "clk_seq_hi_res",
|
66 |
// 8 bits for "clk_seq_low",
|
67 |
// two most significant bits holds zero and one for variant DCE1.1
|
68 |
mt_rand( 0, 0x3fff ) | 0x8000,
|
69 |
-
|
70 |
// 48 bits for "node"
|
71 |
-
mt_rand( 0, 0xffff ),
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
|
@@ -83,10 +89,10 @@ class PUM_GA {
|
|
83 |
*/
|
84 |
public static function fire_hit( $data = null ) {
|
85 |
if ( $data ) {
|
86 |
-
$getString
|
87 |
$getString .= '?payload_data&';
|
88 |
$getString .= http_build_query( $data );
|
89 |
-
$result
|
90 |
|
91 |
return $result;
|
92 |
}
|
9 |
|
10 |
/**
|
11 |
* Class PUM_GA
|
12 |
+
*
|
13 |
* @package Ahoy
|
14 |
*/
|
15 |
class PUM_GA {
|
42 |
static $cookie = false;
|
43 |
|
44 |
if ( ! $cookie && isset( $_COOKIE['_ga'] ) ) {
|
45 |
+
list( $version, $domainDepth, $cid1, $cid2 ) = preg_split( '[\.]', $_COOKIE['_ga'], 4 );
|
46 |
+
$cookie = [
|
47 |
+
'version' => $version,
|
48 |
+
'domainDepth' => $domainDepth,
|
49 |
+
'cid' => $cid1 . '.' . $cid2,
|
50 |
+
];
|
51 |
}
|
52 |
|
53 |
return $cookie;
|
57 |
* Generate UUID v4 function - needed to generate a CID when one isn't available
|
58 |
*/
|
59 |
public static function generate_uuid() {
|
60 |
+
return sprintf(
|
61 |
+
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low"
|
62 |
+
mt_rand( 0, 0xffff ),
|
63 |
+
mt_rand( 0, 0xffff ),
|
64 |
// 16 bits for "time_mid"
|
65 |
mt_rand( 0, 0xffff ),
|
|
|
66 |
// 16 bits for "time_hi_and_version",
|
67 |
// four most significant bits holds version number 4
|
68 |
mt_rand( 0, 0x0fff ) | 0x4000,
|
|
|
69 |
// 16 bits, 8 bits for "clk_seq_hi_res",
|
70 |
// 8 bits for "clk_seq_low",
|
71 |
// two most significant bits holds zero and one for variant DCE1.1
|
72 |
mt_rand( 0, 0x3fff ) | 0x8000,
|
|
|
73 |
// 48 bits for "node"
|
74 |
+
mt_rand( 0, 0xffff ),
|
75 |
+
mt_rand( 0, 0xffff ),
|
76 |
+
mt_rand( 0, 0xffff )
|
77 |
+
);
|
78 |
}
|
79 |
|
80 |
|
89 |
*/
|
90 |
public static function fire_hit( $data = null ) {
|
91 |
if ( $data ) {
|
92 |
+
$getString = 'https://ssl.google-analytics.com/collect';
|
93 |
$getString .= '?payload_data&';
|
94 |
$getString .= http_build_query( $data );
|
95 |
+
$result = wp_remote_get( $getString );
|
96 |
|
97 |
return $result;
|
98 |
}
|
classes/Helpers.php
CHANGED
@@ -28,15 +28,15 @@ class PUM_Helpers {
|
|
28 |
|
29 |
public static function get_shortcodes_from_content( $content ) {
|
30 |
$pattern = get_shortcode_regex();
|
31 |
-
$shortcodes =
|
32 |
if ( preg_match_all( '/' . $pattern . '/s', $content, $matches ) ) {
|
33 |
foreach ( $matches[0] as $key => $value ) {
|
34 |
-
$shortcodes[ $key ] =
|
35 |
'full_text' => $value,
|
36 |
'tag' => $matches[2][ $key ],
|
37 |
'atts' => shortcode_parse_atts( $matches[3][ $key ] ),
|
38 |
'content' => $matches[5][ $key ],
|
39 |
-
|
40 |
|
41 |
if ( ! empty( $shortcodes[ $key ]['atts'] ) ) {
|
42 |
foreach ( $shortcodes[ $key ]['atts'] as $attr_name => $attr_value ) {
|
@@ -145,7 +145,7 @@ class PUM_Helpers {
|
|
145 |
$upload_dir = $upload_dir['baseurl'];
|
146 |
$upload_dir = preg_replace( '/^https?:/', '', $upload_dir );
|
147 |
|
148 |
-
if ( ! empty
|
149 |
$upload_dir = trailingslashit( $upload_dir ) . $path;
|
150 |
}
|
151 |
|
@@ -171,55 +171,57 @@ class PUM_Helpers {
|
|
171 |
/**
|
172 |
* Sort nested arrays with various options.
|
173 |
*
|
174 |
-
* @param array
|
175 |
* @param string $type
|
176 |
-
* @param bool
|
177 |
*
|
178 |
* @return array
|
179 |
* @deprecated 1.7.20
|
180 |
* @see PUM_Utils_Array::sort instead.
|
181 |
-
*
|
182 |
*/
|
183 |
-
public static function sort_array( $array =
|
184 |
return PUM_Utils_Array::sort( $array, $type, $reverse );
|
185 |
}
|
186 |
|
187 |
-
public static function post_type_selectlist_query( $post_type, $args =
|
188 |
-
|
189 |
-
$args = wp_parse_args(
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
if ( $post_type == 'attachment' ) {
|
203 |
$args['post_status'] = 'inherit';
|
204 |
}
|
205 |
|
206 |
// Query Caching.
|
207 |
-
static $queries =
|
208 |
|
209 |
$key = md5( serialize( $args ) );
|
210 |
|
211 |
if ( ! isset( $queries[ $key ] ) ) {
|
212 |
$query = new WP_Query( $args );
|
213 |
|
214 |
-
$posts =
|
215 |
foreach ( $query->posts as $post ) {
|
216 |
$posts[ $post->ID ] = $post->post_title;
|
217 |
}
|
218 |
|
219 |
-
$results =
|
220 |
'items' => $posts,
|
221 |
'total_count' => $query->found_posts,
|
222 |
-
|
223 |
|
224 |
$queries[ $key ] = $results;
|
225 |
} else {
|
@@ -229,32 +231,35 @@ class PUM_Helpers {
|
|
229 |
return ! $include_total ? $results['items'] : $results;
|
230 |
}
|
231 |
|
232 |
-
public static function taxonomy_selectlist_query( $taxonomies =
|
233 |
-
if ( empty
|
234 |
-
$taxonomies =
|
235 |
}
|
236 |
|
237 |
-
$args = wp_parse_args(
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
246 |
|
247 |
if ( $args['page'] ) {
|
248 |
$args['offset'] = ( $args['page'] - 1 ) * $args['number'];
|
249 |
}
|
250 |
|
251 |
// Query Caching.
|
252 |
-
static $queries =
|
253 |
|
254 |
$key = md5( serialize( $args ) );
|
255 |
|
256 |
if ( ! isset( $queries[ $key ] ) ) {
|
257 |
-
$terms =
|
258 |
|
259 |
foreach ( get_terms( $taxonomies, $args ) as $term ) {
|
260 |
$terms[ $term->term_id ] = $term->name;
|
@@ -264,10 +269,10 @@ class PUM_Helpers {
|
|
264 |
unset( $total_args['number'] );
|
265 |
unset( $total_args['offset'] );
|
266 |
|
267 |
-
$results =
|
268 |
'items' => $terms,
|
269 |
'total_count' => $include_total ? wp_count_terms( $taxonomies, $total_args ) : null,
|
270 |
-
|
271 |
|
272 |
$queries[ $key ] = $results;
|
273 |
} else {
|
@@ -280,35 +285,38 @@ class PUM_Helpers {
|
|
280 |
|
281 |
/**
|
282 |
* @param array $args
|
283 |
-
* @param bool
|
284 |
*
|
285 |
* @return array|mixed
|
286 |
*/
|
287 |
-
public static function user_selectlist_query( $args =
|
288 |
|
289 |
-
$args = wp_parse_args(
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
293 |
|
294 |
// Query Caching.
|
295 |
-
static $queries =
|
296 |
|
297 |
$key = md5( serialize( $args ) );
|
298 |
|
299 |
if ( ! isset( $queries[ $key ] ) ) {
|
300 |
$query = new WP_User_Query( $args );
|
301 |
|
302 |
-
$users =
|
303 |
foreach ( $query->get_results() as $user ) {
|
304 |
/** @var WP_User $user */
|
305 |
$users[ $user->ID ] = $user->display_name;
|
306 |
}
|
307 |
|
308 |
-
$results =
|
309 |
'items' => $users,
|
310 |
'total_count' => $query->get_total(),
|
311 |
-
|
312 |
|
313 |
$queries[ $key ] = $results;
|
314 |
} else {
|
@@ -320,7 +328,7 @@ class PUM_Helpers {
|
|
320 |
|
321 |
public static function popup_theme_selectlist() {
|
322 |
|
323 |
-
$themes =
|
324 |
|
325 |
foreach ( pum_get_all_themes() as $theme ) {
|
326 |
$themes[ $theme->ID ] = $theme->post_title;
|
@@ -330,8 +338,8 @@ class PUM_Helpers {
|
|
330 |
|
331 |
}
|
332 |
|
333 |
-
public static function popup_selectlist( $args =
|
334 |
-
$popup_list =
|
335 |
|
336 |
$popups = pum_get_all_popups( $args );
|
337 |
|
28 |
|
29 |
public static function get_shortcodes_from_content( $content ) {
|
30 |
$pattern = get_shortcode_regex();
|
31 |
+
$shortcodes = [];
|
32 |
if ( preg_match_all( '/' . $pattern . '/s', $content, $matches ) ) {
|
33 |
foreach ( $matches[0] as $key => $value ) {
|
34 |
+
$shortcodes[ $key ] = [
|
35 |
'full_text' => $value,
|
36 |
'tag' => $matches[2][ $key ],
|
37 |
'atts' => shortcode_parse_atts( $matches[3][ $key ] ),
|
38 |
'content' => $matches[5][ $key ],
|
39 |
+
];
|
40 |
|
41 |
if ( ! empty( $shortcodes[ $key ]['atts'] ) ) {
|
42 |
foreach ( $shortcodes[ $key ]['atts'] as $attr_name => $attr_value ) {
|
145 |
$upload_dir = $upload_dir['baseurl'];
|
146 |
$upload_dir = preg_replace( '/^https?:/', '', $upload_dir );
|
147 |
|
148 |
+
if ( ! empty( $path ) ) {
|
149 |
$upload_dir = trailingslashit( $upload_dir ) . $path;
|
150 |
}
|
151 |
|
171 |
/**
|
172 |
* Sort nested arrays with various options.
|
173 |
*
|
174 |
+
* @param array $array
|
175 |
* @param string $type
|
176 |
+
* @param bool $reverse
|
177 |
*
|
178 |
* @return array
|
179 |
* @deprecated 1.7.20
|
180 |
* @see PUM_Utils_Array::sort instead.
|
|
|
181 |
*/
|
182 |
+
public static function sort_array( $array = [], $type = 'key', $reverse = false ) {
|
183 |
return PUM_Utils_Array::sort( $array, $type, $reverse );
|
184 |
}
|
185 |
|
186 |
+
public static function post_type_selectlist_query( $post_type, $args = [], $include_total = false ) {
|
187 |
+
|
188 |
+
$args = wp_parse_args(
|
189 |
+
$args,
|
190 |
+
[
|
191 |
+
'posts_per_page' => 10,
|
192 |
+
'post_type' => $post_type,
|
193 |
+
'post__in' => null,
|
194 |
+
'post__not_in' => null,
|
195 |
+
'post_status' => null,
|
196 |
+
'page' => 1,
|
197 |
+
// Performance Optimization.
|
198 |
+
'no_found_rows' => ! $include_total ? true : false,
|
199 |
+
'update_post_term_cache' => false,
|
200 |
+
'update_post_meta_cache' => false,
|
201 |
+
]
|
202 |
+
);
|
203 |
|
204 |
if ( $post_type == 'attachment' ) {
|
205 |
$args['post_status'] = 'inherit';
|
206 |
}
|
207 |
|
208 |
// Query Caching.
|
209 |
+
static $queries = [];
|
210 |
|
211 |
$key = md5( serialize( $args ) );
|
212 |
|
213 |
if ( ! isset( $queries[ $key ] ) ) {
|
214 |
$query = new WP_Query( $args );
|
215 |
|
216 |
+
$posts = [];
|
217 |
foreach ( $query->posts as $post ) {
|
218 |
$posts[ $post->ID ] = $post->post_title;
|
219 |
}
|
220 |
|
221 |
+
$results = [
|
222 |
'items' => $posts,
|
223 |
'total_count' => $query->found_posts,
|
224 |
+
];
|
225 |
|
226 |
$queries[ $key ] = $results;
|
227 |
} else {
|
231 |
return ! $include_total ? $results['items'] : $results;
|
232 |
}
|
233 |
|
234 |
+
public static function taxonomy_selectlist_query( $taxonomies = [], $args = [], $include_total = false ) {
|
235 |
+
if ( empty( $taxonomies ) ) {
|
236 |
+
$taxonomies = [ 'category' ];
|
237 |
}
|
238 |
|
239 |
+
$args = wp_parse_args(
|
240 |
+
$args,
|
241 |
+
[
|
242 |
+
'hide_empty' => false,
|
243 |
+
'number' => 10,
|
244 |
+
'search' => '',
|
245 |
+
'include' => null,
|
246 |
+
'exclude' => null,
|
247 |
+
'offset' => 0,
|
248 |
+
'page' => null,
|
249 |
+
]
|
250 |
+
);
|
251 |
|
252 |
if ( $args['page'] ) {
|
253 |
$args['offset'] = ( $args['page'] - 1 ) * $args['number'];
|
254 |
}
|
255 |
|
256 |
// Query Caching.
|
257 |
+
static $queries = [];
|
258 |
|
259 |
$key = md5( serialize( $args ) );
|
260 |
|
261 |
if ( ! isset( $queries[ $key ] ) ) {
|
262 |
+
$terms = [];
|
263 |
|
264 |
foreach ( get_terms( $taxonomies, $args ) as $term ) {
|
265 |
$terms[ $term->term_id ] = $term->name;
|
269 |
unset( $total_args['number'] );
|
270 |
unset( $total_args['offset'] );
|
271 |
|
272 |
+
$results = [
|
273 |
'items' => $terms,
|
274 |
'total_count' => $include_total ? wp_count_terms( $taxonomies, $total_args ) : null,
|
275 |
+
];
|
276 |
|
277 |
$queries[ $key ] = $results;
|
278 |
} else {
|
285 |
|
286 |
/**
|
287 |
* @param array $args
|
288 |
+
* @param bool $include_total
|
289 |
*
|
290 |
* @return array|mixed
|
291 |
*/
|
292 |
+
public static function user_selectlist_query( $args = [], $include_total = false ) {
|
293 |
|
294 |
+
$args = wp_parse_args(
|
295 |
+
$args,
|
296 |
+
[
|
297 |
+
'role' => null,
|
298 |
+
'count_total' => ! $include_total ? true : false,
|
299 |
+
]
|
300 |
+
);
|
301 |
|
302 |
// Query Caching.
|
303 |
+
static $queries = [];
|
304 |
|
305 |
$key = md5( serialize( $args ) );
|
306 |
|
307 |
if ( ! isset( $queries[ $key ] ) ) {
|
308 |
$query = new WP_User_Query( $args );
|
309 |
|
310 |
+
$users = [];
|
311 |
foreach ( $query->get_results() as $user ) {
|
312 |
/** @var WP_User $user */
|
313 |
$users[ $user->ID ] = $user->display_name;
|
314 |
}
|
315 |
|
316 |
+
$results = [
|
317 |
'items' => $users,
|
318 |
'total_count' => $query->get_total(),
|
319 |
+
];
|
320 |
|
321 |
$queries[ $key ] = $results;
|
322 |
} else {
|
328 |
|
329 |
public static function popup_theme_selectlist() {
|
330 |
|
331 |
+
$themes = [];
|
332 |
|
333 |
foreach ( pum_get_all_themes() as $theme ) {
|
334 |
$themes[ $theme->ID ] = $theme->post_title;
|
338 |
|
339 |
}
|
340 |
|
341 |
+
public static function popup_selectlist( $args = [] ) {
|
342 |
+
$popup_list = [];
|
343 |
|
344 |
$popups = pum_get_all_popups( $args );
|
345 |
|
classes/Install.php
CHANGED
@@ -19,7 +19,7 @@ class PUM_Install {
|
|
19 |
* @param $network_wide
|
20 |
*/
|
21 |
public static function activate_plugin( $network_wide ) {
|
22 |
-
self::do_multisite( $network_wide,
|
23 |
}
|
24 |
|
25 |
/**
|
@@ -33,20 +33,20 @@ class PUM_Install {
|
|
33 |
*
|
34 |
*/
|
35 |
public static function uninstall_plugin() {
|
36 |
-
self::do_multisite( true,
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
* @param $network_wide
|
41 |
* @param $method
|
42 |
-
* @param array
|
43 |
*/
|
44 |
-
private static function do_multisite( $network_wide, $method, $args =
|
45 |
global $wpdb;
|
46 |
|
47 |
if ( is_multisite() && $network_wide ) {
|
48 |
|
49 |
-
$activated = get_site_option( 'pum_activated',
|
50 |
|
51 |
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
|
52 |
|
@@ -62,7 +62,7 @@ class PUM_Install {
|
|
62 |
|
63 |
foreach ( $blog_ids as $blog_id ) {
|
64 |
switch_to_blog( $blog_id );
|
65 |
-
call_user_func_array( $method,
|
66 |
|
67 |
$activated[] = $blog_id;
|
68 |
|
@@ -71,9 +71,8 @@ class PUM_Install {
|
|
71 |
|
72 |
update_site_option( 'pum_activated', $activated );
|
73 |
|
74 |
-
|
75 |
} else {
|
76 |
-
call_user_func_array( $method,
|
77 |
}
|
78 |
}
|
79 |
|
@@ -84,10 +83,10 @@ class PUM_Install {
|
|
84 |
|
85 |
// Add default values where needed.
|
86 |
$options = array_merge(
|
87 |
-
get_option( 'popmake_settings',
|
88 |
-
|
89 |
'disable_popup_category_tag' => 1,
|
90 |
-
|
91 |
);
|
92 |
|
93 |
// Setup some default options.
|
@@ -150,12 +149,12 @@ class PUM_Install {
|
|
150 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'popup_%'" );
|
151 |
|
152 |
/** Delete All the Taxonomies */
|
153 |
-
foreach (
|
154 |
// Prepare & excecute SQL, Delete Terms.
|
155 |
$wpdb->get_results( $wpdb->prepare( "DELETE t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s')", $taxonomy ) );
|
156 |
|
157 |
// Delete Taxonomy.
|
158 |
-
$wpdb->delete( $wpdb->term_taxonomy,
|
159 |
}
|
160 |
|
161 |
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'popmake%' OR option_name LIKE '_pum_%' OR option_name LIKE 'pum_%' OR option_name LIKE 'popup_analytics_%'" );
|
@@ -222,7 +221,7 @@ class PUM_Install {
|
|
222 |
$flag = self::get_activation_flag();
|
223 |
$version = 'PHP' == $flag ? Popup_Maker::$MIN_PHP_VER : Popup_Maker::$MIN_WP_VER;
|
224 |
|
225 |
-
return sprintf( __( 'The %4$s %1$s %5$s plugin requires %2$s version %3$s or greater.', 'popup-maker' ), Popup_Maker::$NAME, $flag, $version,
|
226 |
}
|
227 |
|
228 |
/**
|
@@ -251,10 +250,14 @@ class PUM_Install {
|
|
251 |
|
252 |
$notice = self::get_activation_failure_notice();
|
253 |
|
254 |
-
wp_die(
|
255 |
-
|
256 |
-
'
|
257 |
-
|
|
|
|
|
|
|
|
|
258 |
}
|
259 |
|
260 |
}
|
19 |
* @param $network_wide
|
20 |
*/
|
21 |
public static function activate_plugin( $network_wide ) {
|
22 |
+
self::do_multisite( $network_wide, [ __CLASS__, 'activate_site' ] );
|
23 |
}
|
24 |
|
25 |
/**
|
33 |
*
|
34 |
*/
|
35 |
public static function uninstall_plugin() {
|
36 |
+
self::do_multisite( true, [ __CLASS__, 'uninstall_site' ] );
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
* @param $network_wide
|
41 |
* @param $method
|
42 |
+
* @param array $args
|
43 |
*/
|
44 |
+
private static function do_multisite( $network_wide, $method, $args = [] ) {
|
45 |
global $wpdb;
|
46 |
|
47 |
if ( is_multisite() && $network_wide ) {
|
48 |
|
49 |
+
$activated = get_site_option( 'pum_activated', [] );
|
50 |
|
51 |
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
|
52 |
|
62 |
|
63 |
foreach ( $blog_ids as $blog_id ) {
|
64 |
switch_to_blog( $blog_id );
|
65 |
+
call_user_func_array( $method, [ $args ] );
|
66 |
|
67 |
$activated[] = $blog_id;
|
68 |
|
71 |
|
72 |
update_site_option( 'pum_activated', $activated );
|
73 |
|
|
|
74 |
} else {
|
75 |
+
call_user_func_array( $method, [ $args ] );
|
76 |
}
|
77 |
}
|
78 |
|
83 |
|
84 |
// Add default values where needed.
|
85 |
$options = array_merge(
|
86 |
+
get_option( 'popmake_settings', [] ),
|
87 |
+
[
|
88 |
'disable_popup_category_tag' => 1,
|
89 |
+
]
|
90 |
);
|
91 |
|
92 |
// Setup some default options.
|
149 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'popup_%'" );
|
150 |
|
151 |
/** Delete All the Taxonomies */
|
152 |
+
foreach ( [ 'popup_category', 'popup_tag' ] as $taxonomy ) {
|
153 |
// Prepare & excecute SQL, Delete Terms.
|
154 |
$wpdb->get_results( $wpdb->prepare( "DELETE t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s')", $taxonomy ) );
|
155 |
|
156 |
// Delete Taxonomy.
|
157 |
+
$wpdb->delete( $wpdb->term_taxonomy, [ 'taxonomy' => $taxonomy ], [ '%s' ] );
|
158 |
}
|
159 |
|
160 |
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'popmake%' OR option_name LIKE '_pum_%' OR option_name LIKE 'pum_%' OR option_name LIKE 'popup_analytics_%'" );
|
221 |
$flag = self::get_activation_flag();
|
222 |
$version = 'PHP' == $flag ? Popup_Maker::$MIN_PHP_VER : Popup_Maker::$MIN_WP_VER;
|
223 |
|
224 |
+
return sprintf( __( 'The %4$s %1$s %5$s plugin requires %2$s version %3$s or greater.', 'popup-maker' ), Popup_Maker::$NAME, $flag, $version, '<strong>', '</strong>' );
|
225 |
}
|
226 |
|
227 |
/**
|
250 |
|
251 |
$notice = self::get_activation_failure_notice();
|
252 |
|
253 |
+
wp_die(
|
254 |
+
"<p>$notice</p>",
|
255 |
+
__( 'Plugin Activation Error', 'popup-maker' ),
|
256 |
+
[
|
257 |
+
'response' => 200,
|
258 |
+
'back_link' => true,
|
259 |
+
]
|
260 |
+
);
|
261 |
}
|
262 |
|
263 |
}
|
classes/Integration/Form/CalderaForms.php
CHANGED
@@ -11,7 +11,7 @@ class PUM_Integration_Form_CalderaForms extends PUM_Abstract_Integration_Form {
|
|
11 |
public $key = 'calderaforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
-
add_action( 'caldera_forms_submit_complete',
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -69,11 +69,13 @@ class PUM_Integration_Form_CalderaForms extends PUM_Abstract_Integration_Form {
|
|
69 |
$popup_id = self::get_popup_id();
|
70 |
self::increase_conversion( $popup_id );
|
71 |
|
72 |
-
pum_integrated_form_submission(
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
11 |
public $key = 'calderaforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
+
add_action( 'caldera_forms_submit_complete', [ $this, 'on_success' ] );
|
15 |
}
|
16 |
|
17 |
/**
|
69 |
$popup_id = self::get_popup_id();
|
70 |
self::increase_conversion( $popup_id );
|
71 |
|
72 |
+
pum_integrated_form_submission(
|
73 |
+
[
|
74 |
+
'popup_id' => $popup_id,
|
75 |
+
'form_provider' => $this->key,
|
76 |
+
'form_id' => $form['ID'],
|
77 |
+
]
|
78 |
+
);
|
79 |
}
|
80 |
|
81 |
/**
|
classes/Integration/Form/ContactForm7.php
CHANGED
@@ -18,7 +18,7 @@ class PUM_Integration_Form_ContactForm7 extends PUM_Abstract_Integration_Form {
|
|
18 |
* Could be used for other initiations as well where needed.
|
19 |
*/
|
20 |
public function __construct() {
|
21 |
-
add_action( 'wpcf7_mail_sent',
|
22 |
}
|
23 |
|
24 |
/**
|
@@ -45,10 +45,12 @@ class PUM_Integration_Form_ContactForm7 extends PUM_Abstract_Integration_Form {
|
|
45 |
* @return array
|
46 |
*/
|
47 |
public function get_forms() {
|
48 |
-
return get_posts(
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
@@ -94,11 +96,13 @@ class PUM_Integration_Form_ContactForm7 extends PUM_Abstract_Integration_Form {
|
|
94 |
$popup_id = self::get_popup_id();
|
95 |
self::increase_conversion( $popup_id );
|
96 |
|
97 |
-
pum_integrated_form_submission(
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
}
|
103 |
|
104 |
/**
|
18 |
* Could be used for other initiations as well where needed.
|
19 |
*/
|
20 |
public function __construct() {
|
21 |
+
add_action( 'wpcf7_mail_sent', [ $this, 'on_success' ], 1 );
|
22 |
}
|
23 |
|
24 |
/**
|
45 |
* @return array
|
46 |
*/
|
47 |
public function get_forms() {
|
48 |
+
return get_posts(
|
49 |
+
[
|
50 |
+
'post_type' => 'wpcf7_contact_form',
|
51 |
+
'posts_per_page' => - 1,
|
52 |
+
]
|
53 |
+
);
|
54 |
}
|
55 |
|
56 |
/**
|
96 |
$popup_id = self::get_popup_id();
|
97 |
self::increase_conversion( $popup_id );
|
98 |
|
99 |
+
pum_integrated_form_submission(
|
100 |
+
[
|
101 |
+
'popup_id' => $popup_id,
|
102 |
+
'form_provider' => $this->key,
|
103 |
+
'form_id' => $cfdata->id(),
|
104 |
+
]
|
105 |
+
);
|
106 |
}
|
107 |
|
108 |
/**
|
classes/Integration/Form/FormidableForms.php
CHANGED
@@ -23,7 +23,7 @@ class PUM_Integration_Form_FormidableForms extends PUM_Abstract_Integration_Form
|
|
23 |
* Could be used for other initiations as well where needed.
|
24 |
*/
|
25 |
public function __construct() {
|
26 |
-
add_action( 'frm_after_create_entry',
|
27 |
}
|
28 |
|
29 |
/**
|
23 |
* Could be used for other initiations as well where needed.
|
24 |
*/
|
25 |
public function __construct() {
|
26 |
+
add_action( 'frm_after_create_entry', [ $this, 'on_success' ], 1, 2 );
|
27 |
}
|
28 |
|
29 |
/**
|
classes/Integration/Form/GravityForms.php
CHANGED
@@ -11,7 +11,7 @@ class PUM_Integration_Form_GravityForms extends PUM_Abstract_Integration_Form {
|
|
11 |
public $key = 'gravityforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
-
add_action( 'gform_after_submission',
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -77,11 +77,13 @@ class PUM_Integration_Form_GravityForms extends PUM_Abstract_Integration_Form {
|
|
77 |
$popup_id = self::get_popup_id();
|
78 |
self::increase_conversion( $popup_id );
|
79 |
|
80 |
-
pum_integrated_form_submission(
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
}
|
86 |
|
87 |
/**
|
11 |
public $key = 'gravityforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
+
add_action( 'gform_after_submission', [ $this, 'on_success' ], 10, 2 );
|
15 |
}
|
16 |
|
17 |
/**
|
77 |
$popup_id = self::get_popup_id();
|
78 |
self::increase_conversion( $popup_id );
|
79 |
|
80 |
+
pum_integrated_form_submission(
|
81 |
+
[
|
82 |
+
'popup_id' => $popup_id,
|
83 |
+
'form_provider' => $this->key,
|
84 |
+
'form_id' => $form['id'],
|
85 |
+
]
|
86 |
+
);
|
87 |
}
|
88 |
|
89 |
/**
|
classes/Integration/Form/NinjaForms.php
CHANGED
@@ -11,8 +11,8 @@ class PUM_Integration_Form_NinjaForms extends PUM_Abstract_Integration_Form {
|
|
11 |
public $key = 'ninjaforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
-
add_action( 'ninja_forms_pre_process',
|
15 |
-
add_action( 'ninja_forms_after_submission',
|
16 |
}
|
17 |
|
18 |
/**
|
@@ -72,11 +72,13 @@ class PUM_Integration_Form_NinjaForms extends PUM_Abstract_Integration_Form {
|
|
72 |
$popup_id = self::get_popup_id();
|
73 |
self::increase_conversion( $popup_id );
|
74 |
|
75 |
-
pum_integrated_form_submission(
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
}
|
81 |
|
82 |
/**
|
@@ -88,11 +90,13 @@ class PUM_Integration_Form_NinjaForms extends PUM_Abstract_Integration_Form {
|
|
88 |
}
|
89 |
$popup_id = self::get_popup_id();
|
90 |
self::increase_conversion( $popup_id );
|
91 |
-
pum_integrated_form_submission(
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
}
|
97 |
|
98 |
/**
|
11 |
public $key = 'ninjaforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
+
add_action( 'ninja_forms_pre_process', [ $this, 'on_success_v2' ] );
|
15 |
+
add_action( 'ninja_forms_after_submission', [ $this, 'on_success_v3' ] );
|
16 |
}
|
17 |
|
18 |
/**
|
72 |
$popup_id = self::get_popup_id();
|
73 |
self::increase_conversion( $popup_id );
|
74 |
|
75 |
+
pum_integrated_form_submission(
|
76 |
+
[
|
77 |
+
'popup_id' => $popup_id,
|
78 |
+
'form_provider' => $this->key,
|
79 |
+
'form_id' => $ninja_forms_processing->get_form_ID(),
|
80 |
+
]
|
81 |
+
);
|
82 |
}
|
83 |
|
84 |
/**
|
90 |
}
|
91 |
$popup_id = self::get_popup_id();
|
92 |
self::increase_conversion( $popup_id );
|
93 |
+
pum_integrated_form_submission(
|
94 |
+
[
|
95 |
+
'popup_id' => $popup_id,
|
96 |
+
'form_provider' => $this->key,
|
97 |
+
'form_id' => $form_data['form_id'],
|
98 |
+
]
|
99 |
+
);
|
100 |
}
|
101 |
|
102 |
/**
|
classes/Integration/Form/PirateForms.php
CHANGED
@@ -54,10 +54,10 @@ class PUM_Integration_Form_PirateForms extends PUM_Abstract_Integration_Form {
|
|
54 |
|
55 |
// Just make sure that it's there and not broken.
|
56 |
if ( empty( $form ) ) {
|
57 |
-
return
|
58 |
}
|
59 |
|
60 |
-
return
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -69,15 +69,15 @@ class PUM_Integration_Form_PirateForms extends PUM_Abstract_Integration_Form {
|
|
69 |
*/
|
70 |
protected function get_pro_forms() {
|
71 |
|
72 |
-
$forms =
|
73 |
$query = new WP_Query(
|
74 |
-
|
75 |
'post_type' => 'pf_form',
|
76 |
'post_status' => 'publish',
|
77 |
'posts_per_page' => - 1,
|
78 |
'update_post_meta_cache' => false,
|
79 |
'update_post_term_cache' => false,
|
80 |
-
|
81 |
);
|
82 |
|
83 |
if ( $query->have_posts() ) {
|
@@ -124,7 +124,7 @@ class PUM_Integration_Form_PirateForms extends PUM_Abstract_Integration_Form {
|
|
124 |
* @param array $fields Sanitized entry field values/properties.
|
125 |
* @param array $entry Original $_POST global.
|
126 |
* @param array $form_data Form data and settings.
|
127 |
-
* @param int
|
128 |
*/
|
129 |
public function on_success( $fields, $entry, $form_data, $entry_id ) {
|
130 |
if ( ! self::should_process_submission() ) {
|
@@ -132,11 +132,13 @@ class PUM_Integration_Form_PirateForms extends PUM_Abstract_Integration_Form {
|
|
132 |
}
|
133 |
$popup_id = self::get_popup_id();
|
134 |
self::increase_conversion( $popup_id );
|
135 |
-
pum_integrated_form_submission(
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
140 |
}
|
141 |
|
142 |
/**
|
54 |
|
55 |
// Just make sure that it's there and not broken.
|
56 |
if ( empty( $form ) ) {
|
57 |
+
return [];
|
58 |
}
|
59 |
|
60 |
+
return [ 0 => esc_html__( 'Default Form', 'wpforms-lite' ) ];
|
61 |
}
|
62 |
|
63 |
/**
|
69 |
*/
|
70 |
protected function get_pro_forms() {
|
71 |
|
72 |
+
$forms = [];
|
73 |
$query = new WP_Query(
|
74 |
+
[
|
75 |
'post_type' => 'pf_form',
|
76 |
'post_status' => 'publish',
|
77 |
'posts_per_page' => - 1,
|
78 |
'update_post_meta_cache' => false,
|
79 |
'update_post_term_cache' => false,
|
80 |
+
]
|
81 |
);
|
82 |
|
83 |
if ( $query->have_posts() ) {
|
124 |
* @param array $fields Sanitized entry field values/properties.
|
125 |
* @param array $entry Original $_POST global.
|
126 |
* @param array $form_data Form data and settings.
|
127 |
+
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
|
128 |
*/
|
129 |
public function on_success( $fields, $entry, $form_data, $entry_id ) {
|
130 |
if ( ! self::should_process_submission() ) {
|
132 |
}
|
133 |
$popup_id = self::get_popup_id();
|
134 |
self::increase_conversion( $popup_id );
|
135 |
+
pum_integrated_form_submission(
|
136 |
+
[
|
137 |
+
'popup_id' => $popup_id,
|
138 |
+
'form_provider' => $this->key,
|
139 |
+
'form_id' => $form_data['id'],
|
140 |
+
]
|
141 |
+
);
|
142 |
}
|
143 |
|
144 |
/**
|
classes/Integration/Form/WPForms.php
CHANGED
@@ -11,7 +11,7 @@ class PUM_Integration_Form_WPForms extends PUM_Abstract_Integration_Form {
|
|
11 |
public $key = 'wpforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
-
add_action( 'wpforms_process_complete',
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -67,7 +67,7 @@ class PUM_Integration_Form_WPForms extends PUM_Abstract_Integration_Form {
|
|
67 |
* @param array $fields Sanitized entry field values/properties.
|
68 |
* @param array $entry Original $_POST global.
|
69 |
* @param array $form_data Form data and settings.
|
70 |
-
* @param int
|
71 |
*/
|
72 |
public function on_success( $fields, $entry, $form_data, $entry_id ) {
|
73 |
if ( ! self::should_process_submission() ) {
|
@@ -75,11 +75,13 @@ class PUM_Integration_Form_WPForms extends PUM_Abstract_Integration_Form {
|
|
75 |
}
|
76 |
$popup_id = self::get_popup_id();
|
77 |
self::increase_conversion( $popup_id );
|
78 |
-
pum_integrated_form_submission(
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -97,10 +99,10 @@ class PUM_Integration_Form_WPForms extends PUM_Abstract_Integration_Form {
|
|
97 |
* @return array
|
98 |
*/
|
99 |
public function custom_styles( $css = [] ) {
|
100 |
-
//
|
101 |
-
//
|
102 |
-
//
|
103 |
-
//
|
104 |
|
105 |
return $css;
|
106 |
}
|
11 |
public $key = 'wpforms';
|
12 |
|
13 |
public function __construct() {
|
14 |
+
add_action( 'wpforms_process_complete', [ $this, 'on_success' ], 10, 4 );
|
15 |
}
|
16 |
|
17 |
/**
|
67 |
* @param array $fields Sanitized entry field values/properties.
|
68 |
* @param array $entry Original $_POST global.
|
69 |
* @param array $form_data Form data and settings.
|
70 |
+
* @param int $entry_id Entry ID. Will return 0 if entry storage is disabled or using WPForms Lite.
|
71 |
*/
|
72 |
public function on_success( $fields, $entry, $form_data, $entry_id ) {
|
73 |
if ( ! self::should_process_submission() ) {
|
75 |
}
|
76 |
$popup_id = self::get_popup_id();
|
77 |
self::increase_conversion( $popup_id );
|
78 |
+
pum_integrated_form_submission(
|
79 |
+
[
|
80 |
+
'popup_id' => $popup_id,
|
81 |
+
'form_provider' => $this->key,
|
82 |
+
'form_id' => $form_data['id'],
|
83 |
+
]
|
84 |
+
);
|
85 |
}
|
86 |
|
87 |
/**
|
99 |
* @return array
|
100 |
*/
|
101 |
public function custom_styles( $css = [] ) {
|
102 |
+
// $css[ $this->key ] = [
|
103 |
+
// 'content' => ".pac-container { z-index: 2000000000 !important; }\n",
|
104 |
+
// 'priority' => 8,
|
105 |
+
// ];
|
106 |
|
107 |
return $css;
|
108 |
}
|
classes/Integration/GoogleFonts.php
CHANGED
@@ -22,7 +22,7 @@ class PUM_Integration_GoogleFonts {
|
|
22 |
// Set the API key based on options first then default second.
|
23 |
self::$api_key = pum_get_option( 'google_fonts_api_key', self::$default_api_key );
|
24 |
|
25 |
-
add_filter( 'pum_theme_font_family_options',
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -49,7 +49,7 @@ class PUM_Integration_GoogleFonts {
|
|
49 |
}
|
50 |
|
51 |
$google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . self::$api_key . '&sort=' . $sort;
|
52 |
-
$response = wp_remote_retrieve_body( wp_remote_get( $google_api_url,
|
53 |
|
54 |
if ( ! is_wp_error( $response ) ) {
|
55 |
$data = json_decode( $response, true );
|
@@ -65,7 +65,7 @@ class PUM_Integration_GoogleFonts {
|
|
65 |
}
|
66 |
|
67 |
$items = $data['items'];
|
68 |
-
$font_list =
|
69 |
|
70 |
if ( count( $items ) ) {
|
71 |
foreach ( $items as $item ) {
|
@@ -92,21 +92,19 @@ class PUM_Integration_GoogleFonts {
|
|
92 |
return $options;
|
93 |
}
|
94 |
|
95 |
-
$new_options =
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
//
|
100 |
-
// '' => __( 'Google Web Fonts', 'popup-maker' ) . ' ⤵',
|
101 |
-
// ) );
|
102 |
|
103 |
foreach ( $font_list as $font_family => $font ) {
|
104 |
$new_options[ $font_family ] = $font_family;
|
105 |
}
|
106 |
|
107 |
-
$options[__( 'Google Web Fonts', 'popup-maker' )] = $new_options;
|
108 |
|
109 |
return $options;
|
110 |
}
|
111 |
|
112 |
-
}
|
22 |
// Set the API key based on options first then default second.
|
23 |
self::$api_key = pum_get_option( 'google_fonts_api_key', self::$default_api_key );
|
24 |
|
25 |
+
add_filter( 'pum_theme_font_family_options', [ __CLASS__, 'font_family_options' ], 20 );
|
26 |
}
|
27 |
|
28 |
/**
|
49 |
}
|
50 |
|
51 |
$google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' . self::$api_key . '&sort=' . $sort;
|
52 |
+
$response = wp_remote_retrieve_body( wp_remote_get( $google_api_url, [ 'sslverify' => false ] ) );
|
53 |
|
54 |
if ( ! is_wp_error( $response ) ) {
|
55 |
$data = json_decode( $response, true );
|
65 |
}
|
66 |
|
67 |
$items = $data['items'];
|
68 |
+
$font_list = [];
|
69 |
|
70 |
if ( count( $items ) ) {
|
71 |
foreach ( $items as $item ) {
|
92 |
return $options;
|
93 |
}
|
94 |
|
95 |
+
$new_options = [];
|
96 |
|
97 |
+
// $options = array_merge( $options, array(
|
98 |
+
// '' => __( 'Google Web Fonts', 'popup-maker' ) . ' ⤵',
|
99 |
+
// ) );
|
|
|
|
|
100 |
|
101 |
foreach ( $font_list as $font_family => $font ) {
|
102 |
$new_options[ $font_family ] = $font_family;
|
103 |
}
|
104 |
|
105 |
+
$options[ __( 'Google Web Fonts', 'popup-maker' ) ] = $new_options;
|
106 |
|
107 |
return $options;
|
108 |
}
|
109 |
|
110 |
+
}
|
classes/Integrations.php
CHANGED
@@ -15,7 +15,7 @@ class PUM_Integrations {
|
|
15 |
/**
|
16 |
* @var PUM_Abstract_Integration[]|PUM_Abstract_Integration_Form[]
|
17 |
*/
|
18 |
-
public static $integrations =
|
19 |
|
20 |
/**
|
21 |
* @var bool
|
@@ -49,18 +49,18 @@ class PUM_Integrations {
|
|
49 |
|
50 |
self::$preload_posts = isset( $_GET['page'] ) && $_GET['page'] == 'pum-settings';
|
51 |
|
52 |
-
add_filter( 'pum_settings_fields',
|
53 |
-
add_action( 'pum_preload_popup',
|
54 |
-
add_filter( 'pum_registered_conditions',
|
55 |
|
56 |
-
add_filter( 'pum_vars',
|
57 |
|
58 |
-
add_action( 'init',
|
59 |
-
add_action( 'admin_init',
|
60 |
-
add_filter( 'pum_popup_post_type_args',
|
61 |
-
add_filter( 'pum_generated_js',
|
62 |
-
add_filter( 'pum_generated_css',
|
63 |
-
add_filter( 'pum_popup_settings',
|
64 |
|
65 |
PUM_Integration_GoogleFonts::init();
|
66 |
}
|
@@ -170,7 +170,7 @@ class PUM_Integrations {
|
|
170 |
*
|
171 |
* @return array
|
172 |
*/
|
173 |
-
public static function settings_fields( $fields =
|
174 |
|
175 |
foreach ( self::$integrations as $key => $integration ) {
|
176 |
if ( ! ( $integration instanceof PUM_Interface_Integration_Settings ) || ! $integration->enabled() ) {
|
@@ -196,10 +196,9 @@ class PUM_Integrations {
|
|
196 |
}
|
197 |
|
198 |
// Do stuff here.
|
199 |
-
|
200 |
}
|
201 |
|
202 |
-
public static function register_conditions( $conditions =
|
203 |
|
204 |
foreach ( self::$integrations as $key => $enabled ) {
|
205 |
if ( ! $enabled ) {
|
@@ -208,7 +207,6 @@ class PUM_Integrations {
|
|
208 |
|
209 |
switch ( $key ) {
|
210 |
|
211 |
-
|
212 |
}
|
213 |
}
|
214 |
|
@@ -233,10 +231,13 @@ class PUM_Integrations {
|
|
233 |
* Runs during admin_init
|
234 |
*/
|
235 |
public static function admin_init() {
|
236 |
-
if ( ! self::enabled( 'visualcomposer' ) && ( is_admin() && isset( $_GET['page'] ) && in_array(
|
237 |
-
|
238 |
-
|
239 |
-
|
|
|
|
|
|
|
240 |
add_filter( 'vc_role_access_with_post_types_get_state', '__return_true' );
|
241 |
add_filter( 'vc_role_access_with_backend_editor_get_state', '__return_true' );
|
242 |
add_filter( 'vc_role_access_with_frontend_editor_get_state', '__return_false' );
|
@@ -244,27 +245,36 @@ class PUM_Integrations {
|
|
244 |
}
|
245 |
}
|
246 |
|
247 |
-
public static function popup_post_type_args( $args =
|
248 |
|
249 |
if ( self::enabled( 'kingcomposer' ) && ( ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == 'kingcomposer' ) || pum_is_popup_editor() ) ) {
|
250 |
-
$args = array_merge(
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
|
|
|
|
|
|
256 |
}
|
257 |
|
258 |
-
if ( self::enabled( 'visualcomposer' ) && ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ( ( isset( $_GET['page'] ) && in_array(
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
return $args;
|
@@ -292,7 +302,7 @@ class PUM_Integrations {
|
|
292 |
*
|
293 |
* @return array $css
|
294 |
*/
|
295 |
-
public static function generated_css( $css =
|
296 |
|
297 |
foreach ( self::$integrations as $integration ) {
|
298 |
if ( $integration->enabled() && method_exists( $integration, 'custom_styles' ) ) {
|
@@ -307,7 +317,7 @@ class PUM_Integrations {
|
|
307 |
* Modify popup settings.
|
308 |
*
|
309 |
* @param array $settings
|
310 |
-
* @param int
|
311 |
*
|
312 |
* @return array
|
313 |
*/
|
@@ -340,7 +350,7 @@ class PUM_Integrations {
|
|
340 |
* If submission exists for this popup remove auto open triggers and add an admin_debug trigger to reshow the popup.
|
341 |
*/
|
342 |
if ( ! in_array( false, $should_reopen ) ) {
|
343 |
-
$triggers = ! empty( $settings['triggers'] ) ? $settings['triggers'] :
|
344 |
|
345 |
foreach ( $triggers as $key => $trigger ) {
|
346 |
if ( $trigger['type'] == 'auto_open' ) {
|
@@ -348,9 +358,9 @@ class PUM_Integrations {
|
|
348 |
}
|
349 |
}
|
350 |
|
351 |
-
$settings['triggers'][] =
|
352 |
'type' => 'admin_debug',
|
353 |
-
|
354 |
}
|
355 |
|
356 |
return $settings;
|
@@ -366,27 +376,33 @@ class PUM_Integrations {
|
|
366 |
*
|
367 |
* @return array
|
368 |
*/
|
369 |
-
public static function pum_vars( $vars =
|
370 |
|
371 |
/**
|
372 |
* If a form was submitted via non-ajax methods this checks if a successful submission was reported.
|
373 |
*/
|
374 |
if ( isset( self::$form_success ) && ! empty( self::$form_success['popup_id'] ) ) {
|
375 |
-
self::$form_success['settings'] = wp_parse_args(
|
376 |
-
'
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
|
|
|
|
|
|
384 |
|
385 |
if ( is_array( self::$form_success['settings']['cookie'] ) ) {
|
386 |
-
self::$form_success['settings']['cookie'] = wp_parse_args(
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
390 |
}
|
391 |
|
392 |
$vars['form_success'] = self::$form_success;
|
@@ -394,12 +410,15 @@ class PUM_Integrations {
|
|
394 |
|
395 |
if ( ! empty( self::$form_submission ) ) {
|
396 |
// Remap values from PHP underscore_case to JS camelCase
|
397 |
-
$vars['form_submission'] = PUM_Utils_Array::remap_keys(
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
|
|
|
|
|
|
403 |
}
|
404 |
|
405 |
return $vars;
|
@@ -411,7 +430,7 @@ class PUM_Integrations {
|
|
411 |
* @return array
|
412 |
*/
|
413 |
public static function get_integrated_forms_selectlist() {
|
414 |
-
$enabled_form_integrations =
|
415 |
|
416 |
$options = [];
|
417 |
|
15 |
/**
|
16 |
* @var PUM_Abstract_Integration[]|PUM_Abstract_Integration_Form[]
|
17 |
*/
|
18 |
+
public static $integrations = [];
|
19 |
|
20 |
/**
|
21 |
* @var bool
|
49 |
|
50 |
self::$preload_posts = isset( $_GET['page'] ) && $_GET['page'] == 'pum-settings';
|
51 |
|
52 |
+
add_filter( 'pum_settings_fields', [ __CLASS__, 'settings_fields' ] );
|
53 |
+
add_action( 'pum_preload_popup', [ __CLASS__, 'enqueue_assets' ] );
|
54 |
+
add_filter( 'pum_registered_conditions', [ __CLASS__, 'register_conditions' ] );
|
55 |
|
56 |
+
add_filter( 'pum_vars', [ __CLASS__, 'pum_vars' ] );
|
57 |
|
58 |
+
add_action( 'init', [ __CLASS__, 'wp_init_late' ], 99 );
|
59 |
+
add_action( 'admin_init', [ __CLASS__, 'admin_init' ] );
|
60 |
+
add_filter( 'pum_popup_post_type_args', [ __CLASS__, 'popup_post_type_args' ] );
|
61 |
+
add_filter( 'pum_generated_js', [ __CLASS__, 'generated_js' ] );
|
62 |
+
add_filter( 'pum_generated_css', [ __CLASS__, 'generated_css' ] );
|
63 |
+
add_filter( 'pum_popup_settings', [ __CLASS__, 'popup_settings' ], 10, 2 );
|
64 |
|
65 |
PUM_Integration_GoogleFonts::init();
|
66 |
}
|
170 |
*
|
171 |
* @return array
|
172 |
*/
|
173 |
+
public static function settings_fields( $fields = [] ) {
|
174 |
|
175 |
foreach ( self::$integrations as $key => $integration ) {
|
176 |
if ( ! ( $integration instanceof PUM_Interface_Integration_Settings ) || ! $integration->enabled() ) {
|
196 |
}
|
197 |
|
198 |
// Do stuff here.
|
|
|
199 |
}
|
200 |
|
201 |
+
public static function register_conditions( $conditions = [] ) {
|
202 |
|
203 |
foreach ( self::$integrations as $key => $enabled ) {
|
204 |
if ( ! $enabled ) {
|
207 |
|
208 |
switch ( $key ) {
|
209 |
|
|
|
210 |
}
|
211 |
}
|
212 |
|
231 |
* Runs during admin_init
|
232 |
*/
|
233 |
public static function admin_init() {
|
234 |
+
if ( ! self::enabled( 'visualcomposer' ) && ( is_admin() && isset( $_GET['page'] ) && in_array(
|
235 |
+
$_GET['page'],
|
236 |
+
[
|
237 |
+
'vc_settings',
|
238 |
+
'fl-builder-settings',
|
239 |
+
]
|
240 |
+
) ) || pum_is_popup_editor() ) {
|
241 |
add_filter( 'vc_role_access_with_post_types_get_state', '__return_true' );
|
242 |
add_filter( 'vc_role_access_with_backend_editor_get_state', '__return_true' );
|
243 |
add_filter( 'vc_role_access_with_frontend_editor_get_state', '__return_false' );
|
245 |
}
|
246 |
}
|
247 |
|
248 |
+
public static function popup_post_type_args( $args = [] ) {
|
249 |
|
250 |
if ( self::enabled( 'kingcomposer' ) && ( ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] == 'kingcomposer' ) || pum_is_popup_editor() ) ) {
|
251 |
+
$args = array_merge(
|
252 |
+
$args,
|
253 |
+
[
|
254 |
+
'public' => true,
|
255 |
+
'exclude_from_search' => true,
|
256 |
+
'publicly_queryable' => false,
|
257 |
+
'show_in_nav_menus' => false,
|
258 |
+
]
|
259 |
+
);
|
260 |
}
|
261 |
|
262 |
+
if ( self::enabled( 'visualcomposer' ) && ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && ( ( isset( $_GET['page'] ) && in_array(
|
263 |
+
$_GET['page'],
|
264 |
+
[
|
265 |
+
'vc_settings',
|
266 |
+
'fl-builder-settings',
|
267 |
+
]
|
268 |
+
) ) || ( isset( $_POST['option_page'] ) && $_POST['option_page'] == 'wpb_js_composer_settings_general' ) || pum_is_popup_editor() ) ) ) {
|
269 |
+
$args = array_merge(
|
270 |
+
$args,
|
271 |
+
[
|
272 |
+
'public' => true,
|
273 |
+
'exclude_from_search' => true,
|
274 |
+
'publicly_queryable' => false, // Was true, verify this isn't a problem.
|
275 |
+
'show_in_nav_menus' => false,
|
276 |
+
]
|
277 |
+
);
|
278 |
}
|
279 |
|
280 |
return $args;
|
302 |
*
|
303 |
* @return array $css
|
304 |
*/
|
305 |
+
public static function generated_css( $css = [] ) {
|
306 |
|
307 |
foreach ( self::$integrations as $integration ) {
|
308 |
if ( $integration->enabled() && method_exists( $integration, 'custom_styles' ) ) {
|
317 |
* Modify popup settings.
|
318 |
*
|
319 |
* @param array $settings
|
320 |
+
* @param int $popup_id
|
321 |
*
|
322 |
* @return array
|
323 |
*/
|
350 |
* If submission exists for this popup remove auto open triggers and add an admin_debug trigger to reshow the popup.
|
351 |
*/
|
352 |
if ( ! in_array( false, $should_reopen ) ) {
|
353 |
+
$triggers = ! empty( $settings['triggers'] ) ? $settings['triggers'] : [];
|
354 |
|
355 |
foreach ( $triggers as $key => $trigger ) {
|
356 |
if ( $trigger['type'] == 'auto_open' ) {
|
358 |
}
|
359 |
}
|
360 |
|
361 |
+
$settings['triggers'][] = [
|
362 |
'type' => 'admin_debug',
|
363 |
+
];
|
364 |
}
|
365 |
|
366 |
return $settings;
|
376 |
*
|
377 |
* @return array
|
378 |
*/
|
379 |
+
public static function pum_vars( $vars = [] ) {
|
380 |
|
381 |
/**
|
382 |
* If a form was submitted via non-ajax methods this checks if a successful submission was reported.
|
383 |
*/
|
384 |
if ( isset( self::$form_success ) && ! empty( self::$form_success['popup_id'] ) ) {
|
385 |
+
self::$form_success['settings'] = wp_parse_args(
|
386 |
+
self::$form_success['settings'],
|
387 |
+
[
|
388 |
+
'openpopup' => false,
|
389 |
+
'openpopup_id' => 0,
|
390 |
+
'closepopup' => false,
|
391 |
+
'closedelay' => 0,
|
392 |
+
'redirect_enabled' => false,
|
393 |
+
'redirect' => '',
|
394 |
+
'cookie' => false,
|
395 |
+
]
|
396 |
+
);
|
397 |
|
398 |
if ( is_array( self::$form_success['settings']['cookie'] ) ) {
|
399 |
+
self::$form_success['settings']['cookie'] = wp_parse_args(
|
400 |
+
self::$form_success['settings']['cookie'],
|
401 |
+
[
|
402 |
+
'name' => 'pum-' . self::$form_success['popup_id'],
|
403 |
+
'expires' => '+1 year',
|
404 |
+
]
|
405 |
+
);
|
406 |
}
|
407 |
|
408 |
$vars['form_success'] = self::$form_success;
|
410 |
|
411 |
if ( ! empty( self::$form_submission ) ) {
|
412 |
// Remap values from PHP underscore_case to JS camelCase
|
413 |
+
$vars['form_submission'] = PUM_Utils_Array::remap_keys(
|
414 |
+
self::$form_submission,
|
415 |
+
[
|
416 |
+
'form_provider' => 'formProvider',
|
417 |
+
'form_id' => 'formId',
|
418 |
+
'form_instance_id' => 'formInstanceId',
|
419 |
+
'popup_id' => 'popupId',
|
420 |
+
]
|
421 |
+
);
|
422 |
}
|
423 |
|
424 |
return $vars;
|
430 |
* @return array
|
431 |
*/
|
432 |
public static function get_integrated_forms_selectlist() {
|
433 |
+
$enabled_form_integrations = self::get_enabled_form_integrations();
|
434 |
|
435 |
$options = [];
|
436 |
|
classes/Interface/CSV/Importer.php
CHANGED
@@ -21,7 +21,7 @@ interface PUM_Interface_CSV_Importer extends PUM_Interface_Batch_Importer {
|
|
21 |
*
|
22 |
* @param array $import_fields Import fields to map.
|
23 |
*/
|
24 |
-
public function map_fields( $import_fields =
|
25 |
|
26 |
/**
|
27 |
* Retrieves the CSV columns.
|
21 |
*
|
22 |
* @param array $import_fields Import fields to map.
|
23 |
*/
|
24 |
+
public function map_fields( $import_fields = [] );
|
25 |
|
26 |
/**
|
27 |
* Retrieves the CSV columns.
|
classes/Interface/Provider.php
CHANGED
@@ -37,7 +37,7 @@ interface PUM_Interface_Provider {
|
|
37 |
*
|
38 |
* @return array
|
39 |
*/
|
40 |
-
public function register_settings_tab_section( $sections =
|
41 |
|
42 |
|
43 |
/**
|
@@ -54,23 +54,23 @@ interface PUM_Interface_Provider {
|
|
54 |
*
|
55 |
* @return array $values
|
56 |
*/
|
57 |
-
public function form_sanitization( $values =
|
58 |
|
59 |
/**
|
60 |
* Allows processing of form value validation.
|
61 |
*
|
62 |
* @param WP_Error $errors
|
63 |
-
* @param array
|
64 |
*
|
65 |
* @return WP_Error
|
66 |
*/
|
67 |
-
public function form_validation( WP_Error $errors, $values =
|
68 |
|
69 |
/**
|
70 |
* Subscribes the user to the list.
|
71 |
*
|
72 |
* @param $values
|
73 |
-
* @param array
|
74 |
* @param WP_Error $errors
|
75 |
*/
|
76 |
public function form_submission( $values, &$json_response, WP_Error &$errors );
|
37 |
*
|
38 |
* @return array
|
39 |
*/
|
40 |
+
public function register_settings_tab_section( $sections = [] );
|
41 |
|
42 |
|
43 |
/**
|
54 |
*
|
55 |
* @return array $values
|
56 |
*/
|
57 |
+
public function form_sanitization( $values = [] );
|
58 |
|
59 |
/**
|
60 |
* Allows processing of form value validation.
|
61 |
*
|
62 |
* @param WP_Error $errors
|
63 |
+
* @param array $values
|
64 |
*
|
65 |
* @return WP_Error
|
66 |
*/
|
67 |
+
public function form_validation( WP_Error $errors, $values = [] );
|
68 |
|
69 |
/**
|
70 |
* Subscribes the user to the list.
|
71 |
*
|
72 |
* @param $values
|
73 |
+
* @param array $json_response
|
74 |
* @param WP_Error $errors
|
75 |
*/
|
76 |
public function form_submission( $values, &$json_response, WP_Error &$errors );
|
classes/Interface/Repository.php
CHANGED
@@ -35,7 +35,7 @@ interface PUM_Interface_Repository {
|
|
35 |
*
|
36 |
* @return WP_Post[||PUM_Abstract_Model_Post[]
|
37 |
*/
|
38 |
-
public function get_items( $args =
|
39 |
|
40 |
/**
|
41 |
* @param array $data
|
@@ -59,4 +59,4 @@ interface PUM_Interface_Repository {
|
|
59 |
*/
|
60 |
public function delete_item( $id );
|
61 |
|
62 |
-
}
|
35 |
*
|
36 |
* @return WP_Post[||PUM_Abstract_Model_Post[]
|
37 |
*/
|
38 |
+
public function get_items( $args = [] );
|
39 |
|
40 |
/**
|
41 |
* @param array $data
|
59 |
*/
|
60 |
public function delete_item( $id );
|
61 |
|
62 |
+
}
|
classes/Licensing.php
CHANGED
@@ -52,17 +52,17 @@ class PUM_Licensing {
|
|
52 |
$error = property_exists( $license, 'error' ) ? $license->error : $status;
|
53 |
|
54 |
switch ( $error ) {
|
55 |
-
case 'expired'
|
56 |
$status = 'expired';
|
57 |
break;
|
58 |
-
case 'revoked'
|
59 |
-
case 'missing'
|
60 |
-
case 'invalid'
|
61 |
-
case 'site_inactive'
|
62 |
-
case 'item_name_mismatch'
|
63 |
case 'no_activations_left':
|
64 |
case 'license_not_activable':
|
65 |
-
default
|
66 |
$status = 'error';
|
67 |
break;
|
68 |
}
|
@@ -77,12 +77,12 @@ class PUM_Licensing {
|
|
77 |
/**
|
78 |
* @param object|bool|null $license
|
79 |
*
|
80 |
-
* @param string
|
81 |
*
|
82 |
* @return array
|
83 |
*/
|
84 |
public static function get_status_messages( $license = null, $key = '' ) {
|
85 |
-
$messages =
|
86 |
|
87 |
if ( self::has_license( $license ) ) {
|
88 |
|
@@ -90,39 +90,38 @@ class PUM_Licensing {
|
|
90 |
if ( false === $license->success ) {
|
91 |
|
92 |
switch ( $license->error ) {
|
93 |
-
case 'expired'
|
94 |
-
$messages[] = sprintf( __( 'Your license key expired on %s. Please %srenew your license key%s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), '<a target="_blank" href="https://wppopupmaker.com/checkout/?edd_license_key=' . $key . '&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_medium=expired&utm_content=pum_license">', '</a>' );
|
95 |
break;
|
96 |
-
case 'disabled'
|
97 |
-
case 'revoked'
|
98 |
-
$messages[] = sprintf( __( 'Your license key has been disabled. Please %scontact support%s for more information.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/support/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=revoked">', '</a>' );
|
99 |
break;
|
100 |
-
case 'missing'
|
101 |
-
$messages[] = sprintf( __( 'Invalid license. Please %svisit your account page%s and verify it.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=missing">', '</a>' );
|
102 |
break;
|
103 |
-
case 'invalid'
|
104 |
-
case 'site_inactive'
|
105 |
-
$messages[] = sprintf( __( 'Your %s is not active for this URL. Please %svisit your account page%s to manage your license key URLs.', 'popup-maker' ), Popup_Maker::$NAME, '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=invalid">', '</a>' );
|
106 |
break;
|
107 |
-
case 'item_name_mismatch'
|
108 |
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'popup-maker' ), Popup_Maker::$NAME );
|
109 |
break;
|
110 |
case 'no_activations_left':
|
111 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. %sView possible upgrades%s now.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=no-activations-left">', '</a>' );
|
112 |
break;
|
113 |
case 'license_not_activable':
|
114 |
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'popup-maker' );
|
115 |
break;
|
116 |
-
default
|
117 |
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'popup-maker' );
|
118 |
-
$messages[] = sprintf( __( 'There was an error with this license key: %s. Please %scontact our support team%s.', 'popup-maker' ), $error, '<a target="_blank" href="https://wppopupmaker.com/support/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=error-contact-support">', '</a>' );
|
119 |
break;
|
120 |
}
|
121 |
-
|
122 |
} else {
|
123 |
|
124 |
switch ( $license->license ) {
|
125 |
-
case 'valid'
|
126 |
default:
|
127 |
$now = current_time( 'timestamp' );
|
128 |
$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
|
@@ -130,16 +129,16 @@ class PUM_Licensing {
|
|
130 |
if ( 'lifetime' === $license->expires ) {
|
131 |
$messages[] = __( 'License key never expires.', 'popup-maker' );
|
132 |
} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
133 |
-
$messages[] = sprintf( __( 'Your license key expires soon! It expires on %s. %sRenew your license key%s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), '<a target="_blank" href="https://wppopupmaker.com/checkout/?edd_license_key=' . $key . '&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=Popup+Maker+license&utm_medium=renew">', '</a>' );
|
134 |
} else {
|
135 |
$messages[] = sprintf( __( 'Your license key expires on %s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) );
|
136 |
}
|
137 |
break;
|
138 |
}
|
139 |
-
|
140 |
}
|
141 |
} else {
|
142 |
-
$messages[] = sprintf( __( 'To receive updates, please enter your valid %s license key.', 'popup-maker' ), Popup_Maker::$NAME )
|
|
|
143 |
}
|
144 |
|
145 |
return $messages;
|
52 |
$error = property_exists( $license, 'error' ) ? $license->error : $status;
|
53 |
|
54 |
switch ( $error ) {
|
55 |
+
case 'expired':
|
56 |
$status = 'expired';
|
57 |
break;
|
58 |
+
case 'revoked':
|
59 |
+
case 'missing':
|
60 |
+
case 'invalid':
|
61 |
+
case 'site_inactive':
|
62 |
+
case 'item_name_mismatch':
|
63 |
case 'no_activations_left':
|
64 |
case 'license_not_activable':
|
65 |
+
default:
|
66 |
$status = 'error';
|
67 |
break;
|
68 |
}
|
77 |
/**
|
78 |
* @param object|bool|null $license
|
79 |
*
|
80 |
+
* @param string $key
|
81 |
*
|
82 |
* @return array
|
83 |
*/
|
84 |
public static function get_status_messages( $license = null, $key = '' ) {
|
85 |
+
$messages = [];
|
86 |
|
87 |
if ( self::has_license( $license ) ) {
|
88 |
|
90 |
if ( false === $license->success ) {
|
91 |
|
92 |
switch ( $license->error ) {
|
93 |
+
case 'expired':
|
94 |
+
$messages[] = sprintf( __( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), '<a target="_blank" href="https://wppopupmaker.com/checkout/?edd_license_key=' . $key . '&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_medium=expired&utm_content=pum_license">', '</a>' );
|
95 |
break;
|
96 |
+
case 'disabled':
|
97 |
+
case 'revoked':
|
98 |
+
$messages[] = sprintf( __( 'Your license key has been disabled. Please %1$scontact support%2$s for more information.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/support/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=revoked">', '</a>' );
|
99 |
break;
|
100 |
+
case 'missing':
|
101 |
+
$messages[] = sprintf( __( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=missing">', '</a>' );
|
102 |
break;
|
103 |
+
case 'invalid':
|
104 |
+
case 'site_inactive':
|
105 |
+
$messages[] = sprintf( __( 'Your %1$s is not active for this URL. Please %2$svisit your account page%3$s to manage your license key URLs.', 'popup-maker' ), Popup_Maker::$NAME, '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=invalid">', '</a>' );
|
106 |
break;
|
107 |
+
case 'item_name_mismatch':
|
108 |
$messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'popup-maker' ), Popup_Maker::$NAME );
|
109 |
break;
|
110 |
case 'no_activations_left':
|
111 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'popup-maker' ), '<a target="_blank" href="https://wppopupmaker.com/your-account/license-keys/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=no-activations-left">', '</a>' );
|
112 |
break;
|
113 |
case 'license_not_activable':
|
114 |
$messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'popup-maker' );
|
115 |
break;
|
116 |
+
default:
|
117 |
$error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'popup-maker' );
|
118 |
+
$messages[] = sprintf( __( 'There was an error with this license key: %1$s. Please %2$scontact our support team%3$s.', 'popup-maker' ), $error, '<a target="_blank" href="https://wppopupmaker.com/support/?utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=pum_license&utm_medium=error-contact-support">', '</a>' );
|
119 |
break;
|
120 |
}
|
|
|
121 |
} else {
|
122 |
|
123 |
switch ( $license->license ) {
|
124 |
+
case 'valid':
|
125 |
default:
|
126 |
$now = current_time( 'timestamp' );
|
127 |
$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
|
129 |
if ( 'lifetime' === $license->expires ) {
|
130 |
$messages[] = __( 'License key never expires.', 'popup-maker' );
|
131 |
} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
132 |
+
$messages[] = sprintf( __( 'Your license key expires soon! It expires on %1$s. %2$sRenew your license key%3$s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), '<a target="_blank" href="https://wppopupmaker.com/checkout/?edd_license_key=' . $key . '&utm_campaign=Licensing&utm_source=plugin-settings-page-licenses-tab&utm_content=Popup+Maker+license&utm_medium=renew">', '</a>' );
|
133 |
} else {
|
134 |
$messages[] = sprintf( __( 'Your license key expires on %s.', 'popup-maker' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) );
|
135 |
}
|
136 |
break;
|
137 |
}
|
|
|
138 |
}
|
139 |
} else {
|
140 |
+
$messages[] = sprintf( __( 'To receive updates, please enter your valid %s license key.', 'popup-maker' ), Popup_Maker::$NAME );
|
141 |
+
|
142 |
}
|
143 |
|
144 |
return $messages;
|
classes/ListTable.php
CHANGED
@@ -37,7 +37,7 @@ class PUM_ListTable {
|
|
37 |
* @since 3.1.0
|
38 |
* @var array
|
39 |
*/
|
40 |
-
protected $_pagination_args =
|
41 |
|
42 |
/**
|
43 |
* The current screen.
|
@@ -69,7 +69,7 @@ class PUM_ListTable {
|
|
69 |
* @since 4.1.0
|
70 |
* @var array
|
71 |
*/
|
72 |
-
protected $modes =
|
73 |
|
74 |
/**
|
75 |
* Stores the value returned by ->get_column_info().
|
@@ -84,17 +84,31 @@ class PUM_ListTable {
|
|
84 |
*
|
85 |
* @var array
|
86 |
*/
|
87 |
-
protected $compat_fields =
|
88 |
|
89 |
/**
|
90 |
* {@internal Missing Summary}
|
91 |
*
|
92 |
* @var array
|
93 |
*/
|
94 |
-
protected $compat_methods =
|
95 |
-
'
|
96 |
-
'
|
97 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
/**
|
100 |
* Constructor.
|
@@ -121,36 +135,40 @@ class PUM_ListTable {
|
|
121 |
* Default null.
|
122 |
* }
|
123 |
*/
|
124 |
-
public function __construct( $args =
|
125 |
-
$args = wp_parse_args(
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
131 |
|
132 |
$this->screen = convert_to_screen( $args['screen'] );
|
133 |
|
134 |
-
add_filter( "manage_{$this->screen->id}_columns",
|
135 |
|
136 |
-
if (
|
137 |
$args['plural'] = $this->screen->base;
|
|
|
138 |
|
139 |
-
$args['plural']
|
140 |
$args['singular'] = sanitize_key( $args['singular'] );
|
141 |
|
142 |
$this->_args = $args;
|
143 |
|
144 |
if ( $args['ajax'] ) {
|
145 |
// wp_enqueue_script( 'list-table' );
|
146 |
-
add_action( 'admin_footer',
|
147 |
}
|
148 |
|
149 |
if ( empty( $this->modes ) ) {
|
150 |
-
$this->modes =
|
151 |
'list' => __( 'List View' ),
|
152 |
-
'excerpt' => __( 'Excerpt View' )
|
153 |
-
|
154 |
}
|
155 |
}
|
156 |
|
@@ -221,7 +239,7 @@ class PUM_ListTable {
|
|
221 |
*/
|
222 |
public function __call( $name, $arguments ) {
|
223 |
if ( in_array( $name, $this->compat_methods ) ) {
|
224 |
-
return call_user_func_array(
|
225 |
}
|
226 |
return false;
|
227 |
}
|
@@ -238,6 +256,7 @@ class PUM_ListTable {
|
|
238 |
|
239 |
/**
|
240 |
* Prepares the list of items for displaying.
|
|
|
241 |
* @uses PUM_ListTable::set_pagination_args()
|
242 |
*
|
243 |
* @since 3.1.0
|
@@ -255,18 +274,22 @@ class PUM_ListTable {
|
|
255 |
* @param array|string $args Array or string of arguments with information about the pagination.
|
256 |
*/
|
257 |
protected function set_pagination_args( $args ) {
|
258 |
-
$args = wp_parse_args(
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
263 |
|
264 |
-
if (
|
265 |
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
|
|
266 |
|
267 |
// Redirect if page number is invalid and headers are not already sent.
|
268 |
if ( ! headers_sent() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
269 |
-
|
270 |
exit;
|
271 |
}
|
272 |
|
@@ -287,8 +310,8 @@ class PUM_ListTable {
|
|
287 |
return $this->get_pagenum();
|
288 |
}
|
289 |
|
290 |
-
if ( isset( $this->_pagination_args[$key] ) ) {
|
291 |
-
return $this->_pagination_args[$key];
|
292 |
}
|
293 |
}
|
294 |
|
@@ -300,7 +323,7 @@ class PUM_ListTable {
|
|
300 |
* @return bool
|
301 |
*/
|
302 |
public function has_items() {
|
303 |
-
return !empty( $this->items );
|
304 |
}
|
305 |
|
306 |
/**
|
@@ -321,26 +344,31 @@ class PUM_ListTable {
|
|
321 |
* @param string $input_id ID attribute value for the search input field.
|
322 |
*/
|
323 |
public function search_box( $text, $input_id ) {
|
324 |
-
if ( empty( $_REQUEST['s'] ) &&
|
325 |
return;
|
|
|
326 |
|
327 |
$input_id = $input_id . '-search-input';
|
328 |
|
329 |
-
if ( ! empty( $_REQUEST['orderby'] ) )
|
330 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
331 |
-
|
|
|
332 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
333 |
-
|
|
|
334 |
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
|
335 |
-
|
|
|
336 |
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
|
337 |
-
|
|
|
338 |
<p class="search-box">
|
339 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
|
340 |
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
341 |
-
|
342 |
</p>
|
343 |
-
<?php
|
344 |
}
|
345 |
|
346 |
/**
|
@@ -352,7 +380,7 @@ class PUM_ListTable {
|
|
352 |
* @return array
|
353 |
*/
|
354 |
protected function get_views() {
|
355 |
-
return
|
356 |
}
|
357 |
|
358 |
/**
|
@@ -374,8 +402,9 @@ class PUM_ListTable {
|
|
374 |
*/
|
375 |
$views = apply_filters( "views_{$this->screen->id}", $views );
|
376 |
|
377 |
-
if ( empty( $views ) )
|
378 |
return;
|
|
|
379 |
|
380 |
$this->screen->render_screen_reader_content( 'heading_views' );
|
381 |
|
@@ -384,7 +413,7 @@ class PUM_ListTable {
|
|
384 |
$views[ $class ] = "\t<li class='$class'>$view";
|
385 |
}
|
386 |
echo implode( " |</li>\n", $views ) . "</li>\n";
|
387 |
-
echo
|
388 |
}
|
389 |
|
390 |
/**
|
@@ -396,7 +425,7 @@ class PUM_ListTable {
|
|
396 |
* @return array
|
397 |
*/
|
398 |
protected function get_bulk_actions() {
|
399 |
-
return
|
400 |
}
|
401 |
|
402 |
/**
|
@@ -423,13 +452,14 @@ class PUM_ListTable {
|
|
423 |
* @param array $actions An array of the available bulk actions.
|
424 |
*/
|
425 |
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
|
426 |
-
$two
|
427 |
} else {
|
428 |
$two = '2';
|
429 |
}
|
430 |
|
431 |
-
if ( empty( $this->_actions ) )
|
432 |
return;
|
|
|
433 |
|
434 |
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
|
435 |
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
|
@@ -443,7 +473,7 @@ class PUM_ListTable {
|
|
443 |
|
444 |
echo "</select>\n";
|
445 |
|
446 |
-
submit_button( __( 'Apply' ), 'action', '', false,
|
447 |
echo "\n";
|
448 |
}
|
449 |
|
@@ -455,14 +485,17 @@ class PUM_ListTable {
|
|
455 |
* @return string|false The action name or False if no action was selected
|
456 |
*/
|
457 |
public function current_action() {
|
458 |
-
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
|
459 |
return false;
|
|
|
460 |
|
461 |
-
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
|
462 |
return $_REQUEST['action'];
|
|
|
463 |
|
464 |
-
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
|
465 |
return $_REQUEST['action2'];
|
|
|
466 |
|
467 |
return false;
|
468 |
}
|
@@ -473,21 +506,22 @@ class PUM_ListTable {
|
|
473 |
* @since 3.1.0
|
474 |
*
|
475 |
* @param array $actions The list of actions
|
476 |
-
* @param bool
|
477 |
* @return string
|
478 |
*/
|
479 |
protected function row_actions( $actions, $always_visible = false ) {
|
480 |
$action_count = count( $actions );
|
481 |
-
$i
|
482 |
|
483 |
-
if (
|
484 |
return '';
|
|
|
485 |
|
486 |
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
487 |
foreach ( $actions as $action => $link ) {
|
488 |
++$i;
|
489 |
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
490 |
-
$out
|
491 |
}
|
492 |
$out .= '</div>';
|
493 |
|
@@ -528,13 +562,18 @@ class PUM_ListTable {
|
|
528 |
$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
|
529 |
}
|
530 |
|
531 |
-
$months = $wpdb->get_results(
|
|
|
|
|
532 |
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
533 |
FROM $wpdb->posts
|
534 |
WHERE post_type = %s
|
535 |
$extra_checks
|
536 |
ORDER BY post_date DESC
|
537 |
-
",
|
|
|
|
|
|
|
538 |
|
539 |
/**
|
540 |
* Filters the 'Months' drop-down results.
|
@@ -548,32 +587,35 @@ class PUM_ListTable {
|
|
548 |
|
549 |
$month_count = count( $months );
|
550 |
|
551 |
-
if (
|
552 |
return;
|
|
|
553 |
|
554 |
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
|
555 |
-
?>
|
556 |
<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
|
557 |
<select name="m" id="filter-by-date">
|
558 |
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
|
559 |
-
<?php
|
560 |
foreach ( $months as $arc_row ) {
|
561 |
-
if ( 0 == $arc_row->year )
|
562 |
continue;
|
|
|
563 |
|
564 |
$month = zeroise( $arc_row->month, 2 );
|
565 |
-
$year
|
566 |
|
567 |
-
printf(
|
|
|
568 |
selected( $m, $year . $month, false ),
|
569 |
esc_attr( $arc_row->year . $month ),
|
570 |
/* translators: 1: month name, 2: 4-digit year */
|
571 |
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
572 |
);
|
573 |
}
|
574 |
-
?>
|
575 |
</select>
|
576 |
-
<?php
|
577 |
}
|
578 |
|
579 |
/**
|
@@ -584,24 +626,25 @@ class PUM_ListTable {
|
|
584 |
* @param string $current_mode
|
585 |
*/
|
586 |
protected function view_switcher( $current_mode ) {
|
587 |
-
?>
|
588 |
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
589 |
<div class="view-switch">
|
590 |
-
<?php
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
printf(
|
596 |
-
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
|
597 |
-
esc_url( add_query_arg( 'mode', $mode ) ),
|
598 |
-
implode( ' ', $classes ),
|
599 |
-
$title
|
600 |
-
);
|
601 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
?>
|
603 |
</div>
|
604 |
-
<?php
|
605 |
}
|
606 |
|
607 |
/**
|
@@ -616,39 +659,60 @@ class PUM_ListTable {
|
|
616 |
$approved_comments = get_comments_number();
|
617 |
|
618 |
$approved_comments_number = number_format_i18n( $approved_comments );
|
619 |
-
$pending_comments_number
|
620 |
|
621 |
$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
|
622 |
-
$approved_phrase
|
623 |
-
$pending_phrase
|
624 |
|
625 |
// No comments at all.
|
626 |
if ( ! $approved_comments && ! $pending_comments ) {
|
627 |
-
printf(
|
|
|
628 |
__( 'No comments' )
|
629 |
);
|
630 |
-
|
631 |
} elseif ( $approved_comments ) {
|
632 |
-
printf(
|
633 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
634 |
$approved_comments_number,
|
635 |
$pending_comments ? $approved_phrase : $approved_only_phrase
|
636 |
);
|
637 |
} else {
|
638 |
-
printf(
|
|
|
639 |
$approved_comments_number,
|
640 |
$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
|
641 |
);
|
642 |
}
|
643 |
|
644 |
if ( $pending_comments ) {
|
645 |
-
printf(
|
646 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
647 |
$pending_comments_number,
|
648 |
$pending_phrase
|
649 |
);
|
650 |
} else {
|
651 |
-
printf(
|
|
|
652 |
$pending_comments_number,
|
653 |
$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
|
654 |
);
|
@@ -665,8 +729,9 @@ class PUM_ListTable {
|
|
665 |
public function get_pagenum() {
|
666 |
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
|
667 |
|
668 |
-
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
|
669 |
$pagenum = $this->_pagination_args['total_pages'];
|
|
|
670 |
|
671 |
return max( 1, $pagenum );
|
672 |
}
|
@@ -682,8 +747,9 @@ class PUM_ListTable {
|
|
682 |
*/
|
683 |
protected function get_items_per_page( $option, $default = 20 ) {
|
684 |
$per_page = (int) get_user_option( $option );
|
685 |
-
if ( empty( $per_page ) || $per_page < 1 )
|
686 |
$per_page = $default;
|
|
|
687 |
|
688 |
/**
|
689 |
* Filters the number of items to be displayed on each page of the list table.
|
@@ -713,8 +779,8 @@ class PUM_ListTable {
|
|
713 |
return;
|
714 |
}
|
715 |
|
716 |
-
$total_items
|
717 |
-
$total_pages
|
718 |
$infinite_scroll = false;
|
719 |
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
|
720 |
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
@@ -728,7 +794,7 @@ class PUM_ListTable {
|
|
728 |
|
729 |
$current = $this->get_pagenum();
|
730 |
|
731 |
-
if ( ! function_exists( 'wp_removable_query_args') ) {
|
732 |
require_once Popup_Maker::$DIR . 'includes/compatibility/function-wp_removable_query_args.php';
|
733 |
}
|
734 |
|
@@ -738,24 +804,24 @@ class PUM_ListTable {
|
|
738 |
|
739 |
$current_url = remove_query_arg( $removable_query_args, $current_url );
|
740 |
|
741 |
-
$page_links =
|
742 |
|
743 |
$total_pages_before = '<span class="paging-input">';
|
744 |
$total_pages_after = '</span></span>';
|
745 |
|
746 |
$disable_first = $disable_last = $disable_prev = $disable_next = false;
|
747 |
|
748 |
-
|
749 |
$disable_first = true;
|
750 |
-
$disable_prev
|
751 |
-
|
752 |
if ( $current == 2 ) {
|
753 |
$disable_first = true;
|
754 |
}
|
755 |
-
|
756 |
$disable_last = true;
|
757 |
$disable_next = true;
|
758 |
-
|
759 |
if ( $current == $total_pages - 1 ) {
|
760 |
$disable_last = true;
|
761 |
}
|
@@ -763,7 +829,8 @@ class PUM_ListTable {
|
|
763 |
if ( $disable_first ) {
|
764 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>';
|
765 |
} else {
|
766 |
-
$page_links[] = sprintf(
|
|
|
767 |
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
768 |
__( 'First page' ),
|
769 |
'«'
|
@@ -773,8 +840,9 @@ class PUM_ListTable {
|
|
773 |
if ( $disable_prev ) {
|
774 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>';
|
775 |
} else {
|
776 |
-
$page_links[] = sprintf(
|
777 |
-
|
|
|
778 |
__( 'Previous page' ),
|
779 |
'‹'
|
780 |
);
|
@@ -784,20 +852,22 @@ class PUM_ListTable {
|
|
784 |
$html_current_page = $current;
|
785 |
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
|
786 |
} else {
|
787 |
-
$html_current_page = sprintf(
|
|
|
788 |
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
|
789 |
$current,
|
790 |
strlen( $total_pages )
|
791 |
);
|
792 |
}
|
793 |
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
794 |
-
$page_links[]
|
795 |
|
796 |
if ( $disable_next ) {
|
797 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>';
|
798 |
} else {
|
799 |
-
$page_links[] = sprintf(
|
800 |
-
|
|
|
801 |
__( 'Next page' ),
|
802 |
'›'
|
803 |
);
|
@@ -806,7 +876,8 @@ class PUM_ListTable {
|
|
806 |
if ( $disable_last ) {
|
807 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>';
|
808 |
} else {
|
809 |
-
$page_links[] = sprintf(
|
|
|
810 |
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
|
811 |
__( 'Last page' ),
|
812 |
'»'
|
@@ -855,7 +926,7 @@ class PUM_ListTable {
|
|
855 |
* @return array
|
856 |
*/
|
857 |
protected function get_sortable_columns() {
|
858 |
-
return
|
859 |
}
|
860 |
|
861 |
/**
|
@@ -867,7 +938,7 @@ class PUM_ListTable {
|
|
867 |
*/
|
868 |
protected function get_default_primary_column_name() {
|
869 |
$columns = $this->get_columns();
|
870 |
-
$column
|
871 |
|
872 |
if ( empty( $columns ) ) {
|
873 |
return $column;
|
@@ -912,7 +983,7 @@ class PUM_ListTable {
|
|
912 |
// If the primary column doesn't exist fall back to the
|
913 |
// first non-checkbox column.
|
914 |
if ( ! isset( $columns[ $default ] ) ) {
|
915 |
-
$default =
|
916 |
}
|
917 |
|
918 |
/**
|
@@ -923,7 +994,7 @@ class PUM_ListTable {
|
|
923 |
* @param string $default Column name default for the specific list table, e.g. 'name'.
|
924 |
* @param string $context Screen ID for specific list table, e.g. 'plugins'.
|
925 |
*/
|
926 |
-
$column
|
927 |
|
928 |
if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
|
929 |
$column = $default;
|
@@ -944,7 +1015,7 @@ class PUM_ListTable {
|
|
944 |
if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
|
945 |
// Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
|
946 |
// In 4.3, we added a fourth argument for primary column.
|
947 |
-
$column_headers =
|
948 |
foreach ( $this->_column_headers as $key => $value ) {
|
949 |
$column_headers[ $key ] = $value;
|
950 |
}
|
@@ -953,7 +1024,7 @@ class PUM_ListTable {
|
|
953 |
}
|
954 |
|
955 |
$columns = get_column_headers( $this->screen );
|
956 |
-
$hidden
|
957 |
|
958 |
$sortable_columns = $this->get_sortable_columns();
|
959 |
/**
|
@@ -968,20 +1039,22 @@ class PUM_ListTable {
|
|
968 |
*/
|
969 |
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
|
970 |
|
971 |
-
$sortable =
|
972 |
foreach ( $_sortable as $id => $data ) {
|
973 |
-
if ( empty( $data ) )
|
974 |
continue;
|
|
|
975 |
|
976 |
$data = (array) $data;
|
977 |
-
if ( !isset( $data[1] ) )
|
978 |
$data[1] = false;
|
|
|
979 |
|
980 |
-
$sortable[$id] = $data;
|
981 |
}
|
982 |
|
983 |
-
$primary
|
984 |
-
$this->_column_headers =
|
985 |
|
986 |
return $this->_column_headers;
|
987 |
}
|
@@ -995,7 +1068,7 @@ class PUM_ListTable {
|
|
995 |
*/
|
996 |
public function get_column_count() {
|
997 |
list ( $columns, $hidden ) = $this->get_column_info();
|
998 |
-
$hidden
|
999 |
return count( $columns ) - count( $hidden );
|
1000 |
}
|
1001 |
|
@@ -1028,36 +1101,37 @@ class PUM_ListTable {
|
|
1028 |
|
1029 |
if ( ! empty( $columns['cb'] ) ) {
|
1030 |
static $cb_counter = 1;
|
1031 |
-
$columns['cb']
|
1032 |
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
|
1033 |
$cb_counter++;
|
1034 |
}
|
1035 |
|
1036 |
foreach ( $columns as $column_key => $column_display_name ) {
|
1037 |
-
$class =
|
1038 |
|
1039 |
if ( in_array( $column_key, $hidden ) ) {
|
1040 |
$class[] = 'hidden';
|
1041 |
}
|
1042 |
|
1043 |
-
if ( 'cb' === $column_key )
|
1044 |
$class[] = 'check-column';
|
1045 |
-
elseif ( in_array( $column_key,
|
1046 |
$class[] = 'num';
|
|
|
1047 |
|
1048 |
if ( $column_key === $primary ) {
|
1049 |
$class[] = 'column-primary';
|
1050 |
}
|
1051 |
|
1052 |
-
if ( isset( $sortable[$column_key] ) ) {
|
1053 |
-
list( $orderby, $desc_first ) = $sortable[$column_key];
|
1054 |
|
1055 |
if ( $current_orderby === $orderby ) {
|
1056 |
-
$order
|
1057 |
$class[] = 'sorted';
|
1058 |
$class[] = $current_order;
|
1059 |
} else {
|
1060 |
-
$order
|
1061 |
$class[] = 'sortable';
|
1062 |
$class[] = $desc_first ? 'asc' : 'desc';
|
1063 |
}
|
@@ -1065,12 +1139,13 @@ class PUM_ListTable {
|
|
1065 |
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
1066 |
}
|
1067 |
|
1068 |
-
$tag
|
1069 |
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
|
1070 |
-
$id
|
1071 |
|
1072 |
-
if ( !empty( $class ) )
|
1073 |
$class = "class='" . join( ' ', $class ) . "'";
|
|
|
1074 |
|
1075 |
echo "<$tag $scope $id $class>$column_display_name</$tag>";
|
1076 |
}
|
@@ -1087,7 +1162,7 @@ class PUM_ListTable {
|
|
1087 |
$this->display_tablenav( 'top' );
|
1088 |
|
1089 |
$this->screen->render_screen_reader_content( 'heading_list' );
|
1090 |
-
?>
|
1091 |
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
|
1092 |
<thead>
|
1093 |
<tr>
|
@@ -1095,10 +1170,13 @@ class PUM_ListTable {
|
|
1095 |
</tr>
|
1096 |
</thead>
|
1097 |
|
1098 |
-
<tbody id="the-list"
|
|
|
1099 |
if ( $singular ) {
|
1100 |
echo " data-wp-lists='list:$singular'";
|
1101 |
-
}
|
|
|
|
|
1102 |
<?php $this->display_rows_or_placeholder(); ?>
|
1103 |
</tbody>
|
1104 |
|
@@ -1109,7 +1187,7 @@ class PUM_ListTable {
|
|
1109 |
</tfoot>
|
1110 |
|
1111 |
</table>
|
1112 |
-
<?php
|
1113 |
$this->display_tablenav( 'bottom' );
|
1114 |
}
|
1115 |
|
@@ -1121,7 +1199,7 @@ class PUM_ListTable {
|
|
1121 |
* @return array List of CSS classes for the table tag.
|
1122 |
*/
|
1123 |
protected function get_table_classes() {
|
1124 |
-
return
|
1125 |
}
|
1126 |
|
1127 |
/**
|
@@ -1137,18 +1215,19 @@ class PUM_ListTable {
|
|
1137 |
?>
|
1138 |
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
1139 |
|
1140 |
-
<?php if ( $this->has_items() ): ?>
|
1141 |
<div class="alignleft actions bulkactions">
|
1142 |
<?php $this->bulk_actions( $which ); ?>
|
1143 |
</div>
|
1144 |
-
|
|
|
1145 |
$this->extra_tablenav( $which );
|
1146 |
$this->pagination( $which );
|
1147 |
-
?>
|
1148 |
|
1149 |
<br class="clear" />
|
1150 |
</div>
|
1151 |
-
<?php
|
1152 |
}
|
1153 |
|
1154 |
/**
|
@@ -1181,8 +1260,9 @@ class PUM_ListTable {
|
|
1181 |
* @since 3.1.0
|
1182 |
*/
|
1183 |
public function display_rows() {
|
1184 |
-
foreach ( $this->items as $item )
|
1185 |
$this->single_row( $item );
|
|
|
1186 |
}
|
1187 |
|
1188 |
/**
|
@@ -1243,7 +1323,7 @@ class PUM_ListTable {
|
|
1243 |
echo '</th>';
|
1244 |
} elseif ( method_exists( $this, '_column_' . $column_name ) ) {
|
1245 |
echo call_user_func(
|
1246 |
-
|
1247 |
$item,
|
1248 |
$classes,
|
1249 |
$data,
|
@@ -1251,14 +1331,14 @@ class PUM_ListTable {
|
|
1251 |
);
|
1252 |
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
1253 |
echo "<td $attributes>";
|
1254 |
-
echo call_user_func(
|
1255 |
echo $this->handle_row_actions( $item, $column_name, $primary );
|
1256 |
-
echo
|
1257 |
} else {
|
1258 |
echo "<td $attributes>";
|
1259 |
echo $this->column_default( $item, $column_name );
|
1260 |
echo $this->handle_row_actions( $item, $column_name, $primary );
|
1261 |
-
echo
|
1262 |
}
|
1263 |
}
|
1264 |
}
|
@@ -1275,7 +1355,7 @@ class PUM_ListTable {
|
|
1275 |
*/
|
1276 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
1277 |
return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
|
1278 |
-
|
1279 |
|
1280 |
/**
|
1281 |
* Handle an incoming ajax request (called from admin-ajax.php)
|
@@ -1294,7 +1374,7 @@ class PUM_ListTable {
|
|
1294 |
|
1295 |
$rows = ob_get_clean();
|
1296 |
|
1297 |
-
$response =
|
1298 |
|
1299 |
if ( isset( $this->_pagination_args['total_items'] ) ) {
|
1300 |
$response['total_items_i18n'] = sprintf(
|
@@ -1303,7 +1383,7 @@ class PUM_ListTable {
|
|
1303 |
);
|
1304 |
}
|
1305 |
if ( isset( $this->_pagination_args['total_pages'] ) ) {
|
1306 |
-
$response['total_pages']
|
1307 |
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
|
1308 |
}
|
1309 |
|
@@ -1312,16 +1392,15 @@ class PUM_ListTable {
|
|
1312 |
|
1313 |
/**
|
1314 |
* Send required variables to JavaScript land
|
1315 |
-
*
|
1316 |
*/
|
1317 |
public function _js_vars() {
|
1318 |
-
$args =
|
1319 |
'class' => get_class( $this ),
|
1320 |
-
'screen' =>
|
1321 |
'id' => $this->screen->id,
|
1322 |
'base' => $this->screen->base,
|
1323 |
-
|
1324 |
-
|
1325 |
|
1326 |
printf( "<script type='text/javascript'>list_args = %s;</script>\n", PUM_Utils_Array::safe_json_encode( $args ) );
|
1327 |
}
|
37 |
* @since 3.1.0
|
38 |
* @var array
|
39 |
*/
|
40 |
+
protected $_pagination_args = [];
|
41 |
|
42 |
/**
|
43 |
* The current screen.
|
69 |
* @since 4.1.0
|
70 |
* @var array
|
71 |
*/
|
72 |
+
protected $modes = [];
|
73 |
|
74 |
/**
|
75 |
* Stores the value returned by ->get_column_info().
|
84 |
*
|
85 |
* @var array
|
86 |
*/
|
87 |
+
protected $compat_fields = [ '_args', '_pagination_args', 'screen', '_actions', '_pagination' ];
|
88 |
|
89 |
/**
|
90 |
* {@internal Missing Summary}
|
91 |
*
|
92 |
* @var array
|
93 |
*/
|
94 |
+
protected $compat_methods = [
|
95 |
+
'set_pagination_args',
|
96 |
+
'get_views',
|
97 |
+
'get_bulk_actions',
|
98 |
+
'bulk_actions',
|
99 |
+
'row_actions',
|
100 |
+
'months_dropdown',
|
101 |
+
'view_switcher',
|
102 |
+
'comments_bubble',
|
103 |
+
'get_items_per_page',
|
104 |
+
'pagination',
|
105 |
+
'get_sortable_columns',
|
106 |
+
'get_column_info',
|
107 |
+
'get_table_classes',
|
108 |
+
'display_tablenav',
|
109 |
+
'extra_tablenav',
|
110 |
+
'single_row_columns',
|
111 |
+
];
|
112 |
|
113 |
/**
|
114 |
* Constructor.
|
135 |
* Default null.
|
136 |
* }
|
137 |
*/
|
138 |
+
public function __construct( $args = [] ) {
|
139 |
+
$args = wp_parse_args(
|
140 |
+
$args,
|
141 |
+
[
|
142 |
+
'plural' => '',
|
143 |
+
'singular' => '',
|
144 |
+
'ajax' => false,
|
145 |
+
'screen' => null,
|
146 |
+
]
|
147 |
+
);
|
148 |
|
149 |
$this->screen = convert_to_screen( $args['screen'] );
|
150 |
|
151 |
+
add_filter( "manage_{$this->screen->id}_columns", [ $this, 'get_columns' ], 0 );
|
152 |
|
153 |
+
if ( ! $args['plural'] ) {
|
154 |
$args['plural'] = $this->screen->base;
|
155 |
+
}
|
156 |
|
157 |
+
$args['plural'] = sanitize_key( $args['plural'] );
|
158 |
$args['singular'] = sanitize_key( $args['singular'] );
|
159 |
|
160 |
$this->_args = $args;
|
161 |
|
162 |
if ( $args['ajax'] ) {
|
163 |
// wp_enqueue_script( 'list-table' );
|
164 |
+
add_action( 'admin_footer', [ $this, '_js_vars' ] );
|
165 |
}
|
166 |
|
167 |
if ( empty( $this->modes ) ) {
|
168 |
+
$this->modes = [
|
169 |
'list' => __( 'List View' ),
|
170 |
+
'excerpt' => __( 'Excerpt View' ),
|
171 |
+
];
|
172 |
}
|
173 |
}
|
174 |
|
239 |
*/
|
240 |
public function __call( $name, $arguments ) {
|
241 |
if ( in_array( $name, $this->compat_methods ) ) {
|
242 |
+
return call_user_func_array( [ $this, $name ], $arguments );
|
243 |
}
|
244 |
return false;
|
245 |
}
|
256 |
|
257 |
/**
|
258 |
* Prepares the list of items for displaying.
|
259 |
+
*
|
260 |
* @uses PUM_ListTable::set_pagination_args()
|
261 |
*
|
262 |
* @since 3.1.0
|
274 |
* @param array|string $args Array or string of arguments with information about the pagination.
|
275 |
*/
|
276 |
protected function set_pagination_args( $args ) {
|
277 |
+
$args = wp_parse_args(
|
278 |
+
$args,
|
279 |
+
[
|
280 |
+
'total_items' => 0,
|
281 |
+
'total_pages' => 0,
|
282 |
+
'per_page' => 0,
|
283 |
+
]
|
284 |
+
);
|
285 |
|
286 |
+
if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
|
287 |
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
|
288 |
+
}
|
289 |
|
290 |
// Redirect if page number is invalid and headers are not already sent.
|
291 |
if ( ! headers_sent() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
|
292 |
+
wp_safe_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
|
293 |
exit;
|
294 |
}
|
295 |
|
310 |
return $this->get_pagenum();
|
311 |
}
|
312 |
|
313 |
+
if ( isset( $this->_pagination_args[ $key ] ) ) {
|
314 |
+
return $this->_pagination_args[ $key ];
|
315 |
}
|
316 |
}
|
317 |
|
323 |
* @return bool
|
324 |
*/
|
325 |
public function has_items() {
|
326 |
+
return ! empty( $this->items );
|
327 |
}
|
328 |
|
329 |
/**
|
344 |
* @param string $input_id ID attribute value for the search input field.
|
345 |
*/
|
346 |
public function search_box( $text, $input_id ) {
|
347 |
+
if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
|
348 |
return;
|
349 |
+
}
|
350 |
|
351 |
$input_id = $input_id . '-search-input';
|
352 |
|
353 |
+
if ( ! empty( $_REQUEST['orderby'] ) ) {
|
354 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
|
355 |
+
}
|
356 |
+
if ( ! empty( $_REQUEST['order'] ) ) {
|
357 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
|
358 |
+
}
|
359 |
+
if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
|
360 |
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
|
361 |
+
}
|
362 |
+
if ( ! empty( $_REQUEST['detached'] ) ) {
|
363 |
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
|
364 |
+
}
|
365 |
+
?>
|
366 |
<p class="search-box">
|
367 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
|
368 |
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
369 |
+
<?php submit_button( $text, '', '', false, [ 'id' => 'search-submit' ] ); ?>
|
370 |
</p>
|
371 |
+
<?php
|
372 |
}
|
373 |
|
374 |
/**
|
380 |
* @return array
|
381 |
*/
|
382 |
protected function get_views() {
|
383 |
+
return [];
|
384 |
}
|
385 |
|
386 |
/**
|
402 |
*/
|
403 |
$views = apply_filters( "views_{$this->screen->id}", $views );
|
404 |
|
405 |
+
if ( empty( $views ) ) {
|
406 |
return;
|
407 |
+
}
|
408 |
|
409 |
$this->screen->render_screen_reader_content( 'heading_views' );
|
410 |
|
413 |
$views[ $class ] = "\t<li class='$class'>$view";
|
414 |
}
|
415 |
echo implode( " |</li>\n", $views ) . "</li>\n";
|
416 |
+
echo '</ul>';
|
417 |
}
|
418 |
|
419 |
/**
|
425 |
* @return array
|
426 |
*/
|
427 |
protected function get_bulk_actions() {
|
428 |
+
return [];
|
429 |
}
|
430 |
|
431 |
/**
|
452 |
* @param array $actions An array of the available bulk actions.
|
453 |
*/
|
454 |
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
|
455 |
+
$two = '';
|
456 |
} else {
|
457 |
$two = '2';
|
458 |
}
|
459 |
|
460 |
+
if ( empty( $this->_actions ) ) {
|
461 |
return;
|
462 |
+
}
|
463 |
|
464 |
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
|
465 |
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
|
473 |
|
474 |
echo "</select>\n";
|
475 |
|
476 |
+
submit_button( __( 'Apply' ), 'action', '', false, [ 'id' => "doaction$two" ] );
|
477 |
echo "\n";
|
478 |
}
|
479 |
|
485 |
* @return string|false The action name or False if no action was selected
|
486 |
*/
|
487 |
public function current_action() {
|
488 |
+
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
|
489 |
return false;
|
490 |
+
}
|
491 |
|
492 |
+
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
|
493 |
return $_REQUEST['action'];
|
494 |
+
}
|
495 |
|
496 |
+
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
|
497 |
return $_REQUEST['action2'];
|
498 |
+
}
|
499 |
|
500 |
return false;
|
501 |
}
|
506 |
* @since 3.1.0
|
507 |
*
|
508 |
* @param array $actions The list of actions
|
509 |
+
* @param bool $always_visible Whether the actions should be always visible
|
510 |
* @return string
|
511 |
*/
|
512 |
protected function row_actions( $actions, $always_visible = false ) {
|
513 |
$action_count = count( $actions );
|
514 |
+
$i = 0;
|
515 |
|
516 |
+
if ( ! $action_count ) {
|
517 |
return '';
|
518 |
+
}
|
519 |
|
520 |
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
521 |
foreach ( $actions as $action => $link ) {
|
522 |
++$i;
|
523 |
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
524 |
+
$out .= "<span class='$action'>$link$sep</span>";
|
525 |
}
|
526 |
$out .= '</div>';
|
527 |
|
562 |
$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
|
563 |
}
|
564 |
|
565 |
+
$months = $wpdb->get_results(
|
566 |
+
$wpdb->prepare(
|
567 |
+
"
|
568 |
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
569 |
FROM $wpdb->posts
|
570 |
WHERE post_type = %s
|
571 |
$extra_checks
|
572 |
ORDER BY post_date DESC
|
573 |
+
",
|
574 |
+
$post_type
|
575 |
+
)
|
576 |
+
);
|
577 |
|
578 |
/**
|
579 |
* Filters the 'Months' drop-down results.
|
587 |
|
588 |
$month_count = count( $months );
|
589 |
|
590 |
+
if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
|
591 |
return;
|
592 |
+
}
|
593 |
|
594 |
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
|
595 |
+
?>
|
596 |
<label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label>
|
597 |
<select name="m" id="filter-by-date">
|
598 |
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
|
599 |
+
<?php
|
600 |
foreach ( $months as $arc_row ) {
|
601 |
+
if ( 0 == $arc_row->year ) {
|
602 |
continue;
|
603 |
+
}
|
604 |
|
605 |
$month = zeroise( $arc_row->month, 2 );
|
606 |
+
$year = $arc_row->year;
|
607 |
|
608 |
+
printf(
|
609 |
+
"<option %s value='%s'>%s</option>\n",
|
610 |
selected( $m, $year . $month, false ),
|
611 |
esc_attr( $arc_row->year . $month ),
|
612 |
/* translators: 1: month name, 2: 4-digit year */
|
613 |
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
614 |
);
|
615 |
}
|
616 |
+
?>
|
617 |
</select>
|
618 |
+
<?php
|
619 |
}
|
620 |
|
621 |
/**
|
626 |
* @param string $current_mode
|
627 |
*/
|
628 |
protected function view_switcher( $current_mode ) {
|
629 |
+
?>
|
630 |
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
631 |
<div class="view-switch">
|
632 |
+
<?php
|
633 |
+
foreach ( $this->modes as $mode => $title ) {
|
634 |
+
$classes = [ 'view-' . $mode ];
|
635 |
+
if ( $current_mode === $mode ) {
|
636 |
+
$classes[] = 'current';
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
}
|
638 |
+
printf(
|
639 |
+
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
|
640 |
+
esc_url( add_query_arg( 'mode', $mode ) ),
|
641 |
+
implode( ' ', $classes ),
|
642 |
+
$title
|
643 |
+
);
|
644 |
+
}
|
645 |
?>
|
646 |
</div>
|
647 |
+
<?php
|
648 |
}
|
649 |
|
650 |
/**
|
659 |
$approved_comments = get_comments_number();
|
660 |
|
661 |
$approved_comments_number = number_format_i18n( $approved_comments );
|
662 |
+
$pending_comments_number = number_format_i18n( $pending_comments );
|
663 |
|
664 |
$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
|
665 |
+
$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
|
666 |
+
$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
|
667 |
|
668 |
// No comments at all.
|
669 |
if ( ! $approved_comments && ! $pending_comments ) {
|
670 |
+
printf(
|
671 |
+
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
672 |
__( 'No comments' )
|
673 |
);
|
674 |
+
// Approved comments have different display depending on some conditions.
|
675 |
} elseif ( $approved_comments ) {
|
676 |
+
printf(
|
677 |
+
'<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
678 |
+
esc_url(
|
679 |
+
add_query_arg(
|
680 |
+
[
|
681 |
+
'p' => $post_id,
|
682 |
+
'comment_status' => 'approved',
|
683 |
+
],
|
684 |
+
admin_url( 'edit-comments.php' )
|
685 |
+
)
|
686 |
+
),
|
687 |
$approved_comments_number,
|
688 |
$pending_comments ? $approved_phrase : $approved_only_phrase
|
689 |
);
|
690 |
} else {
|
691 |
+
printf(
|
692 |
+
'<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
693 |
$approved_comments_number,
|
694 |
$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
|
695 |
);
|
696 |
}
|
697 |
|
698 |
if ( $pending_comments ) {
|
699 |
+
printf(
|
700 |
+
'<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
701 |
+
esc_url(
|
702 |
+
add_query_arg(
|
703 |
+
[
|
704 |
+
'p' => $post_id,
|
705 |
+
'comment_status' => 'moderated',
|
706 |
+
],
|
707 |
+
admin_url( 'edit-comments.php' )
|
708 |
+
)
|
709 |
+
),
|
710 |
$pending_comments_number,
|
711 |
$pending_phrase
|
712 |
);
|
713 |
} else {
|
714 |
+
printf(
|
715 |
+
'<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
716 |
$pending_comments_number,
|
717 |
$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
|
718 |
);
|
729 |
public function get_pagenum() {
|
730 |
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
|
731 |
|
732 |
+
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
|
733 |
$pagenum = $this->_pagination_args['total_pages'];
|
734 |
+
}
|
735 |
|
736 |
return max( 1, $pagenum );
|
737 |
}
|
747 |
*/
|
748 |
protected function get_items_per_page( $option, $default = 20 ) {
|
749 |
$per_page = (int) get_user_option( $option );
|
750 |
+
if ( empty( $per_page ) || $per_page < 1 ) {
|
751 |
$per_page = $default;
|
752 |
+
}
|
753 |
|
754 |
/**
|
755 |
* Filters the number of items to be displayed on each page of the list table.
|
779 |
return;
|
780 |
}
|
781 |
|
782 |
+
$total_items = $this->_pagination_args['total_items'];
|
783 |
+
$total_pages = $this->_pagination_args['total_pages'];
|
784 |
$infinite_scroll = false;
|
785 |
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
|
786 |
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
794 |
|
795 |
$current = $this->get_pagenum();
|
796 |
|
797 |
+
if ( ! function_exists( 'wp_removable_query_args' ) ) {
|
798 |
require_once Popup_Maker::$DIR . 'includes/compatibility/function-wp_removable_query_args.php';
|
799 |
}
|
800 |
|
804 |
|
805 |
$current_url = remove_query_arg( $removable_query_args, $current_url );
|
806 |
|
807 |
+
$page_links = [];
|
808 |
|
809 |
$total_pages_before = '<span class="paging-input">';
|
810 |
$total_pages_after = '</span></span>';
|
811 |
|
812 |
$disable_first = $disable_last = $disable_prev = $disable_next = false;
|
813 |
|
814 |
+
if ( $current == 1 ) {
|
815 |
$disable_first = true;
|
816 |
+
$disable_prev = true;
|
817 |
+
}
|
818 |
if ( $current == 2 ) {
|
819 |
$disable_first = true;
|
820 |
}
|
821 |
+
if ( $current == $total_pages ) {
|
822 |
$disable_last = true;
|
823 |
$disable_next = true;
|
824 |
+
}
|
825 |
if ( $current == $total_pages - 1 ) {
|
826 |
$disable_last = true;
|
827 |
}
|
829 |
if ( $disable_first ) {
|
830 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>';
|
831 |
} else {
|
832 |
+
$page_links[] = sprintf(
|
833 |
+
"<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
834 |
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
835 |
__( 'First page' ),
|
836 |
'«'
|
840 |
if ( $disable_prev ) {
|
841 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>';
|
842 |
} else {
|
843 |
+
$page_links[] = sprintf(
|
844 |
+
"<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
845 |
+
esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
|
846 |
__( 'Previous page' ),
|
847 |
'‹'
|
848 |
);
|
852 |
$html_current_page = $current;
|
853 |
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
|
854 |
} else {
|
855 |
+
$html_current_page = sprintf(
|
856 |
+
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
|
857 |
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
|
858 |
$current,
|
859 |
strlen( $total_pages )
|
860 |
);
|
861 |
}
|
862 |
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
863 |
+
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
|
864 |
|
865 |
if ( $disable_next ) {
|
866 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>';
|
867 |
} else {
|
868 |
+
$page_links[] = sprintf(
|
869 |
+
"<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
870 |
+
esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
|
871 |
__( 'Next page' ),
|
872 |
'›'
|
873 |
);
|
876 |
if ( $disable_last ) {
|
877 |
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>';
|
878 |
} else {
|
879 |
+
$page_links[] = sprintf(
|
880 |
+
"<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
881 |
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
|
882 |
__( 'Last page' ),
|
883 |
'»'
|
926 |
* @return array
|
927 |
*/
|
928 |
protected function get_sortable_columns() {
|
929 |
+
return [];
|
930 |
}
|
931 |
|
932 |
/**
|
938 |
*/
|
939 |
protected function get_default_primary_column_name() {
|
940 |
$columns = $this->get_columns();
|
941 |
+
$column = '';
|
942 |
|
943 |
if ( empty( $columns ) ) {
|
944 |
return $column;
|
983 |
// If the primary column doesn't exist fall back to the
|
984 |
// first non-checkbox column.
|
985 |
if ( ! isset( $columns[ $default ] ) ) {
|
986 |
+
$default = self::get_default_primary_column_name();
|
987 |
}
|
988 |
|
989 |
/**
|
994 |
* @param string $default Column name default for the specific list table, e.g. 'name'.
|
995 |
* @param string $context Screen ID for specific list table, e.g. 'plugins'.
|
996 |
*/
|
997 |
+
$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
|
998 |
|
999 |
if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
|
1000 |
$column = $default;
|
1015 |
if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
|
1016 |
// Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
|
1017 |
// In 4.3, we added a fourth argument for primary column.
|
1018 |
+
$column_headers = [ [], [], [], $this->get_primary_column_name() ];
|
1019 |
foreach ( $this->_column_headers as $key => $value ) {
|
1020 |
$column_headers[ $key ] = $value;
|
1021 |
}
|
1024 |
}
|
1025 |
|
1026 |
$columns = get_column_headers( $this->screen );
|
1027 |
+
$hidden = get_hidden_columns( $this->screen );
|
1028 |
|
1029 |
$sortable_columns = $this->get_sortable_columns();
|
1030 |
/**
|
1039 |
*/
|
1040 |
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
|
1041 |
|
1042 |
+
$sortable = [];
|
1043 |
foreach ( $_sortable as $id => $data ) {
|
1044 |
+
if ( empty( $data ) ) {
|
1045 |
continue;
|
1046 |
+
}
|
1047 |
|
1048 |
$data = (array) $data;
|
1049 |
+
if ( ! isset( $data[1] ) ) {
|
1050 |
$data[1] = false;
|
1051 |
+
}
|
1052 |
|
1053 |
+
$sortable[ $id ] = $data;
|
1054 |
}
|
1055 |
|
1056 |
+
$primary = $this->get_primary_column_name();
|
1057 |
+
$this->_column_headers = [ $columns, $hidden, $sortable, $primary ];
|
1058 |
|
1059 |
return $this->_column_headers;
|
1060 |
}
|
1068 |
*/
|
1069 |
public function get_column_count() {
|
1070 |
list ( $columns, $hidden ) = $this->get_column_info();
|
1071 |
+
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
1072 |
return count( $columns ) - count( $hidden );
|
1073 |
}
|
1074 |
|
1101 |
|
1102 |
if ( ! empty( $columns['cb'] ) ) {
|
1103 |
static $cb_counter = 1;
|
1104 |
+
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
|
1105 |
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
|
1106 |
$cb_counter++;
|
1107 |
}
|
1108 |
|
1109 |
foreach ( $columns as $column_key => $column_display_name ) {
|
1110 |
+
$class = [ 'manage-column', "column-$column_key" ];
|
1111 |
|
1112 |
if ( in_array( $column_key, $hidden ) ) {
|
1113 |
$class[] = 'hidden';
|
1114 |
}
|
1115 |
|
1116 |
+
if ( 'cb' === $column_key ) {
|
1117 |
$class[] = 'check-column';
|
1118 |
+
} elseif ( in_array( $column_key, [ 'posts', 'comments', 'links' ] ) ) {
|
1119 |
$class[] = 'num';
|
1120 |
+
}
|
1121 |
|
1122 |
if ( $column_key === $primary ) {
|
1123 |
$class[] = 'column-primary';
|
1124 |
}
|
1125 |
|
1126 |
+
if ( isset( $sortable[ $column_key ] ) ) {
|
1127 |
+
list( $orderby, $desc_first ) = $sortable[ $column_key ];
|
1128 |
|
1129 |
if ( $current_orderby === $orderby ) {
|
1130 |
+
$order = 'asc' === $current_order ? 'desc' : 'asc';
|
1131 |
$class[] = 'sorted';
|
1132 |
$class[] = $current_order;
|
1133 |
} else {
|
1134 |
+
$order = $desc_first ? 'desc' : 'asc';
|
1135 |
$class[] = 'sortable';
|
1136 |
$class[] = $desc_first ? 'asc' : 'desc';
|
1137 |
}
|
1139 |
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
1140 |
}
|
1141 |
|
1142 |
+
$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
|
1143 |
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
|
1144 |
+
$id = $with_id ? "id='$column_key'" : '';
|
1145 |
|
1146 |
+
if ( ! empty( $class ) ) {
|
1147 |
$class = "class='" . join( ' ', $class ) . "'";
|
1148 |
+
}
|
1149 |
|
1150 |
echo "<$tag $scope $id $class>$column_display_name</$tag>";
|
1151 |
}
|
1162 |
$this->display_tablenav( 'top' );
|
1163 |
|
1164 |
$this->screen->render_screen_reader_content( 'heading_list' );
|
1165 |
+
?>
|
1166 |
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
|
1167 |
<thead>
|
1168 |
<tr>
|
1170 |
</tr>
|
1171 |
</thead>
|
1172 |
|
1173 |
+
<tbody id="the-list"
|
1174 |
+
<?php
|
1175 |
if ( $singular ) {
|
1176 |
echo " data-wp-lists='list:$singular'";
|
1177 |
+
}
|
1178 |
+
?>
|
1179 |
+
>
|
1180 |
<?php $this->display_rows_or_placeholder(); ?>
|
1181 |
</tbody>
|
1182 |
|
1187 |
</tfoot>
|
1188 |
|
1189 |
</table>
|
1190 |
+
<?php
|
1191 |
$this->display_tablenav( 'bottom' );
|
1192 |
}
|
1193 |
|
1199 |
* @return array List of CSS classes for the table tag.
|
1200 |
*/
|
1201 |
protected function get_table_classes() {
|
1202 |
+
return [ 'widefat', 'fixed', 'striped', $this->_args['plural'] ];
|
1203 |
}
|
1204 |
|
1205 |
/**
|
1215 |
?>
|
1216 |
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
1217 |
|
1218 |
+
<?php if ( $this->has_items() ) : ?>
|
1219 |
<div class="alignleft actions bulkactions">
|
1220 |
<?php $this->bulk_actions( $which ); ?>
|
1221 |
</div>
|
1222 |
+
<?php
|
1223 |
+
endif;
|
1224 |
$this->extra_tablenav( $which );
|
1225 |
$this->pagination( $which );
|
1226 |
+
?>
|
1227 |
|
1228 |
<br class="clear" />
|
1229 |
</div>
|
1230 |
+
<?php
|
1231 |
}
|
1232 |
|
1233 |
/**
|
1260 |
* @since 3.1.0
|
1261 |
*/
|
1262 |
public function display_rows() {
|
1263 |
+
foreach ( $this->items as $item ) {
|
1264 |
$this->single_row( $item );
|
1265 |
+
}
|
1266 |
}
|
1267 |
|
1268 |
/**
|
1323 |
echo '</th>';
|
1324 |
} elseif ( method_exists( $this, '_column_' . $column_name ) ) {
|
1325 |
echo call_user_func(
|
1326 |
+
[ $this, '_column_' . $column_name ],
|
1327 |
$item,
|
1328 |
$classes,
|
1329 |
$data,
|
1331 |
);
|
1332 |
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
1333 |
echo "<td $attributes>";
|
1334 |
+
echo call_user_func( [ $this, 'column_' . $column_name ], $item );
|
1335 |
echo $this->handle_row_actions( $item, $column_name, $primary );
|
1336 |
+
echo '</td>';
|
1337 |
} else {
|
1338 |
echo "<td $attributes>";
|
1339 |
echo $this->column_default( $item, $column_name );
|
1340 |
echo $this->handle_row_actions( $item, $column_name, $primary );
|
1341 |
+
echo '</td>';
|
1342 |
}
|
1343 |
}
|
1344 |
}
|
1355 |
*/
|
1356 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
1357 |
return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
|
1358 |
+
}
|
1359 |
|
1360 |
/**
|
1361 |
* Handle an incoming ajax request (called from admin-ajax.php)
|
1374 |
|
1375 |
$rows = ob_get_clean();
|
1376 |
|
1377 |
+
$response = [ 'rows' => $rows ];
|
1378 |
|
1379 |
if ( isset( $this->_pagination_args['total_items'] ) ) {
|
1380 |
$response['total_items_i18n'] = sprintf(
|
1383 |
);
|
1384 |
}
|
1385 |
if ( isset( $this->_pagination_args['total_pages'] ) ) {
|
1386 |
+
$response['total_pages'] = $this->_pagination_args['total_pages'];
|
1387 |
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
|
1388 |
}
|
1389 |
|
1392 |
|
1393 |
/**
|
1394 |
* Send required variables to JavaScript land
|
|
|
1395 |
*/
|
1396 |
public function _js_vars() {
|
1397 |
+
$args = [
|
1398 |
'class' => get_class( $this ),
|
1399 |
+
'screen' => [
|
1400 |
'id' => $this->screen->id,
|
1401 |
'base' => $this->screen->base,
|
1402 |
+
],
|
1403 |
+
];
|
1404 |
|
1405 |
printf( "<script type='text/javascript'>list_args = %s;</script>\n", PUM_Utils_Array::safe_json_encode( $args ) );
|
1406 |
}
|
classes/Model/Popup.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
|
|
|
|
|
5 |
|
6 |
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
exit;
|
@@ -14,13 +16,23 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
*/
|
15 |
class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
16 |
|
17 |
-
/**
|
|
|
|
|
|
|
|
|
18 |
protected $required_post_type = 'popup';
|
19 |
|
20 |
-
/**
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
|
|
|
|
24 |
* @var string
|
25 |
*
|
26 |
* @deprecated 1.8.0 Was used in PUM ALM extension, needs time to get those changes published.
|
@@ -28,7 +40,11 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
28 |
*/
|
29 |
public $content;
|
30 |
|
31 |
-
/**
|
|
|
|
|
|
|
|
|
32 |
public $doing_passive_migration = false;
|
33 |
|
34 |
/**
|
@@ -53,15 +69,19 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
53 |
*/
|
54 |
public $data_version;
|
55 |
|
56 |
-
|
57 |
|
58 |
/**
|
|
|
|
|
59 |
* @var array
|
60 |
* @deprecated 1.7.0
|
61 |
*/
|
62 |
public $display;
|
63 |
|
64 |
/**
|
|
|
|
|
65 |
* @var array
|
66 |
* @deprecated 1.7.0
|
67 |
*/
|
@@ -92,8 +112,10 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
92 |
public $mock = false;
|
93 |
|
94 |
/**
|
95 |
-
*
|
96 |
-
*
|
|
|
|
|
97 |
*
|
98 |
* @return mixed|false
|
99 |
*/
|
@@ -126,7 +148,11 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
126 |
* @return string
|
127 |
*/
|
128 |
public function get_content() {
|
129 |
-
/**
|
|
|
|
|
|
|
|
|
130 |
$this->content = $this->post_content;
|
131 |
|
132 |
return apply_filters( 'pum_popup_content', $this->post_content, $this->ID );
|
@@ -143,7 +169,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
143 |
$settings = isset( $this->settings ) ? $this->settings : $this->get_meta( 'popup_settings' );
|
144 |
|
145 |
if ( ! is_array( $settings ) ) {
|
146 |
-
$settings =
|
147 |
}
|
148 |
|
149 |
// Review: the above should be removed and replaced with a hooked filter here to supply defaults when $settings === false.
|
@@ -156,8 +182,8 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
156 |
/**
|
157 |
* Returns a specific popup setting with optional default value when not found.
|
158 |
*
|
159 |
-
* @param
|
160 |
-
* @param
|
161 |
*
|
162 |
* @return bool|mixed
|
163 |
*/
|
@@ -168,25 +194,29 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
168 |
}
|
169 |
|
170 |
/**
|
171 |
-
*
|
172 |
-
*
|
|
|
|
|
173 |
*
|
174 |
* @return bool|int
|
175 |
*/
|
176 |
public function update_setting( $key, $value ) {
|
177 |
// TODO Once fields have been merged into the model itself, add automatic validation here.
|
178 |
-
$new_settings =
|
179 |
|
180 |
return $this->update_settings( $new_settings, true );
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
-
*
|
185 |
-
*
|
|
|
|
|
186 |
*
|
187 |
* @return bool|int
|
188 |
*/
|
189 |
-
public function update_settings( $new_settings =
|
190 |
$settings = $this->get_settings();
|
191 |
|
192 |
// TODO Once fields have been merged into the model itself, add automatic validation here.
|
@@ -236,9 +266,8 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
236 |
$settings['id'] = $this->ID;
|
237 |
$settings['slug'] = $this->post_name;
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
if ( $this->has_conditions( $filters ) ) {
|
242 |
$settings['conditions'] = $this->get_parsed_js_conditions();
|
243 |
}
|
244 |
|
@@ -277,7 +306,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
277 |
/**
|
278 |
* Check if a given condition is JS based.
|
279 |
*
|
280 |
-
* @param array $condition
|
281 |
*
|
282 |
* @return bool
|
283 |
*/
|
@@ -289,24 +318,28 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
289 |
}
|
290 |
|
291 |
// Bail early with true for conditions that will be processed in JavaScript later.
|
292 |
-
return $condition_args['advanced']
|
293 |
}
|
294 |
|
295 |
/**
|
|
|
|
|
296 |
* @return array
|
297 |
*/
|
298 |
public function get_cookies() {
|
299 |
-
return apply_filters( 'pum_popup_get_cookies', $this->get_setting( 'cookies',
|
300 |
}
|
301 |
|
302 |
/**
|
303 |
-
*
|
|
|
|
|
304 |
*
|
305 |
* @return bool
|
306 |
*/
|
307 |
public function has_cookie( $event ) {
|
308 |
foreach ( (array) $this->get_cookies() as $cookie ) {
|
309 |
-
if ( $cookie['event']
|
310 |
return true;
|
311 |
}
|
312 |
}
|
@@ -315,29 +348,31 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
315 |
}
|
316 |
|
317 |
/**
|
|
|
|
|
318 |
* @return array
|
319 |
*/
|
320 |
public function get_triggers() {
|
321 |
-
$triggers = $this->get_setting( 'triggers',
|
322 |
|
323 |
// Automatically add click trigger when on the front end.
|
324 |
if ( ! is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
325 |
$has_click_trigger = false;
|
326 |
|
327 |
foreach ( $triggers as $trigger ) {
|
328 |
-
if ( $trigger['type']
|
329 |
$has_click_trigger = true;
|
330 |
}
|
331 |
}
|
332 |
|
333 |
if ( ! $has_click_trigger && apply_filters( 'pum_add_default_click_trigger', true, $this->ID ) ) {
|
334 |
-
$triggers[] =
|
335 |
'type' => 'click_open',
|
336 |
-
'settings' =>
|
337 |
'extra_selectors' => '',
|
338 |
'cookie_name' => null,
|
339 |
-
|
340 |
-
|
341 |
}
|
342 |
}
|
343 |
|
@@ -345,7 +380,9 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
345 |
}
|
346 |
|
347 |
/**
|
348 |
-
*
|
|
|
|
|
349 |
*
|
350 |
* @return bool
|
351 |
*/
|
@@ -353,7 +390,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
353 |
$triggers = $this->get_triggers();
|
354 |
|
355 |
foreach ( $triggers as $trigger ) {
|
356 |
-
if ( $trigger['type']
|
357 |
return true;
|
358 |
}
|
359 |
}
|
@@ -378,14 +415,16 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
378 |
/**
|
379 |
* Retrieve settings in the form of deprecated grouped arrays.
|
380 |
*
|
381 |
-
* @
|
382 |
-
*
|
|
|
|
|
383 |
*
|
384 |
* @return mixed
|
385 |
*/
|
386 |
-
protected function
|
387 |
if ( $this->mock ) {
|
388 |
-
return
|
389 |
}
|
390 |
|
391 |
if ( ! $this->$group ) {
|
@@ -398,7 +437,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
398 |
$group_values = $this->get_meta( "popup_$group" );
|
399 |
|
400 |
if ( ! $group_values || ! is_array( $group_values ) ) {
|
401 |
-
$group_values =
|
402 |
}
|
403 |
|
404 |
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
@@ -414,11 +453,9 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
414 |
if ( ! isset( $group_values[ $old_key ] ) ) {
|
415 |
$group_values[ $old_key ] = $value;
|
416 |
}
|
417 |
-
|
418 |
}
|
419 |
}
|
420 |
|
421 |
-
|
422 |
$this->$group = $group_values;
|
423 |
}
|
424 |
|
@@ -428,7 +465,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
428 |
return $values;
|
429 |
}
|
430 |
|
431 |
-
$value = isset
|
432 |
|
433 |
if ( ! isset( $value ) ) {
|
434 |
$value = $this->get_meta( "popup_{$group}_{$key}" );
|
@@ -438,13 +475,15 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
438 |
}
|
439 |
|
440 |
/**
|
441 |
-
*
|
|
|
|
|
442 |
*
|
443 |
* @return array|mixed
|
444 |
*/
|
445 |
public function remapped_meta_settings_keys( $group ) {
|
446 |
-
$remapped_meta_settings_keys =
|
447 |
-
'display' =>
|
448 |
'stackable' => 'stackable',
|
449 |
'overlay_disabled' => 'overlay_disabled',
|
450 |
'scrollable_content' => 'scrollable_content',
|
@@ -471,18 +510,17 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
471 |
'animation_origin' => 'animation_origin',
|
472 |
'overlay_zindex' => 'overlay_zindex',
|
473 |
'zindex' => 'zindex',
|
474 |
-
|
475 |
-
'close' =>
|
476 |
'text' => 'close_text',
|
477 |
'button_delay' => 'close_button_delay',
|
478 |
'overlay_click' => 'close_on_overlay_click',
|
479 |
'esc_press' => 'close_on_esc_press',
|
480 |
'f4_press' => 'close_on_f4_press',
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] : array();
|
485 |
|
|
|
486 |
|
487 |
}
|
488 |
|
@@ -491,20 +529,20 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
491 |
*
|
492 |
* @deprecated 1.7.0 Use get_setting instead.
|
493 |
*
|
494 |
-
* @param string|null $key
|
495 |
*
|
496 |
* @return mixed
|
497 |
*/
|
498 |
public function get_display( $key = null ) {
|
499 |
-
$display = $this->
|
500 |
|
501 |
foreach (
|
502 |
-
|
503 |
'responsive_min_width',
|
504 |
'responsive_max_width',
|
505 |
'custom_width',
|
506 |
'custom_height',
|
507 |
-
|
508 |
) {
|
509 |
$temp = isset( $display[ $key ] ) ? $display[ $key ] : false;
|
510 |
|
@@ -522,12 +560,12 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
522 |
*
|
523 |
* @deprecated 1.7.0 Use get_setting instead.
|
524 |
*
|
525 |
-
* @param string|null $key
|
526 |
*
|
527 |
* @return mixed
|
528 |
*/
|
529 |
public function get_close( $key = null ) {
|
530 |
-
return $this->
|
531 |
}
|
532 |
|
533 |
/**
|
@@ -554,51 +592,57 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
554 |
* @return array $classes
|
555 |
*/
|
556 |
public function get_classes( $element = 'overlay' ) {
|
557 |
-
$classes =
|
558 |
-
'overlay' =>
|
559 |
'pum',
|
560 |
'pum-overlay',
|
561 |
'pum-theme-' . $this->get_theme_id(),
|
562 |
'pum-theme-' . $this->get_theme_slug(),
|
563 |
-
'popmake-overlay', // Backward Compatibility
|
564 |
-
|
565 |
-
'container' =>
|
566 |
'pum-container',
|
567 |
-
'popmake', // Backward Compatibility
|
568 |
-
'theme-' . $this->get_theme_id(), // Backward Compatibility
|
569 |
-
|
570 |
-
'title' =>
|
571 |
'pum-title',
|
572 |
-
'popmake-title', // Backward Compatibility
|
573 |
-
|
574 |
-
'content' =>
|
575 |
'pum-content',
|
576 |
-
'popmake-content', // Backward Compatibility
|
577 |
-
|
578 |
-
'close' =>
|
579 |
'pum-close',
|
580 |
-
'popmake-close' // Backward Compatibility
|
581 |
-
|
582 |
-
|
583 |
|
584 |
$size = $this->get_setting( 'size', 'medium' );
|
585 |
|
586 |
-
if ( in_array( $size,
|
587 |
-
$classes['container'] = array_merge(
|
588 |
-
'
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
|
|
|
|
|
|
595 |
}
|
596 |
|
597 |
if ( ! $this->get_setting( 'custom_height_auto' ) && $this->get_setting( 'scrollable_content' ) ) {
|
598 |
-
$classes['container'] = array_merge(
|
599 |
-
'
|
600 |
-
|
601 |
-
|
|
|
|
|
|
|
602 |
}
|
603 |
|
604 |
if ( $this->get_setting( 'position_fixed' ) ) {
|
@@ -619,7 +663,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
619 |
|
620 |
// Add a class for each trigger type.
|
621 |
foreach ( $this->get_triggers() as $trigger ) {
|
622 |
-
if ( ! in_array( $trigger['type'], $classes['overlay'] ) ) {
|
623 |
$classes['overlay'][] = $trigger['type'];
|
624 |
}
|
625 |
}
|
@@ -628,11 +672,10 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
628 |
$classes['overlay'][] = 'pum-preview';
|
629 |
}
|
630 |
|
631 |
-
|
632 |
$classes = apply_filters( 'pum_popup_classes', $classes, $this->ID );
|
633 |
|
634 |
if ( ! isset( $classes[ $element ] ) ) {
|
635 |
-
$classes[ $element ] =
|
636 |
}
|
637 |
|
638 |
return apply_filters( "pum_popup_{$element}_classes", $classes[ $element ], $this->ID );
|
@@ -650,7 +693,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
650 |
return false;
|
651 |
}
|
652 |
|
653 |
-
$data_attr =
|
654 |
'id' => $this->ID,
|
655 |
'slug' => $this->post_name,
|
656 |
'theme_id' => $this->get_theme_id(),
|
@@ -658,18 +701,17 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
658 |
'triggers' => $this->get_triggers(),
|
659 |
'mobile_disabled' => $this->mobile_disabled() ? true : null,
|
660 |
'tablet_disabled' => $this->tablet_disabled() ? true : null,
|
661 |
-
'meta' =>
|
662 |
'display' => $this->get_display(),
|
663 |
'close' => $this->get_close(),
|
664 |
// Added here for backward compatibility in extensions.
|
665 |
'click_open' => popmake_get_popup_meta( 'click_open', $this->ID ),
|
666 |
-
|
667 |
-
|
668 |
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
$data_attr['conditions'] = $this->get_conditions( $filters );
|
673 |
}
|
674 |
|
675 |
return apply_filters( 'pum_popup_data_attr', $data_attr, $this->ID );
|
@@ -705,30 +747,35 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
705 |
/**
|
706 |
* Get the popups conditions.
|
707 |
*
|
708 |
-
* @param
|
709 |
*
|
710 |
* @return array
|
711 |
*/
|
712 |
-
public function get_conditions( $filters =
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
|
|
|
|
|
|
|
|
|
|
718 |
|
719 |
-
$cache_key = hash( 'md5',
|
720 |
|
721 |
// Check if these exclusion filters have already been applied and prevent extra processing.
|
722 |
$conditions = isset( $this->conditions_filtered[ $cache_key ] ) ? $this->conditions_filtered[ $cache_key ] : false;
|
723 |
|
724 |
if ( ! $conditions ) {
|
725 |
-
$conditions = $this->get_setting( 'conditions',
|
726 |
// Sanity Check on the values not operand value.
|
727 |
foreach ( $conditions as $group_key => $group ) {
|
728 |
|
729 |
foreach ( $group as $key => $condition ) {
|
730 |
|
731 |
-
if ( $this->exclude_condition( $condition, $filters ) ) {
|
732 |
unset( $conditions[ $group_key ][ $key ] );
|
733 |
if ( empty( $conditions[ $group_key ] ) ) {
|
734 |
unset( $conditions[ $group_key ] );
|
@@ -758,16 +805,19 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
758 |
/**
|
759 |
* Ensures condition data integrity.
|
760 |
*
|
761 |
-
* @param $condition
|
762 |
*
|
763 |
* @return array
|
764 |
*/
|
765 |
public function parse_condition( $condition ) {
|
766 |
-
$condition = wp_parse_args(
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
|
|
|
|
|
|
771 |
|
772 |
$condition['not_operand'] = (bool) $condition['not_operand'];
|
773 |
|
@@ -781,12 +831,14 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
781 |
}
|
782 |
|
783 |
/**
|
784 |
-
*
|
785 |
-
*
|
|
|
|
|
786 |
*
|
787 |
* @return bool
|
788 |
*/
|
789 |
-
public function exclude_condition( $condition, $filters =
|
790 |
|
791 |
$exclude = false;
|
792 |
|
@@ -802,9 +854,9 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
802 |
return true;
|
803 |
}
|
804 |
|
805 |
-
if ( $filters['js_only'] && $condition_args['advanced']
|
806 |
return true;
|
807 |
-
} elseif ( $filters['php_only'] && $condition_args['advanced']
|
808 |
return true;
|
809 |
}
|
810 |
|
@@ -814,11 +866,11 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
814 |
/**
|
815 |
* Checks if this popup has any conditions.
|
816 |
*
|
817 |
-
* @param
|
818 |
*
|
819 |
* @return bool
|
820 |
*/
|
821 |
-
public function has_conditions( $filters =
|
822 |
return (bool) count( $this->get_conditions( $filters ) );
|
823 |
}
|
824 |
|
@@ -827,7 +879,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
827 |
*
|
828 |
* Generally used for conditional asset loading.
|
829 |
*
|
830 |
-
* @param
|
831 |
*
|
832 |
* @return bool
|
833 |
*/
|
@@ -840,19 +892,17 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
840 |
$found = false;
|
841 |
|
842 |
if ( ! is_array( $conditions ) ) {
|
843 |
-
$conditions =
|
844 |
}
|
845 |
|
846 |
-
foreach ( $this->get_conditions() as $group
|
847 |
|
848 |
-
foreach ( $
|
849 |
|
850 |
-
if ( in_array( $condition['target'], $conditions ) ) {
|
851 |
$found = true;
|
852 |
}
|
853 |
-
|
854 |
}
|
855 |
-
|
856 |
}
|
857 |
|
858 |
return (bool) $found;
|
@@ -880,7 +930,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
880 |
} else {
|
881 |
// Else, load it in.
|
882 |
$enabled = intval( $enabled );
|
883 |
-
if ( ! in_array( $enabled,
|
884 |
$enabled = 1;
|
885 |
}
|
886 |
}
|
@@ -891,17 +941,6 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
891 |
}
|
892 |
}
|
893 |
|
894 |
-
/**
|
895 |
-
* Check if popup is currently in preview mode.
|
896 |
-
*
|
897 |
-
* @return bool
|
898 |
-
*/
|
899 |
-
public function is_preview() {
|
900 |
-
return isset( $_GET['popup_preview'] )
|
901 |
-
&& isset( $_GET['popup'] )
|
902 |
-
&& $this->ID === absint( $_GET['popup'] );
|
903 |
-
}
|
904 |
-
|
905 |
/**
|
906 |
* Returns whether or not the popup is visible in the loop.
|
907 |
*
|
@@ -914,7 +953,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
914 |
|
915 |
if ( ! $this->ID ) {
|
916 |
return false;
|
917 |
-
// Published/private
|
918 |
}
|
919 |
|
920 |
// If popup is not enabled, this popup is not loadable.
|
@@ -922,12 +961,10 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
922 |
return false;
|
923 |
}
|
924 |
|
925 |
-
$
|
926 |
-
|
927 |
-
if ( $this->has_conditions( $filters ) ) {
|
928 |
|
929 |
// All Groups Must Return True. Break if any is false and set $loadable to false.
|
930 |
-
foreach ( $this->get_conditions(
|
931 |
|
932 |
// Groups are false until a condition proves true.
|
933 |
$group_check = false;
|
@@ -943,7 +980,6 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
943 |
$group_check = true;
|
944 |
break;
|
945 |
}
|
946 |
-
|
947 |
}
|
948 |
|
949 |
// If any group of conditions doesn't pass, popup is not loadable.
|
@@ -951,9 +987,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
951 |
$loadable = false;
|
952 |
break;
|
953 |
}
|
954 |
-
|
955 |
}
|
956 |
-
|
957 |
}
|
958 |
|
959 |
return apply_filters( 'pum_popup_is_loadable', $loadable, $this->ID );
|
@@ -962,11 +996,11 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
962 |
/**
|
963 |
* Check an individual condition with settings.
|
964 |
*
|
965 |
-
* @param array $condition
|
966 |
*
|
967 |
* @return bool
|
968 |
*/
|
969 |
-
public function check_condition( $condition =
|
970 |
$condition_args = PUM_Conditions::instance()->get_condition( $condition['target'] );
|
971 |
|
972 |
if ( ! $condition_args ) {
|
@@ -1004,8 +1038,8 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1004 |
/**
|
1005 |
* Get a popups event count.
|
1006 |
*
|
1007 |
-
* @param string $event
|
1008 |
-
* @param string $which
|
1009 |
*
|
1010 |
* @return int
|
1011 |
*/
|
@@ -1015,7 +1049,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1015 |
$current = $this->get_meta( "popup_{$event}_count" );
|
1016 |
|
1017 |
// Save future queries by inserting a valid count.
|
1018 |
-
if (
|
1019 |
$current = 0;
|
1020 |
$this->update_meta( "popup_{$event}_count", $current );
|
1021 |
}
|
@@ -1025,7 +1059,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1025 |
$total = $this->get_meta( "popup_{$event}_count_total" );
|
1026 |
|
1027 |
// Save future queries by inserting a valid count.
|
1028 |
-
if (
|
1029 |
$total = 0;
|
1030 |
$this->update_meta( "popup_{$event}_count_total", $total );
|
1031 |
}
|
@@ -1039,37 +1073,36 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1039 |
/**
|
1040 |
* Increase popup event counts.
|
1041 |
*
|
1042 |
-
* @param string $event
|
1043 |
*/
|
1044 |
public function increase_event_count( $event = 'open' ) {
|
1045 |
-
|
1046 |
/**
|
1047 |
* This section simply ensures that all keys exist before the below query runs. This should only ever cause extra queries once per popup, usually in the admin.
|
1048 |
*/
|
1049 |
-
//$this->set_event_defaults( $event );
|
1050 |
-
|
1051 |
$keys = PUM_Analytics::event_keys( $event );
|
1052 |
|
1053 |
-
// Set the current count
|
1054 |
$current = $this->get_event_count( $event );
|
1055 |
if ( ! $current ) {
|
1056 |
$current = 0;
|
1057 |
}
|
1058 |
-
|
|
|
1059 |
|
1060 |
// Set the total count since creation.
|
1061 |
$total = $this->get_event_count( $event, 'total' );
|
1062 |
if ( ! $total ) {
|
1063 |
$total = 0;
|
1064 |
}
|
1065 |
-
|
|
|
1066 |
|
1067 |
$this->update_meta( 'popup_' . $keys[0] . '_count', absint( $current ) );
|
1068 |
$this->update_meta( 'popup_' . $keys[0] . '_count_total', absint( $total ) );
|
1069 |
-
$this->update_meta( 'popup_last_' . $keys[1],
|
1070 |
|
1071 |
$site_total = get_option( 'pum_total_' . $keys[0] . '_count', 0 );
|
1072 |
-
$site_total
|
1073 |
update_option( 'pum_total_' . $keys[0] . '_count', $site_total );
|
1074 |
|
1075 |
// If is multisite add this blogs total to the site totals.
|
@@ -1081,7 +1114,9 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1081 |
}
|
1082 |
|
1083 |
/**
|
1084 |
-
*
|
|
|
|
|
1085 |
*/
|
1086 |
public function set_event_defaults( $event ) {
|
1087 |
$this->get_event_count( $event );
|
@@ -1100,13 +1135,17 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1100 |
*/
|
1101 |
public function reset_counts() {
|
1102 |
// Log the reset time and count.
|
1103 |
-
add_post_meta(
|
1104 |
-
|
1105 |
-
'
|
1106 |
-
|
1107 |
-
|
|
|
|
|
|
|
|
|
1108 |
|
1109 |
-
foreach (
|
1110 |
$keys = PUM_Analytics::event_keys( $event );
|
1111 |
$this->update_meta( 'popup_' . $keys[0] . '_count', 0 );
|
1112 |
$this->update_meta( 'popup_last_' . $keys[1], 0 );
|
@@ -1121,7 +1160,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1121 |
public function get_last_count_reset() {
|
1122 |
$resets = $this->get_meta( 'popup_count_reset', false );
|
1123 |
|
1124 |
-
if ( empty
|
1125 |
// No results found.
|
1126 |
return false;
|
1127 |
}
|
@@ -1131,28 +1170,32 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1131 |
return $resets;
|
1132 |
}
|
1133 |
|
1134 |
-
if ( count( $resets )
|
1135 |
// Looks like we only got one result, return it.
|
1136 |
return $resets[0];
|
1137 |
}
|
1138 |
|
1139 |
-
usort( $resets,
|
1140 |
|
1141 |
return $resets[0];
|
1142 |
}
|
1143 |
|
1144 |
/**
|
1145 |
-
*
|
1146 |
-
*
|
|
|
|
|
1147 |
*
|
1148 |
* @return bool
|
1149 |
*/
|
1150 |
public function compare_resets( $a, $b ) {
|
1151 |
-
return (
|
1152 |
}
|
1153 |
|
1154 |
/**
|
1155 |
-
*
|
|
|
|
|
1156 |
*/
|
1157 |
public function setup( $post ) {
|
1158 |
parent::setup( $post );
|
@@ -1193,7 +1236,7 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1193 |
$this->doing_passive_migration = true;
|
1194 |
|
1195 |
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
1196 |
-
do_action_ref_array( 'pum_popup_passive_migration_' . $this->data_version,
|
1197 |
$this->data_version ++;
|
1198 |
|
1199 |
/**
|
@@ -1202,12 +1245,14 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1202 |
$this->update_meta( 'data_version', $this->data_version );
|
1203 |
}
|
1204 |
|
1205 |
-
do_action_ref_array( 'pum_popup_passive_migration',
|
1206 |
|
1207 |
$this->doing_passive_migration = false;
|
1208 |
}
|
1209 |
|
1210 |
/**
|
|
|
|
|
1211 |
* @deprecated 1.7.0 Still used in several extension migration routines, so needs to stay for now.
|
1212 |
*/
|
1213 |
public function save() {
|
@@ -1219,10 +1264,12 @@ class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
|
1219 |
}
|
1220 |
|
1221 |
/**
|
|
|
|
|
1222 |
* @deprecated 1.8.0 Only here to prevent possible errors.
|
1223 |
*
|
1224 |
-
* @param
|
1225 |
-
* @param bool $force
|
1226 |
*
|
1227 |
* @return PUM_Model_Popup
|
1228 |
*/
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Popup model class.
|
4 |
+
*
|
5 |
+
* @package PopupMaker
|
6 |
+
*/
|
7 |
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit;
|
16 |
*/
|
17 |
class PUM_Model_Popup extends PUM_Abstract_Model_Post {
|
18 |
|
19 |
+
/**
|
20 |
+
* Post Type.
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
protected $required_post_type = 'popup';
|
25 |
|
26 |
+
/**
|
27 |
+
* Filtered array of conditions.
|
28 |
+
*
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
public $conditions_filtered = [];
|
32 |
|
33 |
/**
|
34 |
+
* Old content caching, don't use.
|
35 |
+
*
|
36 |
* @var string
|
37 |
*
|
38 |
* @deprecated 1.8.0 Was used in PUM ALM extension, needs time to get those changes published.
|
40 |
*/
|
41 |
public $content;
|
42 |
|
43 |
+
/**
|
44 |
+
* Currently being passively migrated.
|
45 |
+
*
|
46 |
+
* @var bool
|
47 |
+
*/
|
48 |
public $doing_passive_migration = false;
|
49 |
|
50 |
/**
|
69 |
*/
|
70 |
public $data_version;
|
71 |
|
72 |
+
// TODO Remove these once no longer needed.
|
73 |
|
74 |
/**
|
75 |
+
* Don't use!
|
76 |
+
*
|
77 |
* @var array
|
78 |
* @deprecated 1.7.0
|
79 |
*/
|
80 |
public $display;
|
81 |
|
82 |
/**
|
83 |
+
* Don't use!
|
84 |
+
*
|
85 |
* @var array
|
86 |
* @deprecated 1.7.0
|
87 |
*/
|
112 |
public $mock = false;
|
113 |
|
114 |
/**
|
115 |
+
* Get popup meta.
|
116 |
+
*
|
117 |
+
* @param string $key Meta key.
|
118 |
+
* @param bool $single Get single only or multiple values.
|
119 |
*
|
120 |
* @return mixed|false
|
121 |
*/
|
148 |
* @return string
|
149 |
*/
|
150 |
public function get_content() {
|
151 |
+
/**
|
152 |
+
* Do not use!
|
153 |
+
*
|
154 |
+
* @deprecated 1.8.0
|
155 |
+
*/
|
156 |
$this->content = $this->post_content;
|
157 |
|
158 |
return apply_filters( 'pum_popup_content', $this->post_content, $this->ID );
|
169 |
$settings = isset( $this->settings ) ? $this->settings : $this->get_meta( 'popup_settings' );
|
170 |
|
171 |
if ( ! is_array( $settings ) ) {
|
172 |
+
$settings = [];
|
173 |
}
|
174 |
|
175 |
// Review: the above should be removed and replaced with a hooked filter here to supply defaults when $settings === false.
|
182 |
/**
|
183 |
* Returns a specific popup setting with optional default value when not found.
|
184 |
*
|
185 |
+
* @param string $key Setting key.
|
186 |
+
* @param mixed $default Default value if not set.
|
187 |
*
|
188 |
* @return bool|mixed
|
189 |
*/
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
+
* Update popup setting.
|
198 |
+
*
|
199 |
+
* @param string $key Setting key.
|
200 |
+
* @param mixed $value New value.
|
201 |
*
|
202 |
* @return bool|int
|
203 |
*/
|
204 |
public function update_setting( $key, $value ) {
|
205 |
// TODO Once fields have been merged into the model itself, add automatic validation here.
|
206 |
+
$new_settings = [ $key => $value ];
|
207 |
|
208 |
return $this->update_settings( $new_settings, true );
|
209 |
}
|
210 |
|
211 |
/**
|
212 |
+
* Update multiple settings at once.
|
213 |
+
*
|
214 |
+
* @param array $new_settings Array of new setting key=>value pairs.
|
215 |
+
* @param bool $merge Wheher to merge values or replace them.
|
216 |
*
|
217 |
* @return bool|int
|
218 |
*/
|
219 |
+
public function update_settings( $new_settings = [], $merge = true ) {
|
220 |
$settings = $this->get_settings();
|
221 |
|
222 |
// TODO Once fields have been merged into the model itself, add automatic validation here.
|
266 |
$settings['id'] = $this->ID;
|
267 |
$settings['slug'] = $this->post_name;
|
268 |
|
269 |
+
// Pass conditions only if there are JS conditions.
|
270 |
+
if ( $this->has_conditions( [ 'js_only' => true ] ) ) {
|
|
|
271 |
$settings['conditions'] = $this->get_parsed_js_conditions();
|
272 |
}
|
273 |
|
306 |
/**
|
307 |
* Check if a given condition is JS based.
|
308 |
*
|
309 |
+
* @param array $condition Condition to check.
|
310 |
*
|
311 |
* @return bool
|
312 |
*/
|
318 |
}
|
319 |
|
320 |
// Bail early with true for conditions that will be processed in JavaScript later.
|
321 |
+
return true === $condition_args['advanced'];
|
322 |
}
|
323 |
|
324 |
/**
|
325 |
+
* Get popup cookies.
|
326 |
+
*
|
327 |
* @return array
|
328 |
*/
|
329 |
public function get_cookies() {
|
330 |
+
return apply_filters( 'pum_popup_get_cookies', $this->get_setting( 'cookies', [] ), $this->ID );
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
+
* Check if popup has cookie by event.
|
335 |
+
*
|
336 |
+
* @param string $event Event to check for cookie on.
|
337 |
*
|
338 |
* @return bool
|
339 |
*/
|
340 |
public function has_cookie( $event ) {
|
341 |
foreach ( (array) $this->get_cookies() as $cookie ) {
|
342 |
+
if ( $cookie['event'] === $event ) {
|
343 |
return true;
|
344 |
}
|
345 |
}
|
348 |
}
|
349 |
|
350 |
/**
|
351 |
+
* Get popup triggers.
|
352 |
+
*
|
353 |
* @return array
|
354 |
*/
|
355 |
public function get_triggers() {
|
356 |
+
$triggers = $this->get_setting( 'triggers', [] );
|
357 |
|
358 |
// Automatically add click trigger when on the front end.
|
359 |
if ( ! is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
360 |
$has_click_trigger = false;
|
361 |
|
362 |
foreach ( $triggers as $trigger ) {
|
363 |
+
if ( 'click_open' === $trigger['type'] ) {
|
364 |
$has_click_trigger = true;
|
365 |
}
|
366 |
}
|
367 |
|
368 |
if ( ! $has_click_trigger && apply_filters( 'pum_add_default_click_trigger', true, $this->ID ) ) {
|
369 |
+
$triggers[] = [
|
370 |
'type' => 'click_open',
|
371 |
+
'settings' => [
|
372 |
'extra_selectors' => '',
|
373 |
'cookie_name' => null,
|
374 |
+
],
|
375 |
+
];
|
376 |
}
|
377 |
}
|
378 |
|
380 |
}
|
381 |
|
382 |
/**
|
383 |
+
* Check if popup has trigger of type.
|
384 |
+
*
|
385 |
+
* @param string $type Popup trigger type to check for.
|
386 |
*
|
387 |
* @return bool
|
388 |
*/
|
390 |
$triggers = $this->get_triggers();
|
391 |
|
392 |
foreach ( $triggers as $trigger ) {
|
393 |
+
if ( $trigger['type'] === $type ) {
|
394 |
return true;
|
395 |
}
|
396 |
}
|
415 |
/**
|
416 |
* Retrieve settings in the form of deprecated grouped arrays.
|
417 |
*
|
418 |
+
* @deprecated
|
419 |
+
*
|
420 |
+
* @param string $group Old group to fetch settings for.
|
421 |
+
* @param string $key Setting key to retrieve.
|
422 |
*
|
423 |
* @return mixed
|
424 |
*/
|
425 |
+
protected function dep_get_settings_group( $group, $key = null ) {
|
426 |
if ( $this->mock ) {
|
427 |
+
return [];
|
428 |
}
|
429 |
|
430 |
if ( ! $this->$group ) {
|
437 |
$group_values = $this->get_meta( "popup_$group" );
|
438 |
|
439 |
if ( ! $group_values || ! is_array( $group_values ) ) {
|
440 |
+
$group_values = [];
|
441 |
}
|
442 |
|
443 |
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
453 |
if ( ! isset( $group_values[ $old_key ] ) ) {
|
454 |
$group_values[ $old_key ] = $value;
|
455 |
}
|
|
|
456 |
}
|
457 |
}
|
458 |
|
|
|
459 |
$this->$group = $group_values;
|
460 |
}
|
461 |
|
465 |
return $values;
|
466 |
}
|
467 |
|
468 |
+
$value = isset( $values[ $key ] ) ? $values[ $key ] : null;
|
469 |
|
470 |
if ( ! isset( $value ) ) {
|
471 |
$value = $this->get_meta( "popup_{$group}_{$key}" );
|
475 |
}
|
476 |
|
477 |
/**
|
478 |
+
* Get list of remappings for old data.
|
479 |
+
*
|
480 |
+
* @param string $group Group to get values for.
|
481 |
*
|
482 |
* @return array|mixed
|
483 |
*/
|
484 |
public function remapped_meta_settings_keys( $group ) {
|
485 |
+
$remapped_meta_settings_keys = [
|
486 |
+
'display' => [
|
487 |
'stackable' => 'stackable',
|
488 |
'overlay_disabled' => 'overlay_disabled',
|
489 |
'scrollable_content' => 'scrollable_content',
|
510 |
'animation_origin' => 'animation_origin',
|
511 |
'overlay_zindex' => 'overlay_zindex',
|
512 |
'zindex' => 'zindex',
|
513 |
+
],
|
514 |
+
'close' => [
|
515 |
'text' => 'close_text',
|
516 |
'button_delay' => 'close_button_delay',
|
517 |
'overlay_click' => 'close_on_overlay_click',
|
518 |
'esc_press' => 'close_on_esc_press',
|
519 |
'f4_press' => 'close_on_f4_press',
|
520 |
+
],
|
521 |
+
];
|
|
|
|
|
522 |
|
523 |
+
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] : [];
|
524 |
|
525 |
}
|
526 |
|
529 |
*
|
530 |
* @deprecated 1.7.0 Use get_setting instead.
|
531 |
*
|
532 |
+
* @param string|null $key Settings -> Display key to get.
|
533 |
*
|
534 |
* @return mixed
|
535 |
*/
|
536 |
public function get_display( $key = null ) {
|
537 |
+
$display = $this->dep_get_settings_group( 'display', $key );
|
538 |
|
539 |
foreach (
|
540 |
+
[
|
541 |
'responsive_min_width',
|
542 |
'responsive_max_width',
|
543 |
'custom_width',
|
544 |
'custom_height',
|
545 |
+
] as $key => $value
|
546 |
) {
|
547 |
$temp = isset( $display[ $key ] ) ? $display[ $key ] : false;
|
548 |
|
560 |
*
|
561 |
* @deprecated 1.7.0 Use get_setting instead.
|
562 |
*
|
563 |
+
* @param string|null $key Settings key to get.
|
564 |
*
|
565 |
* @return mixed
|
566 |
*/
|
567 |
public function get_close( $key = null ) {
|
568 |
+
return $this->dep_get_settings_group( 'close', $key );
|
569 |
}
|
570 |
|
571 |
/**
|
592 |
* @return array $classes
|
593 |
*/
|
594 |
public function get_classes( $element = 'overlay' ) {
|
595 |
+
$classes = [
|
596 |
+
'overlay' => [
|
597 |
'pum',
|
598 |
'pum-overlay',
|
599 |
'pum-theme-' . $this->get_theme_id(),
|
600 |
'pum-theme-' . $this->get_theme_slug(),
|
601 |
+
'popmake-overlay', // Backward Compatibility.
|
602 |
+
],
|
603 |
+
'container' => [
|
604 |
'pum-container',
|
605 |
+
'popmake', // Backward Compatibility.
|
606 |
+
'theme-' . $this->get_theme_id(), // Backward Compatibility.
|
607 |
+
],
|
608 |
+
'title' => [
|
609 |
'pum-title',
|
610 |
+
'popmake-title', // Backward Compatibility.
|
611 |
+
],
|
612 |
+
'content' => [
|
613 |
'pum-content',
|
614 |
+
'popmake-content', // Backward Compatibility.
|
615 |
+
],
|
616 |
+
'close' => [
|
617 |
'pum-close',
|
618 |
+
'popmake-close', // Backward Compatibility.
|
619 |
+
],
|
620 |
+
];
|
621 |
|
622 |
$size = $this->get_setting( 'size', 'medium' );
|
623 |
|
624 |
+
if ( in_array( $size, [ 'nano', 'micro', 'tiny', 'small', 'medium', 'normal', 'large', 'xlarge' ], true ) ) {
|
625 |
+
$classes['container'] = array_merge(
|
626 |
+
$classes['container'],
|
627 |
+
[
|
628 |
+
'pum-responsive',
|
629 |
+
'pum-responsive-' . $size,
|
630 |
+
'responsive', // Backward Compatibility.
|
631 |
+
'size-' . $size, // Backward Compatibility.
|
632 |
+
]
|
633 |
+
);
|
634 |
+
} elseif ( 'custom' === $size ) {
|
635 |
+
$classes['container'][] = 'size-custom'; // Backward Compatibility.
|
636 |
}
|
637 |
|
638 |
if ( ! $this->get_setting( 'custom_height_auto' ) && $this->get_setting( 'scrollable_content' ) ) {
|
639 |
+
$classes['container'] = array_merge(
|
640 |
+
$classes['container'],
|
641 |
+
[
|
642 |
+
'pum-scrollable',
|
643 |
+
'scrollable', // Backward Compatibility.
|
644 |
+
]
|
645 |
+
);
|
646 |
}
|
647 |
|
648 |
if ( $this->get_setting( 'position_fixed' ) ) {
|
663 |
|
664 |
// Add a class for each trigger type.
|
665 |
foreach ( $this->get_triggers() as $trigger ) {
|
666 |
+
if ( ! in_array( $trigger['type'], $classes['overlay'], true ) ) {
|
667 |
$classes['overlay'][] = $trigger['type'];
|
668 |
}
|
669 |
}
|
672 |
$classes['overlay'][] = 'pum-preview';
|
673 |
}
|
674 |
|
|
|
675 |
$classes = apply_filters( 'pum_popup_classes', $classes, $this->ID );
|
676 |
|
677 |
if ( ! isset( $classes[ $element ] ) ) {
|
678 |
+
$classes[ $element ] = [];
|
679 |
}
|
680 |
|
681 |
return apply_filters( "pum_popup_{$element}_classes", $classes[ $element ], $this->ID );
|
693 |
return false;
|
694 |
}
|
695 |
|
696 |
+
$data_attr = [
|
697 |
'id' => $this->ID,
|
698 |
'slug' => $this->post_name,
|
699 |
'theme_id' => $this->get_theme_id(),
|
701 |
'triggers' => $this->get_triggers(),
|
702 |
'mobile_disabled' => $this->mobile_disabled() ? true : null,
|
703 |
'tablet_disabled' => $this->tablet_disabled() ? true : null,
|
704 |
+
'meta' => [
|
705 |
'display' => $this->get_display(),
|
706 |
'close' => $this->get_close(),
|
707 |
// Added here for backward compatibility in extensions.
|
708 |
'click_open' => popmake_get_popup_meta( 'click_open', $this->ID ),
|
709 |
+
],
|
710 |
+
];
|
711 |
|
712 |
+
// Pass conditions only if there are JS conditions.
|
713 |
+
if ( $this->has_conditions( [ 'js_only' => true ] ) ) {
|
714 |
+
$data_attr['conditions'] = $this->get_parsed_js_conditions();
|
|
|
715 |
}
|
716 |
|
717 |
return apply_filters( 'pum_popup_data_attr', $data_attr, $this->ID );
|
747 |
/**
|
748 |
* Get the popups conditions.
|
749 |
*
|
750 |
+
* @param boolean|string[] $filters Array of condition filters @deprecated 1.16.9.
|
751 |
*
|
752 |
* @return array
|
753 |
*/
|
754 |
+
public function get_conditions( $filters = false ) {
|
755 |
+
|
756 |
+
if ( false !== $filters ) {
|
757 |
+
$filters = wp_parse_args(
|
758 |
+
$filters,
|
759 |
+
[
|
760 |
+
'php_only' => null,
|
761 |
+
'js_only' => null,
|
762 |
+
]
|
763 |
+
);
|
764 |
+
}
|
765 |
|
766 |
+
$cache_key = hash( 'md5', wp_json_encode( $filters ) );
|
767 |
|
768 |
// Check if these exclusion filters have already been applied and prevent extra processing.
|
769 |
$conditions = isset( $this->conditions_filtered[ $cache_key ] ) ? $this->conditions_filtered[ $cache_key ] : false;
|
770 |
|
771 |
if ( ! $conditions ) {
|
772 |
+
$conditions = $this->get_setting( 'conditions', [] );
|
773 |
// Sanity Check on the values not operand value.
|
774 |
foreach ( $conditions as $group_key => $group ) {
|
775 |
|
776 |
foreach ( $group as $key => $condition ) {
|
777 |
|
778 |
+
if ( false !== $filters && $this->exclude_condition( $condition, $filters ) ) {
|
779 |
unset( $conditions[ $group_key ][ $key ] );
|
780 |
if ( empty( $conditions[ $group_key ] ) ) {
|
781 |
unset( $conditions[ $group_key ] );
|
805 |
/**
|
806 |
* Ensures condition data integrity.
|
807 |
*
|
808 |
+
* @param array $condition Condition.
|
809 |
*
|
810 |
* @return array
|
811 |
*/
|
812 |
public function parse_condition( $condition ) {
|
813 |
+
$condition = wp_parse_args(
|
814 |
+
$condition,
|
815 |
+
[
|
816 |
+
'target' => '',
|
817 |
+
'not_operand' => false,
|
818 |
+
'settings' => [],
|
819 |
+
]
|
820 |
+
);
|
821 |
|
822 |
$condition['not_operand'] = (bool) $condition['not_operand'];
|
823 |
|
831 |
}
|
832 |
|
833 |
/**
|
834 |
+
* Check if a given condition should be excluded based on $filters.
|
835 |
+
*
|
836 |
+
* @param array $condition Condition to be checked.
|
837 |
+
* @param string[] $filters Array of filters to be used.
|
838 |
*
|
839 |
* @return bool
|
840 |
*/
|
841 |
+
public function exclude_condition( $condition, $filters = [] ) {
|
842 |
|
843 |
$exclude = false;
|
844 |
|
854 |
return true;
|
855 |
}
|
856 |
|
857 |
+
if ( true !== $filters['js_only'] && $condition_args['advanced'] ) {
|
858 |
return true;
|
859 |
+
} elseif ( false !== $filters['php_only'] && $condition_args['advanced'] ) {
|
860 |
return true;
|
861 |
}
|
862 |
|
866 |
/**
|
867 |
* Checks if this popup has any conditions.
|
868 |
*
|
869 |
+
* @param false|string[] $filters Array of filters to use.
|
870 |
*
|
871 |
* @return bool
|
872 |
*/
|
873 |
+
public function has_conditions( $filters = false ) {
|
874 |
return (bool) count( $this->get_conditions( $filters ) );
|
875 |
}
|
876 |
|
879 |
*
|
880 |
* Generally used for conditional asset loading.
|
881 |
*
|
882 |
+
* @param string[]|string $conditions Array of condition to check for.
|
883 |
*
|
884 |
* @return bool
|
885 |
*/
|
892 |
$found = false;
|
893 |
|
894 |
if ( ! is_array( $conditions ) ) {
|
895 |
+
$conditions = [ $conditions ];
|
896 |
}
|
897 |
|
898 |
+
foreach ( $this->get_conditions() as $group ) {
|
899 |
|
900 |
+
foreach ( $group as $condition ) {
|
901 |
|
902 |
+
if ( in_array( $condition['target'], $conditions, true ) ) {
|
903 |
$found = true;
|
904 |
}
|
|
|
905 |
}
|
|
|
906 |
}
|
907 |
|
908 |
return (bool) $found;
|
930 |
} else {
|
931 |
// Else, load it in.
|
932 |
$enabled = intval( $enabled );
|
933 |
+
if ( ! in_array( $enabled, [ 0, 1 ], true ) ) {
|
934 |
$enabled = 1;
|
935 |
}
|
936 |
}
|
941 |
}
|
942 |
}
|
943 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
944 |
/**
|
945 |
* Returns whether or not the popup is visible in the loop.
|
946 |
*
|
953 |
|
954 |
if ( ! $this->ID ) {
|
955 |
return false;
|
956 |
+
// Published/private.
|
957 |
}
|
958 |
|
959 |
// If popup is not enabled, this popup is not loadable.
|
961 |
return false;
|
962 |
}
|
963 |
|
964 |
+
if ( $this->has_conditions() ) {
|
|
|
|
|
965 |
|
966 |
// All Groups Must Return True. Break if any is false and set $loadable to false.
|
967 |
+
foreach ( $this->get_conditions() as $group => $conditions ) {
|
968 |
|
969 |
// Groups are false until a condition proves true.
|
970 |
$group_check = false;
|
980 |
$group_check = true;
|
981 |
break;
|
982 |
}
|
|
|
983 |
}
|
984 |
|
985 |
// If any group of conditions doesn't pass, popup is not loadable.
|
987 |
$loadable = false;
|
988 |
break;
|
989 |
}
|
|
|
990 |
}
|
|
|
991 |
}
|
992 |
|
993 |
return apply_filters( 'pum_popup_is_loadable', $loadable, $this->ID );
|
996 |
/**
|
997 |
* Check an individual condition with settings.
|
998 |
*
|
999 |
+
* @param array $condition Condition to check.
|
1000 |
*
|
1001 |
* @return bool
|
1002 |
*/
|
1003 |
+
public function check_condition( $condition = [] ) {
|
1004 |
$condition_args = PUM_Conditions::instance()->get_condition( $condition['target'] );
|
1005 |
|
1006 |
if ( ! $condition_args ) {
|
1038 |
/**
|
1039 |
* Get a popups event count.
|
1040 |
*
|
1041 |
+
* @param string $event Event nme.
|
1042 |
+
* @param string $which Which stats to get.
|
1043 |
*
|
1044 |
* @return int
|
1045 |
*/
|
1049 |
$current = $this->get_meta( "popup_{$event}_count" );
|
1050 |
|
1051 |
// Save future queries by inserting a valid count.
|
1052 |
+
if ( false === $current || ! is_numeric( $current ) ) {
|
1053 |
$current = 0;
|
1054 |
$this->update_meta( "popup_{$event}_count", $current );
|
1055 |
}
|
1059 |
$total = $this->get_meta( "popup_{$event}_count_total" );
|
1060 |
|
1061 |
// Save future queries by inserting a valid count.
|
1062 |
+
if ( false === $total || ! is_numeric( $total ) ) {
|
1063 |
$total = 0;
|
1064 |
$this->update_meta( "popup_{$event}_count_total", $total );
|
1065 |
}
|
1073 |
/**
|
1074 |
* Increase popup event counts.
|
1075 |
*
|
1076 |
+
* @param string $event Evet to increase count for.
|
1077 |
*/
|
1078 |
public function increase_event_count( $event = 'open' ) {
|
|
|
1079 |
/**
|
1080 |
* This section simply ensures that all keys exist before the below query runs. This should only ever cause extra queries once per popup, usually in the admin.
|
1081 |
*/
|
|
|
|
|
1082 |
$keys = PUM_Analytics::event_keys( $event );
|
1083 |
|
1084 |
+
// Set the current count.
|
1085 |
$current = $this->get_event_count( $event );
|
1086 |
if ( ! $current ) {
|
1087 |
$current = 0;
|
1088 |
}
|
1089 |
+
|
1090 |
+
++$current;
|
1091 |
|
1092 |
// Set the total count since creation.
|
1093 |
$total = $this->get_event_count( $event, 'total' );
|
1094 |
if ( ! $total ) {
|
1095 |
$total = 0;
|
1096 |
}
|
1097 |
+
|
1098 |
+
++$total;
|
1099 |
|
1100 |
$this->update_meta( 'popup_' . $keys[0] . '_count', absint( $current ) );
|
1101 |
$this->update_meta( 'popup_' . $keys[0] . '_count_total', absint( $total ) );
|
1102 |
+
$this->update_meta( 'popup_last_' . $keys[1], time() );
|
1103 |
|
1104 |
$site_total = get_option( 'pum_total_' . $keys[0] . '_count', 0 );
|
1105 |
+
$site_total++;
|
1106 |
update_option( 'pum_total_' . $keys[0] . '_count', $site_total );
|
1107 |
|
1108 |
// If is multisite add this blogs total to the site totals.
|
1114 |
}
|
1115 |
|
1116 |
/**
|
1117 |
+
* Set event default values.
|
1118 |
+
*
|
1119 |
+
* @param string $event Event name.
|
1120 |
*/
|
1121 |
public function set_event_defaults( $event ) {
|
1122 |
$this->get_event_count( $event );
|
1135 |
*/
|
1136 |
public function reset_counts() {
|
1137 |
// Log the reset time and count.
|
1138 |
+
add_post_meta(
|
1139 |
+
$this->ID,
|
1140 |
+
'popup_count_reset',
|
1141 |
+
[
|
1142 |
+
'timestamp' => time(),
|
1143 |
+
'opens' => absint( $this->get_event_count( 'open', 'current' ) ),
|
1144 |
+
'conversions' => absint( $this->get_event_count( 'conversion', 'current' ) ),
|
1145 |
+
]
|
1146 |
+
);
|
1147 |
|
1148 |
+
foreach ( [ 'open', 'conversion' ] as $event ) {
|
1149 |
$keys = PUM_Analytics::event_keys( $event );
|
1150 |
$this->update_meta( 'popup_' . $keys[0] . '_count', 0 );
|
1151 |
$this->update_meta( 'popup_last_' . $keys[1], 0 );
|
1160 |
public function get_last_count_reset() {
|
1161 |
$resets = $this->get_meta( 'popup_count_reset', false );
|
1162 |
|
1163 |
+
if ( empty( $resets ) ) {
|
1164 |
// No results found.
|
1165 |
return false;
|
1166 |
}
|
1170 |
return $resets;
|
1171 |
}
|
1172 |
|
1173 |
+
if ( count( $resets ) === 1 ) {
|
1174 |
// Looks like we only got one result, return it.
|
1175 |
return $resets[0];
|
1176 |
}
|
1177 |
|
1178 |
+
usort( $resets, [ $this, 'compare_resets' ] );
|
1179 |
|
1180 |
return $resets[0];
|
1181 |
}
|
1182 |
|
1183 |
/**
|
1184 |
+
* Array comparison callback function comparing timestamps.
|
1185 |
+
*
|
1186 |
+
* @param array $a Array with `timestamp` key for comparison.
|
1187 |
+
* @param array $b Array with `timestamp` key for comparison.
|
1188 |
*
|
1189 |
* @return bool
|
1190 |
*/
|
1191 |
public function compare_resets( $a, $b ) {
|
1192 |
+
return (float) $a['timestamp'] < (float) $b['timestamp'];
|
1193 |
}
|
1194 |
|
1195 |
/**
|
1196 |
+
* Setup this popup when instantiated.
|
1197 |
+
*
|
1198 |
+
* @param WP_Post $post WP_Post object.
|
1199 |
*/
|
1200 |
public function setup( $post ) {
|
1201 |
parent::setup( $post );
|
1236 |
$this->doing_passive_migration = true;
|
1237 |
|
1238 |
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
1239 |
+
do_action_ref_array( 'pum_popup_passive_migration_' . $this->data_version, [ &$this ] );
|
1240 |
$this->data_version ++;
|
1241 |
|
1242 |
/**
|
1245 |
$this->update_meta( 'data_version', $this->data_version );
|
1246 |
}
|
1247 |
|
1248 |
+
do_action_ref_array( 'pum_popup_passive_migration', [ &$this, $this->data_version ] );
|
1249 |
|
1250 |
$this->doing_passive_migration = false;
|
1251 |
}
|
1252 |
|
1253 |
/**
|
1254 |
+
* Save unsaved data.
|
1255 |
+
*
|
1256 |
* @deprecated 1.7.0 Still used in several extension migration routines, so needs to stay for now.
|
1257 |
*/
|
1258 |
public function save() {
|
1264 |
}
|
1265 |
|
1266 |
/**
|
1267 |
+
* Get instance of popup model.
|
1268 |
+
*
|
1269 |
* @deprecated 1.8.0 Only here to prevent possible errors.
|
1270 |
*
|
1271 |
+
* @param int $id Popup ID.
|
1272 |
+
* @param bool $force Force load.
|
1273 |
*
|
1274 |
* @return PUM_Model_Popup
|
1275 |
*/
|
classes/Model/Post.php
CHANGED
@@ -12,4 +12,4 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
12 |
*
|
13 |
* @deprecated 1.8.0 Use PUM_Abstract_Model_Post instead.
|
14 |
*/
|
15 |
-
class PUM_Model_Post extends PUM_Abstract_Model_Post {}
|
12 |
*
|
13 |
* @deprecated 1.8.0 Use PUM_Abstract_Model_Post instead.
|
14 |
*/
|
15 |
+
class PUM_Model_Post extends PUM_Abstract_Model_Post {}
|
classes/Model/Theme.php
CHANGED
@@ -54,7 +54,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
54 |
$this->settings = $this->get_meta( 'popup_theme_settings' );
|
55 |
|
56 |
if ( ! is_array( $this->settings ) ) {
|
57 |
-
$this->settings =
|
58 |
}
|
59 |
|
60 |
return apply_filters( 'pum_theme_settings', $this->settings, $this->ID );
|
@@ -93,7 +93,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
93 |
*
|
94 |
* @return bool|int
|
95 |
*/
|
96 |
-
public function update_settings( $merge_settings =
|
97 |
$settings = $this->get_settings();
|
98 |
|
99 |
foreach ( $merge_settings as $key => $value ) {
|
@@ -109,7 +109,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
109 |
* @return array
|
110 |
*/
|
111 |
public function get_google_fonts_used() {
|
112 |
-
$fonts_used =
|
113 |
|
114 |
$settings = $this->get_settings();
|
115 |
|
@@ -145,13 +145,13 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
145 |
*/
|
146 |
public function get_generated_styles() {
|
147 |
|
148 |
-
$styles =
|
149 |
-
'overlay' =>
|
150 |
-
'container' =>
|
151 |
-
'title' =>
|
152 |
-
'content' =>
|
153 |
-
'close' =>
|
154 |
-
|
155 |
|
156 |
/*
|
157 |
* Overlay Styles
|
@@ -163,12 +163,12 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
163 |
/*
|
164 |
* Container Styles
|
165 |
*/
|
166 |
-
$styles['container'] =
|
167 |
'padding' => "{$this->get_setting('container_padding')}px",
|
168 |
'border-radius' => "{$this->get_setting('container_border_radius')}px",
|
169 |
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'container_border_width' ), $this->get_setting( 'container_border_style' ), $this->get_setting( 'container_border_color' ) ),
|
170 |
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'container_boxshadow_horizontal' ), $this->get_setting( 'container_boxshadow_vertical' ), $this->get_setting( 'container_boxshadow_blur' ), $this->get_setting( 'container_boxshadow_spread' ), $this->get_setting( 'container_boxshadow_color' ), $this->get_setting( 'container_boxshadow_opacity' ), $this->get_setting( 'container_boxshadow_inset' ) ),
|
171 |
-
|
172 |
|
173 |
if ( $this->get_setting( 'container_background_color' ) ) {
|
174 |
$styles['container']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'container_background_color' ), $this->get_setting( 'container_background_opacity' ) );
|
@@ -177,7 +177,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
177 |
/*
|
178 |
* Title Styles
|
179 |
*/
|
180 |
-
$styles['title'] =
|
181 |
'color' => $this->get_setting( 'title_font_color' ),
|
182 |
'text-align' => $this->get_setting( 'title_text_align' ),
|
183 |
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'title_textshadow_horizontal' ), $this->get_setting( 'title_textshadow_vertical' ), $this->get_setting( 'title_textshadow_blur' ), $this->get_setting( 'title_textshadow_color' ), $this->get_setting( 'title_textshadow_opacity' ) ),
|
@@ -186,22 +186,22 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
186 |
'font-size' => "{$this->get_setting( 'title_font_size' )}px",
|
187 |
'font-style' => $this->get_setting( 'title_font_style' ),
|
188 |
'line-height' => "{$this->get_setting( 'title_line_height' )}px",
|
189 |
-
|
190 |
|
191 |
/*
|
192 |
* Content Styles
|
193 |
*/
|
194 |
-
$styles['content'] =
|
195 |
'color' => $this->get_setting( 'content_font_color' ),
|
196 |
'font-family' => $this->get_setting( 'content_font_family' ),
|
197 |
'font-weight' => $this->get_setting( 'content_font_weight' ),
|
198 |
'font-style' => $this->get_setting( 'content_font_style' ),
|
199 |
-
|
200 |
|
201 |
/*
|
202 |
* Close Styles
|
203 |
*/
|
204 |
-
$styles['close'] =
|
205 |
'position' => $this->get_setting( 'close_position_outside' ) ? 'fixed' : 'absolute',
|
206 |
'height' => ! $this->get_setting( 'close_height' ) || $this->get_setting( 'close_height' ) <= 0 ? 'auto' : "{$this->get_setting('close_height')}px",
|
207 |
'width' => ! $this->get_setting( 'close_width' ) || $this->get_setting( 'close_width' ) <= 0 ? 'auto' : "{$this->get_setting('close_width')}px",
|
@@ -220,7 +220,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
220 |
'border-radius' => "{$this->get_setting('close_border_radius')}px",
|
221 |
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'close_boxshadow_horizontal' ), $this->get_setting( 'close_boxshadow_vertical' ), $this->get_setting( 'close_boxshadow_blur' ), $this->get_setting( 'close_boxshadow_spread' ), $this->get_setting( 'close_boxshadow_color' ), $this->get_setting( 'close_boxshadow_opacity' ), $this->get_setting( 'close_boxshadow_inset' ) ),
|
222 |
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'close_textshadow_horizontal' ), $this->get_setting( 'close_textshadow_vertical' ), $this->get_setting( 'close_textshadow_blur' ), $this->get_setting( 'close_textshadow_color' ), $this->get_setting( 'close_textshadow_opacity' ) ),
|
223 |
-
|
224 |
|
225 |
if ( $this->get_setting( 'close_background_color' ) ) {
|
226 |
$styles['close']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'close_background_color' ), $this->get_setting( 'close_background_opacity' ) );
|
@@ -232,39 +232,39 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
232 |
$bottom = "{$this->get_setting('close_position_bottom')}px";
|
233 |
|
234 |
switch ( $this->get_setting( 'close_location' ) ) {
|
235 |
-
case
|
236 |
$styles['close']['top'] = $top;
|
237 |
$styles['close']['left'] = $left;
|
238 |
break;
|
239 |
-
case
|
240 |
$styles['close']['top'] = $top;
|
241 |
-
$styles['close']['left'] =
|
242 |
-
$styles['close']['transform'] =
|
243 |
break;
|
244 |
-
case
|
245 |
$styles['close']['top'] = $top;
|
246 |
$styles['close']['right'] = $right;
|
247 |
break;
|
248 |
case 'middleleft':
|
249 |
-
$styles['close']['top'] =
|
250 |
$styles['close']['left'] = $left;
|
251 |
-
$styles['close']['transform'] =
|
252 |
break;
|
253 |
case 'middleright':
|
254 |
-
$styles['close']['top'] =
|
255 |
$styles['close']['right'] = $right;
|
256 |
-
$styles['close']['transform'] =
|
257 |
break;
|
258 |
-
case
|
259 |
$styles['close']['bottom'] = $bottom;
|
260 |
$styles['close']['left'] = $left;
|
261 |
break;
|
262 |
-
case
|
263 |
$styles['close']['bottom'] = $bottom;
|
264 |
-
$styles['close']['left'] =
|
265 |
-
$styles['close']['transform'] =
|
266 |
break;
|
267 |
-
case
|
268 |
$styles['close']['bottom'] = $bottom;
|
269 |
$styles['close']['right'] = $right;
|
270 |
break;
|
@@ -277,20 +277,20 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
277 |
}
|
278 |
|
279 |
public function get_deprecated_settings() {
|
280 |
-
return
|
281 |
'overlay' => $this->_dep_get_settings_group( 'overlay' ),
|
282 |
'container' => $this->_dep_get_settings_group( 'container' ),
|
283 |
'title' => $this->_dep_get_settings_group( 'title' ),
|
284 |
'content' => $this->_dep_get_settings_group( 'content' ),
|
285 |
'close' => $this->_dep_get_settings_group( 'close' ),
|
286 |
-
|
287 |
}
|
288 |
|
289 |
/**
|
290 |
* Retrieve settings in the form of deprecated grouped arrays.
|
291 |
*
|
292 |
* @param $group
|
293 |
-
* @param null
|
294 |
*
|
295 |
* @return mixed
|
296 |
*/
|
@@ -305,7 +305,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
305 |
$group_values = $this->get_meta( "popup_theme_$group" );
|
306 |
|
307 |
if ( ! $group_values || ! is_array( $group_values ) ) {
|
308 |
-
$group_values =
|
309 |
}
|
310 |
|
311 |
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
@@ -321,11 +321,9 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
321 |
if ( ! isset( $group_values[ $old_key ] ) ) {
|
322 |
$group_values[ $old_key ] = $value;
|
323 |
}
|
324 |
-
|
325 |
}
|
326 |
}
|
327 |
|
328 |
-
|
329 |
$this->$group = $group_values;
|
330 |
}
|
331 |
|
@@ -335,7 +333,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
335 |
return $values;
|
336 |
}
|
337 |
|
338 |
-
$value = isset
|
339 |
|
340 |
if ( ! isset( $value ) ) {
|
341 |
$value = $this->get_meta( "popup_theme_{$group}_{$key}" );
|
@@ -350,12 +348,12 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
350 |
* @return array|mixed
|
351 |
*/
|
352 |
public function remapped_meta_settings_keys( $group ) {
|
353 |
-
$remapped_meta_settings_keys =
|
354 |
-
'overlay' =>
|
355 |
'background_color' => 'overlay_background_color',
|
356 |
'background_opacity' => 'overlay_background_opacity',
|
357 |
-
|
358 |
-
'container' =>
|
359 |
'padding' => 'container_padding',
|
360 |
'background_color' => 'container_background_color',
|
361 |
'background_opacity' => 'container_background_opacity',
|
@@ -370,8 +368,8 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
370 |
'boxshadow_spread' => 'container_boxshadow_spread',
|
371 |
'boxshadow_color' => 'container_boxshadow_color',
|
372 |
'boxshadow_opacity' => 'container_boxshadow_opacity',
|
373 |
-
|
374 |
-
'title' =>
|
375 |
'font_color' => 'title_font_color',
|
376 |
'line_height' => 'title_line_height',
|
377 |
'font_size' => 'title_font_size',
|
@@ -384,14 +382,14 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
384 |
'textshadow_blur' => 'title_textshadow_blur',
|
385 |
'textshadow_color' => 'title_textshadow_color',
|
386 |
'textshadow_opacity' => 'title_textshadow_opacity',
|
387 |
-
|
388 |
-
'content' =>
|
389 |
'font_color' => 'content_font_color',
|
390 |
'font_family' => 'content_font_family',
|
391 |
'font_weight' => 'content_font_weight',
|
392 |
'font_style' => 'content_font_style',
|
393 |
-
|
394 |
-
'close' =>
|
395 |
'text' => 'close_text',
|
396 |
'location' => 'close_location',
|
397 |
'position_top' => 'close_position_top',
|
@@ -425,10 +423,10 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
425 |
'textshadow_blur' => 'close_textshadow_blur',
|
426 |
'textshadow_color' => 'close_textshadow_color',
|
427 |
'textshadow_opacity' => 'close_textshadow_opacity',
|
428 |
-
|
429 |
-
|
430 |
|
431 |
-
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] :
|
432 |
}
|
433 |
|
434 |
/**
|
@@ -456,7 +454,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
456 |
// Otherwise set to the current version as this is a new popup.
|
457 |
if ( ! empty( $theme_overlay_v1 ) ) {
|
458 |
$this->data_version = 1;
|
459 |
-
}
|
460 |
$this->data_version = 2;
|
461 |
} else {
|
462 |
$this->data_version = $this->model_version;
|
@@ -482,7 +480,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
482 |
|
483 |
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
484 |
// Process migration for current version. ex. current version is 2, runs pum_theme_passive_migration_2.
|
485 |
-
do_action_ref_array( 'pum_theme_passive_migration_' . $this->data_version,
|
486 |
$this->data_version ++;
|
487 |
|
488 |
/**
|
@@ -491,7 +489,7 @@ class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
|
491 |
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
492 |
}
|
493 |
|
494 |
-
do_action_ref_array( 'pum_theme_passive_migration',
|
495 |
|
496 |
$this->doing_passive_migration = false;
|
497 |
}
|
54 |
$this->settings = $this->get_meta( 'popup_theme_settings' );
|
55 |
|
56 |
if ( ! is_array( $this->settings ) ) {
|
57 |
+
$this->settings = [];
|
58 |
}
|
59 |
|
60 |
return apply_filters( 'pum_theme_settings', $this->settings, $this->ID );
|
93 |
*
|
94 |
* @return bool|int
|
95 |
*/
|
96 |
+
public function update_settings( $merge_settings = [] ) {
|
97 |
$settings = $this->get_settings();
|
98 |
|
99 |
foreach ( $merge_settings as $key => $value ) {
|
109 |
* @return array
|
110 |
*/
|
111 |
public function get_google_fonts_used() {
|
112 |
+
$fonts_used = [];
|
113 |
|
114 |
$settings = $this->get_settings();
|
115 |
|
145 |
*/
|
146 |
public function get_generated_styles() {
|
147 |
|
148 |
+
$styles = [
|
149 |
+
'overlay' => [],
|
150 |
+
'container' => [],
|
151 |
+
'title' => [],
|
152 |
+
'content' => [],
|
153 |
+
'close' => [],
|
154 |
+
];
|
155 |
|
156 |
/*
|
157 |
* Overlay Styles
|
163 |
/*
|
164 |
* Container Styles
|
165 |
*/
|
166 |
+
$styles['container'] = [
|
167 |
'padding' => "{$this->get_setting('container_padding')}px",
|
168 |
'border-radius' => "{$this->get_setting('container_border_radius')}px",
|
169 |
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'container_border_width' ), $this->get_setting( 'container_border_style' ), $this->get_setting( 'container_border_color' ) ),
|
170 |
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'container_boxshadow_horizontal' ), $this->get_setting( 'container_boxshadow_vertical' ), $this->get_setting( 'container_boxshadow_blur' ), $this->get_setting( 'container_boxshadow_spread' ), $this->get_setting( 'container_boxshadow_color' ), $this->get_setting( 'container_boxshadow_opacity' ), $this->get_setting( 'container_boxshadow_inset' ) ),
|
171 |
+
];
|
172 |
|
173 |
if ( $this->get_setting( 'container_background_color' ) ) {
|
174 |
$styles['container']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'container_background_color' ), $this->get_setting( 'container_background_opacity' ) );
|
177 |
/*
|
178 |
* Title Styles
|
179 |
*/
|
180 |
+
$styles['title'] = [
|
181 |
'color' => $this->get_setting( 'title_font_color' ),
|
182 |
'text-align' => $this->get_setting( 'title_text_align' ),
|
183 |
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'title_textshadow_horizontal' ), $this->get_setting( 'title_textshadow_vertical' ), $this->get_setting( 'title_textshadow_blur' ), $this->get_setting( 'title_textshadow_color' ), $this->get_setting( 'title_textshadow_opacity' ) ),
|
186 |
'font-size' => "{$this->get_setting( 'title_font_size' )}px",
|
187 |
'font-style' => $this->get_setting( 'title_font_style' ),
|
188 |
'line-height' => "{$this->get_setting( 'title_line_height' )}px",
|
189 |
+
];
|
190 |
|
191 |
/*
|
192 |
* Content Styles
|
193 |
*/
|
194 |
+
$styles['content'] = [
|
195 |
'color' => $this->get_setting( 'content_font_color' ),
|
196 |
'font-family' => $this->get_setting( 'content_font_family' ),
|
197 |
'font-weight' => $this->get_setting( 'content_font_weight' ),
|
198 |
'font-style' => $this->get_setting( 'content_font_style' ),
|
199 |
+
];
|
200 |
|
201 |
/*
|
202 |
* Close Styles
|
203 |
*/
|
204 |
+
$styles['close'] = [
|
205 |
'position' => $this->get_setting( 'close_position_outside' ) ? 'fixed' : 'absolute',
|
206 |
'height' => ! $this->get_setting( 'close_height' ) || $this->get_setting( 'close_height' ) <= 0 ? 'auto' : "{$this->get_setting('close_height')}px",
|
207 |
'width' => ! $this->get_setting( 'close_width' ) || $this->get_setting( 'close_width' ) <= 0 ? 'auto' : "{$this->get_setting('close_width')}px",
|
220 |
'border-radius' => "{$this->get_setting('close_border_radius')}px",
|
221 |
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'close_boxshadow_horizontal' ), $this->get_setting( 'close_boxshadow_vertical' ), $this->get_setting( 'close_boxshadow_blur' ), $this->get_setting( 'close_boxshadow_spread' ), $this->get_setting( 'close_boxshadow_color' ), $this->get_setting( 'close_boxshadow_opacity' ), $this->get_setting( 'close_boxshadow_inset' ) ),
|
222 |
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'close_textshadow_horizontal' ), $this->get_setting( 'close_textshadow_vertical' ), $this->get_setting( 'close_textshadow_blur' ), $this->get_setting( 'close_textshadow_color' ), $this->get_setting( 'close_textshadow_opacity' ) ),
|
223 |
+
];
|
224 |
|
225 |
if ( $this->get_setting( 'close_background_color' ) ) {
|
226 |
$styles['close']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'close_background_color' ), $this->get_setting( 'close_background_opacity' ) );
|
232 |
$bottom = "{$this->get_setting('close_position_bottom')}px";
|
233 |
|
234 |
switch ( $this->get_setting( 'close_location' ) ) {
|
235 |
+
case 'topleft':
|
236 |
$styles['close']['top'] = $top;
|
237 |
$styles['close']['left'] = $left;
|
238 |
break;
|
239 |
+
case 'topcenter':
|
240 |
$styles['close']['top'] = $top;
|
241 |
+
$styles['close']['left'] = '50%';
|
242 |
+
$styles['close']['transform'] = 'translateX(-50%)';
|
243 |
break;
|
244 |
+
case 'topright':
|
245 |
$styles['close']['top'] = $top;
|
246 |
$styles['close']['right'] = $right;
|
247 |
break;
|
248 |
case 'middleleft':
|
249 |
+
$styles['close']['top'] = '50%';
|
250 |
$styles['close']['left'] = $left;
|
251 |
+
$styles['close']['transform'] = 'translate(0, -50%)';
|
252 |
break;
|
253 |
case 'middleright':
|
254 |
+
$styles['close']['top'] = '50%';
|
255 |
$styles['close']['right'] = $right;
|
256 |
+
$styles['close']['transform'] = 'translate(0, -50%)';
|
257 |
break;
|
258 |
+
case 'bottomleft':
|
259 |
$styles['close']['bottom'] = $bottom;
|
260 |
$styles['close']['left'] = $left;
|
261 |
break;
|
262 |
+
case 'bottomcenter':
|
263 |
$styles['close']['bottom'] = $bottom;
|
264 |
+
$styles['close']['left'] = '50%';
|
265 |
+
$styles['close']['transform'] = 'translateX(-50%)';
|
266 |
break;
|
267 |
+
case 'bottomright':
|
268 |
$styles['close']['bottom'] = $bottom;
|
269 |
$styles['close']['right'] = $right;
|
270 |
break;
|
277 |
}
|
278 |
|
279 |
public function get_deprecated_settings() {
|
280 |
+
return [
|
281 |
'overlay' => $this->_dep_get_settings_group( 'overlay' ),
|
282 |
'container' => $this->_dep_get_settings_group( 'container' ),
|
283 |
'title' => $this->_dep_get_settings_group( 'title' ),
|
284 |
'content' => $this->_dep_get_settings_group( 'content' ),
|
285 |
'close' => $this->_dep_get_settings_group( 'close' ),
|
286 |
+
];
|
287 |
}
|
288 |
|
289 |
/**
|
290 |
* Retrieve settings in the form of deprecated grouped arrays.
|
291 |
*
|
292 |
* @param $group
|
293 |
+
* @param null $key
|
294 |
*
|
295 |
* @return mixed
|
296 |
*/
|
305 |
$group_values = $this->get_meta( "popup_theme_$group" );
|
306 |
|
307 |
if ( ! $group_values || ! is_array( $group_values ) ) {
|
308 |
+
$group_values = [];
|
309 |
}
|
310 |
|
311 |
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
321 |
if ( ! isset( $group_values[ $old_key ] ) ) {
|
322 |
$group_values[ $old_key ] = $value;
|
323 |
}
|
|
|
324 |
}
|
325 |
}
|
326 |
|
|
|
327 |
$this->$group = $group_values;
|
328 |
}
|
329 |
|
333 |
return $values;
|
334 |
}
|
335 |
|
336 |
+
$value = isset( $values[ $key ] ) ? $values[ $key ] : null;
|
337 |
|
338 |
if ( ! isset( $value ) ) {
|
339 |
$value = $this->get_meta( "popup_theme_{$group}_{$key}" );
|
348 |
* @return array|mixed
|
349 |
*/
|
350 |
public function remapped_meta_settings_keys( $group ) {
|
351 |
+
$remapped_meta_settings_keys = [
|
352 |
+
'overlay' => [
|
353 |
'background_color' => 'overlay_background_color',
|
354 |
'background_opacity' => 'overlay_background_opacity',
|
355 |
+
],
|
356 |
+
'container' => [
|
357 |
'padding' => 'container_padding',
|
358 |
'background_color' => 'container_background_color',
|
359 |
'background_opacity' => 'container_background_opacity',
|
368 |
'boxshadow_spread' => 'container_boxshadow_spread',
|
369 |
'boxshadow_color' => 'container_boxshadow_color',
|
370 |
'boxshadow_opacity' => 'container_boxshadow_opacity',
|
371 |
+
],
|
372 |
+
'title' => [
|
373 |
'font_color' => 'title_font_color',
|
374 |
'line_height' => 'title_line_height',
|
375 |
'font_size' => 'title_font_size',
|
382 |
'textshadow_blur' => 'title_textshadow_blur',
|
383 |
'textshadow_color' => 'title_textshadow_color',
|
384 |
'textshadow_opacity' => 'title_textshadow_opacity',
|
385 |
+
],
|
386 |
+
'content' => [
|
387 |
'font_color' => 'content_font_color',
|
388 |
'font_family' => 'content_font_family',
|
389 |
'font_weight' => 'content_font_weight',
|
390 |
'font_style' => 'content_font_style',
|
391 |
+
],
|
392 |
+
'close' => [
|
393 |
'text' => 'close_text',
|
394 |
'location' => 'close_location',
|
395 |
'position_top' => 'close_position_top',
|
423 |
'textshadow_blur' => 'close_textshadow_blur',
|
424 |
'textshadow_color' => 'close_textshadow_color',
|
425 |
'textshadow_opacity' => 'close_textshadow_opacity',
|
426 |
+
],
|
427 |
+
];
|
428 |
|
429 |
+
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] : [];
|
430 |
}
|
431 |
|
432 |
/**
|
454 |
// Otherwise set to the current version as this is a new popup.
|
455 |
if ( ! empty( $theme_overlay_v1 ) ) {
|
456 |
$this->data_version = 1;
|
457 |
+
} elseif ( ! empty( $theme_overlay_v2 ) && is_array( $theme_overlay_v2 ) ) {
|
458 |
$this->data_version = 2;
|
459 |
} else {
|
460 |
$this->data_version = $this->model_version;
|
480 |
|
481 |
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
482 |
// Process migration for current version. ex. current version is 2, runs pum_theme_passive_migration_2.
|
483 |
+
do_action_ref_array( 'pum_theme_passive_migration_' . $this->data_version, [ &$this ] );
|
484 |
$this->data_version ++;
|
485 |
|
486 |
/**
|
489 |
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
490 |
}
|
491 |
|
492 |
+
do_action_ref_array( 'pum_theme_passive_migration', [ &$this, $this->data_version ] );
|
493 |
|
494 |
$this->doing_passive_migration = false;
|
495 |
}
|
classes/Newsletter/Provider.php
CHANGED
@@ -18,9 +18,9 @@ abstract class PUM_Newsletter_Provider extends PUM_Abstract_Provider {
|
|
18 |
public function __construct() {
|
19 |
parent::__construct();
|
20 |
|
21 |
-
remove_filter( 'pum_settings_fields',
|
22 |
-
add_filter( 'pum_settings_fields',
|
23 |
-
//add_filter( 'pum_newsletter_settings', array( $this, 'register_settings' ) );
|
24 |
}
|
25 |
|
26 |
/**
|
18 |
public function __construct() {
|
19 |
parent::__construct();
|
20 |
|
21 |
+
remove_filter( 'pum_settings_fields', [ $this, 'register_settings' ] );
|
22 |
+
add_filter( 'pum_settings_fields', [ $this, 'process_deprecated_settings_fields' ] );
|
23 |
+
// add_filter( 'pum_newsletter_settings', array( $this, 'register_settings' ) );
|
24 |
}
|
25 |
|
26 |
/**
|
classes/Newsletter/Providers.php
CHANGED
@@ -22,14 +22,14 @@ class PUM_Newsletter_Providers {
|
|
22 |
/**
|
23 |
* @var array
|
24 |
*/
|
25 |
-
public $providers =
|
26 |
|
27 |
/**
|
28 |
* @return PUM_Newsletter_Providers
|
29 |
*/
|
30 |
public static function instance() {
|
31 |
if ( ! isset( self::$instance ) ) {
|
32 |
-
self::$instance = new self;
|
33 |
}
|
34 |
|
35 |
return self::$instance;
|
@@ -47,7 +47,7 @@ class PUM_Newsletter_Providers {
|
|
47 |
}
|
48 |
|
49 |
public static function selectlist() {
|
50 |
-
$selectlist =
|
51 |
|
52 |
foreach ( self::instance()->get_providers() as $id => $provider ) {
|
53 |
$selectlist[ $provider->name ] = $id;
|
@@ -61,7 +61,7 @@ class PUM_Newsletter_Providers {
|
|
61 |
*/
|
62 |
public static function dropdown_list() {
|
63 |
$providers = self::instance()->get_providers();
|
64 |
-
$list
|
65 |
|
66 |
foreach ( $providers as $id => $provider ) {
|
67 |
$list[ $id ] = $provider->name;
|
22 |
/**
|
23 |
* @var array
|
24 |
*/
|
25 |
+
public $providers = [];
|
26 |
|
27 |
/**
|
28 |
* @return PUM_Newsletter_Providers
|
29 |
*/
|
30 |
public static function instance() {
|
31 |
if ( ! isset( self::$instance ) ) {
|
32 |
+
self::$instance = new self();
|
33 |
}
|
34 |
|
35 |
return self::$instance;
|
47 |
}
|
48 |
|
49 |
public static function selectlist() {
|
50 |
+
$selectlist = [];
|
51 |
|
52 |
foreach ( self::instance()->get_providers() as $id => $provider ) {
|
53 |
$selectlist[ $provider->name ] = $id;
|
61 |
*/
|
62 |
public static function dropdown_list() {
|
63 |
$providers = self::instance()->get_providers();
|
64 |
+
$list = [];
|
65 |
|
66 |
foreach ( $providers as $id => $provider ) {
|
67 |
$list[ $id ] = $provider->name;
|
classes/Newsletters.php
CHANGED
@@ -18,7 +18,7 @@ class PUM_Newsletters {
|
|
18 |
|
19 |
public static function init() {
|
20 |
if ( doing_action( 'plugins_loaded' ) || ! did_action( 'plugins_loaded' ) ) {
|
21 |
-
add_action( 'plugins_loaded',
|
22 |
} else {
|
23 |
self::delayed_init();
|
24 |
}
|
@@ -28,11 +28,14 @@ class PUM_Newsletters {
|
|
28 |
// TODO Once PUM-Aweber has been updated properly for a few months remove these if checks.
|
29 |
// TODO Consider adding notice to update aweber.
|
30 |
|
31 |
-
self::$disabled = in_array(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
// Checks for single very specific versions.
|
38 |
if ( self::$disabled ) {
|
@@ -45,21 +48,21 @@ class PUM_Newsletters {
|
|
45 |
|
46 |
PUM_Shortcode_Subscribe::init();
|
47 |
|
48 |
-
add_action( 'wp_ajax_pum_sub_form',
|
49 |
-
add_action( 'wp_ajax_nopriv_pum_sub_form',
|
50 |
|
51 |
-
add_filter( 'pum_sub_form_sanitization',
|
52 |
-
add_filter( 'pum_sub_form_validation',
|
53 |
-
add_action( 'pum_sub_form_success',
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
* Submits the form using ajax
|
58 |
*/
|
59 |
public static function ajax_request() {
|
60 |
-
self::$errors = new WP_Error;
|
61 |
|
62 |
-
$values = isset( $_REQUEST['values'] ) ? $_REQUEST['values'] :
|
63 |
|
64 |
if ( empty( $values['popup_id'] ) && ! empty( $values['pum_form_popup_id'] ) ) {
|
65 |
$values['popup_id'] = absint( $values['pum_form_popup_id'] );
|
@@ -80,10 +83,10 @@ class PUM_Newsletters {
|
|
80 |
self::send_errors( self::$errors );
|
81 |
}
|
82 |
|
83 |
-
$response =
|
84 |
|
85 |
// Process the submission and pass the $response array as a reference variable so data can be added..
|
86 |
-
do_action_ref_array( 'pum_sub_form_submission',
|
87 |
|
88 |
$error_code = self::$errors->get_error_code();
|
89 |
|
@@ -107,7 +110,7 @@ class PUM_Newsletters {
|
|
107 |
$response['already_subscribed'] = true;
|
108 |
}
|
109 |
|
110 |
-
$response[
|
111 |
self::send_success( $response );
|
112 |
}
|
113 |
// Don't let it keep going.
|
@@ -120,16 +123,19 @@ class PUM_Newsletters {
|
|
120 |
* Optionally pass extra data to send back to front end.
|
121 |
*
|
122 |
* @param $errors WP_Error
|
123 |
-
* @param array
|
124 |
*/
|
125 |
-
public static function send_errors( WP_Error $errors, $extra_response_args =
|
126 |
if ( ! $errors || ! is_wp_error( $errors ) ) {
|
127 |
$errors = self::$errors;
|
128 |
}
|
129 |
|
130 |
-
$response = array_merge(
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
133 |
|
134 |
wp_send_json_error( $response );
|
135 |
|
@@ -141,7 +147,7 @@ class PUM_Newsletters {
|
|
141 |
*
|
142 |
* @param array|mixed $response
|
143 |
*/
|
144 |
-
public static function send_success( $response =
|
145 |
wp_send_json_success( array_filter( $response ) );
|
146 |
die;
|
147 |
}
|
@@ -158,14 +164,14 @@ class PUM_Newsletters {
|
|
158 |
$_errors = self::$errors;
|
159 |
}
|
160 |
|
161 |
-
$errors =
|
162 |
|
163 |
foreach ( $_errors->get_error_codes() as $code ) {
|
164 |
-
$errors[] =
|
165 |
'code' => $code,
|
166 |
'field' => $_errors->get_error_data( $code ),
|
167 |
'message' => $_errors->get_error_message( $code ),
|
168 |
-
|
169 |
}
|
170 |
|
171 |
return $errors;
|
@@ -176,19 +182,22 @@ class PUM_Newsletters {
|
|
176 |
*
|
177 |
* @param array $values
|
178 |
*/
|
179 |
-
public static function record_submission( $values =
|
180 |
-
$data = wp_parse_args(
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
192 |
|
193 |
$subscriber_id = PUM_DB_Subscribers::instance()->insert( $data );
|
194 |
|
@@ -219,12 +228,15 @@ class PUM_Newsletters {
|
|
219 |
*
|
220 |
* @return array
|
221 |
*/
|
222 |
-
public static function sanitization( $values =
|
223 |
-
$values = wp_parse_args(
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
228 |
|
229 |
$values['provider'] = sanitize_text_field( $values['provider'] );
|
230 |
|
@@ -232,19 +244,20 @@ class PUM_Newsletters {
|
|
232 |
|
233 |
if ( ! empty( $values['consent_args'] ) && is_string( $values['consent_args'] ) ) {
|
234 |
if ( strpos( $values['consent_args'], '\"' ) >= 0 ) {
|
235 |
-
$values['consent_args'] = stripslashes( $values[
|
236 |
}
|
237 |
|
238 |
$values['consent_args'] = (array) json_decode( $values['consent_args'] );
|
239 |
}
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
248 |
|
249 |
// Anonymize the data if they didn't consent and privacy is enabled.
|
250 |
if ( $values['consent_args']['enabled'] === 'yes' && ! $values['consent_args']['required'] && $values['consent'] === 'no' ) {
|
@@ -258,10 +271,10 @@ class PUM_Newsletters {
|
|
258 |
|
259 |
// Split name into fname & lname or vice versa.
|
260 |
if ( isset( $values['name'] ) ) {
|
261 |
-
$values['name'] = trim( sanitize_text_field( $values[
|
262 |
|
263 |
-
//Creates last name
|
264 |
-
$name = explode(
|
265 |
if ( ! isset( $name[1] ) ) {
|
266 |
$name[1] = '';
|
267 |
}
|
@@ -269,13 +282,13 @@ class PUM_Newsletters {
|
|
269 |
$values['fname'] = trim( $name[0] );
|
270 |
$values['lname'] = trim( $name[1] );
|
271 |
} else {
|
272 |
-
$values['fname'] = isset( $values[
|
273 |
-
$values['lname'] = isset( $values[
|
274 |
|
275 |
$values['name'] = trim( $values['fname'] . ' ' . $values['lname'] );
|
276 |
}
|
277 |
|
278 |
-
$values['email'] = sanitize_email( $values[
|
279 |
$values['email_hash'] = md5( $values['email'] );
|
280 |
|
281 |
return $values;
|
@@ -285,14 +298,14 @@ class PUM_Newsletters {
|
|
285 |
* Provides basic field validation.
|
286 |
*
|
287 |
* @param WP_Error $errors
|
288 |
-
* @param array
|
289 |
*
|
290 |
* @return WP_Error
|
291 |
*/
|
292 |
-
public static function validation( $errors, $values =
|
293 |
-
if ( ! isset( $values[
|
294 |
$errors->add( 'empty_email', pum_get_newsletter_provider_message( $values['provider'], 'empty_email', $values ), 'email' );
|
295 |
-
} elseif ( ! is_email( $values[
|
296 |
$errors->add( 'invalid_email', pum_get_newsletter_provider_message( $values['provider'], 'invalid_email', $values ), 'email' );
|
297 |
}
|
298 |
|
18 |
|
19 |
public static function init() {
|
20 |
if ( doing_action( 'plugins_loaded' ) || ! did_action( 'plugins_loaded' ) ) {
|
21 |
+
add_action( 'plugins_loaded', [ __CLASS__, 'delayed_init' ], 11 );
|
22 |
} else {
|
23 |
self::delayed_init();
|
24 |
}
|
28 |
// TODO Once PUM-Aweber has been updated properly for a few months remove these if checks.
|
29 |
// TODO Consider adding notice to update aweber.
|
30 |
|
31 |
+
self::$disabled = in_array(
|
32 |
+
true,
|
33 |
+
[
|
34 |
+
class_exists( 'PUM_Aweber_Integration' ) && defined( 'PUM_AWEBER_INTEGRATION_VER' ) && version_compare( PUM_AWEBER_INTEGRATION_VER, '1.1.0', '<' ),
|
35 |
+
class_exists( 'PUM_MailChimp_Integration' ) && defined( 'PUM_MAILCHIMP_INTEGRATION_VER' ) && PUM_MAILCHIMP_INTEGRATION_VER,
|
36 |
+
class_exists( 'PUM_MCI' ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ),
|
37 |
+
]
|
38 |
+
);
|
39 |
|
40 |
// Checks for single very specific versions.
|
41 |
if ( self::$disabled ) {
|
48 |
|
49 |
PUM_Shortcode_Subscribe::init();
|
50 |
|
51 |
+
add_action( 'wp_ajax_pum_sub_form', [ __CLASS__, 'ajax_request' ] );
|
52 |
+
add_action( 'wp_ajax_nopriv_pum_sub_form', [ __CLASS__, 'ajax_request' ] );
|
53 |
|
54 |
+
add_filter( 'pum_sub_form_sanitization', [ __CLASS__, 'sanitization' ], 0 );
|
55 |
+
add_filter( 'pum_sub_form_validation', [ __CLASS__, 'validation' ], 0, 2 );
|
56 |
+
add_action( 'pum_sub_form_success', [ __CLASS__, 'record_submission' ], 0 );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* Submits the form using ajax
|
61 |
*/
|
62 |
public static function ajax_request() {
|
63 |
+
self::$errors = new WP_Error();
|
64 |
|
65 |
+
$values = isset( $_REQUEST['values'] ) ? $_REQUEST['values'] : [];
|
66 |
|
67 |
if ( empty( $values['popup_id'] ) && ! empty( $values['pum_form_popup_id'] ) ) {
|
68 |
$values['popup_id'] = absint( $values['pum_form_popup_id'] );
|
83 |
self::send_errors( self::$errors );
|
84 |
}
|
85 |
|
86 |
+
$response = [];
|
87 |
|
88 |
// Process the submission and pass the $response array as a reference variable so data can be added..
|
89 |
+
do_action_ref_array( 'pum_sub_form_submission', [ $values, &$response, &self::$errors ] );
|
90 |
|
91 |
$error_code = self::$errors->get_error_code();
|
92 |
|
110 |
$response['already_subscribed'] = true;
|
111 |
}
|
112 |
|
113 |
+
$response['message'] = pum_get_newsletter_provider_message( $values['provider'], $already_subscribed ? 'already_subscribed' : 'success', $values );
|
114 |
self::send_success( $response );
|
115 |
}
|
116 |
// Don't let it keep going.
|
123 |
* Optionally pass extra data to send back to front end.
|
124 |
*
|
125 |
* @param $errors WP_Error
|
126 |
+
* @param array $extra_response_args
|
127 |
*/
|
128 |
+
public static function send_errors( WP_Error $errors, $extra_response_args = [] ) {
|
129 |
if ( ! $errors || ! is_wp_error( $errors ) ) {
|
130 |
$errors = self::$errors;
|
131 |
}
|
132 |
|
133 |
+
$response = array_merge(
|
134 |
+
$extra_response_args,
|
135 |
+
[
|
136 |
+
'errors' => self::prepare_errors( $errors ),
|
137 |
+
]
|
138 |
+
);
|
139 |
|
140 |
wp_send_json_error( $response );
|
141 |
|
147 |
*
|
148 |
* @param array|mixed $response
|
149 |
*/
|
150 |
+
public static function send_success( $response = [] ) {
|
151 |
wp_send_json_success( array_filter( $response ) );
|
152 |
die;
|
153 |
}
|
164 |
$_errors = self::$errors;
|
165 |
}
|
166 |
|
167 |
+
$errors = [];
|
168 |
|
169 |
foreach ( $_errors->get_error_codes() as $code ) {
|
170 |
+
$errors[] = [
|
171 |
'code' => $code,
|
172 |
'field' => $_errors->get_error_data( $code ),
|
173 |
'message' => $_errors->get_error_message( $code ),
|
174 |
+
];
|
175 |
}
|
176 |
|
177 |
return $errors;
|
182 |
*
|
183 |
* @param array $values
|
184 |
*/
|
185 |
+
public static function record_submission( $values = [] ) {
|
186 |
+
$data = wp_parse_args(
|
187 |
+
$values,
|
188 |
+
[
|
189 |
+
'uuid' => self::uuid(),
|
190 |
+
'user_id' => get_current_user_id(),
|
191 |
+
'popup_id' => 0,
|
192 |
+
'email_hash' => '',
|
193 |
+
'email' => '',
|
194 |
+
'name' => '',
|
195 |
+
'fname' => '',
|
196 |
+
'lname' => '',
|
197 |
+
'consent' => 'no',
|
198 |
+
'consent_args' => '',
|
199 |
+
]
|
200 |
+
);
|
201 |
|
202 |
$subscriber_id = PUM_DB_Subscribers::instance()->insert( $data );
|
203 |
|
228 |
*
|
229 |
* @return array
|
230 |
*/
|
231 |
+
public static function sanitization( $values = [] ) {
|
232 |
+
$values = wp_parse_args(
|
233 |
+
$values,
|
234 |
+
[
|
235 |
+
'provider' => pum_get_option( 'newsletter_default_provider', 'none' ),
|
236 |
+
'consent' => 'no',
|
237 |
+
'consent_args' => [],
|
238 |
+
]
|
239 |
+
);
|
240 |
|
241 |
$values['provider'] = sanitize_text_field( $values['provider'] );
|
242 |
|
244 |
|
245 |
if ( ! empty( $values['consent_args'] ) && is_string( $values['consent_args'] ) ) {
|
246 |
if ( strpos( $values['consent_args'], '\"' ) >= 0 ) {
|
247 |
+
$values['consent_args'] = stripslashes( $values['consent_args'] );
|
248 |
}
|
249 |
|
250 |
$values['consent_args'] = (array) json_decode( $values['consent_args'] );
|
251 |
}
|
252 |
|
253 |
+
$values['consent_args'] = wp_parse_args(
|
254 |
+
$values['consent_args'],
|
255 |
+
[
|
256 |
+
'enabled' => 'no',
|
257 |
+
'required' => false,
|
258 |
+
'text' => '',
|
259 |
+
]
|
260 |
+
);
|
261 |
|
262 |
// Anonymize the data if they didn't consent and privacy is enabled.
|
263 |
if ( $values['consent_args']['enabled'] === 'yes' && ! $values['consent_args']['required'] && $values['consent'] === 'no' ) {
|
271 |
|
272 |
// Split name into fname & lname or vice versa.
|
273 |
if ( isset( $values['name'] ) ) {
|
274 |
+
$values['name'] = trim( sanitize_text_field( $values['name'] ) );
|
275 |
|
276 |
+
// Creates last name
|
277 |
+
$name = explode( ' ', $values['name'] );
|
278 |
if ( ! isset( $name[1] ) ) {
|
279 |
$name[1] = '';
|
280 |
}
|
282 |
$values['fname'] = trim( $name[0] );
|
283 |
$values['lname'] = trim( $name[1] );
|
284 |
} else {
|
285 |
+
$values['fname'] = isset( $values['fname'] ) ? sanitize_text_field( $values['fname'] ) : '';
|
286 |
+
$values['lname'] = isset( $values['lname'] ) ? sanitize_text_field( $values['lname'] ) : '';
|
287 |
|
288 |
$values['name'] = trim( $values['fname'] . ' ' . $values['lname'] );
|
289 |
}
|
290 |
|
291 |
+
$values['email'] = sanitize_email( $values['email'] );
|
292 |
$values['email_hash'] = md5( $values['email'] );
|
293 |
|
294 |
return $values;
|
298 |
* Provides basic field validation.
|
299 |
*
|
300 |
* @param WP_Error $errors
|
301 |
+
* @param array $values
|
302 |
*
|
303 |
* @return WP_Error
|
304 |
*/
|
305 |
+
public static function validation( $errors, $values = [] ) {
|
306 |
+
if ( ! isset( $values['email'] ) || empty( $values['email'] ) ) {
|
307 |
$errors->add( 'empty_email', pum_get_newsletter_provider_message( $values['provider'], 'empty_email', $values ), 'email' );
|
308 |
+
} elseif ( ! is_email( $values['email'] ) ) {
|
309 |
$errors->add( 'invalid_email', pum_get_newsletter_provider_message( $values['provider'], 'invalid_email', $values ), 'email' );
|
310 |
}
|
311 |
|
classes/Popup.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Empty class extender here for backward compatibility.
|
4 |
-
class PUM_Popup extends PUM_Model_Popup {}
|
1 |
<?php
|
2 |
|
3 |
// Empty class extender here for backward compatibility.
|
4 |
+
class PUM_Popup extends PUM_Model_Popup {}
|
classes/Popups.php
CHANGED
@@ -42,11 +42,14 @@ class PUM_Popups {
|
|
42 |
*
|
43 |
* @return \WP_Query
|
44 |
*/
|
45 |
-
public static function query( $args =
|
46 |
-
$args = wp_parse_args(
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
return new WP_Query( $args );
|
52 |
}
|
42 |
*
|
43 |
* @return \WP_Query
|
44 |
*/
|
45 |
+
public static function query( $args = [] ) {
|
46 |
+
$args = wp_parse_args(
|
47 |
+
$args,
|
48 |
+
[
|
49 |
+
'post_type' => 'popup',
|
50 |
+
'posts_per_page' => - 1,
|
51 |
+
]
|
52 |
+
);
|
53 |
|
54 |
return new WP_Query( $args );
|
55 |
}
|
classes/Previews.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
|
|
|
|
|
5 |
|
6 |
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
exit;
|
@@ -18,54 +20,47 @@ class PUM_Previews {
|
|
18 |
* Initiator method.
|
19 |
*/
|
20 |
public static function init() {
|
21 |
-
// add_filter( 'template_include', array( __CLASS__, 'template_include' ), 1000, 2 );
|
22 |
add_action( 'template_redirect', [ __CLASS__, 'force_load_preview' ] );
|
23 |
-
add_filter( 'pum_popup_is_loadable',
|
24 |
-
add_filter( 'pum_popup_data_attr',
|
25 |
-
add_filter( 'pum_popup_get_public_settings',
|
26 |
-
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
*
|
|
|
|
|
31 |
*/
|
32 |
-
public static function
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
}
|
36 |
|
37 |
-
$
|
38 |
|
39 |
-
if (
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
-
}
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
public static function template_include( $template ) {
|
52 |
-
if ( ! is_singular( 'popup' ) ) {
|
53 |
-
return $template;
|
54 |
}
|
55 |
|
56 |
-
return
|
57 |
-
}
|
58 |
|
59 |
-
/**
|
60 |
-
* For popup previews this will force only the correct popup to load.
|
61 |
-
*
|
62 |
-
* @param bool $loadable
|
63 |
-
* @param int $popup_id
|
64 |
-
*
|
65 |
-
* @return bool
|
66 |
-
*/
|
67 |
-
public static function is_loadable( $loadable, $popup_id ) {
|
68 |
-
return self::should_preview_popup( $popup_id ) ? true : $loadable;
|
69 |
}
|
70 |
|
71 |
/**
|
@@ -73,55 +68,65 @@ class PUM_Previews {
|
|
73 |
*
|
74 |
* This enables them to use the built in preview links.
|
75 |
*
|
76 |
-
* @param int $popup_id
|
77 |
*
|
78 |
* @return bool
|
79 |
*/
|
80 |
-
|
81 |
-
if ( defined(
|
82 |
return false;
|
83 |
}
|
84 |
|
|
|
85 |
|
86 |
-
|
|
|
87 |
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
if ( is_numeric( $_GET['popup'] ) && absint( $_GET['popup'] ) > 0 ) {
|
92 |
-
$popup = absint( $_GET['popup'] );
|
93 |
-
} else {
|
94 |
-
$post = get_page_by_path( sanitize_text_field( $_GET['popup'] ), OBJECT, 'popup' );
|
95 |
-
$popup = $post->ID;
|
96 |
-
}
|
97 |
-
}
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
}
|
102 |
}
|
|
|
103 |
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* On popup previews add an admin debug trigger.
|
109 |
*
|
110 |
-
* @
|
111 |
-
*
|
|
|
|
|
112 |
*
|
113 |
* @return mixed
|
114 |
*/
|
115 |
public static function data_attr( $data_attr, $popup_id ) {
|
116 |
-
if ( ! self::
|
117 |
return $data_attr;
|
118 |
}
|
119 |
|
120 |
-
$data_attr['triggers'] =
|
121 |
-
|
122 |
'type' => 'admin_debug',
|
123 |
-
|
124 |
-
|
125 |
|
126 |
return $data_attr;
|
127 |
}
|
@@ -129,21 +134,21 @@ class PUM_Previews {
|
|
129 |
/**
|
130 |
* On popup previews add an admin debug trigger.
|
131 |
*
|
132 |
-
* @param array
|
133 |
-
* @param PUM_Model_Popup $popup
|
134 |
*
|
135 |
* @return array
|
136 |
*/
|
137 |
public static function get_public_settings( $settings, $popup ) {
|
138 |
-
if ( ! self::
|
139 |
return $settings;
|
140 |
}
|
141 |
|
142 |
-
$settings['triggers'] =
|
143 |
-
|
144 |
'type' => 'admin_debug',
|
145 |
-
|
146 |
-
|
147 |
|
148 |
return $settings;
|
149 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Manage popup prevews.
|
4 |
+
*
|
5 |
+
* @package PopupMaker
|
6 |
+
*/
|
7 |
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
exit;
|
20 |
* Initiator method.
|
21 |
*/
|
22 |
public static function init() {
|
|
|
23 |
add_action( 'template_redirect', [ __CLASS__, 'force_load_preview' ] );
|
24 |
+
add_filter( 'pum_popup_is_loadable', [ __CLASS__, 'is_loadable' ], 1000, 2 );
|
25 |
+
add_filter( 'pum_popup_data_attr', [ __CLASS__, 'data_attr' ], 1000, 2 );
|
26 |
+
add_filter( 'pum_popup_get_public_settings', [ __CLASS__, 'get_public_settings' ], 1000, 2 );
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* Get popup id for previewing.
|
31 |
+
*
|
32 |
+
* @return false|int
|
33 |
*/
|
34 |
+
public static function get_popup_preview() {
|
35 |
+
static $preview_id;
|
36 |
+
|
37 |
+
if ( isset( $preview_id ) ) {
|
38 |
+
return $preview_id;
|
39 |
}
|
40 |
|
41 |
+
$preview_id = false;
|
42 |
|
43 |
+
if (
|
44 |
+
! isset( $_GET['popup_preview'] ) ||
|
45 |
+
! isset( $_GET['popup'] ) ||
|
46 |
+
// Overridden as wp_verify_nonce is already safe: https://github.com/WordPress/WordPress-Coding-Standards/issues/869#issuecomment-611782416.
|
47 |
+
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
48 |
+
! wp_verify_nonce( $_GET['popup_preview'], 'popup-preview' )
|
49 |
+
) {
|
50 |
+
return false;
|
51 |
}
|
|
|
52 |
|
53 |
+
$popup_id = sanitize_text_field( wp_unslash( $_GET['popup'] ) );
|
54 |
+
|
55 |
+
if ( is_numeric( $_GET['popup'] ) && absint( $_GET['popup'] ) > 0 ) {
|
56 |
+
$preview_id = absint( $_GET['popup'] );
|
57 |
+
} else {
|
58 |
+
$post = get_page_by_path( $popup_id, OBJECT, 'popup' );
|
59 |
+
$preview_id = $post->ID;
|
|
|
|
|
|
|
60 |
}
|
61 |
|
62 |
+
return $preview_id;
|
|
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
68 |
*
|
69 |
* This enables them to use the built in preview links.
|
70 |
*
|
71 |
+
* @param int $popup_id Popup ID.
|
72 |
*
|
73 |
* @return bool
|
74 |
*/
|
75 |
+
private static function is_previewing_popup( $popup_id = 0 ) {
|
76 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
77 |
return false;
|
78 |
}
|
79 |
|
80 |
+
$preview_id = static::get_popup_preview();
|
81 |
|
82 |
+
return $popup_id === $preview_id && current_user_can( 'edit_post', $preview_id );
|
83 |
+
}
|
84 |
|
85 |
+
/**
|
86 |
+
* Force popup to load no matter its status if its supposed to be previewed.
|
87 |
+
*/
|
88 |
+
public static function force_load_preview() {
|
89 |
+
$preview_id = static::get_popup_preview();
|
90 |
|
91 |
+
$popup = pum_get_popup( $preview_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
+
if ( $popup->is_valid() && $preview_id === $popup->ID ) {
|
94 |
+
PUM_Site_Popups::preload_popup( $popup );
|
|
|
95 |
}
|
96 |
+
}
|
97 |
|
98 |
+
/**
|
99 |
+
* For popup previews this will force only the correct popup to load.
|
100 |
+
*
|
101 |
+
* @param bool $loadable Is popup loadable.
|
102 |
+
* @param int $popup_id Popup ID.
|
103 |
+
*
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
public static function is_loadable( $loadable, $popup_id ) {
|
107 |
+
return self::is_previewing_popup( $popup_id ) ? true : $loadable;
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
* On popup previews add an admin debug trigger.
|
112 |
*
|
113 |
+
* @deprecated 1.16.10 Use get_public_settings instead.
|
114 |
+
*
|
115 |
+
* @param array $data_attr Array of popup data attributes.
|
116 |
+
* @param int $popup_id Popup ID.
|
117 |
*
|
118 |
* @return mixed
|
119 |
*/
|
120 |
public static function data_attr( $data_attr, $popup_id ) {
|
121 |
+
if ( ! self::is_previewing_popup( $popup_id ) ) {
|
122 |
return $data_attr;
|
123 |
}
|
124 |
|
125 |
+
$data_attr['triggers'] = [
|
126 |
+
[
|
127 |
'type' => 'admin_debug',
|
128 |
+
],
|
129 |
+
];
|
130 |
|
131 |
return $data_attr;
|
132 |
}
|
134 |
/**
|
135 |
* On popup previews add an admin debug trigger.
|
136 |
*
|
137 |
+
* @param array $settings Array of settigs.
|
138 |
+
* @param PUM_Model_Popup $popup Popup model object.
|
139 |
*
|
140 |
* @return array
|
141 |
*/
|
142 |
public static function get_public_settings( $settings, $popup ) {
|
143 |
+
if ( ! self::is_previewing_popup( $popup->ID ) ) {
|
144 |
return $settings;
|
145 |
}
|
146 |
|
147 |
+
$settings['triggers'] = [
|
148 |
+
[
|
149 |
'type' => 'admin_debug',
|
150 |
+
],
|
151 |
+
];
|
152 |
|
153 |
return $settings;
|
154 |
}
|
classes/Privacy.php
CHANGED
@@ -14,10 +14,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
class PUM_Privacy {
|
15 |
|
16 |
public static function init() {
|
17 |
-
add_filter( 'wp_privacy_personal_data_exporters',
|
18 |
-
add_filter( 'wp_privacy_personal_data_erasers',
|
19 |
-
add_action( 'admin_init',
|
20 |
-
add_action( 'pum_save_popup',
|
21 |
}
|
22 |
|
23 |
public static function clear_cookie_list() {
|
@@ -67,7 +67,8 @@ class PUM_Privacy {
|
|
67 |
|
68 |
<?php
|
69 |
$cookies = self::get_all_cookies();
|
70 |
-
if ( ! empty( $cookies ) ) :
|
|
|
71 |
<p class="privacy-policy-tutorial"><?php _e( 'Below is a list of all cookies currently registered within your popup settings. These are here for you to disclose if you are so required.', 'popup-maker' ); ?></p>
|
72 |
<table class="wp-list-table" style="width: 100%;">
|
73 |
<thead>
|
@@ -77,25 +78,30 @@ class PUM_Privacy {
|
|
77 |
<th align="left"><?php _e( 'Time', 'popup-maker' ); ?></th>
|
78 |
</tr>
|
79 |
</thead>
|
80 |
-
<tbody style="border: 1px solid;"
|
|
|
81 |
foreach ( $cookies as $cookie ) {
|
82 |
if ( ! is_array( $cookie ) ) {
|
83 |
continue;
|
84 |
}
|
85 |
|
86 |
-
$cookie = wp_parse_args(
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
91 |
|
92 |
printf( '<tr><td style="border-top: 1px dashed;">%s</td><td style="border-top: 1px dashed;">%s</td><td style="border-top: 1px dashed;">%s</td></tr>', $cookie['name'], $cookie['label'], $cookie['time'] );
|
93 |
}
|
94 |
?>
|
95 |
</tbody>
|
96 |
</table>
|
97 |
-
|
98 |
-
endif;
|
|
|
99 |
|
100 |
<p><?php echo $suggested_text . __( 'We use anonymous cookies to prevent users from seeing the same popup repetitively in an attempt to make our users experience more pleasant while still delivering time sensitive messaging.', 'popup-maker' ); ?></p>
|
101 |
|
@@ -133,10 +139,10 @@ class PUM_Privacy {
|
|
133 |
* @return array
|
134 |
*/
|
135 |
public static function register_exporter( $exporters ) {
|
136 |
-
$exporters[] =
|
137 |
'exporter_friendly_name' => __( 'Popup Maker Subscribe Form' ),
|
138 |
-
'callback' =>
|
139 |
-
|
140 |
|
141 |
return $exporters;
|
142 |
}
|
@@ -151,10 +157,10 @@ class PUM_Privacy {
|
|
151 |
* @return array
|
152 |
*/
|
153 |
public static function register_erasers( $exporters ) {
|
154 |
-
$exporters[] =
|
155 |
'eraser_friendly_name' => __( 'Popup Maker Subscribe Form' ),
|
156 |
-
'callback' =>
|
157 |
-
|
158 |
|
159 |
return $exporters;
|
160 |
}
|
@@ -165,7 +171,7 @@ class PUM_Privacy {
|
|
165 |
* @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md
|
166 |
*
|
167 |
* @param $email_address
|
168 |
-
* @param int
|
169 |
*
|
170 |
* @return array
|
171 |
*/
|
@@ -173,14 +179,17 @@ class PUM_Privacy {
|
|
173 |
$number = 500; // Limit us to avoid timing out
|
174 |
$page = (int) $page;
|
175 |
|
176 |
-
$export_items =
|
177 |
-
$subscribers = PUM_DB_Subscribers::instance()->query(
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
184 |
|
185 |
foreach ( (array) $subscribers as $subscriber ) {
|
186 |
if ( $subscriber['email'] == $email_address ) {
|
@@ -202,45 +211,45 @@ class PUM_Privacy {
|
|
202 |
|
203 |
// Plugins can add as many items in the item data array as they want
|
204 |
|
205 |
-
$data =
|
206 |
|
207 |
foreach ( $subscriber as $field_key => $field_value ) {
|
208 |
switch ( $field_key ) {
|
209 |
case 'ID':
|
210 |
-
$data[] =
|
211 |
'name' => __( 'ID', 'popup-maker' ),
|
212 |
'value' => $field_value,
|
213 |
-
|
214 |
break;
|
215 |
case 'email':
|
216 |
-
$data[] =
|
217 |
'name' => __( 'Email', 'popup-maker' ),
|
218 |
'value' => $field_value,
|
219 |
-
|
220 |
break;
|
221 |
case 'name':
|
222 |
-
$data[] =
|
223 |
'name' => __( 'Name', 'popup-maker' ),
|
224 |
'value' => $field_value,
|
225 |
-
|
226 |
break;
|
227 |
case 'fname':
|
228 |
-
$data[] =
|
229 |
'name' => __( 'First Name', 'popup-maker' ),
|
230 |
'value' => $field_value,
|
231 |
-
|
232 |
break;
|
233 |
case 'lname':
|
234 |
-
$data[] =
|
235 |
'name' => __( 'Last Name', 'popup-maker' ),
|
236 |
'value' => $field_value,
|
237 |
-
|
238 |
break;
|
239 |
case 'consent':
|
240 |
-
$data[] =
|
241 |
'name' => __( 'Provided Consent', 'popup-maker' ),
|
242 |
'value' => ucfirst( $field_value ),
|
243 |
-
|
244 |
break;
|
245 |
case 'values':
|
246 |
case 'consent_args':
|
@@ -285,40 +294,39 @@ class PUM_Privacy {
|
|
285 |
$label = apply_filters( 'pum_privacy_subscriber_value_label', $label, $key, $value );
|
286 |
|
287 |
if ( ! empty( $label ) ) {
|
288 |
-
$data[] =
|
289 |
'name' => $label,
|
290 |
'value' => $value,
|
291 |
-
|
292 |
}
|
293 |
}
|
294 |
|
295 |
break;
|
296 |
case 'created':
|
297 |
-
$data[] =
|
298 |
'name' => __( 'Date Subscribed', 'popup-maker' ),
|
299 |
'value' => $field_value,
|
300 |
-
|
301 |
break;
|
302 |
}
|
303 |
}
|
304 |
|
305 |
-
$export_items[] =
|
306 |
'group_id' => $group_id,
|
307 |
'group_label' => $group_label,
|
308 |
'item_id' => $item_id,
|
309 |
'data' => $data,
|
310 |
-
|
311 |
}
|
312 |
-
|
313 |
}
|
314 |
|
315 |
// Tell core if we have more comments to work on still
|
316 |
$done = count( $subscribers ) < $number;
|
317 |
|
318 |
-
return
|
319 |
'data' => $export_items,
|
320 |
'done' => $done,
|
321 |
-
|
322 |
}
|
323 |
|
324 |
|
@@ -328,34 +336,37 @@ class PUM_Privacy {
|
|
328 |
* @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md
|
329 |
*
|
330 |
* @param $email_address
|
331 |
-
* @param int
|
332 |
*
|
333 |
* @return array
|
334 |
*/
|
335 |
public static function eraser( $email_address, $page = 1 ) {
|
336 |
if ( empty( $email_address ) ) {
|
337 |
-
return
|
338 |
'items_removed' => false,
|
339 |
'items_retained' => false,
|
340 |
-
'messages' =>
|
341 |
'done' => true,
|
342 |
-
|
343 |
}
|
344 |
|
345 |
-
$messages =
|
346 |
$items_removed = false;
|
347 |
$items_retained = false;
|
348 |
|
349 |
$number = 500; // Limit us to avoid timing out
|
350 |
$page = (int) $page;
|
351 |
|
352 |
-
$subscribers = PUM_DB_Subscribers::instance()->query(
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
|
|
|
|
|
|
359 |
|
360 |
foreach ( (array) $subscribers as $subscriber ) {
|
361 |
if ( $subscriber['email'] == $email_address ) {
|
@@ -377,20 +388,18 @@ class PUM_Privacy {
|
|
377 |
$items_retained = true;
|
378 |
$messages[] = __( 'Subscription information was not removed. This may occur when no immediate confirmation is received during our attempt to unsubscribe you from our mailing list.', 'popup-maker' );
|
379 |
}
|
380 |
-
|
381 |
}
|
382 |
-
|
383 |
}
|
384 |
|
385 |
// Tell core if we have more comments to work on still
|
386 |
$done = count( $subscribers ) < $number;
|
387 |
|
388 |
-
return
|
389 |
'items_removed' => $items_removed,
|
390 |
'items_retained' => $items_retained,
|
391 |
'messages' => $messages,
|
392 |
'done' => $done,
|
393 |
-
|
394 |
}
|
395 |
|
396 |
/**
|
@@ -398,9 +407,9 @@ class PUM_Privacy {
|
|
398 |
*/
|
399 |
public static function get_all_cookies() {
|
400 |
$cookie_list = get_option( 'pum_privacy_cookie_list' );
|
401 |
-
$cookies
|
402 |
|
403 |
-
if ( false === $cookie_list || ! isset( $cookie_list['timestamp'] ) || strtotime('-7 days' ) > $cookie_list['timestamp'] ) {
|
404 |
$popups = pum_get_all_popups();
|
405 |
|
406 |
if ( ! empty( $popups ) ) {
|
@@ -414,22 +423,22 @@ class PUM_Privacy {
|
|
414 |
// Set this popup as the global $current.
|
415 |
pum()->current_popup = $popup;
|
416 |
|
417 |
-
$popup_cookies = $popup->get_setting( 'cookies',
|
418 |
|
419 |
if ( ! empty( $popup_cookies ) ) {
|
420 |
foreach ( $popup_cookies as $cookie ) {
|
421 |
-
if ( ! empty
|
422 |
$current_time = 0;
|
423 |
if ( ! empty( $cookies[ $cookie['settings']['name'] ] ) ) {
|
424 |
$current_time = strtotime( '+' . $cookies[ $cookie['settings']['name'] ]['time'] );
|
425 |
}
|
426 |
|
427 |
if ( empty( $cookies[ $cookie['settings']['name'] ] ) ) {
|
428 |
-
$cookies[ $cookie['settings']['name'] ] =
|
429 |
'label' => __( 'Cookie used to prevent popup from displaying repeatedly.', 'popup-maker' ),
|
430 |
'name' => $cookie['settings']['name'],
|
431 |
'time' => $cookie['settings']['time'],
|
432 |
-
|
433 |
}
|
434 |
|
435 |
$new_time = strtotime( '+' . $cookie['settings']['time'] );
|
@@ -447,12 +456,15 @@ class PUM_Privacy {
|
|
447 |
}
|
448 |
|
449 |
// Update cookie list so we don't have to regenerate it every page load.
|
450 |
-
update_option(
|
451 |
-
'
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
454 |
}
|
455 |
|
456 |
return apply_filters( 'pum_privacy_get_all_cookies', $cookies );
|
457 |
}
|
458 |
-
}
|
14 |
class PUM_Privacy {
|
15 |
|
16 |
public static function init() {
|
17 |
+
add_filter( 'wp_privacy_personal_data_exporters', [ __CLASS__, 'register_exporter' ], 10 );
|
18 |
+
add_filter( 'wp_privacy_personal_data_erasers', [ __CLASS__, 'register_erasers' ], 10 );
|
19 |
+
add_action( 'admin_init', [ __CLASS__, 'privacy_policy_content' ], 20 );
|
20 |
+
add_action( 'pum_save_popup', [ __CLASS__, 'clear_cookie_list' ] );
|
21 |
}
|
22 |
|
23 |
public static function clear_cookie_list() {
|
67 |
|
68 |
<?php
|
69 |
$cookies = self::get_all_cookies();
|
70 |
+
if ( ! empty( $cookies ) ) :
|
71 |
+
?>
|
72 |
<p class="privacy-policy-tutorial"><?php _e( 'Below is a list of all cookies currently registered within your popup settings. These are here for you to disclose if you are so required.', 'popup-maker' ); ?></p>
|
73 |
<table class="wp-list-table" style="width: 100%;">
|
74 |
<thead>
|
78 |
<th align="left"><?php _e( 'Time', 'popup-maker' ); ?></th>
|
79 |
</tr>
|
80 |
</thead>
|
81 |
+
<tbody style="border: 1px solid;">
|
82 |
+
<?php
|
83 |
foreach ( $cookies as $cookie ) {
|
84 |
if ( ! is_array( $cookie ) ) {
|
85 |
continue;
|
86 |
}
|
87 |
|
88 |
+
$cookie = wp_parse_args(
|
89 |
+
$cookie,
|
90 |
+
[
|
91 |
+
'name' => '',
|
92 |
+
'label' => '',
|
93 |
+
'time' => '',
|
94 |
+
]
|
95 |
+
);
|
96 |
|
97 |
printf( '<tr><td style="border-top: 1px dashed;">%s</td><td style="border-top: 1px dashed;">%s</td><td style="border-top: 1px dashed;">%s</td></tr>', $cookie['name'], $cookie['label'], $cookie['time'] );
|
98 |
}
|
99 |
?>
|
100 |
</tbody>
|
101 |
</table>
|
102 |
+
<?php
|
103 |
+
endif;
|
104 |
+
?>
|
105 |
|
106 |
<p><?php echo $suggested_text . __( 'We use anonymous cookies to prevent users from seeing the same popup repetitively in an attempt to make our users experience more pleasant while still delivering time sensitive messaging.', 'popup-maker' ); ?></p>
|
107 |
|
139 |
* @return array
|
140 |
*/
|
141 |
public static function register_exporter( $exporters ) {
|
142 |
+
$exporters[] = [
|
143 |
'exporter_friendly_name' => __( 'Popup Maker Subscribe Form' ),
|
144 |
+
'callback' => [ __CLASS__, 'exporter' ],
|
145 |
+
];
|
146 |
|
147 |
return $exporters;
|
148 |
}
|
157 |
* @return array
|
158 |
*/
|
159 |
public static function register_erasers( $exporters ) {
|
160 |
+
$exporters[] = [
|
161 |
'eraser_friendly_name' => __( 'Popup Maker Subscribe Form' ),
|
162 |
+
'callback' => [ __CLASS__, 'eraser' ],
|
163 |
+
];
|
164 |
|
165 |
return $exporters;
|
166 |
}
|
171 |
* @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md
|
172 |
*
|
173 |
* @param $email_address
|
174 |
+
* @param int $page
|
175 |
*
|
176 |
* @return array
|
177 |
*/
|
179 |
$number = 500; // Limit us to avoid timing out
|
180 |
$page = (int) $page;
|
181 |
|
182 |
+
$export_items = [];
|
183 |
+
$subscribers = PUM_DB_Subscribers::instance()->query(
|
184 |
+
[
|
185 |
+
's' => $email_address,
|
186 |
+
'page' => $page,
|
187 |
+
'limit' => $number,
|
188 |
+
'orderby' => 'ID',
|
189 |
+
'order' => 'ASC',
|
190 |
+
],
|
191 |
+
'ARRAY_A'
|
192 |
+
);
|
193 |
|
194 |
foreach ( (array) $subscribers as $subscriber ) {
|
195 |
if ( $subscriber['email'] == $email_address ) {
|
211 |
|
212 |
// Plugins can add as many items in the item data array as they want
|
213 |
|
214 |
+
$data = [];
|
215 |
|
216 |
foreach ( $subscriber as $field_key => $field_value ) {
|
217 |
switch ( $field_key ) {
|
218 |
case 'ID':
|
219 |
+
$data[] = [
|
220 |
'name' => __( 'ID', 'popup-maker' ),
|
221 |
'value' => $field_value,
|
222 |
+
];
|
223 |
break;
|
224 |
case 'email':
|
225 |
+
$data[] = [
|
226 |
'name' => __( 'Email', 'popup-maker' ),
|
227 |
'value' => $field_value,
|
228 |
+
];
|
229 |
break;
|
230 |
case 'name':
|
231 |
+
$data[] = [
|
232 |
'name' => __( 'Name', 'popup-maker' ),
|
233 |
'value' => $field_value,
|
234 |
+
];
|
235 |
break;
|
236 |
case 'fname':
|
237 |
+
$data[] = [
|
238 |
'name' => __( 'First Name', 'popup-maker' ),
|
239 |
'value' => $field_value,
|
240 |
+
];
|
241 |
break;
|
242 |
case 'lname':
|
243 |
+
$data[] = [
|
244 |
'name' => __( 'Last Name', 'popup-maker' ),
|
245 |
'value' => $field_value,
|
246 |
+
];
|
247 |
break;
|
248 |
case 'consent':
|
249 |
+
$data[] = [
|
250 |
'name' => __( 'Provided Consent', 'popup-maker' ),
|
251 |
'value' => ucfirst( $field_value ),
|
252 |
+
];
|
253 |
break;
|
254 |
case 'values':
|
255 |
case 'consent_args':
|
294 |
$label = apply_filters( 'pum_privacy_subscriber_value_label', $label, $key, $value );
|
295 |
|
296 |
if ( ! empty( $label ) ) {
|
297 |
+
$data[] = [
|
298 |
'name' => $label,
|
299 |
'value' => $value,
|
300 |
+
];
|
301 |
}
|
302 |
}
|
303 |
|
304 |
break;
|
305 |
case 'created':
|
306 |
+
$data[] = [
|
307 |
'name' => __( 'Date Subscribed', 'popup-maker' ),
|
308 |
'value' => $field_value,
|
309 |
+
];
|
310 |
break;
|
311 |
}
|
312 |
}
|
313 |
|
314 |
+
$export_items[] = [
|
315 |
'group_id' => $group_id,
|
316 |
'group_label' => $group_label,
|
317 |
'item_id' => $item_id,
|
318 |
'data' => $data,
|
319 |
+
];
|
320 |
}
|
|
|
321 |
}
|
322 |
|
323 |
// Tell core if we have more comments to work on still
|
324 |
$done = count( $subscribers ) < $number;
|
325 |
|
326 |
+
return [
|
327 |
'data' => $export_items,
|
328 |
'done' => $done,
|
329 |
+
];
|
330 |
}
|
331 |
|
332 |
|
336 |
* @see https://github.com/allendav/wp-privacy-requests/blob/master/EXPORT.md
|
337 |
*
|
338 |
* @param $email_address
|
339 |
+
* @param int $page
|
340 |
*
|
341 |
* @return array
|
342 |
*/
|
343 |
public static function eraser( $email_address, $page = 1 ) {
|
344 |
if ( empty( $email_address ) ) {
|
345 |
+
return [
|
346 |
'items_removed' => false,
|
347 |
'items_retained' => false,
|
348 |
+
'messages' => [],
|
349 |
'done' => true,
|
350 |
+
];
|
351 |
}
|
352 |
|
353 |
+
$messages = [];
|
354 |
$items_removed = false;
|
355 |
$items_retained = false;
|
356 |
|
357 |
$number = 500; // Limit us to avoid timing out
|
358 |
$page = (int) $page;
|
359 |
|
360 |
+
$subscribers = PUM_DB_Subscribers::instance()->query(
|
361 |
+
[
|
362 |
+
's' => $email_address,
|
363 |
+
'page' => $page,
|
364 |
+
'limit' => $number,
|
365 |
+
'orderby' => 'ID',
|
366 |
+
'order' => 'ASC',
|
367 |
+
],
|
368 |
+
'ARRAY_A'
|
369 |
+
);
|
370 |
|
371 |
foreach ( (array) $subscribers as $subscriber ) {
|
372 |
if ( $subscriber['email'] == $email_address ) {
|
388 |
$items_retained = true;
|
389 |
$messages[] = __( 'Subscription information was not removed. This may occur when no immediate confirmation is received during our attempt to unsubscribe you from our mailing list.', 'popup-maker' );
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
}
|
393 |
|
394 |
// Tell core if we have more comments to work on still
|
395 |
$done = count( $subscribers ) < $number;
|
396 |
|
397 |
+
return [
|
398 |
'items_removed' => $items_removed,
|
399 |
'items_retained' => $items_retained,
|
400 |
'messages' => $messages,
|
401 |
'done' => $done,
|
402 |
+
];
|
403 |
}
|
404 |
|
405 |
/**
|
407 |
*/
|
408 |
public static function get_all_cookies() {
|
409 |
$cookie_list = get_option( 'pum_privacy_cookie_list' );
|
410 |
+
$cookies = ! empty( $cookie_list['cookies'] ) ? $cookie_list['cookies'] : [];
|
411 |
|
412 |
+
if ( false === $cookie_list || ! isset( $cookie_list['timestamp'] ) || strtotime( '-7 days' ) > $cookie_list['timestamp'] ) {
|
413 |
$popups = pum_get_all_popups();
|
414 |
|
415 |
if ( ! empty( $popups ) ) {
|
423 |
// Set this popup as the global $current.
|
424 |
pum()->current_popup = $popup;
|
425 |
|
426 |
+
$popup_cookies = $popup->get_setting( 'cookies', [] );
|
427 |
|
428 |
if ( ! empty( $popup_cookies ) ) {
|
429 |
foreach ( $popup_cookies as $cookie ) {
|
430 |
+
if ( ! empty( $cookie['settings']['name'] ) ) {
|
431 |
$current_time = 0;
|
432 |
if ( ! empty( $cookies[ $cookie['settings']['name'] ] ) ) {
|
433 |
$current_time = strtotime( '+' . $cookies[ $cookie['settings']['name'] ]['time'] );
|
434 |
}
|
435 |
|
436 |
if ( empty( $cookies[ $cookie['settings']['name'] ] ) ) {
|
437 |
+
$cookies[ $cookie['settings']['name'] ] = [
|
438 |
'label' => __( 'Cookie used to prevent popup from displaying repeatedly.', 'popup-maker' ),
|
439 |
'name' => $cookie['settings']['name'],
|
440 |
'time' => $cookie['settings']['time'],
|
441 |
+
];
|
442 |
}
|
443 |
|
444 |
$new_time = strtotime( '+' . $cookie['settings']['time'] );
|
456 |
}
|
457 |
|
458 |
// Update cookie list so we don't have to regenerate it every page load.
|
459 |
+
update_option(
|
460 |
+
'pum_privacy_cookie_list',
|
461 |
+
[
|
462 |
+
'cookies' => $cookies,
|
463 |
+
'timestamp' => strtotime( 'now' ),
|
464 |
+
]
|
465 |
+
);
|
466 |
}
|
467 |
|
468 |
return apply_filters( 'pum_privacy_get_all_cookies', $cookies );
|
469 |
}
|
470 |
+
}
|
classes/Repository/Popups.php
CHANGED
@@ -31,15 +31,15 @@ class PUM_Repository_Popups extends PUM_Abstract_Repository_Posts {
|
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
34 |
-
protected function build_wp_query_args( $args =
|
35 |
// Ordering
|
36 |
-
$orderby =
|
37 |
|
38 |
// Meta Query
|
39 |
if ( ! isset( $args['meta_query'] ) ) {
|
40 |
-
$args['meta_query'] =
|
41 |
'relation' => 'AND',
|
42 |
-
|
43 |
}
|
44 |
|
45 |
if ( isset( $args['popups'] ) ) {
|
@@ -56,15 +56,15 @@ class PUM_Repository_Popups extends PUM_Abstract_Repository_Posts {
|
|
56 |
*/
|
57 |
if ( ! isset( $args['orderby'] ) ) {
|
58 |
$orderby['post_modified'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
59 |
-
} elseif ( ! empty( $args['post__in'] ) && in_array( $args['orderby'],
|
60 |
// This one can't be part of an $orderby array so needs to override.
|
61 |
$orderby = 'post__in';
|
62 |
} else {
|
63 |
switch ( $args['orderby'] ) {
|
64 |
-
case 'name'
|
65 |
$orderby['post_title'] = isset( $args['order'] ) ? $args['order'] : 'ASC';
|
66 |
break;
|
67 |
-
case 'date'
|
68 |
$orderby['post_date'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
69 |
break;
|
70 |
case 'activity':
|
@@ -100,7 +100,7 @@ class PUM_Repository_Popups extends PUM_Abstract_Repository_Posts {
|
|
100 |
*
|
101 |
* @return PUM_Model_Popup[]|WP_Post[]
|
102 |
*/
|
103 |
-
public function get_items( $args =
|
104 |
return parent::get_items( $args );
|
105 |
}
|
106 |
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
34 |
+
protected function build_wp_query_args( $args = [] ) {
|
35 |
// Ordering
|
36 |
+
$orderby = [];
|
37 |
|
38 |
// Meta Query
|
39 |
if ( ! isset( $args['meta_query'] ) ) {
|
40 |
+
$args['meta_query'] = [
|
41 |
'relation' => 'AND',
|
42 |
+
];
|
43 |
}
|
44 |
|
45 |
if ( isset( $args['popups'] ) ) {
|
56 |
*/
|
57 |
if ( ! isset( $args['orderby'] ) ) {
|
58 |
$orderby['post_modified'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
59 |
+
} elseif ( ! empty( $args['post__in'] ) && in_array( $args['orderby'], [ 'post__in', 'user_order' ] ) ) {
|
60 |
// This one can't be part of an $orderby array so needs to override.
|
61 |
$orderby = 'post__in';
|
62 |
} else {
|
63 |
switch ( $args['orderby'] ) {
|
64 |
+
case 'name':
|
65 |
$orderby['post_title'] = isset( $args['order'] ) ? $args['order'] : 'ASC';
|
66 |
break;
|
67 |
+
case 'date':
|
68 |
$orderby['post_date'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
69 |
break;
|
70 |
case 'activity':
|
100 |
*
|
101 |
* @return PUM_Model_Popup[]|WP_Post[]
|
102 |
*/
|
103 |
+
public function get_items( $args = [] ) {
|
104 |
return parent::get_items( $args );
|
105 |
}
|
106 |
|
classes/Repository/Themes.php
CHANGED
@@ -31,15 +31,15 @@ class PUM_Repository_Themes extends PUM_Abstract_Repository_Posts {
|
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
34 |
-
protected function build_wp_query_args( $args =
|
35 |
// Ordering
|
36 |
-
$orderby =
|
37 |
|
38 |
// Meta Query
|
39 |
if ( ! isset( $args['meta_query'] ) ) {
|
40 |
-
$args['meta_query'] =
|
41 |
'relation' => 'AND',
|
42 |
-
|
43 |
}
|
44 |
|
45 |
if ( isset( $args['themes'] ) ) {
|
@@ -56,15 +56,15 @@ class PUM_Repository_Themes extends PUM_Abstract_Repository_Posts {
|
|
56 |
*/
|
57 |
if ( ! isset( $args['orderby'] ) ) {
|
58 |
$orderby['post_modified'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
59 |
-
} elseif ( ! empty( $args['post__in'] ) && in_array( $args['orderby'],
|
60 |
// This one can't be part of an $orderby array so needs to override.
|
61 |
$orderby = 'post__in';
|
62 |
} else {
|
63 |
switch ( $args['orderby'] ) {
|
64 |
-
case 'name'
|
65 |
$orderby['post_title'] = isset( $args['order'] ) ? $args['order'] : 'ASC';
|
66 |
break;
|
67 |
-
case 'date'
|
68 |
$orderby['post_date'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
69 |
break;
|
70 |
case 'activity':
|
@@ -100,7 +100,7 @@ class PUM_Repository_Themes extends PUM_Abstract_Repository_Posts {
|
|
100 |
*
|
101 |
* @return PUM_Model_Theme[]|WP_Post[]
|
102 |
*/
|
103 |
-
public function get_items( $args =
|
104 |
return parent::get_items( $args );
|
105 |
}
|
106 |
|
31 |
*
|
32 |
* @return array
|
33 |
*/
|
34 |
+
protected function build_wp_query_args( $args = [] ) {
|
35 |
// Ordering
|
36 |
+
$orderby = [];
|
37 |
|
38 |
// Meta Query
|
39 |
if ( ! isset( $args['meta_query'] ) ) {
|
40 |
+
$args['meta_query'] = [
|
41 |
'relation' => 'AND',
|
42 |
+
];
|
43 |
}
|
44 |
|
45 |
if ( isset( $args['themes'] ) ) {
|
56 |
*/
|
57 |
if ( ! isset( $args['orderby'] ) ) {
|
58 |
$orderby['post_modified'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
59 |
+
} elseif ( ! empty( $args['post__in'] ) && in_array( $args['orderby'], [ 'post__in', 'user_order' ] ) ) {
|
60 |
// This one can't be part of an $orderby array so needs to override.
|
61 |
$orderby = 'post__in';
|
62 |
} else {
|
63 |
switch ( $args['orderby'] ) {
|
64 |
+
case 'name':
|
65 |
$orderby['post_title'] = isset( $args['order'] ) ? $args['order'] : 'ASC';
|
66 |
break;
|
67 |
+
case 'date':
|
68 |
$orderby['post_date'] = isset( $args['order'] ) ? $args['order'] : 'DESC';
|
69 |
break;
|
70 |
case 'activity':
|
100 |
*
|
101 |
* @return PUM_Model_Theme[]|WP_Post[]
|
102 |
*/
|
103 |
+
public function get_items( $args = [] ) {
|
104 |
return parent::get_items( $args );
|
105 |
}
|
106 |
|
classes/Shortcode.php
CHANGED
@@ -73,11 +73,11 @@ abstract class PUM_Shortcode {
|
|
73 |
*
|
74 |
* @param array $args
|
75 |
*/
|
76 |
-
public function __construct( $args =
|
77 |
if ( ! did_action( 'init' ) ) {
|
78 |
-
add_action( 'init',
|
79 |
} elseif ( ! did_action( 'admin_head' ) && current_action() != 'init' ) {
|
80 |
-
add_action( 'admin_head',
|
81 |
} else {
|
82 |
$this->register();
|
83 |
}
|
@@ -87,9 +87,9 @@ abstract class PUM_Shortcode {
|
|
87 |
* Register this shortcode with Shortcode UI & Shortcake.
|
88 |
*/
|
89 |
public function register() {
|
90 |
-
add_shortcode( $this->tag(),
|
91 |
-
add_action( 'print_media_templates',
|
92 |
-
add_action( 'register_shortcode_ui',
|
93 |
|
94 |
PUM_Shortcodes::instance()->add_shortcode( $this );
|
95 |
}
|
@@ -104,7 +104,7 @@ abstract class PUM_Shortcode {
|
|
104 |
*/
|
105 |
public static function init() {
|
106 |
$class = get_called_class();
|
107 |
-
return new $class;
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -128,9 +128,9 @@ abstract class PUM_Shortcode {
|
|
128 |
|
129 |
foreach ( $this->_tabs() as $tab_id => $tab_label ) {
|
130 |
if ( empty( $subtabs[ $tab_id ] ) || ! is_array( $subtabs[ $tab_id ] ) ) {
|
131 |
-
$subtabs[ $tab_id ] =
|
132 |
'main' => $tab_label,
|
133 |
-
|
134 |
}
|
135 |
}
|
136 |
|
@@ -147,10 +147,10 @@ abstract class PUM_Shortcode {
|
|
147 |
* @return array
|
148 |
*/
|
149 |
public function sections() {
|
150 |
-
return
|
151 |
'general' => __( 'General', 'popup-maker' ),
|
152 |
'options' => __( 'Options', 'popup-maker' ),
|
153 |
-
|
154 |
}
|
155 |
|
156 |
/**
|
@@ -159,10 +159,10 @@ abstract class PUM_Shortcode {
|
|
159 |
* @return array
|
160 |
*/
|
161 |
public function tabs() {
|
162 |
-
return
|
163 |
'general' => __( 'General', 'popup-maker' ),
|
164 |
'options' => __( 'Options', 'popup-maker' ),
|
165 |
-
|
166 |
}
|
167 |
|
168 |
/**
|
@@ -171,14 +171,14 @@ abstract class PUM_Shortcode {
|
|
171 |
* @return array
|
172 |
*/
|
173 |
public function subtabs() {
|
174 |
-
return
|
175 |
-
'general' =>
|
176 |
'main' => __( 'General', 'popup-maker' ),
|
177 |
-
|
178 |
-
'options' =>
|
179 |
'main' => __( 'Options', 'popup-maker' ),
|
180 |
-
|
181 |
-
|
182 |
}
|
183 |
|
184 |
/**
|
@@ -190,10 +190,10 @@ abstract class PUM_Shortcode {
|
|
190 |
*/
|
191 |
public function shortcode_atts( $atts ) {
|
192 |
if ( ! is_array( $atts ) ) {
|
193 |
-
$atts =
|
194 |
}
|
195 |
|
196 |
-
foreach( $atts as $key => $value ) {
|
197 |
/**
|
198 |
* Fix for truthy & value-less arguments such as [shortcode argument]
|
199 |
*/
|
@@ -214,7 +214,7 @@ abstract class PUM_Shortcode {
|
|
214 |
* @return array
|
215 |
*/
|
216 |
public function defaults() {
|
217 |
-
$defaults =
|
218 |
|
219 |
$fields = PUM_Admin_Helpers::flatten_fields_array( $this->fields() );
|
220 |
|
@@ -329,12 +329,12 @@ abstract class PUM_Shortcode {
|
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
-
$shortcode_ui_args =
|
333 |
'label' => $this->label(),
|
334 |
'listItemImage' => $this->icon(),
|
335 |
'post_type' => apply_filters( 'pum_shortcode_post_types', $this->post_types(), $this ),
|
336 |
-
'attrs' =>
|
337 |
-
|
338 |
|
339 |
/**
|
340 |
* Register UI for the "inner content" of the shortcode. Optional.
|
@@ -355,15 +355,15 @@ abstract class PUM_Shortcode {
|
|
355 |
continue;
|
356 |
}
|
357 |
|
358 |
-
//text, checkbox, textarea, radio, select, email, url, number, date, attachment, color, post_select
|
359 |
switch ( $field['type'] ) {
|
360 |
case 'select':
|
361 |
-
$shortcode_ui_args['attrs'][] =
|
362 |
'label' => esc_html( $field['label'] ),
|
363 |
'attr' => $field_id,
|
364 |
'type' => 'select',
|
365 |
'options' => $field['options'],
|
366 |
-
|
367 |
break;
|
368 |
|
369 |
case 'postselect':
|
@@ -371,13 +371,13 @@ abstract class PUM_Shortcode {
|
|
371 |
if ( empty( $field['post_type'] ) ) {
|
372 |
break;
|
373 |
}
|
374 |
-
$shortcode_ui_args['attrs'][] =
|
375 |
'label' => esc_html( $field['label'] ),
|
376 |
'attr' => $field_id,
|
377 |
'type' => 'post_select',
|
378 |
-
'options' => isset( $field['options'] ) ? $field['options'] :
|
379 |
-
'query' =>
|
380 |
-
|
381 |
break;
|
382 |
|
383 |
case 'taxonomyselect':
|
@@ -385,16 +385,16 @@ abstract class PUM_Shortcode {
|
|
385 |
|
386 |
case 'text';
|
387 |
default:
|
388 |
-
$shortcode_ui_args['attrs'][] =
|
389 |
'label' => $field['label'],
|
390 |
'attr' => $field_id,
|
391 |
'type' => 'text',
|
392 |
'value' => ! empty( $field['std'] ) ? $field['std'] : '',
|
393 |
-
//'encode' => true,
|
394 |
-
'meta' =>
|
395 |
'placeholder' => $field['placeholder'],
|
396 |
-
|
397 |
-
|
398 |
break;
|
399 |
}
|
400 |
}
|
@@ -434,7 +434,7 @@ abstract class PUM_Shortcode {
|
|
434 |
* @return array
|
435 |
*/
|
436 |
public function post_types() {
|
437 |
-
return
|
438 |
}
|
439 |
|
440 |
/**
|
@@ -443,10 +443,10 @@ abstract class PUM_Shortcode {
|
|
443 |
* @return array
|
444 |
*/
|
445 |
public function inner_content_labels() {
|
446 |
-
return
|
447 |
'label' => $this->label(),
|
448 |
'description' => $this->description(),
|
449 |
-
|
450 |
}
|
451 |
|
452 |
/**
|
@@ -460,19 +460,22 @@ abstract class PUM_Shortcode {
|
|
460 |
if ( $this->has_content ) {
|
461 |
$inner_content_labels = $this->inner_content_labels();
|
462 |
|
463 |
-
$fields[ $this->inner_content_section ]['main']['_inner_content'] =
|
464 |
'label' => $inner_content_labels['label'],
|
465 |
'desc' => $inner_content_labels['description'],
|
466 |
'section' => $this->inner_content_section,
|
467 |
'type' => 'textarea',
|
468 |
'priority' => $this->inner_content_priority,
|
469 |
-
|
470 |
}
|
471 |
|
472 |
-
$fields = PUM_Admin_Helpers::parse_tab_fields(
|
473 |
-
|
474 |
-
|
475 |
-
|
|
|
|
|
|
|
476 |
|
477 |
if ( $this->version < 2 ) {
|
478 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
@@ -480,8 +483,8 @@ abstract class PUM_Shortcode {
|
|
480 |
/**
|
481 |
* Apply field compatibility fixes for shortcodes still on v1.
|
482 |
*/
|
483 |
-
if ( ! empty( $field['type'] ) && in_array( $field['type'],
|
484 |
-
$fields[ $tab_id ][ $field_id ]['options'] = ! empty( $field['options'] ) ? array_flip( $field['options'] ) :
|
485 |
}
|
486 |
}
|
487 |
}
|
73 |
*
|
74 |
* @param array $args
|
75 |
*/
|
76 |
+
public function __construct( $args = [] ) {
|
77 |
if ( ! did_action( 'init' ) ) {
|
78 |
+
add_action( 'init', [ $this, 'register' ] );
|
79 |
} elseif ( ! did_action( 'admin_head' ) && current_action() != 'init' ) {
|
80 |
+
add_action( 'admin_head', [ $this, 'register' ] );
|
81 |
} else {
|
82 |
$this->register();
|
83 |
}
|
87 |
* Register this shortcode with Shortcode UI & Shortcake.
|
88 |
*/
|
89 |
public function register() {
|
90 |
+
add_shortcode( $this->tag(), [ $this, 'handler' ] );
|
91 |
+
add_action( 'print_media_templates', [ $this, 'render_template' ] );
|
92 |
+
add_action( 'register_shortcode_ui', [ $this, 'register_shortcode_ui' ] );
|
93 |
|
94 |
PUM_Shortcodes::instance()->add_shortcode( $this );
|
95 |
}
|
104 |
*/
|
105 |
public static function init() {
|
106 |
$class = get_called_class();
|
107 |
+
return new $class();
|
108 |
}
|
109 |
|
110 |
/**
|
128 |
|
129 |
foreach ( $this->_tabs() as $tab_id => $tab_label ) {
|
130 |
if ( empty( $subtabs[ $tab_id ] ) || ! is_array( $subtabs[ $tab_id ] ) ) {
|
131 |
+
$subtabs[ $tab_id ] = [
|
132 |
'main' => $tab_label,
|
133 |
+
];
|
134 |
}
|
135 |
}
|
136 |
|
147 |
* @return array
|
148 |
*/
|
149 |
public function sections() {
|
150 |
+
return [
|
151 |
'general' => __( 'General', 'popup-maker' ),
|
152 |
'options' => __( 'Options', 'popup-maker' ),
|
153 |
+
];
|
154 |
}
|
155 |
|
156 |
/**
|
159 |
* @return array
|
160 |
*/
|
161 |
public function tabs() {
|
162 |
+
return [
|
163 |
'general' => __( 'General', 'popup-maker' ),
|
164 |
'options' => __( 'Options', 'popup-maker' ),
|
165 |
+
];
|
166 |
}
|
167 |
|
168 |
/**
|
171 |
* @return array
|
172 |
*/
|
173 |
public function subtabs() {
|
174 |
+
return [
|
175 |
+
'general' => [
|
176 |
'main' => __( 'General', 'popup-maker' ),
|
177 |
+
],
|
178 |
+
'options' => [
|
179 |
'main' => __( 'Options', 'popup-maker' ),
|
180 |
+
],
|
181 |
+
];
|
182 |
}
|
183 |
|
184 |
/**
|
190 |
*/
|
191 |
public function shortcode_atts( $atts ) {
|
192 |
if ( ! is_array( $atts ) ) {
|
193 |
+
$atts = [];
|
194 |
}
|
195 |
|
196 |
+
foreach ( $atts as $key => $value ) {
|
197 |
/**
|
198 |
* Fix for truthy & value-less arguments such as [shortcode argument]
|
199 |
*/
|
214 |
* @return array
|
215 |
*/
|
216 |
public function defaults() {
|
217 |
+
$defaults = [];
|
218 |
|
219 |
$fields = PUM_Admin_Helpers::flatten_fields_array( $this->fields() );
|
220 |
|
329 |
return;
|
330 |
}
|
331 |
|
332 |
+
$shortcode_ui_args = [
|
333 |
'label' => $this->label(),
|
334 |
'listItemImage' => $this->icon(),
|
335 |
'post_type' => apply_filters( 'pum_shortcode_post_types', $this->post_types(), $this ),
|
336 |
+
'attrs' => [],
|
337 |
+
];
|
338 |
|
339 |
/**
|
340 |
* Register UI for the "inner content" of the shortcode. Optional.
|
355 |
continue;
|
356 |
}
|
357 |
|
358 |
+
// text, checkbox, textarea, radio, select, email, url, number, date, attachment, color, post_select
|
359 |
switch ( $field['type'] ) {
|
360 |
case 'select':
|
361 |
+
$shortcode_ui_args['attrs'][] = [
|
362 |
'label' => esc_html( $field['label'] ),
|
363 |
'attr' => $field_id,
|
364 |
'type' => 'select',
|
365 |
'options' => $field['options'],
|
366 |
+
];
|
367 |
break;
|
368 |
|
369 |
case 'postselect':
|
371 |
if ( empty( $field['post_type'] ) ) {
|
372 |
break;
|
373 |
}
|
374 |
+
$shortcode_ui_args['attrs'][] = [
|
375 |
'label' => esc_html( $field['label'] ),
|
376 |
'attr' => $field_id,
|
377 |
'type' => 'post_select',
|
378 |
+
'options' => isset( $field['options'] ) ? $field['options'] : [],
|
379 |
+
'query' => [ 'post_type' => $field['post_type'] ],
|
380 |
+
];
|
381 |
break;
|
382 |
|
383 |
case 'taxonomyselect':
|
385 |
|
386 |
case 'text';
|
387 |
default:
|
388 |
+
$shortcode_ui_args['attrs'][] = [
|
389 |
'label' => $field['label'],
|
390 |
'attr' => $field_id,
|
391 |
'type' => 'text',
|
392 |
'value' => ! empty( $field['std'] ) ? $field['std'] : '',
|
393 |
+
// 'encode' => true,
|
394 |
+
'meta' => [
|
395 |
'placeholder' => $field['placeholder'],
|
396 |
+
],
|
397 |
+
];
|
398 |
break;
|
399 |
}
|
400 |
}
|
434 |
* @return array
|
435 |
*/
|
436 |
public function post_types() {
|
437 |
+
return [ 'post', 'page', 'popup' ];
|
438 |
}
|
439 |
|
440 |
/**
|
443 |
* @return array
|
444 |
*/
|
445 |
public function inner_content_labels() {
|
446 |
+
return [
|
447 |
'label' => $this->label(),
|
448 |
'description' => $this->description(),
|
449 |
+
];
|
450 |
}
|
451 |
|
452 |
/**
|
460 |
if ( $this->has_content ) {
|
461 |
$inner_content_labels = $this->inner_content_labels();
|
462 |
|
463 |
+
$fields[ $this->inner_content_section ]['main']['_inner_content'] = [
|
464 |
'label' => $inner_content_labels['label'],
|
465 |
'desc' => $inner_content_labels['description'],
|
466 |
'section' => $this->inner_content_section,
|
467 |
'type' => 'textarea',
|
468 |
'priority' => $this->inner_content_priority,
|
469 |
+
];
|
470 |
}
|
471 |
|
472 |
+
$fields = PUM_Admin_Helpers::parse_tab_fields(
|
473 |
+
$fields,
|
474 |
+
[
|
475 |
+
'has_subtabs' => $this->version >= 2,
|
476 |
+
'name' => 'attrs[%s]',
|
477 |
+
]
|
478 |
+
);
|
479 |
|
480 |
if ( $this->version < 2 ) {
|
481 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
483 |
/**
|
484 |
* Apply field compatibility fixes for shortcodes still on v1.
|
485 |
*/
|
486 |
+
if ( ! empty( $field['type'] ) && in_array( $field['type'], [ 'select', 'postselect', 'radio', 'multicheck' ] ) ) {
|
487 |
+
$fields[ $tab_id ][ $field_id ]['options'] = ! empty( $field['options'] ) ? array_flip( $field['options'] ) : [];
|
488 |
}
|
489 |
}
|
490 |
}
|
classes/Shortcode/Popup.php
CHANGED
@@ -33,74 +33,77 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
33 |
}
|
34 |
|
35 |
public function inner_content_labels() {
|
36 |
-
return
|
37 |
'label' => __( 'Content', 'popup-maker' ),
|
38 |
'description' => __( 'Can contain other shortcodes, images, text or html content.', 'popup-maker' ),
|
39 |
-
|
40 |
}
|
41 |
|
42 |
public function post_types() {
|
43 |
-
return
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
* @return array
|
48 |
*/
|
49 |
public function tabs() {
|
50 |
-
return
|
51 |
'general' => __( 'General', 'popup-maker' ),
|
52 |
'display' => __( 'Display', 'popup-maker' ),
|
53 |
'position' => __( 'Position', 'popup-maker' ),
|
54 |
'animation' => __( 'Animation', 'popup-maker' ),
|
55 |
'close' => __( 'Close', 'popup-maker' ),
|
56 |
-
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* @return array
|
61 |
*/
|
62 |
public function subtabs() {
|
63 |
-
return apply_filters(
|
64 |
-
'
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
public function fields() {
|
83 |
-
return
|
84 |
-
'general' =>
|
85 |
-
'main' =>
|
86 |
-
'id' =>
|
87 |
'label' => __( 'Unique Popup ID', 'popup-maker' ),
|
88 |
'placeholder' => __( '`offer`, `more-info`', 'popup-maker' ),
|
89 |
'desc' => __( 'Used in popup triggers to target this popup', 'popup-maker' ),
|
90 |
'priority' => 5,
|
91 |
'required' => true,
|
92 |
-
|
93 |
-
'title' =>
|
94 |
'label' => __( 'Popup Title', 'popup-maker' ),
|
95 |
'placeholder' => __( 'Enter popup title text,', 'popup-maker' ),
|
96 |
'desc' => __( 'This will be displayed above the content. Leave it empty to disable it.', 'popup-maker' ),
|
97 |
'priority' => 10,
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
'display' =>
|
102 |
-
'main' =>
|
103 |
-
'theme_id' =>
|
104 |
'type' => 'select',
|
105 |
'label' => __( 'Popup Theme', 'popup-maker' ),
|
106 |
'placeholder' => __( 'Choose a theme,', 'popup-maker' ),
|
@@ -110,57 +113,57 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
110 |
'options' => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
|
111 |
'required' => true,
|
112 |
'priority' => 5,
|
113 |
-
|
114 |
-
'overlay_disabled' =>
|
115 |
'label' => __( 'Disable Overlay', 'popup-maker' ),
|
116 |
'description' => __( 'Checking this will disable and hide the overlay for this popup.', 'popup-maker' ),
|
117 |
'type' => 'checkbox',
|
118 |
'std' => false,
|
119 |
'priority' => 10,
|
120 |
-
|
121 |
-
'size' =>
|
122 |
'label' => __( 'Size', 'popup-maker' ),
|
123 |
'description' => __( 'Select the size of the popup.', 'popup-maker' ),
|
124 |
'type' => 'select',
|
125 |
'std' => 'small',
|
126 |
-
'options' => array_flip( apply_filters( 'popmake_popup_display_size_options',
|
127 |
'priority' => 15,
|
128 |
-
|
129 |
-
'width' =>
|
130 |
'label' => __( 'Width', 'popup-maker' ),
|
131 |
'priority' => 20,
|
132 |
-
|
133 |
-
'width_unit' =>
|
134 |
'label' => __( 'Width Unit', 'popup-maker' ),
|
135 |
'type' => 'select',
|
136 |
'std' => 'px',
|
137 |
-
'options' => array_flip( apply_filters( 'popmake_size_unit_options',
|
138 |
'priority' => 25,
|
139 |
-
|
140 |
-
'height' =>
|
141 |
'label' => __( 'Height', 'popup-maker' ),
|
142 |
'priority' => 30,
|
143 |
-
|
144 |
-
'height_unit' =>
|
145 |
'label' => __( 'Height Unit', 'popup-maker' ),
|
146 |
'type' => 'select',
|
147 |
'std' => 'px',
|
148 |
-
'options' => array_flip( apply_filters( 'popmake_size_unit_options',
|
149 |
'priority' => 35,
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
'position' =>
|
154 |
-
'main' =>
|
155 |
-
'location' =>
|
156 |
'label' => __( 'Location', 'popup-maker' ),
|
157 |
'description' => __( 'Choose where the popup will be displayed.', 'popup-maker' ),
|
158 |
'type' => 'select',
|
159 |
'std' => 'center top',
|
160 |
'priority' => 4,
|
161 |
-
'options' => array_flip( apply_filters( 'popmake_popup_display_location_options',
|
162 |
-
|
163 |
-
'position_top' =>
|
164 |
'label' => __( 'Top', 'popup-maker' ),
|
165 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
|
166 |
'type' => 'rangeslider',
|
@@ -170,8 +173,8 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
170 |
'min' => 0,
|
171 |
'max' => 500,
|
172 |
'unit' => 'px',
|
173 |
-
|
174 |
-
'position_bottom' =>
|
175 |
'label' => __( 'Bottom', 'popup-maker' ),
|
176 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
|
177 |
'type' => 'rangeslider',
|
@@ -181,8 +184,8 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
181 |
'min' => 0,
|
182 |
'max' => 500,
|
183 |
'unit' => 'px',
|
184 |
-
|
185 |
-
'position_left' =>
|
186 |
'label' => __( 'Left', 'popup-maker' ),
|
187 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
|
188 |
'type' => 'rangeslider',
|
@@ -192,8 +195,8 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
192 |
'min' => 0,
|
193 |
'max' => 500,
|
194 |
'unit' => 'px',
|
195 |
-
|
196 |
-
'position_right' =>
|
197 |
'label' => __( 'Right', 'popup-maker' ),
|
198 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
|
199 |
'type' => 'rangeslider',
|
@@ -203,20 +206,20 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
203 |
'min' => 0,
|
204 |
'max' => 500,
|
205 |
'unit' => 'px',
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
'animation' =>
|
210 |
-
'main' =>
|
211 |
-
'animation_type' =>
|
212 |
'label' => __( 'Animation Type', 'popup-maker' ),
|
213 |
'description' => __( 'Select an animation type for your popup.', 'popup-maker' ),
|
214 |
'type' => 'select',
|
215 |
'std' => 'fade',
|
216 |
'priority' => 5,
|
217 |
-
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_type_options',
|
218 |
-
|
219 |
-
'animation_speed' =>
|
220 |
'label' => __( 'Animation Speed', 'popup-maker' ),
|
221 |
'description' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
|
222 |
'type' => 'rangeslider',
|
@@ -226,29 +229,29 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
226 |
'min' => 50,
|
227 |
'max' => 1000,
|
228 |
'unit' => __( 'ms', 'popup-maker' ),
|
229 |
-
|
230 |
-
'animation_origin' =>
|
231 |
'label' => __( 'Animation Origin', 'popup-maker' ),
|
232 |
'description' => __( 'Choose where the animation will begin.', 'popup-maker' ),
|
233 |
'type' => 'select',
|
234 |
'std' => 'center top',
|
235 |
'priority' => 15,
|
236 |
-
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_origin_options',
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
'close' =>
|
241 |
-
'main' =>
|
242 |
-
'overlay_click' =>
|
243 |
'label' => __( 'Click Overlay to Close', 'popup-maker' ),
|
244 |
'description' => __( 'Checking this will cause popup to close when user clicks on overlay.', 'popup-maker' ),
|
245 |
'type' => 'checkbox',
|
246 |
'std' => false,
|
247 |
'priority' => 5,
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
}
|
253 |
|
254 |
/**
|
@@ -262,34 +265,41 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
262 |
public function handler( $atts, $content = null ) {
|
263 |
global $popup;
|
264 |
|
265 |
-
$atts = shortcode_atts(
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
// We need to fake a popup using the PUM_Popup data model.
|
295 |
$post_id = rand( - 99999, - 1 ); // negative ID, to avoid clash with a valid post
|
@@ -323,36 +333,39 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
323 |
}
|
324 |
|
325 |
$popup->title = $atts['title'];
|
326 |
-
$popup->settings = array_merge(
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
'
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
|
|
|
|
|
|
356 |
|
357 |
$current_global_popup = pum()->current_popup;
|
358 |
|
@@ -375,7 +388,8 @@ class PUM_Shortcode_Popup extends PUM_Shortcode {
|
|
375 |
|
376 |
public function template() { ?>
|
377 |
<p class="pum-sub-form-desc">
|
378 |
-
<?php
|
|
|
379 |
<?php
|
380 |
}
|
381 |
|
33 |
}
|
34 |
|
35 |
public function inner_content_labels() {
|
36 |
+
return [
|
37 |
'label' => __( 'Content', 'popup-maker' ),
|
38 |
'description' => __( 'Can contain other shortcodes, images, text or html content.', 'popup-maker' ),
|
39 |
+
];
|
40 |
}
|
41 |
|
42 |
public function post_types() {
|
43 |
+
return [];
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
* @return array
|
48 |
*/
|
49 |
public function tabs() {
|
50 |
+
return [
|
51 |
'general' => __( 'General', 'popup-maker' ),
|
52 |
'display' => __( 'Display', 'popup-maker' ),
|
53 |
'position' => __( 'Position', 'popup-maker' ),
|
54 |
'animation' => __( 'Animation', 'popup-maker' ),
|
55 |
'close' => __( 'Close', 'popup-maker' ),
|
56 |
+
];
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* @return array
|
61 |
*/
|
62 |
public function subtabs() {
|
63 |
+
return apply_filters(
|
64 |
+
'pum_sub_form_shortcode_subtabs',
|
65 |
+
[
|
66 |
+
'general' => [
|
67 |
+
'main' => __( 'General', 'popup-maker' ),
|
68 |
+
],
|
69 |
+
'display' => [
|
70 |
+
'main' => __( 'Display', 'popup-maker' ),
|
71 |
+
],
|
72 |
+
'position' => [
|
73 |
+
'main' => __( 'Position', 'popup-maker' ),
|
74 |
+
],
|
75 |
+
'animation' => [
|
76 |
+
'main' => __( 'Animation', 'popup-maker' ),
|
77 |
+
],
|
78 |
+
'close' => [
|
79 |
+
'main' => __( 'Close', 'popup-maker' ),
|
80 |
+
],
|
81 |
+
]
|
82 |
+
);
|
83 |
}
|
84 |
|
85 |
public function fields() {
|
86 |
+
return [
|
87 |
+
'general' => [
|
88 |
+
'main' => [
|
89 |
+
'id' => [
|
90 |
'label' => __( 'Unique Popup ID', 'popup-maker' ),
|
91 |
'placeholder' => __( '`offer`, `more-info`', 'popup-maker' ),
|
92 |
'desc' => __( 'Used in popup triggers to target this popup', 'popup-maker' ),
|
93 |
'priority' => 5,
|
94 |
'required' => true,
|
95 |
+
],
|
96 |
+
'title' => [
|
97 |
'label' => __( 'Popup Title', 'popup-maker' ),
|
98 |
'placeholder' => __( 'Enter popup title text,', 'popup-maker' ),
|
99 |
'desc' => __( 'This will be displayed above the content. Leave it empty to disable it.', 'popup-maker' ),
|
100 |
'priority' => 10,
|
101 |
+
],
|
102 |
+
],
|
103 |
+
],
|
104 |
+
'display' => [
|
105 |
+
'main' => [
|
106 |
+
'theme_id' => [
|
107 |
'type' => 'select',
|
108 |
'label' => __( 'Popup Theme', 'popup-maker' ),
|
109 |
'placeholder' => __( 'Choose a theme,', 'popup-maker' ),
|
113 |
'options' => pum_is_settings_page() ? PUM_Helpers::popup_theme_selectlist() : null,
|
114 |
'required' => true,
|
115 |
'priority' => 5,
|
116 |
+
],
|
117 |
+
'overlay_disabled' => [
|
118 |
'label' => __( 'Disable Overlay', 'popup-maker' ),
|
119 |
'description' => __( 'Checking this will disable and hide the overlay for this popup.', 'popup-maker' ),
|
120 |
'type' => 'checkbox',
|
121 |
'std' => false,
|
122 |
'priority' => 10,
|
123 |
+
],
|
124 |
+
'size' => [
|
125 |
'label' => __( 'Size', 'popup-maker' ),
|
126 |
'description' => __( 'Select the size of the popup.', 'popup-maker' ),
|
127 |
'type' => 'select',
|
128 |
'std' => 'small',
|
129 |
+
'options' => array_flip( apply_filters( 'popmake_popup_display_size_options', [] ) ),
|
130 |
'priority' => 15,
|
131 |
+
],
|
132 |
+
'width' => [
|
133 |
'label' => __( 'Width', 'popup-maker' ),
|
134 |
'priority' => 20,
|
135 |
+
],
|
136 |
+
'width_unit' => [
|
137 |
'label' => __( 'Width Unit', 'popup-maker' ),
|
138 |
'type' => 'select',
|
139 |
'std' => 'px',
|
140 |
+
'options' => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
|
141 |
'priority' => 25,
|
142 |
+
],
|
143 |
+
'height' => [
|
144 |
'label' => __( 'Height', 'popup-maker' ),
|
145 |
'priority' => 30,
|
146 |
+
],
|
147 |
+
'height_unit' => [
|
148 |
'label' => __( 'Height Unit', 'popup-maker' ),
|
149 |
'type' => 'select',
|
150 |
'std' => 'px',
|
151 |
+
'options' => array_flip( apply_filters( 'popmake_size_unit_options', [] ) ),
|
152 |
'priority' => 35,
|
153 |
+
],
|
154 |
+
],
|
155 |
+
],
|
156 |
+
'position' => [
|
157 |
+
'main' => [
|
158 |
+
'location' => [
|
159 |
'label' => __( 'Location', 'popup-maker' ),
|
160 |
'description' => __( 'Choose where the popup will be displayed.', 'popup-maker' ),
|
161 |
'type' => 'select',
|
162 |
'std' => 'center top',
|
163 |
'priority' => 4,
|
164 |
+
'options' => array_flip( apply_filters( 'popmake_popup_display_location_options', [] ) ),
|
165 |
+
],
|
166 |
+
'position_top' => [
|
167 |
'label' => __( 'Top', 'popup-maker' ),
|
168 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Top', 'popup-maker' ) ) ),
|
169 |
'type' => 'rangeslider',
|
173 |
'min' => 0,
|
174 |
'max' => 500,
|
175 |
'unit' => 'px',
|
176 |
+
],
|
177 |
+
'position_bottom' => [
|
178 |
'label' => __( 'Bottom', 'popup-maker' ),
|
179 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Bottom', 'popup-maker' ) ) ),
|
180 |
'type' => 'rangeslider',
|
184 |
'min' => 0,
|
185 |
'max' => 500,
|
186 |
'unit' => 'px',
|
187 |
+
],
|
188 |
+
'position_left' => [
|
189 |
'label' => __( 'Left', 'popup-maker' ),
|
190 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Left', 'popup-maker' ) ) ),
|
191 |
'type' => 'rangeslider',
|
195 |
'min' => 0,
|
196 |
'max' => 500,
|
197 |
'unit' => 'px',
|
198 |
+
],
|
199 |
+
'position_right' => [
|
200 |
'label' => __( 'Right', 'popup-maker' ),
|
201 |
'description' => sprintf( _x( 'Distance from the %s edge of the screen.', 'Screen Edge: top, bottom', 'popup-maker' ), strtolower( __( 'Right', 'popup-maker' ) ) ),
|
202 |
'type' => 'rangeslider',
|
206 |
'min' => 0,
|
207 |
'max' => 500,
|
208 |
'unit' => 'px',
|
209 |
+
],
|
210 |
+
],
|
211 |
+
],
|
212 |
+
'animation' => [
|
213 |
+
'main' => [
|
214 |
+
'animation_type' => [
|
215 |
'label' => __( 'Animation Type', 'popup-maker' ),
|
216 |
'description' => __( 'Select an animation type for your popup.', 'popup-maker' ),
|
217 |
'type' => 'select',
|
218 |
'std' => 'fade',
|
219 |
'priority' => 5,
|
220 |
+
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_type_options', [] ) ),
|
221 |
+
],
|
222 |
+
'animation_speed' => [
|
223 |
'label' => __( 'Animation Speed', 'popup-maker' ),
|
224 |
'description' => __( 'Set the animation speed for the popup.', 'popup-maker' ),
|
225 |
'type' => 'rangeslider',
|
229 |
'min' => 50,
|
230 |
'max' => 1000,
|
231 |
'unit' => __( 'ms', 'popup-maker' ),
|
232 |
+
],
|
233 |
+
'animation_origin' => [
|
234 |
'label' => __( 'Animation Origin', 'popup-maker' ),
|
235 |
'description' => __( 'Choose where the animation will begin.', 'popup-maker' ),
|
236 |
'type' => 'select',
|
237 |
'std' => 'center top',
|
238 |
'priority' => 15,
|
239 |
+
'options' => array_flip( apply_filters( 'popmake_popup_display_animation_origin_options', [] ) ),
|
240 |
+
],
|
241 |
+
],
|
242 |
+
],
|
243 |
+
'close' => [
|
244 |
+
'main' => [
|
245 |
+
'overlay_click' => [
|
246 |
'label' => __( 'Click Overlay to Close', 'popup-maker' ),
|
247 |
'description' => __( 'Checking this will cause popup to close when user clicks on overlay.', 'popup-maker' ),
|
248 |
'type' => 'checkbox',
|
249 |
'std' => false,
|
250 |
'priority' => 5,
|
251 |
+
],
|
252 |
+
],
|
253 |
+
],
|
254 |
+
];
|
255 |
}
|
256 |
|
257 |
/**
|
265 |
public function handler( $atts, $content = null ) {
|
266 |
global $popup;
|
267 |
|
268 |
+
$atts = shortcode_atts(
|
269 |
+
apply_filters(
|
270 |
+
'pum_popup_shortcode_default_atts',
|
271 |
+
[
|
272 |
+
|
273 |
+
'id' => '',
|
274 |
+
'title' => '',
|
275 |
+
|
276 |
+
'theme_id' => null,
|
277 |
+
'theme' => null,
|
278 |
+
'overlay_disabled' => 0,
|
279 |
+
'size' => 'small',
|
280 |
+
'width' => '',
|
281 |
+
'width_unit' => 'px',
|
282 |
+
'height' => '',
|
283 |
+
'height_unit' => 'px',
|
284 |
+
|
285 |
+
'location' => 'center top',
|
286 |
+
'position_top' => 100,
|
287 |
+
'position_left' => 0,
|
288 |
+
'position_bottom' => 0,
|
289 |
+
'position_right' => 0,
|
290 |
+
'position_fixed' => 0,
|
291 |
+
|
292 |
+
'animation_type' => 'fade',
|
293 |
+
'animation_speed' => 1000,
|
294 |
+
'animation_origin' => 'top',
|
295 |
+
|
296 |
+
'overlay_click' => 0,
|
297 |
+
'esc_press' => 1,
|
298 |
+
]
|
299 |
+
),
|
300 |
+
$atts,
|
301 |
+
'popup'
|
302 |
+
);
|
303 |
|
304 |
// We need to fake a popup using the PUM_Popup data model.
|
305 |
$post_id = rand( - 99999, - 1 ); // negative ID, to avoid clash with a valid post
|
333 |
}
|
334 |
|
335 |
$popup->title = $atts['title'];
|
336 |
+
$popup->settings = array_merge(
|
337 |
+
PUM_Admin_Popups::defaults(),
|
338 |
+
[
|
339 |
+
'disable_analytics' => true,
|
340 |
+
'theme_id' => $atts['theme_id'],
|
341 |
+
'size' => $atts['size'],
|
342 |
+
'overlay_disabled' => $atts['overlay_disabled'],
|
343 |
+
'custom_width' => $atts['width'],
|
344 |
+
'custom_width_unit' => $atts['width_unit'],
|
345 |
+
'custom_height' => $atts['height'],
|
346 |
+
'custom_height_unit' => $atts['height_unit'],
|
347 |
+
'custom_height_auto' => $atts['width'] > 0 ? 0 : 1,
|
348 |
+
'location' => $atts['location'],
|
349 |
+
'position_top' => $atts['position_top'],
|
350 |
+
'position_left' => $atts['position_left'],
|
351 |
+
'position_bottom' => $atts['position_bottom'],
|
352 |
+
'position_right' => $atts['position_right'],
|
353 |
+
'position_fixed' => $atts['position_fixed'],
|
354 |
+
'animation_type' => $atts['animation_type'],
|
355 |
+
'animation_speed' => $atts['animation_speed'],
|
356 |
+
'animation_origin' => $atts['animation_origin'],
|
357 |
+
'close_on_overlay_click' => $atts['overlay_click'],
|
358 |
+
'close_on_esc_press' => $atts['esc_press'],
|
359 |
+
'triggers' => [
|
360 |
+
[
|
361 |
+
'type' => 'click_open',
|
362 |
+
'settings' => [
|
363 |
+
'extra_selectors' => '#popmake-' . $atts['id'],
|
364 |
+
],
|
365 |
+
],
|
366 |
+
],
|
367 |
+
]
|
368 |
+
);
|
369 |
|
370 |
$current_global_popup = pum()->current_popup;
|
371 |
|
388 |
|
389 |
public function template() { ?>
|
390 |
<p class="pum-sub-form-desc">
|
391 |
+
<?php esc_html_e( 'Popup', 'popup-maker' ); ?>: ID "{{attrs.id}}"
|
392 |
+
</p>
|
393 |
<?php
|
394 |
}
|
395 |
|
classes/Shortcode/PopupClose.php
CHANGED
@@ -31,25 +31,25 @@ class PUM_Shortcode_PopupClose extends PUM_Shortcode {
|
|
31 |
}
|
32 |
|
33 |
public function inner_content_labels() {
|
34 |
-
return
|
35 |
'label' => __( 'Content', 'popup-maker' ),
|
36 |
'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
|
37 |
-
|
38 |
}
|
39 |
|
40 |
public function post_types() {
|
41 |
-
return
|
42 |
}
|
43 |
|
44 |
public function fields() {
|
45 |
-
return
|
46 |
-
'general' =>
|
47 |
-
'main' =>
|
48 |
-
'tag'
|
49 |
-
'label'
|
50 |
-
'desc'
|
51 |
-
'type'
|
52 |
-
'options'
|
53 |
'a' => 'a',
|
54 |
'button' => 'button',
|
55 |
'div' => 'div',
|
@@ -57,49 +57,49 @@ class PUM_Shortcode_PopupClose extends PUM_Shortcode {
|
|
57 |
'li' => 'li',
|
58 |
'p' => 'p',
|
59 |
'span' => 'span',
|
60 |
-
|
61 |
-
'std'
|
62 |
-
'required'
|
63 |
-
|
64 |
-
'href' =>
|
65 |
'label' => __( 'Value for href', 'popup-maker' ),
|
66 |
'placeholder' => '#',
|
67 |
'desc' => __( 'Enter the href value for your link. Leave blank if you do not want this link to take the visitor to a different page.', 'popup-maker' ),
|
68 |
'type' => 'text',
|
69 |
'std' => '',
|
70 |
-
'dependencies' =>
|
71 |
-
'tag' =>
|
72 |
-
|
73 |
-
|
74 |
-
'target'
|
75 |
'label' => __( 'Target for the element', 'popup-maker' ),
|
76 |
'placeholder' => '',
|
77 |
'desc' => __( 'Enter the target value for your link. Can be left blank.', 'popup-maker' ),
|
78 |
'type' => 'text',
|
79 |
'std' => '',
|
80 |
-
'dependencies' =>
|
81 |
-
'tag' =>
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
'options' =>
|
87 |
-
'main' =>
|
88 |
-
'classes' =>
|
89 |
'label' => __( 'CSS Class', 'popup-maker' ),
|
90 |
'placeholder' => 'my-custom-class',
|
91 |
'type' => 'text',
|
92 |
'desc' => __( 'Add additional classes for styling.', 'popup-maker' ),
|
93 |
'std' => '',
|
94 |
-
|
95 |
-
'do_default' =>
|
96 |
-
'type'
|
97 |
-
'label'
|
98 |
-
'desc'
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
}
|
104 |
|
105 |
/**
|
@@ -143,17 +143,17 @@ class PUM_Shortcode_PopupClose extends PUM_Shortcode {
|
|
143 |
public function handler( $atts, $content = null ) {
|
144 |
$atts = $this->shortcode_atts( $atts );
|
145 |
|
146 |
-
$tag
|
147 |
-
|
148 |
-
$do_default = $atts['do_default'] ? " data-do-default='true'" : '';
|
|
|
|
|
149 |
|
150 |
// Sets up our href and target, if the tag is an `a`.
|
151 |
-
$href = 'a' === $atts['tag'] ? "href='
|
152 |
$target = 'a' === $atts['tag'] && ! empty( $atts['target'] ) ? "target='" . esc_attr( $atts['target'] ) . "'" : '';
|
153 |
|
154 |
-
$return = "
|
155 |
-
$return .= esc_html( PUM_Helpers::do_shortcode( $content ) );
|
156 |
-
$return .= "</{$tag}>";
|
157 |
|
158 |
return $return;
|
159 |
}
|
@@ -168,7 +168,8 @@ class PUM_Shortcode_PopupClose extends PUM_Shortcode {
|
|
168 |
const allowedTags = <?php echo json_encode( array_keys( $allowedtags ) ); ?>;
|
169 |
const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
|
170 |
#>
|
171 |
-
<{{{tag}}} class="pum-close popmake-close <# if (typeof attrs.classes !== 'undefined') print(attrs.classes); #>">{{{attrs._inner_content}}}</{{{tag}}}
|
|
|
172 |
}
|
173 |
|
174 |
}
|
31 |
}
|
32 |
|
33 |
public function inner_content_labels() {
|
34 |
+
return [
|
35 |
'label' => __( 'Content', 'popup-maker' ),
|
36 |
'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
|
37 |
+
];
|
38 |
}
|
39 |
|
40 |
public function post_types() {
|
41 |
+
return [ 'popup' ];
|
42 |
}
|
43 |
|
44 |
public function fields() {
|
45 |
+
return [
|
46 |
+
'general' => [
|
47 |
+
'main' => [
|
48 |
+
'tag' => [
|
49 |
+
'label' => __( 'HTML Tag', 'popup-maker' ),
|
50 |
+
'desc' => __( 'The HTML tag used for this element.', 'popup-maker' ),
|
51 |
+
'type' => 'select',
|
52 |
+
'options' => [
|
53 |
'a' => 'a',
|
54 |
'button' => 'button',
|
55 |
'div' => 'div',
|
57 |
'li' => 'li',
|
58 |
'p' => 'p',
|
59 |
'span' => 'span',
|
60 |
+
],
|
61 |
+
'std' => 'span',
|
62 |
+
'required' => true,
|
63 |
+
],
|
64 |
+
'href' => [
|
65 |
'label' => __( 'Value for href', 'popup-maker' ),
|
66 |
'placeholder' => '#',
|
67 |
'desc' => __( 'Enter the href value for your link. Leave blank if you do not want this link to take the visitor to a different page.', 'popup-maker' ),
|
68 |
'type' => 'text',
|
69 |
'std' => '',
|
70 |
+
'dependencies' => [
|
71 |
+
'tag' => [ 'a' ],
|
72 |
+
],
|
73 |
+
],
|
74 |
+
'target' => [
|
75 |
'label' => __( 'Target for the element', 'popup-maker' ),
|
76 |
'placeholder' => '',
|
77 |
'desc' => __( 'Enter the target value for your link. Can be left blank.', 'popup-maker' ),
|
78 |
'type' => 'text',
|
79 |
'std' => '',
|
80 |
+
'dependencies' => [
|
81 |
+
'tag' => [ 'a' ],
|
82 |
+
],
|
83 |
+
],
|
84 |
+
],
|
85 |
+
],
|
86 |
+
'options' => [
|
87 |
+
'main' => [
|
88 |
+
'classes' => [
|
89 |
'label' => __( 'CSS Class', 'popup-maker' ),
|
90 |
'placeholder' => 'my-custom-class',
|
91 |
'type' => 'text',
|
92 |
'desc' => __( 'Add additional classes for styling.', 'popup-maker' ),
|
93 |
'std' => '',
|
94 |
+
],
|
95 |
+
'do_default' => [
|
96 |
+
'type' => 'checkbox',
|
97 |
+
'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
|
98 |
+
'desc' => __( 'This prevents us from disabling the browsers default action when a close button is clicked. It can be used to allow a link to a file to both close a popup and still download the file.', 'popup-maker' ),
|
99 |
+
],
|
100 |
+
],
|
101 |
+
],
|
102 |
+
];
|
103 |
}
|
104 |
|
105 |
/**
|
143 |
public function handler( $atts, $content = null ) {
|
144 |
$atts = $this->shortcode_atts( $atts );
|
145 |
|
146 |
+
$tag = esc_attr( $atts['tag'] );
|
147 |
+
$classes = esc_attr( $atts['classes'] );
|
148 |
+
$do_default = esc_attr( $atts['do_default'] ? " data-do-default='true'" : '' );
|
149 |
+
// Escaped using notes here: https://wordpress.stackexchange.com/a/357349/63942.
|
150 |
+
$esc_content = PUM_Helpers::do_shortcode( force_balance_tags( wp_kses_post( $content ) ) );
|
151 |
|
152 |
// Sets up our href and target, if the tag is an `a`.
|
153 |
+
$href = 'a' === $atts['tag'] ? "href='" . esc_attr( $atts['href'] ) . "'" : '';
|
154 |
$target = 'a' === $atts['tag'] && ! empty( $atts['target'] ) ? "target='" . esc_attr( $atts['target'] ) . "'" : '';
|
155 |
|
156 |
+
$return = "<$tag $href $target class='pum-close popmake-close $classes' $do_default>$esc_content</$tag>";
|
|
|
|
|
157 |
|
158 |
return $return;
|
159 |
}
|
168 |
const allowedTags = <?php echo json_encode( array_keys( $allowedtags ) ); ?>;
|
169 |
const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
|
170 |
#>
|
171 |
+
<{{{tag}}} class="pum-close popmake-close <# if (typeof attrs.classes !== 'undefined') print(attrs.classes); #>">{{{attrs._inner_content}}}</{{{tag}}}>
|
172 |
+
<?php
|
173 |
}
|
174 |
|
175 |
}
|
classes/Shortcode/PopupCookie.php
CHANGED
@@ -31,7 +31,7 @@ class PUM_Shortcode_PopupCookie extends PUM_Shortcode {
|
|
31 |
}
|
32 |
|
33 |
public function post_types() {
|
34 |
-
return
|
35 |
}
|
36 |
|
37 |
public function fields() {
|
@@ -44,7 +44,7 @@ class PUM_Shortcode_PopupCookie extends PUM_Shortcode {
|
|
44 |
'desc' => __( 'The name that will be used when checking for or saving this cookie.', 'popup-maker' ),
|
45 |
'std' => '',
|
46 |
],
|
47 |
-
'expires'
|
48 |
'label' => __( 'Cookie Time', 'popup-maker' ),
|
49 |
'placeholder' => __( '364 days 23 hours 59 minutes 59 seconds', 'popup-maker' ),
|
50 |
'desc' => __( 'Enter a plain english time before cookie expires.', 'popup-maker' ),
|
@@ -78,23 +78,26 @@ class PUM_Shortcode_PopupCookie extends PUM_Shortcode {
|
|
78 |
public function handler( $atts, $content = null ) {
|
79 |
$atts = $this->shortcode_atts( $atts );
|
80 |
|
81 |
-
$args = [
|
82 |
-
'name' => $atts['name'],
|
83 |
-
'time' => $atts['expires'],
|
84 |
-
'path' => $atts['sitewide'],
|
85 |
-
];
|
86 |
-
|
87 |
// This shortcode requires our scripts, but can be used on pages where no popups exist.
|
88 |
wp_enqueue_script( 'popup-maker-site' );
|
89 |
|
90 |
-
$onscreen = 'data-only-onscreen="' . ( $atts['only_onscreen'] ? 1 : 0 ) . '"';
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
public function template() { ?>
|
96 |
-
<div class="pum-cookie"><?php
|
|
|
97 |
}
|
98 |
|
99 |
}
|
100 |
-
|
31 |
}
|
32 |
|
33 |
public function post_types() {
|
34 |
+
return [ '*' ];
|
35 |
}
|
36 |
|
37 |
public function fields() {
|
44 |
'desc' => __( 'The name that will be used when checking for or saving this cookie.', 'popup-maker' ),
|
45 |
'std' => '',
|
46 |
],
|
47 |
+
'expires' => [
|
48 |
'label' => __( 'Cookie Time', 'popup-maker' ),
|
49 |
'placeholder' => __( '364 days 23 hours 59 minutes 59 seconds', 'popup-maker' ),
|
50 |
'desc' => __( 'Enter a plain english time before cookie expires.', 'popup-maker' ),
|
78 |
public function handler( $atts, $content = null ) {
|
79 |
$atts = $this->shortcode_atts( $atts );
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
// This shortcode requires our scripts, but can be used on pages where no popups exist.
|
82 |
wp_enqueue_script( 'popup-maker-site' );
|
83 |
|
84 |
+
$onscreen = esc_attr( 'data-only-onscreen="' . ( $atts['only_onscreen'] ? 1 : 0 ) . '"' );
|
85 |
+
$args = esc_attr(
|
86 |
+
wp_json_encode(
|
87 |
+
[
|
88 |
+
'name' => $atts['name'],
|
89 |
+
'time' => $atts['expires'],
|
90 |
+
'path' => $atts['sitewide'],
|
91 |
+
]
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
return "<div class='pum-cookie' data-cookie-args='$args' $onscreen></div>";
|
96 |
}
|
97 |
|
98 |
public function template() { ?>
|
99 |
+
<div class="pum-cookie"><?php esc_html_e( 'Popup Cookie', 'popup-maker' ); ?></div>
|
100 |
+
<?php
|
101 |
}
|
102 |
|
103 |
}
|
|
classes/Shortcode/PopupTrigger.php
CHANGED
@@ -48,33 +48,33 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
48 |
* @return array
|
49 |
*/
|
50 |
public function inner_content_labels() {
|
51 |
-
return
|
52 |
'label' => __( 'Trigger Content', 'popup-maker' ),
|
53 |
'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
|
54 |
-
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* @return array
|
59 |
*/
|
60 |
public function post_types() {
|
61 |
-
return
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* @return array
|
66 |
*/
|
67 |
public function fields() {
|
68 |
-
$select_args =
|
69 |
|
70 |
if ( isset( $_GET['post'] ) && is_int( (int) $_GET['post'] ) && isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) {
|
71 |
-
$select_args['post__not_in'] = wp_parse_id_list(
|
72 |
}
|
73 |
|
74 |
-
return
|
75 |
-
'general' =>
|
76 |
-
'main' =>
|
77 |
-
'id' =>
|
78 |
'label' => __( 'Targeted Popup', 'popup-maker' ),
|
79 |
'placeholder' => __( 'Choose a Popup', 'popup-maker' ),
|
80 |
'desc' => __( 'Choose which popup will be targeted by this trigger.', 'popup-maker' ),
|
@@ -82,24 +82,24 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
82 |
'post_type' => 'popup',
|
83 |
'priority' => 5,
|
84 |
'required' => true,
|
85 |
-
'options' => PUM_Helpers::popup_selectlist( $select_args ) +
|
86 |
-
|
87 |
-
|
88 |
'std' => 0,
|
89 |
-
|
90 |
-
'custom_id' =>
|
91 |
'label' => __( 'Custom Popup ID', 'popup-maker' ),
|
92 |
'type' => 'text',
|
93 |
-
'dependencies' =>
|
94 |
'id' => 'custom',
|
95 |
-
|
96 |
'std' => '',
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
'options' =>
|
101 |
-
'main' =>
|
102 |
-
'tag' =>
|
103 |
'label' => __( 'HTML Tag', 'popup-maker' ),
|
104 |
'placeholder' => __( 'HTML Tags: button, span etc.', 'popup-maker' ),
|
105 |
'desc' => __( 'The HTML tag used to generate the trigger and wrap your text.', 'popup-maker' ),
|
@@ -107,29 +107,29 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
107 |
'std' => '',
|
108 |
'priority' => 10,
|
109 |
'required' => true,
|
110 |
-
|
111 |
-
'classes' =>
|
112 |
'label' => __( 'CSS Class', 'popup-maker' ),
|
113 |
'placeholder' => __( 'CSS Class', 'popup-maker' ),
|
114 |
'type' => 'text',
|
115 |
'desc' => __( 'Add additional classes for styling.', 'popup-maker' ),
|
116 |
'priority' => 15,
|
117 |
'std' => '',
|
118 |
-
|
119 |
-
'class'
|
120 |
-
|
121 |
-
|
122 |
-
'do_default' =>
|
123 |
'type' => 'checkbox',
|
124 |
'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
|
125 |
'desc' => __( 'This prevents us from disabling the browsers default action when a trigger is clicked. It can be used to allow a link to a file to both trigger a popup and still download the file.', 'popup-maker' ),
|
126 |
'priority' => 20,
|
127 |
'std' => false,
|
128 |
-
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
}
|
134 |
|
135 |
/**
|
@@ -141,13 +141,16 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
141 |
* @return string
|
142 |
*/
|
143 |
public function handler( $atts, $content = null ) {
|
144 |
-
$atts
|
145 |
|
146 |
-
$tag
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
-
$return
|
149 |
-
$return .= esc_html( PUM_Helpers::do_shortcode( $content ) );
|
150 |
-
$return .= '</' . $tag . '>';
|
151 |
|
152 |
PUM_Site_Popups::preload_popup_by_id_if_enabled( $atts['id'] );
|
153 |
|
@@ -172,7 +175,7 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
172 |
$atts['tag'] = 'span';
|
173 |
}
|
174 |
|
175 |
-
if ( $atts['id']
|
176 |
$atts['id'] = $atts['custom_id'];
|
177 |
}
|
178 |
|
@@ -188,10 +191,11 @@ class PUM_Shortcode_PopupTrigger extends PUM_Shortcode {
|
|
188 |
global $allowedtags;
|
189 |
?>
|
190 |
<#
|
191 |
-
const allowedTags = <?php echo
|
192 |
const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
|
193 |
#>
|
194 |
-
<{{{tag}}} class="pum-trigger popmake-{{{attrs.id}}} {{{attrs.classes}}}">{{{attrs._inner_content}}}</{{{tag}}}
|
|
|
195 |
}
|
196 |
|
197 |
}
|
48 |
* @return array
|
49 |
*/
|
50 |
public function inner_content_labels() {
|
51 |
+
return [
|
52 |
'label' => __( 'Trigger Content', 'popup-maker' ),
|
53 |
'description' => __( 'Can contain other shortcodes, images, text or html content.' ),
|
54 |
+
];
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* @return array
|
59 |
*/
|
60 |
public function post_types() {
|
61 |
+
return [ 'post', 'page', 'popup' ];
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
* @return array
|
66 |
*/
|
67 |
public function fields() {
|
68 |
+
$select_args = [];
|
69 |
|
70 |
if ( isset( $_GET['post'] ) && is_int( (int) $_GET['post'] ) && isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) {
|
71 |
+
$select_args['post__not_in'] = wp_parse_id_list( [ get_the_ID(), $_GET['post'] ] );
|
72 |
}
|
73 |
|
74 |
+
return [
|
75 |
+
'general' => [
|
76 |
+
'main' => [
|
77 |
+
'id' => [
|
78 |
'label' => __( 'Targeted Popup', 'popup-maker' ),
|
79 |
'placeholder' => __( 'Choose a Popup', 'popup-maker' ),
|
80 |
'desc' => __( 'Choose which popup will be targeted by this trigger.', 'popup-maker' ),
|
82 |
'post_type' => 'popup',
|
83 |
'priority' => 5,
|
84 |
'required' => true,
|
85 |
+
'options' => PUM_Helpers::popup_selectlist( $select_args ) + [
|
86 |
+
'custom' => __( 'Custom', 'popup-maker' ),
|
87 |
+
],
|
88 |
'std' => 0,
|
89 |
+
],
|
90 |
+
'custom_id' => [
|
91 |
'label' => __( 'Custom Popup ID', 'popup-maker' ),
|
92 |
'type' => 'text',
|
93 |
+
'dependencies' => [
|
94 |
'id' => 'custom',
|
95 |
+
],
|
96 |
'std' => '',
|
97 |
+
],
|
98 |
+
],
|
99 |
+
],
|
100 |
+
'options' => [
|
101 |
+
'main' => [
|
102 |
+
'tag' => [
|
103 |
'label' => __( 'HTML Tag', 'popup-maker' ),
|
104 |
'placeholder' => __( 'HTML Tags: button, span etc.', 'popup-maker' ),
|
105 |
'desc' => __( 'The HTML tag used to generate the trigger and wrap your text.', 'popup-maker' ),
|
107 |
'std' => '',
|
108 |
'priority' => 10,
|
109 |
'required' => true,
|
110 |
+
],
|
111 |
+
'classes' => [
|
112 |
'label' => __( 'CSS Class', 'popup-maker' ),
|
113 |
'placeholder' => __( 'CSS Class', 'popup-maker' ),
|
114 |
'type' => 'text',
|
115 |
'desc' => __( 'Add additional classes for styling.', 'popup-maker' ),
|
116 |
'priority' => 15,
|
117 |
'std' => '',
|
118 |
+
],
|
119 |
+
'class' => [
|
120 |
+
'type' => 'hidden',
|
121 |
+
],
|
122 |
+
'do_default' => [
|
123 |
'type' => 'checkbox',
|
124 |
'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
|
125 |
'desc' => __( 'This prevents us from disabling the browsers default action when a trigger is clicked. It can be used to allow a link to a file to both trigger a popup and still download the file.', 'popup-maker' ),
|
126 |
'priority' => 20,
|
127 |
'std' => false,
|
128 |
+
],
|
129 |
|
130 |
+
],
|
131 |
+
],
|
132 |
+
];
|
133 |
}
|
134 |
|
135 |
/**
|
141 |
* @return string
|
142 |
*/
|
143 |
public function handler( $atts, $content = null ) {
|
144 |
+
$atts = $this->shortcode_atts( $atts );
|
145 |
|
146 |
+
$tag = esc_attr( $atts['tag'] );
|
147 |
+
$id = esc_attr( $atts['id'] );
|
148 |
+
$classes = esc_attr( $atts['classes'] );
|
149 |
+
$do_default = esc_attr( $atts['do_default'] );
|
150 |
+
// Escaped using notes here: https://wordpress.stackexchange.com/a/357349/63942.
|
151 |
+
$esc_content = PUM_Helpers::do_shortcode( force_balance_tags( wp_kses_post( $content ) ) );
|
152 |
|
153 |
+
$return = "<$tag class='pum-trigger popmake-$id $classes' data-do-default='$do_default'>$esc_content</$tag>";
|
|
|
|
|
154 |
|
155 |
PUM_Site_Popups::preload_popup_by_id_if_enabled( $atts['id'] );
|
156 |
|
175 |
$atts['tag'] = 'span';
|
176 |
}
|
177 |
|
178 |
+
if ( 'custom' === $atts['id'] ) {
|
179 |
$atts['id'] = $atts['custom_id'];
|
180 |
}
|
181 |
|
191 |
global $allowedtags;
|
192 |
?>
|
193 |
<#
|
194 |
+
const allowedTags = <?php echo wp_json_encode( array_keys( $allowedtags ) ); ?>;
|
195 |
const tag = allowedTags.indexOf( attrs.tag ) >= 0 ? attrs.tag : 'span';
|
196 |
#>
|
197 |
+
<{{{tag}}} class="pum-trigger popmake-{{{attrs.id}}} {{{attrs.classes}}}">{{{attrs._inner_content}}}</{{{tag}}}>
|
198 |
+
<?php
|
199 |
}
|
200 |
|
201 |
}
|
classes/Shortcode/Subscribe.php
CHANGED
@@ -49,19 +49,19 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
49 |
* @return array
|
50 |
*/
|
51 |
public function post_types() {
|
52 |
-
return
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
* @return array
|
57 |
*/
|
58 |
public function tabs() {
|
59 |
-
$tabs =
|
60 |
'general' => __( 'General', 'popup-maker' ),
|
61 |
'form' => __( 'Form', 'popup-maker' ),
|
62 |
'privacy' => __( 'Privacy', 'popup-maker' ),
|
63 |
'actions' => __( 'Actions', 'popup-maker' ),
|
64 |
-
|
65 |
|
66 |
// Deprecated filter
|
67 |
$tabs = apply_filters( 'pum_sub_form_shortcode_sections', $tabs );
|
@@ -75,25 +75,28 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
75 |
* @return array
|
76 |
*/
|
77 |
public function subtabs() {
|
78 |
-
$subtabs = apply_filters(
|
79 |
-
'
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
'
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
|
98 |
return $this->resort_provider_tabs( $subtabs );
|
99 |
}
|
@@ -102,340 +105,352 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
102 |
* @return array
|
103 |
*/
|
104 |
public function fields() {
|
105 |
-
$select_args =
|
106 |
|
107 |
if ( isset( $_GET['post'] ) && is_int( (int) $_GET['post'] ) && isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) {
|
108 |
-
$select_args['post__not_in'] = wp_parse_id_list(
|
109 |
}
|
110 |
|
111 |
$privacy_always_enabled = pum_get_option( 'privacy_consent_always_enabled', 'no' ) == 'yes';
|
112 |
|
113 |
-
$privacy_enabled_dependency =
|
114 |
'privacy_consent_enabled' => 'yes',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
);
|
116 |
|
117 |
-
$fields = apply_filters( 'pum_sub_form_shortcode_fields', array(
|
118 |
-
'general' => array(
|
119 |
-
'main' => array(
|
120 |
-
'provider' => array(
|
121 |
-
'label' => __( 'Service Provider', 'popup-maker' ),
|
122 |
-
'desc' => __( 'Choose which service provider to submit to.', 'popup-maker' ),
|
123 |
-
'type' => 'select',
|
124 |
-
'options' => array_merge( array( '' => __( 'Default', 'popup-maker' ) ), PUM_Newsletter_Providers::dropdown_list(), array( 'none' => __( 'None', 'popup-maker' ) ) ),
|
125 |
-
'std' => '',
|
126 |
-
),
|
127 |
-
),
|
128 |
-
),
|
129 |
-
'form' => array(
|
130 |
-
'fields' => array(
|
131 |
-
'name_field_type' => array(
|
132 |
-
'label' => __( 'Name Field Type', 'popup-maker' ),
|
133 |
-
'type' => 'select',
|
134 |
-
'options' => array(
|
135 |
-
'disabled' => __( 'None', 'popup-maker' ),
|
136 |
-
'fullname' => __( 'Full', 'popup-maker' ),
|
137 |
-
'first_only' => __( 'First Only', 'popup-maker' ),
|
138 |
-
'first_last' => __( 'First & Last', 'popup-maker' ),
|
139 |
-
),
|
140 |
-
'std' => 'fullname',
|
141 |
-
'private' => true,
|
142 |
-
),
|
143 |
-
'name_optional' => array(
|
144 |
-
'label' => __( 'Name Optional', 'popup-maker' ),
|
145 |
-
'desc' => __( 'Makes the name field optional.', 'popup-maker' ),
|
146 |
-
'type' => 'checkbox',
|
147 |
-
'dependencies' => array(
|
148 |
-
'name_field_type' => array( 'fullname', 'first_only', 'first_last' ),
|
149 |
-
),
|
150 |
-
'private' => true,
|
151 |
-
),
|
152 |
-
'name_disabled' => array(
|
153 |
-
'label' => __( 'Name Disabled', 'popup-maker' ),
|
154 |
-
'desc' => __( 'Removes the name field.', 'popup-maker' ),
|
155 |
-
'type' => 'checkbox',
|
156 |
-
'dependencies' => array(
|
157 |
-
'name_field_type' => false,
|
158 |
-
),
|
159 |
-
'private' => true,
|
160 |
-
),
|
161 |
-
|
162 |
-
),
|
163 |
-
'labels' => array(
|
164 |
-
'disable_labels' => array(
|
165 |
-
'label' => __( 'Disable Labels', 'popup-maker' ),
|
166 |
-
'desc' => __( 'Disables the display of field labels.', 'popup-maker' ),
|
167 |
-
'type' => 'checkbox',
|
168 |
-
'private' => true,
|
169 |
-
),
|
170 |
-
'heading_labels' => array(
|
171 |
-
'label' => __( 'Labels', 'popup-maker' ),
|
172 |
-
'desc' => __( 'Field label text', 'popup-maker' ),
|
173 |
-
'type' => 'heading',
|
174 |
-
'private' => true,
|
175 |
-
),
|
176 |
-
'label_name' => array(
|
177 |
-
'label' => __( 'Full Name', 'popup-maker' ),
|
178 |
-
'dependencies' => array(
|
179 |
-
'disable_labels' => false,
|
180 |
-
'name_field_type' => array( 'fullname' ),
|
181 |
-
),
|
182 |
-
'std' => __( 'Name', 'popup-maker' ),
|
183 |
-
'private' => true,
|
184 |
-
),
|
185 |
-
'label_fname' => array(
|
186 |
-
'label' => __( 'First Name', 'popup-maker' ),
|
187 |
-
'dependencies' => array(
|
188 |
-
'disable_labels' => false,
|
189 |
-
'name_field_type' => array( 'first_only', 'first_last' ),
|
190 |
-
),
|
191 |
-
'std' => __( 'First Name', 'popup-maker' ),
|
192 |
-
'private' => true,
|
193 |
-
),
|
194 |
-
'label_lname' => array(
|
195 |
-
'label' => __( 'Last Name', 'popup-maker' ),
|
196 |
-
'dependencies' => array(
|
197 |
-
'disable_labels' => false,
|
198 |
-
'name_field_type' => array( 'first_last' ),
|
199 |
-
),
|
200 |
-
'std' => __( 'Last Name', 'popup-maker' ),
|
201 |
-
'private' => true,
|
202 |
-
),
|
203 |
-
'label_email' => array(
|
204 |
-
'label' => __( 'Email', 'popup-maker' ),
|
205 |
-
'dependencies' => array(
|
206 |
-
'disable_labels' => false,
|
207 |
-
),
|
208 |
-
'std' => __( 'Email', 'popup-maker' ),
|
209 |
-
'private' => true,
|
210 |
-
),
|
211 |
-
'label_submit' => array(
|
212 |
-
'label' => __( 'Submit Button', 'popup-maker' ),
|
213 |
-
'std' => __( 'Subscribe', 'popup-maker' ),
|
214 |
-
'private' => true,
|
215 |
-
),
|
216 |
-
// Deprecated fields.
|
217 |
-
'name_text' => array(
|
218 |
-
'type' => 'hidden',
|
219 |
-
'private' => true,
|
220 |
-
),
|
221 |
-
'email_text' => array(
|
222 |
-
'private' => true,
|
223 |
-
'type' => 'hidden',
|
224 |
-
),
|
225 |
-
'button_text' => array(
|
226 |
-
'type' => 'hidden',
|
227 |
-
'private' => true,
|
228 |
-
),
|
229 |
-
),
|
230 |
-
'placeholders' => array(
|
231 |
-
'placeholder_name' => array(
|
232 |
-
'label' => __( 'Full Name', 'popup-maker' ),
|
233 |
-
'dependencies' => array(
|
234 |
-
'name_field_type' => array( 'fullname' ),
|
235 |
-
),
|
236 |
-
'std' => __( 'Name', 'popup-maker' ),
|
237 |
-
'private' => true,
|
238 |
-
),
|
239 |
-
'placeholder_fname' => array(
|
240 |
-
'label' => __( 'First Name', 'popup-maker' ),
|
241 |
-
'dependencies' => array(
|
242 |
-
'name_field_type' => array( 'first_only', 'first_last' ),
|
243 |
-
),
|
244 |
-
'std' => __( 'First Name', 'popup-maker' ),
|
245 |
-
'private' => true,
|
246 |
-
),
|
247 |
-
'placeholder_lname' => array(
|
248 |
-
'label' => __( 'Last Name', 'popup-maker' ),
|
249 |
-
'dependencies' => array(
|
250 |
-
'name_field_type' => array( 'first_last' ),
|
251 |
-
),
|
252 |
-
'std' => __( 'Last Name', 'popup-maker' ),
|
253 |
-
'private' => true,
|
254 |
-
),
|
255 |
-
'placeholder_email' => array(
|
256 |
-
'label' => __( 'Email', 'popup-maker' ),
|
257 |
-
'std' => __( 'Email', 'popup-maker' ),
|
258 |
-
'private' => true,
|
259 |
-
),
|
260 |
-
|
261 |
-
),
|
262 |
-
'appearance' => array(
|
263 |
-
'form_layout' => array(
|
264 |
-
'label' => __( 'Form Layout', 'popup-maker' ),
|
265 |
-
'desc' => __( 'Choose a form layout.', 'popup-maker' ),
|
266 |
-
'type' => 'select',
|
267 |
-
'options' => array(
|
268 |
-
'block' => __( 'Block', 'popup-maker' ),
|
269 |
-
'inline' => __( 'Inline', 'popup-maker' ),
|
270 |
-
),
|
271 |
-
'std' => 'block',
|
272 |
-
'private' => true,
|
273 |
-
),
|
274 |
-
'form_alignment' => array(
|
275 |
-
'label' => __( 'Form Alignment', 'popup-maker' ),
|
276 |
-
'desc' => __( 'Choose a form alignment.', 'popup-maker' ),
|
277 |
-
'type' => 'select',
|
278 |
-
'options' => array(
|
279 |
-
'left' => __( 'Left', 'popup-maker' ),
|
280 |
-
'center' => __( 'Center', 'popup-maker' ),
|
281 |
-
'right' => __( 'Right', 'popup-maker' ),
|
282 |
-
),
|
283 |
-
'std' => 'center',
|
284 |
-
'private' => true,
|
285 |
-
),
|
286 |
-
'form_style' => array(
|
287 |
-
'label' => __( 'Form Style', 'popup-maker' ),
|
288 |
-
'desc' => __( 'Choose how you want your form styled.', 'popup-maker' ),
|
289 |
-
'type' => 'select',
|
290 |
-
'options' => array(
|
291 |
-
'' => __( 'None', 'popup-maker' ),
|
292 |
-
'default' => __( 'Default', 'popup-maker' ),
|
293 |
-
),
|
294 |
-
'std' => 'default',
|
295 |
-
),
|
296 |
-
'layout' => array(
|
297 |
-
'type' => 'hidden',
|
298 |
-
'private' => true,
|
299 |
-
),
|
300 |
-
'style' => array(
|
301 |
-
'type' => 'hidden',
|
302 |
-
'private' => true,
|
303 |
-
),
|
304 |
-
),
|
305 |
-
),
|
306 |
-
'privacy' => array(
|
307 |
-
'main' => array(
|
308 |
-
'privacy_consent_enabled' => array(
|
309 |
-
'label' => __( 'Enabled', 'popup-maker' ),
|
310 |
-
'desc' => __( 'When enabled, the successful completion will result in normal success actions, but if they do not opt-in no records will be made.', 'popup-maker' ),
|
311 |
-
'type' => $privacy_always_enabled ? 'hidden' : 'select',
|
312 |
-
'options' => array(
|
313 |
-
'yes' => __( 'Yes', 'popup-maker' ),
|
314 |
-
'no' => __( 'No', 'popup-maker' ),
|
315 |
-
),
|
316 |
-
'std' => 'yes',
|
317 |
-
'value' => $privacy_always_enabled ? 'yes' : null,
|
318 |
-
'private' => true,
|
319 |
-
),
|
320 |
-
'privacy_consent_label' => array(
|
321 |
-
'label' => __( 'Consent Field Label', 'popup-maker' ),
|
322 |
-
'type' => 'text',
|
323 |
-
'std' => pum_get_option( 'default_privacy_consent_label', __( 'Notify me about related content and special offers.', 'popup-maker' ) ),
|
324 |
-
'private' => true,
|
325 |
-
'dependencies' => $privacy_enabled_dependency,
|
326 |
-
),
|
327 |
-
'privacy_consent_required' => array(
|
328 |
-
'label' => __( 'Consent Required', 'popup-maker' ),
|
329 |
-
'desc' => __( 'Note: Requiring consent may not be compliant with GDPR for all situations. Be sure to do your research or check with legal council.', 'popup-maker' ),
|
330 |
-
'type' => 'checkbox',
|
331 |
-
'std' => pum_get_option( 'default_privacy_consent_required' ),
|
332 |
-
'private' => true,
|
333 |
-
'dependencies' => $privacy_enabled_dependency,
|
334 |
-
),
|
335 |
-
'privacy_consent_type' => array(
|
336 |
-
'label' => __( 'Field Type', 'popup-maker' ),
|
337 |
-
'desc' => __( 'Radio forces the user to make a choice, often resulting in more optins.', 'popup-maker' ),
|
338 |
-
'type' => 'select',
|
339 |
-
'options' => array(
|
340 |
-
'radio' => __( 'Radio', 'popup-maker' ),
|
341 |
-
'checkbox' => __( 'Checkbox', 'popup-maker' ),
|
342 |
-
),
|
343 |
-
'std' => pum_get_option( 'default_privacy_consent_type', 'radio' ),
|
344 |
-
'private' => true,
|
345 |
-
'dependencies' => $privacy_enabled_dependency,
|
346 |
-
),
|
347 |
-
'privacy_consent_radio_layout' => array(
|
348 |
-
'label' => __( 'Consent Radio Layout', 'popup-maker' ),
|
349 |
-
'type' => 'select',
|
350 |
-
'options' => array(
|
351 |
-
'inline' => __( 'Inline', 'popup-maker' ),
|
352 |
-
'stacked' => __( 'Stacked', 'popup-maker' ),
|
353 |
-
),
|
354 |
-
'std' => pum_get_option( 'default_privacy_consent_radio_layout', 'inline' ),
|
355 |
-
'private' => true,
|
356 |
-
'dependencies' => array_merge( $privacy_enabled_dependency, array(
|
357 |
-
'privacy_consent_type' => 'radio',
|
358 |
-
) ),
|
359 |
-
),
|
360 |
-
'privacy_consent_yes_label' => array(
|
361 |
-
'label' => __( 'Consent Yes Label', 'popup-maker' ),
|
362 |
-
'type' => 'text',
|
363 |
-
'std' => pum_get_option( 'default_privacy_consent_yes_label', __( 'Yes', 'popup-maker' ) ),
|
364 |
-
'private' => true,
|
365 |
-
'dependencies' => array_merge( $privacy_enabled_dependency, array(
|
366 |
-
'privacy_consent_type' => 'radio',
|
367 |
-
) ),
|
368 |
-
),
|
369 |
-
'privacy_consent_no_label' => array(
|
370 |
-
'label' => __( 'Consent No Label', 'popup-maker' ),
|
371 |
-
'type' => 'text',
|
372 |
-
'std' => pum_get_option( 'default_privacy_consent_no_label', __( 'No', 'popup-maker' ) ),
|
373 |
-
'private' => true,
|
374 |
-
'dependencies' => array_merge( $privacy_enabled_dependency, array(
|
375 |
-
'privacy_consent_type' => 'radio',
|
376 |
-
) ),
|
377 |
-
),
|
378 |
-
'privacy_usage_text' => array(
|
379 |
-
'label' => __( 'Consent Usage Text', 'popup-maker' ),
|
380 |
-
'desc' => function_exists( 'get_privacy_policy_url' ) ? sprintf( __( 'You can use %1$s%2$s to insert a link to your privacy policy. To customize the link text use %1$s:Link Text%2$s', 'popup-maker' ), '{{privacy_link', '}}' ) : '',
|
381 |
-
'type' => 'text',
|
382 |
-
'std' => pum_get_option( 'default_privacy_usage_text', __( 'If you opt in above we use this information send related content, discounts and other special offers.', 'popup-maker' ) ),
|
383 |
-
'dependencies' => $privacy_enabled_dependency,
|
384 |
-
),
|
385 |
-
),
|
386 |
-
),
|
387 |
-
'actions' => array(
|
388 |
-
'popup' => array(
|
389 |
-
'closepopup' => array(
|
390 |
-
'label' => __( 'Close Popup', 'popup-maker' ),
|
391 |
-
'type' => 'checkbox',
|
392 |
-
),
|
393 |
-
'closedelay' => array(
|
394 |
-
'label' => __( 'Delay', 'popup-maker' ),
|
395 |
-
'type' => 'rangeslider',
|
396 |
-
'min' => 0,
|
397 |
-
'max' => 180,
|
398 |
-
'step' => 1,
|
399 |
-
'unit' => 's',
|
400 |
-
'std' => 0,
|
401 |
-
'dependencies' => array(
|
402 |
-
'closepopup' => true,
|
403 |
-
),
|
404 |
-
),
|
405 |
-
'openpopup' => array(
|
406 |
-
'label' => __( 'Open Popup', 'popup-maker' ),
|
407 |
-
'type' => 'checkbox',
|
408 |
-
),
|
409 |
-
'openpopup_id' => array(
|
410 |
-
'label' => __( 'Popup ID', 'popup-maker' ),
|
411 |
-
'type' => 'select',
|
412 |
-
'options' => array(
|
413 |
-
0 => __( 'Select a popup', 'popup-maker' ),
|
414 |
-
) + PUM_Helpers::popup_selectlist( $select_args ),
|
415 |
-
'std' => 0,
|
416 |
-
'dependencies' => array(
|
417 |
-
'openpopup' => true,
|
418 |
-
),
|
419 |
-
),
|
420 |
-
),
|
421 |
-
'redirect' => array(
|
422 |
-
'redirect_enabled' => array(
|
423 |
-
'label' => __( 'Redirect', 'popup-maker' ),
|
424 |
-
'desc' => __( 'Enable refreshing the page or redirecting after success.', 'popup-maker' ),
|
425 |
-
'type' => 'checkbox',
|
426 |
-
),
|
427 |
-
'redirect' => array(
|
428 |
-
'label' => __( 'Redirect URL', 'popup-maker' ),
|
429 |
-
'desc' => __( 'Leave blank to refresh, or enter a url that users will be taken to after success.', 'popup-maker' ),
|
430 |
-
'std' => '',
|
431 |
-
'dependencies' => array(
|
432 |
-
'redirect_enabled' => true,
|
433 |
-
),
|
434 |
-
),
|
435 |
-
),
|
436 |
-
),
|
437 |
-
) );
|
438 |
-
|
439 |
return $this->resort_provider_tabs( $fields );
|
440 |
}
|
441 |
|
@@ -446,7 +461,7 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
446 |
*
|
447 |
* @return array
|
448 |
*/
|
449 |
-
public function resort_provider_tabs( $tabs =
|
450 |
$sorted_tabs = $tabs;
|
451 |
|
452 |
foreach ( $tabs as $tab_id => $tab ) {
|
@@ -479,18 +494,21 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
479 |
|
480 |
$data_attr = $this->data_attr( $atts );
|
481 |
|
482 |
-
$classes = implode(
|
483 |
-
'
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
|
|
|
|
|
|
494 |
|
495 |
|
496 |
<form class="<?php echo esc_attr( $classes ); ?>" data-settings="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $data_attr ) ); ?>">
|
@@ -499,13 +517,13 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
499 |
|
500 |
<?php
|
501 |
|
502 |
-
|
503 |
if ( ! $atts['name_field_type'] != 'disabled' ) :
|
504 |
|
505 |
$required = ! $atts['name_optional'] ? 'required' : '';
|
506 |
|
507 |
switch ( $atts['name_field_type'] ) {
|
508 |
-
case 'fullname':
|
|
|
509 |
|
510 |
<div class="pum-form__field pum-form__field--name pum-sub-form-field pum-sub-form-field--name">
|
511 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
@@ -517,7 +535,8 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
517 |
<?php
|
518 |
break;
|
519 |
|
520 |
-
case 'first_only':
|
|
|
521 |
|
522 |
<div class="pum-form__field pum-form__field--fname pum-sub-form-field pum-sub-form-field--fname">
|
523 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
@@ -529,7 +548,8 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
529 |
<?php
|
530 |
break;
|
531 |
|
532 |
-
case 'first_last':
|
|
|
533 |
|
534 |
<div class="pum-form__field pum-form__field--fname pum-sub-form-field pum-sub-form-field--fname">
|
535 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
@@ -547,7 +567,8 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
547 |
|
548 |
<?php
|
549 |
break;
|
550 |
-
}
|
|
|
551 |
|
552 |
<?php endif; ?>
|
553 |
|
@@ -564,35 +585,39 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
564 |
|
565 |
<input type="hidden" name="provider" value="<?php echo esc_attr( $atts['provider'] ); ?>" />
|
566 |
|
567 |
-
<?php
|
|
|
568 |
$consent_text = trim( $atts['privacy_consent_label'] );
|
569 |
-
$consent_args =
|
570 |
-
'enabled'
|
571 |
'required' => isset( $atts['privacy_consent_required'] ) && $atts['privacy_consent_required'],
|
572 |
-
'text'
|
573 |
-
|
574 |
?>
|
575 |
|
576 |
<input type="hidden" name="consent_args" value="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $consent_args ) ); ?>" />
|
577 |
|
578 |
<div class="pum-form__field pum-form__field--<?php echo esc_attr( $atts['privacy_consent_type'] ); ?> pum-form__field--consent pum-sub-form-field">
|
579 |
-
<?php
|
580 |
-
|
|
|
|
|
581 |
<label class="pum-form__label pum-sub-form-label">
|
582 |
-
<input type="checkbox" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo wp_kses( $consent_text,
|
583 |
</label>
|
584 |
<?php
|
585 |
break;
|
586 |
-
case 'radio':
|
|
|
587 |
<?php if ( ! empty( $consent_text ) ) : ?>
|
588 |
-
<label class="pum-form__label pum-sub-form-label"><?php echo esc_html( wp_kses( $consent_text,
|
589 |
<?php endif; ?>
|
590 |
<div class="pum-form__consent-radios pum-form__consent-radios--<?php echo esc_attr( $atts['privacy_consent_radio_layout'] ); ?>">
|
591 |
<label class="pum-form__label pum-sub-form-label">
|
592 |
-
<input type="radio" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo esc_html( wp_kses( $atts['privacy_consent_yes_label'],
|
593 |
</label>
|
594 |
<label class="pum-form__label pum-sub-form-label">
|
595 |
-
<input type="radio" value="no" name="consent" /> <?php echo esc_html( wp_kses( $atts['privacy_consent_no_label'],
|
596 |
</label>
|
597 |
</div>
|
598 |
<?php
|
@@ -603,7 +628,7 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
603 |
$usage_text = trim( $atts['privacy_usage_text'] );
|
604 |
|
605 |
if ( strpos( $usage_text, '{{privacy_link' ) !== false && function_exists( 'get_privacy_policy_url' ) && get_privacy_policy_url() !== '' ) {
|
606 |
-
preg_match_all(
|
607 |
|
608 |
$link = '<a href="' . get_privacy_policy_url() . '" target="_blank">%s</a>';
|
609 |
|
@@ -613,7 +638,21 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
613 |
}
|
614 |
?>
|
615 |
<p>
|
616 |
-
<small
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
</p>
|
618 |
<?php endif; ?>
|
619 |
</div>
|
@@ -628,7 +667,7 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
628 |
|
629 |
<?php
|
630 |
|
631 |
-
//return content
|
632 |
return ob_get_clean();
|
633 |
}
|
634 |
|
@@ -687,8 +726,8 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
687 |
*
|
688 |
* @return array
|
689 |
*/
|
690 |
-
public function data_attr( $atts =
|
691 |
-
$data =
|
692 |
|
693 |
$data_attr_fields = $this->data_attr_fields();
|
694 |
|
@@ -711,20 +750,24 @@ class PUM_Shortcode_Subscribe extends PUM_Shortcode {
|
|
711 |
* @return mixed
|
712 |
*/
|
713 |
public function data_attr_fields() {
|
714 |
-
return apply_filters(
|
715 |
-
'
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
|
|
|
|
|
|
722 |
}
|
723 |
|
724 |
/**
|
725 |
*
|
726 |
*/
|
727 |
-
public function template() {
|
|
|
728 |
<p class="pum-sub-form-desc">
|
729 |
<?php _e( 'Subscription Form Placeholder', 'popup-maker' ); ?>
|
730 |
</p>
|
49 |
* @return array
|
50 |
*/
|
51 |
public function post_types() {
|
52 |
+
return [ 'page', 'post', 'popup' ];
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
* @return array
|
57 |
*/
|
58 |
public function tabs() {
|
59 |
+
$tabs = [
|
60 |
'general' => __( 'General', 'popup-maker' ),
|
61 |
'form' => __( 'Form', 'popup-maker' ),
|
62 |
'privacy' => __( 'Privacy', 'popup-maker' ),
|
63 |
'actions' => __( 'Actions', 'popup-maker' ),
|
64 |
+
];
|
65 |
|
66 |
// Deprecated filter
|
67 |
$tabs = apply_filters( 'pum_sub_form_shortcode_sections', $tabs );
|
75 |
* @return array
|
76 |
*/
|
77 |
public function subtabs() {
|
78 |
+
$subtabs = apply_filters(
|
79 |
+
'pum_sub_form_shortcode_subtabs',
|
80 |
+
[
|
81 |
+
'general' => [
|
82 |
+
'main' => __( 'General', 'popup-maker' ),
|
83 |
+
],
|
84 |
+
'privacy' => [
|
85 |
+
'main' => __( 'General', 'popup-maker' ),
|
86 |
+
],
|
87 |
+
'form' => [
|
88 |
+
'appearance' => __( 'Appearance', 'popup-maker' ),
|
89 |
+
'fields' => __( 'Fields', 'popup-maker' ),
|
90 |
+
'labels' => __( 'Labels', 'popup-maker' ),
|
91 |
+
'placeholders' => __( 'Placeholders', 'popup-maker' ),
|
92 |
+
'privacy' => __( 'Privacy', 'popup-maker' ),
|
93 |
+
],
|
94 |
+
'actions' => [
|
95 |
+
'popup' => __( 'Popup', 'popup-maker' ),
|
96 |
+
'redirect' => __( 'Redirect', 'popup-maker' ),
|
97 |
+
],
|
98 |
+
]
|
99 |
+
);
|
100 |
|
101 |
return $this->resort_provider_tabs( $subtabs );
|
102 |
}
|
105 |
* @return array
|
106 |
*/
|
107 |
public function fields() {
|
108 |
+
$select_args = [];
|
109 |
|
110 |
if ( isset( $_GET['post'] ) && is_int( (int) $_GET['post'] ) && isset( $_GET['action'] ) && $_GET['action'] == 'edit' ) {
|
111 |
+
$select_args['post__not_in'] = wp_parse_id_list( [ get_the_ID(), $_GET['post'] ] );
|
112 |
}
|
113 |
|
114 |
$privacy_always_enabled = pum_get_option( 'privacy_consent_always_enabled', 'no' ) == 'yes';
|
115 |
|
116 |
+
$privacy_enabled_dependency = [
|
117 |
'privacy_consent_enabled' => 'yes',
|
118 |
+
];
|
119 |
+
|
120 |
+
$fields = apply_filters(
|
121 |
+
'pum_sub_form_shortcode_fields',
|
122 |
+
[
|
123 |
+
'general' => [
|
124 |
+
'main' => [
|
125 |
+
'provider' => [
|
126 |
+
'label' => __( 'Service Provider', 'popup-maker' ),
|
127 |
+
'desc' => __( 'Choose which service provider to submit to.', 'popup-maker' ),
|
128 |
+
'type' => 'select',
|
129 |
+
'options' => array_merge( [ '' => __( 'Default', 'popup-maker' ) ], PUM_Newsletter_Providers::dropdown_list(), [ 'none' => __( 'None', 'popup-maker' ) ] ),
|
130 |
+
'std' => '',
|
131 |
+
],
|
132 |
+
],
|
133 |
+
],
|
134 |
+
'form' => [
|
135 |
+
'fields' => [
|
136 |
+
'name_field_type' => [
|
137 |
+
'label' => __( 'Name Field Type', 'popup-maker' ),
|
138 |
+
'type' => 'select',
|
139 |
+
'options' => [
|
140 |
+
'disabled' => __( 'None', 'popup-maker' ),
|
141 |
+
'fullname' => __( 'Full', 'popup-maker' ),
|
142 |
+
'first_only' => __( 'First Only', 'popup-maker' ),
|
143 |
+
'first_last' => __( 'First & Last', 'popup-maker' ),
|
144 |
+
],
|
145 |
+
'std' => 'fullname',
|
146 |
+
'private' => true,
|
147 |
+
],
|
148 |
+
'name_optional' => [
|
149 |
+
'label' => __( 'Name Optional', 'popup-maker' ),
|
150 |
+
'desc' => __( 'Makes the name field optional.', 'popup-maker' ),
|
151 |
+
'type' => 'checkbox',
|
152 |
+
'dependencies' => [
|
153 |
+
'name_field_type' => [ 'fullname', 'first_only', 'first_last' ],
|
154 |
+
],
|
155 |
+
'private' => true,
|
156 |
+
],
|
157 |
+
'name_disabled' => [
|
158 |
+
'label' => __( 'Name Disabled', 'popup-maker' ),
|
159 |
+
'desc' => __( 'Removes the name field.', 'popup-maker' ),
|
160 |
+
'type' => 'checkbox',
|
161 |
+
'dependencies' => [
|
162 |
+
'name_field_type' => false,
|
163 |
+
],
|
164 |
+
'private' => true,
|
165 |
+
],
|
166 |
+
|
167 |
+
],
|
168 |
+
'labels' => [
|
169 |
+
'disable_labels' => [
|
170 |
+
'label' => __( 'Disable Labels', 'popup-maker' ),
|
171 |
+
'desc' => __( 'Disables the display of field labels.', 'popup-maker' ),
|
172 |
+
'type' => 'checkbox',
|
173 |
+
'private' => true,
|
174 |
+
],
|
175 |
+
'heading_labels' => [
|
176 |
+
'label' => __( 'Labels', 'popup-maker' ),
|
177 |
+
'desc' => __( 'Field label text', 'popup-maker' ),
|
178 |
+
'type' => 'heading',
|
179 |
+
'private' => true,
|
180 |
+
],
|
181 |
+
'label_name' => [
|
182 |
+
'label' => __( 'Full Name', 'popup-maker' ),
|
183 |
+
'dependencies' => [
|
184 |
+
'disable_labels' => false,
|
185 |
+
'name_field_type' => [ 'fullname' ],
|
186 |
+
],
|
187 |
+
'std' => __( 'Name', 'popup-maker' ),
|
188 |
+
'private' => true,
|
189 |
+
],
|
190 |
+
'label_fname' => [
|
191 |
+
'label' => __( 'First Name', 'popup-maker' ),
|
192 |
+
'dependencies' => [
|
193 |
+
'disable_labels' => false,
|
194 |
+
'name_field_type' => [ 'first_only', 'first_last' ],
|
195 |
+
],
|
196 |
+
'std' => __( 'First Name', 'popup-maker' ),
|
197 |
+
'private' => true,
|
198 |
+
],
|
199 |
+
'label_lname' => [
|
200 |
+
'label' => __( 'Last Name', 'popup-maker' ),
|
201 |
+
'dependencies' => [
|
202 |
+
'disable_labels' => false,
|
203 |
+
'name_field_type' => [ 'first_last' ],
|
204 |
+
],
|
205 |
+
'std' => __( 'Last Name', 'popup-maker' ),
|
206 |
+
'private' => true,
|
207 |
+
],
|
208 |
+
'label_email' => [
|
209 |
+
'label' => __( 'Email', 'popup-maker' ),
|
210 |
+
'dependencies' => [
|
211 |
+
'disable_labels' => false,
|
212 |
+
],
|
213 |
+
'std' => __( 'Email', 'popup-maker' ),
|
214 |
+
'private' => true,
|
215 |
+
],
|
216 |
+
'label_submit' => [
|
217 |
+
'label' => __( 'Submit Button', 'popup-maker' ),
|
218 |
+
'std' => __( 'Subscribe', 'popup-maker' ),
|
219 |
+
'private' => true,
|
220 |
+
],
|
221 |
+
// Deprecated fields.
|
222 |
+
'name_text' => [
|
223 |
+
'type' => 'hidden',
|
224 |
+
'private' => true,
|
225 |
+
],
|
226 |
+
'email_text' => [
|
227 |
+
'private' => true,
|
228 |
+
'type' => 'hidden',
|
229 |
+
],
|
230 |
+
'button_text' => [
|
231 |
+
'type' => 'hidden',
|
232 |
+
'private' => true,
|
233 |
+
],
|
234 |
+
],
|
235 |
+
'placeholders' => [
|
236 |
+
'placeholder_name' => [
|
237 |
+
'label' => __( 'Full Name', 'popup-maker' ),
|
238 |
+
'dependencies' => [
|
239 |
+
'name_field_type' => [ 'fullname' ],
|
240 |
+
],
|
241 |
+
'std' => __( 'Name', 'popup-maker' ),
|
242 |
+
'private' => true,
|
243 |
+
],
|
244 |
+
'placeholder_fname' => [
|
245 |
+
'label' => __( 'First Name', 'popup-maker' ),
|
246 |
+
'dependencies' => [
|
247 |
+
'name_field_type' => [ 'first_only', 'first_last' ],
|
248 |
+
],
|
249 |
+
'std' => __( 'First Name', 'popup-maker' ),
|
250 |
+
'private' => true,
|
251 |
+
],
|
252 |
+
'placeholder_lname' => [
|
253 |
+
'label' => __( 'Last Name', 'popup-maker' ),
|
254 |
+
'dependencies' => [
|
255 |
+
'name_field_type' => [ 'first_last' ],
|
256 |
+
],
|
257 |
+
'std' => __( 'Last Name', 'popup-maker' ),
|
258 |
+
'private' => true,
|
259 |
+
],
|
260 |
+
'placeholder_email' => [
|
261 |
+
'label' => __( 'Email', 'popup-maker' ),
|
262 |
+
'std' => __( 'Email', 'popup-maker' ),
|
263 |
+
'private' => true,
|
264 |
+
],
|
265 |
+
|
266 |
+
],
|
267 |
+
'appearance' => [
|
268 |
+
'form_layout' => [
|
269 |
+
'label' => __( 'Form Layout', 'popup-maker' ),
|
270 |
+
'desc' => __( 'Choose a form layout.', 'popup-maker' ),
|
271 |
+
'type' => 'select',
|
272 |
+
'options' => [
|
273 |
+
'block' => __( 'Block', 'popup-maker' ),
|
274 |
+
'inline' => __( 'Inline', 'popup-maker' ),
|
275 |
+
],
|
276 |
+
'std' => 'block',
|
277 |
+
'private' => true,
|
278 |
+
],
|
279 |
+
'form_alignment' => [
|
280 |
+
'label' => __( 'Form Alignment', 'popup-maker' ),
|
281 |
+
'desc' => __( 'Choose a form alignment.', 'popup-maker' ),
|
282 |
+
'type' => 'select',
|
283 |
+
'options' => [
|
284 |
+
'left' => __( 'Left', 'popup-maker' ),
|
285 |
+
'center' => __( 'Center', 'popup-maker' ),
|
286 |
+
'right' => __( 'Right', 'popup-maker' ),
|
287 |
+
],
|
288 |
+
'std' => 'center',
|
289 |
+
'private' => true,
|
290 |
+
],
|
291 |
+
'form_style' => [
|
292 |
+
'label' => __( 'Form Style', 'popup-maker' ),
|
293 |
+
'desc' => __( 'Choose how you want your form styled.', 'popup-maker' ),
|
294 |
+
'type' => 'select',
|
295 |
+
'options' => [
|
296 |
+
'' => __( 'None', 'popup-maker' ),
|
297 |
+
'default' => __( 'Default', 'popup-maker' ),
|
298 |
+
],
|
299 |
+
'std' => 'default',
|
300 |
+
],
|
301 |
+
'layout' => [
|
302 |
+
'type' => 'hidden',
|
303 |
+
'private' => true,
|
304 |
+
],
|
305 |
+
'style' => [
|
306 |
+
'type' => 'hidden',
|
307 |
+
'private' => true,
|
308 |
+
],
|
309 |
+
],
|
310 |
+
],
|
311 |
+
'privacy' => [
|
312 |
+
'main' => [
|
313 |
+
'privacy_consent_enabled' => [
|
314 |
+
'label' => __( 'Enabled', 'popup-maker' ),
|
315 |
+
'desc' => __( 'When enabled, the successful completion will result in normal success actions, but if they do not opt-in no records will be made.', 'popup-maker' ),
|
316 |
+
'type' => $privacy_always_enabled ? 'hidden' : 'select',
|
317 |
+
'options' => [
|
318 |
+
'yes' => __( 'Yes', 'popup-maker' ),
|
319 |
+
'no' => __( 'No', 'popup-maker' ),
|
320 |
+
],
|
321 |
+
'std' => 'yes',
|
322 |
+
'value' => $privacy_always_enabled ? 'yes' : null,
|
323 |
+
'private' => true,
|
324 |
+
],
|
325 |
+
'privacy_consent_label' => [
|
326 |
+
'label' => __( 'Consent Field Label', 'popup-maker' ),
|
327 |
+
'type' => 'text',
|
328 |
+
'std' => pum_get_option( 'default_privacy_consent_label', __( 'Notify me about related content and special offers.', 'popup-maker' ) ),
|
329 |
+
'private' => true,
|
330 |
+
'dependencies' => $privacy_enabled_dependency,
|
331 |
+
],
|
332 |
+
'privacy_consent_required' => [
|
333 |
+
'label' => __( 'Consent Required', 'popup-maker' ),
|
334 |
+
'desc' => __( 'Note: Requiring consent may not be compliant with GDPR for all situations. Be sure to do your research or check with legal council.', 'popup-maker' ),
|
335 |
+
'type' => 'checkbox',
|
336 |
+
'std' => pum_get_option( 'default_privacy_consent_required' ),
|
337 |
+
'private' => true,
|
338 |
+
'dependencies' => $privacy_enabled_dependency,
|
339 |
+
],
|
340 |
+
'privacy_consent_type' => [
|
341 |
+
'label' => __( 'Field Type', 'popup-maker' ),
|
342 |
+
'desc' => __( 'Radio forces the user to make a choice, often resulting in more optins.', 'popup-maker' ),
|
343 |
+
'type' => 'select',
|
344 |
+
'options' => [
|
345 |
+
'radio' => __( 'Radio', 'popup-maker' ),
|
346 |
+
'checkbox' => __( 'Checkbox', 'popup-maker' ),
|
347 |
+
],
|
348 |
+
'std' => pum_get_option( 'default_privacy_consent_type', 'radio' ),
|
349 |
+
'private' => true,
|
350 |
+
'dependencies' => $privacy_enabled_dependency,
|
351 |
+
],
|
352 |
+
'privacy_consent_radio_layout' => [
|
353 |
+
'label' => __( 'Consent Radio Layout', 'popup-maker' ),
|
354 |
+
'type' => 'select',
|
355 |
+
'options' => [
|
356 |
+
'inline' => __( 'Inline', 'popup-maker' ),
|
357 |
+
'stacked' => __( 'Stacked', 'popup-maker' ),
|
358 |
+
],
|
359 |
+
'std' => pum_get_option( 'default_privacy_consent_radio_layout', 'inline' ),
|
360 |
+
'private' => true,
|
361 |
+
'dependencies' => array_merge(
|
362 |
+
$privacy_enabled_dependency,
|
363 |
+
[
|
364 |
+
'privacy_consent_type' => 'radio',
|
365 |
+
]
|
366 |
+
),
|
367 |
+
],
|
368 |
+
'privacy_consent_yes_label' => [
|
369 |
+
'label' => __( 'Consent Yes Label', 'popup-maker' ),
|
370 |
+
'type' => 'text',
|
371 |
+
'std' => pum_get_option( 'default_privacy_consent_yes_label', __( 'Yes', 'popup-maker' ) ),
|
372 |
+
'private' => true,
|
373 |
+
'dependencies' => array_merge(
|
374 |
+
$privacy_enabled_dependency,
|
375 |
+
[
|
376 |
+
'privacy_consent_type' => 'radio',
|
377 |
+
]
|
378 |
+
),
|
379 |
+
],
|
380 |
+
'privacy_consent_no_label' => [
|
381 |
+
'label' => __( 'Consent No Label', 'popup-maker' ),
|
382 |
+
'type' => 'text',
|
383 |
+
'std' => pum_get_option( 'default_privacy_consent_no_label', __( 'No', 'popup-maker' ) ),
|
384 |
+
'private' => true,
|
385 |
+
'dependencies' => array_merge(
|
386 |
+
$privacy_enabled_dependency,
|
387 |
+
[
|
388 |
+
'privacy_consent_type' => 'radio',
|
389 |
+
]
|
390 |
+
),
|
391 |
+
],
|
392 |
+
'privacy_usage_text' => [
|
393 |
+
'label' => __( 'Consent Usage Text', 'popup-maker' ),
|
394 |
+
'desc' => function_exists( 'get_privacy_policy_url' ) ? sprintf( __( 'You can use %1$s%2$s to insert a link to your privacy policy. To customize the link text use %1$s:Link Text%2$s', 'popup-maker' ), '{{privacy_link', '}}' ) : '',
|
395 |
+
'type' => 'text',
|
396 |
+
'std' => pum_get_option( 'default_privacy_usage_text', __( 'If you opt in above we use this information send related content, discounts and other special offers.', 'popup-maker' ) ),
|
397 |
+
'dependencies' => $privacy_enabled_dependency,
|
398 |
+
],
|
399 |
+
],
|
400 |
+
],
|
401 |
+
'actions' => [
|
402 |
+
'popup' => [
|
403 |
+
'closepopup' => [
|
404 |
+
'label' => __( 'Close Popup', 'popup-maker' ),
|
405 |
+
'type' => 'checkbox',
|
406 |
+
],
|
407 |
+
'closedelay' => [
|
408 |
+
'label' => __( 'Delay', 'popup-maker' ),
|
409 |
+
'type' => 'rangeslider',
|
410 |
+
'min' => 0,
|
411 |
+
'max' => 180,
|
412 |
+
'step' => 1,
|
413 |
+
'unit' => 's',
|
414 |
+
'std' => 0,
|
415 |
+
'dependencies' => [
|
416 |
+
'closepopup' => true,
|
417 |
+
],
|
418 |
+
],
|
419 |
+
'openpopup' => [
|
420 |
+
'label' => __( 'Open Popup', 'popup-maker' ),
|
421 |
+
'type' => 'checkbox',
|
422 |
+
],
|
423 |
+
'openpopup_id' => [
|
424 |
+
'label' => __( 'Popup ID', 'popup-maker' ),
|
425 |
+
'type' => 'select',
|
426 |
+
'options' => [
|
427 |
+
0 => __( 'Select a popup', 'popup-maker' ),
|
428 |
+
] + PUM_Helpers::popup_selectlist( $select_args ),
|
429 |
+
'std' => 0,
|
430 |
+
'dependencies' => [
|
431 |
+
'openpopup' => true,
|
432 |
+
],
|
433 |
+
],
|
434 |
+
],
|
435 |
+
'redirect' => [
|
436 |
+
'redirect_enabled' => [
|
437 |
+
'label' => __( 'Redirect', 'popup-maker' ),
|
438 |
+
'desc' => __( 'Enable refreshing the page or redirecting after success.', 'popup-maker' ),
|
439 |
+
'type' => 'checkbox',
|
440 |
+
],
|
441 |
+
'redirect' => [
|
442 |
+
'label' => __( 'Redirect URL', 'popup-maker' ),
|
443 |
+
'desc' => __( 'Leave blank to refresh, or enter a url that users will be taken to after success.', 'popup-maker' ),
|
444 |
+
'std' => '',
|
445 |
+
'dependencies' => [
|
446 |
+
'redirect_enabled' => true,
|
447 |
+
],
|
448 |
+
],
|
449 |
+
],
|
450 |
+
],
|
451 |
+
]
|
452 |
);
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
return $this->resort_provider_tabs( $fields );
|
455 |
}
|
456 |
|
461 |
*
|
462 |
* @return array
|
463 |
*/
|
464 |
+
public function resort_provider_tabs( $tabs = [] ) {
|
465 |
$sorted_tabs = $tabs;
|
466 |
|
467 |
foreach ( $tabs as $tab_id => $tab ) {
|
494 |
|
495 |
$data_attr = $this->data_attr( $atts );
|
496 |
|
497 |
+
$classes = implode(
|
498 |
+
' ',
|
499 |
+
[
|
500 |
+
'pum_sub_form',
|
501 |
+
$atts['provider'],
|
502 |
+
$atts['form_layout'],
|
503 |
+
$atts['form_style'],
|
504 |
+
'pum-sub-form',
|
505 |
+
'pum-form',
|
506 |
+
'pum-sub-form--provider-' . $atts['provider'],
|
507 |
+
'pum-form--layout-' . $atts['form_layout'],
|
508 |
+
'pum-form--style-' . $atts['form_style'],
|
509 |
+
'pum-form--alignment-' . $atts['form_alignment'],
|
510 |
+
]
|
511 |
+
); ?>
|
512 |
|
513 |
|
514 |
<form class="<?php echo esc_attr( $classes ); ?>" data-settings="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $data_attr ) ); ?>">
|
517 |
|
518 |
<?php
|
519 |
|
|
|
520 |
if ( ! $atts['name_field_type'] != 'disabled' ) :
|
521 |
|
522 |
$required = ! $atts['name_optional'] ? 'required' : '';
|
523 |
|
524 |
switch ( $atts['name_field_type'] ) {
|
525 |
+
case 'fullname':
|
526 |
+
?>
|
527 |
|
528 |
<div class="pum-form__field pum-form__field--name pum-sub-form-field pum-sub-form-field--name">
|
529 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
535 |
<?php
|
536 |
break;
|
537 |
|
538 |
+
case 'first_only':
|
539 |
+
?>
|
540 |
|
541 |
<div class="pum-form__field pum-form__field--fname pum-sub-form-field pum-sub-form-field--fname">
|
542 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
548 |
<?php
|
549 |
break;
|
550 |
|
551 |
+
case 'first_last':
|
552 |
+
?>
|
553 |
|
554 |
<div class="pum-form__field pum-form__field--fname pum-sub-form-field pum-sub-form-field--fname">
|
555 |
<?php if ( ! $atts['disable_labels'] ) : ?>
|
567 |
|
568 |
<?php
|
569 |
break;
|
570 |
+
}
|
571 |
+
?>
|
572 |
|
573 |
<?php endif; ?>
|
574 |
|
585 |
|
586 |
<input type="hidden" name="provider" value="<?php echo esc_attr( $atts['provider'] ); ?>" />
|
587 |
|
588 |
+
<?php
|
589 |
+
if ( $atts['privacy_consent_enabled'] == 'yes' ) :
|
590 |
$consent_text = trim( $atts['privacy_consent_label'] );
|
591 |
+
$consent_args = [
|
592 |
+
'enabled' => 'yes',
|
593 |
'required' => isset( $atts['privacy_consent_required'] ) && $atts['privacy_consent_required'],
|
594 |
+
'text' => ! empty( $consent_text ) ? $consent_text : ( ! empty( $atts['privacy_consent_yes_label'] ) ? $atts['privacy_consent_yes_label'] : '' ),
|
595 |
+
];
|
596 |
?>
|
597 |
|
598 |
<input type="hidden" name="consent_args" value="<?php echo esc_attr( PUM_Utils_Array::safe_json_encode( $consent_args ) ); ?>" />
|
599 |
|
600 |
<div class="pum-form__field pum-form__field--<?php echo esc_attr( $atts['privacy_consent_type'] ); ?> pum-form__field--consent pum-sub-form-field">
|
601 |
+
<?php
|
602 |
+
switch ( $atts['privacy_consent_type'] ) {
|
603 |
+
case 'checkbox':
|
604 |
+
?>
|
605 |
<label class="pum-form__label pum-sub-form-label">
|
606 |
+
<input type="checkbox" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo wp_kses( $consent_text, [] ); ?>
|
607 |
</label>
|
608 |
<?php
|
609 |
break;
|
610 |
+
case 'radio':
|
611 |
+
?>
|
612 |
<?php if ( ! empty( $consent_text ) ) : ?>
|
613 |
+
<label class="pum-form__label pum-sub-form-label"><?php echo esc_html( wp_kses( $consent_text, [] ) ); ?></label>
|
614 |
<?php endif; ?>
|
615 |
<div class="pum-form__consent-radios pum-form__consent-radios--<?php echo esc_attr( $atts['privacy_consent_radio_layout'] ); ?>">
|
616 |
<label class="pum-form__label pum-sub-form-label">
|
617 |
+
<input type="radio" value="yes" name="consent" <?php echo $consent_args['required'] ? 'required="required"' : ''; ?> /> <?php echo esc_html( wp_kses( $atts['privacy_consent_yes_label'], [] ) ); ?>
|
618 |
</label>
|
619 |
<label class="pum-form__label pum-sub-form-label">
|
620 |
+
<input type="radio" value="no" name="consent" /> <?php echo esc_html( wp_kses( $atts['privacy_consent_no_label'], [] ) ); ?>
|
621 |
</label>
|
622 |
</div>
|
623 |
<?php
|
628 |
$usage_text = trim( $atts['privacy_usage_text'] );
|
629 |
|
630 |
if ( strpos( $usage_text, '{{privacy_link' ) !== false && function_exists( 'get_privacy_policy_url' ) && get_privacy_policy_url() !== '' ) {
|
631 |
+
preg_match_all( '/{{privacy_link:?(.*)}}/', $usage_text, $matches );
|
632 |
|
633 |
$link = '<a href="' . get_privacy_policy_url() . '" target="_blank">%s</a>';
|
634 |
|
638 |
}
|
639 |
?>
|
640 |
<p>
|
641 |
+
<small>
|
642 |
+
<?php
|
643 |
+
echo esc_html(
|
644 |
+
wp_kses(
|
645 |
+
$usage_text,
|
646 |
+
[
|
647 |
+
'a' => [
|
648 |
+
'target' => true,
|
649 |
+
'href' => true,
|
650 |
+
],
|
651 |
+
]
|
652 |
+
)
|
653 |
+
);
|
654 |
+
?>
|
655 |
+
</small>
|
656 |
</p>
|
657 |
<?php endif; ?>
|
658 |
</div>
|
667 |
|
668 |
<?php
|
669 |
|
670 |
+
// return content
|
671 |
return ob_get_clean();
|
672 |
}
|
673 |
|
726 |
*
|
727 |
* @return array
|
728 |
*/
|
729 |
+
public function data_attr( $atts = [] ) {
|
730 |
+
$data = [];
|
731 |
|
732 |
$data_attr_fields = $this->data_attr_fields();
|
733 |
|
750 |
* @return mixed
|
751 |
*/
|
752 |
public function data_attr_fields() {
|
753 |
+
return apply_filters(
|
754 |
+
'pum_sub_form_data_attr_fields',
|
755 |
+
[
|
756 |
+
'closepopup',
|
757 |
+
'closedelay',
|
758 |
+
'openpopup',
|
759 |
+
'openpopup_id',
|
760 |
+
'redirect_enabled',
|
761 |
+
'redirect',
|
762 |
+
]
|
763 |
+
);
|
764 |
}
|
765 |
|
766 |
/**
|
767 |
*
|
768 |
*/
|
769 |
+
public function template() {
|
770 |
+
?>
|
771 |
<p class="pum-sub-form-desc">
|
772 |
<?php _e( 'Subscription Form Placeholder', 'popup-maker' ); ?>
|
773 |
</p>
|
classes/Shortcodes.php
CHANGED
@@ -22,7 +22,7 @@ class PUM_Shortcodes {
|
|
22 |
/**
|
23 |
* @var array Holds array of registered $shortcode_tags => $shortcode_objects.
|
24 |
*/
|
25 |
-
private $shortcodes =
|
26 |
|
27 |
/**
|
28 |
* Main PUM_Shortcodes Instance
|
@@ -31,7 +31,7 @@ class PUM_Shortcodes {
|
|
31 |
*/
|
32 |
public static function instance() {
|
33 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof PUM_Shortcodes ) ) {
|
34 |
-
self::$instance = new self;
|
35 |
}
|
36 |
|
37 |
return self::$instance;
|
22 |
/**
|
23 |
* @var array Holds array of registered $shortcode_tags => $shortcode_objects.
|
24 |
*/
|
25 |
+
private $shortcodes = [];
|
26 |
|
27 |
/**
|
28 |
* Main PUM_Shortcodes Instance
|
31 |
*/
|
32 |
public static function instance() {
|
33 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof PUM_Shortcodes ) ) {
|
34 |
+
self::$instance = new self();
|
35 |
}
|
36 |
|
37 |
return self::$instance;
|
classes/Site.php
CHANGED
@@ -12,7 +12,7 @@ class PUM_Site {
|
|
12 |
|
13 |
self::add_core_content_filters();
|
14 |
|
15 |
-
add_action( 'init',
|
16 |
}
|
17 |
|
18 |
/**
|
@@ -28,8 +28,8 @@ class PUM_Site {
|
|
28 |
*
|
29 |
* @since 1.4 hooks & filters
|
30 |
*/
|
31 |
-
add_filter( 'pum_popup_content',
|
32 |
-
add_filter( 'pum_popup_content',
|
33 |
|
34 |
/**
|
35 |
* Copied & from wp-includes/default-filters.php:141:144.
|
@@ -39,7 +39,7 @@ class PUM_Site {
|
|
39 |
* @since 1.10.0
|
40 |
* @sinceWP 5.4
|
41 |
*/
|
42 |
-
foreach (
|
43 |
add_filter( $filter, 'capital_P_dangit', 11 );
|
44 |
}
|
45 |
|
@@ -50,7 +50,7 @@ class PUM_Site {
|
|
50 |
* @sinceWP 5.4
|
51 |
*/
|
52 |
if ( version_compare( $wp_version, '5.0.0', '>=' ) ) {
|
53 |
-
add_filter( 'pum_popup_content',
|
54 |
}
|
55 |
add_filter( 'pum_popup_content', 'wptexturize' );
|
56 |
add_filter( 'pum_popup_content', 'convert_smilies', 20 );
|
@@ -71,7 +71,7 @@ class PUM_Site {
|
|
71 |
* @since 1.10.0
|
72 |
* @sinceWP 5.4
|
73 |
*/
|
74 |
-
$do_shortcode_handler = pum_get_option( 'disable_shortcode_compatibility_mode' ) ? 'do_shortcode' :
|
75 |
add_filter( 'pum_popup_content', $do_shortcode_handler, 11 );
|
76 |
}
|
77 |
|
@@ -96,7 +96,7 @@ class PUM_Site {
|
|
96 |
$priority = has_filter( 'pum_popup_content', 'wpautop' );
|
97 |
if ( false !== $priority && doing_filter( 'pum_popup_content' ) && has_blocks( $content ) ) {
|
98 |
remove_filter( 'pum_popup_content', 'wpautop', $priority );
|
99 |
-
add_filter( 'pum_popup_content',
|
100 |
}
|
101 |
|
102 |
return $output;
|
@@ -135,11 +135,11 @@ class PUM_Site {
|
|
135 |
|
136 |
$valid_actions = apply_filters(
|
137 |
'pum_valid_request_actions',
|
138 |
-
|
139 |
'save_enabled_betas',
|
140 |
'download_batch_export',
|
141 |
'empty_error_log',
|
142 |
-
|
143 |
);
|
144 |
|
145 |
$action = sanitize_text_field( $_REQUEST['pum_action'] );
|
12 |
|
13 |
self::add_core_content_filters();
|
14 |
|
15 |
+
add_action( 'init', [ __CLASS__, 'actions' ] );
|
16 |
}
|
17 |
|
18 |
/**
|
28 |
*
|
29 |
* @since 1.4 hooks & filters
|
30 |
*/
|
31 |
+
add_filter( 'pum_popup_content', [ $GLOBALS['wp_embed'], 'run_shortcode' ], 8 );
|
32 |
+
add_filter( 'pum_popup_content', [ $GLOBALS['wp_embed'], 'autoembed' ], 8 );
|
33 |
|
34 |
/**
|
35 |
* Copied & from wp-includes/default-filters.php:141:144.
|
39 |
* @since 1.10.0
|
40 |
* @sinceWP 5.4
|
41 |
*/
|
42 |
+
foreach ( [ 'pum_popup_content', 'pum_popup_title' ] as $filter ) {
|
43 |
add_filter( $filter, 'capital_P_dangit', 11 );
|
44 |
}
|
45 |
|
50 |
* @sinceWP 5.4
|
51 |
*/
|
52 |
if ( version_compare( $wp_version, '5.0.0', '>=' ) ) {
|
53 |
+
add_filter( 'pum_popup_content', [ __CLASS__, 'do_blocks' ], 9 );
|
54 |
}
|
55 |
add_filter( 'pum_popup_content', 'wptexturize' );
|
56 |
add_filter( 'pum_popup_content', 'convert_smilies', 20 );
|
71 |
* @since 1.10.0
|
72 |
* @sinceWP 5.4
|
73 |
*/
|
74 |
+
$do_shortcode_handler = pum_get_option( 'disable_shortcode_compatibility_mode' ) ? 'do_shortcode' : [ 'PUM_Helpers', 'do_shortcode' ];
|
75 |
add_filter( 'pum_popup_content', $do_shortcode_handler, 11 );
|
76 |
}
|
77 |
|
96 |
$priority = has_filter( 'pum_popup_content', 'wpautop' );
|
97 |
if ( false !== $priority && doing_filter( 'pum_popup_content' ) && has_blocks( $content ) ) {
|
98 |
remove_filter( 'pum_popup_content', 'wpautop', $priority );
|
99 |
+
add_filter( 'pum_popup_content', [ __CLASS__, '_restore_wpautop_hook' ], $priority + 1 );
|
100 |
}
|
101 |
|
102 |
return $output;
|
135 |
|
136 |
$valid_actions = apply_filters(
|
137 |
'pum_valid_request_actions',
|
138 |
+
[
|
139 |
'save_enabled_betas',
|
140 |
'download_batch_export',
|
141 |
'empty_error_log',
|
142 |
+
]
|
143 |
);
|
144 |
|
145 |
$action = sanitize_text_field( $_REQUEST['pum_action'] );
|
classes/Site/Assets.php
CHANGED
@@ -28,12 +28,12 @@ class PUM_Site_Assets {
|
|
28 |
/**
|
29 |
* @var array
|
30 |
*/
|
31 |
-
public static $enqueued_scripts =
|
32 |
|
33 |
/**
|
34 |
* @var array
|
35 |
*/
|
36 |
-
public static $enqueued_styles =
|
37 |
|
38 |
/**
|
39 |
* @var bool
|
@@ -61,20 +61,20 @@ class PUM_Site_Assets {
|
|
61 |
self::$css_url = Popup_Maker::$URL . 'assets/css/';
|
62 |
|
63 |
// Register assets early.
|
64 |
-
add_action( 'wp_enqueue_scripts',
|
65 |
-
add_action( 'wp_enqueue_scripts',
|
66 |
|
67 |
// Localize after popups rendered in PUM_Site_Popups
|
68 |
-
add_action( 'wp_footer',
|
69 |
|
70 |
// Checks preloaded popups in the head for which assets to enqueue.
|
71 |
-
add_action( 'pum_preload_popup',
|
72 |
-
add_filter( 'wp_enqueue_scripts',
|
73 |
|
74 |
-
add_action( 'wp_enqueue_scripts',
|
75 |
|
76 |
// Allow forcing assets to load.
|
77 |
-
add_action( 'wp_head',
|
78 |
}
|
79 |
|
80 |
public static function fix_broken_extension_scripts() {
|
@@ -85,17 +85,26 @@ class PUM_Site_Assets {
|
|
85 |
wp_dequeue_style( 'pum-newsletter-styles' );
|
86 |
|
87 |
wp_enqueue_style( 'pum-newsletter-styles', PUM_AWEBER_INTEGRATION_URL . '/includes/pum-newsletters/newsletter-styles' . self::$suffix . '.css' );
|
88 |
-
wp_enqueue_script(
|
89 |
-
'
|
90 |
-
'
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
}
|
94 |
|
95 |
-
$mc_ver_test = in_array(
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
99 |
|
100 |
if ( $mc_ver_test ) {
|
101 |
wp_dequeue_script( 'pum_mailchimp_integration_admin_js' );
|
@@ -106,11 +115,15 @@ class PUM_Site_Assets {
|
|
106 |
wp_dequeue_style( 'pum-newsletter-site' );
|
107 |
|
108 |
wp_enqueue_style( 'pum-newsletter-site', PUM_NEWSLETTER_URL . 'assets/css/pum-newsletter-site' . self::$suffix . '.css', null, PUM_NEWSLETTER_VERSION );
|
109 |
-
wp_enqueue_script( 'pum-newsletter-site', PUM_NEWSLETTER_URL . 'assets/js/pum-newsletter-site' . self::$suffix . '.js',
|
110 |
-
wp_localize_script(
|
111 |
-
'
|
112 |
-
'
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
}
|
@@ -171,7 +184,7 @@ class PUM_Site_Assets {
|
|
171 |
self::$scripts_registered = true;
|
172 |
|
173 |
wp_register_script( 'mobile-detect', self::$js_url . 'vendor/mobile-detect.min.js', null, '1.3.3', true );
|
174 |
-
wp_register_script( 'iframe-resizer', self::$js_url . 'vendor/iframeResizer.min.js',
|
175 |
|
176 |
if ( PUM_AssetCache::enabled() && false !== self::$cache_url ) {
|
177 |
$cached = get_option( 'pum-has-cached-js' );
|
@@ -181,23 +194,33 @@ class PUM_Site_Assets {
|
|
181 |
$cached = get_option( 'pum-has-cached-js' );
|
182 |
}
|
183 |
|
184 |
-
|
185 |
-
|
186 |
-
'
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
190 |
} else {
|
191 |
-
wp_register_script(
|
192 |
-
'
|
193 |
-
'
|
194 |
-
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
|
198 |
-
|
199 |
if ( popmake_get_option( 'enable_easy_modal_compatibility_mode', false ) ) {
|
200 |
-
wp_register_script( 'popup-maker-easy-modal-importer-site', self::$js_url . 'popup-maker-easy-modal-importer-site' . self::$suffix . '?defer',
|
201 |
}
|
202 |
|
203 |
self::localize_scripts();
|
@@ -210,55 +233,73 @@ class PUM_Site_Assets {
|
|
210 |
$site_home_path = parse_url( home_url() );
|
211 |
$site_home_path = isset( $site_home_path['path'] ) ? $site_home_path['path'] : '/';
|
212 |
|
213 |
-
wp_localize_script(
|
214 |
-
'
|
215 |
-
'
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
if ( Popup_Maker::debug_mode() || isset( $_GET['pum_debug'] ) ) {
|
229 |
-
wp_localize_script(
|
230 |
-
'
|
231 |
-
'
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
/* Here for backward compatibility. */
|
258 |
-
wp_localize_script(
|
259 |
-
'
|
260 |
-
'
|
261 |
-
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
|
264 |
/**
|
@@ -273,7 +314,7 @@ class PUM_Site_Assets {
|
|
273 |
echo 'window.pum_popups = ' . PUM_Utils_Array::safe_json_encode( self::get_popup_settings() ) . ';';
|
274 |
// Backward compatibility fill.
|
275 |
echo 'window.pum_vars = window.pum_vars || {}; window.pum_vars.popups = window.pum_popups;';
|
276 |
-
echo
|
277 |
}
|
278 |
}
|
279 |
|
@@ -285,12 +326,13 @@ class PUM_Site_Assets {
|
|
285 |
public static function get_popup_settings() {
|
286 |
$loaded = PUM_Site_Popups::get_loaded_popups();
|
287 |
|
288 |
-
$settings =
|
289 |
|
290 |
$current_popup = pum()->current_popup;
|
291 |
|
292 |
if ( $loaded->have_posts() ) {
|
293 |
-
while ( $loaded->have_posts() ) :
|
|
|
294 |
pum()->current_popup = $loaded->post;
|
295 |
$popup = pum_get_popup( $loaded->post->ID );
|
296 |
// Set the key to the CSS id of this popup for easy lookup.
|
@@ -317,9 +359,9 @@ class PUM_Site_Assets {
|
|
317 |
$cached = get_option( 'pum-has-cached-css' );
|
318 |
}
|
319 |
|
320 |
-
wp_register_style( 'popup-maker-site', self::$cache_url . '/' . PUM_AssetCache::generate_cache_filename( 'pum-site-styles' ) . '.css?generated=' . $cached,
|
321 |
} else {
|
322 |
-
wp_register_style( 'popup-maker-site', self::$css_url . 'pum-site' . ( is_rtl() ? '-rtl' : '' ) . self::$suffix . '.css',
|
323 |
self::inline_styles();
|
324 |
}
|
325 |
}
|
@@ -356,7 +398,7 @@ class PUM_Site_Assets {
|
|
356 |
*/
|
357 |
public static function check_force_script_loading() {
|
358 |
global $wp_query;
|
359 |
-
if ( ! empty( $wp_query->post ) && has_shortcode( $wp_query->post->post_content, 'popup' ) || ( defined(
|
360 |
wp_enqueue_script( 'popup-maker-site' );
|
361 |
wp_enqueue_style( 'popup-maker-site' );
|
362 |
}
|
28 |
/**
|
29 |
* @var array
|
30 |
*/
|
31 |
+
public static $enqueued_scripts = [];
|
32 |
|
33 |
/**
|
34 |
* @var array
|
35 |
*/
|
36 |
+
public static $enqueued_styles = [];
|
37 |
|
38 |
/**
|
39 |
* @var bool
|
61 |
self::$css_url = Popup_Maker::$URL . 'assets/css/';
|
62 |
|
63 |
// Register assets early.
|
64 |
+
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'register_styles' ] );
|
65 |
+
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'register_scripts' ] );
|
66 |
|
67 |
// Localize after popups rendered in PUM_Site_Popups
|
68 |
+
add_action( 'wp_footer', [ __CLASS__, 'late_localize_scripts' ], 19 );
|
69 |
|
70 |
// Checks preloaded popups in the head for which assets to enqueue.
|
71 |
+
add_action( 'pum_preload_popup', [ __CLASS__, 'enqueue_popup_assets' ] );
|
72 |
+
add_filter( 'wp_enqueue_scripts', [ __CLASS__, 'enqueue_page_assets' ] );
|
73 |
|
74 |
+
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'fix_broken_extension_scripts' ], 100 );
|
75 |
|
76 |
// Allow forcing assets to load.
|
77 |
+
add_action( 'wp_head', [ __CLASS__, 'check_force_script_loading' ] );
|
78 |
}
|
79 |
|
80 |
public static function fix_broken_extension_scripts() {
|
85 |
wp_dequeue_style( 'pum-newsletter-styles' );
|
86 |
|
87 |
wp_enqueue_style( 'pum-newsletter-styles', PUM_AWEBER_INTEGRATION_URL . '/includes/pum-newsletters/newsletter-styles' . self::$suffix . '.css' );
|
88 |
+
wp_enqueue_script(
|
89 |
+
'pum_newsletter_script',
|
90 |
+
PUM_AWEBER_INTEGRATION_URL . '/includes/pum-newsletters/newsletter-scripts' . self::$suffix . '.js',
|
91 |
+
[
|
92 |
+
'jquery',
|
93 |
+
'popup-maker-site',
|
94 |
+
],
|
95 |
+
false,
|
96 |
+
true
|
97 |
+
);
|
98 |
|
99 |
}
|
100 |
|
101 |
+
$mc_ver_test = in_array(
|
102 |
+
true,
|
103 |
+
[
|
104 |
+
class_exists( 'PUM_MailChimp_Integration' ) && defined( 'PUM_MAILCHIMP_INTEGRATION_VER' ) && PUM_MAILCHIMP_INTEGRATION_VER,
|
105 |
+
class_exists( 'PUM_MCI' ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ),
|
106 |
+
]
|
107 |
+
);
|
108 |
|
109 |
if ( $mc_ver_test ) {
|
110 |
wp_dequeue_script( 'pum_mailchimp_integration_admin_js' );
|
115 |
wp_dequeue_style( 'pum-newsletter-site' );
|
116 |
|
117 |
wp_enqueue_style( 'pum-newsletter-site', PUM_NEWSLETTER_URL . 'assets/css/pum-newsletter-site' . self::$suffix . '.css', null, PUM_NEWSLETTER_VERSION );
|
118 |
+
wp_enqueue_script( 'pum-newsletter-site', PUM_NEWSLETTER_URL . 'assets/js/pum-newsletter-site' . self::$suffix . '.js', [ 'jquery' ], PUM_NEWSLETTER_VERSION, true );
|
119 |
+
wp_localize_script(
|
120 |
+
'pum-newsletter-site',
|
121 |
+
'pum_sub_vars',
|
122 |
+
[
|
123 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
124 |
+
'message_position' => 'top',
|
125 |
+
]
|
126 |
+
);
|
127 |
}
|
128 |
|
129 |
}
|
184 |
self::$scripts_registered = true;
|
185 |
|
186 |
wp_register_script( 'mobile-detect', self::$js_url . 'vendor/mobile-detect.min.js', null, '1.3.3', true );
|
187 |
+
wp_register_script( 'iframe-resizer', self::$js_url . 'vendor/iframeResizer.min.js', [ 'jquery' ] );
|
188 |
|
189 |
if ( PUM_AssetCache::enabled() && false !== self::$cache_url ) {
|
190 |
$cached = get_option( 'pum-has-cached-js' );
|
194 |
$cached = get_option( 'pum-has-cached-js' );
|
195 |
}
|
196 |
|
197 |
+
wp_register_script(
|
198 |
+
'popup-maker-site',
|
199 |
+
self::$cache_url . '/' . PUM_AssetCache::generate_cache_filename( 'pum-site-scripts' ) . '.js?defer&generated=' . $cached,
|
200 |
+
[
|
201 |
+
'jquery',
|
202 |
+
'jquery-ui-core',
|
203 |
+
'jquery-ui-position',
|
204 |
+
],
|
205 |
+
Popup_Maker::$VER,
|
206 |
+
true
|
207 |
+
);
|
208 |
} else {
|
209 |
+
wp_register_script(
|
210 |
+
'popup-maker-site',
|
211 |
+
self::$js_url . 'site' . self::$suffix . '.js?defer',
|
212 |
+
[
|
213 |
+
'jquery',
|
214 |
+
'jquery-ui-core',
|
215 |
+
'jquery-ui-position',
|
216 |
+
],
|
217 |
+
Popup_Maker::$VER,
|
218 |
+
true
|
219 |
+
);
|
220 |
}
|
221 |
|
|
|
222 |
if ( popmake_get_option( 'enable_easy_modal_compatibility_mode', false ) ) {
|
223 |
+
wp_register_script( 'popup-maker-easy-modal-importer-site', self::$js_url . 'popup-maker-easy-modal-importer-site' . self::$suffix . '?defer', [ 'popup-maker-site' ], POPMAKE_VERSION, true );
|
224 |
}
|
225 |
|
226 |
self::localize_scripts();
|
233 |
$site_home_path = parse_url( home_url() );
|
234 |
$site_home_path = isset( $site_home_path['path'] ) ? $site_home_path['path'] : '/';
|
235 |
|
236 |
+
wp_localize_script(
|
237 |
+
'popup-maker-site',
|
238 |
+
'pum_vars',
|
239 |
+
apply_filters(
|
240 |
+
'pum_vars',
|
241 |
+
[
|
242 |
+
'version' => Popup_Maker::$VER,
|
243 |
+
'pm_dir_url' => Popup_Maker::$URL,
|
244 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
245 |
+
'restapi' => function_exists( 'rest_url' ) ? esc_url_raw( rest_url( 'pum/v1' ) ) : false,
|
246 |
+
'rest_nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : null,
|
247 |
+
'default_theme' => (string) pum_get_default_theme_id(),
|
248 |
+
'debug_mode' => Popup_Maker::debug_mode(),
|
249 |
+
'disable_tracking' => popmake_get_option( 'disable_popup_open_tracking' ),
|
250 |
+
'home_url' => trailingslashit( $site_home_path ),
|
251 |
+
'message_position' => 'top',
|
252 |
+
'core_sub_forms_enabled' => ! PUM_Newsletters::$disabled,
|
253 |
+
'popups' => [],
|
254 |
+
]
|
255 |
+
)
|
256 |
+
);
|
257 |
|
258 |
if ( Popup_Maker::debug_mode() || isset( $_GET['pum_debug'] ) ) {
|
259 |
+
wp_localize_script(
|
260 |
+
'popup-maker-site',
|
261 |
+
'pum_debug_vars',
|
262 |
+
apply_filters(
|
263 |
+
'pum_debug_vars',
|
264 |
+
[
|
265 |
+
'debug_mode_enabled' => __( 'Popup Maker', 'popup-maker' ) . ': ' . __( 'Debug Mode Enabled', 'popup-maker' ),
|
266 |
+
'debug_started_at' => __( 'Debug started at:', 'popup-maker' ),
|
267 |
+
'debug_more_info' => sprintf( __( 'For more information on how to use this information visit %s', 'popup-maker' ), 'https://docs.wppopupmaker.com/?utm_medium=js-debug-info&utm_campaign=contextual-help&utm_source=browser-console&utm_content=more-info' ),
|
268 |
+
'global_info' => __( 'Global Information', 'popup-maker' ),
|
269 |
+
'localized_vars' => __( 'Localized variables', 'popup-maker' ),
|
270 |
+
'popups_initializing' => __( 'Popups Initializing', 'popup-maker' ),
|
271 |
+
'popups_initialized' => __( 'Popups Initialized', 'popup-maker' ),
|
272 |
+
'single_popup_label' => __( 'Popup: #', 'popup-maker' ),
|
273 |
+
'theme_id' => __( 'Theme ID: ', 'popup-maker' ),
|
274 |
+
'label_method_call' => __( 'Method Call:', 'popup-maker' ),
|
275 |
+
'label_method_args' => __( 'Method Arguments:', 'popup-maker' ),
|
276 |
+
'label_popup_settings' => __( 'Settings', 'popup-maker' ),
|
277 |
+
'label_triggers' => __( 'Triggers', 'popup-maker' ),
|
278 |
+
'label_cookies' => __( 'Cookies', 'popup-maker' ),
|
279 |
+
'label_delay' => __( 'Delay:', 'popup-maker' ),
|
280 |
+
'label_conditions' => __( 'Conditions', 'popup-maker' ),
|
281 |
+
'label_cookie' => __( 'Cookie:', 'popup-maker' ),
|
282 |
+
'label_settings' => __( 'Settings:', 'popup-maker' ),
|
283 |
+
'label_selector' => __( 'Selector:', 'popup-maker' ),
|
284 |
+
'label_mobile_disabled' => __( 'Mobile Disabled:', 'popup-maker' ),
|
285 |
+
'label_tablet_disabled' => __( 'Tablet Disabled:', 'popup-maker' ),
|
286 |
+
'label_event' => __( 'Event: %s', 'popup-maker' ),
|
287 |
+
'triggers' => PUM_Triggers::instance()->dropdown_list(),
|
288 |
+
'cookies' => PUM_Cookies::instance()->dropdown_list(),
|
289 |
+
]
|
290 |
+
)
|
291 |
+
);
|
292 |
}
|
293 |
|
294 |
/* Here for backward compatibility. */
|
295 |
+
wp_localize_script(
|
296 |
+
'popup-maker-site',
|
297 |
+
'pum_sub_vars',
|
298 |
+
[
|
299 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
300 |
+
'message_position' => 'top',
|
301 |
+
]
|
302 |
+
);
|
303 |
}
|
304 |
|
305 |
/**
|
314 |
echo 'window.pum_popups = ' . PUM_Utils_Array::safe_json_encode( self::get_popup_settings() ) . ';';
|
315 |
// Backward compatibility fill.
|
316 |
echo 'window.pum_vars = window.pum_vars || {}; window.pum_vars.popups = window.pum_popups;';
|
317 |
+
echo '</script>';
|
318 |
}
|
319 |
}
|
320 |
|
326 |
public static function get_popup_settings() {
|
327 |
$loaded = PUM_Site_Popups::get_loaded_popups();
|
328 |
|
329 |
+
$settings = [];
|
330 |
|
331 |
$current_popup = pum()->current_popup;
|
332 |
|
333 |
if ( $loaded->have_posts() ) {
|
334 |
+
while ( $loaded->have_posts() ) :
|
335 |
+
$loaded->next_post();
|
336 |
pum()->current_popup = $loaded->post;
|
337 |
$popup = pum_get_popup( $loaded->post->ID );
|
338 |
// Set the key to the CSS id of this popup for easy lookup.
|
359 |
$cached = get_option( 'pum-has-cached-css' );
|
360 |
}
|
361 |
|
362 |
+
wp_register_style( 'popup-maker-site', self::$cache_url . '/' . PUM_AssetCache::generate_cache_filename( 'pum-site-styles' ) . '.css?generated=' . $cached, [], Popup_Maker::$VER );
|
363 |
} else {
|
364 |
+
wp_register_style( 'popup-maker-site', self::$css_url . 'pum-site' . ( is_rtl() ? '-rtl' : '' ) . self::$suffix . '.css', [], Popup_Maker::$VER );
|
365 |
self::inline_styles();
|
366 |
}
|
367 |
}
|
398 |
*/
|
399 |
public static function check_force_script_loading() {
|
400 |
global $wp_query;
|
401 |
+
if ( ! empty( $wp_query->post ) && has_shortcode( $wp_query->post->post_content, 'popup' ) || ( defined( 'POPMAKE_FORCE_SCRIPTS' ) && POPMAKE_FORCE_SCRIPTS ) ) {
|
402 |
wp_enqueue_script( 'popup-maker-site' );
|
403 |
wp_enqueue_style( 'popup-maker-site' );
|
404 |
}
|
classes/Telemetry.php
CHANGED
@@ -21,10 +21,10 @@ class PUM_Telemetry {
|
|
21 |
* Initialization method
|
22 |
*/
|
23 |
public static function init() {
|
24 |
-
add_action( 'pum_daily_scheduled_events',
|
25 |
if ( is_admin() && current_user_can( 'manage_options' ) ) {
|
26 |
-
add_filter( 'pum_alert_list',
|
27 |
-
add_action( 'pum_alert_dismissed',
|
28 |
}
|
29 |
}
|
30 |
|
@@ -60,7 +60,7 @@ class PUM_Telemetry {
|
|
60 |
}
|
61 |
|
62 |
$plugins = array_keys( get_plugins() );
|
63 |
-
$active_plugins = get_option( 'active_plugins',
|
64 |
|
65 |
foreach ( $plugins as $key => $plugin ) {
|
66 |
if ( in_array( $plugin, $active_plugins ) ) {
|
@@ -81,12 +81,12 @@ class PUM_Telemetry {
|
|
81 |
|
82 |
// Aggregates important settings across all popups.
|
83 |
$all_popups = pum_get_all_popups();
|
84 |
-
$triggers =
|
85 |
-
$cookies =
|
86 |
-
$conditions =
|
87 |
-
$location =
|
88 |
-
$sizes =
|
89 |
-
$sounds =
|
90 |
|
91 |
// Cycle through each popup.
|
92 |
foreach ( $all_popups as $popup ) {
|
@@ -143,7 +143,7 @@ class PUM_Telemetry {
|
|
143 |
}
|
144 |
}
|
145 |
|
146 |
-
return
|
147 |
// UID.
|
148 |
'uid' => self::get_uuid(),
|
149 |
|
@@ -184,7 +184,7 @@ class PUM_Telemetry {
|
|
184 |
'locations' => $location,
|
185 |
'sizes' => $sizes,
|
186 |
'sounds' => $sounds,
|
187 |
-
|
188 |
}
|
189 |
|
190 |
/**
|
@@ -193,7 +193,7 @@ class PUM_Telemetry {
|
|
193 |
* @param array $data Telemetry data to send.
|
194 |
* @since 1.11.0
|
195 |
*/
|
196 |
-
public static function send_data( $data =
|
197 |
self::api_call( 'check_in', $data );
|
198 |
}
|
199 |
|
@@ -205,10 +205,10 @@ class PUM_Telemetry {
|
|
205 |
* @return array|bool False if WP Error. Otherwise, array response from wp_remote_post.
|
206 |
* @since 1.11.0
|
207 |
*/
|
208 |
-
public static function api_call( $action = '', $data =
|
209 |
$response = wp_remote_post(
|
210 |
'https://api.wppopupmaker.com/wp-json/pmapi/v2/' . $action,
|
211 |
-
|
212 |
'method' => 'POST',
|
213 |
'timeout' => 20,
|
214 |
'redirection' => 5,
|
@@ -216,7 +216,7 @@ class PUM_Telemetry {
|
|
216 |
'blocking' => false,
|
217 |
'body' => $data,
|
218 |
'user-agent' => 'POPMAKE/' . Popup_Maker::$VER . '; ' . get_site_url(),
|
219 |
-
|
220 |
);
|
221 |
|
222 |
if ( is_wp_error( $response ) ) {
|
@@ -240,35 +240,35 @@ class PUM_Telemetry {
|
|
240 |
return $alerts;
|
241 |
}
|
242 |
|
243 |
-
$alerts[] =
|
244 |
'code' => 'pum_telemetry_notice',
|
245 |
'type' => 'info',
|
246 |
'message' => esc_html__( "We are constantly improving Popup Maker but that's difficult to do if we don't know how it's being used. Please allow data sharing so that we can receive a little information on how it is used. You can change this setting at any time on our Settings page. No user data is sent to our servers. No sensitive data is tracked.", 'popup-maker' ),
|
247 |
'priority' => 10,
|
248 |
'dismissible' => true,
|
249 |
'global' => false,
|
250 |
-
'actions' =>
|
251 |
-
|
252 |
'primary' => true,
|
253 |
'type' => 'action',
|
254 |
'action' => 'pum_optin_check_allow',
|
255 |
'text' => __( 'Allow', 'popup-maker' ),
|
256 |
-
|
257 |
-
|
258 |
'primary' => false,
|
259 |
'type' => 'action',
|
260 |
'action' => 'dismiss',
|
261 |
'text' => __( 'Do not allow', 'popup-maker' ),
|
262 |
-
|
263 |
-
|
264 |
'primary' => false,
|
265 |
'type' => 'link',
|
266 |
'action' => '',
|
267 |
'href' => 'https://docs.wppopupmaker.com/article/528-the-data-the-popup-maker-plugin-collects',
|
268 |
'text' => __( 'Learn more', 'popup-maker' ),
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
return $alerts;
|
273 |
}
|
274 |
|
21 |
* Initialization method
|
22 |
*/
|
23 |
public static function init() {
|
24 |
+
add_action( 'pum_daily_scheduled_events', [ __CLASS__, 'track_check' ] );
|
25 |
if ( is_admin() && current_user_can( 'manage_options' ) ) {
|
26 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'optin_alert' ] );
|
27 |
+
add_action( 'pum_alert_dismissed', [ __CLASS__, 'optin_alert_check' ], 10, 2 );
|
28 |
}
|
29 |
}
|
30 |
|
60 |
}
|
61 |
|
62 |
$plugins = array_keys( get_plugins() );
|
63 |
+
$active_plugins = get_option( 'active_plugins', [] );
|
64 |
|
65 |
foreach ( $plugins as $key => $plugin ) {
|
66 |
if ( in_array( $plugin, $active_plugins ) ) {
|
81 |
|
82 |
// Aggregates important settings across all popups.
|
83 |
$all_popups = pum_get_all_popups();
|
84 |
+
$triggers = [];
|
85 |
+
$cookies = [];
|
86 |
+
$conditions = [];
|
87 |
+
$location = [];
|
88 |
+
$sizes = [];
|
89 |
+
$sounds = [];
|
90 |
|
91 |
// Cycle through each popup.
|
92 |
foreach ( $all_popups as $popup ) {
|
143 |
}
|
144 |
}
|
145 |
|
146 |
+
return [
|
147 |
// UID.
|
148 |
'uid' => self::get_uuid(),
|
149 |
|
184 |
'locations' => $location,
|
185 |
'sizes' => $sizes,
|
186 |
'sounds' => $sounds,
|
187 |
+
];
|
188 |
}
|
189 |
|
190 |
/**
|
193 |
* @param array $data Telemetry data to send.
|
194 |
* @since 1.11.0
|
195 |
*/
|
196 |
+
public static function send_data( $data = [] ) {
|
197 |
self::api_call( 'check_in', $data );
|
198 |
}
|
199 |
|
205 |
* @return array|bool False if WP Error. Otherwise, array response from wp_remote_post.
|
206 |
* @since 1.11.0
|
207 |
*/
|
208 |
+
public static function api_call( $action = '', $data = [] ) {
|
209 |
$response = wp_remote_post(
|
210 |
'https://api.wppopupmaker.com/wp-json/pmapi/v2/' . $action,
|
211 |
+
[
|
212 |
'method' => 'POST',
|
213 |
'timeout' => 20,
|
214 |
'redirection' => 5,
|
216 |
'blocking' => false,
|
217 |
'body' => $data,
|
218 |
'user-agent' => 'POPMAKE/' . Popup_Maker::$VER . '; ' . get_site_url(),
|
219 |
+
]
|
220 |
);
|
221 |
|
222 |
if ( is_wp_error( $response ) ) {
|
240 |
return $alerts;
|
241 |
}
|
242 |
|
243 |
+
$alerts[] = [
|
244 |
'code' => 'pum_telemetry_notice',
|
245 |
'type' => 'info',
|
246 |
'message' => esc_html__( "We are constantly improving Popup Maker but that's difficult to do if we don't know how it's being used. Please allow data sharing so that we can receive a little information on how it is used. You can change this setting at any time on our Settings page. No user data is sent to our servers. No sensitive data is tracked.", 'popup-maker' ),
|
247 |
'priority' => 10,
|
248 |
'dismissible' => true,
|
249 |
'global' => false,
|
250 |
+
'actions' => [
|
251 |
+
[
|
252 |
'primary' => true,
|
253 |
'type' => 'action',
|
254 |
'action' => 'pum_optin_check_allow',
|
255 |
'text' => __( 'Allow', 'popup-maker' ),
|
256 |
+
],
|
257 |
+
[
|
258 |
'primary' => false,
|
259 |
'type' => 'action',
|
260 |
'action' => 'dismiss',
|
261 |
'text' => __( 'Do not allow', 'popup-maker' ),
|
262 |
+
],
|
263 |
+
[
|
264 |
'primary' => false,
|
265 |
'type' => 'link',
|
266 |
'action' => '',
|
267 |
'href' => 'https://docs.wppopupmaker.com/article/528-the-data-the-popup-maker-plugin-collects',
|
268 |
'text' => __( 'Learn more', 'popup-maker' ),
|
269 |
+
],
|
270 |
+
],
|
271 |
+
];
|
272 |
return $alerts;
|
273 |
}
|
274 |
|
classes/Triggers.php
CHANGED
@@ -55,7 +55,7 @@ class PUM_Triggers {
|
|
55 |
* @param array $triggers The array of triggers to add.
|
56 |
* @uses PUM_Triggers::add_trigger()
|
57 |
*/
|
58 |
-
public function add_triggers( $triggers =
|
59 |
foreach ( $triggers as $key => $trigger ) {
|
60 |
if ( empty( $trigger['id'] ) && ! is_numeric( $key ) ) {
|
61 |
$trigger['id'] = $key;
|
@@ -70,19 +70,19 @@ class PUM_Triggers {
|
|
70 |
*
|
71 |
* @param array $trigger The trigger array.
|
72 |
*/
|
73 |
-
public function add_trigger( $trigger =
|
74 |
if ( ! empty( $trigger['id'] ) && ! isset( $this->triggers[ $trigger['id'] ] ) ) {
|
75 |
$trigger = wp_parse_args(
|
76 |
$trigger,
|
77 |
-
|
78 |
'id' => '',
|
79 |
'name' => '',
|
80 |
'modal_title' => '',
|
81 |
'settings_column' => '',
|
82 |
'priority' => 10,
|
83 |
'tabs' => $this->get_tabs(),
|
84 |
-
'fields' =>
|
85 |
-
|
86 |
);
|
87 |
|
88 |
if ( empty( $trigger['modal_title'] ) && ! empty( $trigger['name'] ) ) {
|
@@ -91,7 +91,7 @@ class PUM_Triggers {
|
|
91 |
|
92 |
// Here for backward compatibility to merge in labels properly.
|
93 |
$labels = $this->get_labels();
|
94 |
-
$trigger_labels = isset( $labels[ $trigger['id'] ] ) ? $labels[ $trigger['id'] ] :
|
95 |
|
96 |
if ( ! empty( $trigger_labels ) ) {
|
97 |
foreach ( $trigger_labels as $key => $value ) {
|
@@ -146,9 +146,8 @@ class PUM_Triggers {
|
|
146 |
*
|
147 |
* @return array
|
148 |
* @deprecated
|
149 |
-
*
|
150 |
*/
|
151 |
-
public function validate_trigger( $trigger = null, $settings =
|
152 |
return $settings;
|
153 |
}
|
154 |
|
@@ -160,40 +159,40 @@ class PUM_Triggers {
|
|
160 |
public function register_triggers() {
|
161 |
$triggers = apply_filters(
|
162 |
'pum_registered_triggers',
|
163 |
-
|
164 |
-
'click_open' =>
|
165 |
'name' => __( 'Click Open', 'popup-maker' ),
|
166 |
'modal_title' => __( 'Click Trigger Settings', 'popup-maker' ),
|
167 |
'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Extra Selectors', 'popup-maker' ), '{{data.extra_selectors}}' ),
|
168 |
-
'fields' =>
|
169 |
-
'general' =>
|
170 |
-
'click_info' =>
|
171 |
'type' => 'html',
|
172 |
'content' => '<p>' . __( 'Adding the class "popmake-<span id="pum-default-click-trigger-class">{popup-ID}</span>" to an element will trigger it to be opened once clicked. Additionally you can add additional CSS selectors below.', 'popup-maker' ) . '</p>',
|
173 |
-
|
174 |
-
'extra_selectors' =>
|
175 |
'label' => __( 'Extra CSS Selectors', 'popup-maker' ),
|
176 |
'desc' => __( 'For more than one selector, separate by comma (,)', 'popup-maker' ) . '<br /><strong>eg: </strong>' . __( ' .class-here, .class-2-here, #button_id', 'popup-maker' ),
|
177 |
'placeholder' => __( '.class-here', 'popup-maker' ),
|
178 |
'doclink' => 'https://docs.wppopupmaker.com/article/147-getting-css-selectors?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=extra-selectors',
|
179 |
-
|
180 |
-
|
181 |
-
'advanced' =>
|
182 |
-
'do_default' =>
|
183 |
'type' => 'checkbox',
|
184 |
'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
|
185 |
'desc' => __( 'This prevents us from disabling the browsers default action when a trigger is clicked. It can be used to allow a link to a file to both trigger a popup and still download the file.', 'popup-maker' ),
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
'auto_open' =>
|
191 |
'name' => __( 'Time Delay / Auto Open', 'popup-maker' ),
|
192 |
'modal_title' => __( 'Time Delay Settings', 'popup-maker' ),
|
193 |
'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Delay', 'popup-maker' ), '{{data.delay}}' ),
|
194 |
-
'fields' =>
|
195 |
-
'general' =>
|
196 |
-
'delay' =>
|
197 |
'type' => 'rangeslider',
|
198 |
'label' => __( 'Delay', 'popup-maker' ),
|
199 |
'desc' => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
|
@@ -202,30 +201,30 @@ class PUM_Triggers {
|
|
202 |
'max' => 10000,
|
203 |
'step' => 500,
|
204 |
'unit' => 'ms',
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
'form_submission' =>
|
210 |
'name' => __( 'Form Submission', 'popup-maker' ),
|
211 |
-
//'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Form', 'popup-maker' ), '' ),
|
212 |
-
'fields' =>
|
213 |
-
'general' =>
|
214 |
-
'form' =>
|
215 |
'type' => 'select',
|
216 |
'label' => __( 'Form', 'popup-maker' ),
|
217 |
'options' => $this->preload_posts ? array_merge(
|
218 |
-
|
219 |
'any' => __( 'Any Supported Form*', 'popup-maker' ),
|
220 |
-
__( 'Popup Maker', 'popup-maker' ) =>
|
221 |
'pumsubform' => __( 'Subscription Form', 'popup-maker' ),
|
222 |
-
|
223 |
-
|
224 |
PUM_Integrations::get_integrated_forms_selectlist()
|
225 |
-
) :
|
226 |
'std' => 'any',
|
227 |
-
|
228 |
-
'delay' =>
|
229 |
'type' => 'rangeslider',
|
230 |
'label' => __( 'Delay', 'popup-maker' ),
|
231 |
'desc' => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
|
@@ -234,25 +233,25 @@ class PUM_Triggers {
|
|
234 |
'max' => 10000,
|
235 |
'step' => 500,
|
236 |
'unit' => 'ms',
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
);
|
243 |
|
244 |
foreach ( $triggers as $key => $trigger ) {
|
245 |
$triggers[ $key ]['fields'] = PUM_Admin_Helpers::parse_tab_fields(
|
246 |
$triggers[ $key ]['fields'],
|
247 |
-
|
248 |
'has_subtabs' => false,
|
249 |
'name' => '%s',
|
250 |
-
|
251 |
);
|
252 |
}
|
253 |
|
254 |
// @deprecated filter.
|
255 |
-
$old_triggers = apply_filters( 'pum_get_triggers',
|
256 |
|
257 |
foreach ( $old_triggers as $type => $trigger ) {
|
258 |
if ( isset( $triggers[ $type ] ) ) {
|
@@ -282,7 +281,7 @@ class PUM_Triggers {
|
|
282 |
*/
|
283 |
public function dropdown_list() {
|
284 |
$_triggers = $this->get_triggers();
|
285 |
-
$triggers =
|
286 |
|
287 |
foreach ( $_triggers as $id => $trigger ) {
|
288 |
$triggers[ $id ] = $trigger['name'];
|
@@ -306,9 +305,9 @@ class PUM_Triggers {
|
|
306 |
*/
|
307 |
return apply_filters(
|
308 |
'pum_trigger_cookie_fields',
|
309 |
-
|
310 |
'cookie_name' => $this->cookie_field(),
|
311 |
-
|
312 |
);
|
313 |
}
|
314 |
|
@@ -327,7 +326,7 @@ class PUM_Triggers {
|
|
327 |
*/
|
328 |
return apply_filters(
|
329 |
'pum_trigger_cookie_field',
|
330 |
-
|
331 |
'label' => __( 'Cookie Name', 'popup-maker' ),
|
332 |
'desc' => __( 'Choose which cookies will disable this trigger?', 'popup-maker' ),
|
333 |
'type' => 'select',
|
@@ -335,10 +334,10 @@ class PUM_Triggers {
|
|
335 |
'as_array' => true,
|
336 |
'select2' => true,
|
337 |
'priority' => 99,
|
338 |
-
'options' =>
|
339 |
'add_new' => __( 'Add New Cookie', 'popup-maker' ),
|
340 |
-
|
341 |
-
|
342 |
);
|
343 |
}
|
344 |
|
@@ -357,11 +356,11 @@ class PUM_Triggers {
|
|
357 |
*/
|
358 |
return apply_filters(
|
359 |
'pum_get_trigger_tabs',
|
360 |
-
|
361 |
'general' => __( 'General', 'popup-maker' ),
|
362 |
'cookie' => __( 'Cookie', 'popup-maker' ),
|
363 |
'advanced' => __( 'Advanced', 'popup-maker' ),
|
364 |
-
|
365 |
);
|
366 |
}
|
367 |
|
@@ -381,7 +380,7 @@ class PUM_Triggers {
|
|
381 |
*
|
382 |
* @param array $to_do The list of trigger labels.
|
383 |
*/
|
384 |
-
$labels = apply_filters( 'pum_get_trigger_labels',
|
385 |
}
|
386 |
|
387 |
return $labels;
|
55 |
* @param array $triggers The array of triggers to add.
|
56 |
* @uses PUM_Triggers::add_trigger()
|
57 |
*/
|
58 |
+
public function add_triggers( $triggers = [] ) {
|
59 |
foreach ( $triggers as $key => $trigger ) {
|
60 |
if ( empty( $trigger['id'] ) && ! is_numeric( $key ) ) {
|
61 |
$trigger['id'] = $key;
|
70 |
*
|
71 |
* @param array $trigger The trigger array.
|
72 |
*/
|
73 |
+
public function add_trigger( $trigger = [] ) {
|
74 |
if ( ! empty( $trigger['id'] ) && ! isset( $this->triggers[ $trigger['id'] ] ) ) {
|
75 |
$trigger = wp_parse_args(
|
76 |
$trigger,
|
77 |
+
[
|
78 |
'id' => '',
|
79 |
'name' => '',
|
80 |
'modal_title' => '',
|
81 |
'settings_column' => '',
|
82 |
'priority' => 10,
|
83 |
'tabs' => $this->get_tabs(),
|
84 |
+
'fields' => [],
|
85 |
+
]
|
86 |
);
|
87 |
|
88 |
if ( empty( $trigger['modal_title'] ) && ! empty( $trigger['name'] ) ) {
|
91 |
|
92 |
// Here for backward compatibility to merge in labels properly.
|
93 |
$labels = $this->get_labels();
|
94 |
+
$trigger_labels = isset( $labels[ $trigger['id'] ] ) ? $labels[ $trigger['id'] ] : [];
|
95 |
|
96 |
if ( ! empty( $trigger_labels ) ) {
|
97 |
foreach ( $trigger_labels as $key => $value ) {
|
146 |
*
|
147 |
* @return array
|
148 |
* @deprecated
|
|
|
149 |
*/
|
150 |
+
public function validate_trigger( $trigger = null, $settings = [] ) {
|
151 |
return $settings;
|
152 |
}
|
153 |
|
159 |
public function register_triggers() {
|
160 |
$triggers = apply_filters(
|
161 |
'pum_registered_triggers',
|
162 |
+
[
|
163 |
+
'click_open' => [
|
164 |
'name' => __( 'Click Open', 'popup-maker' ),
|
165 |
'modal_title' => __( 'Click Trigger Settings', 'popup-maker' ),
|
166 |
'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Extra Selectors', 'popup-maker' ), '{{data.extra_selectors}}' ),
|
167 |
+
'fields' => [
|
168 |
+
'general' => [
|
169 |
+
'click_info' => [
|
170 |
'type' => 'html',
|
171 |
'content' => '<p>' . __( 'Adding the class "popmake-<span id="pum-default-click-trigger-class">{popup-ID}</span>" to an element will trigger it to be opened once clicked. Additionally you can add additional CSS selectors below.', 'popup-maker' ) . '</p>',
|
172 |
+
],
|
173 |
+
'extra_selectors' => [
|
174 |
'label' => __( 'Extra CSS Selectors', 'popup-maker' ),
|
175 |
'desc' => __( 'For more than one selector, separate by comma (,)', 'popup-maker' ) . '<br /><strong>eg: </strong>' . __( ' .class-here, .class-2-here, #button_id', 'popup-maker' ),
|
176 |
'placeholder' => __( '.class-here', 'popup-maker' ),
|
177 |
'doclink' => 'https://docs.wppopupmaker.com/article/147-getting-css-selectors?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-popup-editor&utm_content=extra-selectors',
|
178 |
+
],
|
179 |
+
],
|
180 |
+
'advanced' => [
|
181 |
+
'do_default' => [
|
182 |
'type' => 'checkbox',
|
183 |
'label' => __( 'Do not prevent the default click functionality.', 'popup-maker' ),
|
184 |
'desc' => __( 'This prevents us from disabling the browsers default action when a trigger is clicked. It can be used to allow a link to a file to both trigger a popup and still download the file.', 'popup-maker' ),
|
185 |
+
],
|
186 |
+
],
|
187 |
+
],
|
188 |
+
],
|
189 |
+
'auto_open' => [
|
190 |
'name' => __( 'Time Delay / Auto Open', 'popup-maker' ),
|
191 |
'modal_title' => __( 'Time Delay Settings', 'popup-maker' ),
|
192 |
'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Delay', 'popup-maker' ), '{{data.delay}}' ),
|
193 |
+
'fields' => [
|
194 |
+
'general' => [
|
195 |
+
'delay' => [
|
196 |
'type' => 'rangeslider',
|
197 |
'label' => __( 'Delay', 'popup-maker' ),
|
198 |
'desc' => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
|
201 |
'max' => 10000,
|
202 |
'step' => 500,
|
203 |
'unit' => 'ms',
|
204 |
+
],
|
205 |
+
],
|
206 |
+
],
|
207 |
+
],
|
208 |
+
'form_submission' => [
|
209 |
'name' => __( 'Form Submission', 'popup-maker' ),
|
210 |
+
// 'settings_column' => sprintf( '<strong>%1$s</strong>: %2$s', __( 'Form', 'popup-maker' ), '' ),
|
211 |
+
'fields' => [
|
212 |
+
'general' => [
|
213 |
+
'form' => [
|
214 |
'type' => 'select',
|
215 |
'label' => __( 'Form', 'popup-maker' ),
|
216 |
'options' => $this->preload_posts ? array_merge(
|
217 |
+
[
|
218 |
'any' => __( 'Any Supported Form*', 'popup-maker' ),
|
219 |
+
__( 'Popup Maker', 'popup-maker' ) => [
|
220 |
'pumsubform' => __( 'Subscription Form', 'popup-maker' ),
|
221 |
+
],
|
222 |
+
],
|
223 |
PUM_Integrations::get_integrated_forms_selectlist()
|
224 |
+
) : [],
|
225 |
'std' => 'any',
|
226 |
+
],
|
227 |
+
'delay' => [
|
228 |
'type' => 'rangeslider',
|
229 |
'label' => __( 'Delay', 'popup-maker' ),
|
230 |
'desc' => __( 'The delay before the popup will open in milliseconds.', 'popup-maker' ),
|
233 |
'max' => 10000,
|
234 |
'step' => 500,
|
235 |
'unit' => 'ms',
|
236 |
+
],
|
237 |
+
],
|
238 |
+
],
|
239 |
+
],
|
240 |
+
]
|
241 |
);
|
242 |
|
243 |
foreach ( $triggers as $key => $trigger ) {
|
244 |
$triggers[ $key ]['fields'] = PUM_Admin_Helpers::parse_tab_fields(
|
245 |
$triggers[ $key ]['fields'],
|
246 |
+
[
|
247 |
'has_subtabs' => false,
|
248 |
'name' => '%s',
|
249 |
+
]
|
250 |
);
|
251 |
}
|
252 |
|
253 |
// @deprecated filter.
|
254 |
+
$old_triggers = apply_filters( 'pum_get_triggers', [] );
|
255 |
|
256 |
foreach ( $old_triggers as $type => $trigger ) {
|
257 |
if ( isset( $triggers[ $type ] ) ) {
|
281 |
*/
|
282 |
public function dropdown_list() {
|
283 |
$_triggers = $this->get_triggers();
|
284 |
+
$triggers = [];
|
285 |
|
286 |
foreach ( $_triggers as $id => $trigger ) {
|
287 |
$triggers[ $id ] = $trigger['name'];
|
305 |
*/
|
306 |
return apply_filters(
|
307 |
'pum_trigger_cookie_fields',
|
308 |
+
[
|
309 |
'cookie_name' => $this->cookie_field(),
|
310 |
+
]
|
311 |
);
|
312 |
}
|
313 |
|
326 |
*/
|
327 |
return apply_filters(
|
328 |
'pum_trigger_cookie_field',
|
329 |
+
[
|
330 |
'label' => __( 'Cookie Name', 'popup-maker' ),
|
331 |
'desc' => __( 'Choose which cookies will disable this trigger?', 'popup-maker' ),
|
332 |
'type' => 'select',
|
334 |
'as_array' => true,
|
335 |
'select2' => true,
|
336 |
'priority' => 99,
|
337 |
+
'options' => [
|
338 |
'add_new' => __( 'Add New Cookie', 'popup-maker' ),
|
339 |
+
],
|
340 |
+
]
|
341 |
);
|
342 |
}
|
343 |
|
356 |
*/
|
357 |
return apply_filters(
|
358 |
'pum_get_trigger_tabs',
|
359 |
+
[
|
360 |
'general' => __( 'General', 'popup-maker' ),
|
361 |
'cookie' => __( 'Cookie', 'popup-maker' ),
|
362 |
'advanced' => __( 'Advanced', 'popup-maker' ),
|
363 |
+
]
|
364 |
);
|
365 |
}
|
366 |
|
380 |
*
|
381 |
* @param array $to_do The list of trigger labels.
|
382 |
*/
|
383 |
+
$labels = apply_filters( 'pum_get_trigger_labels', [] );
|
384 |
}
|
385 |
|
386 |
return $labels;
|
classes/Types.php
CHANGED
@@ -6,11 +6,11 @@ class PUM_Types {
|
|
6 |
* Hook the initialize method to the WP init action.
|
7 |
*/
|
8 |
public static function init() {
|
9 |
-
add_action( 'init',
|
10 |
-
add_action( 'init',
|
11 |
-
add_filter( 'post_updated_messages',
|
12 |
|
13 |
-
add_filter( 'wpseo_accessible_post_types',
|
14 |
}
|
15 |
|
16 |
/**
|
@@ -18,29 +18,35 @@ class PUM_Types {
|
|
18 |
*/
|
19 |
public static function register_post_types() {
|
20 |
if ( ! post_type_exists( 'popup' ) ) {
|
21 |
-
$labels =
|
22 |
|
23 |
$labels['menu_name'] = __( 'Popup Maker', 'popup-maker' );
|
24 |
|
25 |
-
$popup_args = apply_filters(
|
26 |
-
'
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
'
|
38 |
-
'
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
// Temporary Yoast Fixes
|
46 |
if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_titles' ) {
|
@@ -51,26 +57,35 @@ class PUM_Types {
|
|
51 |
}
|
52 |
|
53 |
if ( ! post_type_exists( 'popup_theme' ) ) {
|
54 |
-
$labels =
|
55 |
|
56 |
$labels['all_items'] = __( 'Popup Themes', 'popup-maker' );
|
57 |
|
58 |
$labels = apply_filters( 'popmake_popup_theme_labels', $labels );
|
59 |
|
60 |
-
register_post_type(
|
61 |
-
'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
}
|
76 |
|
@@ -81,19 +96,22 @@ class PUM_Types {
|
|
81 |
* @return mixed
|
82 |
*/
|
83 |
public static function post_type_labels( $singular, $plural ) {
|
84 |
-
$labels = apply_filters(
|
85 |
-
'
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
97 |
|
98 |
foreach ( $labels as $key => $value ) {
|
99 |
$labels[ $key ] = sprintf( $value, $singular, $plural );
|
@@ -115,13 +133,16 @@ class PUM_Types {
|
|
115 |
/** Categories */
|
116 |
$category_labels = (array) get_taxonomy_labels( get_taxonomy( 'category' ) );
|
117 |
|
118 |
-
$category_args = apply_filters(
|
119 |
-
'
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
125 |
register_taxonomy_for_object_type( 'popup_category', 'popup' );
|
126 |
register_taxonomy_for_object_type( 'popup_category', 'popup_theme' );
|
127 |
|
@@ -129,13 +150,16 @@ class PUM_Types {
|
|
129 |
|
130 |
$tag_labels = (array) get_taxonomy_labels( get_taxonomy( 'post_tag' ) );
|
131 |
|
132 |
-
$tag_args = apply_filters(
|
133 |
-
'
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
139 |
register_taxonomy_for_object_type( 'popup_tag', 'popup' );
|
140 |
register_taxonomy_for_object_type( 'popup_tag', 'popup_theme' );
|
141 |
}
|
@@ -153,16 +177,16 @@ class PUM_Types {
|
|
153 |
*/
|
154 |
public static function updated_messages( $messages ) {
|
155 |
|
156 |
-
$labels =
|
157 |
1 => _x( '%1$s updated.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
158 |
4 => _x( '%1$s updated.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
159 |
6 => _x( '%1$s published.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
160 |
7 => _x( '%1$s saved.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
161 |
8 => _x( '%1$s submitted.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
162 |
-
|
163 |
|
164 |
-
$messages['popup'] =
|
165 |
-
$messages['popup_theme'] =
|
166 |
|
167 |
$popup = __( 'Popup', 'popup-maker' );
|
168 |
$theme = __( 'Popup Theme', 'popup-maker' );
|
@@ -182,7 +206,7 @@ class PUM_Types {
|
|
182 |
*
|
183 |
* @return array
|
184 |
*/
|
185 |
-
public static function yoast_sitemap_fix( $post_types =
|
186 |
unset( $post_types['popup'] );
|
187 |
|
188 |
return $post_types;
|
6 |
* Hook the initialize method to the WP init action.
|
7 |
*/
|
8 |
public static function init() {
|
9 |
+
add_action( 'init', [ __CLASS__, 'register_post_types' ], 1 );
|
10 |
+
add_action( 'init', [ __CLASS__, 'register_taxonomies' ], 0 );
|
11 |
+
add_filter( 'post_updated_messages', [ __CLASS__, 'updated_messages' ] );
|
12 |
|
13 |
+
add_filter( 'wpseo_accessible_post_types', [ __CLASS__, 'yoast_sitemap_fix' ] );
|
14 |
}
|
15 |
|
16 |
/**
|
18 |
*/
|
19 |
public static function register_post_types() {
|
20 |
if ( ! post_type_exists( 'popup' ) ) {
|
21 |
+
$labels = self::post_type_labels( __( 'Popup', 'popup-maker' ), __( 'Popups', 'popup-maker' ) );
|
22 |
|
23 |
$labels['menu_name'] = __( 'Popup Maker', 'popup-maker' );
|
24 |
|
25 |
+
$popup_args = apply_filters(
|
26 |
+
'popmake_popup_post_type_args',
|
27 |
+
[
|
28 |
+
'labels' => $labels,
|
29 |
+
'public' => true,
|
30 |
+
'publicly_queryable' => false,
|
31 |
+
'query_var' => false,
|
32 |
+
'rewrite' => false,
|
33 |
+
'exclude_from_search' => true,
|
34 |
+
'show_in_nav_menus' => false,
|
35 |
+
'show_ui' => true,
|
36 |
+
'menu_icon' => pum_get_svg_icon( true ),
|
37 |
+
'menu_position' => 20.292892729,
|
38 |
+
'supports' => apply_filters(
|
39 |
+
'popmake_popup_supports',
|
40 |
+
[
|
41 |
+
'title',
|
42 |
+
'editor',
|
43 |
+
'revisions',
|
44 |
+
'author',
|
45 |
+
]
|
46 |
+
),
|
47 |
+
'show_in_rest' => pum_get_option( 'gutenberg_support_enabled', false ), // Adds support for Gutenberg currently.
|
48 |
+
]
|
49 |
+
);
|
50 |
|
51 |
// Temporary Yoast Fixes
|
52 |
if ( is_admin() && isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_titles' ) {
|
57 |
}
|
58 |
|
59 |
if ( ! post_type_exists( 'popup_theme' ) ) {
|
60 |
+
$labels = self::post_type_labels( __( 'Popup Theme', 'popup-maker' ), __( 'Popup Themes', 'popup-maker' ) );
|
61 |
|
62 |
$labels['all_items'] = __( 'Popup Themes', 'popup-maker' );
|
63 |
|
64 |
$labels = apply_filters( 'popmake_popup_theme_labels', $labels );
|
65 |
|
66 |
+
register_post_type(
|
67 |
+
'popup_theme',
|
68 |
+
apply_filters(
|
69 |
+
'popmake_popup_theme_post_type_args',
|
70 |
+
[
|
71 |
+
'labels' => $labels,
|
72 |
+
'show_ui' => true,
|
73 |
+
'show_in_nav_menus' => false,
|
74 |
+
'show_in_menu' => 'edit.php?post_type=popup',
|
75 |
+
'show_in_admin_bar' => false,
|
76 |
+
'query_var' => false,
|
77 |
+
'rewrite' => false,
|
78 |
+
'supports' => apply_filters(
|
79 |
+
'popmake_popup_theme_supports',
|
80 |
+
[
|
81 |
+
'title',
|
82 |
+
'revisions',
|
83 |
+
'author',
|
84 |
+
]
|
85 |
+
),
|
86 |
+
]
|
87 |
+
)
|
88 |
+
);
|
89 |
}
|
90 |
}
|
91 |
|
96 |
* @return mixed
|
97 |
*/
|
98 |
public static function post_type_labels( $singular, $plural ) {
|
99 |
+
$labels = apply_filters(
|
100 |
+
'popmake_popup_labels',
|
101 |
+
[
|
102 |
+
'name' => '%2$s',
|
103 |
+
'singular_name' => '%1$s',
|
104 |
+
'add_new_item' => _x( 'Create New %1$s', 'Post Type Singular: "Popup", "Popup Theme"', 'popup-maker' ),
|
105 |
+
'add_new' => _x( 'Create %1$s', 'Post Type Singular: "Popup", "Popup Theme"', 'popup-maker' ),
|
106 |
+
'edit_item' => _x( 'Edit %1$s', 'Post Type Singular: "Popup", "Popup Theme"', 'popup-maker' ),
|
107 |
+
'new_item' => _x( 'New %1$s', 'Post Type Singular: "Popup", "Popup Theme"', 'popup-maker' ),
|
108 |
+
'all_items' => _x( 'All %2$s', 'Post Type Plural: "Popups", "Popup Themes"', 'popup-maker' ),
|
109 |
+
'view_item' => _x( 'View %1$s', 'Post Type Singular: "Popup", "Popup Theme"', 'popup-maker' ),
|
110 |
+
'search_items' => _x( 'Search %2$s', 'Post Type Plural: "Popups", "Popup Themes"', 'popup-maker' ),
|
111 |
+
'not_found' => _x( 'No %2$s found', 'Post Type Plural: "Popups", "Popup Themes"', 'popup-maker' ),
|
112 |
+
'not_found_in_trash' => _x( 'No %2$s found in Trash', 'Post Type Plural: "Popups", "Popup Themes"', 'popup-maker' ),
|
113 |
+
]
|
114 |
+
);
|
115 |
|
116 |
foreach ( $labels as $key => $value ) {
|
117 |
$labels[ $key ] = sprintf( $value, $singular, $plural );
|
133 |
/** Categories */
|
134 |
$category_labels = (array) get_taxonomy_labels( get_taxonomy( 'category' ) );
|
135 |
|
136 |
+
$category_args = apply_filters(
|
137 |
+
'popmake_category_args',
|
138 |
+
[
|
139 |
+
'hierarchical' => true,
|
140 |
+
'labels' => apply_filters( 'popmake_category_labels', $category_labels ),
|
141 |
+
'public' => false,
|
142 |
+
'show_ui' => true,
|
143 |
+
]
|
144 |
+
);
|
145 |
+
register_taxonomy( 'popup_category', [ 'popup', 'popup_theme' ], $category_args );
|
146 |
register_taxonomy_for_object_type( 'popup_category', 'popup' );
|
147 |
register_taxonomy_for_object_type( 'popup_category', 'popup_theme' );
|
148 |
|
150 |
|
151 |
$tag_labels = (array) get_taxonomy_labels( get_taxonomy( 'post_tag' ) );
|
152 |
|
153 |
+
$tag_args = apply_filters(
|
154 |
+
'popmake_tag_args',
|
155 |
+
[
|
156 |
+
'hierarchical' => false,
|
157 |
+
'labels' => apply_filters( 'popmake_tag_labels', $tag_labels ),
|
158 |
+
'public' => false,
|
159 |
+
'show_ui' => true,
|
160 |
+
]
|
161 |
+
);
|
162 |
+
register_taxonomy( 'popup_tag', [ 'popup', 'popup_theme' ], $tag_args );
|
163 |
register_taxonomy_for_object_type( 'popup_tag', 'popup' );
|
164 |
register_taxonomy_for_object_type( 'popup_tag', 'popup_theme' );
|
165 |
}
|
177 |
*/
|
178 |
public static function updated_messages( $messages ) {
|
179 |
|
180 |
+
$labels = [
|
181 |
1 => _x( '%1$s updated.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
182 |
4 => _x( '%1$s updated.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
183 |
6 => _x( '%1$s published.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
184 |
7 => _x( '%1$s saved.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
185 |
8 => _x( '%1$s submitted.', 'Post Type Singular: Popup, Theme', 'popup-maker' ),
|
186 |
+
];
|
187 |
|
188 |
+
$messages['popup'] = [];
|
189 |
+
$messages['popup_theme'] = [];
|
190 |
|
191 |
$popup = __( 'Popup', 'popup-maker' );
|
192 |
$theme = __( 'Popup Theme', 'popup-maker' );
|
206 |
*
|
207 |
* @return array
|
208 |
*/
|
209 |
+
public static function yoast_sitemap_fix( $post_types = [] ) {
|
210 |
unset( $post_types['popup'] );
|
211 |
|
212 |
return $post_types;
|
classes/Upgrade/Registry.php
CHANGED
@@ -42,7 +42,7 @@ class PUM_Upgrade_Registry extends PUM_Batch_Process_Registry {
|
|
42 |
public static function instance() {
|
43 |
if ( ! isset( self::$instance ) ) {
|
44 |
self::$instance = new self();
|
45 |
-
add_action( 'init',
|
46 |
}
|
47 |
|
48 |
return self::$instance;
|
@@ -81,7 +81,7 @@ class PUM_Upgrade_Registry extends PUM_Batch_Process_Registry {
|
|
81 |
/**
|
82 |
* Adds an upgrade to the registry.
|
83 |
*
|
84 |
-
* @param int
|
85 |
* @param array $attributes {
|
86 |
* Upgrade attributes.
|
87 |
*
|
@@ -92,11 +92,14 @@ class PUM_Upgrade_Registry extends PUM_Batch_Process_Registry {
|
|
92 |
* @return true Always true.
|
93 |
*/
|
94 |
public function add_upgrade( $upgrade_id, $attributes ) {
|
95 |
-
$attributes = wp_parse_args(
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
100 |
|
101 |
// Log an error if it's too late to register the process.
|
102 |
if ( did_action( 'pum_upgrade_process_init' ) ) {
|
42 |
public static function instance() {
|
43 |
if ( ! isset( self::$instance ) ) {
|
44 |
self::$instance = new self();
|
45 |
+
add_action( 'init', [ self::$instance, 'init' ], -9999 );
|
46 |
}
|
47 |
|
48 |
return self::$instance;
|
81 |
/**
|
82 |
* Adds an upgrade to the registry.
|
83 |
*
|
84 |
+
* @param int $upgrade_id upgrade ID.
|
85 |
* @param array $attributes {
|
86 |
* Upgrade attributes.
|
87 |
*
|
92 |
* @return true Always true.
|
93 |
*/
|
94 |
public function add_upgrade( $upgrade_id, $attributes ) {
|
95 |
+
$attributes = wp_parse_args(
|
96 |
+
$attributes,
|
97 |
+
[
|
98 |
+
'rules' => [],
|
99 |
+
'class' => '',
|
100 |
+
'file' => '',
|
101 |
+
]
|
102 |
+
);
|
103 |
|
104 |
// Log an error if it's too late to register the process.
|
105 |
if ( did_action( 'pum_upgrade_process_init' ) ) {
|
classes/Upsell.php
CHANGED
@@ -9,11 +9,11 @@ class PUM_Upsell {
|
|
9 |
* Hooks any needed methods
|
10 |
*/
|
11 |
public static function init() {
|
12 |
-
add_filter( 'views_edit-popup',
|
13 |
-
add_filter( 'views_edit-popup_theme',
|
14 |
-
add_filter( 'pum_popup_settings_fields',
|
15 |
-
add_filter( 'pum_theme_settings_fields',
|
16 |
-
add_action( 'in_admin_header',
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -36,13 +36,13 @@ class PUM_Upsell {
|
|
36 |
<?php
|
37 |
echo wp_kses(
|
38 |
$message,
|
39 |
-
|
40 |
-
'a' =>
|
41 |
-
'href' =>
|
42 |
-
'rel' =>
|
43 |
-
'target' =>
|
44 |
-
|
45 |
-
|
46 |
);
|
47 |
?>
|
48 |
</span>
|
@@ -58,29 +58,29 @@ class PUM_Upsell {
|
|
58 |
* @param array $tabs The tabs/fields for popup settings.
|
59 |
* @return array
|
60 |
*/
|
61 |
-
public static function popup_promotional_fields( $tabs =
|
62 |
if ( ! pum_extension_enabled( 'forced-interaction' ) ) {
|
63 |
/* translators: %s url to product page. */
|
64 |
$message = sprintf( __( 'Want to disable the close button? Check out <a href="%s" target="_blank">Forced Interaction</a>!', 'popup-maker' ), 'https://wppopupmaker.com/extensions/forced-interaction/?utm_source=plugin-theme-editor&utm_medium=text-link&utm_campaign=upsell&utm_content=close-button-settings' );
|
65 |
|
66 |
-
$tabs['close']['button']['fi_promotion'] = $tabs['close']['forms']['fi_promotion'] = $tabs['close']['alternate_methods']['fi_promotion'] =
|
67 |
'type' => 'html',
|
68 |
'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-forced-interaction.png' ) . '" />' . $message,
|
69 |
'priority' => 999,
|
70 |
'class' => 'pum-upgrade-tip',
|
71 |
-
|
72 |
}
|
73 |
|
74 |
if ( ! pum_extension_enabled( 'advanced-targeting-conditions' ) ) {
|
75 |
/* translators: %s url to product page. */
|
76 |
$message = sprintf( __( 'Need more <a href="%s" target="_blank">advanced targeting</a> options?', 'popup-maker' ), 'https://wppopupmaker.com/extensions/advanced-targeting-conditions/?utm_campaign=upsell&utm_source=plugin-popup-editor&utm_medium=text-link&utm_content=conditions-editor' );
|
77 |
|
78 |
-
$tabs['targeting']['main']['atc_promotion'] =
|
79 |
'type' => 'html',
|
80 |
'content' => '<img src="' . pum_asset_url( 'images/logo.png' ) . '" height="28" />' . $message,
|
81 |
'priority' => 999,
|
82 |
'class' => 'pum-upgrade-tip',
|
83 |
-
|
84 |
}
|
85 |
|
86 |
return $tabs;
|
@@ -92,19 +92,19 @@ class PUM_Upsell {
|
|
92 |
* @param array $tabs The tabs/fields for popup theme.
|
93 |
* @return array
|
94 |
*/
|
95 |
-
public static function theme_promotional_fields( $tabs =
|
96 |
|
97 |
if ( ! pum_extension_enabled( 'advanced-theme-builder' ) && ! class_exists( 'PUM_ATB' ) ) {
|
98 |
-
foreach (
|
99 |
/* translators: %s url to product page. */
|
100 |
$message = __( 'Want to use <a href="%s" target="_blank">background images</a>?', 'popup-maker' );
|
101 |
|
102 |
-
$tabs[ $tab ]['background']['atc_promotion'] =
|
103 |
'type' => 'html',
|
104 |
'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-advanted-theme-builder.png' ) . '" height="28" />' . sprintf( $message, 'https://wppopupmaker.com/extensions/advanced-theme-builder/?utm_campaign=upsell&utm_source=plugin-theme-editor&utm_medium=text-link&utm_content=' . $tab . '-settings' ),
|
105 |
'priority' => 999,
|
106 |
'class' => 'pum-upgrade-tip',
|
107 |
-
|
108 |
}
|
109 |
}
|
110 |
|
@@ -153,20 +153,20 @@ class PUM_Upsell {
|
|
153 |
</style>
|
154 |
<nav class="nav-tab-wrapper">
|
155 |
<?php
|
156 |
-
$tabs =
|
157 |
-
'popups' =>
|
158 |
'name' => esc_html( $popup_labels['name'] ),
|
159 |
'url' => admin_url( 'edit.php?post_type=popup' ),
|
160 |
-
|
161 |
-
'themes' =>
|
162 |
'name' => esc_html( $theme_labels['name'] ),
|
163 |
'url' => admin_url( 'edit.php?post_type=popup_theme' ),
|
164 |
-
|
165 |
-
'integrations' =>
|
166 |
'name' => esc_html__( 'Upgrade', 'popup-maker' ),
|
167 |
'url' => admin_url( 'edit.php?post_type=popup&page=pum-extensions&view=integrations' ),
|
168 |
-
|
169 |
-
|
170 |
|
171 |
$tabs = apply_filters( 'pum_add_ons_tabs', $tabs );
|
172 |
|
9 |
* Hooks any needed methods
|
10 |
*/
|
11 |
public static function init() {
|
12 |
+
add_filter( 'views_edit-popup', [ __CLASS__, 'addon_tabs' ], 10, 1 );
|
13 |
+
add_filter( 'views_edit-popup_theme', [ __CLASS__, 'addon_tabs' ], 10, 1 );
|
14 |
+
add_filter( 'pum_popup_settings_fields', [ __CLASS__, 'popup_promotional_fields' ] );
|
15 |
+
add_filter( 'pum_theme_settings_fields', [ __CLASS__, 'theme_promotional_fields' ] );
|
16 |
+
add_action( 'in_admin_header', [ __CLASS__, 'notice_bar_display' ] );
|
17 |
}
|
18 |
|
19 |
/**
|
36 |
<?php
|
37 |
echo wp_kses(
|
38 |
$message,
|
39 |
+
[
|
40 |
+
'a' => [
|
41 |
+
'href' => [],
|
42 |
+
'rel' => [],
|
43 |
+
'target' => [],
|
44 |
+
],
|
45 |
+
]
|
46 |
);
|
47 |
?>
|
48 |
</span>
|
58 |
* @param array $tabs The tabs/fields for popup settings.
|
59 |
* @return array
|
60 |
*/
|
61 |
+
public static function popup_promotional_fields( $tabs = [] ) {
|
62 |
if ( ! pum_extension_enabled( 'forced-interaction' ) ) {
|
63 |
/* translators: %s url to product page. */
|
64 |
$message = sprintf( __( 'Want to disable the close button? Check out <a href="%s" target="_blank">Forced Interaction</a>!', 'popup-maker' ), 'https://wppopupmaker.com/extensions/forced-interaction/?utm_source=plugin-theme-editor&utm_medium=text-link&utm_campaign=upsell&utm_content=close-button-settings' );
|
65 |
|
66 |
+
$tabs['close']['button']['fi_promotion'] = $tabs['close']['forms']['fi_promotion'] = $tabs['close']['alternate_methods']['fi_promotion'] = [
|
67 |
'type' => 'html',
|
68 |
'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-forced-interaction.png' ) . '" />' . $message,
|
69 |
'priority' => 999,
|
70 |
'class' => 'pum-upgrade-tip',
|
71 |
+
];
|
72 |
}
|
73 |
|
74 |
if ( ! pum_extension_enabled( 'advanced-targeting-conditions' ) ) {
|
75 |
/* translators: %s url to product page. */
|
76 |
$message = sprintf( __( 'Need more <a href="%s" target="_blank">advanced targeting</a> options?', 'popup-maker' ), 'https://wppopupmaker.com/extensions/advanced-targeting-conditions/?utm_campaign=upsell&utm_source=plugin-popup-editor&utm_medium=text-link&utm_content=conditions-editor' );
|
77 |
|
78 |
+
$tabs['targeting']['main']['atc_promotion'] = [
|
79 |
'type' => 'html',
|
80 |
'content' => '<img src="' . pum_asset_url( 'images/logo.png' ) . '" height="28" />' . $message,
|
81 |
'priority' => 999,
|
82 |
'class' => 'pum-upgrade-tip',
|
83 |
+
];
|
84 |
}
|
85 |
|
86 |
return $tabs;
|
92 |
* @param array $tabs The tabs/fields for popup theme.
|
93 |
* @return array
|
94 |
*/
|
95 |
+
public static function theme_promotional_fields( $tabs = [] ) {
|
96 |
|
97 |
if ( ! pum_extension_enabled( 'advanced-theme-builder' ) && ! class_exists( 'PUM_ATB' ) ) {
|
98 |
+
foreach ( [ 'overlay', 'container', 'close' ] as $tab ) {
|
99 |
/* translators: %s url to product page. */
|
100 |
$message = __( 'Want to use <a href="%s" target="_blank">background images</a>?', 'popup-maker' );
|
101 |
|
102 |
+
$tabs[ $tab ]['background']['atc_promotion'] = [
|
103 |
'type' => 'html',
|
104 |
'content' => '<img src="' . pum_asset_url( 'images/upsell-icon-advanted-theme-builder.png' ) . '" height="28" />' . sprintf( $message, 'https://wppopupmaker.com/extensions/advanced-theme-builder/?utm_campaign=upsell&utm_source=plugin-theme-editor&utm_medium=text-link&utm_content=' . $tab . '-settings' ),
|
105 |
'priority' => 999,
|
106 |
'class' => 'pum-upgrade-tip',
|
107 |
+
];
|
108 |
}
|
109 |
}
|
110 |
|
153 |
</style>
|
154 |
<nav class="nav-tab-wrapper">
|
155 |
<?php
|
156 |
+
$tabs = [
|
157 |
+
'popups' => [
|
158 |
'name' => esc_html( $popup_labels['name'] ),
|
159 |
'url' => admin_url( 'edit.php?post_type=popup' ),
|
160 |
+
],
|
161 |
+
'themes' => [
|
162 |
'name' => esc_html( $theme_labels['name'] ),
|
163 |
'url' => admin_url( 'edit.php?post_type=popup_theme' ),
|
164 |
+
],
|
165 |
+
'integrations' => [
|
166 |
'name' => esc_html__( 'Upgrade', 'popup-maker' ),
|
167 |
'url' => admin_url( 'edit.php?post_type=popup&page=pum-extensions&view=integrations' ),
|
168 |
+
],
|
169 |
+
];
|
170 |
|
171 |
$tabs = apply_filters( 'pum_add_ons_tabs', $tabs );
|
172 |
|
classes/Utils/Alerts.php
CHANGED
@@ -16,13 +16,13 @@ class PUM_Utils_Alerts {
|
|
16 |
*
|
17 |
*/
|
18 |
public static function init() {
|
19 |
-
add_action( 'admin_init',
|
20 |
-
add_action( 'admin_init',
|
21 |
-
add_action( 'wp_ajax_pum_alerts_action',
|
22 |
-
add_filter( 'pum_alert_list',
|
23 |
-
add_filter( 'pum_alert_list',
|
24 |
-
add_filter( 'pum_alert_list',
|
25 |
-
add_action( 'admin_menu',
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -52,7 +52,7 @@ class PUM_Utils_Alerts {
|
|
52 |
*
|
53 |
* @return array
|
54 |
*/
|
55 |
-
public static function translation_request( $alerts =
|
56 |
|
57 |
$version = explode( '.', Popup_Maker::$VER );
|
58 |
// Get only the major.minor version exclude the point releases.
|
@@ -120,7 +120,7 @@ class PUM_Utils_Alerts {
|
|
120 |
$locales_supported_by_wordpress = PUM_Utils_I10n::available_locales();
|
121 |
|
122 |
// Get the native language names of the locales.
|
123 |
-
$suggest_translated_locale_names =
|
124 |
foreach ( $suggested_locales_with_langpack as $locale ) {
|
125 |
$suggest_translated_locale_names[ $locale ] = $locales_supported_by_wordpress[ $locale ]['native_name'];
|
126 |
}
|
@@ -139,7 +139,10 @@ class PUM_Utils_Alerts {
|
|
139 |
$language = current( $suggest_translated_locale_names );
|
140 |
|
141 |
$suggest_string = sprintf( /* translators: %s: native language name. */
|
142 |
-
__( 'This plugin is also available in %1$s. <a href="%2$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
|
|
|
|
|
|
143 |
|
144 |
// Multiple locale suggestions.
|
145 |
} elseif ( ! empty( $suggest_translated_locale_names ) ) {
|
@@ -152,7 +155,11 @@ class PUM_Utils_Alerts {
|
|
152 |
}
|
153 |
|
154 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: other native language names, comma separated */
|
155 |
-
__( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
|
|
|
|
|
|
|
|
156 |
|
157 |
// Non-English locale in header, no translations.
|
158 |
} elseif ( ! empty( $non_en_locales_from_header ) ) {
|
@@ -161,7 +168,10 @@ class PUM_Utils_Alerts {
|
|
161 |
$locale = reset( $non_en_locales_from_header );
|
162 |
|
163 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: URL to translate.wordpress.org */
|
164 |
-
__( 'This plugin is not translated into %1$s yet. <a href="%2$s" target="_blank">Help translate it!</a>', 'popup-maker' ),
|
|
|
|
|
|
|
165 |
} else {
|
166 |
$primary_locale = reset( $non_en_locales_from_header );
|
167 |
$primary_language = $locales_supported_by_wordpress[ $primary_locale ]['native_name'];
|
@@ -173,7 +183,11 @@ class PUM_Utils_Alerts {
|
|
173 |
}
|
174 |
|
175 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: other native language names, comma separated */
|
176 |
-
__( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
|
|
|
|
|
|
|
|
177 |
}
|
178 |
}
|
179 |
|
@@ -183,16 +197,18 @@ class PUM_Utils_Alerts {
|
|
183 |
// The plugin has translations for current locale, but they are out of date.
|
184 |
} elseif ( $current_locale_is_suggested && $current_locale_is_translated && version_compare( $locale_translation_versions[ $current_locale ], Popup_Maker::$VER, '<' ) ) {
|
185 |
$suggest_string = sprintf( /* translators: %s: native language name. */
|
186 |
-
__( 'This plugin\'s translation for %1$s is out of date. <a href="%2$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
|
|
|
|
|
|
187 |
}
|
188 |
|
189 |
-
|
190 |
if ( ! empty( $suggest_string ) ) {
|
191 |
-
$alerts[] =
|
192 |
'code' => $code,
|
193 |
'message' => $suggest_string,
|
194 |
'type' => 'info',
|
195 |
-
|
196 |
}
|
197 |
|
198 |
return $alerts;
|
@@ -203,29 +219,36 @@ class PUM_Utils_Alerts {
|
|
203 |
*
|
204 |
* @return array
|
205 |
*/
|
206 |
-
public static function whats_new_alerts( $alerts =
|
207 |
|
208 |
$upgraded_from = PUM_Utils_Upgrades::$upgraded_from;
|
209 |
|
210 |
if ( version_compare( $upgraded_from, '0.0.0', '>' ) ) {
|
211 |
|
212 |
if ( version_compare( $upgraded_from, '1.8.0', '<' ) ) {
|
213 |
-
$alerts[] =
|
214 |
'code' => 'whats_new_1_8_0',
|
215 |
'type' => 'success',
|
216 |
-
'message' => sprintf(
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
'priority' => 100,
|
226 |
-
|
227 |
}
|
228 |
-
|
229 |
}
|
230 |
|
231 |
return $alerts;
|
@@ -236,18 +259,18 @@ class PUM_Utils_Alerts {
|
|
236 |
*
|
237 |
* @return array
|
238 |
*/
|
239 |
-
public static function integration_alerts( $alerts =
|
240 |
|
241 |
-
$integrations =
|
242 |
-
'buddypress' =>
|
243 |
'label' => __( 'BuddyPress', 'buddypress' ),
|
244 |
'learn_more_url' => 'https://wppopupmaker.com/works-with/buddypress/',
|
245 |
'conditions' => ! class_exists( 'PUM_BuddyPress' ) && ( function_exists( 'buddypress' ) || class_exists( 'BuddyPress' ) ),
|
246 |
'slug' => 'popup-maker-buddypress-integration',
|
247 |
'name' => 'Popup Maker - BuddyPress Integration',
|
248 |
'free' => true,
|
249 |
-
|
250 |
-
|
251 |
|
252 |
foreach ( $integrations as $key => $integration ) {
|
253 |
|
@@ -261,16 +284,15 @@ class PUM_Utils_Alerts {
|
|
261 |
$text = $installed ? __( 'activate it now', 'popup-maker' ) : __( 'install it now', 'popup-maker' );
|
262 |
$url = $installed ? esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) : esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker-buddypress-integration' ), 'install-plugin_popup-maker-buddypress-integration' ) );
|
263 |
|
264 |
-
$alerts[] =
|
265 |
'code' => $key . '_integration_available',
|
266 |
-
'message' => sprintf( __( '%sDid you know:%s Popup Maker has custom integrations with %s, %slearn more%s or %s%s%s!', 'popup-maker' ), '<strong>', '</strong>', $integration['label'], '<a href="' . $integration['learn_more_url'] . '" target="_blank">', '</a>', '<a href="' . $url . '">', $text, '</a>' ),
|
267 |
'dismissible' => true,
|
268 |
'global' => false,
|
269 |
'type' => $installed ? 'warning' : 'info',
|
270 |
-
|
271 |
|
272 |
}
|
273 |
-
|
274 |
}
|
275 |
|
276 |
return $alerts;
|
@@ -281,9 +303,9 @@ class PUM_Utils_Alerts {
|
|
281 |
*/
|
282 |
public static function hooks() {
|
283 |
if ( is_admin() && current_user_can( 'edit_posts' ) ) {
|
284 |
-
add_action( 'admin_notices',
|
285 |
-
add_action( 'network_admin_notices',
|
286 |
-
add_action( 'user_admin_notices',
|
287 |
}
|
288 |
}
|
289 |
|
@@ -291,10 +313,13 @@ class PUM_Utils_Alerts {
|
|
291 |
* @return bool
|
292 |
*/
|
293 |
public static function should_show_alerts() {
|
294 |
-
return in_array(
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
298 |
}
|
299 |
|
300 |
/**
|
@@ -322,7 +347,7 @@ class PUM_Utils_Alerts {
|
|
322 |
?>
|
323 |
|
324 |
<script type="text/javascript">
|
325 |
-
|
326 |
</script>
|
327 |
|
328 |
<div class="pum-alerts">
|
@@ -333,14 +358,17 @@ class PUM_Utils_Alerts {
|
|
333 |
|
334 |
<p><?php __( 'Check out the following notifications from Popup Maker.', 'popup-maker' ); ?></p>
|
335 |
|
336 |
-
<?php
|
337 |
-
|
338 |
-
$
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
|
|
|
|
|
|
344 |
?>
|
345 |
|
346 |
<div class="pum-alert-holder" data-code="<?php echo $alert['code']; ?>" class="<?php echo $alert['dismissible'] ? 'is-dismissible' : ''; ?>" data-dismissible="<?php echo esc_attr( $alert['dismissible'] ); ?>">
|
@@ -364,12 +392,14 @@ class PUM_Utils_Alerts {
|
|
364 |
$url = $action['href'];
|
365 |
$attributes = 'target="_blank" rel="noreferrer noopener"';
|
366 |
} else {
|
367 |
-
$url = add_query_arg(
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
|
|
373 |
|
374 |
$attributes = 'class="pum-dismiss"';
|
375 |
}
|
@@ -404,7 +434,7 @@ class PUM_Utils_Alerts {
|
|
404 |
public static function get_global_alerts() {
|
405 |
$alerts = self::get_alerts();
|
406 |
|
407 |
-
$global_alerts =
|
408 |
|
409 |
foreach ( $alerts as $alert ) {
|
410 |
if ( $alert['global'] ) {
|
@@ -423,10 +453,10 @@ class PUM_Utils_Alerts {
|
|
423 |
static $alert_list;
|
424 |
|
425 |
if ( ! isset( $alert_list ) ) {
|
426 |
-
$alert_list = apply_filters( 'pum_alert_list',
|
427 |
}
|
428 |
|
429 |
-
$alerts =
|
430 |
|
431 |
foreach ( $alert_list as $alert ) {
|
432 |
|
@@ -435,15 +465,18 @@ class PUM_Utils_Alerts {
|
|
435 |
continue;
|
436 |
}
|
437 |
|
438 |
-
$alerts[] = wp_parse_args(
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
|
|
|
|
|
|
447 |
|
448 |
}
|
449 |
|
@@ -458,11 +491,14 @@ class PUM_Utils_Alerts {
|
|
458 |
* Handles if alert was dismissed AJAX
|
459 |
*/
|
460 |
public static function ajax_handler() {
|
461 |
-
$args = wp_parse_args(
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
|
|
|
|
|
|
466 |
|
467 |
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'pum_alerts_action' ) ) {
|
468 |
wp_send_json_error();
|
@@ -490,11 +526,14 @@ class PUM_Utils_Alerts {
|
|
490 |
return;
|
491 |
}
|
492 |
|
493 |
-
$args = wp_parse_args(
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
|
|
|
|
|
|
498 |
|
499 |
self::action_handler( $args['code'], $args['pum_dismiss_alert'], $args['expires'] );
|
500 |
}
|
@@ -559,7 +598,7 @@ class PUM_Utils_Alerts {
|
|
559 |
$dismissed_alerts = get_user_meta( $user_id, '_pum_dismissed_alerts', true );
|
560 |
|
561 |
if ( ! is_array( $dismissed_alerts ) ) {
|
562 |
-
$dismissed_alerts =
|
563 |
update_user_meta( $user_id, '_pum_dismissed_alerts', $dismissed_alerts );
|
564 |
}
|
565 |
|
16 |
*
|
17 |
*/
|
18 |
public static function init() {
|
19 |
+
add_action( 'admin_init', [ __CLASS__, 'hooks' ] );
|
20 |
+
add_action( 'admin_init', [ __CLASS__, 'php_handler' ] );
|
21 |
+
add_action( 'wp_ajax_pum_alerts_action', [ __CLASS__, 'ajax_handler' ] );
|
22 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'whats_new_alerts' ], 0 );
|
23 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'integration_alerts' ], 5 );
|
24 |
+
add_filter( 'pum_alert_list', [ __CLASS__, 'translation_request' ], 10 );
|
25 |
+
add_action( 'admin_menu', [ __CLASS__, 'append_alert_count' ], 999 );
|
26 |
}
|
27 |
|
28 |
/**
|
52 |
*
|
53 |
* @return array
|
54 |
*/
|
55 |
+
public static function translation_request( $alerts = [] ) {
|
56 |
|
57 |
$version = explode( '.', Popup_Maker::$VER );
|
58 |
// Get only the major.minor version exclude the point releases.
|
120 |
$locales_supported_by_wordpress = PUM_Utils_I10n::available_locales();
|
121 |
|
122 |
// Get the native language names of the locales.
|
123 |
+
$suggest_translated_locale_names = [];
|
124 |
foreach ( $suggested_locales_with_langpack as $locale ) {
|
125 |
$suggest_translated_locale_names[ $locale ] = $locales_supported_by_wordpress[ $locale ]['native_name'];
|
126 |
}
|
139 |
$language = current( $suggest_translated_locale_names );
|
140 |
|
141 |
$suggest_string = sprintf( /* translators: %s: native language name. */
|
142 |
+
__( 'This plugin is also available in %1$s. <a href="%2$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
143 |
+
$language,
|
144 |
+
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/popup-maker' )
|
145 |
+
);
|
146 |
|
147 |
// Multiple locale suggestions.
|
148 |
} elseif ( ! empty( $suggest_translated_locale_names ) ) {
|
155 |
}
|
156 |
|
157 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: other native language names, comma separated */
|
158 |
+
__( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
159 |
+
$primary_language,
|
160 |
+
trim( $other_suggest, ' ,' ),
|
161 |
+
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/popup-maker' )
|
162 |
+
);
|
163 |
|
164 |
// Non-English locale in header, no translations.
|
165 |
} elseif ( ! empty( $non_en_locales_from_header ) ) {
|
168 |
$locale = reset( $non_en_locales_from_header );
|
169 |
|
170 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: URL to translate.wordpress.org */
|
171 |
+
__( 'This plugin is not translated into %1$s yet. <a href="%2$s" target="_blank">Help translate it!</a>', 'popup-maker' ),
|
172 |
+
$locales_supported_by_wordpress[ $locale ]['native_name'],
|
173 |
+
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/popup-maker' )
|
174 |
+
);
|
175 |
} else {
|
176 |
$primary_locale = reset( $non_en_locales_from_header );
|
177 |
$primary_language = $locales_supported_by_wordpress[ $primary_locale ]['native_name'];
|
183 |
}
|
184 |
|
185 |
$suggest_string = sprintf( /* translators: 1: native language name, 2: other native language names, comma separated */
|
186 |
+
__( 'This plugin is also available in %1$s (also: %2$s). <a href="%3$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
187 |
+
$primary_language,
|
188 |
+
trim( $other_suggest, ' ,' ),
|
189 |
+
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/popup-maker' )
|
190 |
+
);
|
191 |
}
|
192 |
}
|
193 |
|
197 |
// The plugin has translations for current locale, but they are out of date.
|
198 |
} elseif ( $current_locale_is_suggested && $current_locale_is_translated && version_compare( $locale_translation_versions[ $current_locale ], Popup_Maker::$VER, '<' ) ) {
|
199 |
$suggest_string = sprintf( /* translators: %s: native language name. */
|
200 |
+
__( 'This plugin\'s translation for %1$s is out of date. <a href="%2$s" target="_blank">Help improve the translation!</a>', 'popup-maker' ),
|
201 |
+
$locales_supported_by_wordpress[ $current_locale ]['native_name'],
|
202 |
+
esc_url( 'https://translate.wordpress.org/projects/wp-plugins/popup-maker' )
|
203 |
+
);
|
204 |
}
|
205 |
|
|
|
206 |
if ( ! empty( $suggest_string ) ) {
|
207 |
+
$alerts[] = [
|
208 |
'code' => $code,
|
209 |
'message' => $suggest_string,
|
210 |
'type' => 'info',
|
211 |
+
];
|
212 |
}
|
213 |
|
214 |
return $alerts;
|
219 |
*
|
220 |
* @return array
|
221 |
*/
|
222 |
+
public static function whats_new_alerts( $alerts = [] ) {
|
223 |
|
224 |
$upgraded_from = PUM_Utils_Upgrades::$upgraded_from;
|
225 |
|
226 |
if ( version_compare( $upgraded_from, '0.0.0', '>' ) ) {
|
227 |
|
228 |
if ( version_compare( $upgraded_from, '1.8.0', '<' ) ) {
|
229 |
+
$alerts[] = [
|
230 |
'code' => 'whats_new_1_8_0',
|
231 |
'type' => 'success',
|
232 |
+
'message' => sprintf(
|
233 |
+
'<strong>' . __( 'See whats new in v%1$s - (%2$sview all changes%3$s)', 'popup-maker' ) . '</strong>',
|
234 |
+
'1.8.0',
|
235 |
+
'<a href="' . add_query_arg(
|
236 |
+
[
|
237 |
+
'tab' => 'plugin-information',
|
238 |
+
'plugin' => 'popup-maker',
|
239 |
+
'section' => 'changelog',
|
240 |
+
'TB_iframe' => true,
|
241 |
+
'width' => 722,
|
242 |
+
'height' => 949,
|
243 |
+
],
|
244 |
+
admin_url( 'plugin-install.php' )
|
245 |
+
) . '" target="_blank">',
|
246 |
+
'</a>'
|
247 |
+
),
|
248 |
+
'html' => "<ul class='ul-disc'>" . '<li>' . 'New UX for the Popup Theme editor.' . '</li>' . '<li>' . 'New close button positions: top center, bottom center, middle left & middle right.' . '</li>' . '<li>' . 'New option to position close button outside of popup.' . '</li>' . '</ul>',
|
249 |
'priority' => 100,
|
250 |
+
];
|
251 |
}
|
|
|
252 |
}
|
253 |
|
254 |
return $alerts;
|
259 |
*
|
260 |
* @return array
|
261 |
*/
|
262 |
+
public static function integration_alerts( $alerts = [] ) {
|
263 |
|
264 |
+
$integrations = [
|
265 |
+
'buddypress' => [
|
266 |
'label' => __( 'BuddyPress', 'buddypress' ),
|
267 |
'learn_more_url' => 'https://wppopupmaker.com/works-with/buddypress/',
|
268 |
'conditions' => ! class_exists( 'PUM_BuddyPress' ) && ( function_exists( 'buddypress' ) || class_exists( 'BuddyPress' ) ),
|
269 |
'slug' => 'popup-maker-buddypress-integration',
|
270 |
'name' => 'Popup Maker - BuddyPress Integration',
|
271 |
'free' => true,
|
272 |
+
],
|
273 |
+
];
|
274 |
|
275 |
foreach ( $integrations as $key => $integration ) {
|
276 |
|
284 |
$text = $installed ? __( 'activate it now', 'popup-maker' ) : __( 'install it now', 'popup-maker' );
|
285 |
$url = $installed ? esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) : esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker-buddypress-integration' ), 'install-plugin_popup-maker-buddypress-integration' ) );
|
286 |
|
287 |
+
$alerts[] = [
|
288 |
'code' => $key . '_integration_available',
|
289 |
+
'message' => sprintf( __( '%1$sDid you know:%2$s Popup Maker has custom integrations with %3$s, %4$slearn more%5$s or %6$s%7$s%8$s!', 'popup-maker' ), '<strong>', '</strong>', $integration['label'], '<a href="' . $integration['learn_more_url'] . '" target="_blank">', '</a>', '<a href="' . $url . '">', $text, '</a>' ),
|
290 |
'dismissible' => true,
|
291 |
'global' => false,
|
292 |
'type' => $installed ? 'warning' : 'info',
|
293 |
+
];
|
294 |
|
295 |
}
|
|
|
296 |
}
|
297 |
|
298 |
return $alerts;
|
303 |
*/
|
304 |
public static function hooks() {
|
305 |
if ( is_admin() && current_user_can( 'edit_posts' ) ) {
|
306 |
+
add_action( 'admin_notices', [ __CLASS__, 'admin_notices' ] );
|
307 |
+
add_action( 'network_admin_notices', [ __CLASS__, 'admin_notices' ] );
|
308 |
+
add_action( 'user_admin_notices', [ __CLASS__, 'admin_notices' ] );
|
309 |
}
|
310 |
}
|
311 |
|
313 |
* @return bool
|
314 |
*/
|
315 |
public static function should_show_alerts() {
|
316 |
+
return in_array(
|
317 |
+
true,
|
318 |
+
[
|
319 |
+
pum_is_admin_page(),
|
320 |
+
count( self::get_global_alerts() ) > 0,
|
321 |
+
]
|
322 |
+
);
|
323 |
}
|
324 |
|
325 |
/**
|
347 |
?>
|
348 |
|
349 |
<script type="text/javascript">
|
350 |
+
window.pum_alerts_nonce = '<?php echo $nonce; ?>';
|
351 |
</script>
|
352 |
|
353 |
<div class="pum-alerts">
|
358 |
|
359 |
<p><?php __( 'Check out the following notifications from Popup Maker.', 'popup-maker' ); ?></p>
|
360 |
|
361 |
+
<?php
|
362 |
+
foreach ( $alerts as $alert ) {
|
363 |
+
$expires = 1 == $alert['dismissible'] ? '' : $alert['dismissible'];
|
364 |
+
$dismiss_url = add_query_arg(
|
365 |
+
[
|
366 |
+
'nonce' => $nonce,
|
367 |
+
'code' => $alert['code'],
|
368 |
+
'pum_dismiss_alert' => 'dismiss',
|
369 |
+
'expires' => $expires,
|
370 |
+
]
|
371 |
+
);
|
372 |
?>
|
373 |
|
374 |
<div class="pum-alert-holder" data-code="<?php echo $alert['code']; ?>" class="<?php echo $alert['dismissible'] ? 'is-dismissible' : ''; ?>" data-dismissible="<?php echo esc_attr( $alert['dismissible'] ); ?>">
|
392 |
$url = $action['href'];
|
393 |
$attributes = 'target="_blank" rel="noreferrer noopener"';
|
394 |
} else {
|
395 |
+
$url = add_query_arg(
|
396 |
+
[
|
397 |
+
'nonce' => $nonce,
|
398 |
+
'code' => $alert['code'],
|
399 |
+
'pum_dismiss_alert' => $action['action'],
|
400 |
+
'expires' => $expires,
|
401 |
+
]
|
402 |
+
);
|
403 |
|
404 |
$attributes = 'class="pum-dismiss"';
|
405 |
}
|
434 |
public static function get_global_alerts() {
|
435 |
$alerts = self::get_alerts();
|
436 |
|
437 |
+
$global_alerts = [];
|
438 |
|
439 |
foreach ( $alerts as $alert ) {
|
440 |
if ( $alert['global'] ) {
|
453 |
static $alert_list;
|
454 |
|
455 |
if ( ! isset( $alert_list ) ) {
|
456 |
+
$alert_list = apply_filters( 'pum_alert_list', [] );
|
457 |
}
|
458 |
|
459 |
+
$alerts = [];
|
460 |
|
461 |
foreach ( $alert_list as $alert ) {
|
462 |
|
465 |
continue;
|
466 |
}
|
467 |
|
468 |
+
$alerts[] = wp_parse_args(
|
469 |
+
$alert,
|
470 |
+
[
|
471 |
+
'code' => 'default',
|
472 |
+
'priority' => 10,
|
473 |
+
'message' => '',
|
474 |
+
'type' => 'info',
|
475 |
+
'html' => '',
|
476 |
+
'dismissible' => true,
|
477 |
+
'global' => false,
|
478 |
+
]
|
479 |
+
);
|
480 |
|
481 |
}
|
482 |
|
491 |
* Handles if alert was dismissed AJAX
|
492 |
*/
|
493 |
public static function ajax_handler() {
|
494 |
+
$args = wp_parse_args(
|
495 |
+
$_REQUEST,
|
496 |
+
[
|
497 |
+
'code' => '',
|
498 |
+
'expires' => '',
|
499 |
+
'pum_dismiss_alert' => '',
|
500 |
+
]
|
501 |
+
);
|
502 |
|
503 |
if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'pum_alerts_action' ) ) {
|
504 |
wp_send_json_error();
|
526 |
return;
|
527 |
}
|
528 |
|
529 |
+
$args = wp_parse_args(
|
530 |
+
$_REQUEST,
|
531 |
+
[
|
532 |
+
'code' => '',
|
533 |
+
'expires' => '',
|
534 |
+
'pum_dismiss_alert' => '',
|
535 |
+
]
|
536 |
+
);
|
537 |
|
538 |
self::action_handler( $args['code'], $args['pum_dismiss_alert'], $args['expires'] );
|
539 |
}
|
598 |
$dismissed_alerts = get_user_meta( $user_id, '_pum_dismissed_alerts', true );
|
599 |
|
600 |
if ( ! is_array( $dismissed_alerts ) ) {
|
601 |
+
$dismissed_alerts = [];
|
602 |
update_user_meta( $user_id, '_pum_dismissed_alerts', $dismissed_alerts );
|
603 |
}
|
604 |
|
classes/Utils/CSS.php
CHANGED
@@ -15,7 +15,7 @@ class PUM_Utils_CSS {
|
|
15 |
if ( is_array( $hex ) ) {
|
16 |
$hex = implode( '', $hex );
|
17 |
}
|
18 |
-
$hex = str_replace(
|
19 |
|
20 |
if ( strlen( $hex ) == 3 ) {
|
21 |
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
|
@@ -27,13 +27,13 @@ class PUM_Utils_CSS {
|
|
27 |
$b = hexdec( substr( $hex, 4, 2 ) );
|
28 |
}
|
29 |
|
30 |
-
$rgb =
|
31 |
|
32 |
if ( $return_type === 'array' ) {
|
33 |
return $rgb; // returns an array with the rgb values
|
34 |
}
|
35 |
|
36 |
-
return 'rgb(' . implode(
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -105,4 +105,4 @@ class PUM_Utils_CSS {
|
|
105 |
return str_replace( ' ', ' ', trim( "$style $variant $weight {$size}/{$line_height} \"$family\"" ) );
|
106 |
}
|
107 |
|
108 |
-
}
|
15 |
if ( is_array( $hex ) ) {
|
16 |
$hex = implode( '', $hex );
|
17 |
}
|
18 |
+
$hex = str_replace( '#', '', $hex );
|
19 |
|
20 |
if ( strlen( $hex ) == 3 ) {
|
21 |
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
|
27 |
$b = hexdec( substr( $hex, 4, 2 ) );
|
28 |
}
|
29 |
|
30 |
+
$rgb = [ $r, $g, $b ];
|
31 |
|
32 |
if ( $return_type === 'array' ) {
|
33 |
return $rgb; // returns an array with the rgb values
|
34 |
}
|
35 |
|
36 |
+
return 'rgb(' . implode( ',', $rgb ) . ')'; // returns the rgb values separated by commas
|
37 |
}
|
38 |
|
39 |
/**
|
105 |
return str_replace( ' ', ' ', trim( "$style $variant $weight {$size}/{$line_height} \"$family\"" ) );
|
106 |
}
|
107 |
|
108 |
+
}
|
classes/Utils/Config.php
CHANGED
@@ -26,7 +26,7 @@ class PUM_Utils_Config {
|
|
26 |
$file = plugin_dir_path( __DIR__ ) . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . $file_name . '.php';
|
27 |
|
28 |
if ( ! file_exists( $file ) ) {
|
29 |
-
return
|
30 |
}
|
31 |
|
32 |
return include $file;
|
26 |
$file = plugin_dir_path( __DIR__ ) . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . $file_name . '.php';
|
27 |
|
28 |
if ( ! file_exists( $file ) ) {
|
29 |
+
return [];
|
30 |
}
|
31 |
|
32 |
return include $file;
|
classes/Utils/Cron.php
CHANGED
@@ -18,8 +18,8 @@ class PUM_Utils_Cron {
|
|
18 |
* PUM_Utils_Cron constructor.
|
19 |
*/
|
20 |
public function __construct() {
|
21 |
-
add_filter( 'cron_schedules',
|
22 |
-
add_action( 'wp',
|
23 |
}
|
24 |
|
25 |
/**
|
@@ -29,12 +29,12 @@ class PUM_Utils_Cron {
|
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
32 |
-
public function add_schedules( $schedules =
|
33 |
// Adds once weekly to the existing schedules.
|
34 |
-
$schedules['weekly'] =
|
35 |
'interval' => 604800,
|
36 |
-
'display' => __( 'Once Weekly', 'popup-maker' )
|
37 |
-
|
38 |
|
39 |
return $schedules;
|
40 |
}
|
18 |
* PUM_Utils_Cron constructor.
|
19 |
*/
|
20 |
public function __construct() {
|
21 |
+
add_filter( 'cron_schedules', [ $this, 'add_schedules' ] );
|
22 |
+
add_action( 'wp', [ $this, 'schedule_events' ] );
|
23 |
}
|
24 |
|
25 |
/**
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
32 |
+
public function add_schedules( $schedules = [] ) {
|
33 |
// Adds once weekly to the existing schedules.
|
34 |
+
$schedules['weekly'] = [
|
35 |
'interval' => 604800,
|
36 |
+
'display' => __( 'Once Weekly', 'popup-maker' ),
|
37 |
+
];
|
38 |
|
39 |
return $schedules;
|
40 |
}
|
classes/Utils/DataStorage.php
CHANGED
@@ -17,7 +17,7 @@ class PUM_Utils_DataStorage {
|
|
17 |
*
|
18 |
* Given a key, get the information from the database directly.
|
19 |
*
|
20 |
-
* @param string
|
21 |
* @param null|mixed $default Optional. A default value to retrieve should `$value` be empty.
|
22 |
* Default null.
|
23 |
*
|
@@ -38,18 +38,18 @@ class PUM_Utils_DataStorage {
|
|
38 |
* Write some data based on key and value.
|
39 |
*
|
40 |
* @param string $key The option_name.
|
41 |
-
* @param mixed
|
42 |
*/
|
43 |
public static function write( $key, $value ) {
|
44 |
global $wpdb;
|
45 |
|
46 |
$value = maybe_serialize( $value );
|
47 |
|
48 |
-
$data =
|
49 |
'option_name' => $key,
|
50 |
'option_value' => $value,
|
51 |
'autoload' => 'no',
|
52 |
-
|
53 |
|
54 |
$formats = self::get_data_formats( $value );
|
55 |
|
@@ -67,16 +67,16 @@ class PUM_Utils_DataStorage {
|
|
67 |
|
68 |
switch ( gettype( $value ) ) {
|
69 |
case 'integer':
|
70 |
-
$formats =
|
71 |
break;
|
72 |
|
73 |
case 'double':
|
74 |
-
$formats =
|
75 |
break;
|
76 |
|
77 |
default:
|
78 |
case 'string':
|
79 |
-
$formats =
|
80 |
break;
|
81 |
}
|
82 |
|
@@ -93,7 +93,7 @@ class PUM_Utils_DataStorage {
|
|
93 |
public static function delete( $key ) {
|
94 |
global $wpdb;
|
95 |
|
96 |
-
return $wpdb->delete( $wpdb->options,
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -107,7 +107,7 @@ class PUM_Utils_DataStorage {
|
|
107 |
global $wpdb;
|
108 |
|
109 |
// Double check to make sure the batch_id got included before proceeding.
|
110 |
-
if (
|
111 |
$query = "DELETE FROM $wpdb->options WHERE option_name REGEXP %s";
|
112 |
|
113 |
$result = $wpdb->query( $wpdb->prepare( $query, $pattern ) );
|
17 |
*
|
18 |
* Given a key, get the information from the database directly.
|
19 |
*
|
20 |
+
* @param string $key The stored option key.
|
21 |
* @param null|mixed $default Optional. A default value to retrieve should `$value` be empty.
|
22 |
* Default null.
|
23 |
*
|
38 |
* Write some data based on key and value.
|
39 |
*
|
40 |
* @param string $key The option_name.
|
41 |
+
* @param mixed $value The value to store.
|
42 |
*/
|
43 |
public static function write( $key, $value ) {
|
44 |
global $wpdb;
|
45 |
|
46 |
$value = maybe_serialize( $value );
|
47 |
|
48 |
+
$data = [
|
49 |
'option_name' => $key,
|
50 |
'option_value' => $value,
|
51 |
'autoload' => 'no',
|
52 |
+
];
|
53 |
|
54 |
$formats = self::get_data_formats( $value );
|
55 |
|
67 |
|
68 |
switch ( gettype( $value ) ) {
|
69 |
case 'integer':
|
70 |
+
$formats = [ '%s', '%d', '%s' ];
|
71 |
break;
|
72 |
|
73 |
case 'double':
|
74 |
+
$formats = [ '%s', '%f', '%s' ];
|
75 |
break;
|
76 |
|
77 |
default:
|
78 |
case 'string':
|
79 |
+
$formats = [ '%s', '%s', '%s' ];
|
80 |
break;
|
81 |
}
|
82 |
|
93 |
public static function delete( $key ) {
|
94 |
global $wpdb;
|
95 |
|
96 |
+
return $wpdb->delete( $wpdb->options, [ 'option_name' => $key ] );
|
97 |
}
|
98 |
|
99 |
/**
|
107 |
global $wpdb;
|
108 |
|
109 |
// Double check to make sure the batch_id got included before proceeding.
|
110 |
+
if ( '^[0-9a-z\\_]+' !== $pattern && ! empty( $pattern ) ) {
|
111 |
$query = "DELETE FROM $wpdb->options WHERE option_name REGEXP %s";
|
112 |
|
113 |
$result = $wpdb->query( $wpdb->prepare( $query, $pattern ) );
|
classes/Utils/Fields.php
CHANGED
@@ -29,7 +29,7 @@ class PUM_Utils_Fields {
|
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
32 |
-
public static function get_form_default_values( $fields =
|
33 |
$fields = static::flatten_fields_array( $fields );
|
34 |
|
35 |
return static::get_field_default_values( $fields );
|
@@ -40,11 +40,11 @@ class PUM_Utils_Fields {
|
|
40 |
*
|
41 |
* @return array
|
42 |
*/
|
43 |
-
public static function get_field_default_values( $fields =
|
44 |
-
$defaults =
|
45 |
|
46 |
foreach ( $fields as $field_id => $field ) {
|
47 |
-
switch( $field['type'] ) {
|
48 |
case 'checkbox':
|
49 |
$defaults[ $field_id ] = ! empty( $field['std'] ) ? $field['std'] : false;
|
50 |
break;
|
@@ -62,7 +62,7 @@ class PUM_Utils_Fields {
|
|
62 |
* @return array
|
63 |
*/
|
64 |
public static function flatten_fields_array( $tabs ) {
|
65 |
-
$fields =
|
66 |
|
67 |
foreach ( $tabs as $tab_id => $tab_sections ) {
|
68 |
|
@@ -94,67 +94,73 @@ class PUM_Utils_Fields {
|
|
94 |
* @return array
|
95 |
*/
|
96 |
public static function parse_field( $field ) {
|
97 |
-
return wp_parse_args(
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
'
|
132 |
-
'
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
145 |
}
|
146 |
|
147 |
/**
|
148 |
* @param $fields
|
149 |
-
* @param array
|
150 |
*
|
151 |
* @return mixed
|
152 |
*/
|
153 |
-
public static function parse_tab_fields( $fields, $args =
|
154 |
-
$args = wp_parse_args(
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
158 |
|
159 |
if ( $args['has_sections'] ) {
|
160 |
foreach ( $fields as $tab_id => $tab_sections ) {
|
@@ -162,14 +168,13 @@ class PUM_Utils_Fields {
|
|
162 |
if ( self::is_field( $section_fields ) ) {
|
163 |
// Allow for flat tabs with no sections.
|
164 |
$section_id = 'main';
|
165 |
-
$section_fields =
|
166 |
$section_id => $section_fields,
|
167 |
-
|
168 |
}
|
169 |
|
170 |
$fields[ $tab_id ][ $section_id ] = self::parse_fields( $section_fields, $args['name'] );
|
171 |
}
|
172 |
-
|
173 |
}
|
174 |
} else {
|
175 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
@@ -225,11 +230,11 @@ class PUM_Utils_Fields {
|
|
225 |
*
|
226 |
* @return bool
|
227 |
*/
|
228 |
-
public static function is_field( $array =
|
229 |
-
$field_tests =
|
230 |
! isset( $array['type'] ) && ( isset( $array['label'] ) || isset( $array['desc'] ) ),
|
231 |
isset( $array['type'] ) && is_string( $array['type'] ),
|
232 |
-
|
233 |
|
234 |
return in_array( true, $field_tests );
|
235 |
}
|
@@ -241,14 +246,14 @@ class PUM_Utils_Fields {
|
|
241 |
*
|
242 |
* @return bool
|
243 |
*/
|
244 |
-
public static function is_section( $array =
|
245 |
return ! self::is_field( $array );
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
* @param array $args
|
250 |
*/
|
251 |
-
public static function render_field( $args =
|
252 |
$args = static::parse_field( $args );
|
253 |
|
254 |
// If no type default to text.
|
@@ -264,8 +269,8 @@ class PUM_Utils_Fields {
|
|
264 |
/**
|
265 |
* Check if renderer method exists and load that.
|
266 |
*/
|
267 |
-
$function_name =
|
268 |
-
}
|
269 |
/**
|
270 |
* Check if function exists and load that.
|
271 |
*/
|
@@ -274,13 +279,13 @@ class PUM_Utils_Fields {
|
|
274 |
/**
|
275 |
* No method exists, lets notify them the field type doesn't exist.
|
276 |
*/
|
277 |
-
$function_name =
|
278 |
}
|
279 |
|
280 |
/**
|
281 |
* Call the determined method, passing the field args & $value to the callback.
|
282 |
*/
|
283 |
-
call_user_func_array( $function_name,
|
284 |
}
|
285 |
}
|
286 |
|
@@ -325,7 +330,7 @@ class PUM_Utils_Fields {
|
|
325 |
*
|
326 |
* @return mixed
|
327 |
*/
|
328 |
-
public static function sanitize_fields( $values, $fields =
|
329 |
|
330 |
foreach ( $values as $key => $value ) {
|
331 |
if ( is_string( $value ) ) {
|
@@ -350,7 +355,7 @@ class PUM_Utils_Fields {
|
|
350 |
*
|
351 |
* @return mixed|null
|
352 |
*/
|
353 |
-
public static function sanitize_field( $args, $value = null, $fields =
|
354 |
|
355 |
// If no type default to text.
|
356 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
@@ -369,18 +374,17 @@ class PUM_Utils_Fields {
|
|
369 |
} /**
|
370 |
* Check if core method exists and load that.
|
371 |
*/ elseif ( method_exists( 'PUM_Utils_Sanitize', $type ) ) {
|
372 |
-
$function_name =
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
if ( $function_name ) {
|
378 |
-
/**
|
379 |
-
* Call the determined method, passing the field args & $value to the callback.
|
380 |
-
*/
|
381 |
-
$value = call_user_func_array( $function_name, array( $value, $args, $fields, $values ) );
|
382 |
-
}
|
383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
}
|
385 |
|
386 |
$value = apply_filters( 'pum_settings_sanitize', $value, $args, $fields, $values );
|
29 |
*
|
30 |
* @return array
|
31 |
*/
|
32 |
+
public static function get_form_default_values( $fields = [] ) {
|
33 |
$fields = static::flatten_fields_array( $fields );
|
34 |
|
35 |
return static::get_field_default_values( $fields );
|
40 |
*
|
41 |
* @return array
|
42 |
*/
|
43 |
+
public static function get_field_default_values( $fields = [] ) {
|
44 |
+
$defaults = [];
|
45 |
|
46 |
foreach ( $fields as $field_id => $field ) {
|
47 |
+
switch ( $field['type'] ) {
|
48 |
case 'checkbox':
|
49 |
$defaults[ $field_id ] = ! empty( $field['std'] ) ? $field['std'] : false;
|
50 |
break;
|
62 |
* @return array
|
63 |
*/
|
64 |
public static function flatten_fields_array( $tabs ) {
|
65 |
+
$fields = [];
|
66 |
|
67 |
foreach ( $tabs as $tab_id => $tab_sections ) {
|
68 |
|
94 |
* @return array
|
95 |
*/
|
96 |
public static function parse_field( $field ) {
|
97 |
+
return wp_parse_args(
|
98 |
+
$field,
|
99 |
+
[
|
100 |
+
'section' => 'main',
|
101 |
+
'type' => 'text',
|
102 |
+
'id' => null,
|
103 |
+
'label' => '',
|
104 |
+
'desc' => '',
|
105 |
+
'name' => null,
|
106 |
+
'templ_name' => null,
|
107 |
+
'size' => 'regular',
|
108 |
+
'options' => [],
|
109 |
+
'std' => null,
|
110 |
+
'rows' => 5,
|
111 |
+
'cols' => 50,
|
112 |
+
'min' => 0,
|
113 |
+
'max' => 50,
|
114 |
+
'force_minmax' => false,
|
115 |
+
'step' => 1,
|
116 |
+
'select2' => null,
|
117 |
+
'object_type' => 'post_type',
|
118 |
+
'object_key' => 'post',
|
119 |
+
'post_type' => null,
|
120 |
+
'taxonomy' => null,
|
121 |
+
'multiple' => null,
|
122 |
+
'as_array' => false,
|
123 |
+
'placeholder' => null,
|
124 |
+
'checkbox_val' => 1,
|
125 |
+
'allow_blank' => true,
|
126 |
+
'readonly' => false,
|
127 |
+
'required' => false,
|
128 |
+
'disabled' => false,
|
129 |
+
'hook' => null,
|
130 |
+
'unit' => __( 'ms', 'popup-maker' ),
|
131 |
+
'desc_position' => 'bottom',
|
132 |
+
'units' => [
|
133 |
+
'px' => 'px',
|
134 |
+
'%' => '%',
|
135 |
+
'em' => 'em',
|
136 |
+
'rem' => 'rem',
|
137 |
+
],
|
138 |
+
'priority' => 10,
|
139 |
+
'doclink' => '',
|
140 |
+
'button_type' => 'submit',
|
141 |
+
'class' => '',
|
142 |
+
'messages' => [],
|
143 |
+
'license_status' => '',
|
144 |
+
'value' => null,
|
145 |
+
'private' => false,
|
146 |
+
]
|
147 |
+
);
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
* @param $fields
|
152 |
+
* @param array $args
|
153 |
*
|
154 |
* @return mixed
|
155 |
*/
|
156 |
+
public static function parse_tab_fields( $fields, $args = [] ) {
|
157 |
+
$args = wp_parse_args(
|
158 |
+
$args,
|
159 |
+
[
|
160 |
+
'has_sections' => false,
|
161 |
+
'name' => '%s',
|
162 |
+
]
|
163 |
+
);
|
164 |
|
165 |
if ( $args['has_sections'] ) {
|
166 |
foreach ( $fields as $tab_id => $tab_sections ) {
|
168 |
if ( self::is_field( $section_fields ) ) {
|
169 |
// Allow for flat tabs with no sections.
|
170 |
$section_id = 'main';
|
171 |
+
$section_fields = [
|
172 |
$section_id => $section_fields,
|
173 |
+
];
|
174 |
}
|
175 |
|
176 |
$fields[ $tab_id ][ $section_id ] = self::parse_fields( $section_fields, $args['name'] );
|
177 |
}
|
|
|
178 |
}
|
179 |
} else {
|
180 |
foreach ( $fields as $tab_id => $tab_fields ) {
|
230 |
*
|
231 |
* @return bool
|
232 |
*/
|
233 |
+
public static function is_field( $array = [] ) {
|
234 |
+
$field_tests = [
|
235 |
! isset( $array['type'] ) && ( isset( $array['label'] ) || isset( $array['desc'] ) ),
|
236 |
isset( $array['type'] ) && is_string( $array['type'] ),
|
237 |
+
];
|
238 |
|
239 |
return in_array( true, $field_tests );
|
240 |
}
|
246 |
*
|
247 |
* @return bool
|
248 |
*/
|
249 |
+
public static function is_section( $array = [] ) {
|
250 |
return ! self::is_field( $array );
|
251 |
}
|
252 |
|
253 |
/**
|
254 |
* @param array $args
|
255 |
*/
|
256 |
+
public static function render_field( $args = [] ) {
|
257 |
$args = static::parse_field( $args );
|
258 |
|
259 |
// If no type default to text.
|
269 |
/**
|
270 |
* Check if renderer method exists and load that.
|
271 |
*/
|
272 |
+
$function_name = [ 'PUM_Form_Fields', $type . '_callback' ];
|
273 |
+
} elseif ( function_exists( "pum_{$type}_callback" ) ) {
|
274 |
/**
|
275 |
* Check if function exists and load that.
|
276 |
*/
|
279 |
/**
|
280 |
* No method exists, lets notify them the field type doesn't exist.
|
281 |
*/
|
282 |
+
$function_name = [ 'PUM_Form_Fields', 'missing_callback' ];
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
* Call the determined method, passing the field args & $value to the callback.
|
287 |
*/
|
288 |
+
call_user_func_array( $function_name, [ $args ] );
|
289 |
}
|
290 |
}
|
291 |
|
330 |
*
|
331 |
* @return mixed
|
332 |
*/
|
333 |
+
public static function sanitize_fields( $values, $fields = [] ) {
|
334 |
|
335 |
foreach ( $values as $key => $value ) {
|
336 |
if ( is_string( $value ) ) {
|
355 |
*
|
356 |
* @return mixed|null
|
357 |
*/
|
358 |
+
public static function sanitize_field( $args, $value = null, $fields = [], $values = [] ) {
|
359 |
|
360 |
// If no type default to text.
|
361 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
374 |
} /**
|
375 |
* Check if core method exists and load that.
|
376 |
*/ elseif ( method_exists( 'PUM_Utils_Sanitize', $type ) ) {
|
377 |
+
$function_name = [ 'PUM_Utils_Sanitize', $type ];
|
378 |
+
} else {
|
379 |
+
$function_name = null;
|
380 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
|
382 |
+
if ( $function_name ) {
|
383 |
+
/**
|
384 |
+
* Call the determined method, passing the field args & $value to the callback.
|
385 |
+
*/
|
386 |
+
$value = call_user_func_array( $function_name, [ $value, $args, $fields, $values ] );
|
387 |
+
}
|
388 |
}
|
389 |
|
390 |
$value = apply_filters( 'pum_settings_sanitize', $value, $args, $fields, $values );
|
classes/Utils/Format.php
CHANGED
@@ -20,8 +20,8 @@ class PUM_Utils_Format {
|
|
20 |
* @return mixed|string
|
21 |
*/
|
22 |
public static function unwrap_urls( $content = '' ) {
|
23 |
-
$content = preg_replace(
|
24 |
-
$content = str_replace(
|
25 |
|
26 |
return $content;
|
27 |
}
|
@@ -85,7 +85,7 @@ class PUM_Utils_Format {
|
|
85 |
|
86 |
if ( $diff < 60 ) {
|
87 |
$since = sprintf( __( '%ss', 'popup-maker' ), $diff );
|
88 |
-
}
|
89 |
$mins = round( $diff / MINUTE_IN_SECONDS );
|
90 |
if ( $mins <= 1 ) {
|
91 |
$mins = 1;
|
@@ -150,7 +150,7 @@ class PUM_Utils_Format {
|
|
150 |
* @return mixed
|
151 |
*/
|
152 |
public static function strip_white_space( $string = '' ) {
|
153 |
-
return str_replace(
|
154 |
}
|
155 |
|
156 |
}
|
20 |
* @return mixed|string
|
21 |
*/
|
22 |
public static function unwrap_urls( $content = '' ) {
|
23 |
+
$content = preg_replace( '/<\\w+>((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[.\\!\\/\\\\w]*))?)<\\/\\w+>/', "$1\n\n", $content );
|
24 |
+
$content = str_replace( '</p>', "</p>\n\n", $content );
|
25 |
|
26 |
return $content;
|
27 |
}
|
85 |
|
86 |
if ( $diff < 60 ) {
|
87 |
$since = sprintf( __( '%ss', 'popup-maker' ), $diff );
|
88 |
+
} elseif ( $diff < HOUR_IN_SECONDS ) {
|
89 |
$mins = round( $diff / MINUTE_IN_SECONDS );
|
90 |
if ( $mins <= 1 ) {
|
91 |
$mins = 1;
|
150 |
* @return mixed
|
151 |
*/
|
152 |
public static function strip_white_space( $string = '' ) {
|
153 |
+
return str_replace( [ "\t", "\r", "\n" ], '', $string );
|
154 |
}
|
155 |
|
156 |
}
|
classes/Utils/I10n.php
CHANGED
@@ -29,7 +29,7 @@ class PUM_Utils_I10n {
|
|
29 |
set_transient( 'pum_alerts_translation_status', $translations, 604800 );
|
30 |
}
|
31 |
|
32 |
-
$ret =
|
33 |
|
34 |
foreach ( $translations as $translation ) {
|
35 |
$ret[ $translation['language'] ] = $translation;
|
@@ -45,7 +45,7 @@ class PUM_Utils_I10n {
|
|
45 |
* @return array List of locales.
|
46 |
*/
|
47 |
public static function get_non_en_accepted_wp_locales_from_header() {
|
48 |
-
$res =
|
49 |
|
50 |
$http_locales = self::get_http_locales();
|
51 |
|
@@ -96,7 +96,7 @@ class PUM_Utils_I10n {
|
|
96 |
|
97 |
if ( ! isset( $available_locales ) ) {
|
98 |
if ( ! function_exists( 'wp_get_available_translations' ) ) {
|
99 |
-
require_once
|
100 |
}
|
101 |
|
102 |
$available_locales = wp_get_available_translations();
|
@@ -116,14 +116,14 @@ class PUM_Utils_I10n {
|
|
116 |
public static function map_locale( $lang, $region ) {
|
117 |
$uregion = strtoupper( $region );
|
118 |
$ulang = strtoupper( $lang );
|
119 |
-
$variants =
|
120 |
"$lang-$region",
|
121 |
"{$lang}_$region",
|
122 |
"$lang-$uregion",
|
123 |
"{$lang}_$uregion",
|
124 |
"{$lang}_$ulang",
|
125 |
$lang,
|
126 |
-
|
127 |
|
128 |
$available_locales = self::available_locales();
|
129 |
|
@@ -158,7 +158,7 @@ class PUM_Utils_I10n {
|
|
158 |
if ( preg_match_all( "/$locale_re/i", isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '', $matches ) ) {
|
159 |
return $matches[0];
|
160 |
} else {
|
161 |
-
return
|
162 |
}
|
163 |
}
|
164 |
|
29 |
set_transient( 'pum_alerts_translation_status', $translations, 604800 );
|
30 |
}
|
31 |
|
32 |
+
$ret = [];
|
33 |
|
34 |
foreach ( $translations as $translation ) {
|
35 |
$ret[ $translation['language'] ] = $translation;
|
45 |
* @return array List of locales.
|
46 |
*/
|
47 |
public static function get_non_en_accepted_wp_locales_from_header() {
|
48 |
+
$res = [];
|
49 |
|
50 |
$http_locales = self::get_http_locales();
|
51 |
|
96 |
|
97 |
if ( ! isset( $available_locales ) ) {
|
98 |
if ( ! function_exists( 'wp_get_available_translations' ) ) {
|
99 |
+
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
100 |
}
|
101 |
|
102 |
$available_locales = wp_get_available_translations();
|
116 |
public static function map_locale( $lang, $region ) {
|
117 |
$uregion = strtoupper( $region );
|
118 |
$ulang = strtoupper( $lang );
|
119 |
+
$variants = [
|
120 |
"$lang-$region",
|
121 |
"{$lang}_$region",
|
122 |
"$lang-$uregion",
|
123 |
"{$lang}_$uregion",
|
124 |
"{$lang}_$ulang",
|
125 |
$lang,
|
126 |
+
];
|
127 |
|
128 |
$available_locales = self::available_locales();
|
129 |
|
158 |
if ( preg_match_all( "/$locale_re/i", isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '', $matches ) ) {
|
159 |
return $matches[0];
|
160 |
} else {
|
161 |
+
return [];
|
162 |
}
|
163 |
}
|
164 |
|
classes/Utils/Logging.php
CHANGED
@@ -191,7 +191,7 @@ class PUM_Utils_Logging {
|
|
191 |
public function truncate_log() {
|
192 |
$content = $this->get_file();
|
193 |
$lines = explode( "\r\n", $content );
|
194 |
-
$lines = array_slice( $lines, 0, 250 ); //50 is how many lines you want to keep
|
195 |
$this->content = implode( "\r\n", $lines );
|
196 |
$this->save_logs();
|
197 |
}
|
@@ -206,7 +206,7 @@ class PUM_Utils_Logging {
|
|
206 |
/**
|
207 |
* @param $function
|
208 |
* @param $version
|
209 |
-
* @param null
|
210 |
*/
|
211 |
public function log_deprecated_notice( $function, $version, $replacement = null ) {
|
212 |
if ( ! is_null( $replacement ) ) {
|
191 |
public function truncate_log() {
|
192 |
$content = $this->get_file();
|
193 |
$lines = explode( "\r\n", $content );
|
194 |
+
$lines = array_slice( $lines, 0, 250 ); // 50 is how many lines you want to keep
|
195 |
$this->content = implode( "\r\n", $lines );
|
196 |
$this->save_logs();
|
197 |
}
|
206 |
/**
|
207 |
* @param $function
|
208 |
* @param $version
|
209 |
+
* @param null $replacement
|
210 |
*/
|
211 |
public function log_deprecated_notice( $function, $version, $replacement = null ) {
|
212 |
if ( ! is_null( $replacement ) ) {
|
classes/Utils/Options.php
CHANGED
@@ -50,9 +50,9 @@ class PUM_Utils_Options {
|
|
50 |
* @return array settings
|
51 |
*/
|
52 |
public static function get_all() {
|
53 |
-
$settings = get_option( self::$_prefix . 'settings',
|
54 |
if ( ! is_array( $settings ) ) {
|
55 |
-
$settings =
|
56 |
}
|
57 |
|
58 |
/* @deprecated filter. */
|
@@ -133,7 +133,7 @@ class PUM_Utils_Options {
|
|
133 |
*
|
134 |
* @return bool
|
135 |
*/
|
136 |
-
public static function update_all( $new_options =
|
137 |
// First let's grab the current settings
|
138 |
$options = get_option( self::$_prefix . 'settings' );
|
139 |
|
@@ -157,7 +157,7 @@ class PUM_Utils_Options {
|
|
157 |
*
|
158 |
* @return bool
|
159 |
*/
|
160 |
-
public static function merge( $new_options =
|
161 |
|
162 |
$options = self::get_all();
|
163 |
|
@@ -192,8 +192,8 @@ class PUM_Utils_Options {
|
|
192 |
// If no key, exit
|
193 |
if ( empty( $keys ) ) {
|
194 |
return false;
|
195 |
-
}
|
196 |
-
$keys =
|
197 |
}
|
198 |
|
199 |
// First let's grab the current settings
|
@@ -223,7 +223,7 @@ class PUM_Utils_Options {
|
|
223 |
*
|
224 |
* @return bool
|
225 |
*/
|
226 |
-
public static function remap_keys( $remap_array =
|
227 |
$options = self::get_all();
|
228 |
|
229 |
foreach ( $remap_array as $key => $new_key ) {
|
50 |
* @return array settings
|
51 |
*/
|
52 |
public static function get_all() {
|
53 |
+
$settings = get_option( self::$_prefix . 'settings', [] );
|
54 |
if ( ! is_array( $settings ) ) {
|
55 |
+
$settings = [];
|
56 |
}
|
57 |
|
58 |
/* @deprecated filter. */
|
133 |
*
|
134 |
* @return bool
|
135 |
*/
|
136 |
+
public static function update_all( $new_options = [] ) {
|
137 |
// First let's grab the current settings
|
138 |
$options = get_option( self::$_prefix . 'settings' );
|
139 |
|
157 |
*
|
158 |
* @return bool
|
159 |
*/
|
160 |
+
public static function merge( $new_options = [] ) {
|
161 |
|
162 |
$options = self::get_all();
|
163 |
|
192 |
// If no key, exit
|
193 |
if ( empty( $keys ) ) {
|
194 |
return false;
|
195 |
+
} elseif ( is_string( $keys ) ) {
|
196 |
+
$keys = [ $keys ];
|
197 |
}
|
198 |
|
199 |
// First let's grab the current settings
|
223 |
*
|
224 |
* @return bool
|
225 |
*/
|
226 |
+
public static function remap_keys( $remap_array = [] ) {
|
227 |
$options = self::get_all();
|
228 |
|
229 |
foreach ( $remap_array as $key => $new_key ) {
|
classes/Utils/Prerequisites.php
CHANGED
@@ -230,10 +230,14 @@ class PUM_Utils_Prerequisites {
|
|
230 |
*/
|
231 |
private function get_plugin_data( $slug, $header = null ) {
|
232 |
if ( ! isset( static::$cache['get_plugin_data'][ $slug ] ) ) {
|
233 |
-
$headers = \get_file_data(
|
234 |
-
'
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
237 |
|
238 |
static::$cache['get_plugin_data'][ $slug ] = $headers;
|
239 |
}
|
230 |
*/
|
231 |
private function get_plugin_data( $slug, $header = null ) {
|
232 |
if ( ! isset( static::$cache['get_plugin_data'][ $slug ] ) ) {
|
233 |
+
$headers = \get_file_data(
|
234 |
+
WP_PLUGIN_DIR . '/' . $slug,
|
235 |
+
[
|
236 |
+
'Name' => 'Plugin Name',
|
237 |
+
'Version' => 'Version',
|
238 |
+
],
|
239 |
+
'plugin'
|
240 |
+
);
|
241 |
|
242 |
static::$cache['get_plugin_data'][ $slug ] = $headers;
|
243 |
}
|
classes/Utils/Sanitize.php
CHANGED
@@ -18,7 +18,7 @@ class PUM_Utils_Sanitize {
|
|
18 |
*
|
19 |
* @return string
|
20 |
*/
|
21 |
-
public static function text( $value = '', $args =
|
22 |
return sanitize_text_field( $value );
|
23 |
}
|
24 |
|
@@ -28,7 +28,7 @@ class PUM_Utils_Sanitize {
|
|
28 |
*
|
29 |
* @return bool|int
|
30 |
*/
|
31 |
-
public static function checkbox( $value = null, $args =
|
32 |
if ( intval( $value ) == 1 ) {
|
33 |
return 1;
|
34 |
}
|
@@ -36,7 +36,7 @@ class PUM_Utils_Sanitize {
|
|
36 |
return 0;
|
37 |
}
|
38 |
|
39 |
-
public static function measure( $value = '', $args =
|
40 |
if ( isset( $values[ $args['id'] . '_unit' ] ) ) {
|
41 |
$value .= $values[ $args['id'] . '_unit' ];
|
42 |
}
|
@@ -44,4 +44,4 @@ class PUM_Utils_Sanitize {
|
|
44 |
return sanitize_text_field( $value );
|
45 |
}
|
46 |
|
47 |
-
}
|
18 |
*
|
19 |
* @return string
|
20 |
*/
|
21 |
+
public static function text( $value = '', $args = [] ) {
|
22 |
return sanitize_text_field( $value );
|
23 |
}
|
24 |
|
28 |
*
|
29 |
* @return bool|int
|
30 |
*/
|
31 |
+
public static function checkbox( $value = null, $args = [] ) {
|
32 |
if ( intval( $value ) == 1 ) {
|
33 |
return 1;
|
34 |
}
|
36 |
return 0;
|
37 |
}
|
38 |
|
39 |
+
public static function measure( $value = '', $args = [], $fields = [], $values = [] ) {
|
40 |
if ( isset( $values[ $args['id'] . '_unit' ] ) ) {
|
41 |
$value .= $values[ $args['id'] . '_unit' ];
|
42 |
}
|
44 |
return sanitize_text_field( $value );
|
45 |
}
|
46 |
|
47 |
+
}
|
classes/Utils/Template.php
CHANGED
@@ -20,13 +20,16 @@ class PUM_Utils_Template {
|
|
20 |
|
21 |
$old_template_dir = apply_filters( 'popmake_templates_dir', 'popmake_templates' );
|
22 |
|
23 |
-
$file_paths = apply_filters(
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
/* @deprecated 1.8.9 */
|
32 |
$file_paths = apply_filters( 'popmake_template_paths', $file_paths );
|
@@ -55,7 +58,6 @@ class PUM_Utils_Template {
|
|
55 |
* @return string
|
56 |
* @internal param string $template_path (default: '')
|
57 |
* @internal param string $default_path (default: '')
|
58 |
-
*
|
59 |
*/
|
60 |
public static function locate( $template_names, $load = false, $require_once = true ) {
|
61 |
// No file found yet
|
@@ -110,7 +112,7 @@ class PUM_Utils_Template {
|
|
110 |
* @return string
|
111 |
*/
|
112 |
public static function locate_part( $slug, $name = null, $load = false ) {
|
113 |
-
$templates =
|
114 |
if ( $name ) {
|
115 |
// slug-name.php
|
116 |
$templates[] = "{$slug}-{$name}.php";
|
@@ -133,9 +135,9 @@ class PUM_Utils_Template {
|
|
133 |
* Render file with extracted arguments.
|
134 |
*
|
135 |
* @param $template
|
136 |
-
* @param array
|
137 |
*/
|
138 |
-
public static function render( $template, $args =
|
139 |
|
140 |
if ( ! $template || ! file_exists( $template ) ) {
|
141 |
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $template ), '1.0.0' );
|
@@ -159,7 +161,7 @@ class PUM_Utils_Template {
|
|
159 |
* @param string $name
|
160 |
* @param array $args
|
161 |
*/
|
162 |
-
public static function part( $slug, $name = null, $args =
|
163 |
echo self::get_part( $slug, $name, $args );
|
164 |
}
|
165 |
|
@@ -174,7 +176,7 @@ class PUM_Utils_Template {
|
|
174 |
*
|
175 |
* @return string
|
176 |
*/
|
177 |
-
public static function get_part( $slug, $name = null, $args =
|
178 |
|
179 |
$template = self::locate_part( $slug, $name );
|
180 |
|
@@ -196,11 +198,11 @@ class PUM_Utils_Template {
|
|
196 |
* Gets the rendered contents of the specified template file.
|
197 |
*
|
198 |
* @param $template_name
|
199 |
-
* @param array
|
200 |
*
|
201 |
* @return string
|
202 |
*/
|
203 |
-
public static function get( $template_name, $args =
|
204 |
$template = self::locate( $template_name );
|
205 |
|
206 |
// Allow 3rd party plugin filter template file from their plugin.
|
@@ -225,7 +227,7 @@ class PUM_Utils_Template {
|
|
225 |
* @param string $template_name Template file name with extension: file-name.php
|
226 |
* @param array $args (default: array())
|
227 |
*/
|
228 |
-
public static function load( $template_name, $args =
|
229 |
echo self::get( $template_name, $args );
|
230 |
}
|
231 |
|
20 |
|
21 |
$old_template_dir = apply_filters( 'popmake_templates_dir', 'popmake_templates' );
|
22 |
|
23 |
+
$file_paths = apply_filters(
|
24 |
+
'pum_template_paths',
|
25 |
+
[
|
26 |
+
1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
|
27 |
+
2 => trailingslashit( get_stylesheet_directory() ) . $old_template_dir,
|
28 |
+
10 => trailingslashit( get_template_directory() ) . $template_dir,
|
29 |
+
11 => trailingslashit( get_template_directory() ) . $old_template_dir,
|
30 |
+
100 => Popup_Maker::$DIR . 'templates',
|
31 |
+
]
|
32 |
+
);
|
33 |
|
34 |
/* @deprecated 1.8.9 */
|
35 |
$file_paths = apply_filters( 'popmake_template_paths', $file_paths );
|
58 |
* @return string
|
59 |
* @internal param string $template_path (default: '')
|
60 |
* @internal param string $default_path (default: '')
|
|
|
61 |
*/
|
62 |
public static function locate( $template_names, $load = false, $require_once = true ) {
|
63 |
// No file found yet
|
112 |
* @return string
|
113 |
*/
|
114 |
public static function locate_part( $slug, $name = null, $load = false ) {
|
115 |
+
$templates = [];
|
116 |
if ( $name ) {
|
117 |
// slug-name.php
|
118 |
$templates[] = "{$slug}-{$name}.php";
|
135 |
* Render file with extracted arguments.
|
136 |
*
|
137 |
* @param $template
|
138 |
+
* @param array $args
|
139 |
*/
|
140 |
+
public static function render( $template, $args = [] ) {
|
141 |
|
142 |
if ( ! $template || ! file_exists( $template ) ) {
|
143 |
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $template ), '1.0.0' );
|
161 |
* @param string $name
|
162 |
* @param array $args
|
163 |
*/
|
164 |
+
public static function part( $slug, $name = null, $args = [] ) {
|
165 |
echo self::get_part( $slug, $name, $args );
|
166 |
}
|
167 |
|
176 |
*
|
177 |
* @return string
|
178 |
*/
|
179 |
+
public static function get_part( $slug, $name = null, $args = [] ) {
|
180 |
|
181 |
$template = self::locate_part( $slug, $name );
|
182 |
|
198 |
* Gets the rendered contents of the specified template file.
|
199 |
*
|
200 |
* @param $template_name
|
201 |
+
* @param array $args
|
202 |
*
|
203 |
* @return string
|
204 |
*/
|
205 |
+
public static function get( $template_name, $args = [] ) {
|
206 |
$template = self::locate( $template_name );
|
207 |
|
208 |
// Allow 3rd party plugin filter template file from their plugin.
|
227 |
* @param string $template_name Template file name with extension: file-name.php
|
228 |
* @param array $args (default: array())
|
229 |
*/
|
230 |
+
public static function load( $template_name, $args = [] ) {
|
231 |
echo self::get( $template_name, $args );
|
232 |
}
|
233 |
|
classes/Utils/Upgrades.php
CHANGED
@@ -78,15 +78,15 @@ class PUM_Utils_Upgrades {
|
|
78 |
self::update_plugin_version();
|
79 |
|
80 |
// Render upgrade admin notices.
|
81 |
-
add_filter( 'pum_alert_list',
|
82 |
// Add Upgrade tab to Tools page when upgrades available.
|
83 |
-
add_filter( 'pum_tools_tabs',
|
84 |
// Render tools page upgrade tab content.
|
85 |
-
add_action( 'pum_tools_page_tab_upgrades',
|
86 |
// Ajax upgrade handler.
|
87 |
-
add_action( 'wp_ajax_pum_process_upgrade_request',
|
88 |
// Register core upgrades.
|
89 |
-
add_action( 'pum_register_upgrades',
|
90 |
|
91 |
// Initiate the upgrade registry. Must be done after versions update for proper comparisons.
|
92 |
$this->registry = PUM_Upgrade_Registry::instance();
|
@@ -157,7 +157,7 @@ class PUM_Utils_Upgrades {
|
|
157 |
|
158 |
// Reset JS/CSS assets for regeneration.
|
159 |
pum_reset_assets();
|
160 |
-
}
|
161 |
// Here to prevent constant extra queries.
|
162 |
self::$upgraded_from = '0.0.0';
|
163 |
update_option( 'pum_ver_upgraded_from', self::$upgraded_from );
|
@@ -193,29 +193,38 @@ class PUM_Utils_Upgrades {
|
|
193 |
public function register_processes( PUM_Upgrade_Registry $registry ) {
|
194 |
|
195 |
// v1.7 Upgrades
|
196 |
-
$registry->add_upgrade(
|
197 |
-
'
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
'
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
}
|
220 |
|
221 |
/**
|
@@ -229,24 +238,26 @@ class PUM_Utils_Upgrades {
|
|
229 |
$needs_upgrade = get_transient( 'pum_needs_1_8_theme_upgrades' );
|
230 |
|
231 |
if ( $needs_upgrade === false ) {
|
232 |
-
$query = new WP_Query(
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
'
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
|
|
250 |
|
251 |
$needs_upgrade = $query->post_count;
|
252 |
}
|
@@ -307,7 +318,7 @@ class PUM_Utils_Upgrades {
|
|
307 |
*
|
308 |
* @return array
|
309 |
*/
|
310 |
-
public function upgrade_alert( $alerts =
|
311 |
if ( ! $this->has_uncomplete_upgrades() || ! current_user_can( 'manage_options' ) ) {
|
312 |
return $alerts;
|
313 |
}
|
@@ -321,14 +332,14 @@ class PUM_Utils_Upgrades {
|
|
321 |
$this->render_form();
|
322 |
$html = ob_get_clean();
|
323 |
|
324 |
-
$alerts[] =
|
325 |
'code' => 'upgrades_required',
|
326 |
'type' => 'warning',
|
327 |
'html' => $html,
|
328 |
'priority' => 1000,
|
329 |
'dismissible' => false,
|
330 |
'global' => true,
|
331 |
-
|
332 |
|
333 |
return $alerts;
|
334 |
}
|
@@ -339,15 +350,18 @@ class PUM_Utils_Upgrades {
|
|
339 |
* Message only, no form.
|
340 |
*/
|
341 |
public function render_upgrade_notice() {
|
342 |
-
$resume_upgrade = $this->maybe_resume_upgrade();
|
|
|
343 |
<p class="pum-upgrade-notice">
|
344 |
<?php
|
345 |
-
if ( empty( $resume_upgrade ) ) {
|
|
|
346 |
<strong><?php _e( 'The latest version of Popup Maker requires changes to the Popup Maker settings saved on your site.', 'popup-maker' ); ?></strong>
|
347 |
<?php
|
348 |
} else {
|
349 |
_e( 'Popup Maker needs to complete a the update of your settings that was previously started.', 'popup-maker' );
|
350 |
-
}
|
|
|
351 |
</p>
|
352 |
<?php
|
353 |
}
|
@@ -356,16 +370,17 @@ class PUM_Utils_Upgrades {
|
|
356 |
* Renders the upgrade processing form for reuse.
|
357 |
*/
|
358 |
public function render_form() {
|
359 |
-
$args =
|
360 |
'upgrade_id' => $this->get_current_upgrade_id(),
|
361 |
'step' => 1,
|
362 |
-
|
363 |
|
364 |
$resume_upgrade = $this->maybe_resume_upgrade();
|
365 |
|
366 |
if ( $resume_upgrade && is_array( $resume_upgrade ) ) {
|
367 |
$args = wp_parse_args( $resume_upgrade, $args );
|
368 |
-
}
|
|
|
369 |
|
370 |
<form method="post" class="pum-form pum-batch-form pum-upgrade-form" data-ays="<?php _e( 'This can sometimes take a few minutes, are you ready to begin?', 'popup-maker' ); ?>" data-upgrade_id="<?php echo $args['upgrade_id']; ?>" data-step="<?php echo (int) $args['step']; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'pum_upgrade_ajax_nonce' ) ); ?>">
|
371 |
|
@@ -398,7 +413,7 @@ class PUM_Utils_Upgrades {
|
|
398 |
* @return false|array When nothing to resume returns false, otherwise starts the upgrade where it left off
|
399 |
*/
|
400 |
public function maybe_resume_upgrade() {
|
401 |
-
$doing_upgrade = get_option( 'pum_doing_upgrade',
|
402 |
|
403 |
if ( empty( $doing_upgrade ) ) {
|
404 |
return false;
|
@@ -465,11 +480,11 @@ class PUM_Utils_Upgrades {
|
|
465 |
$completed_upgrades = get_option( 'pum_completed_upgrades' );
|
466 |
|
467 |
if ( $completed_upgrades === false ) {
|
468 |
-
$completed_upgrades =
|
469 |
update_option( 'pum_completed_upgrades', $completed_upgrades );
|
470 |
}
|
471 |
|
472 |
-
return get_option( 'pum_completed_upgrades',
|
473 |
}
|
474 |
|
475 |
/**
|
@@ -528,16 +543,20 @@ class PUM_Utils_Upgrades {
|
|
528 |
$upgrade_id = isset( $_REQUEST['upgrade_id'] ) ? sanitize_key( $_REQUEST['upgrade_id'] ) : false;
|
529 |
|
530 |
if ( ! $upgrade_id && ! $this->has_uncomplete_upgrades() ) {
|
531 |
-
wp_send_json_error(
|
532 |
-
|
533 |
-
|
|
|
|
|
534 |
}
|
535 |
|
536 |
// Nonce.
|
537 |
if ( ! check_ajax_referer( 'pum_upgrade_ajax_nonce', 'nonce' ) ) {
|
538 |
-
wp_send_json_error(
|
539 |
-
|
540 |
-
|
|
|
|
|
541 |
}
|
542 |
|
543 |
if ( ! $upgrade_id ) {
|
@@ -554,9 +573,11 @@ class PUM_Utils_Upgrades {
|
|
554 |
$upgrade = $this->get_upgrade( $upgrade_id, $step );
|
555 |
|
556 |
if ( $upgrade === false ) {
|
557 |
-
wp_send_json_error(
|
558 |
-
|
559 |
-
|
|
|
|
|
560 |
}
|
561 |
|
562 |
/**
|
@@ -574,7 +595,7 @@ class PUM_Utils_Upgrades {
|
|
574 |
// Handle pre-fetching data.
|
575 |
if ( $using_prefetch ) {
|
576 |
// Initialize any data needed to process a step.
|
577 |
-
$data = isset( $_REQUEST['form'] ) ? $_REQUEST['form'] :
|
578 |
|
579 |
$upgrade->init( $data );
|
580 |
$upgrade->pre_fetch();
|
@@ -584,10 +605,10 @@ class PUM_Utils_Upgrades {
|
|
584 |
$step = $upgrade->process_step();
|
585 |
|
586 |
if ( ! is_wp_error( $step ) ) {
|
587 |
-
$response_data =
|
588 |
'step' => $step,
|
589 |
'next' => null,
|
590 |
-
|
591 |
|
592 |
// Finish and set the status flag if done.
|
593 |
if ( 'done' === $step ) {
|
@@ -661,15 +682,19 @@ class PUM_Utils_Upgrades {
|
|
661 |
if ( ! class_exists( $class ) && ! empty( $class_file ) && file_exists( $class_file ) ) {
|
662 |
require_once $class_file;
|
663 |
} else {
|
664 |
-
wp_send_json_error(
|
665 |
-
|
666 |
-
|
|
|
|
|
667 |
}
|
668 |
|
669 |
if ( empty( $class ) || ! class_exists( $class ) ) {
|
670 |
-
wp_send_json_error(
|
671 |
-
|
672 |
-
|
|
|
|
|
673 |
}
|
674 |
|
675 |
/**
|
@@ -685,7 +710,7 @@ class PUM_Utils_Upgrades {
|
|
685 |
*
|
686 |
* @return array
|
687 |
*/
|
688 |
-
public function tools_page_tabs( $tabs =
|
689 |
|
690 |
if ( $this->has_uncomplete_upgrades() ) {
|
691 |
$tabs['upgrades'] = __( 'Upgrades', 'popup-maker' );
|
78 |
self::update_plugin_version();
|
79 |
|
80 |
// Render upgrade admin notices.
|
81 |
+
add_filter( 'pum_alert_list', [ $this, 'upgrade_alert' ] );
|
82 |
// Add Upgrade tab to Tools page when upgrades available.
|
83 |
+
add_filter( 'pum_tools_tabs', [ $this, 'tools_page_tabs' ] );
|
84 |
// Render tools page upgrade tab content.
|
85 |
+
add_action( 'pum_tools_page_tab_upgrades', [ $this, 'tools_page_tab_content' ] );
|
86 |
// Ajax upgrade handler.
|
87 |
+
add_action( 'wp_ajax_pum_process_upgrade_request', [ $this, 'process_upgrade_request' ] );
|
88 |
// Register core upgrades.
|
89 |
+
add_action( 'pum_register_upgrades', [ $this, 'register_processes' ] );
|
90 |
|
91 |
// Initiate the upgrade registry. Must be done after versions update for proper comparisons.
|
92 |
$this->registry = PUM_Upgrade_Registry::instance();
|
157 |
|
158 |
// Reset JS/CSS assets for regeneration.
|
159 |
pum_reset_assets();
|
160 |
+
} elseif ( ! self::$upgraded_from || self::$upgraded_from === 'false' ) {
|
161 |
// Here to prevent constant extra queries.
|
162 |
self::$upgraded_from = '0.0.0';
|
163 |
update_option( 'pum_ver_upgraded_from', self::$upgraded_from );
|
193 |
public function register_processes( PUM_Upgrade_Registry $registry ) {
|
194 |
|
195 |
// v1.7 Upgrades
|
196 |
+
$registry->add_upgrade(
|
197 |
+
'core-v1_7-popups',
|
198 |
+
[
|
199 |
+
'rules' => [
|
200 |
+
version_compare( self::$initial_version, '1.7', '<' ),
|
201 |
+
],
|
202 |
+
'class' => 'PUM_Upgrade_v1_7_Popups',
|
203 |
+
'file' => Popup_Maker::$DIR . 'includes/batch/upgrade/class-upgrade-v1_7-popups.php',
|
204 |
+
]
|
205 |
+
);
|
206 |
+
|
207 |
+
$registry->add_upgrade(
|
208 |
+
'core-v1_7-settings',
|
209 |
+
[
|
210 |
+
'rules' => [
|
211 |
+
version_compare( self::$initial_version, '1.7', '<' ),
|
212 |
+
],
|
213 |
+
'class' => 'PUM_Upgrade_v1_7_Settings',
|
214 |
+
'file' => Popup_Maker::$DIR . 'includes/batch/upgrade/class-upgrade-v1_7-settings.php',
|
215 |
+
]
|
216 |
+
);
|
217 |
+
|
218 |
+
$registry->add_upgrade(
|
219 |
+
'core-v1_8-themes',
|
220 |
+
[
|
221 |
+
'rules' => [
|
222 |
+
$this->needs_v1_8_theme_upgrade(),
|
223 |
+
],
|
224 |
+
'class' => 'PUM_Upgrade_v1_8_Themes',
|
225 |
+
'file' => Popup_Maker::$DIR . 'includes/batch/upgrade/class-upgrade-v1_8-themes.php',
|
226 |
+
]
|
227 |
+
);
|
228 |
}
|
229 |
|
230 |
/**
|
238 |
$needs_upgrade = get_transient( 'pum_needs_1_8_theme_upgrades' );
|
239 |
|
240 |
if ( $needs_upgrade === false ) {
|
241 |
+
$query = new WP_Query(
|
242 |
+
[
|
243 |
+
'post_type' => 'popup_theme',
|
244 |
+
'post_status' => 'any',
|
245 |
+
'fields' => 'ids',
|
246 |
+
'meta_query' => [
|
247 |
+
'relation' => 'OR',
|
248 |
+
[
|
249 |
+
'key' => 'popup_theme_data_version',
|
250 |
+
'compare' => 'NOT EXISTS',
|
251 |
+
'value' => 'deprecated', // Here for WP 3.9 or less.
|
252 |
+
],
|
253 |
+
[
|
254 |
+
'key' => 'popup_theme_data_version',
|
255 |
+
'compare' => '<',
|
256 |
+
'value' => 3,
|
257 |
+
],
|
258 |
+
],
|
259 |
+
]
|
260 |
+
);
|
261 |
|
262 |
$needs_upgrade = $query->post_count;
|
263 |
}
|
318 |
*
|
319 |
* @return array
|
320 |
*/
|
321 |
+
public function upgrade_alert( $alerts = [] ) {
|
322 |
if ( ! $this->has_uncomplete_upgrades() || ! current_user_can( 'manage_options' ) ) {
|
323 |
return $alerts;
|
324 |
}
|
332 |
$this->render_form();
|
333 |
$html = ob_get_clean();
|
334 |
|
335 |
+
$alerts[] = [
|
336 |
'code' => 'upgrades_required',
|
337 |
'type' => 'warning',
|
338 |
'html' => $html,
|
339 |
'priority' => 1000,
|
340 |
'dismissible' => false,
|
341 |
'global' => true,
|
342 |
+
];
|
343 |
|
344 |
return $alerts;
|
345 |
}
|
350 |
* Message only, no form.
|
351 |
*/
|
352 |
public function render_upgrade_notice() {
|
353 |
+
$resume_upgrade = $this->maybe_resume_upgrade();
|
354 |
+
?>
|
355 |
<p class="pum-upgrade-notice">
|
356 |
<?php
|
357 |
+
if ( empty( $resume_upgrade ) ) {
|
358 |
+
?>
|
359 |
<strong><?php _e( 'The latest version of Popup Maker requires changes to the Popup Maker settings saved on your site.', 'popup-maker' ); ?></strong>
|
360 |
<?php
|
361 |
} else {
|
362 |
_e( 'Popup Maker needs to complete a the update of your settings that was previously started.', 'popup-maker' );
|
363 |
+
}
|
364 |
+
?>
|
365 |
</p>
|
366 |
<?php
|
367 |
}
|
370 |
* Renders the upgrade processing form for reuse.
|
371 |
*/
|
372 |
public function render_form() {
|
373 |
+
$args = [
|
374 |
'upgrade_id' => $this->get_current_upgrade_id(),
|
375 |
'step' => 1,
|
376 |
+
];
|
377 |
|
378 |
$resume_upgrade = $this->maybe_resume_upgrade();
|
379 |
|
380 |
if ( $resume_upgrade && is_array( $resume_upgrade ) ) {
|
381 |
$args = wp_parse_args( $resume_upgrade, $args );
|
382 |
+
}
|
383 |
+
?>
|
384 |
|
385 |
<form method="post" class="pum-form pum-batch-form pum-upgrade-form" data-ays="<?php _e( 'This can sometimes take a few minutes, are you ready to begin?', 'popup-maker' ); ?>" data-upgrade_id="<?php echo $args['upgrade_id']; ?>" data-step="<?php echo (int) $args['step']; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'pum_upgrade_ajax_nonce' ) ); ?>">
|
386 |
|
413 |
* @return false|array When nothing to resume returns false, otherwise starts the upgrade where it left off
|
414 |
*/
|
415 |
public function maybe_resume_upgrade() {
|
416 |
+
$doing_upgrade = get_option( 'pum_doing_upgrade', [] );
|
417 |
|
418 |
if ( empty( $doing_upgrade ) ) {
|
419 |
return false;
|
480 |
$completed_upgrades = get_option( 'pum_completed_upgrades' );
|
481 |
|
482 |
if ( $completed_upgrades === false ) {
|
483 |
+
$completed_upgrades = [];
|
484 |
update_option( 'pum_completed_upgrades', $completed_upgrades );
|
485 |
}
|
486 |
|
487 |
+
return get_option( 'pum_completed_upgrades', [] );
|
488 |
}
|
489 |
|
490 |
/**
|
543 |
$upgrade_id = isset( $_REQUEST['upgrade_id'] ) ? sanitize_key( $_REQUEST['upgrade_id'] ) : false;
|
544 |
|
545 |
if ( ! $upgrade_id && ! $this->has_uncomplete_upgrades() ) {
|
546 |
+
wp_send_json_error(
|
547 |
+
[
|
548 |
+
'error' => __( 'A batch process ID must be present to continue.', 'popup-maker' ),
|
549 |
+
]
|
550 |
+
);
|
551 |
}
|
552 |
|
553 |
// Nonce.
|
554 |
if ( ! check_ajax_referer( 'pum_upgrade_ajax_nonce', 'nonce' ) ) {
|
555 |
+
wp_send_json_error(
|
556 |
+
[
|
557 |
+
'error' => __( 'You do not have permission to initiate this request. Contact an administrator for more information.', 'popup-maker' ),
|
558 |
+
]
|
559 |
+
);
|
560 |
}
|
561 |
|
562 |
if ( ! $upgrade_id ) {
|
573 |
$upgrade = $this->get_upgrade( $upgrade_id, $step );
|
574 |
|
575 |
if ( $upgrade === false ) {
|
576 |
+
wp_send_json_error(
|
577 |
+
[
|
578 |
+
'error' => sprintf( __( '%s is an invalid batch process ID.', 'popup-maker' ), esc_html( $upgrade_id ) ),
|
579 |
+
]
|
580 |
+
);
|
581 |
}
|
582 |
|
583 |
/**
|
595 |
// Handle pre-fetching data.
|
596 |
if ( $using_prefetch ) {
|
597 |
// Initialize any data needed to process a step.
|
598 |
+
$data = isset( $_REQUEST['form'] ) ? sanitize_key( $_REQUEST['form'] ) : [];
|
599 |
|
600 |
$upgrade->init( $data );
|
601 |
$upgrade->pre_fetch();
|
605 |
$step = $upgrade->process_step();
|
606 |
|
607 |
if ( ! is_wp_error( $step ) ) {
|
608 |
+
$response_data = [
|
609 |
'step' => $step,
|
610 |
'next' => null,
|
611 |
+
];
|
612 |
|
613 |
// Finish and set the status flag if done.
|
614 |
if ( 'done' === $step ) {
|
682 |
if ( ! class_exists( $class ) && ! empty( $class_file ) && file_exists( $class_file ) ) {
|
683 |
require_once $class_file;
|
684 |
} else {
|
685 |
+
wp_send_json_error(
|
686 |
+
[
|
687 |
+
'error' => sprintf( __( 'An invalid file path is registered for the %1$s batch process handler.', 'popup-maker' ), "<code>{$upgrade_id}</code>" ),
|
688 |
+
]
|
689 |
+
);
|
690 |
}
|
691 |
|
692 |
if ( empty( $class ) || ! class_exists( $class ) ) {
|
693 |
+
wp_send_json_error(
|
694 |
+
[
|
695 |
+
'error' => sprintf( __( '%1$s is an invalid handler for the %2$s batch process. Please try again.', 'popup-maker' ), "<code>{$class}</code>", "<code>{$upgrade_id}</code>" ),
|
696 |
+
]
|
697 |
+
);
|
698 |
}
|
699 |
|
700 |
/**
|
710 |
*
|
711 |
* @return array
|
712 |
*/
|
713 |
+
public function tools_page_tabs( $tabs = [] ) {
|
714 |
|
715 |
if ( $this->has_uncomplete_upgrades() ) {
|
716 |
$tabs['upgrades'] = __( 'Upgrades', 'popup-maker' );
|
includes/admin/class-pum-admin-upgrades.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
|
7 |
// Exit if accessed directly
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
|
10 |
}
|
11 |
|
12 |
/**
|
@@ -14,654 +14,652 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
*/
|
15 |
class PUM_Admin_Upgrades {
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* Process upgrades in a stepped succession.
|
368 |
-
*
|
369 |
-
* Starts with the current version and loops until reaching the target version.
|
370 |
-
*/
|
371 |
-
public function process_upgrades() {
|
372 |
-
|
373 |
-
// this is the target version that we need to reach
|
374 |
-
$target_db_ver = Popup_Maker::$DB_VER;
|
375 |
-
|
376 |
-
// this is the current database schema version number
|
377 |
-
$current_db_ver = $this->get_pum_db_ver();
|
378 |
-
|
379 |
-
// Run upgrade routine until target version reached.
|
380 |
-
while ( $current_db_ver < $target_db_ver ) {
|
381 |
-
|
382 |
-
// increment the current db_ver by one
|
383 |
-
$current_db_ver ++;
|
384 |
|
385 |
-
|
386 |
-
|
387 |
-
$this->next_routine = $current_db_ver == $target_db_ver ? null : $current_db_ver + 1;
|
388 |
-
|
389 |
-
if ( file_exists( POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php" ) ) {
|
390 |
-
|
391 |
-
require_once POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php";
|
392 |
-
|
393 |
-
$func = "PUM_Admin_Upgrade_Routine_{$current_db_ver}::run";
|
394 |
-
if ( is_callable( $func ) ) {
|
395 |
-
call_user_func( $func );
|
396 |
-
}
|
397 |
-
|
398 |
-
}
|
399 |
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
$timer.text(time_left / 1000);
|
603 |
-
countdown(time_left, callback);
|
604 |
-
}, 1000);
|
605 |
-
} else {
|
606 |
-
callback();
|
607 |
-
}
|
608 |
-
}
|
609 |
-
|
610 |
-
function next_step(args) {
|
611 |
-
|
612 |
-
$loader.show();
|
613 |
-
|
614 |
-
if (args === undefined) {
|
615 |
-
args = {};
|
616 |
-
}
|
617 |
-
|
618 |
-
$.ajax({
|
619 |
-
url: ajaxurl,
|
620 |
-
data: $.extend({action: 'pum_trigger_upgrades'}, args),
|
621 |
-
type: 'GET',
|
622 |
-
dataType: 'json'
|
623 |
-
})
|
624 |
-
.done(function (response) {
|
625 |
-
|
626 |
-
if (response.status !== undefined) {
|
627 |
-
update_status(response.status);
|
628 |
-
}
|
629 |
-
|
630 |
-
if (response.complete !== undefined) {
|
631 |
-
$loader.hide();
|
632 |
-
} else if (response.next !== undefined && typeof response.next === 'object') {
|
633 |
-
next_step(response.next);
|
634 |
-
}
|
635 |
-
|
636 |
-
if (response.redirect !== undefined) {
|
637 |
-
if (response.countdown === undefined) {
|
638 |
-
setTimeout(function () {
|
639 |
-
document.location.href = response.redirect;
|
640 |
-
}, timer);
|
641 |
-
} else {
|
642 |
-
$timer = $('#pum-countdown');
|
643 |
-
countdown(response.countdown, function () {
|
644 |
-
document.location.href = response.redirect;
|
645 |
-
});
|
646 |
-
}
|
647 |
-
}
|
648 |
-
})
|
649 |
-
.fail(function () {
|
650 |
-
update_status("<?php _e( 'Upgrade failed, please try again.', 'popup-maker' ); ?>");
|
651 |
-
});
|
652 |
-
}
|
653 |
-
|
654 |
-
$(document).ready(function () {
|
655 |
-
// Trigger upgrades on page load
|
656 |
-
next_step(<?php echo wp_json_encode( $this->get_args() ); ?>);
|
657 |
-
update_status('<?php printf( '<strong>%s</strong>', $this->get_upgrade( $this->get_arg( 'pum-upgrade' ) ) ); ?>');
|
658 |
-
});
|
659 |
-
}(jQuery, document));
|
660 |
-
</script>
|
661 |
-
|
662 |
-
</div>
|
663 |
-
<?php
|
664 |
-
}
|
665 |
|
666 |
}
|
667 |
|
6 |
|
7 |
// Exit if accessed directly
|
8 |
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
}
|
11 |
|
12 |
/**
|
14 |
*/
|
15 |
class PUM_Admin_Upgrades {
|
16 |
|
17 |
+
/**
|
18 |
+
* @var PUM_Admin_Upgrades The one true PUM_Admin_Upgrades
|
19 |
+
*/
|
20 |
+
private static $instance;
|
21 |
|
22 |
+
/**
|
23 |
+
* @var $upgrade_args
|
24 |
+
*/
|
25 |
+
public $upgrade_args = [];
|
26 |
|
27 |
+
public $page = null;
|
28 |
|
29 |
+
public $doing_upgrades = false;
|
30 |
|
31 |
+
public $required_cap = 'manage_options';
|
32 |
|
33 |
+
public $current_routine = null;
|
34 |
|
35 |
+
public $next_routine = null;
|
36 |
|
37 |
+
/**
|
38 |
+
* Initialize the actions needed to process upgrades.
|
39 |
+
*/
|
40 |
+
public static function instance() {
|
41 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof PUM_Admin_Upgrades ) ) {
|
42 |
+
self::$instance = new PUM_Admin_Upgrades();
|
43 |
+
self::$instance->init();
|
44 |
+
}
|
45 |
|
46 |
+
return self::$instance;
|
47 |
+
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Initialize the actions needed to process upgrades.
|
51 |
+
*/
|
52 |
+
public function init() {
|
53 |
|
54 |
+
$this->update_plugin_version();
|
55 |
|
56 |
+
$this->required_cap = apply_filters( 'pum_upgrade_required_cap', 'manage_options' );
|
57 |
|
58 |
+
// bail if this plugin data doesn't need updating
|
59 |
+
if ( pum_get_db_ver() >= Popup_Maker::$DB_VER ) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
|
63 |
+
add_action( 'admin_menu', [ $this, 'register_pages' ] );
|
64 |
+
add_action( 'network_admin_menu', [ $this, 'register_pages' ] );
|
65 |
|
66 |
+
add_action( 'admin_init', [ $this, 'process_upgrade_args' ] );
|
67 |
|
68 |
+
add_action( 'wp_ajax_pum_trigger_upgrades', [ $this, 'trigger_upgrades' ] );
|
69 |
+
add_action( 'admin_notices', [ $this, 'show_upgrade_notices' ] );
|
70 |
+
}
|
71 |
+
|
72 |
+
public function update_plugin_version() {
|
73 |
+
|
74 |
+
$current_ver = get_option( 'pum_ver', false );
|
75 |
+
|
76 |
+
if ( ! $current_ver ) {
|
77 |
+
|
78 |
+
$deprecated_ver = get_site_option( 'popmake_version', false );
|
79 |
+
|
80 |
+
$current_ver = $deprecated_ver ? $deprecated_ver : Popup_Maker::$VER;
|
81 |
+
add_option( 'pum_ver', Popup_Maker::$VER );
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
if ( version_compare( $current_ver, Popup_Maker::$VER, '<' ) ) {
|
86 |
+
// Save Upgraded From option
|
87 |
+
update_option( 'pum_ver_upgraded_from', $current_ver );
|
88 |
+
update_option( 'pum_ver', Popup_Maker::$VER );
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Registers the pum-upgrades admin page.
|
95 |
+
*/
|
96 |
+
public function register_pages() {
|
97 |
+
global $pum_upgrades_page;
|
98 |
+
|
99 |
+
$parent = null;
|
100 |
+
|
101 |
+
/*
|
102 |
+
if ( function_exists( 'is_network_admin' ) && is_network_admin() ) {
|
103 |
+
add_menu_page(
|
104 |
+
__( 'Popup Maker', 'popup-maker' ),
|
105 |
+
__( 'Popup Maker', 'popup-maker' ),
|
106 |
+
'manage_network_plugins',
|
107 |
+
'popup-maker',
|
108 |
+
'',
|
109 |
+
pum_get_svg_icon( true )
|
110 |
+
);
|
111 |
+
$parent = 'popup-maker';
|
112 |
+
}
|
113 |
+
*/
|
114 |
+
|
115 |
+
$this->page = add_submenu_page(
|
116 |
+
$parent,
|
117 |
+
__( 'Popup Maker Upgrades', 'popup-maker' ),
|
118 |
+
__( 'Popup Maker Upgrades', 'popup-maker' ),
|
119 |
+
$this->required_cap,
|
120 |
+
'pum-upgrades',
|
121 |
+
[ $this, 'upgrades_screen' ]
|
122 |
+
);
|
123 |
+
|
124 |
+
$pum_upgrades_page = $this->page;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Process upgrade args.
|
129 |
+
*/
|
130 |
+
public function process_upgrade_args() {
|
131 |
+
|
132 |
+
$page = isset( $_GET['page'] ) ? $_GET['page'] : '';
|
133 |
+
|
134 |
+
if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['action'] == 'pum_trigger_upgrades' ) && $page != 'pum-upgrades' ) {
|
135 |
+
return;
|
136 |
+
}
|
137 |
+
|
138 |
+
$this->doing_upgrades = true;
|
139 |
+
|
140 |
+
$action = isset( $_REQUEST['pum-upgrade'] ) ? sanitize_text_field( $_REQUEST['pum-upgrade'] ) : $this->get_pum_db_ver() + 1;
|
141 |
+
$step = isset( $_REQUEST['step'] ) ? absint( $_REQUEST['step'] ) : 1;
|
142 |
+
$total = isset( $_REQUEST['total'] ) ? absint( $_REQUEST['total'] ) : false;
|
143 |
+
$custom = isset( $_REQUEST['custom'] ) ? absint( $_REQUEST['custom'] ) : 0;
|
144 |
+
$number = isset( $_REQUEST['number'] ) ? absint( $_REQUEST['number'] ) : 100;
|
145 |
+
$completed = isset( $_REQUEST['completed'] ) ? absint( $_REQUEST['completed'] ) : false;
|
146 |
+
$steps = ceil( $total / $number );
|
147 |
+
|
148 |
+
if ( $step > $steps ) {
|
149 |
+
// Prevent a weird case where the estimate was off. Usually only a couple.
|
150 |
+
$steps = $step;
|
151 |
+
}
|
152 |
+
|
153 |
+
$this->upgrade_args = [
|
154 |
+
'page' => 'pum-upgrades',
|
155 |
+
'pum-upgrade' => $action,
|
156 |
+
'step' => $step,
|
157 |
+
'total' => $total,
|
158 |
+
'custom' => $custom,
|
159 |
+
'steps' => $steps,
|
160 |
+
'number' => $number,
|
161 |
+
'completed' => $completed,
|
162 |
+
];
|
163 |
+
update_option( 'pum_doing_upgrade', $this->upgrade_args );
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Get upgrade arg.
|
169 |
+
*
|
170 |
+
* @param string $key
|
171 |
+
*
|
172 |
+
* @return bool|null
|
173 |
+
*/
|
174 |
+
public function set_arg( $key, $value = null ) {
|
175 |
+
|
176 |
+
$this->upgrade_args[ $key ] = $value;
|
177 |
+
if ( $key == 'number' || $key == 'total' ) {
|
178 |
+
$this->upgrade_args['steps'] = ceil( $this->upgrade_args['total'] / $this->upgrade_args['number'] );
|
179 |
+
}
|
180 |
+
if ( $this->upgrade_args['step'] > $this->upgrade_args['steps'] ) {
|
181 |
+
// Prevent a weird case where the estimate was off. Usually only a couple.
|
182 |
+
$this->upgrade_args['steps'] = $this->upgrade_args['step'];
|
183 |
+
} elseif ( $this->upgrade_args['step'] * $this->upgrade_args['steps'] ) {
|
184 |
+
update_option( 'pum_doing_upgrade', $this->upgrade_args );
|
185 |
+
}
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Get upgrade arg.
|
191 |
+
*
|
192 |
+
* @param string $key
|
193 |
+
*
|
194 |
+
* @return bool|null
|
195 |
+
*/
|
196 |
+
public function get_arg( $key = null ) {
|
197 |
+
|
198 |
+
if ( ! $key ) {
|
199 |
+
return null;
|
200 |
+
}
|
201 |
+
|
202 |
+
if ( ! isset( $this->upgrade_args[ $key ] ) ) {
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
return $this->upgrade_args[ $key ];
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
public function get_args() {
|
211 |
+
return $this->upgrade_args;
|
212 |
+
}
|
213 |
+
|
214 |
+
public function doing_upgrades() {
|
215 |
+
return $this->doing_upgrades;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Display Upgrade Notices
|
220 |
+
*
|
221 |
+
* @return void
|
222 |
+
*/
|
223 |
+
public function show_upgrade_notices() {
|
224 |
+
|
225 |
+
$screen = get_current_screen();
|
226 |
+
|
227 |
+
if ( $screen->id == $this->page ) {
|
228 |
+
return; // Don't show notices on the upgrades page
|
229 |
+
}
|
230 |
+
|
231 |
+
if ( ! $this->has_upgrades() ) {
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
// Sequential Orders was the first stepped upgrade, so check if we have a stalled upgrade
|
236 |
+
$resume_upgrade = $this->maybe_resume_upgrade();
|
237 |
+
|
238 |
+
if ( ! empty( $resume_upgrade ) ) {
|
239 |
+
|
240 |
+
$resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) );
|
241 |
+
printf(
|
242 |
+
'<div class="error"><p>' . __( 'Popup Maker needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'popup-maker' ) . '</p></div>',
|
243 |
+
esc_url( $resume_url )
|
244 |
+
);
|
245 |
+
|
246 |
+
} else {
|
247 |
+
|
248 |
+
printf(
|
249 |
+
'<div class="error"><p><strong>%s:</strong> <span class="dashicons dashicons-warning" style="color: #dc3232;"></span> %s %s %s</p></div>',
|
250 |
+
__( 'Popup Maker', 'popup-maker' ),
|
251 |
+
__( 'Important', 'popup-maker' ),
|
252 |
+
__( 'Database upgrades required.', 'popup-maker' ),
|
253 |
+
sprintf(
|
254 |
+
__( 'Please click %1$shere%2$s to complete these changes now.', 'popup-maker' ),
|
255 |
+
'<a href="' . esc_url( admin_url( 'options.php?page=pum-upgrades' ) ) . '">',
|
256 |
+
'</a>'
|
257 |
+
)
|
258 |
+
);
|
259 |
+
|
260 |
+
}
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Triggers all upgrade functions
|
266 |
+
*
|
267 |
+
* This function is usually triggered via AJAX
|
268 |
+
*
|
269 |
+
* @return void
|
270 |
+
*/
|
271 |
+
public function trigger_upgrades() {
|
272 |
+
|
273 |
+
if ( ! current_user_can( $this->required_cap ) ) {
|
274 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
275 |
+
}
|
276 |
+
|
277 |
+
$deprecated_ver = get_site_option( 'popmake_version', false );
|
278 |
+
$current_ver = get_option( 'pum_ver', $deprecated_ver );
|
279 |
+
|
280 |
+
// Save Upgraded From option
|
281 |
+
if ( $current_ver ) {
|
282 |
+
update_option( 'pum_ver_upgraded_from', $current_ver );
|
283 |
+
}
|
284 |
+
|
285 |
+
update_option( 'pum_ver', Popup_Maker::$VER );
|
286 |
+
|
287 |
+
// Process DB Upgrades
|
288 |
+
$this->process_upgrades();
|
289 |
+
|
290 |
+
if ( DOING_AJAX ) {
|
291 |
+
echo wp_json_encode(
|
292 |
+
[
|
293 |
+
'complete' => true,
|
294 |
+
'status' => sprintf(
|
295 |
+
'<strong>%s</strong><br/>%s',
|
296 |
+
__( 'Upgrades have been completed successfully.', 'popup-maker' ),
|
297 |
+
sprintf( 'You will automatically be redirected in %s seconds', '<span id="pum-countdown">5</span>' )
|
298 |
+
),
|
299 |
+
'redirect' => admin_url( 'edit.php?post_type=popup' ),
|
300 |
+
'countdown' => 5000,
|
301 |
+
]
|
302 |
+
); // Let AJAX know that the upgrade is complete
|
303 |
+
exit;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Updates the pum_db_ver to the passed $version.
|
309 |
+
*
|
310 |
+
* If no $version is passed a default value will be established.
|
311 |
+
*
|
312 |
+
* @param null $version
|
313 |
+
*/
|
314 |
+
public function set_pum_db_ver( $version = null ) {
|
315 |
+
|
316 |
+
if ( $version ) {
|
317 |
+
$version = preg_replace( '/[^0-9.].*/', '', $version );
|
318 |
+
update_option( 'pum_db_ver', $version );
|
319 |
+
|
320 |
+
return;
|
321 |
+
}
|
322 |
+
|
323 |
+
$upgraded_from = get_option( 'pum_ver_upgraded_from', false );
|
324 |
+
|
325 |
+
// this is the current database schema version number
|
326 |
+
$current_db_ver = pum_get_db_ver();
|
327 |
+
|
328 |
+
// If no current db version, but prior install detected, set db version correctly.
|
329 |
+
if ( ! $current_db_ver ) {
|
330 |
+
if ( $upgraded_from ) {
|
331 |
+
if ( version_compare( $upgraded_from, '1.3.0', '<' ) ) {
|
332 |
+
$current_db_ver = 1;
|
333 |
+
} else {
|
334 |
+
$current_db_ver = 2;
|
335 |
+
}
|
336 |
+
} else {
|
337 |
+
$current_db_ver = Popup_Maker::$DB_VER;
|
338 |
+
}
|
339 |
+
add_option( 'pum_db_ver', $current_db_ver );
|
340 |
+
}
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Gets the pum_db_ver or sets and returns the correct one.
|
346 |
+
*
|
347 |
+
* @see PUM_Utils_Upgrades::set_pum_db_ver()
|
348 |
+
*
|
349 |
+
* return $pum_db_ver
|
350 |
+
*/
|
351 |
+
public function get_pum_db_ver() {
|
352 |
+
|
353 |
+
static $pum_db_ver;
|
354 |
+
|
355 |
+
if ( ! isset( $pum_db_ver ) ) {
|
356 |
+
// this is the current database schema version number
|
357 |
+
$pum_db_ver = pum_get_db_ver();
|
358 |
+
}
|
359 |
+
|
360 |
+
if ( ! $pum_db_ver ) {
|
361 |
+
$this->set_pum_db_ver();
|
362 |
+
$pum_db_ver = pum_get_db_ver();
|
363 |
+
}
|
364 |
+
|
365 |
+
return preg_replace( '/[^0-9.].*/', '', $pum_db_ver );
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Process upgrades in a stepped succession.
|
370 |
+
*
|
371 |
+
* Starts with the current version and loops until reaching the target version.
|
372 |
+
*/
|
373 |
+
public function process_upgrades() {
|
374 |
+
|
375 |
+
// this is the target version that we need to reach
|
376 |
+
$target_db_ver = Popup_Maker::$DB_VER;
|
377 |
+
|
378 |
+
// this is the current database schema version number
|
379 |
+
$current_db_ver = $this->get_pum_db_ver();
|
380 |
+
|
381 |
+
// Run upgrade routine until target version reached.
|
382 |
+
while ( $current_db_ver < $target_db_ver ) {
|
383 |
+
|
384 |
+
// increment the current db_ver by one
|
385 |
+
$current_db_ver ++;
|
386 |
+
|
387 |
+
$this->current_routine = $current_db_ver;
|
388 |
+
|
389 |
+
$this->next_routine = $current_db_ver == $target_db_ver ? null : $current_db_ver + 1;
|
390 |
+
|
391 |
+
if ( file_exists( POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php" ) ) {
|
392 |
+
|
393 |
+
require_once POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php";
|
394 |
+
|
395 |
+
$func = "PUM_Admin_Upgrade_Routine_{$current_db_ver}::run";
|
396 |
+
if ( is_callable( $func ) ) {
|
397 |
+
call_user_func( $func );
|
398 |
+
}
|
399 |
+
}
|
400 |
+
}
|
401 |
+
|
402 |
+
}
|
403 |
+
|
404 |
+
public function current_routine() {
|
405 |
+
return $this->current_routine;
|
406 |
+
}
|
407 |
+
|
408 |
+
public function next_routine() {
|
409 |
+
return $this->next_routine;
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Process upgrades in a stepped succession.
|
414 |
+
*
|
415 |
+
* Starts with the current version and loops until reaching the target version.
|
416 |
+
*/
|
417 |
+
public function get_upgrades() {
|
418 |
+
|
419 |
+
// this is the target version that we need to reach
|
420 |
+
$target_db_ver = Popup_Maker::$DB_VER;
|
421 |
+
|
422 |
+
// this is the current database schema version number
|
423 |
+
$current_db_ver = $this->get_pum_db_ver();
|
424 |
+
|
425 |
+
$upgrades = [];
|
426 |
+
|
427 |
+
// Run upgrade routine until target version reached.
|
428 |
+
while ( $current_db_ver < $target_db_ver ) {
|
429 |
+
|
430 |
+
// increment the current db_ver by one
|
431 |
+
$current_db_ver ++;
|
432 |
+
|
433 |
+
if ( file_exists( POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php" ) ) {
|
434 |
+
|
435 |
+
require_once POPMAKE_DIR . "includes/admin/upgrades/class-pum-admin-upgrade-routine-{$current_db_ver}.php";
|
436 |
|
437 |
+
$func = "PUM_Admin_Upgrade_Routine_{$current_db_ver}::description";
|
438 |
+
if ( is_callable( $func ) ) {
|
439 |
+
$upgrades[ $current_db_ver ] = call_user_func( $func );
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
|
444 |
+
return $upgrades;
|
445 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
|
447 |
+
public function get_upgrade( $version = null ) {
|
448 |
+
$upgrades = $this->get_upgrades();
|
449 |
+
if ( isset( $upgrades[ $version ] ) ) {
|
450 |
+
return $upgrades[ $version ];
|
451 |
+
} else {
|
452 |
+
return false;
|
453 |
+
}
|
454 |
+
}
|
455 |
|
456 |
+
/**
|
457 |
+
* Returns true if there are unprocessed upgrades.
|
458 |
+
*
|
459 |
+
* @return bool
|
460 |
+
*/
|
461 |
+
public function has_upgrades() {
|
462 |
+
return boolval( count( $this->get_upgrades() ) );
|
463 |
+
}
|
464 |
|
465 |
+
/**
|
466 |
+
* For use when doing 'stepped' upgrade routines, to see if we need to start somewhere in the middle
|
467 |
+
*
|
468 |
+
* @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off
|
469 |
+
*/
|
470 |
+
public function maybe_resume_upgrade() {
|
471 |
+
|
472 |
+
$doing_upgrade = get_option( 'pum_doing_upgrade', false );
|
473 |
+
|
474 |
+
if ( empty( $doing_upgrade ) ) {
|
475 |
+
return false;
|
476 |
+
}
|
477 |
+
|
478 |
+
return $doing_upgrade;
|
479 |
+
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Adds an upgrade action to the completed upgrades array
|
484 |
+
*
|
485 |
+
* @param string $upgrade_action The action to add to the competed upgrades array
|
486 |
+
*
|
487 |
+
* @return bool If the function was successfully added
|
488 |
+
*/
|
489 |
+
public function set_upgrade_complete( $upgrade_action = '' ) {
|
490 |
+
|
491 |
+
if ( empty( $upgrade_action ) ) {
|
492 |
+
return false;
|
493 |
+
}
|
494 |
+
|
495 |
+
$completed_upgrades = $this->get_completed_upgrades();
|
496 |
+
$completed_upgrades[] = $upgrade_action;
|
497 |
+
|
498 |
+
// Remove any blanks, and only show uniques
|
499 |
+
$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
|
500 |
+
|
501 |
+
return update_option( 'pum_completed_upgrades', $completed_upgrades );
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Check if the upgrade routine has been run for a specific action
|
506 |
+
*
|
507 |
+
* @param string $upgrade_action The upgrade action to check completion for
|
508 |
+
*
|
509 |
+
* @return bool If the action has been added to the copmleted actions array
|
510 |
+
*/
|
511 |
+
public function has_upgrade_completed( $upgrade_action = '' ) {
|
512 |
+
|
513 |
+
if ( empty( $upgrade_action ) ) {
|
514 |
+
return false;
|
515 |
+
}
|
516 |
+
|
517 |
+
$completed_upgrades = $this->get_completed_upgrades();
|
518 |
+
|
519 |
+
return in_array( $upgrade_action, $completed_upgrades );
|
520 |
+
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Get's the array of completed upgrade actions
|
525 |
+
*
|
526 |
+
* @return array The array of completed upgrades
|
527 |
+
*/
|
528 |
+
public function get_completed_upgrades() {
|
529 |
+
|
530 |
+
$completed_upgrades = get_option( 'pum_completed_upgrades' );
|
531 |
+
|
532 |
+
if ( false === $completed_upgrades ) {
|
533 |
+
$completed_upgrades = [];
|
534 |
+
}
|
535 |
+
|
536 |
+
return $completed_upgrades;
|
537 |
+
|
538 |
+
}
|
539 |
+
|
540 |
+
public function step_up() {
|
541 |
+
$step = $this->upgrade_args['step'];
|
542 |
+
if ( $step >= $this->upgrade_args['steps'] ) {
|
543 |
+
$this->upgrade_args['step'] = $this->upgrade_args['steps'];
|
544 |
+
|
545 |
+
return false;
|
546 |
+
}
|
547 |
+
$this->upgrade_args['step'] ++;
|
548 |
+
|
549 |
+
return true;
|
550 |
+
}
|
551 |
+
|
552 |
+
/**
|
553 |
+
* Renders the upgrades screen.
|
554 |
+
*/
|
555 |
+
public function upgrades_screen() { ?>
|
556 |
+
<div class="wrap">
|
557 |
+
<h2>
|
558 |
+
<?php _e( 'Popup Maker - Upgrades', 'popup-maker' ); ?>
|
559 |
+
<img src="<?php echo POPMAKE_URL . '/assets/images/admin/loading.gif'; ?>" id="pum-upgrade-loader"/>
|
560 |
+
</h2>
|
561 |
+
|
562 |
+
<style>
|
563 |
+
#pum-upgrade-status {
|
564 |
+
max-height: 300px;
|
565 |
+
background: #fff;
|
566 |
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .5);
|
567 |
+
overflow-y: scroll;
|
568 |
+
text-overflow: ellipsis;
|
569 |
+
padding: 0 1.5em;
|
570 |
+
}
|
571 |
+
</style>
|
572 |
+
<p>
|
573 |
+
<?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'popup-maker' ); ?>
|
574 |
+
</p>
|
575 |
+
<div id="pum-upgrade-status"></div>
|
576 |
+
<script type="text/javascript">
|
577 |
+
(function ($, document, undefined) {
|
578 |
+
var $loader = $('#pum-upgrade-loader').hide(),
|
579 |
+
$status_box = $('#pum-upgrade-status'),
|
580 |
+
$timer,
|
581 |
+
timer = 500;
|
582 |
+
|
583 |
+
function update_status(message) {
|
584 |
+
$('<p>')
|
585 |
+
.html(message)
|
586 |
+
.appendTo($status_box);
|
587 |
+
|
588 |
+
$status_box.animate({
|
589 |
+
scrollTop: $status_box.get(0).scrollHeight
|
590 |
+
}, {
|
591 |
+
duration: 'slow',
|
592 |
+
queue: false
|
593 |
+
});
|
594 |
+
}
|
595 |
+
|
596 |
+
function countdown(timer, callback) {
|
597 |
+
var time_left = timer - 1000;
|
598 |
+
if (time_left >= 0) {
|
599 |
+
setTimeout(function () {
|
600 |
+
$timer.text(time_left / 1000);
|
601 |
+
countdown(time_left, callback);
|
602 |
+
}, 1000);
|
603 |
+
} else {
|
604 |
+
callback();
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
function next_step(args) {
|
609 |
+
|
610 |
+
$loader.show();
|
611 |
+
|
612 |
+
if (args === undefined) {
|
613 |
+
args = {};
|
614 |
+
}
|
615 |
+
|
616 |
+
$.ajax({
|
617 |
+
url: ajaxurl,
|
618 |
+
data: $.extend({action: 'pum_trigger_upgrades'}, args),
|
619 |
+
type: 'GET',
|
620 |
+
dataType: 'json'
|
621 |
+
})
|
622 |
+
.done(function (response) {
|
623 |
+
|
624 |
+
if (response.status !== undefined) {
|
625 |
+
update_status(response.status);
|
626 |
+
}
|
627 |
+
|
628 |
+
if (response.complete !== undefined) {
|
629 |
+
$loader.hide();
|
630 |
+
} else if (response.next !== undefined && typeof response.next === 'object') {
|
631 |
+
next_step(response.next);
|
632 |
+
}
|
633 |
+
|
634 |
+
if (response.redirect !== undefined) {
|
635 |
+
if (response.countdown === undefined) {
|
636 |
+
setTimeout(function () {
|
637 |
+
document.location.href = response.redirect;
|
638 |
+
}, timer);
|
639 |
+
} else {
|
640 |
+
$timer = $('#pum-countdown');
|
641 |
+
countdown(response.countdown, function () {
|
642 |
+
document.location.href = response.redirect;
|
643 |
+
});
|
644 |
+
}
|
645 |
+
}
|
646 |
+
})
|
647 |
+
.fail(function () {
|
648 |
+
update_status("<?php _e( 'Upgrade failed, please try again.', 'popup-maker' ); ?>");
|
649 |
+
});
|
650 |
+
}
|
651 |
+
|
652 |
+
$(document).ready(function () {
|
653 |
+
// Trigger upgrades on page load
|
654 |
+
next_step(<?php echo wp_json_encode( $this->get_args() ); ?>);
|
655 |
+
update_status('<?php printf( '<strong>%s</strong>', $this->get_upgrade( $this->get_arg( 'pum-upgrade' ) ) ); ?>');
|
656 |
+
});
|
657 |
+
}(jQuery, document));
|
658 |
+
</script>
|
659 |
+
|
660 |
+
</div>
|
661 |
+
<?php
|
662 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
663 |
|
664 |
}
|
665 |
|
includes/admin/upgrades/class-pum-admin-upgrade-routine-2.php
CHANGED
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
-
require_once POPMAKE_DIR .
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -29,7 +29,7 @@ final class PUM_Admin_Upgrade_Routine_2 extends PUM_Admin_Upgrade_Routine {
|
|
29 |
|
30 |
public static function run() {
|
31 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
32 |
-
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
33 |
}
|
34 |
|
35 |
ignore_user_abort( true );
|
@@ -38,25 +38,27 @@ final class PUM_Admin_Upgrade_Routine_2 extends PUM_Admin_Upgrade_Routine {
|
|
38 |
@set_time_limit( 0 );
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
}
|
44 |
|
45 |
public static function process_popups() {
|
46 |
|
47 |
-
$popups = get_posts(
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
52 |
|
53 |
-
$popup_groups =
|
54 |
'display' => popmake_popup_display_defaults(),
|
55 |
'close' => popmake_popup_close_defaults(),
|
56 |
'click_open' => popmake_popup_click_open_defaults(),
|
57 |
'auto_open' => popmake_popup_auto_open_defaults(),
|
58 |
'admin_debug' => popmake_popup_admin_debug_defaults(),
|
59 |
-
|
60 |
|
61 |
foreach ( $popups as $popup ) {
|
62 |
|
@@ -64,7 +66,6 @@ final class PUM_Admin_Upgrade_Routine_2 extends PUM_Admin_Upgrade_Routine {
|
|
64 |
$values = array_merge( $defaults, popmake_get_popup_meta_group( $group, $popup->ID ) );
|
65 |
update_post_meta( $popup->ID, "popup_{$group}", $values );
|
66 |
}
|
67 |
-
|
68 |
}
|
69 |
|
70 |
}
|
@@ -72,18 +73,18 @@ final class PUM_Admin_Upgrade_Routine_2 extends PUM_Admin_Upgrade_Routine {
|
|
72 |
public static function cleanup_old_data() {
|
73 |
global $wpdb;
|
74 |
|
75 |
-
$popup_groups =
|
76 |
'display',
|
77 |
'close',
|
78 |
'click_open',
|
79 |
'auto_open',
|
80 |
'admin_debug',
|
81 |
-
|
82 |
|
83 |
-
$popup_fields =
|
84 |
|
85 |
foreach ( $popup_groups as $group ) {
|
86 |
-
foreach ( apply_filters( 'popmake_popup_meta_field_group_' . $group,
|
87 |
$popup_fields[] = 'popup_' . $group . '_' . $field;
|
88 |
}
|
89 |
}
|
@@ -93,4 +94,4 @@ final class PUM_Admin_Upgrade_Routine_2 extends PUM_Admin_Upgrade_Routine {
|
|
93 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key IN('$popup_fields');" );
|
94 |
}
|
95 |
|
96 |
-
}
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
+
require_once POPMAKE_DIR . 'includes/admin/upgrades/class-pum-admin-upgrade-routine.php';
|
19 |
}
|
20 |
|
21 |
/**
|
29 |
|
30 |
public static function run() {
|
31 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
32 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
33 |
}
|
34 |
|
35 |
ignore_user_abort( true );
|
38 |
@set_time_limit( 0 );
|
39 |
}
|
40 |
|
41 |
+
self::process_popups();
|
42 |
+
self::cleanup_old_data();
|
43 |
}
|
44 |
|
45 |
public static function process_popups() {
|
46 |
|
47 |
+
$popups = get_posts(
|
48 |
+
[
|
49 |
+
'post_type' => 'popup',
|
50 |
+
'post_status' => [ 'any', 'trash' ],
|
51 |
+
'posts_per_page' => - 1,
|
52 |
+
]
|
53 |
+
);
|
54 |
|
55 |
+
$popup_groups = [
|
56 |
'display' => popmake_popup_display_defaults(),
|
57 |
'close' => popmake_popup_close_defaults(),
|
58 |
'click_open' => popmake_popup_click_open_defaults(),
|
59 |
'auto_open' => popmake_popup_auto_open_defaults(),
|
60 |
'admin_debug' => popmake_popup_admin_debug_defaults(),
|
61 |
+
];
|
62 |
|
63 |
foreach ( $popups as $popup ) {
|
64 |
|
66 |
$values = array_merge( $defaults, popmake_get_popup_meta_group( $group, $popup->ID ) );
|
67 |
update_post_meta( $popup->ID, "popup_{$group}", $values );
|
68 |
}
|
|
|
69 |
}
|
70 |
|
71 |
}
|
73 |
public static function cleanup_old_data() {
|
74 |
global $wpdb;
|
75 |
|
76 |
+
$popup_groups = [
|
77 |
'display',
|
78 |
'close',
|
79 |
'click_open',
|
80 |
'auto_open',
|
81 |
'admin_debug',
|
82 |
+
];
|
83 |
|
84 |
+
$popup_fields = [];
|
85 |
|
86 |
foreach ( $popup_groups as $group ) {
|
87 |
+
foreach ( apply_filters( 'popmake_popup_meta_field_group_' . $group, [] ) as $field ) {
|
88 |
$popup_fields[] = 'popup_' . $group . '_' . $field;
|
89 |
}
|
90 |
}
|
94 |
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key IN('$popup_fields');" );
|
95 |
}
|
96 |
|
97 |
+
}
|
includes/admin/upgrades/class-pum-admin-upgrade-routine-3.php
CHANGED
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
-
require_once POPMAKE_DIR .
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -40,7 +40,7 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
40 |
*/
|
41 |
public static function run() {
|
42 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
43 |
-
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
44 |
}
|
45 |
|
46 |
ignore_user_abort( true );
|
@@ -63,31 +63,32 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
63 |
$upgrades->set_arg( 'total', $total );
|
64 |
}
|
65 |
|
66 |
-
$popups = pum_get_popups(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
if ( $popups ) {
|
74 |
|
75 |
foreach ( $popups as $popup ) {
|
76 |
-
$_cookies = $cookies =
|
77 |
-
$_triggers = $triggers =
|
78 |
-
|
79 |
|
80 |
// Convert Click Open Triggers.
|
81 |
-
$click_open
|
82 |
-
$_triggers[] =
|
83 |
'type' => 'click_open',
|
84 |
-
'settings' =>
|
85 |
'extra_selectors' => ! empty( $click_open['extra_selectors'] ) ? $click_open['extra_selectors'] : '',
|
86 |
-
'cookie' =>
|
87 |
'name' => null,
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
// If auto open enabled create a new trigger.
|
93 |
$auto_open = popmake_get_popup_meta_group( 'auto_open', $popup->ID );
|
@@ -111,7 +112,7 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
111 |
if ( $cookie_trigger != 'disabled' ) {
|
112 |
|
113 |
// Add the new cookie to the auto open trigger.
|
114 |
-
$trigger_cookie =
|
115 |
|
116 |
// Set the event based on the original option.
|
117 |
switch ( $cookie_trigger ) {
|
@@ -127,28 +128,28 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
127 |
}
|
128 |
|
129 |
// Add the new cookie to the cookies array.
|
130 |
-
$_cookies[] =
|
131 |
'event' => $event,
|
132 |
-
'settings' =>
|
133 |
'name' => $cookie_name,
|
134 |
'key' => '',
|
135 |
'time' => $auto_open['cookie_time'],
|
136 |
'path' => isset( $auto_open['cookie_path'] ) ? 1 : 0,
|
137 |
'session' => isset( $auto_open['session_cookie'] ) ? 1 : 0,
|
138 |
-
|
139 |
-
|
140 |
}
|
141 |
|
142 |
// Add the new auto open trigger to the triggers array.
|
143 |
-
$_triggers[] =
|
144 |
'type' => 'auto_open',
|
145 |
-
'settings' =>
|
146 |
'delay' => ! empty( $auto_open['delay'] ) ? absint( $auto_open['delay'] ) : 500,
|
147 |
-
'cookie' =>
|
148 |
'name' => $trigger_cookie,
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
}
|
153 |
|
154 |
foreach ( $_cookies as $cookie ) {
|
@@ -171,12 +172,11 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
171 |
|
172 |
if ( $completed < $total ) {
|
173 |
$upgrades->set_arg( 'completed', $completed );
|
174 |
-
|
175 |
}
|
176 |
-
|
177 |
}
|
178 |
|
179 |
-
|
180 |
|
181 |
}
|
182 |
|
@@ -193,4 +193,4 @@ final class PUM_Admin_Upgrade_Routine_3 extends PUM_Admin_Upgrade_Routine {
|
|
193 |
public static function get_auto_open( $popup_id = null, $key = null, $default = null ) {
|
194 |
return popmake_get_popup_meta( 'auto_open', $popup_id, $key, $default );
|
195 |
}
|
196 |
-
}
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
+
require_once POPMAKE_DIR . 'includes/admin/upgrades/class-pum-admin-upgrade-routine.php';
|
19 |
}
|
20 |
|
21 |
/**
|
40 |
*/
|
41 |
public static function run() {
|
42 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
43 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
44 |
}
|
45 |
|
46 |
ignore_user_abort( true );
|
63 |
$upgrades->set_arg( 'total', $total );
|
64 |
}
|
65 |
|
66 |
+
$popups = pum_get_popups(
|
67 |
+
[
|
68 |
+
'number' => $upgrades->get_arg( 'number' ),
|
69 |
+
'page' => $upgrades->get_arg( 'step' ),
|
70 |
+
'status' => [ 'any', 'trash', 'auto-draft' ],
|
71 |
+
'order' => 'ASC',
|
72 |
+
]
|
73 |
+
);
|
74 |
|
75 |
if ( $popups ) {
|
76 |
|
77 |
foreach ( $popups as $popup ) {
|
78 |
+
$_cookies = $cookies = [];
|
79 |
+
$_triggers = $triggers = [];
|
|
|
80 |
|
81 |
// Convert Click Open Triggers.
|
82 |
+
$click_open = popmake_get_popup_meta_group( 'click_open', $popup->ID );
|
83 |
+
$_triggers[] = [
|
84 |
'type' => 'click_open',
|
85 |
+
'settings' => [
|
86 |
'extra_selectors' => ! empty( $click_open['extra_selectors'] ) ? $click_open['extra_selectors'] : '',
|
87 |
+
'cookie' => [
|
88 |
'name' => null,
|
89 |
+
],
|
90 |
+
],
|
91 |
+
];
|
92 |
|
93 |
// If auto open enabled create a new trigger.
|
94 |
$auto_open = popmake_get_popup_meta_group( 'auto_open', $popup->ID );
|
112 |
if ( $cookie_trigger != 'disabled' ) {
|
113 |
|
114 |
// Add the new cookie to the auto open trigger.
|
115 |
+
$trigger_cookie = [ $cookie_name ];
|
116 |
|
117 |
// Set the event based on the original option.
|
118 |
switch ( $cookie_trigger ) {
|
128 |
}
|
129 |
|
130 |
// Add the new cookie to the cookies array.
|
131 |
+
$_cookies[] = [
|
132 |
'event' => $event,
|
133 |
+
'settings' => [
|
134 |
'name' => $cookie_name,
|
135 |
'key' => '',
|
136 |
'time' => $auto_open['cookie_time'],
|
137 |
'path' => isset( $auto_open['cookie_path'] ) ? 1 : 0,
|
138 |
'session' => isset( $auto_open['session_cookie'] ) ? 1 : 0,
|
139 |
+
],
|
140 |
+
];
|
141 |
}
|
142 |
|
143 |
// Add the new auto open trigger to the triggers array.
|
144 |
+
$_triggers[] = [
|
145 |
'type' => 'auto_open',
|
146 |
+
'settings' => [
|
147 |
'delay' => ! empty( $auto_open['delay'] ) ? absint( $auto_open['delay'] ) : 500,
|
148 |
+
'cookie' => [
|
149 |
'name' => $trigger_cookie,
|
150 |
+
],
|
151 |
+
],
|
152 |
+
];
|
153 |
}
|
154 |
|
155 |
foreach ( $_cookies as $cookie ) {
|
172 |
|
173 |
if ( $completed < $total ) {
|
174 |
$upgrades->set_arg( 'completed', $completed );
|
175 |
+
self::next_step();
|
176 |
}
|
|
|
177 |
}
|
178 |
|
179 |
+
self::done();
|
180 |
|
181 |
}
|
182 |
|
193 |
public static function get_auto_open( $popup_id = null, $key = null, $default = null ) {
|
194 |
return popmake_get_popup_meta( 'auto_open', $popup_id, $key, $default );
|
195 |
}
|
196 |
+
}
|
includes/admin/upgrades/class-pum-admin-upgrade-routine-4.php
CHANGED
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
-
require_once POPMAKE_DIR .
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -40,7 +40,7 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
40 |
*/
|
41 |
public static function run() {
|
42 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
43 |
-
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
44 |
}
|
45 |
|
46 |
ignore_user_abort( true );
|
@@ -63,18 +63,20 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
63 |
$upgrades->set_arg( 'total', $total );
|
64 |
}
|
65 |
|
66 |
-
$popups = pum_get_popups(
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
if ( $popups ) {
|
74 |
|
75 |
foreach ( $popups as $popup ) {
|
76 |
|
77 |
-
$_conditions = $conditions =
|
78 |
|
79 |
// Convert Conditions
|
80 |
$targeting_conditions = popmake_get_popup_meta_group( 'targeting_condition', $popup->ID );
|
@@ -82,26 +84,25 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
82 |
if ( empty( $targeting_conditions ) ) {
|
83 |
if ( $popup->post_status == 'publish' ) {
|
84 |
// Default popups with no conditions to draft
|
85 |
-
|
86 |
}
|
87 |
update_post_meta( $popup->ID, 'popup_conditions', $conditions );
|
88 |
$completed ++;
|
89 |
continue;
|
90 |
}
|
91 |
|
92 |
-
|
93 |
$sitewide = false;
|
94 |
|
95 |
if ( array_key_exists( 'on_entire_site', $targeting_conditions ) ) {
|
96 |
$sitewide = true;
|
97 |
-
$targeting_conditions =
|
98 |
} else {
|
99 |
-
$targeting_conditions =
|
100 |
}
|
101 |
|
102 |
-
$targeting_conditions =
|
103 |
|
104 |
-
$_group =
|
105 |
|
106 |
foreach ( $targeting_conditions as $condition ) {
|
107 |
|
@@ -110,12 +111,11 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
110 |
|
111 |
// Add a new AND condition group.
|
112 |
if ( $sitewide ) {
|
113 |
-
$_conditions[] =
|
114 |
} // Add a new OR condition to the group.
|
115 |
else {
|
116 |
$_group[] = $condition;
|
117 |
}
|
118 |
-
|
119 |
}
|
120 |
|
121 |
if ( ! $sitewide && ! empty( $_group ) ) {
|
@@ -138,12 +138,11 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
138 |
|
139 |
if ( $completed < $total ) {
|
140 |
$upgrades->set_arg( 'completed', $completed );
|
141 |
-
|
142 |
}
|
143 |
-
|
144 |
}
|
145 |
|
146 |
-
|
147 |
}
|
148 |
|
149 |
/**
|
@@ -153,8 +152,8 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
153 |
*
|
154 |
* @return array
|
155 |
*/
|
156 |
-
public static function parse_conditions( $targeting_conditions =
|
157 |
-
$conditions =
|
158 |
|
159 |
$targeting_conditions = array_keys( $targeting_conditions );
|
160 |
|
@@ -164,62 +163,61 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
164 |
|
165 |
// Front Page
|
166 |
if ( strpos( $key, 'on_home' ) !== false ) {
|
167 |
-
$condition =
|
168 |
'target' => 'is_front_page',
|
169 |
-
|
170 |
} // Blog Index
|
171 |
elseif ( strpos( $key, 'on_blog' ) !== false ) {
|
172 |
-
$condition =
|
173 |
'target' => 'is_home',
|
174 |
-
|
175 |
} // Search Pages
|
176 |
elseif ( strpos( $key, 'on_search' ) !== false ) {
|
177 |
-
$condition =
|
178 |
'target' => 'is_search',
|
179 |
-
|
180 |
} // 404 Pages
|
181 |
elseif ( strpos( $key, 'on_404' ) !== false ) {
|
182 |
-
$condition =
|
183 |
'target' => 'is_404',
|
184 |
-
|
185 |
} // WooCommerce Pages
|
186 |
elseif ( strpos( $key, 'on_woocommerce' ) !== false ) {
|
187 |
-
$condition =
|
188 |
'target' => 'is_woocommerce',
|
189 |
-
|
190 |
} // WooCommerce Shop Pages
|
191 |
elseif ( strpos( $key, 'on_shop' ) !== false ) {
|
192 |
-
$condition =
|
193 |
'target' => 'is_shop',
|
194 |
-
|
195 |
}
|
196 |
|
197 |
if ( $condition ) {
|
198 |
unset( $targeting_conditions[ $index ] );
|
199 |
$conditions[] = $condition;
|
200 |
}
|
201 |
-
|
202 |
}
|
203 |
|
204 |
-
foreach ( get_post_types(
|
205 |
-
$pt_conditions =
|
206 |
|
207 |
if ( empty( $pt_conditions ) ) {
|
208 |
continue;
|
209 |
}
|
210 |
|
211 |
if ( in_array( "on_{$name}s", $pt_conditions ) && ! in_array( "on_specific_{$name}s", $pt_conditions ) ) {
|
212 |
-
$conditions[] =
|
213 |
'target' => $name . '_all',
|
214 |
-
|
215 |
continue;
|
216 |
}
|
217 |
|
218 |
// Remove non ID keys
|
219 |
-
unset( $pt_conditions["on_{$name}s"] );
|
220 |
-
unset( $pt_conditions["on_specific_{$name}s"] );
|
221 |
|
222 |
-
$ids =
|
223 |
|
224 |
// Convert the rest of the keys to post IDs.
|
225 |
foreach ( $pt_conditions as $key ) {
|
@@ -230,32 +228,32 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
230 |
}
|
231 |
|
232 |
// Create a new post_type_selected condition with the ids.
|
233 |
-
$conditions[] =
|
234 |
'target' => $name . '_selected',
|
235 |
'selected' => $ids,
|
236 |
-
|
237 |
}
|
238 |
|
239 |
-
foreach ( get_taxonomies(
|
240 |
|
241 |
-
$tax_conditions =
|
242 |
|
243 |
if ( empty( $tax_conditions ) ) {
|
244 |
continue;
|
245 |
}
|
246 |
|
247 |
if ( in_array( "on_{$tax_name}s", $tax_conditions ) && ! in_array( "on_specific_{$tax_name}s", $tax_conditions ) ) {
|
248 |
-
$conditions[] =
|
249 |
'target' => 'tax_' . $tax_name . '_all',
|
250 |
-
|
251 |
continue;
|
252 |
}
|
253 |
|
254 |
// Remove non ID keys
|
255 |
-
unset( $tax_conditions["on_{$tax_name}s"] );
|
256 |
-
unset( $tax_conditions["on_specific_{$tax_name}s"] );
|
257 |
|
258 |
-
$ids =
|
259 |
|
260 |
// Convert the rest of the keys to post IDs.
|
261 |
foreach ( $tax_conditions as $key ) {
|
@@ -266,10 +264,10 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
266 |
}
|
267 |
|
268 |
// Create a new post_type_selected condition with the ids.
|
269 |
-
$conditions[] =
|
270 |
'target' => 'tax_' . $tax_name . '_selected',
|
271 |
'selected' => $ids,
|
272 |
-
|
273 |
}
|
274 |
|
275 |
return $conditions;
|
@@ -284,7 +282,7 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
284 |
* @return array
|
285 |
*/
|
286 |
public static function filter_conditions( &$targeting_conditions, $string ) {
|
287 |
-
$conditions =
|
288 |
|
289 |
foreach ( $targeting_conditions as $index => $key ) {
|
290 |
if ( $string == '_post' && strpos( $key, '_post_tag' ) !== false ) {
|
@@ -319,8 +317,8 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
319 |
*
|
320 |
* @return array
|
321 |
*/
|
322 |
-
public static function filter_includes( $conditions =
|
323 |
-
$includes =
|
324 |
|
325 |
foreach ( $conditions as $condition => $value ) {
|
326 |
if ( strpos( $condition, 'on_' ) === 0 ) {
|
@@ -338,8 +336,8 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
338 |
*
|
339 |
* @return array
|
340 |
*/
|
341 |
-
public static function filter_excludes( $conditions =
|
342 |
-
$excludes =
|
343 |
|
344 |
foreach ( $conditions as $condition => $value ) {
|
345 |
if ( strpos( $condition, 'exclude_on_' ) === 0 ) {
|
@@ -350,4 +348,4 @@ final class PUM_Admin_Upgrade_Routine_4 extends PUM_Admin_Upgrade_Routine {
|
|
350 |
return $excludes;
|
351 |
}
|
352 |
|
353 |
-
}
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
+
require_once POPMAKE_DIR . 'includes/admin/upgrades/class-pum-admin-upgrade-routine.php';
|
19 |
}
|
20 |
|
21 |
/**
|
40 |
*/
|
41 |
public static function run() {
|
42 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
43 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
44 |
}
|
45 |
|
46 |
ignore_user_abort( true );
|
63 |
$upgrades->set_arg( 'total', $total );
|
64 |
}
|
65 |
|
66 |
+
$popups = pum_get_popups(
|
67 |
+
[
|
68 |
+
'number' => $upgrades->get_arg( 'number' ),
|
69 |
+
'page' => $upgrades->get_arg( 'step' ),
|
70 |
+
'status' => [ 'any', 'trash', 'auto-draft' ],
|
71 |
+
'order' => 'ASC',
|
72 |
+
]
|
73 |
+
);
|
74 |
|
75 |
if ( $popups ) {
|
76 |
|
77 |
foreach ( $popups as $popup ) {
|
78 |
|
79 |
+
$_conditions = $conditions = [];
|
80 |
|
81 |
// Convert Conditions
|
82 |
$targeting_conditions = popmake_get_popup_meta_group( 'targeting_condition', $popup->ID );
|
84 |
if ( empty( $targeting_conditions ) ) {
|
85 |
if ( $popup->post_status == 'publish' ) {
|
86 |
// Default popups with no conditions to draft
|
87 |
+
self::change_post_status( $popup->ID, 'draft' );
|
88 |
}
|
89 |
update_post_meta( $popup->ID, 'popup_conditions', $conditions );
|
90 |
$completed ++;
|
91 |
continue;
|
92 |
}
|
93 |
|
|
|
94 |
$sitewide = false;
|
95 |
|
96 |
if ( array_key_exists( 'on_entire_site', $targeting_conditions ) ) {
|
97 |
$sitewide = true;
|
98 |
+
$targeting_conditions = self::filter_excludes( $targeting_conditions );
|
99 |
} else {
|
100 |
+
$targeting_conditions = self::filter_includes( $targeting_conditions );
|
101 |
}
|
102 |
|
103 |
+
$targeting_conditions = self::parse_conditions( $targeting_conditions );
|
104 |
|
105 |
+
$_group = [];
|
106 |
|
107 |
foreach ( $targeting_conditions as $condition ) {
|
108 |
|
111 |
|
112 |
// Add a new AND condition group.
|
113 |
if ( $sitewide ) {
|
114 |
+
$_conditions[] = [ $condition ];
|
115 |
} // Add a new OR condition to the group.
|
116 |
else {
|
117 |
$_group[] = $condition;
|
118 |
}
|
|
|
119 |
}
|
120 |
|
121 |
if ( ! $sitewide && ! empty( $_group ) ) {
|
138 |
|
139 |
if ( $completed < $total ) {
|
140 |
$upgrades->set_arg( 'completed', $completed );
|
141 |
+
self::next_step();
|
142 |
}
|
|
|
143 |
}
|
144 |
|
145 |
+
self::done();
|
146 |
}
|
147 |
|
148 |
/**
|
152 |
*
|
153 |
* @return array
|
154 |
*/
|
155 |
+
public static function parse_conditions( $targeting_conditions = [] ) {
|
156 |
+
$conditions = [];
|
157 |
|
158 |
$targeting_conditions = array_keys( $targeting_conditions );
|
159 |
|
163 |
|
164 |
// Front Page
|
165 |
if ( strpos( $key, 'on_home' ) !== false ) {
|
166 |
+
$condition = [
|
167 |
'target' => 'is_front_page',
|
168 |
+
];
|
169 |
} // Blog Index
|
170 |
elseif ( strpos( $key, 'on_blog' ) !== false ) {
|
171 |
+
$condition = [
|
172 |
'target' => 'is_home',
|
173 |
+
];
|
174 |
} // Search Pages
|
175 |
elseif ( strpos( $key, 'on_search' ) !== false ) {
|
176 |
+
$condition = [
|
177 |
'target' => 'is_search',
|
178 |
+
];
|
179 |
} // 404 Pages
|
180 |
elseif ( strpos( $key, 'on_404' ) !== false ) {
|
181 |
+
$condition = [
|
182 |
'target' => 'is_404',
|
183 |
+
];
|
184 |
} // WooCommerce Pages
|
185 |
elseif ( strpos( $key, 'on_woocommerce' ) !== false ) {
|
186 |
+
$condition = [
|
187 |
'target' => 'is_woocommerce',
|
188 |
+
];
|
189 |
} // WooCommerce Shop Pages
|
190 |
elseif ( strpos( $key, 'on_shop' ) !== false ) {
|
191 |
+
$condition = [
|
192 |
'target' => 'is_shop',
|
193 |
+
];
|
194 |
}
|
195 |
|
196 |
if ( $condition ) {
|
197 |
unset( $targeting_conditions[ $index ] );
|
198 |
$conditions[] = $condition;
|
199 |
}
|
|
|
200 |
}
|
201 |
|
202 |
+
foreach ( get_post_types( [ 'public' => true ], 'objects' ) as $name => $post_type ) {
|
203 |
+
$pt_conditions = self::filter_conditions( $targeting_conditions, '_' . $name );
|
204 |
|
205 |
if ( empty( $pt_conditions ) ) {
|
206 |
continue;
|
207 |
}
|
208 |
|
209 |
if ( in_array( "on_{$name}s", $pt_conditions ) && ! in_array( "on_specific_{$name}s", $pt_conditions ) ) {
|
210 |
+
$conditions[] = [
|
211 |
'target' => $name . '_all',
|
212 |
+
];
|
213 |
continue;
|
214 |
}
|
215 |
|
216 |
// Remove non ID keys
|
217 |
+
unset( $pt_conditions[ "on_{$name}s" ] );
|
218 |
+
unset( $pt_conditions[ "on_specific_{$name}s" ] );
|
219 |
|
220 |
+
$ids = [];
|
221 |
|
222 |
// Convert the rest of the keys to post IDs.
|
223 |
foreach ( $pt_conditions as $key ) {
|
228 |
}
|
229 |
|
230 |
// Create a new post_type_selected condition with the ids.
|
231 |
+
$conditions[] = [
|
232 |
'target' => $name . '_selected',
|
233 |
'selected' => $ids,
|
234 |
+
];
|
235 |
}
|
236 |
|
237 |
+
foreach ( get_taxonomies( [ 'public' => true ], 'objects' ) as $tax_name => $taxonomy ) {
|
238 |
|
239 |
+
$tax_conditions = self::filter_conditions( $targeting_conditions, '_' . $tax_name );
|
240 |
|
241 |
if ( empty( $tax_conditions ) ) {
|
242 |
continue;
|
243 |
}
|
244 |
|
245 |
if ( in_array( "on_{$tax_name}s", $tax_conditions ) && ! in_array( "on_specific_{$tax_name}s", $tax_conditions ) ) {
|
246 |
+
$conditions[] = [
|
247 |
'target' => 'tax_' . $tax_name . '_all',
|
248 |
+
];
|
249 |
continue;
|
250 |
}
|
251 |
|
252 |
// Remove non ID keys
|
253 |
+
unset( $tax_conditions[ "on_{$tax_name}s" ] );
|
254 |
+
unset( $tax_conditions[ "on_specific_{$tax_name}s" ] );
|
255 |
|
256 |
+
$ids = [];
|
257 |
|
258 |
// Convert the rest of the keys to post IDs.
|
259 |
foreach ( $tax_conditions as $key ) {
|
264 |
}
|
265 |
|
266 |
// Create a new post_type_selected condition with the ids.
|
267 |
+
$conditions[] = [
|
268 |
'target' => 'tax_' . $tax_name . '_selected',
|
269 |
'selected' => $ids,
|
270 |
+
];
|
271 |
}
|
272 |
|
273 |
return $conditions;
|
282 |
* @return array
|
283 |
*/
|
284 |
public static function filter_conditions( &$targeting_conditions, $string ) {
|
285 |
+
$conditions = [];
|
286 |
|
287 |
foreach ( $targeting_conditions as $index => $key ) {
|
288 |
if ( $string == '_post' && strpos( $key, '_post_tag' ) !== false ) {
|
317 |
*
|
318 |
* @return array
|
319 |
*/
|
320 |
+
public static function filter_includes( $conditions = [] ) {
|
321 |
+
$includes = [];
|
322 |
|
323 |
foreach ( $conditions as $condition => $value ) {
|
324 |
if ( strpos( $condition, 'on_' ) === 0 ) {
|
336 |
*
|
337 |
* @return array
|
338 |
*/
|
339 |
+
public static function filter_excludes( $conditions = [] ) {
|
340 |
+
$excludes = [];
|
341 |
|
342 |
foreach ( $conditions as $condition => $value ) {
|
343 |
if ( strpos( $condition, 'exclude_on_' ) === 0 ) {
|
348 |
return $excludes;
|
349 |
}
|
350 |
|
351 |
+
}
|
includes/admin/upgrades/class-pum-admin-upgrade-routine-5.php
CHANGED
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
-
require_once POPMAKE_DIR .
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -35,7 +35,7 @@ final class PUM_Admin_Upgrade_Routine_5 extends PUM_Admin_Upgrade_Routine {
|
|
35 |
*/
|
36 |
public static function run() {
|
37 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
38 |
-
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
39 |
}
|
40 |
|
41 |
ignore_user_abort( true );
|
@@ -58,12 +58,14 @@ final class PUM_Admin_Upgrade_Routine_5 extends PUM_Admin_Upgrade_Routine {
|
|
58 |
$upgrades->set_arg( 'total', $total );
|
59 |
}
|
60 |
|
61 |
-
$popups = pum_get_popups(
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
if ( $popups ) {
|
69 |
|
@@ -72,16 +74,15 @@ final class PUM_Admin_Upgrade_Routine_5 extends PUM_Admin_Upgrade_Routine {
|
|
72 |
/**
|
73 |
* Initialize the popup meta values for core analytics.
|
74 |
*/
|
75 |
-
|
76 |
|
77 |
$completed ++;
|
78 |
}
|
79 |
|
80 |
if ( $completed < $total ) {
|
81 |
$upgrades->set_arg( 'completed', $completed );
|
82 |
-
|
83 |
}
|
84 |
-
|
85 |
}
|
86 |
|
87 |
// Check for popup analytics extension and import those stats if available.
|
@@ -107,7 +108,7 @@ final class PUM_Admin_Upgrade_Routine_5 extends PUM_Admin_Upgrade_Routine {
|
|
107 |
update_site_option( 'pum_total_conversion_count', $total_conversion_count );
|
108 |
*/
|
109 |
|
110 |
-
|
111 |
}
|
112 |
|
113 |
/**
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
+
require_once POPMAKE_DIR . 'includes/admin/upgrades/class-pum-admin-upgrade-routine.php';
|
19 |
}
|
20 |
|
21 |
/**
|
35 |
*/
|
36 |
public static function run() {
|
37 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
38 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
39 |
}
|
40 |
|
41 |
ignore_user_abort( true );
|
58 |
$upgrades->set_arg( 'total', $total );
|
59 |
}
|
60 |
|
61 |
+
$popups = pum_get_popups(
|
62 |
+
[
|
63 |
+
'number' => $upgrades->get_arg( 'number' ),
|
64 |
+
'page' => $upgrades->get_arg( 'step' ),
|
65 |
+
'status' => [ 'any', 'trash', 'auto-draft' ],
|
66 |
+
'order' => 'ASC',
|
67 |
+
]
|
68 |
+
);
|
69 |
|
70 |
if ( $popups ) {
|
71 |
|
74 |
/**
|
75 |
* Initialize the popup meta values for core analytics.
|
76 |
*/
|
77 |
+
self::initialize_analytics( $popup->ID );
|
78 |
|
79 |
$completed ++;
|
80 |
}
|
81 |
|
82 |
if ( $completed < $total ) {
|
83 |
$upgrades->set_arg( 'completed', $completed );
|
84 |
+
self::next_step();
|
85 |
}
|
|
|
86 |
}
|
87 |
|
88 |
// Check for popup analytics extension and import those stats if available.
|
108 |
update_site_option( 'pum_total_conversion_count', $total_conversion_count );
|
109 |
*/
|
110 |
|
111 |
+
self::done();
|
112 |
}
|
113 |
|
114 |
/**
|
includes/admin/upgrades/class-pum-admin-upgrade-routine-6.php
CHANGED
@@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
-
require_once POPMAKE_DIR .
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -47,7 +47,7 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
47 |
*/
|
48 |
public static function run() {
|
49 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
50 |
-
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ),
|
51 |
}
|
52 |
|
53 |
ignore_user_abort( true );
|
@@ -76,31 +76,33 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
76 |
$upgrades->set_arg( 'total', $total );
|
77 |
}
|
78 |
|
79 |
-
$popups = pum_get_popups(
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
|
86 |
-
|
87 |
|
88 |
// Delete All old meta keys.
|
89 |
-
|
90 |
|
91 |
// Delete All orphaned meta keys.
|
92 |
-
|
93 |
|
94 |
-
|
95 |
|
96 |
if ( $popups ) {
|
97 |
|
98 |
foreach ( $popups as $popup ) {
|
99 |
|
100 |
// Check that each popup has a valid theme id
|
101 |
-
if ( ! array_key_exists( $popup->get_theme_id(),
|
102 |
// Set a valid theme.
|
103 |
-
update_post_meta( $popup->ID, 'popup_theme',
|
104 |
}
|
105 |
|
106 |
$completed ++;
|
@@ -108,31 +110,29 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
108 |
|
109 |
if ( $completed < $total ) {
|
110 |
$upgrades->set_arg( 'completed', $completed );
|
111 |
-
|
112 |
}
|
113 |
-
|
114 |
}
|
115 |
|
116 |
-
|
117 |
}
|
118 |
|
119 |
/**
|
120 |
* Create a list of valid popup themes.
|
121 |
*/
|
122 |
public static function setup_valid_themes() {
|
123 |
-
|
124 |
|
125 |
foreach ( pum_get_all_themes() as $theme ) {
|
126 |
-
|
127 |
if ( pum_get_default_theme_id() == $theme->ID ) {
|
128 |
-
|
129 |
}
|
130 |
}
|
131 |
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
PUM_Admin_Upgrade_Routine_6::$default_theme = PUM_Admin_Upgrade_Routine_6::$valid_themes[ key( PUM_Admin_Upgrade_Routine_6::$valid_themes ) ]->ID;
|
136 |
}
|
137 |
}
|
138 |
|
@@ -142,7 +142,8 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
142 |
public static function delete_all_orphaned_meta_keys() {
|
143 |
global $wpdb;
|
144 |
|
145 |
-
$wpdb->query(
|
|
|
146 |
DELETE pm
|
147 |
FROM $wpdb->postmeta pm
|
148 |
LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id
|
@@ -159,7 +160,8 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
159 |
public static function delete_all_old_meta_keys() {
|
160 |
global $wpdb;
|
161 |
|
162 |
-
$query = $wpdb->query(
|
|
|
163 |
DELETE FROM $wpdb->postmeta
|
164 |
WHERE meta_key LIKE 'popup_display_%'
|
165 |
OR meta_key LIKE 'popup_close_%'
|
@@ -194,8 +196,8 @@ final class PUM_Admin_Upgrade_Routine_6 extends PUM_Admin_Upgrade_Routine {
|
|
194 |
// Setup the Popup Taxonomies
|
195 |
popmake_setup_taxonomies( true );
|
196 |
|
197 |
-
$categories =
|
198 |
-
$tags
|
199 |
|
200 |
if ( is_wp_error( $tags ) ) {
|
201 |
$tags = 0;
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'PUM_Admin_Upgrade_Routine' ) ) {
|
18 |
+
require_once POPMAKE_DIR . 'includes/admin/upgrades/class-pum-admin-upgrade-routine.php';
|
19 |
}
|
20 |
|
21 |
/**
|
47 |
*/
|
48 |
public static function run() {
|
49 |
if ( ! current_user_can( PUM_Admin_Upgrades::instance()->required_cap ) ) {
|
50 |
+
wp_die( __( 'You do not have permission to do upgrades', 'popup-maker' ), __( 'Error', 'popup-maker' ), [ 'response' => 403 ] );
|
51 |
}
|
52 |
|
53 |
ignore_user_abort( true );
|
76 |
$upgrades->set_arg( 'total', $total );
|
77 |
}
|
78 |
|
79 |
+
$popups = pum_get_popups(
|
80 |
+
[
|
81 |
+
'number' => $upgrades->get_arg( 'number' ),
|
82 |
+
'page' => $upgrades->get_arg( 'step' ),
|
83 |
+
'status' => [ 'any', 'trash', 'auto-draft' ],
|
84 |
+
'order' => 'ASC',
|
85 |
+
]
|
86 |
+
);
|
87 |
|
88 |
+
self::setup_valid_themes();
|
89 |
|
90 |
// Delete All old meta keys.
|
91 |
+
self::delete_all_old_meta_keys();
|
92 |
|
93 |
// Delete All orphaned meta keys.
|
94 |
+
self::delete_all_orphaned_meta_keys();
|
95 |
|
96 |
+
self::process_popup_cats_tags();
|
97 |
|
98 |
if ( $popups ) {
|
99 |
|
100 |
foreach ( $popups as $popup ) {
|
101 |
|
102 |
// Check that each popup has a valid theme id
|
103 |
+
if ( ! array_key_exists( $popup->get_theme_id(), self::$valid_themes ) ) {
|
104 |
// Set a valid theme.
|
105 |
+
update_post_meta( $popup->ID, 'popup_theme', self::$default_theme );
|
106 |
}
|
107 |
|
108 |
$completed ++;
|
110 |
|
111 |
if ( $completed < $total ) {
|
112 |
$upgrades->set_arg( 'completed', $completed );
|
113 |
+
self::next_step();
|
114 |
}
|
|
|
115 |
}
|
116 |
|
117 |
+
self::done();
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
* Create a list of valid popup themes.
|
122 |
*/
|
123 |
public static function setup_valid_themes() {
|
124 |
+
self::$valid_themes = [];
|
125 |
|
126 |
foreach ( pum_get_all_themes() as $theme ) {
|
127 |
+
self::$valid_themes[ $theme->ID ] = $theme;
|
128 |
if ( pum_get_default_theme_id() == $theme->ID ) {
|
129 |
+
self::$default_theme = $theme->ID;
|
130 |
}
|
131 |
}
|
132 |
|
133 |
+
if ( ! self::$default_theme ) {
|
134 |
+
reset( self::$valid_themes );
|
135 |
+
self::$default_theme = self::$valid_themes[ key( self::$valid_themes ) ]->ID;
|
|
|
136 |
}
|
137 |
}
|
138 |
|
142 |
public static function delete_all_orphaned_meta_keys() {
|
143 |
global $wpdb;
|
144 |
|
145 |
+
$wpdb->query(
|
146 |
+
"
|
147 |
DELETE pm
|
148 |
FROM $wpdb->postmeta pm
|
149 |
LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id
|
160 |
public static function delete_all_old_meta_keys() {
|
161 |
global $wpdb;
|
162 |
|
163 |
+
$query = $wpdb->query(
|
164 |
+
"
|
165 |
DELETE FROM $wpdb->postmeta
|
166 |
WHERE meta_key LIKE 'popup_display_%'
|
167 |
OR meta_key LIKE 'popup_close_%'
|
196 |
// Setup the Popup Taxonomies
|
197 |
popmake_setup_taxonomies( true );
|
198 |
|
199 |
+
$categories = wp_count_terms( 'popup_category', [ 'hide_empty' => true ] );
|
200 |
+
$tags = wp_count_terms( 'popup_tag', [ 'hide_empty' => true ] );
|
201 |
|
202 |
if ( is_wp_error( $tags ) ) {
|
203 |
$tags = 0;
|
includes/admin/upgrades/class-pum-admin-upgrade-routine.php
CHANGED
@@ -42,7 +42,7 @@ class PUM_Admin_Upgrade_Routine {
|
|
42 |
* @param string $redirect
|
43 |
*/
|
44 |
public static function redirect( $redirect = '' ) {
|
45 |
-
|
46 |
exit;
|
47 |
}
|
48 |
|
@@ -56,14 +56,16 @@ class PUM_Admin_Upgrade_Routine {
|
|
56 |
$upgrades->step_up();
|
57 |
|
58 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
59 |
-
echo wp_json_encode(
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
exit;
|
64 |
} else {
|
65 |
$redirect = add_query_arg( $upgrades->get_args(), admin_url() );
|
66 |
-
|
67 |
}
|
68 |
|
69 |
}
|
@@ -87,10 +89,12 @@ class PUM_Admin_Upgrade_Routine {
|
|
87 |
$upgrades->set_arg( 'completed', 0 );
|
88 |
$upgrades->set_arg( 'pum-upgrade', $next_routine );
|
89 |
|
90 |
-
echo wp_json_encode(
|
91 |
-
|
92 |
-
|
93 |
-
|
|
|
|
|
94 |
exit;
|
95 |
}
|
96 |
}
|
42 |
* @param string $redirect
|
43 |
*/
|
44 |
public static function redirect( $redirect = '' ) {
|
45 |
+
wp_safe_redirect( $redirect );
|
46 |
exit;
|
47 |
}
|
48 |
|
56 |
$upgrades->step_up();
|
57 |
|
58 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
59 |
+
echo wp_json_encode(
|
60 |
+
[
|
61 |
+
'status' => sprintf( __( 'Step %1$d of approximately %2$d running', 'popup-maker' ), $upgrades->get_arg( 'step' ), $upgrades->get_arg( 'steps' ) ),
|
62 |
+
'next' => $upgrades->get_args(),
|
63 |
+
]
|
64 |
+
);
|
65 |
exit;
|
66 |
} else {
|
67 |
$redirect = add_query_arg( $upgrades->get_args(), admin_url() );
|
68 |
+
self::redirect( $redirect );
|
69 |
}
|
70 |
|
71 |
}
|
89 |
$upgrades->set_arg( 'completed', 0 );
|
90 |
$upgrades->set_arg( 'pum-upgrade', $next_routine );
|
91 |
|
92 |
+
echo wp_json_encode(
|
93 |
+
[
|
94 |
+
'status' => sprintf( '<strong>%s</strong>', $upgrades->get_upgrade( $next_routine ) ),
|
95 |
+
'next' => $upgrades->get_args(),
|
96 |
+
]
|
97 |
+
);
|
98 |
exit;
|
99 |
}
|
100 |
}
|
includes/batch/upgrade/class-upgrade-v1_7-settings.php
CHANGED
@@ -28,13 +28,13 @@ class PUM_Upgrade_v1_7_Settings extends PUM_Abstract_Upgrade_Settings {
|
|
28 |
*
|
29 |
* @param array $settings Current global popup maker settings.
|
30 |
*/
|
31 |
-
public function process_settings( $settings =
|
32 |
-
$changed
|
33 |
|
34 |
// popmake_settings['newsletter_default_provider'] == '' should be changed to 'none'
|
35 |
if ( isset( $settings['newsletter_default_provider'] ) && $settings['newsletter_default_provider'] == '' ) {
|
36 |
$settings['newsletter_default_provider'] = 'none';
|
37 |
-
$changed
|
38 |
}
|
39 |
|
40 |
/**
|
28 |
*
|
29 |
* @param array $settings Current global popup maker settings.
|
30 |
*/
|
31 |
+
public function process_settings( $settings = [] ) {
|
32 |
+
$changed = false;
|
33 |
|
34 |
// popmake_settings['newsletter_default_provider'] == '' should be changed to 'none'
|
35 |
if ( isset( $settings['newsletter_default_provider'] ) && $settings['newsletter_default_provider'] == '' ) {
|
36 |
$settings['newsletter_default_provider'] = 'none';
|
37 |
+
$changed = true;
|
38 |
}
|
39 |
|
40 |
/**
|
includes/batch/upgrade/class-upgrade-v1_8-themes.php
CHANGED
@@ -29,21 +29,21 @@ class PUM_Upgrade_v1_8_Themes extends PUM_Abstract_Upgrade_Themes {
|
|
29 |
* @return array
|
30 |
*/
|
31 |
public function custom_query_args() {
|
32 |
-
return
|
33 |
-
'meta_query' =>
|
34 |
'relation' => 'OR',
|
35 |
-
|
36 |
'key' => 'popup_theme_data_version',
|
37 |
'compare' => 'NOT EXISTS',
|
38 |
'value' => 'deprecated', // Here for WP 3.9 or less.
|
39 |
-
|
40 |
-
|
41 |
'key' => 'popup_theme_data_version',
|
42 |
'compare' => '<',
|
43 |
'value' => 3,
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
}
|
48 |
|
49 |
/**
|
29 |
* @return array
|
30 |
*/
|
31 |
public function custom_query_args() {
|
32 |
+
return [
|
33 |
+
'meta_query' => [
|
34 |
'relation' => 'OR',
|
35 |
+
[
|
36 |
'key' => 'popup_theme_data_version',
|
37 |
'compare' => 'NOT EXISTS',
|
38 |
'value' => 'deprecated', // Here for WP 3.9 or less.
|
39 |
+
],
|
40 |
+
[
|
41 |
'key' => 'popup_theme_data_version',
|
42 |
'compare' => '<',
|
43 |
'value' => 3,
|
44 |
+
],
|
45 |
+
],
|
46 |
+
];
|
47 |
}
|
48 |
|
49 |
/**
|
includes/class-popmake-fields.php
CHANGED
@@ -30,33 +30,33 @@ class Popmake_Fields {
|
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
-
public $fields =
|
34 |
|
35 |
/**
|
36 |
* @var array
|
37 |
*/
|
38 |
-
public $sections =
|
39 |
|
40 |
/**
|
41 |
* @var array
|
42 |
*/
|
43 |
-
public $args =
|
44 |
|
45 |
/**
|
46 |
* @var array
|
47 |
*/
|
48 |
-
private static $instances =
|
49 |
|
50 |
/**
|
51 |
* @param array $args
|
52 |
*/
|
53 |
-
public function __construct( $args =
|
54 |
|
55 |
-
$sections = isset( $args['sections'] ) ? $args['sections'] :
|
56 |
-
'general' =>
|
57 |
'title' => __( 'General', 'popup-maker' ),
|
58 |
-
|
59 |
-
|
60 |
|
61 |
$this->add_sections( $sections );
|
62 |
|
@@ -74,7 +74,7 @@ class Popmake_Fields {
|
|
74 |
*
|
75 |
* @return mixed
|
76 |
*/
|
77 |
-
public static function instance( $args =
|
78 |
$class = get_called_class();
|
79 |
|
80 |
$class_key = md5( $class );
|
@@ -94,14 +94,16 @@ class Popmake_Fields {
|
|
94 |
*
|
95 |
* @param $id
|
96 |
* @param $title
|
97 |
-
* @param null
|
98 |
*/
|
99 |
public function register_section( $id, $title, $callback = null ) {
|
100 |
-
$this->add_section(
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
105 |
}
|
106 |
|
107 |
/**
|
@@ -110,9 +112,9 @@ class Popmake_Fields {
|
|
110 |
public function add_sections( $sections ) {
|
111 |
foreach ( $sections as $id => $section ) {
|
112 |
if ( ! is_array( $section ) ) {
|
113 |
-
$section =
|
114 |
'title' => $section,
|
115 |
-
|
116 |
}
|
117 |
|
118 |
if ( empty( $section['id'] ) ) {
|
@@ -127,57 +129,63 @@ class Popmake_Fields {
|
|
127 |
* @param $section
|
128 |
*/
|
129 |
public function add_section( $section ) {
|
130 |
-
$section = wp_parse_args(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
136 |
$this->sections[ $section['id'] ] = $section;
|
137 |
}
|
138 |
|
139 |
/**
|
140 |
* @param array $field
|
141 |
*/
|
142 |
-
public function add_field( $field =
|
143 |
-
|
144 |
-
$field = wp_parse_args(
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
181 |
|
182 |
if ( ! $field['name'] ) {
|
183 |
$field['name'] = $this->get_field_name( $field );
|
@@ -192,9 +200,9 @@ class Popmake_Fields {
|
|
192 |
|
193 |
/**
|
194 |
* @param array $fields
|
195 |
-
* @param null
|
196 |
*/
|
197 |
-
public function add_fields( $fields =
|
198 |
|
199 |
/**
|
200 |
* Switch the variables for backward compatibility with a
|
@@ -209,7 +217,7 @@ class Popmake_Fields {
|
|
209 |
foreach ( $fields as $key => $field ) {
|
210 |
|
211 |
// Either an undefined field or empty section. So lets skip it.
|
212 |
-
if ( empty
|
213 |
continue;
|
214 |
}
|
215 |
|
@@ -251,11 +259,11 @@ class Popmake_Fields {
|
|
251 |
}
|
252 |
|
253 |
if ( ! isset( $this->fields[ $section ] ) ) {
|
254 |
-
return
|
255 |
}
|
256 |
|
257 |
-
$non_priority_fields =
|
258 |
-
$priority_fields =
|
259 |
|
260 |
foreach ( $this->fields[ $section ] as $field_id => $field ) {
|
261 |
if ( ! isset( $field['priority'] ) || is_null( $field['priority'] ) ) {
|
@@ -265,7 +273,7 @@ class Popmake_Fields {
|
|
265 |
}
|
266 |
}
|
267 |
|
268 |
-
uasort( $priority_fields,
|
269 |
|
270 |
$fields = $priority_fields + $non_priority_fields;
|
271 |
|
@@ -276,7 +284,7 @@ class Popmake_Fields {
|
|
276 |
* @return array
|
277 |
*/
|
278 |
public function get_all_fields() {
|
279 |
-
$all_fields =
|
280 |
foreach ( $this->fields as $section => $fields ) {
|
281 |
$all_fields[ $section ] = $this->get_fields( $section );
|
282 |
}
|
@@ -298,18 +306,21 @@ class Popmake_Fields {
|
|
298 |
*
|
299 |
* @uses public $field_prefix
|
300 |
* @uses public $field_name_format
|
301 |
-
*
|
302 |
*/
|
303 |
public function get_field_name( $field ) {
|
304 |
-
return str_replace(
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
313 |
}
|
314 |
|
315 |
/**
|
@@ -318,7 +329,7 @@ class Popmake_Fields {
|
|
318 |
* @return array
|
319 |
*/
|
320 |
public function get_field_names( $section ) {
|
321 |
-
$names =
|
322 |
|
323 |
foreach ( $this->get_fields( $section ) as $id => $args ) {
|
324 |
$names[] = $this->get_field_name( $args );
|
@@ -333,22 +344,26 @@ class Popmake_Fields {
|
|
333 |
* @return mixed|string
|
334 |
*/
|
335 |
public function get_templ_name( $args ) {
|
336 |
-
return str_replace(
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
|
|
|
|
|
|
|
|
345 |
}
|
346 |
|
347 |
/**
|
348 |
* @param string $section
|
349 |
-
* @param array
|
350 |
*/
|
351 |
-
function render_fields_by_section( $section = 'general', $values =
|
352 |
foreach ( $this->get_fields( $section ) as $key => $args ) {
|
353 |
$value = isset( $values[ $args['id'] ] ) ? $values[ $args['id'] ] : null;
|
354 |
|
@@ -359,7 +374,7 @@ class Popmake_Fields {
|
|
359 |
/**
|
360 |
* @param array $values
|
361 |
*/
|
362 |
-
function render_fields( $values =
|
363 |
foreach ( $this->get_all_fields() as $section => $fields ) {
|
364 |
foreach ( $fields as $id => $args ) {
|
365 |
$value = isset( $values[ $args['id'] ] ) ? $values[ $args['id'] ] : null;
|
@@ -371,9 +386,9 @@ class Popmake_Fields {
|
|
371 |
|
372 |
/**
|
373 |
* @param array $args
|
374 |
-
* @param null
|
375 |
*/
|
376 |
-
public function render_field( $args =
|
377 |
|
378 |
// If no type default to text.
|
379 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
@@ -392,17 +407,17 @@ class Popmake_Fields {
|
|
392 |
} /**
|
393 |
* Check if core method exists and load that.
|
394 |
*/ elseif ( method_exists( $this, $type . '_callback' ) ) {
|
395 |
-
$function_name =
|
396 |
-
|
397 |
* No method exists, lets notify them the field type doesn't exist.
|
398 |
*/ else {
|
399 |
-
$function_name =
|
400 |
-
|
401 |
|
402 |
/**
|
403 |
* Call the determined method, passing the field args & $value to the callback.
|
404 |
*/
|
405 |
-
call_user_func_array( $function_name,
|
406 |
}
|
407 |
|
408 |
}
|
@@ -429,7 +444,7 @@ class Popmake_Fields {
|
|
429 |
/**
|
430 |
* @param array $args
|
431 |
*/
|
432 |
-
public function render_templ_field( $args =
|
433 |
|
434 |
// If no type default to text.
|
435 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
@@ -448,21 +463,21 @@ class Popmake_Fields {
|
|
448 |
} /**
|
449 |
* Check if core method exists and load that.
|
450 |
*/ elseif ( method_exists( $this, $type . '_templ_callback' ) ) {
|
451 |
-
$function_name =
|
452 |
-
|
453 |
* Check if the field type is hook.
|
454 |
*/ elseif ( $type == 'hook' ) {
|
455 |
-
$function_name =
|
456 |
-
|
457 |
* No method exists, lets notify them the field type doesn't exist.
|
458 |
*/ else {
|
459 |
-
$function_name =
|
460 |
-
|
461 |
|
462 |
/**
|
463 |
* Call the determined method, passing the field args & $value to the callback.
|
464 |
*/
|
465 |
-
call_user_func_array( $function_name,
|
466 |
}
|
467 |
|
468 |
}
|
@@ -470,16 +485,19 @@ class Popmake_Fields {
|
|
470 |
/**
|
471 |
* @param array $args
|
472 |
*/
|
473 |
-
public function field_before( $args =
|
474 |
$classes = is_array( $args ) ? $this->field_classes( $args ) : ( is_string( $args ) ? $args : '' );
|
475 |
-
?><div class="<?php echo esc_attr( $classes ); ?>"
|
|
|
476 |
}
|
477 |
|
478 |
/**
|
479 |
*
|
480 |
*/
|
481 |
public function field_after() {
|
482 |
-
|
|
|
|
|
483 |
}
|
484 |
|
485 |
/**
|
@@ -490,19 +508,22 @@ class Popmake_Fields {
|
|
490 |
*/
|
491 |
public function field_classes( $args, $class = null ) {
|
492 |
|
493 |
-
$args = wp_parse_args(
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
|
|
|
|
|
|
500 |
|
501 |
-
$classes =
|
502 |
'pum-field',
|
503 |
'pum-field-' . $args['id'],
|
504 |
'pum-field-' . $args['type'],
|
505 |
-
|
506 |
|
507 |
if ( $args['doclink'] != '' ) {
|
508 |
$classes[] = 'pum-field--has-doclink';
|
@@ -518,24 +539,32 @@ class Popmake_Fields {
|
|
518 |
}
|
519 |
|
520 |
public function field_description( $args ) {
|
521 |
-
if ( $args['desc'] != '' ) {
|
522 |
-
|
|
|
|
|
523 |
}
|
524 |
-
/*
|
525 |
if ( $args['doclink'] != '' ) { ?>
|
526 |
<a href="<?php echo esc_url( $args['doclink'] ); ?>" target="_blank" class="pum-doclink dashicons dashicons-editor-help"></a><?php
|
527 |
}
|
528 |
-
*/
|
529 |
}
|
530 |
|
531 |
public function field_label( $args ) {
|
532 |
-
if ( ! empty( $args['label'] ) ) {
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
}
|
540 |
}
|
541 |
|
@@ -559,18 +588,17 @@ class Popmake_Fields {
|
|
559 |
} /**
|
560 |
* Check if core method exists and load that.
|
561 |
*/ elseif ( method_exists( $this, $type . '_sanitize' ) ) {
|
562 |
-
$function_name =
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
if ( $function_name ) {
|
568 |
-
/**
|
569 |
-
* Call the determined method, passing the field args & $value to the callback.
|
570 |
-
*/
|
571 |
-
$value = call_user_func_array( $function_name, array( $value, $args ) );
|
572 |
-
}
|
573 |
|
|
|
|
|
|
|
|
|
|
|
|
|
574 |
}
|
575 |
|
576 |
$value = apply_filters( 'pum_settings_sanitize', $value, $args );
|
@@ -585,11 +613,10 @@ class Popmake_Fields {
|
|
585 |
*
|
586 |
* @return array|mixed $input Sanitized value
|
587 |
* @internal param array $input The value inputted in the field
|
588 |
-
*
|
589 |
*/
|
590 |
-
public function sanitize_fields( $values =
|
591 |
|
592 |
-
$sanitized_values =
|
593 |
|
594 |
foreach ( $this->get_all_fields() as $section => $fields ) {
|
595 |
foreach ( $fields as $field ) {
|
@@ -622,7 +649,7 @@ class Popmake_Fields {
|
|
622 |
return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
|
623 |
}
|
624 |
|
625 |
-
public function checkbox_sanitize( $value = null, $args =
|
626 |
if ( intval( $value ) == 1 ) {
|
627 |
return 1;
|
628 |
}
|
30 |
/**
|
31 |
* @var array
|
32 |
*/
|
33 |
+
public $fields = [];
|
34 |
|
35 |
/**
|
36 |
* @var array
|
37 |
*/
|
38 |
+
public $sections = [];
|
39 |
|
40 |
/**
|
41 |
* @var array
|
42 |
*/
|
43 |
+
public $args = [];
|
44 |
|
45 |
/**
|
46 |
* @var array
|
47 |
*/
|
48 |
+
private static $instances = [];
|
49 |
|
50 |
/**
|
51 |
* @param array $args
|
52 |
*/
|
53 |
+
public function __construct( $args = [] ) {
|
54 |
|
55 |
+
$sections = isset( $args['sections'] ) ? $args['sections'] : [
|
56 |
+
'general' => [
|
57 |
'title' => __( 'General', 'popup-maker' ),
|
58 |
+
],
|
59 |
+
];
|
60 |
|
61 |
$this->add_sections( $sections );
|
62 |
|
74 |
*
|
75 |
* @return mixed
|
76 |
*/
|
77 |
+
public static function instance( $args = [] ) {
|
78 |
$class = get_called_class();
|
79 |
|
80 |
$class_key = md5( $class );
|
94 |
*
|
95 |
* @param $id
|
96 |
* @param $title
|
97 |
+
* @param null $callback
|
98 |
*/
|
99 |
public function register_section( $id, $title, $callback = null ) {
|
100 |
+
$this->add_section(
|
101 |
+
[
|
102 |
+
'id' => $id,
|
103 |
+
'title' => $title,
|
104 |
+
'callback' => $callback,
|
105 |
+
]
|
106 |
+
);
|
107 |
}
|
108 |
|
109 |
/**
|
112 |
public function add_sections( $sections ) {
|
113 |
foreach ( $sections as $id => $section ) {
|
114 |
if ( ! is_array( $section ) ) {
|
115 |
+
$section = [
|
116 |
'title' => $section,
|
117 |
+
];
|
118 |
}
|
119 |
|
120 |
if ( empty( $section['id'] ) ) {
|
129 |
* @param $section
|
130 |
*/
|
131 |
public function add_section( $section ) {
|
132 |
+
$section = wp_parse_args(
|
133 |
+
$section,
|
134 |
+
[
|
135 |
+
'id' => null,
|
136 |
+
'title' => '',
|
137 |
+
'hidden' => false,
|
138 |
+
'callback' => null,
|
139 |
+
]
|
140 |
+
);
|
141 |
$this->sections[ $section['id'] ] = $section;
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
* @param array $field
|
146 |
*/
|
147 |
+
public function add_field( $field = [] ) {
|
148 |
+
|
149 |
+
$field = wp_parse_args(
|
150 |
+
$field,
|
151 |
+
[
|
152 |
+
'section' => 'general',
|
153 |
+
'type' => 'text',
|
154 |
+
'id' => null,
|
155 |
+
'label' => '',
|
156 |
+
'desc' => '',
|
157 |
+
'name' => null,
|
158 |
+
'templ_name' => null,
|
159 |
+
'size' => 'regular',
|
160 |
+
'options' => [],
|
161 |
+
'std' => null,
|
162 |
+
'rows' => 5,
|
163 |
+
'cols' => 50,
|
164 |
+
'min' => 0,
|
165 |
+
'max' => 50,
|
166 |
+
'force_minmax' => false,
|
167 |
+
'step' => 1,
|
168 |
+
'select2' => null,
|
169 |
+
'object_type' => 'post_type',
|
170 |
+
'object_key' => 'post',
|
171 |
+
'post_type' => null,
|
172 |
+
'taxonomy' => null,
|
173 |
+
'multiple' => null,
|
174 |
+
'as_array' => false,
|
175 |
+
'placeholder' => null,
|
176 |
+
'checkbox_val' => 1,
|
177 |
+
'allow_blank' => true,
|
178 |
+
'readonly' => false,
|
179 |
+
'required' => false,
|
180 |
+
'disabled' => false,
|
181 |
+
'hook' => null,
|
182 |
+
'unit' => __( 'ms', 'popup-maker' ),
|
183 |
+
'priority' => null,
|
184 |
+
'doclink' => '',
|
185 |
+
'button_type' => 'submit',
|
186 |
+
'class' => '',
|
187 |
+
]
|
188 |
+
);
|
189 |
|
190 |
if ( ! $field['name'] ) {
|
191 |
$field['name'] = $this->get_field_name( $field );
|
200 |
|
201 |
/**
|
202 |
* @param array $fields
|
203 |
+
* @param null $section
|
204 |
*/
|
205 |
+
public function add_fields( $fields = [], $section = null ) {
|
206 |
|
207 |
/**
|
208 |
* Switch the variables for backward compatibility with a
|
217 |
foreach ( $fields as $key => $field ) {
|
218 |
|
219 |
// Either an undefined field or empty section. So lets skip it.
|
220 |
+
if ( empty( $field ) ) {
|
221 |
continue;
|
222 |
}
|
223 |
|
259 |
}
|
260 |
|
261 |
if ( ! isset( $this->fields[ $section ] ) ) {
|
262 |
+
return [];
|
263 |
}
|
264 |
|
265 |
+
$non_priority_fields = [];
|
266 |
+
$priority_fields = [];
|
267 |
|
268 |
foreach ( $this->fields[ $section ] as $field_id => $field ) {
|
269 |
if ( ! isset( $field['priority'] ) || is_null( $field['priority'] ) ) {
|
273 |
}
|
274 |
}
|
275 |
|
276 |
+
uasort( $priority_fields, [ $this, 'sort_by_priority' ] );
|
277 |
|
278 |
$fields = $priority_fields + $non_priority_fields;
|
279 |
|
284 |
* @return array
|
285 |
*/
|
286 |
public function get_all_fields() {
|
287 |
+
$all_fields = [];
|
288 |
foreach ( $this->fields as $section => $fields ) {
|
289 |
$all_fields[ $section ] = $this->get_fields( $section );
|
290 |
}
|
306 |
*
|
307 |
* @uses public $field_prefix
|
308 |
* @uses public $field_name_format
|
|
|
309 |
*/
|
310 |
public function get_field_name( $field ) {
|
311 |
+
return str_replace(
|
312 |
+
[
|
313 |
+
'{$prefix}',
|
314 |
+
'{$section}',
|
315 |
+
'{$field}',
|
316 |
+
],
|
317 |
+
[
|
318 |
+
$this->field_prefix,
|
319 |
+
$field['section'],
|
320 |
+
$field['id'],
|
321 |
+
],
|
322 |
+
$this->field_name_format
|
323 |
+
);
|
324 |
}
|
325 |
|
326 |
/**
|
329 |
* @return array
|
330 |
*/
|
331 |
public function get_field_names( $section ) {
|
332 |
+
$names = [];
|
333 |
|
334 |
foreach ( $this->get_fields( $section ) as $id => $args ) {
|
335 |
$names[] = $this->get_field_name( $args );
|
344 |
* @return mixed|string
|
345 |
*/
|
346 |
public function get_templ_name( $args ) {
|
347 |
+
return str_replace(
|
348 |
+
[
|
349 |
+
'{$prefix}',
|
350 |
+
'{$section}',
|
351 |
+
'{$field}',
|
352 |
+
],
|
353 |
+
[
|
354 |
+
$this->field_prefix,
|
355 |
+
$args['section'] != 'general' ? ".{$args['section']}" : '',
|
356 |
+
$args['id'],
|
357 |
+
],
|
358 |
+
$this->templ_value_format
|
359 |
+
);
|
360 |
}
|
361 |
|
362 |
/**
|
363 |
* @param string $section
|
364 |
+
* @param array $values
|
365 |
*/
|
366 |
+
function render_fields_by_section( $section = 'general', $values = [] ) {
|
367 |
foreach ( $this->get_fields( $section ) as $key => $args ) {
|
368 |
$value = isset( $values[ $args['id'] ] ) ? $values[ $args['id'] ] : null;
|
369 |
|
374 |
/**
|
375 |
* @param array $values
|
376 |
*/
|
377 |
+
function render_fields( $values = [] ) {
|
378 |
foreach ( $this->get_all_fields() as $section => $fields ) {
|
379 |
foreach ( $fields as $id => $args ) {
|
380 |
$value = isset( $values[ $args['id'] ] ) ? $values[ $args['id'] ] : null;
|
386 |
|
387 |
/**
|
388 |
* @param array $args
|
389 |
+
* @param null $value
|
390 |
*/
|
391 |
+
public function render_field( $args = [], $value = null ) {
|
392 |
|
393 |
// If no type default to text.
|
394 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
407 |
} /**
|
408 |
* Check if core method exists and load that.
|
409 |
*/ elseif ( method_exists( $this, $type . '_callback' ) ) {
|
410 |
+
$function_name = [ $this, $type . '_callback' ];
|
411 |
+
} /**
|
412 |
* No method exists, lets notify them the field type doesn't exist.
|
413 |
*/ else {
|
414 |
+
$function_name = [ $this, 'missing_callback' ];
|
415 |
+
}
|
416 |
|
417 |
/**
|
418 |
* Call the determined method, passing the field args & $value to the callback.
|
419 |
*/
|
420 |
+
call_user_func_array( $function_name, [ $args, $value ] );
|
421 |
}
|
422 |
|
423 |
}
|
444 |
/**
|
445 |
* @param array $args
|
446 |
*/
|
447 |
+
public function render_templ_field( $args = [] ) {
|
448 |
|
449 |
// If no type default to text.
|
450 |
$type = ! empty( $args['type'] ) ? $args['type'] : 'text';
|
463 |
} /**
|
464 |
* Check if core method exists and load that.
|
465 |
*/ elseif ( method_exists( $this, $type . '_templ_callback' ) ) {
|
466 |
+
$function_name = [ $this, $type . '_templ_callback' ];
|
467 |
+
} /**
|
468 |
* Check if the field type is hook.
|
469 |
*/ elseif ( $type == 'hook' ) {
|
470 |
+
$function_name = [ $this, 'hook_callback' ];
|
471 |
+
} /**
|
472 |
* No method exists, lets notify them the field type doesn't exist.
|
473 |
*/ else {
|
474 |
+
$function_name = [ $this, 'missing_callback' ];
|
475 |
+
}
|
476 |
|
477 |
/**
|
478 |
* Call the determined method, passing the field args & $value to the callback.
|
479 |
*/
|
480 |
+
call_user_func_array( $function_name, [ $args, $this ] );
|
481 |
}
|
482 |
|
483 |
}
|
485 |
/**
|
486 |
* @param array $args
|
487 |
*/
|
488 |
+
public function field_before( $args = [] ) {
|
489 |
$classes = is_array( $args ) ? $this->field_classes( $args ) : ( is_string( $args ) ? $args : '' );
|
490 |
+
?><div class="<?php echo esc_attr( $classes ); ?>">
|
491 |
+
<?php
|
492 |
}
|
493 |
|
494 |
/**
|
495 |
*
|
496 |
*/
|
497 |
public function field_after() {
|
498 |
+
?>
|
499 |
+
</div>
|
500 |
+
<?php
|
501 |
}
|
502 |
|
503 |
/**
|
508 |
*/
|
509 |
public function field_classes( $args, $class = null ) {
|
510 |
|
511 |
+
$args = wp_parse_args(
|
512 |
+
$args,
|
513 |
+
[
|
514 |
+
'id' => '',
|
515 |
+
'class' => '',
|
516 |
+
'type' => '',
|
517 |
+
'desc' => '',
|
518 |
+
'doclink' => '',
|
519 |
+
]
|
520 |
+
);
|
521 |
|
522 |
+
$classes = [
|
523 |
'pum-field',
|
524 |
'pum-field-' . $args['id'],
|
525 |
'pum-field-' . $args['type'],
|
526 |
+
];
|
527 |
|
528 |
if ( $args['doclink'] != '' ) {
|
529 |
$classes[] = 'pum-field--has-doclink';
|
539 |
}
|
540 |
|
541 |
public function field_description( $args ) {
|
542 |
+
if ( $args['desc'] != '' ) {
|
543 |
+
?>
|
544 |
+
<p class="pum-desc"><?php echo esc_html( $args['desc'] ); ?></p>
|
545 |
+
<?php
|
546 |
}
|
547 |
+
/*
|
548 |
if ( $args['doclink'] != '' ) { ?>
|
549 |
<a href="<?php echo esc_url( $args['doclink'] ); ?>" target="_blank" class="pum-doclink dashicons dashicons-editor-help"></a><?php
|
550 |
}
|
551 |
+
*/
|
552 |
}
|
553 |
|
554 |
public function field_label( $args ) {
|
555 |
+
if ( ! empty( $args['label'] ) ) {
|
556 |
+
?>
|
557 |
+
<label for="<?php echo esc_attr( $args['id'] ); ?>">
|
558 |
+
<?php
|
559 |
+
echo esc_html( $args['label'] );
|
560 |
+
if ( $args['doclink'] != '' ) {
|
561 |
+
?>
|
562 |
+
<a href="<?php echo esc_url( $args['doclink'] ); ?>" target="_blank" class="pum-doclink dashicons dashicons-editor-help"></a>
|
563 |
+
<?php
|
564 |
+
}
|
565 |
+
?>
|
566 |
+
</label>
|
567 |
+
<?php
|
568 |
}
|
569 |
}
|
570 |
|
588 |
} /**
|
589 |
* Check if core method exists and load that.
|
590 |
*/ elseif ( method_exists( $this, $type . '_sanitize' ) ) {
|
591 |
+
$function_name = [ $this, $type . '_sanitize' ];
|
592 |
+
} else {
|
593 |
+
$function_name = null;
|
594 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
|
596 |
+
if ( $function_name ) {
|
597 |
+
/**
|
598 |
+
* Call the determined method, passing the field args & $value to the callback.
|
599 |
+
*/
|
600 |
+
$value = call_user_func_array( $function_name, [ $value, $args ] );
|
601 |
+
}
|
602 |
}
|
603 |
|
604 |
$value = apply_filters( 'pum_settings_sanitize', $value, $args );
|
613 |
*
|
614 |
* @return array|mixed $input Sanitized value
|
615 |
* @internal param array $input The value inputted in the field
|
|
|
616 |
*/
|
617 |
+
public function sanitize_fields( $values = [] ) {
|
618 |
|
619 |
+
$sanitized_values = [];
|
620 |
|
621 |
foreach ( $this->get_all_fields() as $section => $fields ) {
|
622 |
foreach ( $fields as $field ) {
|
649 |
return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
|
650 |
}
|
651 |
|
652 |
+
public function checkbox_sanitize( $value = null, $args = [] ) {
|
653 |
if ( intval( $value ) == 1 ) {
|
654 |
return 1;
|
655 |
}
|
includes/class-pum-fields.php
CHANGED
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
|
17 |
class PUM_Fields extends Popmake_Fields {
|
18 |
|
19 |
-
|
20 |
|
21 |
/**
|
22 |
* Hook Callback
|
@@ -28,7 +28,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
28 |
* @return void
|
29 |
*/
|
30 |
public function hook_callback( $args ) {
|
31 |
-
|
32 |
}
|
33 |
|
34 |
/**
|
@@ -41,16 +41,17 @@ class PUM_Fields extends Popmake_Fields {
|
|
41 |
* @return void
|
42 |
*/
|
43 |
public function heading_callback( $args ) { ?>
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
48 |
}
|
49 |
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
54 |
|
55 |
/**
|
56 |
* Button Callback
|
@@ -63,13 +64,15 @@ class PUM_Fields extends Popmake_Fields {
|
|
63 |
*/
|
64 |
public function button_callback( $args ) {
|
65 |
|
66 |
-
$this->field_before( $args );
|
|
|
67 |
|
68 |
-
<button type="<?php echo esc_attr( $args['button_type'] ); ?>" class="pum-button-<?php echo esc_attr( $args['size'] ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>"><?php echo esc_html( $args['label'] ); ?></button
|
|
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -77,14 +80,14 @@ class PUM_Fields extends Popmake_Fields {
|
|
77 |
*
|
78 |
* Renders text fields.
|
79 |
*
|
80 |
-
* @param array
|
81 |
*
|
82 |
* @param string $value
|
83 |
*/
|
84 |
public function text_callback( $args, $value = null ) {
|
85 |
|
86 |
if ( $args['type'] != 'text' ) {
|
87 |
-
$args['class'].= ' pum-field-text';
|
88 |
}
|
89 |
|
90 |
$this->field_before( $args );
|
@@ -93,13 +96,20 @@ class PUM_Fields extends Popmake_Fields {
|
|
93 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
94 |
}
|
95 |
|
96 |
-
$this->field_label( $args );
|
|
|
97 |
|
98 |
-
<input type="<?php echo esc_attr( $args['type'] ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
|
102 |
-
|
103 |
}
|
104 |
|
105 |
/**
|
@@ -118,13 +128,20 @@ class PUM_Fields extends Popmake_Fields {
|
|
118 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
119 |
}
|
120 |
|
121 |
-
$this->field_label( $args );
|
|
|
122 |
|
123 |
-
<textarea placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" cols="<?php echo esc_attr( $args['cols'] ); ?>" rows="<?php echo esc_attr( $args['rows'] ); ?>"
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
-
|
126 |
|
127 |
-
|
128 |
}
|
129 |
|
130 |
/**
|
@@ -135,16 +152,18 @@ class PUM_Fields extends Popmake_Fields {
|
|
135 |
* @param array $args Arguments passed by the setting
|
136 |
*
|
137 |
* @param $value
|
138 |
-
|
139 |
public function hidden_callback( $args, $value = null ) {
|
140 |
|
141 |
$class = $this->field_classes( $args );
|
142 |
|
143 |
if ( ! $value ) {
|
144 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
145 |
-
}
|
|
|
146 |
|
147 |
-
<input type="hidden" class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
|
|
|
148 |
}
|
149 |
|
150 |
/**
|
@@ -158,34 +177,44 @@ class PUM_Fields extends Popmake_Fields {
|
|
158 |
*/
|
159 |
public function select_callback( $args, $value = null ) {
|
160 |
|
161 |
-
|
162 |
-
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
177 |
$this->field_before( $args );
|
178 |
|
179 |
-
$this->field_label( $args );
|
180 |
-
|
181 |
-
|
182 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
foreach ( $args['options'] as $label => $option ) {
|
184 |
-
|
185 |
-
|
|
|
|
|
186 |
}
|
187 |
-
}
|
188 |
-
|
|
|
|
|
189 |
|
190 |
$this->field_description( $args );
|
191 |
|
@@ -204,13 +233,15 @@ class PUM_Fields extends Popmake_Fields {
|
|
204 |
public function checkbox_callback( $args, $value ) {
|
205 |
$this->field_before( $args );
|
206 |
|
207 |
-
$this->field_label( $args );
|
|
|
208 |
|
209 |
-
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( $args['checkbox_val'] ); ?>" <?php checked( 1, $value ); ?>
|
|
|
210 |
|
211 |
-
|
212 |
|
213 |
-
|
214 |
}
|
215 |
|
216 |
/**
|
@@ -222,7 +253,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
222 |
*
|
223 |
* @param array $values
|
224 |
*/
|
225 |
-
public function multicheck_callback( $args, $values =
|
226 |
$this->field_before( $args );
|
227 |
|
228 |
$this->field_label( $args );
|
@@ -231,20 +262,33 @@ class PUM_Fields extends Popmake_Fields {
|
|
231 |
foreach ( $args['options'] as $key => $option ) {
|
232 |
|
233 |
if ( ! is_array( $option ) ) {
|
234 |
-
$option =
|
235 |
'label' => $option,
|
236 |
-
|
237 |
}
|
238 |
|
239 |
-
$option = wp_parse_args(
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
}
|
249 |
}
|
250 |
|
@@ -253,16 +297,16 @@ class PUM_Fields extends Popmake_Fields {
|
|
253 |
$this->field_after();
|
254 |
}
|
255 |
|
256 |
-
|
257 |
|
258 |
-
|
259 |
|
260 |
/**
|
261 |
* Password Callback
|
262 |
*
|
263 |
* Renders password fields.
|
264 |
*
|
265 |
-
* @param array
|
266 |
*
|
267 |
* @param string $value
|
268 |
*/
|
@@ -277,7 +321,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
277 |
*
|
278 |
* Renders email fields.
|
279 |
*
|
280 |
-
* @param array
|
281 |
*
|
282 |
* @param string $value
|
283 |
*/
|
@@ -292,7 +336,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
292 |
*
|
293 |
* Renders search fields.
|
294 |
*
|
295 |
-
* @param array
|
296 |
*
|
297 |
* @param string $value
|
298 |
*/
|
@@ -307,7 +351,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
307 |
*
|
308 |
* Renders url fields.
|
309 |
*
|
310 |
-
* @param array
|
311 |
*
|
312 |
* @param string $value
|
313 |
*/
|
@@ -322,7 +366,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
322 |
*
|
323 |
* Renders telelphone number fields.
|
324 |
*
|
325 |
-
* @param array
|
326 |
*
|
327 |
* @param string $value
|
328 |
*/
|
@@ -337,7 +381,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
337 |
*
|
338 |
* Renders number fields.
|
339 |
*
|
340 |
-
* @param array
|
341 |
*
|
342 |
* @param string $value
|
343 |
*/
|
@@ -352,7 +396,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
352 |
*
|
353 |
* Renders range fields.
|
354 |
*
|
355 |
-
* @param array
|
356 |
*
|
357 |
* @param string $value
|
358 |
*/
|
@@ -362,9 +406,9 @@ class PUM_Fields extends Popmake_Fields {
|
|
362 |
$this->text_callback( $args, $value );
|
363 |
}
|
364 |
|
365 |
-
|
366 |
|
367 |
-
|
368 |
|
369 |
/**
|
370 |
* Object Select Callback
|
@@ -373,7 +417,7 @@ class PUM_Fields extends Popmake_Fields {
|
|
373 |
*
|
374 |
* @param array $args Arguments passed by the setting
|
375 |
*
|
376 |
-
* @param null
|
377 |
*/
|
378 |
public function objectselect_callback( $args, $value = null ) {
|
379 |
|
@@ -389,25 +433,36 @@ class PUM_Fields extends Popmake_Fields {
|
|
389 |
|
390 |
$multiple = null;
|
391 |
if ( $args['multiple'] ) {
|
392 |
-
$multiple
|
393 |
$args['class'] .= ' pum-field-select--multiple';
|
394 |
-
$args['name']
|
395 |
-
$value
|
396 |
-
$value
|
397 |
}
|
398 |
|
399 |
$this->field_before( $args );
|
400 |
|
401 |
-
$this->field_label( $args );
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
|
412 |
$this->field_description( $args );
|
413 |
|
@@ -425,8 +480,8 @@ class PUM_Fields extends Popmake_Fields {
|
|
425 |
*/
|
426 |
public function taxonomyselect_callback( $args, $value ) {
|
427 |
$args['object_type'] = 'taxonomy';
|
428 |
-
$args['object_key']
|
429 |
-
$args['class']
|
430 |
|
431 |
$this->objectselect_callback( $args, $value );
|
432 |
}
|
@@ -442,8 +497,8 @@ class PUM_Fields extends Popmake_Fields {
|
|
442 |
*/
|
443 |
public function postselect_callback( $args, $value = null ) {
|
444 |
$args['object_type'] = 'post_type';
|
445 |
-
$args['object_key']
|
446 |
-
$args['class']
|
447 |
|
448 |
$this->objectselect_callback( $args, $value );
|
449 |
}
|
@@ -464,34 +519,39 @@ class PUM_Fields extends Popmake_Fields {
|
|
464 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
465 |
}
|
466 |
|
467 |
-
$this->field_label( $args );
|
|
|
468 |
|
469 |
<input type="text"
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
<?php
|
|
|
|
|
|
|
478 |
data-force-minmax="<?php echo esc_attr( $args['force_minmax'] ); ?>"
|
479 |
/>
|
480 |
-
<span class="range-value-unit regular-text"><?php echo esc_html( $args['unit'] ); ?></span
|
|
|
481 |
|
482 |
-
|
483 |
|
484 |
-
|
485 |
}
|
486 |
-
|
487 |
|
488 |
-
|
489 |
|
490 |
public function heading_templ_callback( $args ) {
|
491 |
$this->heading_callback( $args );
|
492 |
}
|
493 |
|
494 |
-
|
495 |
|
496 |
|
497 |
public function text_templ_callback( $args ) {
|
@@ -502,13 +562,15 @@ class PUM_Fields extends Popmake_Fields {
|
|
502 |
|
503 |
$this->field_before( $args );
|
504 |
|
505 |
-
$this->field_label( $args );
|
|
|
506 |
|
507 |
-
<input type="<?php echo esc_attr( $args['type'] ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="{{data.<?php echo $args['templ_name']; ?>}}"
|
|
|
508 |
|
509 |
-
|
510 |
|
511 |
-
|
512 |
}
|
513 |
|
514 |
/**
|
@@ -615,37 +677,45 @@ class PUM_Fields extends Popmake_Fields {
|
|
615 |
* @param array $args Arguments passed by the setting
|
616 |
*/
|
617 |
public function hidden_templ_callback( $args ) {
|
618 |
-
$class = $this->field_classes( $args );
|
619 |
-
|
|
|
|
|
620 |
}
|
621 |
|
622 |
public function select_templ_callback( $args ) {
|
623 |
-
|
624 |
-
|
625 |
}
|
626 |
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
|
634 |
$this->field_before( $args );
|
635 |
|
636 |
-
$this->field_label( $args );
|
|
|
637 |
|
638 |
-
|
639 |
|
640 |
-
<?php
|
641 |
-
|
|
|
|
|
642 |
<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data.<?php echo esc_attr( $args['templ_name'] ); ?>, '<?php echo $option; ?>', true)}}>
|
643 |
<?php echo esc_html( $label ); ?>
|
644 |
-
</option
|
|
|
645 |
}
|
646 |
-
}
|
|
|
647 |
|
648 |
-
</select
|
|
|
649 |
|
650 |
$this->field_description( $args );
|
651 |
|
@@ -661,8 +731,8 @@ class PUM_Fields extends Popmake_Fields {
|
|
661 |
*/
|
662 |
public function postselect_templ_callback( $args ) {
|
663 |
$args['object_type'] = 'post_type';
|
664 |
-
$args['object_key']
|
665 |
-
$args['class']
|
666 |
|
667 |
$this->objectselect_templ_callback( $args );
|
668 |
|
@@ -675,16 +745,17 @@ class PUM_Fields extends Popmake_Fields {
|
|
675 |
|
676 |
$args['class'] .= ' pum-field-select pum-field-select2';
|
677 |
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
|
685 |
$this->field_before( $args );
|
686 |
|
687 |
-
$this->field_label( $args );
|
|
|
688 |
|
689 |
<# var templ_name = '<?php echo esc_attr( $args['templ_name'] ); ?>'; #>
|
690 |
|
@@ -692,15 +763,20 @@ class PUM_Fields extends Popmake_Fields {
|
|
692 |
data[templ_name] = '';
|
693 |
} #>
|
694 |
|
695 |
-
|
696 |
-
<?php
|
697 |
-
|
|
|
|
|
698 |
<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data[templ_name], '<?php echo $option; ?>', true)}}>
|
699 |
<?php echo esc_html( $label ); ?>
|
700 |
-
</option
|
|
|
701 |
}
|
702 |
-
}
|
703 |
-
|
|
|
|
|
704 |
|
705 |
$this->field_description( $args );
|
706 |
|
@@ -716,23 +792,25 @@ class PUM_Fields extends Popmake_Fields {
|
|
716 |
*/
|
717 |
public function taxonomyselect_templ_callback( $args ) {
|
718 |
$args['object_type'] = 'taxonomy';
|
719 |
-
$args['object_key']
|
720 |
-
$args['class']
|
721 |
$this->objectselect_templ_callback( $args );
|
722 |
}
|
723 |
|
724 |
public function checkbox_templ_callback( $args ) {
|
725 |
$this->field_before( $args );
|
726 |
|
727 |
-
$this->field_label( $args );
|
|
|
728 |
|
729 |
<# var checked = data.<?php echo esc_attr( $args['templ_name'] ); ?> !== undefined && data.<?php echo esc_attr( $args['templ_name'] ); ?> ? true : false; #>
|
730 |
|
731 |
-
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( $args['checkbox_val'] ); ?>" {{pumChecked(checked, true, true)}}
|
|
|
732 |
|
733 |
-
|
734 |
|
735 |
-
|
736 |
}
|
737 |
|
738 |
public function multicheck_templ_callback( $args ) {
|
@@ -740,20 +818,23 @@ class PUM_Fields extends Popmake_Fields {
|
|
740 |
|
741 |
$this->field_label( $args );
|
742 |
|
743 |
-
$this->field_description( $args );
|
|
|
744 |
|
745 |
<# var checked = data.<?php echo esc_attr( $args['templ_name'] ); ?> !== undefined && data.<?php echo esc_attr( $args['templ_name'] ); ?> && typeof data.<?php echo esc_attr( $args['templ_name'] ); ?> === 'object' ? data.<?php echo esc_attr( $args['templ_name'] ); ?> : {}; #>
|
746 |
|
747 |
<?php
|
748 |
|
749 |
if ( ! empty( $args['options'] ) ) {
|
750 |
-
foreach ( $args['options'] as $option => $label ) {
|
|
|
751 |
<# if (checked.<?php echo esc_attr( $option ); ?> === undefined) {
|
752 |
checked.<?php echo esc_attr( $option ); ?> = false;
|
753 |
} #>
|
754 |
|
755 |
<input name="<?php echo esc_attr( $args['name'] ); ?>[<?php echo esc_attr( $option ); ?>]" id="<?php echo esc_attr( $args['id'] ); ?>_<?php echo esc_attr( $option ); ?>" type="checkbox" value="<?php echo esc_html( $option ); ?>" {{pumChecked(checked.<?php echo esc_attr( $option ); ?>, '<?php echo $option; ?>', true)}} />
|
756 |
-
<label for="<?php echo esc_attr( $args['id'] ); ?>_<?php echo esc_attr( $option ); ?>"><?php echo esc_html( $label ); ?></label><br
|
|
|
757 |
}
|
758 |
}
|
759 |
|
@@ -765,19 +846,19 @@ class PUM_Fields extends Popmake_Fields {
|
|
765 |
$this->rangeslider_callback( $args, $value );
|
766 |
}
|
767 |
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
|
780 |
-
|
781 |
* TODO: Finish adding the following field types for HTML & underscore.js
|
782 |
*/
|
783 |
/*
|
@@ -791,32 +872,32 @@ class PUM_Fields extends Popmake_Fields {
|
|
791 |
*
|
792 |
* public function radio_callback( $args, $value ) {
|
793 |
* if ( ! empty( $args['options'] ) ) {
|
794 |
-
|
795 |
-
* foreach ( $args['options'] as $key => $option ) {
|
796 |
* $checked = false;
|
797 |
-
|
798 |
-
* $value = $this->get_option( $args['id'] );
|
799 |
-
|
800 |
-
* if ( $value == $key || ( ! $value && isset( $args['std'] ) && $args['std'] == $key ) ) {
|
801 |
* $checked = true;
|
802 |
* }
|
803 |
-
|
804 |
-
* echo '<input name="<?php echo esc_attr( $args['name'] ); ?>"" id="<?php echo esc_attr( $args['id'] ); ?>[<?php echo esc_attr( $key ); ?>]" type="radio" value="<?php echo esc_attr( $key ); ?>" ' . checked( true, $checked, false ) . '/> ';
|
805 |
* echo '<label for="<?php echo esc_attr( $args['id'] ); ?>[<?php echo esc_attr( $key ); ?>]">' . $option . '</label><br/>';
|
806 |
* }
|
807 |
-
|
808 |
-
* echo '<p class="pum-desc">' . $args['desc'] . '</p>';
|
809 |
-
|
810 |
-
* }
|
811 |
* }
|
812 |
-
|
813 |
-
*
|
814 |
-
|
815 |
-
*
|
816 |
-
*
|
817 |
-
|
818 |
-
*
|
819 |
-
*
|
|
|
820 |
* Color select Callback
|
821 |
*
|
822 |
* Renders color select fields.
|
@@ -826,29 +907,29 @@ class PUM_Fields extends Popmake_Fields {
|
|
826 |
* @return void
|
827 |
*
|
828 |
* public function color_select_callback( $args ) {
|
829 |
-
|
830 |
-
* $value = $this->get_option( $args['id'] );
|
831 |
-
|
832 |
-
* if ( ! $value ) {
|
833 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
834 |
* }
|
835 |
-
|
836 |
-
* $html = '<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>"/>';
|
837 |
-
|
838 |
-
* if ( ! empty( $args['options'] ) ) {
|
839 |
* foreach ( $args['options'] as $option => $color ) {
|
840 |
* $selected = selected( $option, $value, false );
|
841 |
* $html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
842 |
* }
|
843 |
* }
|
844 |
-
|
845 |
-
* $html .= '</select>';
|
846 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
847 |
-
|
848 |
-
* echo $html;
|
849 |
* }
|
850 |
-
|
851 |
-
* /**
|
852 |
* Rich Editor Callback
|
853 |
*
|
854 |
* Renders rich editor fields.
|
@@ -860,14 +941,14 @@ class PUM_Fields extends Popmake_Fields {
|
|
860 |
* public function rich_editor_callback( $args ) {
|
861 |
* global $wp_version;
|
862 |
* $value = $this->get_option( $args['id'] );
|
863 |
-
|
864 |
-
* if ( ! $value ) {
|
865 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
866 |
* }
|
867 |
-
|
868 |
-
* $rows = isset( $args['size'] ) ? $args['size'] : 20;
|
869 |
-
|
870 |
-
* if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
|
871 |
* ob_start();
|
872 |
* wp_editor( stripslashes( $value ), $this->options_key . '_' . $args['id'], array(
|
873 |
* 'textarea_name' => '' . $this->options_key . '[' . $args['id'] . ']',
|
@@ -877,13 +958,13 @@ class PUM_Fields extends Popmake_Fields {
|
|
877 |
* } else {
|
878 |
* $html = '<textarea class="large-text" rows="10" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
879 |
* }
|
880 |
-
|
881 |
-
* $html .= '<br/><label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
882 |
-
|
883 |
-
* echo $html;
|
884 |
* }
|
885 |
-
|
886 |
-
* /**
|
887 |
* Upload Callback
|
888 |
*
|
889 |
* Renders upload fields.
|
@@ -894,20 +975,20 @@ class PUM_Fields extends Popmake_Fields {
|
|
894 |
*
|
895 |
* public function upload_callback( $args ) {
|
896 |
* $value = $this->get_option( $args['id'] );
|
897 |
-
|
898 |
-
* if ( ! $value ) {
|
899 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
900 |
* }
|
901 |
-
|
902 |
-
* $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
903 |
* $html = '<input type="text" class="' . $size . '-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( stripslashes( $value ) ) . '"/>';
|
904 |
* $html .= '<span> <input type="button" class="' . $this->options_key . '_upload_button button-secondary" value="' . __( 'Upload File' ) . '"/></span>';
|
905 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
906 |
-
|
907 |
-
* echo $html;
|
908 |
* }
|
909 |
-
|
910 |
-
* /**
|
911 |
* Color picker Callback
|
912 |
*
|
913 |
* Renders color picker fields.
|
@@ -918,20 +999,20 @@ class PUM_Fields extends Popmake_Fields {
|
|
918 |
*
|
919 |
* public function color_callback( $args ) {
|
920 |
* $value = $this->get_option( $args['id'] );
|
921 |
-
|
922 |
-
* if ( ! $value ) {
|
923 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
924 |
* }
|
925 |
-
|
926 |
-
* $default = isset( $args['std'] ) ? $args['std'] : '';
|
927 |
-
|
928 |
-
* $html = '<input type="text" class="di-color-picker" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( $value ) . '" data-default-color="' . echo esc_attr( $default ) . '" />';
|
929 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
930 |
-
|
931 |
-
* echo $html;
|
932 |
* }
|
933 |
-
|
934 |
-
* /**
|
935 |
* Descriptive text callback.
|
936 |
*
|
937 |
* Renders descriptive text onto the settings field.
|
@@ -943,8 +1024,8 @@ class PUM_Fields extends Popmake_Fields {
|
|
943 |
* public function descriptive_text_callback( $args ) {
|
944 |
* echo esc_html( $args['desc'] );
|
945 |
* }
|
946 |
-
|
947 |
-
* /**
|
948 |
* Registers the license field callback for Software Licensing
|
949 |
*
|
950 |
* @param array $args Arguments passed by the setting
|
@@ -953,23 +1034,23 @@ class PUM_Fields extends Popmake_Fields {
|
|
953 |
*
|
954 |
* public function license_key_callback( $args ) {
|
955 |
* $value = $this->get_option( $args['id'] );
|
956 |
-
|
957 |
-
* if ( ! $value ) {
|
958 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
959 |
* }
|
960 |
-
|
961 |
-
* $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
962 |
-
|
963 |
-
* $html = '<input type="' . ( $value == '' ? 'text' : 'password' ) . '" class="' . $size . '-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( $value ) . '"/>';
|
964 |
-
|
965 |
-
* if ( 'valid' == get_option( $args['options']['is_valid_license_option'] ) ) {
|
966 |
* $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License' ) . '"/>';
|
967 |
* }
|
968 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
969 |
-
|
970 |
-
* echo $html;
|
971 |
* }
|
972 |
-
|
973 |
-
|
974 |
|
975 |
}
|
16 |
|
17 |
class PUM_Fields extends Popmake_Fields {
|
18 |
|
19 |
+
// region Non Fields
|
20 |
|
21 |
/**
|
22 |
* Hook Callback
|
28 |
* @return void
|
29 |
*/
|
30 |
public function hook_callback( $args ) {
|
31 |
+
do_action( $args['hook'], $args );
|
32 |
}
|
33 |
|
34 |
/**
|
41 |
* @return void
|
42 |
*/
|
43 |
public function heading_callback( $args ) { ?>
|
44 |
+
</td></tr></tbody></table>
|
45 |
+
<h2 class="pum-setting-heading"><?php echo esc_html( $args['desc'] ); ?></h2>
|
46 |
+
<hr/>
|
47 |
+
<table class="form-table"><tbody><tr style="display:none;"><td colspan="2">
|
48 |
+
<?php
|
49 |
}
|
50 |
|
51 |
|
52 |
+
// endregion Non Fields
|
53 |
|
54 |
+
// region Standard Fields
|
55 |
|
56 |
/**
|
57 |
* Button Callback
|
64 |
*/
|
65 |
public function button_callback( $args ) {
|
66 |
|
67 |
+
$this->field_before( $args );
|
68 |
+
?>
|
69 |
|
70 |
+
<button type="<?php echo esc_attr( $args['button_type'] ); ?>" class="pum-button-<?php echo esc_attr( $args['size'] ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>"><?php echo esc_html( $args['label'] ); ?></button>
|
71 |
+
<?php
|
72 |
|
73 |
+
$this->field_description( $args );
|
74 |
|
75 |
+
$this->field_after();
|
76 |
}
|
77 |
|
78 |
/**
|
80 |
*
|
81 |
* Renders text fields.
|
82 |
*
|
83 |
+
* @param array $args Arguments passed by the setting
|
84 |
*
|
85 |
* @param string $value
|
86 |
*/
|
87 |
public function text_callback( $args, $value = null ) {
|
88 |
|
89 |
if ( $args['type'] != 'text' ) {
|
90 |
+
$args['class'] .= ' pum-field-text';
|
91 |
}
|
92 |
|
93 |
$this->field_before( $args );
|
96 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
97 |
}
|
98 |
|
99 |
+
$this->field_label( $args );
|
100 |
+
?>
|
101 |
|
102 |
+
<input type="<?php echo esc_attr( $args['type'] ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"
|
103 |
+
<?php
|
104 |
+
if ( $args['required'] ) {
|
105 |
+
echo 'required'; }
|
106 |
+
?>
|
107 |
+
/>
|
108 |
+
<?php
|
109 |
|
110 |
+
$this->field_description( $args );
|
111 |
|
112 |
+
$this->field_after();
|
113 |
}
|
114 |
|
115 |
/**
|
128 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
129 |
}
|
130 |
|
131 |
+
$this->field_label( $args );
|
132 |
+
?>
|
133 |
|
134 |
+
<textarea placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" cols="<?php echo esc_attr( $args['cols'] ); ?>" rows="<?php echo esc_attr( $args['rows'] ); ?>"
|
135 |
+
<?php
|
136 |
+
if ( $args['required'] ) {
|
137 |
+
echo 'required'; }
|
138 |
+
?>
|
139 |
+
><?php echo esc_textarea( stripslashes( $value ) ); ?></textarea>
|
140 |
+
<?php
|
141 |
|
142 |
+
$this->field_description( $args );
|
143 |
|
144 |
+
$this->field_after();
|
145 |
}
|
146 |
|
147 |
/**
|
152 |
* @param array $args Arguments passed by the setting
|
153 |
*
|
154 |
* @param $value
|
155 |
+
*/
|
156 |
public function hidden_callback( $args, $value = null ) {
|
157 |
|
158 |
$class = $this->field_classes( $args );
|
159 |
|
160 |
if ( ! $value ) {
|
161 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
162 |
+
}
|
163 |
+
?>
|
164 |
|
165 |
+
<input type="hidden" class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( stripslashes( $value ) ); ?>"/>
|
166 |
+
<?php
|
167 |
}
|
168 |
|
169 |
/**
|
177 |
*/
|
178 |
public function select_callback( $args, $value = null ) {
|
179 |
|
180 |
+
if ( isset( $args['select2'] ) ) {
|
181 |
+
$args['class'] .= ' pum-field-select2';
|
182 |
}
|
183 |
|
184 |
+
if ( ! $value ) {
|
185 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
186 |
+
}
|
187 |
|
188 |
+
$multiple = null;
|
189 |
+
if ( $args['multiple'] ) {
|
190 |
+
$multiple = 'multiple';
|
191 |
+
$args['class'] .= ' pum-field-select--multiple';
|
192 |
+
$args['name'] .= $args['as_array'] ? '[]' : '';
|
193 |
+
$value = ! is_array( $value ) ? [ $value ] : $value;
|
194 |
+
}
|
195 |
|
196 |
$this->field_before( $args );
|
197 |
|
198 |
+
$this->field_label( $args );
|
199 |
+
?>
|
200 |
+
|
201 |
+
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> <?php
|
202 |
+
if ( $args['required'] ) {
|
203 |
+
echo 'required'; }
|
204 |
+
?>
|
205 |
+
>
|
206 |
+
<?php
|
207 |
+
if ( ! empty( $args['options'] ) ) {
|
208 |
foreach ( $args['options'] as $label => $option ) {
|
209 |
+
$selected = ( ! $multiple && $option == $value ) || ( $multiple && in_array( $option, $value ) );
|
210 |
+
?>
|
211 |
+
<option value="<?php echo esc_attr( $option ); ?>" <?php selected( 1, $selected ); ?>><?php echo esc_html( $label ); ?></option>
|
212 |
+
<?php
|
213 |
}
|
214 |
+
}
|
215 |
+
?>
|
216 |
+
</select>
|
217 |
+
<?php
|
218 |
|
219 |
$this->field_description( $args );
|
220 |
|
233 |
public function checkbox_callback( $args, $value ) {
|
234 |
$this->field_before( $args );
|
235 |
|
236 |
+
$this->field_label( $args );
|
237 |
+
?>
|
238 |
|
239 |
+
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( $args['checkbox_val'] ); ?>" <?php checked( 1, $value ); ?> />
|
240 |
+
<?php
|
241 |
|
242 |
+
$this->field_description( $args );
|
243 |
|
244 |
+
$this->field_after();
|
245 |
}
|
246 |
|
247 |
/**
|
253 |
*
|
254 |
* @param array $values
|
255 |
*/
|
256 |
+
public function multicheck_callback( $args, $values = [] ) {
|
257 |
$this->field_before( $args );
|
258 |
|
259 |
$this->field_label( $args );
|
262 |
foreach ( $args['options'] as $key => $option ) {
|
263 |
|
264 |
if ( ! is_array( $option ) ) {
|
265 |
+
$option = [
|
266 |
'label' => $option,
|
267 |
+
];
|
268 |
}
|
269 |
|
270 |
+
$option = wp_parse_args(
|
271 |
+
$option,
|
272 |
+
[
|
273 |
+
'label' => '',
|
274 |
+
'required' => false,
|
275 |
+
'disabled' => false,
|
276 |
+
]
|
277 |
+
);
|
278 |
+
|
279 |
+
$checked = isset( $values[ $key ] );
|
280 |
+
?>
|
281 |
+
<input name="<?php echo esc_attr( $args['name'] ); ?>[<?php echo esc_attr( $key ); ?>]" id="<?php echo esc_attr( $args['id'] . '_' . $key ); ?>" type="checkbox" value="<?php echo esc_html( $option ); ?>" <?php checked( true, $checked ); ?> <?php
|
282 |
+
if ( $option['disabled'] ) {
|
283 |
+
echo 'disabled="disabled"'; }
|
284 |
+
?>
|
285 |
+
<?php
|
286 |
+
if ( $option['required'] ) {
|
287 |
+
echo 'required'; }
|
288 |
+
?>
|
289 |
+
/>
|
290 |
+
<label for="<?php echo esc_attr( $args['id'] . '_' . $key ); ?>"><?php echo esc_html( $option['label'] ); ?></label><br/>
|
291 |
+
<?php
|
292 |
}
|
293 |
}
|
294 |
|
297 |
$this->field_after();
|
298 |
}
|
299 |
|
300 |
+
// endregion Standard Fields
|
301 |
|
302 |
+
// region HTML5 Text Fields
|
303 |
|
304 |
/**
|
305 |
* Password Callback
|
306 |
*
|
307 |
* Renders password fields.
|
308 |
*
|
309 |
+
* @param array $args Arguments passed by the setting
|
310 |
*
|
311 |
* @param string $value
|
312 |
*/
|
321 |
*
|
322 |
* Renders email fields.
|
323 |
*
|
324 |
+
* @param array $args Arguments passed by the setting
|
325 |
*
|
326 |
* @param string $value
|
327 |
*/
|
336 |
*
|
337 |
* Renders search fields.
|
338 |
*
|
339 |
+
* @param array $args Arguments passed by the setting
|
340 |
*
|
341 |
* @param string $value
|
342 |
*/
|
351 |
*
|
352 |
* Renders url fields.
|
353 |
*
|
354 |
+
* @param array $args Arguments passed by the setting
|
355 |
*
|
356 |
* @param string $value
|
357 |
*/
|
366 |
*
|
367 |
* Renders telelphone number fields.
|
368 |
*
|
369 |
+
* @param array $args Arguments passed by the setting
|
370 |
*
|
371 |
* @param string $value
|
372 |
*/
|
381 |
*
|
382 |
* Renders number fields.
|
383 |
*
|
384 |
+
* @param array $args Arguments passed by the setting
|
385 |
*
|
386 |
* @param string $value
|
387 |
*/
|
396 |
*
|
397 |
* Renders range fields.
|
398 |
*
|
399 |
+
* @param array $args Arguments passed by the setting
|
400 |
*
|
401 |
* @param string $value
|
402 |
*/
|
406 |
$this->text_callback( $args, $value );
|
407 |
}
|
408 |
|
409 |
+
// endregion HTML5 Text Fields
|
410 |
|
411 |
+
// region Custom Fields (post_type, taxonomy, object, rangeslider)
|
412 |
|
413 |
/**
|
414 |
* Object Select Callback
|
417 |
*
|
418 |
* @param array $args Arguments passed by the setting
|
419 |
*
|
420 |
+
* @param null $value
|
421 |
*/
|
422 |
public function objectselect_callback( $args, $value = null ) {
|
423 |
|
433 |
|
434 |
$multiple = null;
|
435 |
if ( $args['multiple'] ) {
|
436 |
+
$multiple = 'multiple';
|
437 |
$args['class'] .= ' pum-field-select--multiple';
|
438 |
+
$args['name'] .= $args['as_array'] ? '[]' : '';
|
439 |
+
$value = ! is_array( $value ) ? [ $value ] : $value;
|
440 |
+
$value = wp_parse_id_list( $value );
|
441 |
}
|
442 |
|
443 |
$this->field_before( $args );
|
444 |
|
445 |
+
$this->field_label( $args );
|
446 |
+
?>
|
447 |
+
|
448 |
+
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> data-objecttype="<?php echo esc_attr( $args['object_type'] ); ?>" data-objectkey="<?php echo esc_attr( $args['object_key'] ); ?>" data-current="<?php echo maybe_json_attr( $value, true ); ?>"
|
449 |
+
<?php
|
450 |
+
if ( $args['required'] ) {
|
451 |
+
echo 'required'; }
|
452 |
+
?>
|
453 |
+
>
|
454 |
+
<?php
|
455 |
+
if ( ! empty( $args['options'] ) ) {
|
456 |
+
foreach ( $args['options'] as $label => $option ) {
|
457 |
+
$selected = ( $multiple && in_array( $option, $value ) ) || ( ! $multiple && $option == $value );
|
458 |
+
?>
|
459 |
+
<option value="<?php echo esc_attr( $option ); ?>" <?php selected( 1, $selected ); ?>><?php echo esc_html( $label ); ?></option>
|
460 |
+
<?php
|
461 |
+
}
|
462 |
+
}
|
463 |
+
?>
|
464 |
+
</select>
|
465 |
+
<?php
|
466 |
|
467 |
$this->field_description( $args );
|
468 |
|
480 |
*/
|
481 |
public function taxonomyselect_callback( $args, $value ) {
|
482 |
$args['object_type'] = 'taxonomy';
|
483 |
+
$args['object_key'] = $args['taxonomy'];
|
484 |
+
$args['class'] = ! empty( $args['class'] ) ? $args['class'] : '' . ' pum-taxonomyselect';
|
485 |
|
486 |
$this->objectselect_callback( $args, $value );
|
487 |
}
|
497 |
*/
|
498 |
public function postselect_callback( $args, $value = null ) {
|
499 |
$args['object_type'] = 'post_type';
|
500 |
+
$args['object_key'] = $args['post_type'];
|
501 |
+
$args['class'] = ! empty( $args['class'] ) ? $args['class'] : '' . ' pum-postselect';
|
502 |
|
503 |
$this->objectselect_callback( $args, $value );
|
504 |
}
|
519 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
520 |
}
|
521 |
|
522 |
+
$this->field_label( $args );
|
523 |
+
?>
|
524 |
|
525 |
<input type="text"
|
526 |
+
value="<?php echo $value; ?>"
|
527 |
+
name="<?php echo esc_attr( $args['name'] ); ?>"
|
528 |
+
id="<?php echo esc_attr( $args['id'] ); ?>"
|
529 |
+
class="pum-range-manual popmake-range-manual"
|
530 |
+
step="<?php echo esc_attr( $args['step'] ); ?>"
|
531 |
+
min="<?php echo esc_attr( $args['min'] ); ?>"
|
532 |
+
max="<?php echo esc_attr( $args['max'] ); ?>"
|
533 |
+
<?php
|
534 |
+
if ( $args['required'] ) {
|
535 |
+
echo 'required'; }
|
536 |
+
?>
|
537 |
data-force-minmax="<?php echo esc_attr( $args['force_minmax'] ); ?>"
|
538 |
/>
|
539 |
+
<span class="range-value-unit regular-text"><?php echo esc_html( $args['unit'] ); ?></span>
|
540 |
+
<?php
|
541 |
|
542 |
+
$this->field_description( $args );
|
543 |
|
544 |
+
$this->field_after();
|
545 |
}
|
546 |
+
// endregion Custom Fields (post_type, taxonomy, object, rangeslider)
|
547 |
|
548 |
+
// region Templ Non Fields
|
549 |
|
550 |
public function heading_templ_callback( $args ) {
|
551 |
$this->heading_callback( $args );
|
552 |
}
|
553 |
|
554 |
+
// endregion Non Fields
|
555 |
|
556 |
|
557 |
public function text_templ_callback( $args ) {
|
562 |
|
563 |
$this->field_before( $args );
|
564 |
|
565 |
+
$this->field_label( $args );
|
566 |
+
?>
|
567 |
|
568 |
+
<input type="<?php echo esc_attr( $args['type'] ); ?>" placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" class="<?php echo esc_attr( $args['size'] ); ?>-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="{{data.<?php echo $args['templ_name']; ?>}}" />
|
569 |
+
<?php
|
570 |
|
571 |
+
$this->field_description( $args );
|
572 |
|
573 |
+
$this->field_after();
|
574 |
}
|
575 |
|
576 |
/**
|
677 |
* @param array $args Arguments passed by the setting
|
678 |
*/
|
679 |
public function hidden_templ_callback( $args ) {
|
680 |
+
$class = $this->field_classes( $args );
|
681 |
+
?>
|
682 |
+
<input type="hidden" class="<?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="{{data.<?php echo $args['templ_name']; ?>}}"/>
|
683 |
+
<?php
|
684 |
}
|
685 |
|
686 |
public function select_templ_callback( $args ) {
|
687 |
+
if ( $args['select2'] ) {
|
688 |
+
$args['class'] .= ' pum-field-select2';
|
689 |
}
|
690 |
|
691 |
+
$multiple = null;
|
692 |
+
if ( $args['multiple'] ) {
|
693 |
+
$multiple = 'multiple';
|
694 |
+
$args['class'] .= ' pum-field-select--multiple';
|
695 |
+
$args['name'] .= $args['as_array'] ? '[]' : '';
|
696 |
+
}
|
697 |
|
698 |
$this->field_before( $args );
|
699 |
|
700 |
+
$this->field_label( $args );
|
701 |
+
?>
|
702 |
|
703 |
+
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?>>
|
704 |
|
705 |
+
<?php
|
706 |
+
if ( ! empty( $args['options'] ) ) {
|
707 |
+
foreach ( $args['options'] as $label => $option ) {
|
708 |
+
?>
|
709 |
<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data.<?php echo esc_attr( $args['templ_name'] ); ?>, '<?php echo $option; ?>', true)}}>
|
710 |
<?php echo esc_html( $label ); ?>
|
711 |
+
</option>
|
712 |
+
<?php
|
713 |
}
|
714 |
+
}
|
715 |
+
?>
|
716 |
|
717 |
+
</select>
|
718 |
+
<?php
|
719 |
|
720 |
$this->field_description( $args );
|
721 |
|
731 |
*/
|
732 |
public function postselect_templ_callback( $args ) {
|
733 |
$args['object_type'] = 'post_type';
|
734 |
+
$args['object_key'] = $args['post_type'];
|
735 |
+
$args['class'] .= ' pum-postselect';
|
736 |
|
737 |
$this->objectselect_templ_callback( $args );
|
738 |
|
745 |
|
746 |
$args['class'] .= ' pum-field-select pum-field-select2';
|
747 |
|
748 |
+
$multiple = null;
|
749 |
+
if ( $args['multiple'] ) {
|
750 |
+
$multiple = 'multiple';
|
751 |
+
$args['class'] .= ' pum-field-select--multiple';
|
752 |
+
$args['name'] .= $args['as_array'] ? '[]' : '';
|
753 |
+
}
|
754 |
|
755 |
$this->field_before( $args );
|
756 |
|
757 |
+
$this->field_label( $args );
|
758 |
+
?>
|
759 |
|
760 |
<# var templ_name = '<?php echo esc_attr( $args['templ_name'] ); ?>'; #>
|
761 |
|
763 |
data[templ_name] = '';
|
764 |
} #>
|
765 |
|
766 |
+
<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" data-placeholder="<?php echo esc_attr( $args['placeholder'] ); ?>" data-allow-clear="true" <?php echo $multiple; ?> data-objecttype="<?php echo esc_attr( $args['object_type'] ); ?>" data-objectkey="<?php echo esc_attr( $args['object_key'] ); ?>">
|
767 |
+
<?php
|
768 |
+
if ( ! empty( $args['options'] ) ) {
|
769 |
+
foreach ( $args['options'] as $label => $option ) {
|
770 |
+
?>
|
771 |
<option value="<?php echo esc_attr( $option ); ?>" {{pumSelected(data[templ_name], '<?php echo $option; ?>', true)}}>
|
772 |
<?php echo esc_html( $label ); ?>
|
773 |
+
</option>
|
774 |
+
<?php
|
775 |
}
|
776 |
+
}
|
777 |
+
?>
|
778 |
+
</select>
|
779 |
+
<?php
|
780 |
|
781 |
$this->field_description( $args );
|
782 |
|
792 |
*/
|
793 |
public function taxonomyselect_templ_callback( $args ) {
|
794 |
$args['object_type'] = 'taxonomy';
|
795 |
+
$args['object_key'] = $args['taxonomy'];
|
796 |
+
$args['class'] .= ' pum-field-taxonomyselect';
|
797 |
$this->objectselect_templ_callback( $args );
|
798 |
}
|
799 |
|
800 |
public function checkbox_templ_callback( $args ) {
|
801 |
$this->field_before( $args );
|
802 |
|
803 |
+
$this->field_label( $args );
|
804 |
+
?>
|
805 |
|
806 |
<# var checked = data.<?php echo esc_attr( $args['templ_name'] ); ?> !== undefined && data.<?php echo esc_attr( $args['templ_name'] ); ?> ? true : false; #>
|
807 |
|
808 |
+
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="<?php echo esc_attr( $args['checkbox_val'] ); ?>" {{pumChecked(checked, true, true)}} />
|
809 |
+
<?php
|
810 |
|
811 |
+
$this->field_description( $args );
|
812 |
|
813 |
+
$this->field_after();
|
814 |
}
|
815 |
|
816 |
public function multicheck_templ_callback( $args ) {
|
818 |
|
819 |
$this->field_label( $args );
|
820 |
|
821 |
+
$this->field_description( $args );
|
822 |
+
?>
|
823 |
|
824 |
<# var checked = data.<?php echo esc_attr( $args['templ_name'] ); ?> !== undefined && data.<?php echo esc_attr( $args['templ_name'] ); ?> && typeof data.<?php echo esc_attr( $args['templ_name'] ); ?> === 'object' ? data.<?php echo esc_attr( $args['templ_name'] ); ?> : {}; #>
|
825 |
|
826 |
<?php
|
827 |
|
828 |
if ( ! empty( $args['options'] ) ) {
|
829 |
+
foreach ( $args['options'] as $option => $label ) {
|
830 |
+
?>
|
831 |
<# if (checked.<?php echo esc_attr( $option ); ?> === undefined) {
|
832 |
checked.<?php echo esc_attr( $option ); ?> = false;
|
833 |
} #>
|
834 |
|
835 |
<input name="<?php echo esc_attr( $args['name'] ); ?>[<?php echo esc_attr( $option ); ?>]" id="<?php echo esc_attr( $args['id'] ); ?>_<?php echo esc_attr( $option ); ?>" type="checkbox" value="<?php echo esc_html( $option ); ?>" {{pumChecked(checked.<?php echo esc_attr( $option ); ?>, '<?php echo $option; ?>', true)}} />
|
836 |
+
<label for="<?php echo esc_attr( $args['id'] ); ?>_<?php echo esc_attr( $option ); ?>"><?php echo esc_html( $label ); ?></label><br/>
|
837 |
+
<?php
|
838 |
}
|
839 |
}
|
840 |
|
846 |
$this->rangeslider_callback( $args, $value );
|
847 |
}
|
848 |
|
849 |
+
public function postselect_sanitize( $value = [], $args = [] ) {
|
850 |
+
return $this->objectselect_sanitize( $value, $args );
|
851 |
+
}
|
852 |
|
853 |
+
public function objectselect_sanitize( $value = [], $args = [] ) {
|
854 |
+
return wp_parse_id_list( $value );
|
855 |
+
}
|
856 |
|
857 |
+
public function taxonomyselect_sanitize( $value = [], $args = [] ) {
|
858 |
+
return $this->objectselect_sanitize( $value, $args );
|
859 |
+
}
|
860 |
|
861 |
+
/**
|
862 |
* TODO: Finish adding the following field types for HTML & underscore.js
|
863 |
*/
|
864 |
/*
|
872 |
*
|
873 |
* public function radio_callback( $args, $value ) {
|
874 |
* if ( ! empty( $args['options'] ) ) {
|
875 |
+
*
|
876 |
+
* foreach ( $args['options'] as $key => $option ) {
|
877 |
* $checked = false;
|
878 |
+
*
|
879 |
+
* $value = $this->get_option( $args['id'] );
|
880 |
+
*
|
881 |
+
* if ( $value == $key || ( ! $value && isset( $args['std'] ) && $args['std'] == $key ) ) {
|
882 |
* $checked = true;
|
883 |
* }
|
884 |
+
*
|
885 |
+
* echo '<input name="<?php echo esc_attr( $args['name'] ); ?>"" id="<?php echo esc_attr( $args['id'] ); ?>[<?php echo esc_attr( $key ); ?>]" type="radio" value="<?php echo esc_attr( $key ); ?>" ' . checked( true, $checked, false ) . '/> ';
|
886 |
* echo '<label for="<?php echo esc_attr( $args['id'] ); ?>[<?php echo esc_attr( $key ); ?>]">' . $option . '</label><br/>';
|
887 |
* }
|
888 |
+
*
|
889 |
+
* echo '<p class="pum-desc">' . $args['desc'] . '</p>';
|
890 |
+
*
|
|
|
891 |
* }
|
892 |
+
* }
|
893 |
+
*
|
894 |
+
*
|
895 |
+
*
|
896 |
+
*
|
897 |
+
*
|
898 |
+
*
|
899 |
+
*
|
900 |
+
* /**
|
901 |
* Color select Callback
|
902 |
*
|
903 |
* Renders color select fields.
|
907 |
* @return void
|
908 |
*
|
909 |
* public function color_select_callback( $args ) {
|
910 |
+
*
|
911 |
+
* $value = $this->get_option( $args['id'] );
|
912 |
+
*
|
913 |
+
* if ( ! $value ) {
|
914 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
915 |
* }
|
916 |
+
*
|
917 |
+
* $html = '<select id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>"/>';
|
918 |
+
*
|
919 |
+
* if ( ! empty( $args['options'] ) ) {
|
920 |
* foreach ( $args['options'] as $option => $color ) {
|
921 |
* $selected = selected( $option, $value, false );
|
922 |
* $html .= '<option value="' . $option . '" ' . $selected . '>' . $color['label'] . '</option>';
|
923 |
* }
|
924 |
* }
|
925 |
+
*
|
926 |
+
* $html .= '</select>';
|
927 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
928 |
+
*
|
929 |
+
* echo $html;
|
930 |
* }
|
931 |
+
*
|
932 |
+
* /**
|
933 |
* Rich Editor Callback
|
934 |
*
|
935 |
* Renders rich editor fields.
|
941 |
* public function rich_editor_callback( $args ) {
|
942 |
* global $wp_version;
|
943 |
* $value = $this->get_option( $args['id'] );
|
944 |
+
*
|
945 |
+
* if ( ! $value ) {
|
946 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
947 |
* }
|
948 |
+
*
|
949 |
+
* $rows = isset( $args['size'] ) ? $args['size'] : 20;
|
950 |
+
*
|
951 |
+
* if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
|
952 |
* ob_start();
|
953 |
* wp_editor( stripslashes( $value ), $this->options_key . '_' . $args['id'], array(
|
954 |
* 'textarea_name' => '' . $this->options_key . '[' . $args['id'] . ']',
|
958 |
* } else {
|
959 |
* $html = '<textarea class="large-text" rows="10" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
960 |
* }
|
961 |
+
*
|
962 |
+
* $html .= '<br/><label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
963 |
+
*
|
964 |
+
* echo $html;
|
965 |
* }
|
966 |
+
*
|
967 |
+
* /**
|
968 |
* Upload Callback
|
969 |
*
|
970 |
* Renders upload fields.
|
975 |
*
|
976 |
* public function upload_callback( $args ) {
|
977 |
* $value = $this->get_option( $args['id'] );
|
978 |
+
*
|
979 |
+
* if ( ! $value ) {
|
980 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
981 |
* }
|
982 |
+
*
|
983 |
+
* $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
984 |
* $html = '<input type="text" class="' . $size . '-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( stripslashes( $value ) ) . '"/>';
|
985 |
* $html .= '<span> <input type="button" class="' . $this->options_key . '_upload_button button-secondary" value="' . __( 'Upload File' ) . '"/></span>';
|
986 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
987 |
+
*
|
988 |
+
* echo $html;
|
989 |
* }
|
990 |
+
*
|
991 |
+
* /**
|
992 |
* Color picker Callback
|
993 |
*
|
994 |
* Renders color picker fields.
|
999 |
*
|
1000 |
* public function color_callback( $args ) {
|
1001 |
* $value = $this->get_option( $args['id'] );
|
1002 |
+
*
|
1003 |
+
* if ( ! $value ) {
|
1004 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
1005 |
* }
|
1006 |
+
*
|
1007 |
+
* $default = isset( $args['std'] ) ? $args['std'] : '';
|
1008 |
+
*
|
1009 |
+
* $html = '<input type="text" class="di-color-picker" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( $value ) . '" data-default-color="' . echo esc_attr( $default ) . '" />';
|
1010 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
1011 |
+
*
|
1012 |
+
* echo $html;
|
1013 |
* }
|
1014 |
+
*
|
1015 |
+
* /**
|
1016 |
* Descriptive text callback.
|
1017 |
*
|
1018 |
* Renders descriptive text onto the settings field.
|
1024 |
* public function descriptive_text_callback( $args ) {
|
1025 |
* echo esc_html( $args['desc'] );
|
1026 |
* }
|
1027 |
+
*
|
1028 |
+
* /**
|
1029 |
* Registers the license field callback for Software Licensing
|
1030 |
*
|
1031 |
* @param array $args Arguments passed by the setting
|
1034 |
*
|
1035 |
* public function license_key_callback( $args ) {
|
1036 |
* $value = $this->get_option( $args['id'] );
|
1037 |
+
*
|
1038 |
+
* if ( ! $value ) {
|
1039 |
* $value = isset( $args['std'] ) ? $args['std'] : '';
|
1040 |
* }
|
1041 |
+
*
|
1042 |
+
* $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1043 |
+
*
|
1044 |
+
* $html = '<input type="' . ( $value == '' ? 'text' : 'password' ) . '" class="' . $size . '-text" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['name'] ); ?>" value="' . echo esc_attr( $value ) . '"/>';
|
1045 |
+
*
|
1046 |
+
* if ( 'valid' == get_option( $args['options']['is_valid_license_option'] ) ) {
|
1047 |
* $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License' ) . '"/>';
|
1048 |
* }
|
1049 |
* $html .= '<label for="<?php echo esc_attr( $args['id'] ); ?>"> ' . $args['desc'] . '</label>';
|
1050 |
+
*
|
1051 |
+
* echo $html;
|
1052 |
* }
|
1053 |
+
*
|
1054 |
+
* */
|
1055 |
|
1056 |
}
|
includes/class-pum-form.php
CHANGED
@@ -19,7 +19,7 @@ class PUM_Form extends PUM_Fields {
|
|
19 |
* @param array $id
|
20 |
* @param array $args
|
21 |
*/
|
22 |
-
public function __construct( $id, $args =
|
23 |
$this->id = $id;
|
24 |
|
25 |
if ( empty( $args['id'] ) ) {
|
19 |
* @param array $id
|
20 |
* @param array $args
|
21 |
*/
|
22 |
+
public function __construct( $id, $args = [] ) {
|
23 |
$this->id = $id;
|
24 |
|
25 |
if ( empty( $args['id'] ) ) {
|
includes/compat.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// SPL can be disabled on PHP 5.2
|
4 |
if ( ! function_exists( 'spl_autoload_register' ) ) {
|
5 |
-
$_wp_spl_autoloaders =
|
6 |
|
7 |
/**
|
8 |
* Registers a function to be autoloaded.
|
@@ -10,10 +10,10 @@ if ( ! function_exists( 'spl_autoload_register' ) ) {
|
|
10 |
* @since 4.6.0
|
11 |
*
|
12 |
* @param callable $autoload_function The function to register.
|
13 |
-
* @param bool
|
14 |
-
*
|
15 |
-
* @param bool
|
16 |
-
*
|
17 |
*
|
18 |
* @throws Exception
|
19 |
*/
|
@@ -82,47 +82,49 @@ if ( ! function_exists( 'get_called_class' ) ) {
|
|
82 |
if ( ! $bt ) {
|
83 |
$bt = debug_backtrace();
|
84 |
}
|
85 |
-
if ( ! isset
|
86 |
-
throw new Exception
|
87 |
}
|
88 |
if ( ! isset( $bt[ $l ]['type'] ) ) {
|
89 |
-
throw new Exception
|
90 |
-
} else
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
|
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
}
|
127 |
}
|
128 |
}
|
@@ -195,7 +197,7 @@ if ( ! function_exists( 'recurse' ) ) {
|
|
195 |
foreach ( $array1 as $key => $value ) {
|
196 |
// create new key in $array, if it is empty or not an array
|
197 |
if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
|
198 |
-
$array[ $key ] =
|
199 |
}
|
200 |
|
201 |
// overwrite the value in the base array
|
@@ -221,7 +223,7 @@ if ( ! function_exists( 'write_log' ) ) {
|
|
221 |
|
222 |
if ( ! function_exists( 'boolval' ) ) {
|
223 |
function boolval( $val ) {
|
224 |
-
return (
|
225 |
}
|
226 |
}
|
227 |
|
@@ -258,5 +260,4 @@ if ( ! function_exists( 'has_blocks' ) ) {
|
|
258 |
|
259 |
return false !== strpos( (string) $post, '<!-- wp:' );
|
260 |
}
|
261 |
-
|
262 |
-
}
|
2 |
|
3 |
// SPL can be disabled on PHP 5.2
|
4 |
if ( ! function_exists( 'spl_autoload_register' ) ) {
|
5 |
+
$_wp_spl_autoloaders = [];
|
6 |
|
7 |
/**
|
8 |
* Registers a function to be autoloaded.
|
10 |
* @since 4.6.0
|
11 |
*
|
12 |
* @param callable $autoload_function The function to register.
|
13 |
+
* @param bool $throw Optional. Whether the function should throw an exception
|
14 |
+
* if the function isn't callable. Default true.
|
15 |
+
* @param bool $prepend Whether the function should be prepended to the stack.
|
16 |
+
* Default false.
|
17 |
*
|
18 |
* @throws Exception
|
19 |
*/
|
82 |
if ( ! $bt ) {
|
83 |
$bt = debug_backtrace();
|
84 |
}
|
85 |
+
if ( ! isset( $bt[ $l ] ) ) {
|
86 |
+
throw new Exception( 'Cannot find called class -> stack level too deep.' );
|
87 |
}
|
88 |
if ( ! isset( $bt[ $l ]['type'] ) ) {
|
89 |
+
throw new Exception( 'type not set' );
|
90 |
+
} else {
|
91 |
+
switch ( $bt[ $l ]['type'] ) {
|
92 |
+
case '::':
|
93 |
+
$lines = file( $bt[ $l ]['file'] );
|
94 |
+
$i = 0;
|
95 |
+
$callerLine = '';
|
96 |
+
do {
|
97 |
+
$i ++;
|
98 |
+
$callerLine = $lines[ $bt[ $l ]['line'] - $i ] . $callerLine;
|
99 |
+
} while ( stripos( $callerLine, $bt[ $l ]['function'] ) === false );
|
100 |
+
preg_match( '/([a-zA-Z0-9\_]+)::' . $bt[ $l ]['function'] . '/', $callerLine, $matches );
|
101 |
+
if ( ! isset( $matches[1] ) ) {
|
102 |
+
// must be an edge case.
|
103 |
+
throw new Exception( 'Could not find caller class: originating method call is obscured.' );
|
104 |
+
}
|
105 |
+
switch ( $matches[1] ) {
|
106 |
+
case 'self':
|
107 |
+
case 'parent':
|
108 |
+
return get_called_class( $bt, $l + 1 );
|
109 |
+
default:
|
110 |
+
return $matches[1];
|
111 |
+
}
|
112 |
+
// won't get here.
|
113 |
+
case '->':
|
114 |
+
switch ( $bt[ $l ]['function'] ) {
|
115 |
+
case '__get':
|
116 |
+
// edge case -> get class of calling object
|
117 |
+
if ( ! is_object( $bt[ $l ]['object'] ) ) {
|
118 |
+
throw new Exception( 'Edge case fail. __get called on non object.' );
|
119 |
+
}
|
120 |
|
121 |
+
return get_class( $bt[ $l ]['object'] );
|
122 |
+
default:
|
123 |
+
return get_class( $bt[ $l ]['object'] );
|
124 |
+
}
|
125 |
+
default:
|
126 |
+
throw new Exception( 'Unknown backtrace method type' );
|
127 |
+
}
|
128 |
}
|
129 |
}
|
130 |
}
|
197 |
foreach ( $array1 as $key => $value ) {
|
198 |
// create new key in $array, if it is empty or not an array
|
199 |
if ( ! isset( $array[ $key ] ) || ( isset( $array[ $key ] ) && ! is_array( $array[ $key ] ) ) ) {
|
200 |
+
$array[ $key ] = [];
|
201 |
}
|
202 |
|
203 |
// overwrite the value in the base array
|
223 |
|
224 |
if ( ! function_exists( 'boolval' ) ) {
|
225 |
function boolval( $val ) {
|
226 |
+
return (bool) $val;
|
227 |
}
|
228 |
}
|
229 |
|
260 |
|
261 |
return false !== strpos( (string) $post, '<!-- wp:' );
|
262 |
}
|
263 |
+
}
|
|
includes/compatibility/function-wp_removable_query_args.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* @return array An array of parameters to remove from the URL.
|
9 |
*/
|
10 |
function wp_removable_query_args() {
|
11 |
-
$removable_query_args =
|
12 |
'activate',
|
13 |
'activated',
|
14 |
'approved',
|
@@ -32,7 +32,7 @@ function wp_removable_query_args() {
|
|
32 |
'update',
|
33 |
'updated',
|
34 |
'wp-post-new-reload',
|
35 |
-
|
36 |
|
37 |
/**
|
38 |
* Filters the list of query variables to remove.
|
8 |
* @return array An array of parameters to remove from the URL.
|
9 |
*/
|
10 |
function wp_removable_query_args() {
|
11 |
+
$removable_query_args = [
|
12 |
'activate',
|
13 |
'activated',
|
14 |
'approved',
|
32 |
'update',
|
33 |
'updated',
|
34 |
'wp-post-new-reload',
|
35 |
+
];
|
36 |
|
37 |
/**
|
38 |
* Filters the list of query variables to remove.
|
includes/defaults.php
CHANGED
@@ -18,48 +18,54 @@ add_filter( 'pum_popup_display_defaults', 'popmake_popup_display_defaults', 0 );
|
|
18 |
*
|
19 |
* @return array
|
20 |
*/
|
21 |
-
function popmake_popup_display_defaults( $defaults =
|
22 |
-
return array_merge(
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
|
53 |
add_filter( 'popmake_popup_close_defaults', 'popmake_popup_close_defaults', 0 );
|
54 |
add_filter( 'pum_popup_close_defaults', 'popmake_popup_close_defaults', 0 );
|
55 |
-
function popmake_popup_close_defaults( $defaults =
|
56 |
-
return array_merge(
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
|
18 |
*
|
19 |
* @return array
|
20 |
*/
|
21 |
+
function popmake_popup_display_defaults( $defaults = [] ) {
|
22 |
+
return array_merge(
|
23 |
+
$defaults,
|
24 |
+
[
|
25 |
+
'stackable' => false,
|
26 |
+
'overlay_disabled' => false,
|
27 |
+
'scrollable_content' => false,
|
28 |
+
'disable_reposition' => false,
|
29 |
+
'size' => 'medium',
|
30 |
+
'responsive_min_width' => '',
|
31 |
+
'responsive_min_width_unit' => 'px',
|
32 |
+
'responsive_max_width' => '',
|
33 |
+
'responsive_max_width_unit' => 'px',
|
34 |
+
'custom_width' => 640,
|
35 |
+
'custom_width_unit' => 'px',
|
36 |
+
'custom_height' => 380,
|
37 |
+
'custom_height_unit' => 'px',
|
38 |
+
'custom_height_auto' => false,
|
39 |
+
'location' => 'center top',
|
40 |
+
'position_from_trigger' => false,
|
41 |
+
'position_top' => 100,
|
42 |
+
'position_left' => 0,
|
43 |
+
'position_bottom' => 0,
|
44 |
+
'position_right' => 0,
|
45 |
+
'position_fixed' => false,
|
46 |
+
'animation_type' => 'fade',
|
47 |
+
'animation_speed' => 350,
|
48 |
+
'animation_origin' => 'center top',
|
49 |
+
'overlay_zindex' => 1999999998,
|
50 |
+
'zindex' => 1999999999,
|
51 |
+
]
|
52 |
+
);
|
53 |
}
|
54 |
|
55 |
|
56 |
add_filter( 'popmake_popup_close_defaults', 'popmake_popup_close_defaults', 0 );
|
57 |
add_filter( 'pum_popup_close_defaults', 'popmake_popup_close_defaults', 0 );
|
58 |
+
function popmake_popup_close_defaults( $defaults = [] ) {
|
59 |
+
return array_merge(
|
60 |
+
$defaults,
|
61 |
+
[
|
62 |
+
'text' => '',
|
63 |
+
'button_delay' => '0',
|
64 |
+
'overlay_click' => false,
|
65 |
+
'esc_press' => false,
|
66 |
+
'f4_press' => false,
|
67 |
+
]
|
68 |
+
);
|
69 |
}
|
70 |
|
71 |
|
includes/deprecated-classes.php
CHANGED
@@ -9,12 +9,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
}
|
10 |
|
11 |
/**
|
12 |
-
* PopMake_License Class
|
13 |
-
*
|
14 |
-
* @deprecated 1.5.0
|
15 |
-
*
|
16 |
-
* Use PUM_Extension_License instead.
|
17 |
-
*/
|
18 |
class PopMake_License extends PUM_Extension_License {}
|
19 |
|
20 |
/**
|
@@ -47,7 +47,7 @@ class PUM_Popup_Query {
|
|
47 |
* @var array
|
48 |
* @access public
|
49 |
*/
|
50 |
-
public $args =
|
51 |
|
52 |
/**
|
53 |
* Default query arguments.
|
@@ -57,7 +57,7 @@ class PUM_Popup_Query {
|
|
57 |
*
|
58 |
* @param array $args The array of arguments that can be passed in and used for setting up this popup query.
|
59 |
*/
|
60 |
-
public function __construct( $args =
|
61 |
$this->args = $args;
|
62 |
}
|
63 |
|
@@ -83,8 +83,8 @@ class PUM_Popup_Query {
|
|
83 |
* @deprecated 1.8.0 - Don't use this. Use Popup_Maker instead.
|
84 |
*/
|
85 |
class PUM {
|
86 |
-
const DB_VER
|
87 |
-
const VER
|
88 |
static $DB_VER = null;
|
89 |
-
static $VER
|
90 |
}
|
9 |
}
|
10 |
|
11 |
/**
|
12 |
+
* PopMake_License Class
|
13 |
+
*
|
14 |
+
* @deprecated 1.5.0
|
15 |
+
*
|
16 |
+
* Use PUM_Extension_License instead.
|
17 |
+
*/
|
18 |
class PopMake_License extends PUM_Extension_License {}
|
19 |
|
20 |
/**
|
47 |
* @var array
|
48 |
* @access public
|
49 |
*/
|
50 |
+
public $args = [];
|
51 |
|
52 |
/**
|
53 |
* Default query arguments.
|
57 |
*
|
58 |
* @param array $args The array of arguments that can be passed in and used for setting up this popup query.
|
59 |
*/
|
60 |
+
public function __construct( $args = [] ) {
|
61 |
$this->args = $args;
|
62 |
}
|
63 |
|
83 |
* @deprecated 1.8.0 - Don't use this. Use Popup_Maker instead.
|
84 |
*/
|
85 |
class PUM {
|
86 |
+
const DB_VER = null;
|
87 |
+
const VER = null;
|
88 |
static $DB_VER = null;
|
89 |
+
static $VER = null;
|
90 |
}
|
includes/deprecated-filters.php
CHANGED
@@ -17,13 +17,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
17 |
* @param null $popup_id
|
18 |
*/
|
19 |
function popmake_enqueue_scripts( $popup_id = null ) {
|
20 |
-
$scripts_needed = apply_filters( 'popmake_enqueue_scripts',
|
21 |
foreach ( $scripts_needed as $script ) {
|
22 |
if ( wp_script_is( $script, 'registered' ) ) {
|
23 |
wp_enqueue_script( $script );
|
24 |
}
|
25 |
}
|
26 |
-
$styles_needed = apply_filters( 'popmake_enqueue_styles',
|
27 |
foreach ( $styles_needed as $style ) {
|
28 |
if ( wp_style_is( $style, 'registered' ) ) {
|
29 |
wp_enqueue_style( $style );
|
@@ -43,7 +43,7 @@ add_action( 'popmake_preload_popup', 'popmake_enqueue_scripts' );
|
|
43 |
*
|
44 |
* @return mixed
|
45 |
*/
|
46 |
-
function pum_deprecated_popmake_settings_extensions_sanitize_filter( $settings =
|
47 |
if ( has_filter( 'popmake_settings_extensions_sanitize' ) ) {
|
48 |
PUM_Utils_Logging::instance()->log_deprecated_notice( 'filter:popmake_settings_extensions_sanitize', '1.7.0', 'filter:pum_settings_sanitize' );
|
49 |
/**
|
17 |
* @param null $popup_id
|
18 |
*/
|
19 |
function popmake_enqueue_scripts( $popup_id = null ) {
|
20 |
+
$scripts_needed = apply_filters( 'popmake_enqueue_scripts', [], $popup_id );
|
21 |
foreach ( $scripts_needed as $script ) {
|
22 |
if ( wp_script_is( $script, 'registered' ) ) {
|
23 |
wp_enqueue_script( $script );
|
24 |
}
|
25 |
}
|
26 |
+
$styles_needed = apply_filters( 'popmake_enqueue_styles', [], $popup_id );
|
27 |
foreach ( $styles_needed as $style ) {
|
28 |
if ( wp_style_is( $style, 'registered' ) ) {
|
29 |
wp_enqueue_style( $style );
|
43 |
*
|
44 |
* @return mixed
|
45 |
*/
|
46 |
+
function pum_deprecated_popmake_settings_extensions_sanitize_filter( $settings = [] ) {
|
47 |
if ( has_filter( 'popmake_settings_extensions_sanitize' ) ) {
|
48 |
PUM_Utils_Logging::instance()->log_deprecated_notice( 'filter:popmake_settings_extensions_sanitize', '1.7.0', 'filter:pum_settings_sanitize' );
|
49 |
/**
|
includes/failsafes.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
if ( ! function_exists( 'popmake_get_option' ) ) {
|
7 |
/**
|
8 |
* @param string $key
|
9 |
-
* @param bool
|
10 |
*
|
11 |
* @return bool
|
12 |
*/
|
@@ -69,7 +69,7 @@ if ( ! function_exists( 'popmake_get_template_part' ) ) {
|
|
69 |
* @return string
|
70 |
*/
|
71 |
function popmake_get_template_part( $slug, $name = null, $load = true ) {
|
72 |
-
if ($load ) {
|
73 |
return;
|
74 |
}
|
75 |
|
6 |
if ( ! function_exists( 'popmake_get_option' ) ) {
|
7 |
/**
|
8 |
* @param string $key
|
9 |
+
* @param bool $default
|
10 |
*
|
11 |
* @return bool
|
12 |
*/
|
69 |
* @return string
|
70 |
*/
|
71 |
function popmake_get_template_part( $slug, $name = null, $load = true ) {
|
72 |
+
if ( $load ) {
|
73 |
return;
|
74 |
}
|
75 |
|
includes/functions-backcompat.php
CHANGED
@@ -20,7 +20,7 @@ add_filter( 'pum_settings_fields', 'pum_merge_deprecated_settings_fields' );
|
|
20 |
*
|
21 |
* @return array
|
22 |
*/
|
23 |
-
function pum_merge_deprecated_settings_fields( $tabs =
|
24 |
/**
|
25 |
* Apply @deprecated filters & process old fields for compatibility.
|
26 |
*/
|
@@ -41,9 +41,9 @@ function pum_merge_deprecated_settings_fields( $tabs = array() ) {
|
|
41 |
|
42 |
if ( $field_args['type'] == 'header' ) {
|
43 |
$field_args['type'] = 'separator';
|
44 |
-
}
|
45 |
$field_args['type'] = 'ga_event_labels';
|
46 |
-
}
|
47 |
$field_args['type'] = 'html';
|
48 |
|
49 |
ob_start();
|
20 |
*
|
21 |
* @return array
|
22 |
*/
|
23 |
+
function pum_merge_deprecated_settings_fields( $tabs = [] ) {
|
24 |
/**
|
25 |
* Apply @deprecated filters & process old fields for compatibility.
|
26 |
*/
|
41 |
|
42 |
if ( $field_args['type'] == 'header' ) {
|
43 |
$field_args['type'] = 'separator';
|
44 |
+
} elseif ( $field_args['type'] == 'gaeventlabel' ) {
|
45 |
$field_args['type'] = 'ga_event_labels';
|
46 |
+
} elseif ( $field_args['type'] == 'hook' ) {
|
47 |
$field_args['type'] = 'html';
|
48 |
|
49 |
ob_start();
|
includes/functions-deprecated.php
CHANGED
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
8 |
exit;
|
9 |
}
|
10 |
|
11 |
-
|
12 |
|
13 |
/**
|
14 |
* @deprecated 1.7.0 Use pum_load_popup
|
@@ -97,15 +97,15 @@ function popmake_get_registered_settings() {
|
|
97 |
* 'Whitelisted' POPMAKE settings, filters are provided for each settings
|
98 |
* section to allow extensions and other plugins to add their own settings
|
99 |
*/
|
100 |
-
$popmake_settings =
|
101 |
/** General Settings */
|
102 |
-
'general' => apply_filters( 'popmake_settings_general',
|
103 |
-
'assets' => apply_filters( 'popmake_settings_assets',
|
104 |
/** Extension Settings */
|
105 |
-
'extensions' => apply_filters( 'popmake_settings_extensions',
|
106 |
-
'licenses' => apply_filters( 'popmake_settings_licenses',
|
107 |
-
'misc' => apply_filters( 'popmake_settings_misc',
|
108 |
-
|
109 |
|
110 |
return apply_filters( 'popmake_registered_settings', $popmake_settings );
|
111 |
}
|
@@ -170,7 +170,7 @@ function popmake_output_pum_styles() {
|
|
170 |
*/
|
171 |
function popmake_get_pages( $force = false ) {
|
172 |
|
173 |
-
$pages_options =
|
174 |
|
175 |
if ( ( ! isset( $_GET['page'] ) || 'pum-settings' != $_GET['page'] ) && ! $force ) {
|
176 |
return $pages_options;
|
@@ -241,9 +241,9 @@ function pum_get_trigger_section_labels() {
|
|
241 |
return PUM_Triggers::instance()->get_tabs();
|
242 |
}
|
243 |
|
244 |
-
|
245 |
|
246 |
-
|
247 |
|
248 |
|
249 |
/**
|
@@ -257,19 +257,21 @@ function pum_get_trigger_section_labels() {
|
|
257 |
function popmake_install_default_theme() {
|
258 |
$defaults = PUM_Admin_Themes::defaults();
|
259 |
|
260 |
-
$default_theme = @wp_insert_post(
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
'
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
|
|
|
|
273 |
|
274 |
update_option( 'popmake_default_theme', $default_theme );
|
275 |
pum_reset_assets();
|
@@ -418,7 +420,8 @@ function popmake_render_popup_theme_overlay_meta_box() {
|
|
418 |
<?php do_action( 'popmake_popup_theme_overlay_meta_box_fields', $post->ID ); ?>
|
419 |
</tbody>
|
420 |
</table>
|
421 |
-
</div
|
|
|
422 |
}
|
423 |
|
424 |
/**
|
@@ -435,14 +438,16 @@ function popmake_render_popup_theme_container_meta_box() {
|
|
435 |
return;
|
436 |
}
|
437 |
|
438 |
-
global $post;
|
|
|
439 |
<div id="popmake_popup_theme_container_fields" class="popmake_meta_table_wrap">
|
440 |
<table class="form-table">
|
441 |
<tbody>
|
442 |
<?php do_action( 'popmake_popup_theme_container_meta_box_fields', $post->ID ); ?>
|
443 |
</tbody>
|
444 |
</table>
|
445 |
-
</div
|
|
|
446 |
}
|
447 |
|
448 |
/**
|
@@ -459,15 +464,17 @@ function popmake_render_popup_theme_close_meta_box() {
|
|
459 |
return;
|
460 |
}
|
461 |
|
462 |
-
global $post;
|
|
|
463 |
<div id="popmake_popup_theme_close_fields" class="popmake_meta_table_wrap">
|
464 |
<table class="form-table">
|
465 |
<tbody>
|
466 |
<?php do_action( 'popmake_popup_theme_close_meta_box_fields', $post->ID ); ?>
|
467 |
</tbody>
|
468 |
</table>
|
469 |
-
</div
|
|
|
470 |
}
|
471 |
|
472 |
|
473 |
-
|
8 |
exit;
|
9 |
}
|
10 |
|
11 |
+
// region Deprecated 1.7.0
|
12 |
|
13 |
/**
|
14 |
* @deprecated 1.7.0 Use pum_load_popup
|
97 |
* 'Whitelisted' POPMAKE settings, filters are provided for each settings
|
98 |
* section to allow extensions and other plugins to add their own settings
|
99 |
*/
|
100 |
+
$popmake_settings = [
|
101 |
/** General Settings */
|
102 |
+
'general' => apply_filters( 'popmake_settings_general', [] ),
|
103 |
+
'assets' => apply_filters( 'popmake_settings_assets', [] ),
|
104 |
/** Extension Settings */
|
105 |
+
'extensions' => apply_filters( 'popmake_settings_extensions', [] ),
|
106 |
+
'licenses' => apply_filters( 'popmake_settings_licenses', [] ),
|
107 |
+
'misc' => apply_filters( 'popmake_settings_misc', [] ),
|
108 |
+
];
|
109 |
|
110 |
return apply_filters( 'popmake_registered_settings', $popmake_settings );
|
111 |
}
|
170 |
*/
|
171 |
function popmake_get_pages( $force = false ) {
|
172 |
|
173 |
+
$pages_options = [ 0 => '' ]; // Blank option
|
174 |
|
175 |
if ( ( ! isset( $_GET['page'] ) || 'pum-settings' != $_GET['page'] ) && ! $force ) {
|
176 |
return $pages_options;
|
241 |
return PUM_Triggers::instance()->get_tabs();
|
242 |
}
|
243 |
|
244 |
+
// endregion
|
245 |
|
246 |
+
// region Deprecated 1.8.0
|
247 |
|
248 |
|
249 |
/**
|
257 |
function popmake_install_default_theme() {
|
258 |
$defaults = PUM_Admin_Themes::defaults();
|
259 |
|
260 |
+
$default_theme = @wp_insert_post(
|
261 |
+
[
|
262 |
+
'post_title' => __( 'Default Theme', 'popup-maker' ),
|
263 |
+
'post_status' => 'publish',
|
264 |
+
'post_author' => 1,
|
265 |
+
'post_type' => 'popup_theme',
|
266 |
+
'comment_status' => 'closed',
|
267 |
+
'meta_input' => [
|
268 |
+
'_pum_built_in' => 'default-theme',
|
269 |
+
'_pum_default_theme' => true,
|
270 |
+
'popup_theme_settings' => $defaults,
|
271 |
+
'popup_theme_data_version' => 3,
|
272 |
+
],
|
273 |
+
]
|
274 |
+
);
|
275 |
|
276 |
update_option( 'popmake_default_theme', $default_theme );
|
277 |
pum_reset_assets();
|
420 |
<?php do_action( 'popmake_popup_theme_overlay_meta_box_fields', $post->ID ); ?>
|
421 |
</tbody>
|
422 |
</table>
|
423 |
+
</div>
|
424 |
+
<?php
|
425 |
}
|
426 |
|
427 |
/**
|
438 |
return;
|
439 |
}
|
440 |
|
441 |
+
global $post;
|
442 |
+
?>
|
443 |
<div id="popmake_popup_theme_container_fields" class="popmake_meta_table_wrap">
|
444 |
<table class="form-table">
|
445 |
<tbody>
|
446 |
<?php do_action( 'popmake_popup_theme_container_meta_box_fields', $post->ID ); ?>
|
447 |
</tbody>
|
448 |
</table>
|
449 |
+
</div>
|
450 |
+
<?php
|
451 |
}
|
452 |
|
453 |
/**
|
464 |
return;
|
465 |
}
|
466 |
|
467 |
+
global $post;
|
468 |
+
?>
|
469 |
<div id="popmake_popup_theme_close_fields" class="popmake_meta_table_wrap">
|
470 |
<table class="form-table">
|
471 |
<tbody>
|
472 |
<?php do_action( 'popmake_popup_theme_close_meta_box_fields', $post->ID ); ?>
|
473 |
</tbody>
|
474 |
</table>
|
475 |
+
</div>
|
476 |
+
<?php
|
477 |
}
|
478 |
|
479 |
|
480 |
+
// endregion
|
includes/functions/admin/conditionals.php
CHANGED
@@ -21,11 +21,11 @@ function pum_is_admin_page() {
|
|
21 |
|
22 |
$typenow = pum_typenow();
|
23 |
|
24 |
-
$tests =
|
25 |
'popup' == $typenow,
|
26 |
'popup_theme' == $typenow,
|
27 |
! empty( $GLOBALS['hook_suffix'] ) && in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ),
|
28 |
-
|
29 |
|
30 |
return in_array( true, $tests );
|
31 |
}
|
@@ -40,11 +40,11 @@ function pum_is_admin_page() {
|
|
40 |
function pum_is_all_popups_page() {
|
41 |
$screen = get_current_screen();
|
42 |
|
43 |
-
$tests =
|
44 |
pum_is_admin_page(),
|
45 |
'edit-popup' === $screen->id,
|
46 |
pum_typenow() === 'popup',
|
47 |
-
|
48 |
|
49 |
return ! in_array( false, $tests, true );
|
50 |
}
|
@@ -59,12 +59,12 @@ function pum_is_all_popups_page() {
|
|
59 |
function pum_is_popup_editor() {
|
60 |
global $pagenow;
|
61 |
|
62 |
-
$tests =
|
63 |
is_admin(),
|
64 |
pum_is_admin_page(),
|
65 |
'popup' == pum_typenow(),
|
66 |
-
in_array( $pagenow,
|
67 |
-
|
68 |
|
69 |
return ! in_array( false, $tests );
|
70 |
}
|
@@ -79,12 +79,12 @@ function pum_is_popup_editor() {
|
|
79 |
function pum_is_popup_theme_editor() {
|
80 |
global $pagenow;
|
81 |
|
82 |
-
$tests =
|
83 |
is_admin(),
|
84 |
pum_is_admin_page(),
|
85 |
'popup_theme' == pum_typenow(),
|
86 |
-
in_array( $pagenow,
|
87 |
-
|
88 |
|
89 |
return ! in_array( false, $tests );
|
90 |
}
|
@@ -99,14 +99,14 @@ function pum_is_popup_theme_editor() {
|
|
99 |
* @return bool
|
100 |
*/
|
101 |
function pum_is_submenu_page( $key = null ) {
|
102 |
-
$tests =
|
103 |
is_admin(),
|
104 |
pum_is_admin_page(),
|
105 |
! pum_is_popup_editor(),
|
106 |
! pum_is_popup_theme_editor(),
|
107 |
$key && ! empty( $GLOBALS['hook_suffix'] ) ? $GLOBALS['hook_suffix'] == PUM_Admin_Pages::get_page( $key ) : true,
|
108 |
! isset( $key ) && ! empty( $GLOBALS['hook_suffix'] ) ? in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ) : true,
|
109 |
-
|
110 |
|
111 |
return ! in_array( false, $tests );
|
112 |
}
|
21 |
|
22 |
$typenow = pum_typenow();
|
23 |
|
24 |
+
$tests = [
|
25 |
'popup' == $typenow,
|
26 |
'popup_theme' == $typenow,
|
27 |
! empty( $GLOBALS['hook_suffix'] ) && in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ),
|
28 |
+
];
|
29 |
|
30 |
return in_array( true, $tests );
|
31 |
}
|
40 |
function pum_is_all_popups_page() {
|
41 |
$screen = get_current_screen();
|
42 |
|
43 |
+
$tests = [
|
44 |
pum_is_admin_page(),
|
45 |
'edit-popup' === $screen->id,
|
46 |
pum_typenow() === 'popup',
|
47 |
+
];
|
48 |
|
49 |
return ! in_array( false, $tests, true );
|
50 |
}
|
59 |
function pum_is_popup_editor() {
|
60 |
global $pagenow;
|
61 |
|
62 |
+
$tests = [
|
63 |
is_admin(),
|
64 |
pum_is_admin_page(),
|
65 |
'popup' == pum_typenow(),
|
66 |
+
in_array( $pagenow, [ 'post-new.php', 'post.php' ] ),
|
67 |
+
];
|
68 |
|
69 |
return ! in_array( false, $tests );
|
70 |
}
|
79 |
function pum_is_popup_theme_editor() {
|
80 |
global $pagenow;
|
81 |
|
82 |
+
$tests = [
|
83 |
is_admin(),
|
84 |
pum_is_admin_page(),
|
85 |
'popup_theme' == pum_typenow(),
|
86 |
+
in_array( $pagenow, [ 'post-new.php', 'post.php' ] ),
|
87 |
+
];
|
88 |
|
89 |
return ! in_array( false, $tests );
|
90 |
}
|
99 |
* @return bool
|
100 |
*/
|
101 |
function pum_is_submenu_page( $key = null ) {
|
102 |
+
$tests = [
|
103 |
is_admin(),
|
104 |
pum_is_admin_page(),
|
105 |
! pum_is_popup_editor(),
|
106 |
! pum_is_popup_theme_editor(),
|
107 |
$key && ! empty( $GLOBALS['hook_suffix'] ) ? $GLOBALS['hook_suffix'] == PUM_Admin_Pages::get_page( $key ) : true,
|
108 |
! isset( $key ) && ! empty( $GLOBALS['hook_suffix'] ) ? in_array( $GLOBALS['hook_suffix'], PUM_Admin_Pages::$pages ) : true,
|
109 |
+
];
|
110 |
|
111 |
return ! in_array( false, $tests );
|
112 |
}
|
includes/functions/admin/general.php
CHANGED
@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
13 |
* @return bool|string
|
14 |
*/
|
15 |
function pum_typenow() {
|
16 |
-
if ( ! empty
|
17 |
return $GLOBALS['typenow'];
|
18 |
}
|
19 |
|
@@ -40,7 +40,7 @@ function pum_typenow() {
|
|
40 |
*
|
41 |
* @return string Constructed admin URL.
|
42 |
*/
|
43 |
-
function pum_admin_url( $type = '', $query_args =
|
44 |
$page = '';
|
45 |
|
46 |
$whitelist = PUM_Admin_Pages::$pages;
|
@@ -49,7 +49,7 @@ function pum_admin_url( $type = '', $query_args = array() ) {
|
|
49 |
$page = "pum-{$type}";
|
50 |
}
|
51 |
|
52 |
-
$admin_query_args = array_merge(
|
53 |
|
54 |
$url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
|
55 |
|
@@ -67,12 +67,12 @@ function pum_admin_url( $type = '', $query_args = array() ) {
|
|
67 |
* @return array
|
68 |
*/
|
69 |
function pum_support_assist_args() {
|
70 |
-
return
|
71 |
// Forces the dashboard to force logout any users.
|
72 |
'nouser' => true,
|
73 |
'fname' => wp_get_current_user()->first_name,
|
74 |
'lname' => wp_get_current_user()->last_name,
|
75 |
'email' => wp_get_current_user()->user_email,
|
76 |
'url' => home_url(),
|
77 |
-
|
78 |
}
|
13 |
* @return bool|string
|
14 |
*/
|
15 |
function pum_typenow() {
|
16 |
+
if ( ! empty( $GLOBALS['typenow'] ) ) {
|
17 |
return $GLOBALS['typenow'];
|
18 |
}
|
19 |
|
40 |
*
|
41 |
* @return string Constructed admin URL.
|
42 |
*/
|
43 |
+
function pum_admin_url( $type = '', $query_args = [] ) {
|
44 |
$page = '';
|
45 |
|
46 |
$whitelist = PUM_Admin_Pages::$pages;
|
49 |
$page = "pum-{$type}";
|
50 |
}
|
51 |
|
52 |
+
$admin_query_args = array_merge( [ 'page' => $page ], $query_args );
|
53 |
|
54 |
$url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
|
55 |
|
67 |
* @return array
|
68 |
*/
|
69 |
function pum_support_assist_args() {
|
70 |
+
return [
|
71 |
// Forces the dashboard to force logout any users.
|
72 |
'nouser' => true,
|
73 |
'fname' => wp_get_current_user()->first_name,
|
74 |
'lname' => wp_get_current_user()->last_name,
|
75 |
'email' => wp_get_current_user()->user_email,
|
76 |
'url' => home_url(),
|
77 |
+
];
|
78 |
}
|
includes/functions/developers.php
CHANGED
@@ -14,43 +14,46 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
*
|
15 |
* @since 1.7.0
|
16 |
*
|
17 |
-
* @param int
|
18 |
* @param array $settings
|
19 |
*/
|
20 |
-
function pum_trigger_popup_form_success( $popup_id = null, $settings =
|
21 |
-
if ( ! isset( $popup_id )
|
22 |
$popup_id = isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false;
|
23 |
}
|
24 |
|
25 |
if ( $popup_id ) {
|
26 |
-
PUM_Integrations::$form_success =
|
27 |
'popup_id' => $popup_id,
|
28 |
-
'settings'=> $settings
|
29 |
-
|
30 |
}
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* @param array $args {
|
35 |
-
*
|
36 |
*
|
37 |
-
*
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
* }
|
44 |
*/
|
45 |
function pum_integrated_form_submission( $args = [] ) {
|
46 |
-
$args = wp_parse_args(
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
54 |
|
55 |
$args = apply_filters( 'pum_integrated_form_submission_args', $args );
|
56 |
|
14 |
*
|
15 |
* @since 1.7.0
|
16 |
*
|
17 |
+
* @param int $popup_id
|
18 |
* @param array $settings
|
19 |
*/
|
20 |
+
function pum_trigger_popup_form_success( $popup_id = null, $settings = [] ) {
|
21 |
+
if ( ! isset( $popup_id ) ) {
|
22 |
$popup_id = isset( $_REQUEST['pum_form_popup_id'] ) && absint( $_REQUEST['pum_form_popup_id'] ) > 0 ? absint( $_REQUEST['pum_form_popup_id'] ) : false;
|
23 |
}
|
24 |
|
25 |
if ( $popup_id ) {
|
26 |
+
PUM_Integrations::$form_success = [
|
27 |
'popup_id' => $popup_id,
|
28 |
+
'settings' => $settings,
|
29 |
+
];
|
30 |
}
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* @param array $args {
|
35 |
+
* An array of parameters that customize the way the parser works.
|
36 |
*
|
37 |
+
* @type string $form_provider Key indicating which form provider this form belongs to.
|
38 |
+
* @type string|int $form_id Form ID, usually numeric, but can be hash based.
|
39 |
+
* @type int $form_instance_id Optional form instance ID.
|
40 |
+
* @type int $popup_id Optional popup ID.
|
41 |
+
* @type bool $ajax If the submission was processed via AJAX. Generally gonna be false outside of JavaScript.
|
42 |
+
* @type bool $tracked Whether the submission has been handled by tracking code or not. Prevents duplicates.
|
43 |
* }
|
44 |
*/
|
45 |
function pum_integrated_form_submission( $args = [] ) {
|
46 |
+
$args = wp_parse_args(
|
47 |
+
$args,
|
48 |
+
[
|
49 |
+
'popup_id' => null,
|
50 |
+
'form_provider' => null,
|
51 |
+
'form_id' => null,
|
52 |
+
'form_instance_id' => null,
|
53 |
+
'ajax' => false,
|
54 |
+
'tracked' => false,
|
55 |
+
]
|
56 |
+
);
|
57 |
|
58 |
$args = apply_filters( 'pum_integrated_form_submission_args', $args );
|
59 |
|
includes/functions/extensions.php
CHANGED
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function pum_enabled_extensions() {
|
19 |
-
return apply_filters( 'pum_enabled_extensions',
|
20 |
}
|
21 |
|
22 |
/**
|
16 |
* @return mixed
|
17 |
*/
|
18 |
function pum_enabled_extensions() {
|
19 |
+
return apply_filters( 'pum_enabled_extensions', [] );
|
20 |
}
|
21 |
|
22 |
/**
|
includes/functions/general.php
CHANGED
@@ -84,11 +84,11 @@ function pum_get_all_themes_close_text() {
|
|
84 |
* @return array
|
85 |
*/
|
86 |
function pum_update_all_themes_close_text_cache() {
|
87 |
-
$all_themes_close_text =
|
88 |
|
89 |
$themes = pum_get_all_themes();
|
90 |
|
91 |
-
foreach( $themes as $theme ) {
|
92 |
$all_themes_close_text[ $theme->ID ] = $theme->get_setting( 'close_text', '' );
|
93 |
}
|
94 |
|
@@ -105,7 +105,7 @@ add_action( 'pum_save_theme', 'pum_update_all_themes_close_text_cache', 100 );
|
|
105 |
* @return string
|
106 |
*/
|
107 |
function pum_asset_path( $path = '' ) {
|
108 |
-
return Popup_Maker::$DIR . 'assets/' . ltrim( $path,'/' );
|
109 |
}
|
110 |
|
111 |
/**
|
@@ -114,7 +114,7 @@ function pum_asset_path( $path = '' ) {
|
|
114 |
* @return string
|
115 |
*/
|
116 |
function pum_asset_url( $path = '' ) {
|
117 |
-
return Popup_Maker::$URL . 'assets/' . ltrim( $path,'/' );
|
118 |
}
|
119 |
|
120 |
/**
|
@@ -124,7 +124,7 @@ function pum_asset_url( $path = '' ) {
|
|
124 |
*/
|
125 |
function pum_get_svg_icon( $encode = false ) {
|
126 |
$svg_icon_code = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16" width="16" height="16"><defs><path d="M12.67 1.75L13.12 1.83L13.58 1.97L14.04 2.17L14.49 2.43L14.9 2.77L15.26 3.19L15.57 3.71L15.79 4.28L15.93 4.85L15.99 5.41L16 5.95L15.95 6.45L15.88 6.89L15.78 7.27L15.67 7.57L15.57 7.78L15.45 7.95L15.29 8.16L15.1 8.4L14.87 8.67L14.61 8.95L14.32 9.25L14 9.54L13.66 9.84L13.3 10.13L12.94 10.4L12.61 10.65L12.29 10.88L11.99 11.11L11.69 11.35L11.39 11.59L11.08 11.84L10.76 12.11L10.42 12.42L10.04 12.73L9.63 13.02L9.19 13.29L8.72 13.53L8.23 13.75L7.72 13.93L7.21 14.09L6.69 14.2L6.18 14.28L5.6 14.3L4.9 14.25L4.12 14.09L3.31 13.8L2.5 13.36L1.74 12.76L1.07 11.96L0.52 10.94L0.14 9.68L0 8.36L0.12 7.17L0.45 6.12L0.94 5.2L1.54 4.42L2.22 3.78L2.92 3.29L3.59 2.95L4.19 2.76L4.85 2.63L5.7 2.48L6.68 2.33L7.73 2.18L8.78 2.03L9.79 1.9L10.68 1.8L11.4 1.72L11.88 1.7L12.26 1.7L12.67 1.75ZM10.64 2.39L9.62 2.51L8.48 2.66L7.32 2.82L6.22 2.98L5.26 3.13L4.55 3.26L3.91 3.46L3.18 3.83L2.43 4.38L1.72 5.08L1.12 5.95L0.7 6.96L0.51 8.13L0.63 9.43L1 10.67L1.51 11.67L2.14 12.44L2.86 13.02L3.65 13.41L4.49 13.64L5.34 13.73L6.19 13.71L6.97 13.6L7.64 13.44L8.22 13.23L8.73 12.98L9.17 12.71L9.57 12.41L9.95 12.1L10.32 11.78L10.67 11.48L11 11.21L11.32 10.97L11.63 10.73L11.94 10.5L12.27 10.27L12.61 10.03L12.99 9.76L13.36 9.47L13.71 9.18L14.03 8.88L14.32 8.6L14.57 8.32L14.79 8.08L14.96 7.86L15.08 7.69L15.19 7.47L15.3 7.14L15.4 6.72L15.47 6.23L15.48 5.69L15.44 5.11L15.31 4.53L15.08 3.96L14.78 3.45L14.42 3.06L14.04 2.76L13.62 2.55L13.2 2.41L12.78 2.32L12.38 2.28L12 2.27L11.46 2.31L10.64 2.39Z" id="eLoMHfaS"></path><path d="M8.35 6.04L9.08 7.19L9.35 8.59L9.08 9.99L8.35 11.13L7.27 11.91L5.95 12.19L4.62 11.91L3.54 11.13L2.81 9.99L2.54 8.59L2.81 7.19L3.54 6.04L4.62 5.27L5.95 4.99L7.27 5.27L8.35 6.04ZM4.1 6.6L3.54 7.49L3.34 8.58L3.54 9.67L4.1 10.56L4.93 11.17L5.94 11.39L6.96 11.17L7.79 10.56L8.35 9.67L8.55 8.58L8.35 7.49L7.79 6.6L6.96 5.99L5.94 5.77L4.93 5.99L4.1 6.6Z" id="a1xlBX7eUk"></path><path d="M9.04 9.39L8.35 10.9L9.11 11.66C9.12 11.66 9.12 11.66 9.12 11.66C10.01 10.71 10.41 9.4 10.19 8.11C10.19 8.09 10.18 8.04 10.16 7.95L9.11 8.01L9.04 9.39Z" id="e1KfKU9JEu"></path><path d="M3.74 11.08L2.82 9.7L1.78 9.94C1.78 9.94 1.78 9.94 1.78 9.94C2.1 11.2 3 12.24 4.2 12.74C4.23 12.75 4.28 12.77 4.36 12.8L4.87 11.89L3.74 11.08Z" id="aswxBlyrF"></path><path d="M4.96 5.33L6.62 5.17L6.89 4.14C6.89 4.14 6.89 4.14 6.89 4.14C5.62 3.83 4.29 4.14 3.28 4.96C3.26 4.97 3.22 5.01 3.15 5.07L3.72 5.95L4.96 5.33Z" id="aFREkIqrT"></path><path d="M13.56 4.26L13.97 4.89L14.12 5.67L13.97 6.45L13.56 7.09L12.96 7.52L12.23 7.68L11.5 7.52L10.9 7.09L10.49 6.45L10.34 5.67L10.49 4.89L10.9 4.26L11.5 3.83L12.23 3.67L12.96 3.83L13.56 4.26ZM11.88 5.24L11.77 5.44L11.73 5.68L11.77 5.92L11.88 6.12L12.04 6.25L12.23 6.3L12.42 6.25L12.58 6.12L12.69 5.92L12.73 5.68L12.69 5.44L12.58 5.24L12.42 5.11L12.23 5.06L12.04 5.11L11.88 5.24Z" id="amDpzCYZN"></path><path d="M12.51 2.83L13.24 3.05L13.02 4.27L12.02 3.98L12.51 2.83Z" id="c1FHpaNCVv"></path><path d="M14.65 4.57L14.87 5.29L13.73 5.78L13.42 4.79L14.65 4.57Z" id="c59InZ73I"></path><path d="M14.34 7.35L13.77 7.85L12.85 7.02L13.62 6.33L14.34 7.35Z" id="cp1hej6U"></path><path d="M11.95 8.41L11.2 8.27L11.3 7.03L12.32 7.22L11.95 8.41Z" id="akiLoJGaJ"></path><path d="M9.69 6.69L9.58 5.95L10.78 5.62L10.95 6.64L9.69 6.69Z" id="a12HrJSLIM"></path><path d="M10.05 3.9L10.62 3.4L11.54 4.24L10.76 4.93L10.05 3.9Z" id="alSln9w1"></path></defs><g><g><g><use xlink:href="#eLoMHfaS" opacity="1" fill="black" fill-opacity="1"></use></g><g><g><use xlink:href="#a1xlBX7eUk" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#e1KfKU9JEu" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#aswxBlyrF" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#aFREkIqrT" opacity="1" fill="black" fill-opacity="1"></use></g></g><g><g><use xlink:href="#amDpzCYZN" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#c1FHpaNCVv" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#c59InZ73I" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#cp1hej6U" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#akiLoJGaJ" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#a12HrJSLIM" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#alSln9w1" opacity="1" fill="black" fill-opacity="1"></use></g></g></g></g></svg>';
|
127 |
-
if( $encode ) {
|
128 |
$svg_icon_code = 'data:image/svg+xml;base64,' . base64_encode( $svg_icon_code );
|
129 |
}
|
130 |
return $svg_icon_code;
|
@@ -149,7 +149,7 @@ function pum_reset_assets() {
|
|
149 |
*
|
150 |
* @deprecated 1.8.0
|
151 |
*
|
152 |
-
* @param array
|
153 |
* @param string $path is the dot notated path.
|
154 |
* @param string $default is the default returned if key empty or not found.
|
155 |
*
|
84 |
* @return array
|
85 |
*/
|
86 |
function pum_update_all_themes_close_text_cache() {
|
87 |
+
$all_themes_close_text = [];
|
88 |
|
89 |
$themes = pum_get_all_themes();
|
90 |
|
91 |
+
foreach ( $themes as $theme ) {
|
92 |
$all_themes_close_text[ $theme->ID ] = $theme->get_setting( 'close_text', '' );
|
93 |
}
|
94 |
|
105 |
* @return string
|
106 |
*/
|
107 |
function pum_asset_path( $path = '' ) {
|
108 |
+
return Popup_Maker::$DIR . 'assets/' . ltrim( $path, '/' );
|
109 |
}
|
110 |
|
111 |
/**
|
114 |
* @return string
|
115 |
*/
|
116 |
function pum_asset_url( $path = '' ) {
|
117 |
+
return Popup_Maker::$URL . 'assets/' . ltrim( $path, '/' );
|
118 |
}
|
119 |
|
120 |
/**
|
124 |
*/
|
125 |
function pum_get_svg_icon( $encode = false ) {
|
126 |
$svg_icon_code = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16" width="16" height="16"><defs><path d="M12.67 1.75L13.12 1.83L13.58 1.97L14.04 2.17L14.49 2.43L14.9 2.77L15.26 3.19L15.57 3.71L15.79 4.28L15.93 4.85L15.99 5.41L16 5.95L15.95 6.45L15.88 6.89L15.78 7.27L15.67 7.57L15.57 7.78L15.45 7.95L15.29 8.16L15.1 8.4L14.87 8.67L14.61 8.95L14.32 9.25L14 9.54L13.66 9.84L13.3 10.13L12.94 10.4L12.61 10.65L12.29 10.88L11.99 11.11L11.69 11.35L11.39 11.59L11.08 11.84L10.76 12.11L10.42 12.42L10.04 12.73L9.63 13.02L9.19 13.29L8.72 13.53L8.23 13.75L7.72 13.93L7.21 14.09L6.69 14.2L6.18 14.28L5.6 14.3L4.9 14.25L4.12 14.09L3.31 13.8L2.5 13.36L1.74 12.76L1.07 11.96L0.52 10.94L0.14 9.68L0 8.36L0.12 7.17L0.45 6.12L0.94 5.2L1.54 4.42L2.22 3.78L2.92 3.29L3.59 2.95L4.19 2.76L4.85 2.63L5.7 2.48L6.68 2.33L7.73 2.18L8.78 2.03L9.79 1.9L10.68 1.8L11.4 1.72L11.88 1.7L12.26 1.7L12.67 1.75ZM10.64 2.39L9.62 2.51L8.48 2.66L7.32 2.82L6.22 2.98L5.26 3.13L4.55 3.26L3.91 3.46L3.18 3.83L2.43 4.38L1.72 5.08L1.12 5.95L0.7 6.96L0.51 8.13L0.63 9.43L1 10.67L1.51 11.67L2.14 12.44L2.86 13.02L3.65 13.41L4.49 13.64L5.34 13.73L6.19 13.71L6.97 13.6L7.64 13.44L8.22 13.23L8.73 12.98L9.17 12.71L9.57 12.41L9.95 12.1L10.32 11.78L10.67 11.48L11 11.21L11.32 10.97L11.63 10.73L11.94 10.5L12.27 10.27L12.61 10.03L12.99 9.76L13.36 9.47L13.71 9.18L14.03 8.88L14.32 8.6L14.57 8.32L14.79 8.08L14.96 7.86L15.08 7.69L15.19 7.47L15.3 7.14L15.4 6.72L15.47 6.23L15.48 5.69L15.44 5.11L15.31 4.53L15.08 3.96L14.78 3.45L14.42 3.06L14.04 2.76L13.62 2.55L13.2 2.41L12.78 2.32L12.38 2.28L12 2.27L11.46 2.31L10.64 2.39Z" id="eLoMHfaS"></path><path d="M8.35 6.04L9.08 7.19L9.35 8.59L9.08 9.99L8.35 11.13L7.27 11.91L5.95 12.19L4.62 11.91L3.54 11.13L2.81 9.99L2.54 8.59L2.81 7.19L3.54 6.04L4.62 5.27L5.95 4.99L7.27 5.27L8.35 6.04ZM4.1 6.6L3.54 7.49L3.34 8.58L3.54 9.67L4.1 10.56L4.93 11.17L5.94 11.39L6.96 11.17L7.79 10.56L8.35 9.67L8.55 8.58L8.35 7.49L7.79 6.6L6.96 5.99L5.94 5.77L4.93 5.99L4.1 6.6Z" id="a1xlBX7eUk"></path><path d="M9.04 9.39L8.35 10.9L9.11 11.66C9.12 11.66 9.12 11.66 9.12 11.66C10.01 10.71 10.41 9.4 10.19 8.11C10.19 8.09 10.18 8.04 10.16 7.95L9.11 8.01L9.04 9.39Z" id="e1KfKU9JEu"></path><path d="M3.74 11.08L2.82 9.7L1.78 9.94C1.78 9.94 1.78 9.94 1.78 9.94C2.1 11.2 3 12.24 4.2 12.74C4.23 12.75 4.28 12.77 4.36 12.8L4.87 11.89L3.74 11.08Z" id="aswxBlyrF"></path><path d="M4.96 5.33L6.62 5.17L6.89 4.14C6.89 4.14 6.89 4.14 6.89 4.14C5.62 3.83 4.29 4.14 3.28 4.96C3.26 4.97 3.22 5.01 3.15 5.07L3.72 5.95L4.96 5.33Z" id="aFREkIqrT"></path><path d="M13.56 4.26L13.97 4.89L14.12 5.67L13.97 6.45L13.56 7.09L12.96 7.52L12.23 7.68L11.5 7.52L10.9 7.09L10.49 6.45L10.34 5.67L10.49 4.89L10.9 4.26L11.5 3.83L12.23 3.67L12.96 3.83L13.56 4.26ZM11.88 5.24L11.77 5.44L11.73 5.68L11.77 5.92L11.88 6.12L12.04 6.25L12.23 6.3L12.42 6.25L12.58 6.12L12.69 5.92L12.73 5.68L12.69 5.44L12.58 5.24L12.42 5.11L12.23 5.06L12.04 5.11L11.88 5.24Z" id="amDpzCYZN"></path><path d="M12.51 2.83L13.24 3.05L13.02 4.27L12.02 3.98L12.51 2.83Z" id="c1FHpaNCVv"></path><path d="M14.65 4.57L14.87 5.29L13.73 5.78L13.42 4.79L14.65 4.57Z" id="c59InZ73I"></path><path d="M14.34 7.35L13.77 7.85L12.85 7.02L13.62 6.33L14.34 7.35Z" id="cp1hej6U"></path><path d="M11.95 8.41L11.2 8.27L11.3 7.03L12.32 7.22L11.95 8.41Z" id="akiLoJGaJ"></path><path d="M9.69 6.69L9.58 5.95L10.78 5.62L10.95 6.64L9.69 6.69Z" id="a12HrJSLIM"></path><path d="M10.05 3.9L10.62 3.4L11.54 4.24L10.76 4.93L10.05 3.9Z" id="alSln9w1"></path></defs><g><g><g><use xlink:href="#eLoMHfaS" opacity="1" fill="black" fill-opacity="1"></use></g><g><g><use xlink:href="#a1xlBX7eUk" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#e1KfKU9JEu" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#aswxBlyrF" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#aFREkIqrT" opacity="1" fill="black" fill-opacity="1"></use></g></g><g><g><use xlink:href="#amDpzCYZN" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#c1FHpaNCVv" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#c59InZ73I" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#cp1hej6U" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#akiLoJGaJ" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#a12HrJSLIM" opacity="1" fill="black" fill-opacity="1"></use></g><g><use xlink:href="#alSln9w1" opacity="1" fill="black" fill-opacity="1"></use></g></g></g></g></svg>';
|
127 |
+
if ( $encode ) {
|
128 |
$svg_icon_code = 'data:image/svg+xml;base64,' . base64_encode( $svg_icon_code );
|
129 |
}
|
130 |
return $svg_icon_code;
|
149 |
*
|
150 |
* @deprecated 1.8.0
|
151 |
*
|
152 |
+
* @param array $a is the array you are searching.
|
153 |
* @param string $path is the dot notated path.
|
154 |
* @param string $default is the default returned if key empty or not found.
|
155 |
*
|
includes/functions/newsletter.php
CHANGED
@@ -28,13 +28,13 @@ function pum_get_newsletter_provider( $provider_id ) {
|
|
28 |
/**
|
29 |
* @param string $provider_id
|
30 |
* @param string $context
|
31 |
-
* @param array
|
32 |
*
|
33 |
* @return mixed|string
|
34 |
*/
|
35 |
-
function pum_get_newsletter_provider_message( $provider_id, $context, $values =
|
36 |
$provider = pum_get_newsletter_provider( $provider_id );
|
37 |
-
$default
|
38 |
|
39 |
if ( ! $provider ) {
|
40 |
return $default;
|
@@ -53,15 +53,15 @@ function pum_get_newsletter_provider_message( $provider_id, $context, $values =
|
|
53 |
* @return array|mixed|string
|
54 |
*/
|
55 |
function pum_get_newsletter_default_messages( $context = null ) {
|
56 |
-
$messages =
|
57 |
-
'success' => pum_get_option('default_success_message', __( 'You have been subscribed!', 'popup-maker' ) ),
|
58 |
-
'double_opt_in_success' => pum_get_option('default_double_opt_in_success_message',__( 'Please check your email and confirm your subscription.', 'popup-maker' ) ),
|
59 |
-
'error' => pum_get_option('default_error_message',__( 'Error occurred when subscribing. Please try again.', 'popup-maker' ) ),
|
60 |
-
'already_subscribed' => pum_get_option('default_already_subscribed_message',__( 'You are already a subscriber.', 'popup-maker' ) ),
|
61 |
-
'empty_email' => pum_get_option('default_empty_email_message',__( 'Please enter a valid email.', 'popup-maker' ) ),
|
62 |
-
'invalid_email' => pum_get_option('default_invalid_email_message',__( 'Email provided is not a valid email address.', 'popup-maker' ) ),
|
63 |
-
'consent_required' => pum_get_option('default_consent_required_message',__( 'Email provided is not a valid email address.', 'popup-maker' ) ),
|
64 |
-
|
65 |
|
66 |
if ( $context ) {
|
67 |
return isset( $messages[ $context ] ) ? $messages[ $context ] : '';
|
@@ -74,7 +74,7 @@ function pum_get_newsletter_default_messages( $context = null ) {
|
|
74 |
* @return array
|
75 |
*/
|
76 |
function pum_get_newsletter_admin_localized_vars() {
|
77 |
-
return
|
78 |
'default_provider' => pum_get_option( 'newsletter_default_provider', pum_get_option( 'newsletter_default', '' ) ),
|
79 |
-
|
80 |
}
|
28 |
/**
|
29 |
* @param string $provider_id
|
30 |
* @param string $context
|
31 |
+
* @param array $values
|
32 |
*
|
33 |
* @return mixed|string
|
34 |
*/
|
35 |
+
function pum_get_newsletter_provider_message( $provider_id, $context, $values = [] ) {
|
36 |
$provider = pum_get_newsletter_provider( $provider_id );
|
37 |
+
$default = pum_get_newsletter_default_messages( $context );
|
38 |
|
39 |
if ( ! $provider ) {
|
40 |
return $default;
|
53 |
* @return array|mixed|string
|
54 |
*/
|
55 |
function pum_get_newsletter_default_messages( $context = null ) {
|
56 |
+
$messages = [
|
57 |
+
'success' => pum_get_option( 'default_success_message', __( 'You have been subscribed!', 'popup-maker' ) ),
|
58 |
+
'double_opt_in_success' => pum_get_option( 'default_double_opt_in_success_message', __( 'Please check your email and confirm your subscription.', 'popup-maker' ) ),
|
59 |
+
'error' => pum_get_option( 'default_error_message', __( 'Error occurred when subscribing. Please try again.', 'popup-maker' ) ),
|
60 |
+
'already_subscribed' => pum_get_option( 'default_already_subscribed_message', __( 'You are already a subscriber.', 'popup-maker' ) ),
|
61 |
+
'empty_email' => pum_get_option( 'default_empty_email_message', __( 'Please enter a valid email.', 'popup-maker' ) ),
|
62 |
+
'invalid_email' => pum_get_option( 'default_invalid_email_message', __( 'Email provided is not a valid email address.', 'popup-maker' ) ),
|
63 |
+
'consent_required' => pum_get_option( 'default_consent_required_message', __( 'Email provided is not a valid email address.', 'popup-maker' ) ),
|
64 |
+
];
|
65 |
|
66 |
if ( $context ) {
|
67 |
return isset( $messages[ $context ] ) ? $messages[ $context ] : '';
|
74 |
* @return array
|
75 |
*/
|
76 |
function pum_get_newsletter_admin_localized_vars() {
|
77 |
+
return [
|
78 |
'default_provider' => pum_get_option( 'newsletter_default_provider', pum_get_option( 'newsletter_default', '' ) ),
|
79 |
+
];
|
80 |
}
|
includes/functions/popups/conditionals.php
CHANGED
@@ -59,4 +59,4 @@ function pum_show_close_button( $popup_id = null ) {
|
|
59 |
}
|
60 |
|
61 |
return $popup->show_close_button();
|
62 |
-
}
|
59 |
}
|
60 |
|
61 |
return $popup->show_close_button();
|
62 |
+
}
|
includes/functions/popups/deprecated.php
CHANGED
@@ -23,9 +23,9 @@ function pum_popup( $popup_id = null ) {
|
|
23 |
* @deprecated 1.4
|
24 |
*
|
25 |
* @param $group
|
26 |
-
* @param int
|
27 |
-
* @param null
|
28 |
-
* @param null
|
29 |
*
|
30 |
* @return mixed array|string
|
31 |
*/
|
@@ -37,8 +37,8 @@ function popmake_get_popup_meta( $group, $popup_id = null, $key = null, $default
|
|
37 |
$values = get_post_meta( $popup_id, "popup_{$group}", true );
|
38 |
|
39 |
if ( ! $values ) {
|
40 |
-
$defaults = apply_filters( "popmake_popup_{$group}_defaults",
|
41 |
-
$values
|
42 |
} else {
|
43 |
$values = array_merge( popmake_get_popup_meta_group( $group, $popup_id ), $values );
|
44 |
}
|
@@ -57,7 +57,6 @@ function popmake_get_popup_meta( $group, $popup_id = null, $key = null, $default
|
|
57 |
} else {
|
58 |
$value = $values[ $key ];
|
59 |
}
|
60 |
-
|
61 |
}
|
62 |
|
63 |
return apply_filters( "popmake_get_popup_{$group}_$key", $value, $popup_id );
|
@@ -77,22 +76,22 @@ function popmake_get_popup_meta( $group, $popup_id = null, $key = null, $default
|
|
77 |
* @return mixed array|string
|
78 |
*/
|
79 |
function popmake_get_popup_meta_group( $group, $popup_id = null, $key = null, $default = null ) {
|
80 |
-
if ( ! $popup_id || $group === 'secure_logout') {
|
81 |
$popup_id = pum_get_popup_id();
|
82 |
}
|
83 |
|
84 |
-
$post_meta
|
85 |
|
86 |
if ( ! is_array( $post_meta ) ) {
|
87 |
-
$post_meta =
|
88 |
}
|
89 |
|
90 |
$default_check_key = 'popup_defaults_set';
|
91 |
-
if ( ! in_array( $group,
|
92 |
$default_check_key = "popup_{$group}_defaults_set";
|
93 |
}
|
94 |
|
95 |
-
$group_values = array_key_exists( $default_check_key, $post_meta ) ?
|
96 |
foreach ( $post_meta as $meta_key => $value ) {
|
97 |
if ( strpos( $meta_key, "popup_{$group}_" ) !== false ) {
|
98 |
$new_key = str_replace( "popup_{$group}_", '', $meta_key );
|
23 |
* @deprecated 1.4
|
24 |
*
|
25 |
* @param $group
|
26 |
+
* @param int $popup_id ID number of the popup to retrieve a overlay meta for
|
27 |
+
* @param null $key
|
28 |
+
* @param null $default
|
29 |
*
|
30 |
* @return mixed array|string
|
31 |
*/
|
37 |
$values = get_post_meta( $popup_id, "popup_{$group}", true );
|
38 |
|
39 |
if ( ! $values ) {
|
40 |
+
$defaults = apply_filters( "popmake_popup_{$group}_defaults", [] );
|
41 |
+
$values = array_merge( $defaults, popmake_get_popup_meta_group( $group, $popup_id ) );
|
42 |
} else {
|
43 |
$values = array_merge( popmake_get_popup_meta_group( $group, $popup_id ), $values );
|
44 |
}
|
57 |
} else {
|
58 |
$value = $values[ $key ];
|
59 |
}
|
|
|
60 |
}
|
61 |
|
62 |
return apply_filters( "popmake_get_popup_{$group}_$key", $value, $popup_id );
|
76 |
* @return mixed array|string
|
77 |
*/
|
78 |
function popmake_get_popup_meta_group( $group, $popup_id = null, $key = null, $default = null ) {
|
79 |
+
if ( ! $popup_id || $group === 'secure_logout' ) {
|
80 |
$popup_id = pum_get_popup_id();
|
81 |
}
|
82 |
|
83 |
+
$post_meta = get_post_custom( $popup_id );
|
84 |
|
85 |
if ( ! is_array( $post_meta ) ) {
|
86 |
+
$post_meta = [];
|
87 |
}
|
88 |
|
89 |
$default_check_key = 'popup_defaults_set';
|
90 |
+
if ( ! in_array( $group, [ 'auto_open', 'close', 'display', 'targeting_condition' ] ) ) {
|
91 |
$default_check_key = "popup_{$group}_defaults_set";
|
92 |
}
|
93 |
|
94 |
+
$group_values = array_key_exists( $default_check_key, $post_meta ) ? [] : apply_filters( "popmake_popup_{$group}_defaults", [] );
|
95 |
foreach ( $post_meta as $meta_key => $value ) {
|
96 |
if ( strpos( $meta_key, "popup_{$group}_" ) !== false ) {
|
97 |
$new_key = str_replace( "popup_{$group}_", '', $meta_key );
|
includes/functions/popups/getters.php
CHANGED
@@ -33,7 +33,7 @@ function pum_get_popup_title( $popup_id = null ) {
|
|
33 |
$popup = pum_get_popup( $popup_id );
|
34 |
|
35 |
if ( ! pum_is_popup_object( $popup ) ) {
|
36 |
-
return
|
37 |
}
|
38 |
|
39 |
return $popup->get_title();
|
@@ -44,13 +44,12 @@ function pum_get_popup_title( $popup_id = null ) {
|
|
44 |
*
|
45 |
* @return array
|
46 |
* @deprecated 1.8.0
|
47 |
-
*
|
48 |
*/
|
49 |
function pum_get_popup_triggers( $popup_id = null ) {
|
50 |
$popup = pum_get_popup( $popup_id );
|
51 |
|
52 |
if ( ! pum_is_popup_object( $popup ) ) {
|
53 |
-
return
|
54 |
}
|
55 |
|
56 |
return $popup->get_triggers();
|
33 |
$popup = pum_get_popup( $popup_id );
|
34 |
|
35 |
if ( ! pum_is_popup_object( $popup ) ) {
|
36 |
+
return '';
|
37 |
}
|
38 |
|
39 |
return $popup->get_title();
|
44 |
*
|
45 |
* @return array
|
46 |
* @deprecated 1.8.0
|
|
|
47 |
*/
|
48 |
function pum_get_popup_triggers( $popup_id = null ) {
|
49 |
$popup = pum_get_popup( $popup_id );
|
50 |
|
51 |
if ( ! pum_is_popup_object( $popup ) ) {
|
52 |
+
return [];
|
53 |
}
|
54 |
|
55 |
return $popup->get_triggers();
|
includes/functions/popups/migrations.php
CHANGED
@@ -22,9 +22,11 @@ function pum_passive_popup_upgrades_enabled() {
|
|
22 |
$popup_count = get_transient( 'pum_popup_count' );
|
23 |
|
24 |
if ( $popup_count === false ) {
|
25 |
-
$popup_count = pum_count_popups(
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
set_transient( 'pum_popup_count', $popup_count, HOUR_IN_SECONDS * 24 );
|
30 |
}
|
@@ -43,7 +45,7 @@ function pum_passive_popup_upgrades_enabled() {
|
|
43 |
function pum_popup_migration_2( &$popup ) {
|
44 |
|
45 |
$changed = false;
|
46 |
-
$delete_meta =
|
47 |
|
48 |
/**
|
49 |
* Update pum_sub_form shortcode args
|
@@ -66,8 +68,8 @@ function pum_popup_migration_2( &$popup ) {
|
|
66 |
$theme = $popup->get_meta( 'popup_theme' );
|
67 |
if ( ! empty( $theme ) && is_numeric( $theme ) ) {
|
68 |
$settings['theme_id'] = absint( $theme );
|
69 |
-
$changed
|
70 |
-
$delete_meta[]
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -81,15 +83,18 @@ function pum_popup_migration_2( &$popup ) {
|
|
81 |
foreach ( $keys as $old_key => $new_key ) {
|
82 |
if ( isset( $display[ $old_key ] ) && ! empty( $display[ $old_key ] ) ) {
|
83 |
$settings[ $new_key ] = $display[ $old_key ];
|
84 |
-
$changed
|
85 |
unset( $display[ $old_key ] );
|
86 |
|
87 |
-
if ( in_array(
|
|
|
|
|
88 |
'responsive_min_width',
|
89 |
'responsive_max_width',
|
90 |
'custom_width',
|
91 |
'custom_height',
|
92 |
-
|
|
|
93 |
$settings[ $new_key ] .= $display[ $old_key . '_unit' ];
|
94 |
unset( $display[ $old_key . '_unit' ] );
|
95 |
}
|
@@ -115,7 +120,7 @@ function pum_popup_migration_2( &$popup ) {
|
|
115 |
foreach ( $keys as $old_key => $new_key ) {
|
116 |
if ( isset( $close[ $old_key ] ) ) {
|
117 |
$settings[ $new_key ] = $close[ $old_key ];
|
118 |
-
$changed
|
119 |
unset( $close[ $old_key ] );
|
120 |
}
|
121 |
}
|
@@ -143,7 +148,7 @@ function pum_popup_migration_2( &$popup ) {
|
|
143 |
}
|
144 |
|
145 |
$settings['triggers'] = $triggers;
|
146 |
-
$changed
|
147 |
|
148 |
$delete_meta[] = 'popup_triggers';
|
149 |
}
|
@@ -153,10 +158,10 @@ function pum_popup_migration_2( &$popup ) {
|
|
153 |
*/
|
154 |
$cookies = $popup->get_meta( 'popup_cookies' );
|
155 |
if ( ! empty( $cookies ) && is_array( $cookies ) ) {
|
156 |
-
$cookies
|
157 |
$settings['cookies'] = $cookies;
|
158 |
-
$changed
|
159 |
-
$delete_meta[]
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -172,14 +177,14 @@ function pum_popup_migration_2( &$popup ) {
|
|
172 |
|
173 |
// Clean empty conditions.
|
174 |
if ( ! empty( $condition['target'] ) ) {
|
175 |
-
$fixed_condition =
|
176 |
'target' => $condition['target'],
|
177 |
'not_operand' => isset( $condition['not_operand'] ) ? (bool) $condition['not_operand'] : false,
|
178 |
-
'settings' => isset( $condition['settings'] ) ? $condition['settings'] :
|
179 |
-
|
180 |
|
181 |
foreach ( $condition as $key => $val ) {
|
182 |
-
if ( ! in_array( $key,
|
183 |
$fixed_condition['settings'][ $key ] = $val;
|
184 |
}
|
185 |
}
|
@@ -198,8 +203,8 @@ function pum_popup_migration_2( &$popup ) {
|
|
198 |
}
|
199 |
|
200 |
$settings['conditions'] = $conditions;
|
201 |
-
$changed
|
202 |
-
$delete_meta[]
|
203 |
}
|
204 |
|
205 |
/**
|
@@ -208,8 +213,8 @@ function pum_popup_migration_2( &$popup ) {
|
|
208 |
$mobile_disabled = $popup->get_meta( 'popup_mobile_disabled' );
|
209 |
if ( ! empty( $mobile_disabled ) ) {
|
210 |
$settings['disable_on_mobile'] = (bool) ( $mobile_disabled );
|
211 |
-
$changed
|
212 |
-
$delete_meta[]
|
213 |
}
|
214 |
|
215 |
/**
|
@@ -218,8 +223,8 @@ function pum_popup_migration_2( &$popup ) {
|
|
218 |
$tablet_disabled = $popup->get_meta( 'popup_tablet_disabled' );
|
219 |
if ( ! empty( $tablet_disabled ) ) {
|
220 |
$settings['disable_on_tablet'] = (bool) ( $tablet_disabled );
|
221 |
-
$changed
|
222 |
-
$delete_meta[]
|
223 |
}
|
224 |
|
225 |
/**
|
@@ -229,11 +234,15 @@ function pum_popup_migration_2( &$popup ) {
|
|
229 |
if ( ! empty( $open_count_reset ) && is_array( $open_count_reset ) ) {
|
230 |
foreach ( $open_count_reset as $key => $reset ) {
|
231 |
if ( is_array( $reset ) ) {
|
232 |
-
add_post_meta(
|
233 |
-
|
234 |
-
'
|
235 |
-
|
236 |
-
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
}
|
239 |
|
22 |
$popup_count = get_transient( 'pum_popup_count' );
|
23 |
|
24 |
if ( $popup_count === false ) {
|
25 |
+
$popup_count = pum_count_popups(
|
26 |
+
[
|
27 |
+
'post_status' => [ 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ],
|
28 |
+
]
|
29 |
+
);
|
30 |
|
31 |
set_transient( 'pum_popup_count', $popup_count, HOUR_IN_SECONDS * 24 );
|
32 |
}
|
45 |
function pum_popup_migration_2( &$popup ) {
|
46 |
|
47 |
$changed = false;
|
48 |
+
$delete_meta = [];
|
49 |
|
50 |
/**
|
51 |
* Update pum_sub_form shortcode args
|
68 |
$theme = $popup->get_meta( 'popup_theme' );
|
69 |
if ( ! empty( $theme ) && is_numeric( $theme ) ) {
|
70 |
$settings['theme_id'] = absint( $theme );
|
71 |
+
$changed = true;
|
72 |
+
$delete_meta[] = 'popup_theme';
|
73 |
}
|
74 |
|
75 |
/**
|
83 |
foreach ( $keys as $old_key => $new_key ) {
|
84 |
if ( isset( $display[ $old_key ] ) && ! empty( $display[ $old_key ] ) ) {
|
85 |
$settings[ $new_key ] = $display[ $old_key ];
|
86 |
+
$changed = true;
|
87 |
unset( $display[ $old_key ] );
|
88 |
|
89 |
+
if ( in_array(
|
90 |
+
$old_key,
|
91 |
+
[
|
92 |
'responsive_min_width',
|
93 |
'responsive_max_width',
|
94 |
'custom_width',
|
95 |
'custom_height',
|
96 |
+
]
|
97 |
+
) && isset( $display[ $old_key . '_unit' ] ) ) {
|
98 |
$settings[ $new_key ] .= $display[ $old_key . '_unit' ];
|
99 |
unset( $display[ $old_key . '_unit' ] );
|
100 |
}
|
120 |
foreach ( $keys as $old_key => $new_key ) {
|
121 |
if ( isset( $close[ $old_key ] ) ) {
|
122 |
$settings[ $new_key ] = $close[ $old_key ];
|
123 |
+
$changed = true;
|
124 |
unset( $close[ $old_key ] );
|
125 |
}
|
126 |
}
|
148 |
}
|
149 |
|
150 |
$settings['triggers'] = $triggers;
|
151 |
+
$changed = true;
|
152 |
|
153 |
$delete_meta[] = 'popup_triggers';
|
154 |
}
|
158 |
*/
|
159 |
$cookies = $popup->get_meta( 'popup_cookies' );
|
160 |
if ( ! empty( $cookies ) && is_array( $cookies ) ) {
|
161 |
+
$cookies = ! empty( $settings['cookies'] ) && is_array( $settings['cookies'] ) ? array_merge( $settings['cookies'], $cookies ) : $cookies;
|
162 |
$settings['cookies'] = $cookies;
|
163 |
+
$changed = true;
|
164 |
+
$delete_meta[] = 'popup_cookies';
|
165 |
}
|
166 |
|
167 |
/**
|
177 |
|
178 |
// Clean empty conditions.
|
179 |
if ( ! empty( $condition['target'] ) ) {
|
180 |
+
$fixed_condition = [
|
181 |
'target' => $condition['target'],
|
182 |
'not_operand' => isset( $condition['not_operand'] ) ? (bool) $condition['not_operand'] : false,
|
183 |
+
'settings' => isset( $condition['settings'] ) ? $condition['settings'] : [],
|
184 |
+
];
|
185 |
|
186 |
foreach ( $condition as $key => $val ) {
|
187 |
+
if ( ! in_array( $key, [ 'target', 'not_operand', 'settings' ] ) ) {
|
188 |
$fixed_condition['settings'][ $key ] = $val;
|
189 |
}
|
190 |
}
|
203 |
}
|
204 |
|
205 |
$settings['conditions'] = $conditions;
|
206 |
+
$changed = true;
|
207 |
+
$delete_meta[] = 'popup_conditions';
|
208 |
}
|
209 |
|
210 |
/**
|
213 |
$mobile_disabled = $popup->get_meta( 'popup_mobile_disabled' );
|
214 |
if ( ! empty( $mobile_disabled ) ) {
|
215 |
$settings['disable_on_mobile'] = (bool) ( $mobile_disabled );
|
216 |
+
$changed = true;
|
217 |
+
$delete_meta[] = 'popup_mobile_disabled';
|
218 |
}
|
219 |
|
220 |
/**
|
223 |
$tablet_disabled = $popup->get_meta( 'popup_tablet_disabled' );
|
224 |
if ( ! empty( $tablet_disabled ) ) {
|
225 |
$settings['disable_on_tablet'] = (bool) ( $tablet_disabled );
|
226 |
+
$changed = true;
|
227 |
+
$delete_meta[] = 'popup_tablet_disabled';
|
228 |
}
|
229 |
|
230 |
/**
|
234 |
if ( ! empty( $open_count_reset ) && is_array( $open_count_reset ) ) {
|
235 |
foreach ( $open_count_reset as $key => $reset ) {
|
236 |
if ( is_array( $reset ) ) {
|
237 |
+
add_post_meta(
|
238 |
+
$popup->ID,
|
239 |
+
'popup_count_reset',
|
240 |
+
[
|
241 |
+
'timestamp' => ! empty( $reset['timestamp'] ) ? $reset['timestamp'] : '',
|
242 |
+
'opens' => ! empty( $reset['count'] ) ? absint( $reset['count'] ) : 0,
|
243 |
+
'conversions' => 0,
|
244 |
+
]
|
245 |
+
);
|
246 |
}
|
247 |
}
|
248 |
|
includes/functions/popups/queries.php
CHANGED
@@ -37,7 +37,7 @@ function pum_get_popup( $popup_id = null ) {
|
|
37 |
*
|
38 |
* @return PUM_Model_Popup[]
|
39 |
*/
|
40 |
-
function pum_get_popups( $args =
|
41 |
return pum()->popups->get_items( $args );
|
42 |
}
|
43 |
|
@@ -48,7 +48,7 @@ function pum_get_popups( $args = array() ) {
|
|
48 |
*
|
49 |
* @return PUM_Model_Popup[]
|
50 |
*/
|
51 |
-
function pum_get_all_popups( $args =
|
52 |
$args['posts_per_page'] = -1;
|
53 |
|
54 |
return pum_get_popups( $args );
|
@@ -61,10 +61,13 @@ function pum_get_all_popups( $args = array() ) {
|
|
61 |
*
|
62 |
* @return int
|
63 |
*/
|
64 |
-
function pum_count_popups( $args =
|
65 |
-
$args = wp_parse_args(
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
return pum()->popups->count_items( $args );
|
70 |
}
|
37 |
*
|
38 |
* @return PUM_Model_Popup[]
|
39 |
*/
|
40 |
+
function pum_get_popups( $args = [] ) {
|
41 |
return pum()->popups->get_items( $args );
|
42 |
}
|
43 |
|
48 |
*
|
49 |
* @return PUM_Model_Popup[]
|
50 |
*/
|
51 |
+
function pum_get_all_popups( $args = [] ) {
|
52 |
$args['posts_per_page'] = -1;
|
53 |
|
54 |
return pum_get_popups( $args );
|
61 |
*
|
62 |
* @return int
|
63 |
*/
|
64 |
+
function pum_count_popups( $args = [] ) {
|
65 |
+
$args = wp_parse_args(
|
66 |
+
$args,
|
67 |
+
[
|
68 |
+
'post_status' => 'publish',
|
69 |
+
]
|
70 |
+
);
|
71 |
|
72 |
return pum()->popups->count_items( $args );
|
73 |
}
|
includes/functions/themes/deprecated.php
CHANGED
@@ -31,9 +31,9 @@ function pum_get_theme_v1_meta_defaults() {
|
|
31 |
|
32 |
}
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
/**
|
39 |
* Fetches theme meta group data from v1 data format.
|
@@ -42,9 +42,9 @@ function pum_get_theme_v1_meta_defaults() {
|
|
42 |
* @since 1.8.0
|
43 |
*
|
44 |
* @param $group
|
45 |
-
* @param null
|
46 |
-
* @param null
|
47 |
-
* @param null
|
48 |
*
|
49 |
* @return mixed
|
50 |
*/
|
@@ -56,15 +56,15 @@ function pum_get_theme_v1_meta( $group, $popup_theme_id = null, $key = null, $de
|
|
56 |
$post_meta = get_post_custom( $popup_theme_id );
|
57 |
|
58 |
if ( ! is_array( $post_meta ) ) {
|
59 |
-
$post_meta =
|
60 |
}
|
61 |
|
62 |
$default_check_key = 'popup_theme_defaults_set';
|
63 |
-
if ( ! in_array( $group,
|
64 |
$default_check_key = "popup_{$group}_defaults_set";
|
65 |
}
|
66 |
|
67 |
-
$group_values = array_key_exists( $default_check_key, $post_meta ) ?
|
68 |
foreach ( $post_meta as $meta_key => $value ) {
|
69 |
if ( strpos( $meta_key, "popup_theme_{$group}_" ) !== false ) {
|
70 |
$new_key = str_replace( "popup_theme_{$group}_", '', $meta_key );
|
@@ -99,12 +99,12 @@ function pum_get_theme_v1_meta( $group, $popup_theme_id = null, $key = null, $de
|
|
99 |
* @return array|bool|mixed
|
100 |
*/
|
101 |
function pum_get_theme_v2_meta_defaults( $group = null ) {
|
102 |
-
$defaults =
|
103 |
-
'overlay' =>
|
104 |
'background_color' => '#ffffff',
|
105 |
'background_opacity' => 100,
|
106 |
-
|
107 |
-
'container' =>
|
108 |
'padding' => 18,
|
109 |
'background_color' => '#f9f9f9',
|
110 |
'background_opacity' => 100,
|
@@ -119,8 +119,8 @@ function pum_get_theme_v2_meta_defaults( $group = null ) {
|
|
119 |
'boxshadow_spread' => 0,
|
120 |
'boxshadow_color' => '#020202',
|
121 |
'boxshadow_opacity' => 23,
|
122 |
-
|
123 |
-
'title' =>
|
124 |
'font_color' => '#000000',
|
125 |
'line_height' => 36,
|
126 |
'font_size' => 32,
|
@@ -133,14 +133,14 @@ function pum_get_theme_v2_meta_defaults( $group = null ) {
|
|
133 |
'textshadow_blur' => 0,
|
134 |
'textshadow_color' => '#020202',
|
135 |
'textshadow_opacity' => 23,
|
136 |
-
|
137 |
-
'content' =>
|
138 |
'font_color' => '#8c8c8c',
|
139 |
'font_family' => 'inherit',
|
140 |
'font_weight' => 'inherit',
|
141 |
'font_style' => 'normal',
|
142 |
-
|
143 |
-
'close' =>
|
144 |
'text' => __( 'CLOSE', 'popup-maker' ),
|
145 |
'location' => 'topright',
|
146 |
'position_top' => 0,
|
@@ -174,8 +174,8 @@ function pum_get_theme_v2_meta_defaults( $group = null ) {
|
|
174 |
'textshadow_blur' => 0,
|
175 |
'textshadow_color' => '#000000',
|
176 |
'textshadow_opacity' => 23,
|
177 |
-
|
178 |
-
|
179 |
|
180 |
// Here for backward compatibility with extensions.
|
181 |
foreach ( $defaults as $key => $values ) {
|
@@ -202,13 +202,13 @@ function pum_get_theme_v2_meta( $theme_id = null ) {
|
|
202 |
|
203 |
$defaults = pum_get_theme_v2_meta_defaults();
|
204 |
|
205 |
-
$values =
|
206 |
'overlay' => $theme->get_meta( 'popup_theme_overlay' ),
|
207 |
'container' => $theme->get_meta( 'popup_theme_container' ),
|
208 |
'title' => $theme->get_meta( 'popup_theme_title' ),
|
209 |
'content' => $theme->get_meta( 'popup_theme_content' ),
|
210 |
'close' => $theme->get_meta( 'popup_theme_close' ),
|
211 |
-
|
212 |
|
213 |
foreach ( array_keys( $values ) as $array_key ) {
|
214 |
$values[ $array_key ] = wp_parse_args( $values[ $array_key ], $defaults[ $array_key ] );
|
@@ -342,6 +342,7 @@ function popmake_get_popup_theme_close( $popup_theme_id = null, $key = null, $de
|
|
342 |
}
|
343 |
|
344 |
/**\
|
|
|
345 |
* @deprecated 1.8.0
|
346 |
*
|
347 |
* @param int $theme_id
|
@@ -363,7 +364,7 @@ function popmake_get_popup_theme_data_attr( $theme_id = 0 ) {
|
|
363 |
function popmake_get_popup_themes_data() {
|
364 |
$themes = pum_get_all_themes();
|
365 |
|
366 |
-
$popmake_themes =
|
367 |
|
368 |
foreach ( $themes as $theme ) {
|
369 |
$popmake_themes[ $theme->ID ] = popmake_get_popup_theme_data_attr( $theme->ID );
|
@@ -382,9 +383,9 @@ function popmake_get_popup_themes_data() {
|
|
382 |
* @remove 2.0.0
|
383 |
*
|
384 |
* @param $group
|
385 |
-
* @param int
|
386 |
-
* @param null
|
387 |
-
* @param null
|
388 |
*
|
389 |
* @return mixed array|string of the popup overlay meta
|
390 |
*/
|
@@ -400,9 +401,9 @@ function popmake_get_popup_theme_meta_group( $group, $popup_theme_id = null, $ke
|
|
400 |
* @remove 2.0.0
|
401 |
*
|
402 |
* @param $group
|
403 |
-
* @param null
|
404 |
-
* @param null
|
405 |
-
* @param null
|
406 |
*
|
407 |
* @return mixed
|
408 |
*/
|
31 |
|
32 |
}
|
33 |
|
34 |
+
// TODO LEFT OFF HERE
|
35 |
+
// REFACTOR v1 meta getter & defaults.
|
36 |
+
// CONTINUE PURGING CODE.
|
37 |
|
38 |
/**
|
39 |
* Fetches theme meta group data from v1 data format.
|
42 |
* @since 1.8.0
|
43 |
*
|
44 |
* @param $group
|
45 |
+
* @param null $popup_theme_id
|
46 |
+
* @param null $key
|
47 |
+
* @param null $default
|
48 |
*
|
49 |
* @return mixed
|
50 |
*/
|
56 |
$post_meta = get_post_custom( $popup_theme_id );
|
57 |
|
58 |
if ( ! is_array( $post_meta ) ) {
|
59 |
+
$post_meta = [];
|
60 |
}
|
61 |
|
62 |
$default_check_key = 'popup_theme_defaults_set';
|
63 |
+
if ( ! in_array( $group, [ 'overlay', 'close', 'display', 'targeting_condition' ] ) ) {
|
64 |
$default_check_key = "popup_{$group}_defaults_set";
|
65 |
}
|
66 |
|
67 |
+
$group_values = array_key_exists( $default_check_key, $post_meta ) ? [] : apply_filters( "popmake_popup_theme_{$group}_defaults", [] );
|
68 |
foreach ( $post_meta as $meta_key => $value ) {
|
69 |
if ( strpos( $meta_key, "popup_theme_{$group}_" ) !== false ) {
|
70 |
$new_key = str_replace( "popup_theme_{$group}_", '', $meta_key );
|
99 |
* @return array|bool|mixed
|
100 |
*/
|
101 |
function pum_get_theme_v2_meta_defaults( $group = null ) {
|
102 |
+
$defaults = [
|
103 |
+
'overlay' => [
|
104 |
'background_color' => '#ffffff',
|
105 |
'background_opacity' => 100,
|
106 |
+
],
|
107 |
+
'container' => [
|
108 |
'padding' => 18,
|
109 |
'background_color' => '#f9f9f9',
|
110 |
'background_opacity' => 100,
|
119 |
'boxshadow_spread' => 0,
|
120 |
'boxshadow_color' => '#020202',
|
121 |
'boxshadow_opacity' => 23,
|
122 |
+
],
|
123 |
+
'title' => [
|
124 |
'font_color' => '#000000',
|
125 |
'line_height' => 36,
|
126 |
'font_size' => 32,
|
133 |
'textshadow_blur' => 0,
|
134 |
'textshadow_color' => '#020202',
|
135 |
'textshadow_opacity' => 23,
|
136 |
+
],
|
137 |
+
'content' => [
|
138 |
'font_color' => '#8c8c8c',
|
139 |
'font_family' => 'inherit',
|
140 |
'font_weight' => 'inherit',
|
141 |
'font_style' => 'normal',
|
142 |
+
],
|
143 |
+
'close' => [
|
144 |
'text' => __( 'CLOSE', 'popup-maker' ),
|
145 |
'location' => 'topright',
|
146 |
'position_top' => 0,
|
174 |
'textshadow_blur' => 0,
|
175 |
'textshadow_color' => '#000000',
|
176 |
'textshadow_opacity' => 23,
|
177 |
+
],
|
178 |
+
];
|
179 |
|
180 |
// Here for backward compatibility with extensions.
|
181 |
foreach ( $defaults as $key => $values ) {
|
202 |
|
203 |
$defaults = pum_get_theme_v2_meta_defaults();
|
204 |
|
205 |
+
$values = [
|
206 |
'overlay' => $theme->get_meta( 'popup_theme_overlay' ),
|
207 |
'container' => $theme->get_meta( 'popup_theme_container' ),
|
208 |
'title' => $theme->get_meta( 'popup_theme_title' ),
|
209 |
'content' => $theme->get_meta( 'popup_theme_content' ),
|
210 |
'close' => $theme->get_meta( 'popup_theme_close' ),
|
211 |
+
];
|
212 |
|
213 |
foreach ( array_keys( $values ) as $array_key ) {
|
214 |
$values[ $array_key ] = wp_parse_args( $values[ $array_key ], $defaults[ $array_key ] );
|
342 |
}
|
343 |
|
344 |
/**\
|
345 |
+
*
|
346 |
* @deprecated 1.8.0
|
347 |
*
|
348 |
* @param int $theme_id
|
364 |
function popmake_get_popup_themes_data() {
|
365 |
$themes = pum_get_all_themes();
|
366 |
|
367 |
+
$popmake_themes = [];
|
368 |
|
369 |
foreach ( $themes as $theme ) {
|
370 |
$popmake_themes[ $theme->ID ] = popmake_get_popup_theme_data_attr( $theme->ID );
|
383 |
* @remove 2.0.0
|
384 |
*
|
385 |
* @param $group
|
386 |
+
* @param int $popup_theme_id ID number of the popup to retrieve a overlay meta for
|
387 |
+
* @param null $key
|
388 |
+
* @param null $default
|
389 |
*
|
390 |
* @return mixed array|string of the popup overlay meta
|
391 |
*/
|
401 |
* @remove 2.0.0
|
402 |
*
|
403 |
* @param $group
|
404 |
+
* @param null $popup_theme_id
|
405 |
+
* @param null $key
|
406 |
+
* @param null $default
|
407 |
*
|
408 |
* @return mixed
|
409 |
*/
|
includes/functions/themes/getters.php
CHANGED
@@ -35,7 +35,7 @@ function pum_get_theme_generated_styles( $theme_id = 0 ) {
|
|
35 |
$theme = pum_get_theme( $theme_id );
|
36 |
|
37 |
if ( ! pum_is_theme_object( $theme ) ) {
|
38 |
-
return
|
39 |
}
|
40 |
|
41 |
return $theme->get_generated_styles();
|
35 |
$theme = pum_get_theme( $theme_id );
|
36 |
|
37 |
if ( ! pum_is_theme_object( $theme ) ) {
|
38 |
+
return [];
|
39 |
}
|
40 |
|
41 |
return $theme->get_generated_styles();
|
includes/functions/themes/migrations.php
CHANGED
@@ -22,9 +22,11 @@ function pum_passive_theme_upgrades_enabled() {
|
|
22 |
$theme_count = get_transient( 'pum_theme_count' );
|
23 |
|
24 |
if ( $theme_count === false ) {
|
25 |
-
$theme_count = pum_count_themes(
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
set_transient( 'pum_theme_count', $theme_count, MINUTE_IN_SECONDS );
|
30 |
}
|
@@ -42,7 +44,7 @@ function pum_passive_theme_upgrades_enabled() {
|
|
42 |
*/
|
43 |
function pum_theme_migration_1( &$theme ) {
|
44 |
|
45 |
-
$delete_meta =
|
46 |
|
47 |
// Used to merge with existing values to ensure data integrity.
|
48 |
$meta_defaults = pum_get_theme_v2_meta_defaults();
|
@@ -87,17 +89,17 @@ add_action( 'pum_theme_passive_migration_1', 'pum_theme_migration_1' );
|
|
87 |
function pum_theme_migration_2( &$theme ) {
|
88 |
|
89 |
$changed = false;
|
90 |
-
$delete_meta =
|
91 |
|
92 |
$settings = $theme->get_settings();
|
93 |
|
94 |
-
$old_meta_elements =
|
95 |
'overlay',
|
96 |
'container',
|
97 |
'title',
|
98 |
'content',
|
99 |
'close',
|
100 |
-
|
101 |
|
102 |
foreach ( $old_meta_elements as $element ) {
|
103 |
$meta_key = 'popup_theme_' . $element;
|
@@ -125,7 +127,6 @@ function pum_theme_migration_2( &$theme ) {
|
|
125 |
$theme->update_meta( $meta_key, $element_data );
|
126 |
}
|
127 |
}
|
128 |
-
|
129 |
}
|
130 |
|
131 |
/**
|
22 |
$theme_count = get_transient( 'pum_theme_count' );
|
23 |
|
24 |
if ( $theme_count === false ) {
|
25 |
+
$theme_count = pum_count_themes(
|
26 |
+
[
|
27 |
+
'post_status' => [ 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ],
|
28 |
+
]
|
29 |
+
);
|
30 |
|
31 |
set_transient( 'pum_theme_count', $theme_count, MINUTE_IN_SECONDS );
|
32 |
}
|
44 |
*/
|
45 |
function pum_theme_migration_1( &$theme ) {
|
46 |
|
47 |
+
$delete_meta = [ 'popup_theme_defaults_set' ];
|
48 |
|
49 |
// Used to merge with existing values to ensure data integrity.
|
50 |
$meta_defaults = pum_get_theme_v2_meta_defaults();
|
89 |
function pum_theme_migration_2( &$theme ) {
|
90 |
|
91 |
$changed = false;
|
92 |
+
$delete_meta = [];
|
93 |
|
94 |
$settings = $theme->get_settings();
|
95 |
|
96 |
+
$old_meta_elements = [
|
97 |
'overlay',
|
98 |
'container',
|
99 |
'title',
|
100 |
'content',
|
101 |
'close',
|
102 |
+
];
|
103 |
|
104 |
foreach ( $old_meta_elements as $element ) {
|
105 |
$meta_key = 'popup_theme_' . $element;
|
127 |
$theme->update_meta( $meta_key, $element_data );
|
128 |
}
|
129 |
}
|
|
|
130 |
}
|
131 |
|
132 |
/**
|
includes/functions/themes/portability.php
CHANGED
@@ -10,21 +10,26 @@
|
|
10 |
*
|
11 |
* @return int|\WP_Error
|
12 |
*/
|
13 |
-
function pum_install_theme( $name, $settings = null, $extra_meta =
|
14 |
if ( ! isset( $settings ) ) {
|
15 |
$settings = PUM_Admin_Themes::defaults();
|
16 |
}
|
17 |
|
18 |
-
$new_theme_id = @wp_insert_post(
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
'
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
pum_reset_assets();
|
30 |
|
@@ -38,16 +43,20 @@ function pum_install_theme( $name, $settings = null, $extra_meta = array() ) {
|
|
38 |
* @return mixed
|
39 |
*/
|
40 |
function pum_import_theme_from_repo( $hash ) {
|
41 |
-
$theme_data =
|
42 |
'name' => __( 'Imported Theme', 'popup-maker' ),
|
43 |
'settings' => PUM_Admin_Themes::defaults(),
|
44 |
'original_author' => 'Daniel',
|
45 |
-
|
46 |
|
47 |
-
return pum_install_theme(
|
48 |
-
'
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -58,9 +67,13 @@ function pum_import_theme_from_repo( $hash ) {
|
|
58 |
* @return int|\WP_Error
|
59 |
*/
|
60 |
function pum_install_default_theme() {
|
61 |
-
return pum_install_theme(
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
}
|
10 |
*
|
11 |
* @return int|\WP_Error
|
12 |
*/
|
13 |
+
function pum_install_theme( $name, $settings = null, $extra_meta = [] ) {
|
14 |
if ( ! isset( $settings ) ) {
|
15 |
$settings = PUM_Admin_Themes::defaults();
|
16 |
}
|
17 |
|
18 |
+
$new_theme_id = @wp_insert_post(
|
19 |
+
[
|
20 |
+
'post_title' => $name,
|
21 |
+
'post_author' => get_current_user_id(),
|
22 |
+
'post_status' => 'publish',
|
23 |
+
'post_type' => 'popup_theme',
|
24 |
+
'comment_status' => 'closed',
|
25 |
+
'meta_input' => array_merge(
|
26 |
+
(array) $extra_meta,
|
27 |
+
[
|
28 |
+
'popup_theme_settings' => $settings,
|
29 |
+
]
|
30 |
+
),
|
31 |
+
]
|
32 |
+
);
|
33 |
|
34 |
pum_reset_assets();
|
35 |
|
43 |
* @return mixed
|
44 |
*/
|
45 |
function pum_import_theme_from_repo( $hash ) {
|
46 |
+
$theme_data = [
|
47 |
'name' => __( 'Imported Theme', 'popup-maker' ),
|
48 |
'settings' => PUM_Admin_Themes::defaults(),
|
49 |
'original_author' => 'Daniel',
|
50 |
+
];
|
51 |
|
52 |
+
return pum_install_theme(
|
53 |
+
$theme_data['name'],
|
54 |
+
$theme_data['settings'],
|
55 |
+
[
|
56 |
+
'_pum_theme_repo_hash' => $hash,
|
57 |
+
'_pum_theme_repo_author' => $theme_data['original_author'],
|
58 |
+
]
|
59 |
+
);
|
60 |
}
|
61 |
|
62 |
/**
|
67 |
* @return int|\WP_Error
|
68 |
*/
|
69 |
function pum_install_default_theme() {
|
70 |
+
return pum_install_theme(
|
71 |
+
__( 'Default Theme', 'popup-maker' ),
|
72 |
+
null,
|
73 |
+
[
|
74 |
+
'_pum_built_in' => 'default-theme',
|
75 |
+
'_pum_default_theme' => true,
|
76 |
+
'popup_theme_data_version' => 3,
|
77 |
+
]
|
78 |
+
);
|
79 |
}
|
includes/functions/themes/queries.php
CHANGED
@@ -34,7 +34,7 @@ function pum_get_theme( $theme_id = 0 ) {
|
|
34 |
*
|
35 |
* @return PUM_Model_Theme[]
|
36 |
*/
|
37 |
-
function pum_get_themes( $args =
|
38 |
return pum()->themes->get_items( $args );
|
39 |
}
|
40 |
|
@@ -45,7 +45,7 @@ function pum_get_themes( $args = array() ) {
|
|
45 |
*
|
46 |
* @return PUM_Model_Theme[]
|
47 |
*/
|
48 |
-
function pum_get_all_themes( $args =
|
49 |
$args['posts_per_page'] = -1;
|
50 |
|
51 |
return pum_get_themes( $args );
|
@@ -58,10 +58,13 @@ function pum_get_all_themes( $args = array() ) {
|
|
58 |
*
|
59 |
* @return int
|
60 |
*/
|
61 |
-
function pum_count_themes( $args =
|
62 |
-
$args = wp_parse_args(
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
return pum()->themes->count_items( $args );
|
67 |
}
|
34 |
*
|
35 |
* @return PUM_Model_Theme[]
|
36 |
*/
|
37 |
+
function pum_get_themes( $args = [] ) {
|
38 |
return pum()->themes->get_items( $args );
|
39 |
}
|
40 |
|
45 |
*
|
46 |
* @return PUM_Model_Theme[]
|
47 |
*/
|
48 |
+
function pum_get_all_themes( $args = [] ) {
|
49 |
$args['posts_per_page'] = -1;
|
50 |
|
51 |
return pum_get_themes( $args );
|
58 |
*
|
59 |
* @return int
|
60 |
*/
|
61 |
+
function pum_count_themes( $args = [] ) {
|
62 |
+
$args = wp_parse_args(
|
63 |
+
$args,
|
64 |
+
[
|
65 |
+
'post_status' => 'publish',
|
66 |
+
]
|
67 |
+
);
|
68 |
|
69 |
return pum()->themes->count_items( $args );
|
70 |
}
|
includes/functions/themes/template.php
CHANGED
@@ -47,10 +47,10 @@ function pum_get_rendered_theme_styles( $theme_id ) {
|
|
47 |
break;
|
48 |
|
49 |
case 'close':
|
50 |
-
$css_selector
|
51 |
$admin_bar_selector = "body.admin-bar .pum-theme-{$theme_id} .pum-content + .pum-close";
|
52 |
if ( $slug ) {
|
53 |
-
$css_selector
|
54 |
$admin_bar_selector .= ", body.admin-bar .pum-theme-{$slug} .pum-content + .pum-close";
|
55 |
}
|
56 |
break;
|
@@ -68,7 +68,7 @@ function pum_get_rendered_theme_styles( $theme_id ) {
|
|
68 |
foreach ( $element_rules as $property => $value ) {
|
69 |
if ( ! empty( $value ) ) {
|
70 |
$rule_set .= $sep . $property . ': ' . $value;
|
71 |
-
$sep
|
72 |
}
|
73 |
}
|
74 |
|
@@ -77,10 +77,9 @@ function pum_get_rendered_theme_styles( $theme_id ) {
|
|
77 |
if ( $element === 'close' && ! empty( $admin_bar_selector ) && $theme->get_setting( 'close_position_outside' ) && strpos( $theme->get_setting( 'close_location' ), 'top' ) !== false ) {
|
78 |
$top = ! empty( $element_rules['top'] ) ? (int) str_replace( 'px', '', $element_rules['top'] ) : 0;
|
79 |
// Move it down to compensate for admin bar height.
|
80 |
-
$top
|
81 |
$styles .= "$admin_bar_selector { top: {$top}px }";
|
82 |
}
|
83 |
-
|
84 |
}
|
85 |
|
86 |
return $styles;
|
47 |
break;
|
48 |
|
49 |
case 'close':
|
50 |
+
$css_selector = ".pum-theme-{$theme_id} .pum-content + .pum-close";
|
51 |
$admin_bar_selector = "body.admin-bar .pum-theme-{$theme_id} .pum-content + .pum-close";
|
52 |
if ( $slug ) {
|
53 |
+
$css_selector .= ", .pum-theme-{$slug} .pum-content + .pum-close";
|
54 |
$admin_bar_selector .= ", body.admin-bar .pum-theme-{$slug} .pum-content + .pum-close";
|
55 |
}
|
56 |
break;
|
68 |
foreach ( $element_rules as $property => $value ) {
|
69 |
if ( ! empty( $value ) ) {
|
70 |
$rule_set .= $sep . $property . ': ' . $value;
|
71 |
+
$sep = '; ';
|
72 |
}
|
73 |
}
|
74 |
|
77 |
if ( $element === 'close' && ! empty( $admin_bar_selector ) && $theme->get_setting( 'close_position_outside' ) && strpos( $theme->get_setting( 'close_location' ), 'top' ) !== false ) {
|
78 |
$top = ! empty( $element_rules['top'] ) ? (int) str_replace( 'px', '', $element_rules['top'] ) : 0;
|
79 |
// Move it down to compensate for admin bar height.
|
80 |
+
$top += 32;
|
81 |
$styles .= "$admin_bar_selector { top: {$top}px }";
|
82 |
}
|
|
|
83 |
}
|
84 |
|
85 |
return $styles;
|
includes/functions/utils/cache.php
CHANGED
@@ -51,8 +51,8 @@ function pum_cache_replace( $key, $data, $group = '' ) {
|
|
51 |
*
|
52 |
* @param $key
|
53 |
* @param string $group
|
54 |
-
* @param bool
|
55 |
-
* @param null
|
56 |
*
|
57 |
* @return bool|mixed
|
58 |
*/
|
@@ -87,7 +87,7 @@ function pum_cache_delete_group( $group = '' ) {
|
|
87 |
* Increase a numeric cache value by the offset.
|
88 |
*
|
89 |
* @param $key
|
90 |
-
* @param int
|
91 |
* @param string $group
|
92 |
*
|
93 |
* @return bool|false|int
|
@@ -100,7 +100,7 @@ function pum_cache_incr( $key, $offset = 1, $group = '' ) {
|
|
100 |
* Decrease a numeric cache value by the offset.
|
101 |
*
|
102 |
* @param $key
|
103 |
-
* @param int
|
104 |
* @param string $group
|
105 |
*
|
106 |
* @return bool|false|int
|
@@ -120,7 +120,7 @@ function pum_cache_timeout( $key ) {
|
|
120 |
static $timeouts;
|
121 |
|
122 |
if ( ! isset( $timeouts ) ) {
|
123 |
-
$timeouts = apply_filters( 'pum_cache_timeouts',
|
124 |
}
|
125 |
|
126 |
return isset( $timeouts[ $key ] ) ? $timeouts[ $key ] : 0;
|
51 |
*
|
52 |
* @param $key
|
53 |
* @param string $group
|
54 |
+
* @param bool $force
|
55 |
+
* @param null $found
|
56 |
*
|
57 |
* @return bool|mixed
|
58 |
*/
|
87 |
* Increase a numeric cache value by the offset.
|
88 |
*
|
89 |
* @param $key
|
90 |
+
* @param int $offset
|
91 |
* @param string $group
|
92 |
*
|
93 |
* @return bool|false|int
|
100 |
* Decrease a numeric cache value by the offset.
|
101 |
*
|
102 |
* @param $key
|
103 |
+
* @param int $offset
|
104 |
* @param string $group
|
105 |
*
|
106 |
* @return bool|false|int
|
120 |
static $timeouts;
|
121 |
|
122 |
if ( ! isset( $timeouts ) ) {
|
123 |
+
$timeouts = apply_filters( 'pum_cache_timeouts', [] );
|
124 |
}
|
125 |
|
126 |
return isset( $timeouts[ $key ] ) ? $timeouts[ $key ] : 0;
|
includes/functions/utils/format.php
CHANGED
@@ -29,7 +29,7 @@ function pum_format_number( $number, $format = '' ) {
|
|
29 |
|
30 |
/**
|
31 |
* @param int|float $number
|
32 |
-
* @param string
|
33 |
*
|
34 |
* @return int|string
|
35 |
*/
|
@@ -46,4 +46,4 @@ function pum_format_time( $number, $format = '' ) {
|
|
46 |
*/
|
47 |
function pum_unwrap_urls( $content = '' ) {
|
48 |
return PUM_Utils_Format::unwrap_urls( $content );
|
49 |
-
}
|
29 |
|
30 |
/**
|
31 |
* @param int|float $number
|
32 |
+
* @param string $format U|human|human-readable
|
33 |
*
|
34 |
* @return int|string
|
35 |
*/
|
46 |
*/
|
47 |
function pum_unwrap_urls( $content = '' ) {
|
48 |
return PUM_Utils_Format::unwrap_urls( $content );
|
49 |
+
}
|
includes/functions/utils/options.php
CHANGED
@@ -20,7 +20,7 @@ function pum_get_options() {
|
|
20 |
* Get a forum option.
|
21 |
*
|
22 |
* @param string $key
|
23 |
-
* @param mixed
|
24 |
*
|
25 |
* @return mixed
|
26 |
*/
|
@@ -32,7 +32,7 @@ function pum_get_option( $key, $default = false ) {
|
|
32 |
* Update a forum option.
|
33 |
*
|
34 |
* @param string $key
|
35 |
-
* @param bool
|
36 |
*
|
37 |
* @return bool
|
38 |
*/
|
@@ -47,7 +47,7 @@ function pum_update_option( $key = '', $value = false ) {
|
|
47 |
*
|
48 |
* @return bool
|
49 |
*/
|
50 |
-
function pum_merge_options( $new_options =
|
51 |
return PUM_Utils_Options::merge( $new_options );
|
52 |
}
|
53 |
|
@@ -69,7 +69,7 @@ function pum_delete_option( $key = '' ) {
|
|
69 |
*
|
70 |
* @return bool
|
71 |
*/
|
72 |
-
function pum_delete_options( $keys =
|
73 |
return PUM_Utils_Options::delete( $keys );
|
74 |
}
|
75 |
|
@@ -80,7 +80,7 @@ function pum_delete_options( $keys = array() ) {
|
|
80 |
*
|
81 |
* @return bool
|
82 |
*/
|
83 |
-
function pum_remap_options( $remap_array =
|
84 |
return PUM_Utils_Options::remap_keys( $remap_array );
|
85 |
}
|
86 |
|
20 |
* Get a forum option.
|
21 |
*
|
22 |
* @param string $key
|
23 |
+
* @param mixed $default
|
24 |
*
|
25 |
* @return mixed
|
26 |
*/
|
32 |
* Update a forum option.
|
33 |
*
|
34 |
* @param string $key
|
35 |
+
* @param bool $value
|
36 |
*
|
37 |
* @return bool
|
38 |
*/
|
47 |
*
|
48 |
* @return bool
|
49 |
*/
|
50 |
+
function pum_merge_options( $new_options = [] ) {
|
51 |
return PUM_Utils_Options::merge( $new_options );
|
52 |
}
|
53 |
|
69 |
*
|
70 |
* @return bool
|
71 |
*/
|
72 |
+
function pum_delete_options( $keys = [] ) {
|
73 |
return PUM_Utils_Options::delete( $keys );
|
74 |
}
|
75 |
|
80 |
*
|
81 |
* @return bool
|
82 |
*/
|
83 |
+
function pum_remap_options( $remap_array = [] ) {
|
84 |
return PUM_Utils_Options::remap_keys( $remap_array );
|
85 |
}
|
86 |
|
includes/functions/utils/template.php
CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
*
|
15 |
* @param string $slug
|
16 |
* @param string $name
|
17 |
-
* @param array
|
18 |
*
|
19 |
* @return string
|
20 |
*/
|
@@ -30,9 +30,9 @@ function pum_get_template_part( $slug, $name = null, $args = null ) {
|
|
30 |
*
|
31 |
* @param string $slug
|
32 |
* @param string $name
|
33 |
-
* @param array
|
34 |
*/
|
35 |
-
function pum_template_part( $slug, $name = null, $args =
|
36 |
echo pum_get_template_part( $slug, $name, $args );
|
37 |
}
|
38 |
|
@@ -40,11 +40,11 @@ function pum_template_part( $slug, $name = null, $args = array() ) {
|
|
40 |
* Gets the rendered contents of the specified templates file.
|
41 |
*
|
42 |
* @param $template_name
|
43 |
-
* @param array
|
44 |
*
|
45 |
* @return string
|
46 |
*/
|
47 |
-
function pum_get_template( $template_name, $args =
|
48 |
return PUM_Utils_Template::get( $template_name, $args );
|
49 |
}
|
50 |
|
@@ -54,8 +54,8 @@ function pum_get_template( $template_name, $args = array() ) {
|
|
54 |
* @deprecated Likely a better way @see pum_template_part()
|
55 |
*
|
56 |
* @param string $template_name Template file name with extension: file-name.php
|
57 |
-
* @param array
|
58 |
*/
|
59 |
-
function pum_load_template( $template_name, $args =
|
60 |
echo pum_get_template( $template_name, $args );
|
61 |
-
}
|
14 |
*
|
15 |
* @param string $slug
|
16 |
* @param string $name
|
17 |
+
* @param array $args
|
18 |
*
|
19 |
* @return string
|
20 |
*/
|
30 |
*
|
31 |
* @param string $slug
|
32 |
* @param string $name
|
33 |
+
* @param array $args
|
34 |
*/
|
35 |
+
function pum_template_part( $slug, $name = null, $args = [] ) {
|
36 |
echo pum_get_template_part( $slug, $name, $args );
|
37 |
}
|
38 |
|
40 |
* Gets the rendered contents of the specified templates file.
|
41 |
*
|
42 |
* @param $template_name
|
43 |
+
* @param array $args
|
44 |
*
|
45 |
* @return string
|
46 |
*/
|
47 |
+
function pum_get_template( $template_name, $args = [] ) {
|
48 |
return PUM_Utils_Template::get( $template_name, $args );
|
49 |
}
|
50 |
|
54 |
* @deprecated Likely a better way @see pum_template_part()
|
55 |
*
|
56 |
* @param string $template_name Template file name with extension: file-name.php
|
57 |
+
* @param array $args (default: array())
|
58 |
*/
|
59 |
+
function pum_load_template( $template_name, $args = [] ) {
|
60 |
echo pum_get_template( $template_name, $args );
|
61 |
+
}
|
includes/functions/utils/upgrades.php
CHANGED
@@ -52,7 +52,7 @@ function pum_has_completed_upgrade( $upgrade_id = '' ) {
|
|
52 |
* @param int $post_id
|
53 |
* @param array $keys_to_delete
|
54 |
*/
|
55 |
-
function pum_cleanup_post_meta_keys( $post_id = 0, $keys_to_delete =
|
56 |
/**
|
57 |
* Clean up automatically.
|
58 |
*/
|
@@ -60,7 +60,7 @@ function pum_cleanup_post_meta_keys( $post_id = 0, $keys_to_delete = array() ) {
|
|
60 |
global $wpdb;
|
61 |
|
62 |
$keys_to_delete = array_map( 'esc_sql', (array) $keys_to_delete );
|
63 |
-
$meta_keys
|
64 |
|
65 |
$query = $wpdb->prepare( "DELETE FROM `$wpdb->postmeta` WHERE `post_id` = %d AND `meta_key` IN ('{$meta_keys}')", $post_id );
|
66 |
|
52 |
* @param int $post_id
|
53 |
* @param array $keys_to_delete
|
54 |
*/
|
55 |
+
function pum_cleanup_post_meta_keys( $post_id = 0, $keys_to_delete = [] ) {
|
56 |
/**
|
57 |
* Clean up automatically.
|
58 |
*/
|
60 |
global $wpdb;
|
61 |
|
62 |
$keys_to_delete = array_map( 'esc_sql', (array) $keys_to_delete );
|
63 |
+
$meta_keys = implode( "','", $keys_to_delete );
|
64 |
|
65 |
$query = $wpdb->prepare( "DELETE FROM `$wpdb->postmeta` WHERE `post_id` = %d AND `meta_key` IN ('{$meta_keys}')", $post_id );
|
66 |
|
includes/importer/easy-modal-v2.php
CHANGED
@@ -49,88 +49,91 @@ function popmake_emodal_v2_import() {
|
|
49 |
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/modal/meta.php';
|
50 |
}
|
51 |
|
52 |
-
|
53 |
$themes = get_all_modal_themes( '1 = 1' );
|
54 |
-
$theme_id_map =
|
55 |
foreach ( $themes as $Theme ) {
|
56 |
$theme = $Theme->as_array();
|
57 |
$meta = $theme['meta'];
|
58 |
|
59 |
-
$theme_meta = apply_filters(
|
60 |
-
'
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
125 |
|
126 |
$new_theme_id = wp_insert_post(
|
127 |
-
|
128 |
'post_title' => $theme['name'],
|
129 |
'post_status' => $theme['is_trash'] ? 'trash' : 'publish',
|
130 |
'post_author' => get_current_user_id(),
|
131 |
'post_type' => 'popup_theme',
|
132 |
-
'comment_status' => 'closed'
|
133 |
-
|
134 |
);
|
135 |
foreach ( $theme_meta as $meta_key => $meta_value ) {
|
136 |
update_post_meta( $new_theme_id, $meta_key, $meta_value );
|
@@ -147,61 +150,64 @@ function popmake_emodal_v2_import() {
|
|
147 |
|
148 |
$modals = get_all_modals( '1 = 1' );
|
149 |
|
150 |
-
//echo '<pre>'; var_export(popmake_popup_meta_fields()); echo '</pre>';
|
151 |
|
152 |
foreach ( $modals as $Modal ) {
|
153 |
$modal = $Modal->as_array();
|
154 |
$meta = $modal['meta'];
|
155 |
|
156 |
-
$modal_meta = apply_filters(
|
157 |
-
'
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
|
|
|
|
|
|
186 |
|
187 |
if ( $modal['is_sitewide'] == 1 ) {
|
188 |
$modal_meta['popup_targeting_condition_on_entire_site'] = true;
|
189 |
}
|
190 |
|
191 |
$new_modal_id = wp_insert_post(
|
192 |
-
|
193 |
'post_title' => $modal['name'],
|
194 |
'post_status' => $modal['is_trash'] ? 'trash' : 'publish',
|
195 |
'post_content' => $modal['content'],
|
196 |
'post_author' => get_current_user_id(),
|
197 |
'post_type' => 'popup',
|
198 |
-
'comment_status' => 'closed'
|
199 |
-
|
200 |
);
|
201 |
foreach ( $modal_meta as $meta_key => $meta_value ) {
|
202 |
update_post_meta( $new_modal_id, $meta_key, $meta_value );
|
203 |
}
|
204 |
-
|
205 |
}
|
206 |
}
|
207 |
|
@@ -242,44 +248,50 @@ function popmake_emodal_get_the_popup_data_attr( $data_attr, $popup_id ) {
|
|
242 |
return $data_attr;
|
243 |
}
|
244 |
|
245 |
-
return array_merge(
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
248 |
}
|
249 |
|
250 |
function popmake_emodal_shortcode_modal( $atts, $content = null ) {
|
251 |
$atts = shortcode_atts(
|
252 |
-
apply_filters(
|
253 |
-
'
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
279 |
apply_filters( 'emodal_shortcode_modal_atts', $atts )
|
280 |
);
|
281 |
|
282 |
-
$new_shortcode_atts =
|
283 |
'id' => $atts['id'],
|
284 |
'emodal_id' => $atts['id'],
|
285 |
'theme_id' => $atts['theme_id'],
|
@@ -300,8 +312,8 @@ function popmake_emodal_shortcode_modal( $atts, $content = null ) {
|
|
300 |
'animation_speed' => $atts['animationSpeed'],
|
301 |
'animation_origin' => $atts['animationOrigin'],
|
302 |
'overlay_click' => $atts['overlayClose'],
|
303 |
-
'esc_press' => $atts['escClose']
|
304 |
-
|
305 |
|
306 |
$shortcode = '[popup ';
|
307 |
|
@@ -317,10 +329,13 @@ function popmake_emodal_shortcode_modal( $atts, $content = null ) {
|
|
317 |
}
|
318 |
|
319 |
|
320 |
-
function popmake_emodal_shortcode_popup_default_atts( $default_atts =
|
321 |
-
return array_merge(
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
324 |
}
|
325 |
|
326 |
|
49 |
require_once POPMAKE_DIR . '/includes/importer/easy-modal-v2/model/modal/meta.php';
|
50 |
}
|
51 |
|
|
|
52 |
$themes = get_all_modal_themes( '1 = 1' );
|
53 |
+
$theme_id_map = [];
|
54 |
foreach ( $themes as $Theme ) {
|
55 |
$theme = $Theme->as_array();
|
56 |
$meta = $theme['meta'];
|
57 |
|
58 |
+
$theme_meta = apply_filters(
|
59 |
+
'popmake_emodal_import_theme_meta',
|
60 |
+
[
|
61 |
+
'popup_theme_defaults_set' => true,
|
62 |
+
'popup_theme_overlay_background_color' => $meta['overlay']['background']['color'],
|
63 |
+
'popup_theme_overlay_background_opacity' => $meta['overlay']['background']['opacity'],
|
64 |
+
'popup_theme_container_padding' => $meta['container']['padding'],
|
65 |
+
'popup_theme_container_background_color' => $meta['container']['background']['color'],
|
66 |
+
'popup_theme_container_background_opacity' => $meta['container']['background']['opacity'],
|
67 |
+
'popup_theme_container_border_radius' => $meta['container']['border']['radius'],
|
68 |
+
'popup_theme_container_border_style' => $meta['container']['border']['style'],
|
69 |
+
'popup_theme_container_border_color' => $meta['container']['border']['color'],
|
70 |
+
'popup_theme_container_border_width' => $meta['container']['border']['width'],
|
71 |
+
'popup_theme_container_boxshadow_inset' => $meta['container']['boxshadow']['inset'],
|
72 |
+
'popup_theme_container_boxshadow_horizontal' => $meta['container']['boxshadow']['horizontal'],
|
73 |
+
'popup_theme_container_boxshadow_vertical' => $meta['container']['boxshadow']['vertical'],
|
74 |
+
'popup_theme_container_boxshadow_blur' => $meta['container']['boxshadow']['blur'],
|
75 |
+
'popup_theme_container_boxshadow_spread' => $meta['container']['boxshadow']['spread'],
|
76 |
+
'popup_theme_container_boxshadow_color' => $meta['container']['boxshadow']['color'],
|
77 |
+
'popup_theme_container_boxshadow_opacity' => $meta['container']['boxshadow']['opacity'],
|
78 |
+
'popup_theme_title_font_color' => $meta['title']['font']['color'],
|
79 |
+
'popup_theme_title_line_height' => $meta['title']['font']['size'],
|
80 |
+
'popup_theme_title_font_size' => $meta['title']['font']['size'],
|
81 |
+
'popup_theme_title_font_family' => $meta['title']['font']['family'],
|
82 |
+
'popup_theme_title_font_weight' => $meta['title']['font']['weight'],
|
83 |
+
'popup_theme_title_font_style' => $meta['title']['font']['style'],
|
84 |
+
'popup_theme_title_text_align' => $meta['title']['text']['align'],
|
85 |
+
'popup_theme_title_textshadow_horizontal' => $meta['title']['textshadow']['horizontal'],
|
86 |
+
'popup_theme_title_textshadow_vertical' => $meta['title']['textshadow']['vertical'],
|
87 |
+
'popup_theme_title_textshadow_blur' => $meta['title']['textshadow']['blur'],
|
88 |
+
'popup_theme_title_textshadow_color' => $meta['title']['textshadow']['color'],
|
89 |
+
'popup_theme_title_textshadow_opacity' => $meta['title']['textshadow']['opacity'],
|
90 |
+
'popup_theme_content_font_color' => $meta['content']['font']['color'],
|
91 |
+
'popup_theme_content_font_family' => $meta['content']['font']['family'],
|
92 |
+
'popup_theme_content_font_weight' => $meta['content']['font']['weight'],
|
93 |
+
'popup_theme_content_font_style' => $meta['content']['font']['style'],
|
94 |
+
'popup_theme_close_text' => $meta['close']['text'],
|
95 |
+
'popup_theme_close_padding' => $meta['close']['padding'],
|
96 |
+
'popup_theme_close_location' => $meta['close']['location'],
|
97 |
+
'popup_theme_close_position_top' => $meta['close']['position']['top'],
|
98 |
+
'popup_theme_close_position_left' => $meta['close']['position']['left'],
|
99 |
+
'popup_theme_close_position_bottom' => $meta['close']['position']['bottom'],
|
100 |
+
'popup_theme_close_position_right' => $meta['close']['position']['right'],
|
101 |
+
'popup_theme_close_line_height' => $meta['close']['font']['size'],
|
102 |
+
'popup_theme_close_font_color' => $meta['close']['font']['color'],
|
103 |
+
'popup_theme_close_font_size' => $meta['close']['font']['size'],
|
104 |
+
'popup_theme_close_font_family' => $meta['close']['font']['family'],
|
105 |
+
'popup_theme_close_font_weight' => $meta['close']['font']['weight'],
|
106 |
+
'popup_theme_close_font_style' => $meta['close']['font']['style'],
|
107 |
+
'popup_theme_close_background_color' => $meta['close']['background']['color'],
|
108 |
+
'popup_theme_close_background_opacity' => $meta['close']['background']['opacity'],
|
109 |
+
'popup_theme_close_border_radius' => $meta['close']['border']['radius'],
|
110 |
+
'popup_theme_close_border_style' => $meta['close']['border']['style'],
|
111 |
+
'popup_theme_close_border_color' => $meta['close']['border']['color'],
|
112 |
+
'popup_theme_close_border_width' => $meta['close']['border']['width'],
|
113 |
+
'popup_theme_close_boxshadow_inset' => $meta['close']['boxshadow']['inset'],
|
114 |
+
'popup_theme_close_boxshadow_horizontal' => $meta['close']['boxshadow']['horizontal'],
|
115 |
+
'popup_theme_close_boxshadow_vertical' => $meta['close']['boxshadow']['vertical'],
|
116 |
+
'popup_theme_close_boxshadow_blur' => $meta['close']['boxshadow']['blur'],
|
117 |
+
'popup_theme_close_boxshadow_spread' => $meta['close']['boxshadow']['spread'],
|
118 |
+
'popup_theme_close_boxshadow_color' => $meta['close']['boxshadow']['color'],
|
119 |
+
'popup_theme_close_boxshadow_opacity' => $meta['close']['boxshadow']['opacity'],
|
120 |
+
'popup_theme_close_textshadow_horizontal' => $meta['close']['textshadow']['horizontal'],
|
121 |
+
'popup_theme_close_textshadow_vertical' => $meta['close']['textshadow']['vertical'],
|
122 |
+
'popup_theme_close_textshadow_blur' => $meta['close']['textshadow']['blur'],
|
123 |
+
'popup_theme_close_textshadow_color' => $meta['close']['textshadow']['color'],
|
124 |
+
'popup_theme_close_textshadow_opacity' => $meta['close']['textshadow']['opacity'],
|
125 |
+
],
|
126 |
+
$Theme
|
127 |
+
);
|
128 |
|
129 |
$new_theme_id = wp_insert_post(
|
130 |
+
[
|
131 |
'post_title' => $theme['name'],
|
132 |
'post_status' => $theme['is_trash'] ? 'trash' : 'publish',
|
133 |
'post_author' => get_current_user_id(),
|
134 |
'post_type' => 'popup_theme',
|
135 |
+
'comment_status' => 'closed',
|
136 |
+
]
|
137 |
);
|
138 |
foreach ( $theme_meta as $meta_key => $meta_value ) {
|
139 |
update_post_meta( $new_theme_id, $meta_key, $meta_value );
|
150 |
|
151 |
$modals = get_all_modals( '1 = 1' );
|
152 |
|
153 |
+
// echo '<pre>'; var_export(popmake_popup_meta_fields()); echo '</pre>';
|
154 |
|
155 |
foreach ( $modals as $Modal ) {
|
156 |
$modal = $Modal->as_array();
|
157 |
$meta = $modal['meta'];
|
158 |
|
159 |
+
$modal_meta = apply_filters(
|
160 |
+
'popmake_emodal_import_modal_meta',
|
161 |
+
[
|
162 |
+
'popup_old_easy_modal_id' => $modal['id'],
|
163 |
+
'popup_defaults_set' => true,
|
164 |
+
'popup_theme' => isset( $theme_id_map[ $theme['id'] ] ) ? $theme_id_map[ $theme['id'] ] : null,
|
165 |
+
'popup_title' => $modal['title'],
|
166 |
+
'popup_display_scrollable_content' => null,
|
167 |
+
'popup_display_overlay_disabled' => $meta['display']['overlay_disabled'],
|
168 |
+
'popup_display_size' => $meta['display']['size'],
|
169 |
+
'popup_display_responsive_min_width' => '',
|
170 |
+
'popup_display_responsive_min_width_unit' => 'px',
|
171 |
+
'popup_display_responsive_max_width' => '',
|
172 |
+
'popup_display_responsive_max_width_unit' => 'px',
|
173 |
+
'popup_display_custom_width' => $meta['display']['custom_width'],
|
174 |
+
'popup_display_custom_width_unit' => $meta['display']['custom_width_unit'],
|
175 |
+
'popup_display_custom_height' => $meta['display']['custom_height'],
|
176 |
+
'popup_display_custom_height_unit' => $meta['display']['custom_height_unit'],
|
177 |
+
'popup_display_custom_height_auto' => $meta['display']['custom_height_auto'],
|
178 |
+
'popup_display_location' => $meta['display']['location'],
|
179 |
+
'popup_display_position_top' => $meta['display']['position']['top'],
|
180 |
+
'popup_display_position_left' => $meta['display']['position']['left'],
|
181 |
+
'popup_display_position_bottom' => $meta['display']['position']['bottom'],
|
182 |
+
'popup_display_position_right' => $meta['display']['position']['right'],
|
183 |
+
'popup_display_position_fixed' => $meta['display']['position']['fixed'],
|
184 |
+
'popup_display_animation_type' => $meta['display']['animation']['type'],
|
185 |
+
'popup_display_animation_speed' => $meta['display']['animation']['speed'],
|
186 |
+
'popup_display_animation_origin' => $meta['display']['animation']['origin'],
|
187 |
+
'popup_close_overlay_click' => $meta['close']['overlay_click'],
|
188 |
+
'popup_close_esc_press' => $meta['close']['esc_press'],
|
189 |
+
'popup_close_f4_press' => null,
|
190 |
+
],
|
191 |
+
$Modal
|
192 |
+
);
|
193 |
|
194 |
if ( $modal['is_sitewide'] == 1 ) {
|
195 |
$modal_meta['popup_targeting_condition_on_entire_site'] = true;
|
196 |
}
|
197 |
|
198 |
$new_modal_id = wp_insert_post(
|
199 |
+
[
|
200 |
'post_title' => $modal['name'],
|
201 |
'post_status' => $modal['is_trash'] ? 'trash' : 'publish',
|
202 |
'post_content' => $modal['content'],
|
203 |
'post_author' => get_current_user_id(),
|
204 |
'post_type' => 'popup',
|
205 |
+
'comment_status' => 'closed',
|
206 |
+
]
|
207 |
);
|
208 |
foreach ( $modal_meta as $meta_key => $meta_value ) {
|
209 |
update_post_meta( $new_modal_id, $meta_key, $meta_value );
|
210 |
}
|
|
|
211 |
}
|
212 |
}
|
213 |
|
248 |
return $data_attr;
|
249 |
}
|
250 |
|
251 |
+
return array_merge(
|
252 |
+
$data_attr,
|
253 |
+
[
|
254 |
+
'old_easy_modal_id' => $easy_modal_id,
|
255 |
+
]
|
256 |
+
);
|
257 |
}
|
258 |
|
259 |
function popmake_emodal_shortcode_modal( $atts, $content = null ) {
|
260 |
$atts = shortcode_atts(
|
261 |
+
apply_filters(
|
262 |
+
'emodal_shortcode_modal_default_atts',
|
263 |
+
[
|
264 |
+
'id' => '',
|
265 |
+
'theme_id' => null,
|
266 |
+
'title' => null,
|
267 |
+
'overlay_disabled' => null,
|
268 |
+
'size' => null,
|
269 |
+
'width' => null,
|
270 |
+
'widthUnit' => null,
|
271 |
+
'height' => null,
|
272 |
+
'heightUnit' => null,
|
273 |
+
'location' => null,
|
274 |
+
'positionTop' => null,
|
275 |
+
'positionLeft' => null,
|
276 |
+
'positionBottom' => null,
|
277 |
+
'positionRight' => null,
|
278 |
+
'positionFixed' => null,
|
279 |
+
'animation' => null,
|
280 |
+
'animationSpeed' => null,
|
281 |
+
'animationOrigin' => null,
|
282 |
+
'overlayClose' => null,
|
283 |
+
'escClose' => null,
|
284 |
+
// Deprecated
|
285 |
+
'theme' => null,
|
286 |
+
'duration' => null,
|
287 |
+
'direction' => null,
|
288 |
+
'overlayEscClose' => null,
|
289 |
+
]
|
290 |
+
),
|
291 |
apply_filters( 'emodal_shortcode_modal_atts', $atts )
|
292 |
);
|
293 |
|
294 |
+
$new_shortcode_atts = [
|
295 |
'id' => $atts['id'],
|
296 |
'emodal_id' => $atts['id'],
|
297 |
'theme_id' => $atts['theme_id'],
|
312 |
'animation_speed' => $atts['animationSpeed'],
|
313 |
'animation_origin' => $atts['animationOrigin'],
|
314 |
'overlay_click' => $atts['overlayClose'],
|
315 |
+
'esc_press' => $atts['escClose'],
|
316 |
+
];
|
317 |
|
318 |
$shortcode = '[popup ';
|
319 |
|
329 |
}
|
330 |
|
331 |
|
332 |
+
function popmake_emodal_shortcode_popup_default_atts( $default_atts = [] ) {
|
333 |
+
return array_merge(
|
334 |
+
$default_atts,
|
335 |
+
[
|
336 |
+
'emodal_id' => null,
|
337 |
+
]
|
338 |
+
);
|
339 |
}
|
340 |
|
341 |
|
includes/importer/easy-modal-v2/functions.php
CHANGED
@@ -5,7 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
5 |
exit;
|
6 |
}
|
7 |
|
8 |
-
if ( ! function_exists(
|
9 |
function enqueue_modal( $id ) {
|
10 |
if ( ! is_array( $id ) ) {
|
11 |
EModal_Modals::enqueue_modal( $id );
|
@@ -17,7 +17,7 @@ if ( ! function_exists( "get_all_modals" ) ) {
|
|
17 |
}
|
18 |
}
|
19 |
|
20 |
-
if ( ! function_exists(
|
21 |
function emodal_get_option( $key ) {
|
22 |
global $blog_id;
|
23 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
@@ -29,7 +29,7 @@ if ( ! function_exists( "emodal_get_option" ) ) {
|
|
29 |
}
|
30 |
|
31 |
|
32 |
-
if ( ! function_exists(
|
33 |
function emodal_update_option( $key, $value ) {
|
34 |
global $blog_id;
|
35 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
@@ -40,7 +40,7 @@ if ( ! function_exists( "emodal_update_option" ) ) {
|
|
40 |
}
|
41 |
}
|
42 |
|
43 |
-
if ( ! function_exists(
|
44 |
function emodal_delete_option( $key ) {
|
45 |
global $blog_id;
|
46 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
@@ -51,20 +51,20 @@ if ( ! function_exists( "emodal_delete_option" ) ) {
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
if ( ! function_exists(
|
55 |
function emodal_get_license( $key = null ) {
|
56 |
$license = emodal_get_option( EMCORE_SLUG . '-license' );
|
57 |
if ( ! $license ) {
|
58 |
-
$license =
|
59 |
'valid' => false,
|
60 |
'key' => '',
|
61 |
-
'status' =>
|
62 |
'code' => null,
|
63 |
'message' => null,
|
64 |
'expires' => null,
|
65 |
-
'domains' => null
|
66 |
-
|
67 |
-
|
68 |
emodal_update_option( EMCORE_SLUG . '-license', $license );
|
69 |
}
|
70 |
|
@@ -73,7 +73,7 @@ if ( ! function_exists( "emodal_get_license" ) ) {
|
|
73 |
}
|
74 |
|
75 |
|
76 |
-
if ( ! function_exists(
|
77 |
function emresolve( array $a, $path, $default = null ) {
|
78 |
$current = $a;
|
79 |
$p = strtok( $path, '.' );
|
5 |
exit;
|
6 |
}
|
7 |
|
8 |
+
if ( ! function_exists( 'get_all_modals' ) ) {
|
9 |
function enqueue_modal( $id ) {
|
10 |
if ( ! is_array( $id ) ) {
|
11 |
EModal_Modals::enqueue_modal( $id );
|
17 |
}
|
18 |
}
|
19 |
|
20 |
+
if ( ! function_exists( 'emodal_get_option' ) ) {
|
21 |
function emodal_get_option( $key ) {
|
22 |
global $blog_id;
|
23 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
29 |
}
|
30 |
|
31 |
|
32 |
+
if ( ! function_exists( 'emodal_update_option' ) ) {
|
33 |
function emodal_update_option( $key, $value ) {
|
34 |
global $blog_id;
|
35 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
40 |
}
|
41 |
}
|
42 |
|
43 |
+
if ( ! function_exists( 'emodal_delete_option' ) ) {
|
44 |
function emodal_delete_option( $key ) {
|
45 |
global $blog_id;
|
46 |
if ( function_exists( 'is_multisite' ) && is_multisite() && $blog_id ) {
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
if ( ! function_exists( 'emodal_get_license' ) ) {
|
55 |
function emodal_get_license( $key = null ) {
|
56 |
$license = emodal_get_option( EMCORE_SLUG . '-license' );
|
57 |
if ( ! $license ) {
|
58 |
+
$license = [
|
59 |
'valid' => false,
|
60 |
'key' => '',
|
61 |
+
'status' => [
|
62 |
'code' => null,
|
63 |
'message' => null,
|
64 |
'expires' => null,
|
65 |
+
'domains' => null,
|
66 |
+
],
|
67 |
+
];
|
68 |
emodal_update_option( EMCORE_SLUG . '-license', $license );
|
69 |
}
|
70 |
|
73 |
}
|
74 |
|
75 |
|
76 |
+
if ( ! function_exists( 'emresolve' ) ) {
|
77 |
function emresolve( array $a, $path, $default = null ) {
|
78 |
$current = $a;
|
79 |
$p = strtok( $path, '.' );
|
includes/importer/easy-modal-v2/model.php
CHANGED
@@ -6,12 +6,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
}
|
7 |
|
8 |
class EModal_Model {
|
9 |
-
protected $_class_name
|
10 |
-
protected $_table_name
|
11 |
-
protected $_pk
|
12 |
-
protected $_data
|
13 |
-
protected $_default_fields =
|
14 |
-
protected $_state
|
15 |
|
16 |
public function __construct( $id = null, $limit = 1 ) {
|
17 |
global $wpdb;
|
@@ -26,7 +26,7 @@ class EModal_Model {
|
|
26 |
$this->process_load( $row );
|
27 |
}
|
28 |
} else {
|
29 |
-
$this->set_fields( apply_filters( "{$class_name}_defaults",
|
30 |
}
|
31 |
|
32 |
return $this;
|
@@ -41,9 +41,9 @@ class EModal_Model {
|
|
41 |
}
|
42 |
$rows = $wpdb->get_results( $query, ARRAY_A );
|
43 |
if ( ! empty( $rows ) ) {
|
44 |
-
$results =
|
45 |
foreach ( $rows as $row ) {
|
46 |
-
$model = new $this->_class_name;
|
47 |
$model->process_load( $row );
|
48 |
$results[] = $model;
|
49 |
}
|
@@ -51,14 +51,14 @@ class EModal_Model {
|
|
51 |
return $results;
|
52 |
}
|
53 |
|
54 |
-
return
|
55 |
}
|
56 |
|
57 |
public function save() {
|
58 |
global $wpdb;
|
59 |
$table_name = $wpdb->prefix . $this->_table_name;
|
60 |
if ( $this->id ) {
|
61 |
-
if ( ! $wpdb->update( $table_name, $this->serialized_values(),
|
62 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
63 |
$this->id = $wpdb->insert_id;
|
64 |
}
|
@@ -72,7 +72,7 @@ class EModal_Model {
|
|
72 |
global $wpdb;
|
73 |
$table_name = $wpdb->prefix . $this->_table_name;
|
74 |
|
75 |
-
return $wpdb->delete( $table_name,
|
76 |
}
|
77 |
|
78 |
public function as_array() {
|
@@ -158,4 +158,4 @@ class EModal_Model {
|
|
158 |
public function offsetUnset( $key ) {
|
159 |
$this->_data[ $key ] = null;
|
160 |
}
|
161 |
-
}
|
6 |
}
|
7 |
|
8 |
class EModal_Model {
|
9 |
+
protected $_class_name = 'EModal_Model';
|
10 |
+
protected $_table_name = '';
|
11 |
+
protected $_pk = 'id';
|
12 |
+
protected $_data = [];
|
13 |
+
protected $_default_fields = [];
|
14 |
+
protected $_state = null;
|
15 |
|
16 |
public function __construct( $id = null, $limit = 1 ) {
|
17 |
global $wpdb;
|
26 |
$this->process_load( $row );
|
27 |
}
|
28 |
} else {
|
29 |
+
$this->set_fields( apply_filters( "{$class_name}_defaults", [] ) );
|
30 |
}
|
31 |
|
32 |
return $this;
|
41 |
}
|
42 |
$rows = $wpdb->get_results( $query, ARRAY_A );
|
43 |
if ( ! empty( $rows ) ) {
|
44 |
+
$results = [];
|
45 |
foreach ( $rows as $row ) {
|
46 |
+
$model = new $this->_class_name();
|
47 |
$model->process_load( $row );
|
48 |
$results[] = $model;
|
49 |
}
|
51 |
return $results;
|
52 |
}
|
53 |
|
54 |
+
return [];
|
55 |
}
|
56 |
|
57 |
public function save() {
|
58 |
global $wpdb;
|
59 |
$table_name = $wpdb->prefix . $this->_table_name;
|
60 |
if ( $this->id ) {
|
61 |
+
if ( ! $wpdb->update( $table_name, $this->serialized_values(), [ $this->_pk => $this->{$this->_pk} ] ) ) {
|
62 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
63 |
$this->id = $wpdb->insert_id;
|
64 |
}
|
72 |
global $wpdb;
|
73 |
$table_name = $wpdb->prefix . $this->_table_name;
|
74 |
|
75 |
+
return $wpdb->delete( $table_name, [ $this->_pk => $this->{$this->_pk} ] );
|
76 |
}
|
77 |
|
78 |
public function as_array() {
|
158 |
public function offsetUnset( $key ) {
|
159 |
$this->_data[ $key ] = null;
|
160 |
}
|
161 |
+
}
|
includes/importer/easy-modal-v2/model/modal.php
CHANGED
@@ -9,7 +9,7 @@ class EModal_Model_Modal extends EModal_Model {
|
|
9 |
protected $_class_name = 'EModal_Model_Modal';
|
10 |
protected $_table_name = 'em_modals';
|
11 |
protected $meta;
|
12 |
-
protected $_default_fields =
|
13 |
'id' => null,
|
14 |
'theme_id' => 1,
|
15 |
'name' => '',
|
@@ -19,8 +19,8 @@ class EModal_Model_Modal extends EModal_Model {
|
|
19 |
'modified' => '0000-00-00 00:00:00',
|
20 |
'is_sitewide' => 0,
|
21 |
'is_system' => 0,
|
22 |
-
'is_trash' => 0
|
23 |
-
|
24 |
|
25 |
public function __construct( $id = null ) {
|
26 |
parent::__construct( $id );
|
@@ -70,19 +70,19 @@ class EModal_Model_Modal extends EModal_Model {
|
|
70 |
}
|
71 |
}
|
72 |
|
73 |
-
if ( ! function_exists(
|
74 |
-
function get_all_modals( $where =
|
75 |
global $wpdb;
|
76 |
-
$modals =
|
77 |
-
$modal_ids =
|
78 |
-
$EModal_Model_Modal = new EModal_Model_Modal;
|
79 |
-
$EModal_Model_Modal_Meta = new EModal_Model_Modal_Meta;
|
80 |
-
foreach ( $EModal_Model_Modal->load( "SELECT * FROM {$wpdb->prefix}em_modals" . ( $where ?
|
81 |
$modals[ $modal->id ] = $modal;
|
82 |
$modal_ids[] = $modal->id;
|
83 |
}
|
84 |
if ( count( $modals ) ) {
|
85 |
-
foreach ( $EModal_Model_Modal_Meta->load( "SELECT * FROM {$wpdb->prefix}em_modal_metas WHERE modal_id IN (" . implode( ',', $modal_ids ) .
|
86 |
$modals[ $meta->modal_id ]->meta->process_load( $meta->as_array() );
|
87 |
}
|
88 |
}
|
@@ -91,7 +91,7 @@ if ( ! function_exists( "get_all_modals" ) ) {
|
|
91 |
}
|
92 |
}
|
93 |
|
94 |
-
if ( ! function_exists(
|
95 |
function get_current_modal( $key = null ) {
|
96 |
global $current_modal;
|
97 |
if ( ! $key ) {
|
@@ -104,7 +104,7 @@ if ( ! function_exists( "get_current_modal" ) ) {
|
|
104 |
}
|
105 |
}
|
106 |
|
107 |
-
if ( ! function_exists(
|
108 |
function get_current_modal_id() {
|
109 |
global $current_modal;
|
110 |
|
@@ -112,7 +112,7 @@ if ( ! function_exists( "get_current_modal_id" ) ) {
|
|
112 |
}
|
113 |
}
|
114 |
|
115 |
-
if ( ! function_exists(
|
116 |
function count_all_modals() {
|
117 |
global $wpdb;
|
118 |
|
@@ -120,10 +120,10 @@ if ( ! function_exists( "count_all_modals" ) ) {
|
|
120 |
}
|
121 |
}
|
122 |
|
123 |
-
if ( ! function_exists(
|
124 |
function count_deleted_modals() {
|
125 |
global $wpdb;
|
126 |
|
127 |
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}em_modals WHERE is_trash = 1" );
|
128 |
}
|
129 |
-
}
|
9 |
protected $_class_name = 'EModal_Model_Modal';
|
10 |
protected $_table_name = 'em_modals';
|
11 |
protected $meta;
|
12 |
+
protected $_default_fields = [
|
13 |
'id' => null,
|
14 |
'theme_id' => 1,
|
15 |
'name' => '',
|
19 |
'modified' => '0000-00-00 00:00:00',
|
20 |
'is_sitewide' => 0,
|
21 |
'is_system' => 0,
|
22 |
+
'is_trash' => 0,
|
23 |
+
];
|
24 |
|
25 |
public function __construct( $id = null ) {
|
26 |
parent::__construct( $id );
|
70 |
}
|
71 |
}
|
72 |
|
73 |
+
if ( ! function_exists( 'get_all_modals' ) ) {
|
74 |
+
function get_all_modals( $where = 'is_trash != 1' ) {
|
75 |
global $wpdb;
|
76 |
+
$modals = [];
|
77 |
+
$modal_ids = [];
|
78 |
+
$EModal_Model_Modal = new EModal_Model_Modal();
|
79 |
+
$EModal_Model_Modal_Meta = new EModal_Model_Modal_Meta();
|
80 |
+
foreach ( $EModal_Model_Modal->load( "SELECT * FROM {$wpdb->prefix}em_modals" . ( $where ? ' WHERE ' . $where : '' ) ) as $modal ) {
|
81 |
$modals[ $modal->id ] = $modal;
|
82 |
$modal_ids[] = $modal->id;
|
83 |
}
|
84 |
if ( count( $modals ) ) {
|
85 |
+
foreach ( $EModal_Model_Modal_Meta->load( "SELECT * FROM {$wpdb->prefix}em_modal_metas WHERE modal_id IN (" . implode( ',', $modal_ids ) . ')' ) as $meta ) {
|
86 |
$modals[ $meta->modal_id ]->meta->process_load( $meta->as_array() );
|
87 |
}
|
88 |
}
|
91 |
}
|
92 |
}
|
93 |
|
94 |
+
if ( ! function_exists( 'get_current_modal' ) ) {
|
95 |
function get_current_modal( $key = null ) {
|
96 |
global $current_modal;
|
97 |
if ( ! $key ) {
|
104 |
}
|
105 |
}
|
106 |
|
107 |
+
if ( ! function_exists( 'get_current_modal_id' ) ) {
|
108 |
function get_current_modal_id() {
|
109 |
global $current_modal;
|
110 |
|
112 |
}
|
113 |
}
|
114 |
|
115 |
+
if ( ! function_exists( 'count_all_modals' ) ) {
|
116 |
function count_all_modals() {
|
117 |
global $wpdb;
|
118 |
|
120 |
}
|
121 |
}
|
122 |
|
123 |
+
if ( ! function_exists( 'count_deleted_modals' ) ) {
|
124 |
function count_deleted_modals() {
|
125 |
global $wpdb;
|
126 |
|
127 |
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}em_modals WHERE is_trash = 1" );
|
128 |
}
|
129 |
+
}
|
includes/importer/easy-modal-v2/model/modal/meta.php
CHANGED
@@ -6,15 +6,15 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
}
|
7 |
|
8 |
class EModal_Model_Modal_Meta extends EModal_Model {
|
9 |
-
protected $_class_name
|
10 |
-
protected $_table_name
|
11 |
-
protected $_pk
|
12 |
-
protected $_default_fields =
|
13 |
'id' => null,
|
14 |
'modal_id' => null,
|
15 |
-
'display' =>
|
16 |
-
'close' =>
|
17 |
-
|
18 |
|
19 |
public function __construct( $id = null ) {
|
20 |
global $wpdb;
|
@@ -31,7 +31,7 @@ class EModal_Model_Modal_Meta extends EModal_Model {
|
|
31 |
$this->process_load( $row );
|
32 |
}
|
33 |
} else {
|
34 |
-
$this->set_fields( apply_filters( "{$class_name}_defaults",
|
35 |
}
|
36 |
|
37 |
return $this;
|
@@ -44,11 +44,11 @@ class EModal_Model_Modal_Meta extends EModal_Model {
|
|
44 |
$rows = $wpdb->get_col( "SELECT id FROM $table_name WHERE modal_id = $this->modal_id ORDER BY id DESC" );
|
45 |
if ( count( $rows ) ) {
|
46 |
$this->id = $rows[0];
|
47 |
-
$wpdb->update( $table_name, $this->serialized_values(),
|
48 |
} else {
|
49 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
50 |
$this->id = $wpdb->insert_id;
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
}
|
6 |
}
|
7 |
|
8 |
class EModal_Model_Modal_Meta extends EModal_Model {
|
9 |
+
protected $_class_name = 'EModal_Model_Modal_Meta';
|
10 |
+
protected $_table_name = 'em_modal_metas';
|
11 |
+
protected $_pk = 'modal_id';
|
12 |
+
protected $_default_fields = [
|
13 |
'id' => null,
|
14 |
'modal_id' => null,
|
15 |
+
'display' => [],
|
16 |
+
'close' => [],
|
17 |
+
];
|
18 |
|
19 |
public function __construct( $id = null ) {
|
20 |
global $wpdb;
|
31 |
$this->process_load( $row );
|
32 |
}
|
33 |
} else {
|
34 |
+
$this->set_fields( apply_filters( "{$class_name}_defaults", [] ) );
|
35 |
}
|
36 |
|
37 |
return $this;
|
44 |
$rows = $wpdb->get_col( "SELECT id FROM $table_name WHERE modal_id = $this->modal_id ORDER BY id DESC" );
|
45 |
if ( count( $rows ) ) {
|
46 |
$this->id = $rows[0];
|
47 |
+
$wpdb->update( $table_name, $this->serialized_values(), [ 'id' => $this->id ] );
|
48 |
} else {
|
49 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
50 |
$this->id = $wpdb->insert_id;
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
}
|
includes/importer/easy-modal-v2/model/theme.php
CHANGED
@@ -9,14 +9,14 @@ class EModal_Model_Theme extends EModal_Model {
|
|
9 |
protected $_class_name = 'EModal_Model_Theme';
|
10 |
protected $_table_name = 'em_themes';
|
11 |
protected $meta;
|
12 |
-
protected $_default_fields =
|
13 |
'id' => null,
|
14 |
'name' => 'Default',
|
15 |
'created' => '0000-00-00 00:00:00',
|
16 |
'modified' => '0000-00-00 00:00:00',
|
17 |
'is_system' => 0,
|
18 |
-
'is_trash' => 0
|
19 |
-
|
20 |
|
21 |
public function __construct( $id = null ) {
|
22 |
parent::__construct( $id );
|
@@ -67,20 +67,20 @@ class EModal_Model_Theme extends EModal_Model {
|
|
67 |
}
|
68 |
}
|
69 |
|
70 |
-
if ( ! function_exists(
|
71 |
-
function get_all_modal_themes( $where =
|
72 |
global $wpdb;
|
73 |
|
74 |
-
$themes =
|
75 |
-
$theme_ids =
|
76 |
-
$EModal_Model_Theme = new EModal_Model_Theme;
|
77 |
-
$EModal_Model_Theme_Meta = new EModal_Model_Theme_Meta;
|
78 |
-
foreach ( $EModal_Model_Theme->load( "SELECT * FROM {$wpdb->prefix}em_themes" . ( $where ?
|
79 |
$themes[ $theme->id ] = $theme;
|
80 |
$theme_ids[] = $theme->id;
|
81 |
}
|
82 |
if ( count( $themes ) ) {
|
83 |
-
foreach ( $EModal_Model_Theme_Meta->load( "SELECT * FROM {$wpdb->prefix}em_theme_metas WHERE theme_id IN (" . implode( ',', $theme_ids ) .
|
84 |
$themes[ $meta->theme_id ]->meta->process_load( $meta->as_array() );
|
85 |
}
|
86 |
}
|
@@ -89,7 +89,7 @@ if ( ! function_exists( "get_all_modal_themes" ) ) {
|
|
89 |
}
|
90 |
}
|
91 |
|
92 |
-
if ( ! function_exists(
|
93 |
function get_current_modal_theme( $key = null ) {
|
94 |
global $current_theme;
|
95 |
if ( ! $key ) {
|
@@ -102,7 +102,7 @@ if ( ! function_exists( "get_current_modal_theme" ) ) {
|
|
102 |
}
|
103 |
}
|
104 |
|
105 |
-
if ( ! function_exists(
|
106 |
function get_current_modal_theme_id() {
|
107 |
global $current_theme;
|
108 |
|
@@ -111,7 +111,7 @@ if ( ! function_exists( "get_current_modal_theme_id" ) ) {
|
|
111 |
}
|
112 |
|
113 |
|
114 |
-
if ( ! function_exists(
|
115 |
function count_all_modal_themes() {
|
116 |
global $wpdb;
|
117 |
|
@@ -119,10 +119,10 @@ if ( ! function_exists( "count_all_modal_themes" ) ) {
|
|
119 |
}
|
120 |
}
|
121 |
|
122 |
-
if ( ! function_exists(
|
123 |
function count_deleted_modal_themes() {
|
124 |
global $wpdb;
|
125 |
|
126 |
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}em_themes WHERE is_trash = 1" );
|
127 |
}
|
128 |
-
}
|
9 |
protected $_class_name = 'EModal_Model_Theme';
|
10 |
protected $_table_name = 'em_themes';
|
11 |
protected $meta;
|
12 |
+
protected $_default_fields = [
|
13 |
'id' => null,
|
14 |
'name' => 'Default',
|
15 |
'created' => '0000-00-00 00:00:00',
|
16 |
'modified' => '0000-00-00 00:00:00',
|
17 |
'is_system' => 0,
|
18 |
+
'is_trash' => 0,
|
19 |
+
];
|
20 |
|
21 |
public function __construct( $id = null ) {
|
22 |
parent::__construct( $id );
|
67 |
}
|
68 |
}
|
69 |
|
70 |
+
if ( ! function_exists( 'get_all_modal_themes' ) ) {
|
71 |
+
function get_all_modal_themes( $where = 'is_trash != 1' ) {
|
72 |
global $wpdb;
|
73 |
|
74 |
+
$themes = [];
|
75 |
+
$theme_ids = [];
|
76 |
+
$EModal_Model_Theme = new EModal_Model_Theme();
|
77 |
+
$EModal_Model_Theme_Meta = new EModal_Model_Theme_Meta();
|
78 |
+
foreach ( $EModal_Model_Theme->load( "SELECT * FROM {$wpdb->prefix}em_themes" . ( $where ? ' WHERE ' . $where : '' ) ) as $theme ) {
|
79 |
$themes[ $theme->id ] = $theme;
|
80 |
$theme_ids[] = $theme->id;
|
81 |
}
|
82 |
if ( count( $themes ) ) {
|
83 |
+
foreach ( $EModal_Model_Theme_Meta->load( "SELECT * FROM {$wpdb->prefix}em_theme_metas WHERE theme_id IN (" . implode( ',', $theme_ids ) . ')' ) as $meta ) {
|
84 |
$themes[ $meta->theme_id ]->meta->process_load( $meta->as_array() );
|
85 |
}
|
86 |
}
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
if ( ! function_exists( 'get_current_modal_theme' ) ) {
|
93 |
function get_current_modal_theme( $key = null ) {
|
94 |
global $current_theme;
|
95 |
if ( ! $key ) {
|
102 |
}
|
103 |
}
|
104 |
|
105 |
+
if ( ! function_exists( 'get_current_modal_theme_id' ) ) {
|
106 |
function get_current_modal_theme_id() {
|
107 |
global $current_theme;
|
108 |
|
111 |
}
|
112 |
|
113 |
|
114 |
+
if ( ! function_exists( 'count_all_modal_themes' ) ) {
|
115 |
function count_all_modal_themes() {
|
116 |
global $wpdb;
|
117 |
|
119 |
}
|
120 |
}
|
121 |
|
122 |
+
if ( ! function_exists( 'count_deleted_modal_themes' ) ) {
|
123 |
function count_deleted_modal_themes() {
|
124 |
global $wpdb;
|
125 |
|
126 |
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}em_themes WHERE is_trash = 1" );
|
127 |
}
|
128 |
+
}
|
includes/importer/easy-modal-v2/model/theme/meta.php
CHANGED
@@ -6,18 +6,18 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
}
|
7 |
|
8 |
class EModal_Model_Theme_Meta extends EModal_Model {
|
9 |
-
protected $_class_name
|
10 |
-
protected $_table_name
|
11 |
-
protected $_pk
|
12 |
-
protected $_default_fields =
|
13 |
'id' => null,
|
14 |
'theme_id' => null,
|
15 |
-
'overlay' =>
|
16 |
-
'container' =>
|
17 |
-
'close' =>
|
18 |
-
'title' =>
|
19 |
-
'content' =>
|
20 |
-
|
21 |
|
22 |
public function __construct( $id = null ) {
|
23 |
global $wpdb;
|
@@ -32,7 +32,7 @@ class EModal_Model_Theme_Meta extends EModal_Model {
|
|
32 |
$this->process_load( $row );
|
33 |
}
|
34 |
} else {
|
35 |
-
$this->set_fields( apply_filters( "{$class_name}_defaults",
|
36 |
}
|
37 |
|
38 |
return $this;
|
@@ -45,11 +45,11 @@ class EModal_Model_Theme_Meta extends EModal_Model {
|
|
45 |
$rows = $wpdb->get_col( "SELECT id FROM $table_name WHERE theme_id = $this->theme_id ORDER BY id DESC" );
|
46 |
if ( count( $rows ) ) {
|
47 |
$this->id = $rows[0];
|
48 |
-
$wpdb->update( $table_name, $this->serialized_values(),
|
49 |
} else {
|
50 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
51 |
$this->id = $wpdb->insert_id;
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
}
|
6 |
}
|
7 |
|
8 |
class EModal_Model_Theme_Meta extends EModal_Model {
|
9 |
+
protected $_class_name = 'EModal_Model_Theme_Meta';
|
10 |
+
protected $_table_name = 'em_theme_metas';
|
11 |
+
protected $_pk = 'theme_id';
|
12 |
+
protected $_default_fields = [
|
13 |
'id' => null,
|
14 |
'theme_id' => null,
|
15 |
+
'overlay' => [],
|
16 |
+
'container' => [],
|
17 |
+
'close' => [],
|
18 |
+
'title' => [],
|
19 |
+
'content' => [],
|
20 |
+
];
|
21 |
|
22 |
public function __construct( $id = null ) {
|
23 |
global $wpdb;
|
32 |
$this->process_load( $row );
|
33 |
}
|
34 |
} else {
|
35 |
+
$this->set_fields( apply_filters( "{$class_name}_defaults", [] ) );
|
36 |
}
|
37 |
|
38 |
return $this;
|
45 |
$rows = $wpdb->get_col( "SELECT id FROM $table_name WHERE theme_id = $this->theme_id ORDER BY id DESC" );
|
46 |
if ( count( $rows ) ) {
|
47 |
$this->id = $rows[0];
|
48 |
+
$wpdb->update( $table_name, $this->serialized_values(), [ 'id' => $this->id ] );
|
49 |
} else {
|
50 |
$wpdb->insert( $table_name, $this->serialized_values() );
|
51 |
$this->id = $wpdb->insert_id;
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
}
|
includes/input-options.php
CHANGED
@@ -12,127 +12,154 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
12 |
|
13 |
add_filter( 'popmake_size_unit_options', 'popmake_core_size_unit_options', 10 );
|
14 |
function popmake_core_size_unit_options( $options ) {
|
15 |
-
return array_merge(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
|
25 |
|
26 |
add_filter( 'popmake_font_style_options', 'popmake_core_font_style_options', 10 );
|
27 |
function popmake_core_font_style_options( $options ) {
|
28 |
-
return array_merge(
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
|
35 |
add_filter( 'popmake_text_align_options', 'popmake_core_text_align_options', 10 );
|
36 |
function popmake_core_text_align_options( $options ) {
|
37 |
-
return array_merge(
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
add_filter( 'popmake_popup_display_size_options', 'popmake_popup_display_size_options_responsive', 10 );
|
46 |
function popmake_popup_display_size_options_responsive( $options ) {
|
47 |
-
return array_merge(
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
62 |
}
|
63 |
|
64 |
|
65 |
add_filter( 'popmake_popup_display_animation_type_options', 'popmake_core_popup_display_animation_type_options', 10 );
|
66 |
function popmake_core_popup_display_animation_type_options( $options ) {
|
67 |
-
return array_merge(
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
|
79 |
add_filter( 'popmake_popup_display_animation_origin_options', 'popmake_core_popup_display_animation_origins_options', 10 );
|
80 |
function popmake_core_popup_display_animation_origins_options( $options ) {
|
81 |
-
return array_merge(
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
add_filter( 'popmake_popup_display_location_options', 'popmake_core_popup_display_location_options', 10 );
|
101 |
function popmake_core_popup_display_location_options( $options ) {
|
102 |
-
return array_merge(
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
|
117 |
add_filter( 'popmake_theme_close_location_options', 'popmake_core_theme_close_location_options', 10 );
|
118 |
function popmake_core_theme_close_location_options( $options ) {
|
119 |
-
return array_merge(
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
|
129 |
add_filter( 'popmake_cookie_trigger_options', 'popmake_cookie_trigger_options', 10 );
|
130 |
function popmake_cookie_trigger_options( $options ) {
|
131 |
-
return array_merge(
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
138 |
}
|
12 |
|
13 |
add_filter( 'popmake_size_unit_options', 'popmake_core_size_unit_options', 10 );
|
14 |
function popmake_core_size_unit_options( $options ) {
|
15 |
+
return array_merge(
|
16 |
+
$options,
|
17 |
+
[
|
18 |
+
// option => value
|
19 |
+
'px' => 'px',
|
20 |
+
'%' => '%',
|
21 |
+
'em' => 'em',
|
22 |
+
'rem' => 'rem',
|
23 |
+
]
|
24 |
+
);
|
25 |
}
|
26 |
|
27 |
|
28 |
|
29 |
add_filter( 'popmake_font_style_options', 'popmake_core_font_style_options', 10 );
|
30 |
function popmake_core_font_style_options( $options ) {
|
31 |
+
return array_merge(
|
32 |
+
$options,
|
33 |
+
[
|
34 |
+
__( 'Normal', 'popup-maker' ) => '',
|
35 |
+
__( 'Italic', 'popup-maker' ) => 'italic',
|
36 |
+
]
|
37 |
+
);
|
38 |
}
|
39 |
|
40 |
|
41 |
add_filter( 'popmake_text_align_options', 'popmake_core_text_align_options', 10 );
|
42 |
function popmake_core_text_align_options( $options ) {
|
43 |
+
return array_merge(
|
44 |
+
$options,
|
45 |
+
[
|
46 |
+
// option => value
|
47 |
+
__( 'Left', 'popup-maker' ) => 'left',
|
48 |
+
__( 'Center', 'popup-maker' ) => 'center',
|
49 |
+
__( 'Right', 'popup-maker' ) => 'right',
|
50 |
+
]
|
51 |
+
);
|
52 |
}
|
53 |
|
54 |
add_filter( 'popmake_popup_display_size_options', 'popmake_popup_display_size_options_responsive', 10 );
|
55 |
function popmake_popup_display_size_options_responsive( $options ) {
|
56 |
+
return array_merge(
|
57 |
+
$options,
|
58 |
+
[
|
59 |
+
// option => value
|
60 |
+
__( 'Responsive Sizes⤵', 'popup-maker' ) => '',
|
61 |
+
__( 'Nano - 10%', 'popup-maker' ) => 'nano',
|
62 |
+
__( 'Micro - 20%', 'popup-maker' ) => 'micro',
|
63 |
+
__( 'Tiny - 30%', 'popup-maker' ) => 'tiny',
|
64 |
+
__( 'Small - 40%', 'popup-maker' ) => 'small',
|
65 |
+
__( 'Medium - 60%', 'popup-maker' ) => 'medium',
|
66 |
+
__( 'Normal - 70%', 'popup-maker' ) => 'normal',
|
67 |
+
__( 'Large - 80%', 'popup-maker' ) => 'large',
|
68 |
+
__( 'X Large - 95%', 'popup-maker' ) => 'xlarge',
|
69 |
+
__( 'Non Responsive Sizes⤵', 'popup-maker' ) => '',
|
70 |
+
__( 'Auto', 'popup-maker' ) => 'auto',
|
71 |
+
__( 'Custom', 'popup-maker' ) => 'custom',
|
72 |
+
]
|
73 |
+
);
|
74 |
}
|
75 |
|
76 |
|
77 |
add_filter( 'popmake_popup_display_animation_type_options', 'popmake_core_popup_display_animation_type_options', 10 );
|
78 |
function popmake_core_popup_display_animation_type_options( $options ) {
|
79 |
+
return array_merge(
|
80 |
+
$options,
|
81 |
+
[
|
82 |
+
// option => value
|
83 |
+
__( 'None', 'popup-maker' ) => 'none',
|
84 |
+
__( 'Slide', 'popup-maker' ) => 'slide',
|
85 |
+
__( 'Fade', 'popup-maker' ) => 'fade',
|
86 |
+
__( 'Fade and Slide', 'popup-maker' ) => 'fadeAndSlide',
|
87 |
+
__( 'Grow', 'popup-maker' ) => 'grow',
|
88 |
+
__( 'Grow and Slide', 'popup-maker' ) => 'growAndSlide',
|
89 |
+
]
|
90 |
+
);
|
91 |
}
|
92 |
|
93 |
|
94 |
add_filter( 'popmake_popup_display_animation_origin_options', 'popmake_core_popup_display_animation_origins_options', 10 );
|
95 |
function popmake_core_popup_display_animation_origins_options( $options ) {
|
96 |
+
return array_merge(
|
97 |
+
$options,
|
98 |
+
[
|
99 |
+
// option => value
|
100 |
+
__( 'Top', 'popup-maker' ) => 'top',
|
101 |
+
__( 'Left', 'popup-maker' ) => 'left',
|
102 |
+
__( 'Bottom', 'popup-maker' ) => 'bottom',
|
103 |
+
__( 'Right', 'popup-maker' ) => 'right',
|
104 |
+
__( 'Top Left', 'popup-maker' ) => 'left top',
|
105 |
+
__( 'Top Center', 'popup-maker' ) => 'center top',
|
106 |
+
__( 'Top Right', 'popup-maker' ) => 'right top',
|
107 |
+
__( 'Middle Left', 'popup-maker' ) => 'left center',
|
108 |
+
__( 'Middle Center', 'popup-maker' ) => 'center center',
|
109 |
+
__( 'Middle Right', 'popup-maker' ) => 'right center',
|
110 |
+
__( 'Bottom Left', 'popup-maker' ) => 'left bottom',
|
111 |
+
__( 'Bottom Center', 'popup-maker' ) => 'center bottom',
|
112 |
+
__( 'Bottom Right', 'popup-maker' ) => 'right bottom',
|
113 |
+
// __( 'Mouse', 'popup-maker' ) => 'mouse',
|
114 |
+
]
|
115 |
+
);
|
116 |
}
|
117 |
|
118 |
add_filter( 'popmake_popup_display_location_options', 'popmake_core_popup_display_location_options', 10 );
|
119 |
function popmake_core_popup_display_location_options( $options ) {
|
120 |
+
return array_merge(
|
121 |
+
$options,
|
122 |
+
[
|
123 |
+
// option => value
|
124 |
+
__( 'Top Left', 'popup-maker' ) => 'left top',
|
125 |
+
__( 'Top Center', 'popup-maker' ) => 'center top',
|
126 |
+
__( 'Top Right', 'popup-maker' ) => 'right top',
|
127 |
+
__( 'Middle Left', 'popup-maker' ) => 'left center',
|
128 |
+
__( 'Middle Center', 'popup-maker' ) => 'center',
|
129 |
+
__( 'Middle Right', 'popup-maker' ) => 'right center',
|
130 |
+
__( 'Bottom Left', 'popup-maker' ) => 'left bottom',
|
131 |
+
__( 'Bottom Center', 'popup-maker' ) => 'center bottom',
|
132 |
+
__( 'Bottom Right', 'popup-maker' ) => 'right bottom',
|
133 |
+
]
|
134 |
+
);
|
135 |
}
|
136 |
|
137 |
|
138 |
add_filter( 'popmake_theme_close_location_options', 'popmake_core_theme_close_location_options', 10 );
|
139 |
function popmake_core_theme_close_location_options( $options ) {
|
140 |
+
return array_merge(
|
141 |
+
$options,
|
142 |
+
[
|
143 |
+
// option => value
|
144 |
+
__( 'Top Left', 'popup-maker' ) => 'topleft',
|
145 |
+
__( 'Top Right', 'popup-maker' ) => 'topright',
|
146 |
+
__( 'Bottom Left', 'popup-maker' ) => 'bottomleft',
|
147 |
+
__( 'Bottom Right', 'popup-maker' ) => 'bottomright',
|
148 |
+
]
|
149 |
+
);
|
150 |
}
|
151 |
|
152 |
|
153 |
add_filter( 'popmake_cookie_trigger_options', 'popmake_cookie_trigger_options', 10 );
|
154 |
function popmake_cookie_trigger_options( $options ) {
|
155 |
+
return array_merge(
|
156 |
+
$options,
|
157 |
+
[
|
158 |
+
// option => value
|
159 |
+
__( 'Disabled', 'popup-maker' ) => 'disabled',
|
160 |
+
__( 'On Open', 'popup-maker' ) => 'open',
|
161 |
+
__( 'On Close', 'popup-maker' ) => 'close',
|
162 |
+
__( 'Manual', 'popup-maker' ) => 'manual',
|
163 |
+
]
|
164 |
+
);
|
165 |
}
|
includes/integrations/class-pum-buddypress-integration.php
CHANGED
@@ -17,8 +17,8 @@ class PUM_BuddyPress_Integration {
|
|
17 |
*
|
18 |
*/
|
19 |
public static function init() {
|
20 |
-
add_filter( 'pum_registered_conditions',
|
21 |
-
add_filter( 'pum_condition_sort_order',
|
22 |
}
|
23 |
|
24 |
/**
|
@@ -26,104 +26,107 @@ class PUM_BuddyPress_Integration {
|
|
26 |
*
|
27 |
* @return array
|
28 |
*/
|
29 |
-
public static function registered_conditions( $conditions =
|
30 |
-
|
31 |
-
$conditions = array_merge(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
'
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
'
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
'
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
'
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
'
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
'
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
'
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
'
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
'
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
'
|
105 |
-
|
106 |
-
'
|
107 |
-
|
108 |
-
'
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
'
|
117 |
-
|
118 |
-
'
|
119 |
-
|
120 |
-
'
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
127 |
|
128 |
return $conditions;
|
129 |
}
|
@@ -134,7 +137,7 @@ class PUM_BuddyPress_Integration {
|
|
134 |
public static function component_option_list() {
|
135 |
global $bp;
|
136 |
|
137 |
-
$components =
|
138 |
|
139 |
foreach ( $bp->active_components as $component => $key ) {
|
140 |
$components[ $component ] = ucfirst( $component );
|
@@ -150,15 +153,15 @@ class PUM_BuddyPress_Integration {
|
|
150 |
*
|
151 |
* @return bool
|
152 |
*/
|
153 |
-
public static function bp_is_current_component( $settings =
|
154 |
global $bp;
|
155 |
|
156 |
-
if ( empty
|
157 |
return false;
|
158 |
}
|
159 |
|
160 |
if ( ! is_array( $settings['selected'] ) ) {
|
161 |
-
$settings['selected'] =
|
162 |
}
|
163 |
|
164 |
$found = false;
|
@@ -171,7 +174,6 @@ class PUM_BuddyPress_Integration {
|
|
171 |
if ( bp_is_current_component( $component ) ) {
|
172 |
$found = true;
|
173 |
}
|
174 |
-
|
175 |
}
|
176 |
|
177 |
return $found;
|
@@ -184,9 +186,9 @@ class PUM_BuddyPress_Integration {
|
|
184 |
*
|
185 |
* @return bool
|
186 |
*/
|
187 |
-
public static function bp_is_current_action( $settings =
|
188 |
|
189 |
-
if ( empty
|
190 |
return false;
|
191 |
}
|
192 |
|
@@ -213,9 +215,9 @@ class PUM_BuddyPress_Integration {
|
|
213 |
*
|
214 |
* @return bool
|
215 |
*/
|
216 |
-
public static function bp_is_action_variable( $settings =
|
217 |
|
218 |
-
if ( empty
|
219 |
return false;
|
220 |
}
|
221 |
|
@@ -239,7 +241,7 @@ class PUM_BuddyPress_Integration {
|
|
239 |
*
|
240 |
* @return array
|
241 |
*/
|
242 |
-
public static function condition_sort_order( $order =
|
243 |
$order[ __( 'BuddyPress', 'buddypress' ) ] = 5.756;
|
244 |
|
245 |
return $order;
|
17 |
*
|
18 |
*/
|
19 |
public static function init() {
|
20 |
+
add_filter( 'pum_registered_conditions', [ __CLASS__, 'registered_conditions' ] );
|
21 |
+
add_filter( 'pum_condition_sort_order', [ __CLASS__, 'condition_sort_order' ] );
|
22 |
}
|
23 |
|
24 |
/**
|
26 |
*
|
27 |
* @return array
|
28 |
*/
|
29 |
+
public static function registered_conditions( $conditions = [] ) {
|
30 |
+
|
31 |
+
$conditions = array_merge(
|
32 |
+
$conditions,
|
33 |
+
[
|
34 |
+
// Add Additional Conditions
|
35 |
+
'is_buddypress' => [
|
36 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
37 |
+
'name' => __( 'BP: Is a BuddyPress Page', 'popup-maker' ),
|
38 |
+
'callback' => 'is_buddypress',
|
39 |
+
],
|
40 |
+
|
41 |
+
'bp_is_user' => [
|
42 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
43 |
+
'name' => __( 'BP: Is User Page', 'popup-maker' ),
|
44 |
+
'callback' => 'bp_is_user',
|
45 |
+
],
|
46 |
+
|
47 |
+
'bp_is_group' => [
|
48 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
49 |
+
'name' => __( 'BP: Is Group Page', 'popup-maker' ),
|
50 |
+
'callback' => 'bp_is_group',
|
51 |
+
],
|
52 |
+
|
53 |
+
'bp_is_user_messages' => [
|
54 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
55 |
+
'name' => __( 'BP: Is User Messages Page', 'popup-maker' ),
|
56 |
+
'callback' => 'bp_is_user_messages',
|
57 |
+
],
|
58 |
+
|
59 |
+
'bp_is_activation_page' => [
|
60 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
61 |
+
'name' => __( 'BP: Is Activation Page', 'popup-maker' ),
|
62 |
+
'callback' => 'bp_is_activation_page',
|
63 |
+
],
|
64 |
+
|
65 |
+
'bp_is_register_page' => [
|
66 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
67 |
+
'name' => __( 'BP: Is Register Page', 'popup-maker' ),
|
68 |
+
'callback' => 'bp_is_register_page',
|
69 |
+
],
|
70 |
+
|
71 |
+
'bp_is_item_admin' => [
|
72 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
73 |
+
'name' => __( 'BP: Is Item Admin', 'popup-maker' ),
|
74 |
+
'callback' => 'bp_is_item_admin',
|
75 |
+
],
|
76 |
+
|
77 |
+
'bp_is_item_mod' => [
|
78 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
79 |
+
'name' => __( 'BP: Is Item Mod', 'popup-maker' ),
|
80 |
+
'callback' => 'bp_is_item_mod',
|
81 |
+
],
|
82 |
+
|
83 |
+
'bp_is_directory' => [
|
84 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
85 |
+
'name' => __( 'BP: Is Directory', 'popup-maker' ),
|
86 |
+
'callback' => 'bp_is_directory',
|
87 |
+
],
|
88 |
+
'bp_is_current_component' => [
|
89 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
90 |
+
'name' => __( 'BP: Is Current Component', 'popup-maker' ),
|
91 |
+
'fields' => [
|
92 |
+
'selected' => [
|
93 |
+
'type' => 'select',
|
94 |
+
'multiple' => true,
|
95 |
+
'as_array' => true,
|
96 |
+
'select2' => true,
|
97 |
+
'options' => self::component_option_list(),
|
98 |
+
'label' => __( 'Which components?' ),
|
99 |
+
],
|
100 |
+
],
|
101 |
+
'callback' => [ __CLASS__, 'bp_is_current_component' ],
|
102 |
+
],
|
103 |
+
|
104 |
+
'bp_is_current_action' => [
|
105 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
106 |
+
'name' => __( 'BP: Is Current Action', 'popup-maker' ),
|
107 |
+
'fields' => [
|
108 |
+
'selected' => [
|
109 |
+
'type' => 'text',
|
110 |
+
'label' => __( 'Which actions?' ),
|
111 |
+
],
|
112 |
+
],
|
113 |
+
'callback' => [ __CLASS__, 'bp_is_current_action' ],
|
114 |
+
],
|
115 |
+
|
116 |
+
'bp_is_action_variable' => [
|
117 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
118 |
+
'name' => __( 'BP: Is Action Variable', 'popup-maker' ),
|
119 |
+
'fields' => [
|
120 |
+
'selected' => [
|
121 |
+
'type' => 'text',
|
122 |
+
'label' => __( 'Which action variables?' ),
|
123 |
+
],
|
124 |
+
],
|
125 |
+
'callback' => [ __CLASS__, 'bp_is_action_variable' ],
|
126 |
+
],
|
127 |
+
|
128 |
+
]
|
129 |
+
);
|
130 |
|
131 |
return $conditions;
|
132 |
}
|
137 |
public static function component_option_list() {
|
138 |
global $bp;
|
139 |
|
140 |
+
$components = [];
|
141 |
|
142 |
foreach ( $bp->active_components as $component => $key ) {
|
143 |
$components[ $component ] = ucfirst( $component );
|
153 |
*
|
154 |
* @return bool
|
155 |
*/
|
156 |
+
public static function bp_is_current_component( $settings = [] ) {
|
157 |
global $bp;
|
158 |
|
159 |
+
if ( empty( $settings['selected'] ) ) {
|
160 |
return false;
|
161 |
}
|
162 |
|
163 |
if ( ! is_array( $settings['selected'] ) ) {
|
164 |
+
$settings['selected'] = [ $settings['selected'] ];
|
165 |
}
|
166 |
|
167 |
$found = false;
|
174 |
if ( bp_is_current_component( $component ) ) {
|
175 |
$found = true;
|
176 |
}
|
|
|
177 |
}
|
178 |
|
179 |
return $found;
|
186 |
*
|
187 |
* @return bool
|
188 |
*/
|
189 |
+
public static function bp_is_current_action( $settings = [] ) {
|
190 |
|
191 |
+
if ( empty( $settings['selected'] ) ) {
|
192 |
return false;
|
193 |
}
|
194 |
|
215 |
*
|
216 |
* @return bool
|
217 |
*/
|
218 |
+
public static function bp_is_action_variable( $settings = [] ) {
|
219 |
|
220 |
+
if ( empty( $settings['selected'] ) ) {
|
221 |
return false;
|
222 |
}
|
223 |
|
241 |
*
|
242 |
* @return array
|
243 |
*/
|
244 |
+
public static function condition_sort_order( $order = [] ) {
|
245 |
$order[ __( 'BuddyPress', 'buddypress' ) ] = 5.756;
|
246 |
|
247 |
return $order;
|
includes/integrations/class-pum-cf7.php
CHANGED
@@ -16,11 +16,11 @@ class PUM_CF7_Integration {
|
|
16 |
* Initialize if CF7 is active.
|
17 |
*/
|
18 |
public static function init() {
|
19 |
-
add_filter( 'pum_get_cookies',
|
20 |
-
add_filter( 'wpcf7_editor_panels',
|
21 |
-
add_action( 'wpcf7_after_save',
|
22 |
-
add_filter( 'wpcf7_form_elements',
|
23 |
-
add_action( 'popmake_preload_popup',
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -32,9 +32,9 @@ class PUM_CF7_Integration {
|
|
32 |
$popup = pum_get_popup( $popup_id );
|
33 |
|
34 |
if ( has_shortcode( $popup->post_content, 'contact-form-7' ) ) {
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
|
40 |
wpcf7_enqueue_scripts();
|
@@ -80,12 +80,12 @@ class PUM_CF7_Integration {
|
|
80 |
* @return array
|
81 |
*/
|
82 |
public static function defaults() {
|
83 |
-
return
|
84 |
'closepopup' => false,
|
85 |
'closedelay' => 0,
|
86 |
'openpopup' => false,
|
87 |
'openpopup_id' => 0,
|
88 |
-
|
89 |
}
|
90 |
|
91 |
/**
|
@@ -95,13 +95,13 @@ class PUM_CF7_Integration {
|
|
95 |
*
|
96 |
* @return array
|
97 |
*/
|
98 |
-
public static function register_cookies( $cookies =
|
99 |
-
$cookies['cf7_form_success'] =
|
100 |
-
'labels' =>
|
101 |
'name' => __( 'Contact Form 7 Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
102 |
-
|
103 |
'fields' => pum_get_cookie_fields(),
|
104 |
-
|
105 |
|
106 |
return $cookies;
|
107 |
}
|
@@ -113,13 +113,16 @@ class PUM_CF7_Integration {
|
|
113 |
*
|
114 |
* @return array
|
115 |
*/
|
116 |
-
public static function editor_panels( $panels =
|
117 |
-
return array_merge(
|
118 |
-
|
119 |
-
|
120 |
-
'
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
/**
|
@@ -130,83 +133,85 @@ class PUM_CF7_Integration {
|
|
130 |
public static function editor_panel( $args ) {
|
131 |
|
132 |
$settings = self::form_options( $args->id() ); ?>
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
|
|
171 |
<?php foreach ( self::get_popup_list() as $option ) { ?>
|
172 |
-
|
173 |
<?php } ?>
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
<?php
|
211 |
}
|
212 |
|
@@ -216,24 +221,26 @@ class PUM_CF7_Integration {
|
|
216 |
* @return array
|
217 |
*/
|
218 |
public static function get_popup_list() {
|
219 |
-
$popup_list =
|
220 |
-
|
221 |
'value' => 0,
|
222 |
'label' => __( 'Select a popup', 'popup-maker' ),
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
);
|
225 |
|
226 |
-
$popups = get_posts( array(
|
227 |
-
'post_type' => 'popup',
|
228 |
-
'post_status' => array( 'publish' ),
|
229 |
-
'posts_per_page' => - 1,
|
230 |
-
) );
|
231 |
-
|
232 |
foreach ( $popups as $popup ) {
|
233 |
-
$popup_list[] =
|
234 |
'value' => $popup->ID,
|
235 |
'label' => $popup->post_title,
|
236 |
-
|
237 |
|
238 |
}
|
239 |
|
16 |
* Initialize if CF7 is active.
|
17 |
*/
|
18 |
public static function init() {
|
19 |
+
add_filter( 'pum_get_cookies', [ __CLASS__, 'register_cookies' ] );
|
20 |
+
add_filter( 'wpcf7_editor_panels', [ __CLASS__, 'editor_panels' ] );
|
21 |
+
add_action( 'wpcf7_after_save', [ __CLASS__, 'save' ] );
|
22 |
+
add_filter( 'wpcf7_form_elements', [ __CLASS__, 'form_elements' ] );
|
23 |
+
add_action( 'popmake_preload_popup', [ __CLASS__, 'preload' ] );
|
24 |
}
|
25 |
|
26 |
/**
|
32 |
$popup = pum_get_popup( $popup_id );
|
33 |
|
34 |
if ( has_shortcode( $popup->post_content, 'contact-form-7' ) ) {
|
35 |
+
if ( defined( 'WPCF7_LOAD_JS' ) && ! WPCF7_LOAD_JS ) {
|
36 |
+
return;
|
37 |
+
}
|
38 |
|
39 |
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
|
40 |
wpcf7_enqueue_scripts();
|
80 |
* @return array
|
81 |
*/
|
82 |
public static function defaults() {
|
83 |
+
return [
|
84 |
'closepopup' => false,
|
85 |
'closedelay' => 0,
|
86 |
'openpopup' => false,
|
87 |
'openpopup_id' => 0,
|
88 |
+
];
|
89 |
}
|
90 |
|
91 |
/**
|
95 |
*
|
96 |
* @return array
|
97 |
*/
|
98 |
+
public static function register_cookies( $cookies = [] ) {
|
99 |
+
$cookies['cf7_form_success'] = [
|
100 |
+
'labels' => [
|
101 |
'name' => __( 'Contact Form 7 Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
102 |
+
],
|
103 |
'fields' => pum_get_cookie_fields(),
|
104 |
+
];
|
105 |
|
106 |
return $cookies;
|
107 |
}
|
113 |
*
|
114 |
* @return array
|
115 |
*/
|
116 |
+
public static function editor_panels( $panels = [] ) {
|
117 |
+
return array_merge(
|
118 |
+
$panels,
|
119 |
+
[
|
120 |
+
'popups' => [
|
121 |
+
'title' => __( 'Popup Settings', 'popup-maker' ),
|
122 |
+
'callback' => [ __CLASS__, 'editor_panel' ],
|
123 |
+
],
|
124 |
+
]
|
125 |
+
);
|
126 |
}
|
127 |
|
128 |
/**
|
133 |
public static function editor_panel( $args ) {
|
134 |
|
135 |
$settings = self::form_options( $args->id() ); ?>
|
136 |
+
<h2><?php _e( 'Popup Settings', 'popup-maker' ); ?></h2>
|
137 |
+
<p class="description"><?php _e( 'These settings control popups after successful form submissions.', 'popup-maker' ); ?></p>
|
138 |
+
<table class="form-table">
|
139 |
+
<tbody>
|
140 |
+
<tr>
|
141 |
+
<th scope="row">
|
142 |
+
<label for="wpcf7-pum-closepopup"><?php _e( 'Close Popup', 'popup-maker' ); ?></label>
|
143 |
+
</th>
|
144 |
+
<td>
|
145 |
+
<input type="checkbox" id="wpcf7-pum-closepopup" name="wpcf7-pum[closepopup]" value="true" <?php checked( $settings['closepopup'], true ); ?> />
|
146 |
+
</td>
|
147 |
+
</tr>
|
148 |
+
<tr id="wpcf7-pum-closedelay-wrapper">
|
149 |
+
<th scope="row">
|
150 |
+
<label for="wpcf7-pum-closedelay"><?php _e( 'Delay', 'popup-maker' ); ?></label>
|
151 |
+
</th>
|
152 |
+
<td>
|
153 |
+
<?php
|
154 |
+
if ( strlen( $settings['closedelay'] ) >= 3 ) {
|
155 |
+
$settings['closedelay'] = $settings['closedelay'] / 1000;
|
156 |
+
}
|
157 |
+
?>
|
158 |
+
|
159 |
+
<input type="number" id="wpcf7-pum-closedelay" min="0" step="1" name="wpcf7-pum[closedelay]" style="width: 100px;" value="<?php echo esc_attr( $settings['closedelay'] ); ?>" /><?php _e( 'seconds', 'popup-maker' ); ?>
|
160 |
+
</td>
|
161 |
+
</tr>
|
162 |
+
<tr>
|
163 |
+
<th scope="row">
|
164 |
+
<label for="wpcf7-pum-openpopup"><?php _e( 'Open Popup', 'popup-maker' ); ?></label>
|
165 |
+
</th>
|
166 |
+
<td>
|
167 |
+
<input type="checkbox" id="wpcf7-pum-openpopup" name="wpcf7-pum[openpopup]" value="true" <?php checked( $settings['openpopup'], true ); ?> />
|
168 |
+
</td>
|
169 |
+
</tr>
|
170 |
+
<tr id="wpcf7-pum-openpopup_id-wrapper">
|
171 |
+
<th scope="row">
|
172 |
+
<label for="wpcf7-pum-openpopup_id"><?php _e( 'Popup', 'popup-maker' ); ?></label>
|
173 |
+
</th>
|
174 |
+
<td>
|
175 |
+
<select id="wpcf7-pum-openpopup_id" name="wpcf7-pum[openpopup_id]">
|
176 |
<?php foreach ( self::get_popup_list() as $option ) { ?>
|
177 |
+
<option value="<?php echo esc_attr( $option['value'] ); ?>" <?php selected( $settings['openpopup_id'], $option['value'] ); ?>><?php echo $option['label']; ?></option>
|
178 |
<?php } ?>
|
179 |
+
</select>
|
180 |
+
</td>
|
181 |
+
</tr>
|
182 |
+
|
183 |
+
</tbody>
|
184 |
+
</table>
|
185 |
+
<script>
|
186 |
+
(function ($) {
|
187 |
+
var $open = $('#wpcf7-pum-openpopup'),
|
188 |
+
$close = $('#wpcf7-pum-closepopup'),
|
189 |
+
$popup_id_wrapper = $('#wpcf7-pum-openpopup_id-wrapper'),
|
190 |
+
$delay_wrapper = $('#wpcf7-pum-closedelay-wrapper');
|
191 |
+
|
192 |
+
function check_open() {
|
193 |
+
if ($open.is(':checked')) {
|
194 |
+
$popup_id_wrapper.show();
|
195 |
+
} else {
|
196 |
+
$popup_id_wrapper.hide();
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
function check_close() {
|
201 |
+
if ($close.is(':checked')) {
|
202 |
+
$delay_wrapper.show();
|
203 |
+
} else {
|
204 |
+
$delay_wrapper.hide();
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
check_open();
|
209 |
+
check_close();
|
210 |
+
|
211 |
+
$open.on('click', check_open);
|
212 |
+
$close.on('click', check_close);
|
213 |
+
}(jQuery));
|
214 |
+
</script>
|
215 |
<?php
|
216 |
}
|
217 |
|
221 |
* @return array
|
222 |
*/
|
223 |
public static function get_popup_list() {
|
224 |
+
$popup_list = [
|
225 |
+
[
|
226 |
'value' => 0,
|
227 |
'label' => __( 'Select a popup', 'popup-maker' ),
|
228 |
+
],
|
229 |
+
];
|
230 |
+
|
231 |
+
$popups = get_posts(
|
232 |
+
[
|
233 |
+
'post_type' => 'popup',
|
234 |
+
'post_status' => [ 'publish' ],
|
235 |
+
'posts_per_page' => - 1,
|
236 |
+
]
|
237 |
);
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
foreach ( $popups as $popup ) {
|
240 |
+
$popup_list[] = [
|
241 |
'value' => $popup->ID,
|
242 |
'label' => $popup->post_title,
|
243 |
+
];
|
244 |
|
245 |
}
|
246 |
|
includes/integrations/class-pum-gravity-forms.php
CHANGED
@@ -3,21 +3,21 @@
|
|
3 |
class PUM_Gravity_Forms_Integation {
|
4 |
|
5 |
public static function init() {
|
6 |
-
add_filter( 'gform_form_settings_menu',
|
7 |
-
add_action( 'gform_form_settings_page_popup-maker',
|
8 |
-
add_filter( 'pum_get_cookies',
|
9 |
-
add_filter( 'gform_get_form_filter',
|
10 |
-
add_action( 'popmake_preload_popup',
|
11 |
-
add_action( 'popmake_popup_before_inner',
|
12 |
-
add_action( 'popmake_popup_after_inner',
|
13 |
}
|
14 |
|
15 |
public static function force_ajax() {
|
16 |
if ( current_action() == 'popmake_popup_before_inner' ) {
|
17 |
-
add_filter( 'shortcode_atts_gravityforms',
|
18 |
}
|
19 |
if ( current_action() == 'popmake_popup_after_inner' ) {
|
20 |
-
remove_filter( 'shortcode_atts_gravityforms',
|
21 |
}
|
22 |
}
|
23 |
|
@@ -46,10 +46,10 @@ class PUM_Gravity_Forms_Integation {
|
|
46 |
|
47 |
|
48 |
public static function settings_menu( $setting_tabs ) {
|
49 |
-
$setting_tabs['998.002'] =
|
50 |
'name' => 'popup-maker',
|
51 |
'label' => __( 'Popup Maker', 'popup-maker' ),
|
52 |
-
|
53 |
|
54 |
return $setting_tabs;
|
55 |
}
|
@@ -69,12 +69,12 @@ class PUM_Gravity_Forms_Integation {
|
|
69 |
* @return array
|
70 |
*/
|
71 |
public static function defaults() {
|
72 |
-
return
|
73 |
'closepopup' => false,
|
74 |
'closedelay' => 0,
|
75 |
'openpopup' => false,
|
76 |
'openpopup_id' => 0,
|
77 |
-
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -97,13 +97,13 @@ class PUM_Gravity_Forms_Integation {
|
|
97 |
*
|
98 |
* @return array
|
99 |
*/
|
100 |
-
public static function register_cookies( $cookies =
|
101 |
-
$cookies['gforms_form_success'] =
|
102 |
-
'labels' =>
|
103 |
'name' => __( 'Gravity Form Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
104 |
-
|
105 |
'fields' => pum_get_cookie_fields(),
|
106 |
-
|
107 |
|
108 |
return $cookies;
|
109 |
}
|
@@ -120,94 +120,96 @@ class PUM_Gravity_Forms_Integation {
|
|
120 |
|
121 |
?>
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
|
162 |
<?php foreach ( self::get_popup_list() as $option ) { ?>
|
163 |
-
|
164 |
<?php } ?>
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
|
176 |
<?php wp_nonce_field( 'gform_popup_settings_edit', 'gform_popup_settings_edit' ); ?>
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
|
212 |
<?php
|
213 |
|
@@ -222,24 +224,26 @@ class PUM_Gravity_Forms_Integation {
|
|
222 |
* @return array
|
223 |
*/
|
224 |
public static function get_popup_list() {
|
225 |
-
$popup_list =
|
226 |
-
|
227 |
'value' => '',
|
228 |
'label' => __( 'Select a popup', 'popup-maker' ),
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
);
|
231 |
|
232 |
-
$popups = get_posts( array(
|
233 |
-
'post_type' => 'popup',
|
234 |
-
'post_status' => array( 'publish' ),
|
235 |
-
'posts_per_page' => - 1,
|
236 |
-
) );
|
237 |
-
|
238 |
foreach ( $popups as $popup ) {
|
239 |
-
$popup_list[] =
|
240 |
'value' => $popup->ID,
|
241 |
'label' => $popup->post_title,
|
242 |
-
|
243 |
|
244 |
}
|
245 |
|
@@ -292,5 +296,4 @@ class PUM_Gravity_Forms_Integation {
|
|
292 |
* function pum_gf_addon() {
|
293 |
* return PUM_GF_Popup_Addon::get_instance();
|
294 |
* }
|
295 |
-
*
|
296 |
*/
|
3 |
class PUM_Gravity_Forms_Integation {
|
4 |
|
5 |
public static function init() {
|
6 |
+
add_filter( 'gform_form_settings_menu', [ __CLASS__, 'settings_menu' ] );
|
7 |
+
add_action( 'gform_form_settings_page_popup-maker', [ __CLASS__, 'render_settings_page' ] );
|
8 |
+
add_filter( 'pum_get_cookies', [ __CLASS__, 'register_cookies' ] );
|
9 |
+
add_filter( 'gform_get_form_filter', [ __CLASS__, 'get_form' ], 10, 2 );
|
10 |
+
add_action( 'popmake_preload_popup', [ __CLASS__, 'preload' ] );
|
11 |
+
add_action( 'popmake_popup_before_inner', [ __CLASS__, 'force_ajax' ] );
|
12 |
+
add_action( 'popmake_popup_after_inner', [ __CLASS__, 'force_ajax' ] );
|
13 |
}
|
14 |
|
15 |
public static function force_ajax() {
|
16 |
if ( current_action() == 'popmake_popup_before_inner' ) {
|
17 |
+
add_filter( 'shortcode_atts_gravityforms', [ __CLASS__, 'gfrorms_shortcode_atts' ] );
|
18 |
}
|
19 |
if ( current_action() == 'popmake_popup_after_inner' ) {
|
20 |
+
remove_filter( 'shortcode_atts_gravityforms', [ __CLASS__, 'gfrorms_shortcode_atts' ] );
|
21 |
}
|
22 |
}
|
23 |
|
46 |
|
47 |
|
48 |
public static function settings_menu( $setting_tabs ) {
|
49 |
+
$setting_tabs['998.002'] = [
|
50 |
'name' => 'popup-maker',
|
51 |
'label' => __( 'Popup Maker', 'popup-maker' ),
|
52 |
+
];
|
53 |
|
54 |
return $setting_tabs;
|
55 |
}
|
69 |
* @return array
|
70 |
*/
|
71 |
public static function defaults() {
|
72 |
+
return [
|
73 |
'closepopup' => false,
|
74 |
'closedelay' => 0,
|
75 |
'openpopup' => false,
|
76 |
'openpopup_id' => 0,
|
77 |
+
];
|
78 |
}
|
79 |
|
80 |
/**
|
97 |
*
|
98 |
* @return array
|
99 |
*/
|
100 |
+
public static function register_cookies( $cookies = [] ) {
|
101 |
+
$cookies['gforms_form_success'] = [
|
102 |
+
'labels' => [
|
103 |
'name' => __( 'Gravity Form Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
104 |
+
],
|
105 |
'fields' => pum_get_cookie_fields(),
|
106 |
+
];
|
107 |
|
108 |
return $cookies;
|
109 |
}
|
120 |
|
121 |
?>
|
122 |
|
123 |
+
<div id="popup_settings-editor">
|
124 |
+
|
125 |
+
<form id="popup_settings_edit_form" method="post">
|
126 |
+
|
127 |
+
<table class="form-table gforms_form_settings">
|
128 |
+
<tr>
|
129 |
+
<th scope="row">
|
130 |
+
<label for="gforms-pum-closepopup"><?php _e( 'Close Popup', 'popup-maker' ); ?></label>
|
131 |
+
</th>
|
132 |
+
<td>
|
133 |
+
<input type="checkbox" id="gforms-pum-closepopup" name="gforms-pum[closepopup]" value="true" <?php checked( $settings['closepopup'], true ); ?> />
|
134 |
+
</td>
|
135 |
+
</tr>
|
136 |
+
<tr id="gforms-pum-closedelay-wrapper">
|
137 |
+
<th scope="row">
|
138 |
+
<label for="gforms-pum-closedelay"><?php _e( 'Delay', 'popup-maker' ); ?></label>
|
139 |
+
</th>
|
140 |
+
<td>
|
141 |
+
<?php
|
142 |
+
if ( strlen( $settings['closedelay'] ) >= 3 ) {
|
143 |
+
$settings['closedelay'] = $settings['closedelay'] / 1000;
|
144 |
+
}
|
145 |
+
?>
|
146 |
+
|
147 |
+
<input type="number" id="gforms-pum-closedelay" min="0" step="1" name="gforms-pum[closedelay]" style="width: 100px;" value="<?php echo esc_attr( $settings['closedelay'] ); ?>" /><?php _e( 'seconds', 'popup-maker' ); ?>
|
148 |
+
</td>
|
149 |
+
</tr>
|
150 |
+
<tr>
|
151 |
+
<th scope="row">
|
152 |
+
<label for="gforms-pum-openpopup"><?php _e( 'Open Popup', 'popup-maker' ); ?></label>
|
153 |
+
</th>
|
154 |
+
<td>
|
155 |
+
<input type="checkbox" id="gforms-pum-openpopup" name="gforms-pum[openpopup]" value="true" <?php checked( $settings['openpopup'], true ); ?> />
|
156 |
+
</td>
|
157 |
+
</tr>
|
158 |
+
<tr id="gforms-pum-openpopup_id-wrapper">
|
159 |
+
<th scope="row">
|
160 |
+
<label for="gforms-pum-openpopup_id"><?php _e( 'Popup', 'popup-maker' ); ?></label>
|
161 |
+
</th>
|
162 |
+
<td>
|
163 |
+
<select id="gforms-pum-openpopup_id" name="gforms-pum[openpopup_id]">
|
164 |
<?php foreach ( self::get_popup_list() as $option ) { ?>
|
165 |
+
<option value="<?php echo esc_attr( $option['value'] ); ?>" <?php selected( $settings['openpopup_id'], $option['value'] ); ?>><?php echo $option['label']; ?></option>
|
166 |
<?php } ?>
|
167 |
+
</select>
|
168 |
+
</td>
|
169 |
+
</tr>
|
170 |
+
</table>
|
171 |
|
172 |
+
<input type="hidden" id="form_id" name="form_id" value="<?php echo esc_attr( $form_id ); ?>" />
|
173 |
|
174 |
+
<p class="submit">
|
175 |
+
<input type="submit" name="save" value="<?php _e( 'Save', 'popup-maker' ); ?>" class="button-primary">
|
176 |
+
</p>
|
177 |
|
178 |
<?php wp_nonce_field( 'gform_popup_settings_edit', 'gform_popup_settings_edit' ); ?>
|
179 |
|
180 |
+
</form>
|
181 |
+
<script type="text/javascript">
|
182 |
+
(function ($) {
|
183 |
+
var $open = $('#gforms-pum-openpopup'),
|
184 |
+
$close = $('#gforms-pum-closepopup'),
|
185 |
+
$popup_id_wrapper = $('#gforms-pum-openpopup_id-wrapper'),
|
186 |
+
$delay_wrapper = $('#gforms-pum-closedelay-wrapper');
|
187 |
+
|
188 |
+
function check_open() {
|
189 |
+
if ($open.is(':checked')) {
|
190 |
+
$popup_id_wrapper.show();
|
191 |
+
} else {
|
192 |
+
$popup_id_wrapper.hide();
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
function check_close() {
|
197 |
+
if ($close.is(':checked')) {
|
198 |
+
$delay_wrapper.show();
|
199 |
+
} else {
|
200 |
+
$delay_wrapper.hide();
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
check_open();
|
205 |
+
check_close();
|
206 |
+
|
207 |
+
$open.on('click', check_open);
|
208 |
+
$close.on('click', check_close);
|
209 |
+
}(jQuery));
|
210 |
+
</script>
|
211 |
+
|
212 |
+
</div> <!-- / popup-editor -->
|
213 |
|
214 |
<?php
|
215 |
|
224 |
* @return array
|
225 |
*/
|
226 |
public static function get_popup_list() {
|
227 |
+
$popup_list = [
|
228 |
+
[
|
229 |
'value' => '',
|
230 |
'label' => __( 'Select a popup', 'popup-maker' ),
|
231 |
+
],
|
232 |
+
];
|
233 |
+
|
234 |
+
$popups = get_posts(
|
235 |
+
[
|
236 |
+
'post_type' => 'popup',
|
237 |
+
'post_status' => [ 'publish' ],
|
238 |
+
'posts_per_page' => - 1,
|
239 |
+
]
|
240 |
);
|
241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
foreach ( $popups as $popup ) {
|
243 |
+
$popup_list[] = [
|
244 |
'value' => $popup->ID,
|
245 |
'label' => $popup->post_title,
|
246 |
+
];
|
247 |
|
248 |
}
|
249 |
|
296 |
* function pum_gf_addon() {
|
297 |
* return PUM_GF_Popup_Addon::get_instance();
|
298 |
* }
|
|
|
299 |
*/
|
includes/integrations/class-pum-ninja-forms.php
CHANGED
@@ -46,7 +46,7 @@ final class NF_PUM {
|
|
46 |
*/
|
47 |
public static function instance() {
|
48 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof NF_PUM ) ) {
|
49 |
-
spl_autoload_register(
|
50 |
|
51 |
self::$instance = new NF_PUM();
|
52 |
|
@@ -60,7 +60,7 @@ final class NF_PUM {
|
|
60 |
|
61 |
public function __construct() {
|
62 |
$this->register_actions();
|
63 |
-
add_filter( 'pum_registered_cookies',
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -70,7 +70,7 @@ final class NF_PUM {
|
|
70 |
*/
|
71 |
public function register_actions() {
|
72 |
Ninja_Forms()->actions['closepopup'] = new NF_PUM_Actions_ClosePopup();
|
73 |
-
Ninja_Forms()->actions['openpopup']
|
74 |
}
|
75 |
|
76 |
|
@@ -78,12 +78,12 @@ final class NF_PUM {
|
|
78 |
* Optional. If your extension creates a new field interaction or display template...
|
79 |
*/
|
80 |
public function register_cookies( $cookies ) {
|
81 |
-
$cookies['ninja_form_success'] =
|
82 |
-
'labels' =>
|
83 |
'name' => __( 'Ninja Form Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
84 |
-
|
85 |
'fields' => pum_get_cookie_fields(),
|
86 |
-
|
87 |
|
88 |
return $cookies;
|
89 |
}
|
@@ -116,9 +116,9 @@ final class NF_PUM {
|
|
116 |
* Template
|
117 |
*
|
118 |
* @param string $file_name
|
119 |
-
* @param array
|
120 |
*/
|
121 |
-
public static function template( $file_name = '', array $data =
|
122 |
if ( ! $file_name ) {
|
123 |
return;
|
124 |
}
|
46 |
*/
|
47 |
public static function instance() {
|
48 |
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof NF_PUM ) ) {
|
49 |
+
spl_autoload_register( [ __CLASS__, 'autoloader' ] );
|
50 |
|
51 |
self::$instance = new NF_PUM();
|
52 |
|
60 |
|
61 |
public function __construct() {
|
62 |
$this->register_actions();
|
63 |
+
add_filter( 'pum_registered_cookies', [ $this, 'register_cookies' ] );
|
64 |
}
|
65 |
|
66 |
/**
|
70 |
*/
|
71 |
public function register_actions() {
|
72 |
Ninja_Forms()->actions['closepopup'] = new NF_PUM_Actions_ClosePopup();
|
73 |
+
Ninja_Forms()->actions['openpopup'] = new NF_PUM_Actions_OpenPopup();
|
74 |
}
|
75 |
|
76 |
|
78 |
* Optional. If your extension creates a new field interaction or display template...
|
79 |
*/
|
80 |
public function register_cookies( $cookies ) {
|
81 |
+
$cookies['ninja_form_success'] = [
|
82 |
+
'labels' => [
|
83 |
'name' => __( 'Ninja Form Success (deprecated. Use Form Submission instead.)', 'popup-maker' ),
|
84 |
+
],
|
85 |
'fields' => pum_get_cookie_fields(),
|
86 |
+
];
|
87 |
|
88 |
return $cookies;
|
89 |
}
|
116 |
* Template
|
117 |
*
|
118 |
* @param string $file_name
|
119 |
+
* @param array $data
|
120 |
*/
|
121 |
+
public static function template( $file_name = '', array $data = [] ) {
|
122 |
if ( ! $file_name ) {
|
123 |
return;
|
124 |
}
|
includes/integrations/class-pum-woocommerce-integration.php
CHANGED
@@ -8,12 +8,12 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
8 |
class PUM_Woocommerce_Integration {
|
9 |
|
10 |
public static function init() {
|
11 |
-
add_filter( 'pum_registered_conditions',
|
12 |
-
add_filter( 'pum_condition_sort_order',
|
13 |
}
|
14 |
|
15 |
-
public static function is_wc_endpoint_url( $settings =
|
16 |
-
$results =
|
17 |
|
18 |
foreach ( $settings['selected'] as $key ) {
|
19 |
$results[] = is_wc_endpoint_url( $key );
|
@@ -22,46 +22,46 @@ class PUM_Woocommerce_Integration {
|
|
22 |
return in_array( true, $results );
|
23 |
}
|
24 |
|
25 |
-
public static function register_conditions( $conditions =
|
26 |
|
27 |
// Add Additional Conditions
|
28 |
-
$conditions['is_woocommerce'] =
|
29 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
30 |
'name' => __( 'All WooCommerce', 'popup-maker' ),
|
31 |
'callback' => 'is_woocommerce',
|
32 |
-
|
33 |
-
$conditions['is_shop'] =
|
34 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
35 |
'name' => __( 'Shop Page', 'popup-maker' ),
|
36 |
'callback' => 'is_shop',
|
37 |
-
|
38 |
-
$conditions['is_cart'] =
|
39 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
40 |
'name' => __( 'Cart Page', 'popup-maker' ),
|
41 |
'callback' => 'is_cart',
|
42 |
-
|
43 |
-
$conditions['is_checkout'] =
|
44 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
45 |
'name' => __( 'Checkout Page', 'popup-maker' ),
|
46 |
'callback' => 'is_checkout',
|
47 |
-
|
48 |
-
$conditions['is_account_page'] =
|
49 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
50 |
'name' => __( 'Account Page', 'popup-maker' ),
|
51 |
'callback' => 'is_account_page',
|
52 |
-
|
53 |
|
54 |
-
$conditions['is_wc_endpoint_url'] =
|
55 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
56 |
'name' => __( 'Is Endpoint', 'popup-maker' ),
|
57 |
-
'fields' =>
|
58 |
-
'selected' =>
|
59 |
'placeholder' => __( 'Selected Endpoints', 'popup-maker' ),
|
60 |
'type' => 'select',
|
61 |
'select2' => true,
|
62 |
'multiple' => true,
|
63 |
'as_array' => true,
|
64 |
-
'options' =>
|
65 |
'order-pay' => 'order-pay',
|
66 |
'order-received' => 'order-received',
|
67 |
// My account actions.
|
@@ -76,17 +76,17 @@ class PUM_Woocommerce_Integration {
|
|
76 |
'add-payment-method' => 'add-payment-method',
|
77 |
'delete-payment-method' => 'delete-payment-method',
|
78 |
'set-default-payment-method' => 'set-default-payment-method',
|
79 |
-
'subscriptions'
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
'callback' =>
|
84 |
-
|
85 |
|
86 |
return $conditions;
|
87 |
}
|
88 |
|
89 |
-
public static function condition_sort_order( $order =
|
90 |
$order[ __( 'WooCommerce', 'woocommerce' ) ] = 5.256;
|
91 |
|
92 |
return $order;
|
8 |
class PUM_Woocommerce_Integration {
|
9 |
|
10 |
public static function init() {
|
11 |
+
add_filter( 'pum_registered_conditions', [ __CLASS__, 'register_conditions' ] );
|
12 |
+
add_filter( 'pum_condition_sort_order', [ __CLASS__, 'condition_sort_order' ] );
|
13 |
}
|
14 |
|
15 |
+
public static function is_wc_endpoint_url( $settings = [] ) {
|
16 |
+
$results = [];
|
17 |
|
18 |
foreach ( $settings['selected'] as $key ) {
|
19 |
$results[] = is_wc_endpoint_url( $key );
|
22 |
return in_array( true, $results );
|
23 |
}
|
24 |
|
25 |
+
public static function register_conditions( $conditions = [] ) {
|
26 |
|
27 |
// Add Additional Conditions
|
28 |
+
$conditions['is_woocommerce'] = [
|
29 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
30 |
'name' => __( 'All WooCommerce', 'popup-maker' ),
|
31 |
'callback' => 'is_woocommerce',
|
32 |
+
];
|
33 |
+
$conditions['is_shop'] = [
|
34 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
35 |
'name' => __( 'Shop Page', 'popup-maker' ),
|
36 |
'callback' => 'is_shop',
|
37 |
+
];
|
38 |
+
$conditions['is_cart'] = [
|
39 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
40 |
'name' => __( 'Cart Page', 'popup-maker' ),
|
41 |
'callback' => 'is_cart',
|
42 |
+
];
|
43 |
+
$conditions['is_checkout'] = [
|
44 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
45 |
'name' => __( 'Checkout Page', 'popup-maker' ),
|
46 |
'callback' => 'is_checkout',
|
47 |
+
];
|
48 |
+
$conditions['is_account_page'] = [
|
49 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
50 |
'name' => __( 'Account Page', 'popup-maker' ),
|
51 |
'callback' => 'is_account_page',
|
52 |
+
];
|
53 |
|
54 |
+
$conditions['is_wc_endpoint_url'] = [
|
55 |
'group' => __( 'WooCommerce', 'woocommerce' ),
|
56 |
'name' => __( 'Is Endpoint', 'popup-maker' ),
|
57 |
+
'fields' => [
|
58 |
+
'selected' => [
|
59 |
'placeholder' => __( 'Selected Endpoints', 'popup-maker' ),
|
60 |
'type' => 'select',
|
61 |
'select2' => true,
|
62 |
'multiple' => true,
|
63 |
'as_array' => true,
|
64 |
+
'options' => [
|
65 |
'order-pay' => 'order-pay',
|
66 |
'order-received' => 'order-received',
|
67 |
// My account actions.
|
76 |
'add-payment-method' => 'add-payment-method',
|
77 |
'delete-payment-method' => 'delete-payment-method',
|
78 |
'set-default-payment-method' => 'set-default-payment-method',
|
79 |
+
'subscriptions' => 'subscriptions',
|
80 |
+
],
|
81 |
+
],
|
82 |
+
],
|
83 |
+
'callback' => [ __CLASS__, 'is_wc_endpoint_url' ],
|
84 |
+
];
|
85 |
|
86 |
return $conditions;
|
87 |
}
|
88 |
|
89 |
+
public static function condition_sort_order( $order = [] ) {
|
90 |
$order[ __( 'WooCommerce', 'woocommerce' ) ] = 5.256;
|
91 |
|
92 |
return $order;
|
includes/integrations/class-pum-wpml.php
CHANGED
@@ -15,32 +15,32 @@ class PUM_WPML_Integration {
|
|
15 |
*
|
16 |
*/
|
17 |
public static function init() {
|
18 |
-
add_action( 'icl_make_duplicate',
|
19 |
/*
|
20 |
add_filter( 'pum_popup', array( __CLASS__, 'pum_popup' ), 10, 2 );
|
21 |
TODO Further testing of this filter may prove 80+% of the following unneeded.
|
22 |
*/
|
23 |
-
add_filter( 'pum_popup_get_display',
|
24 |
-
add_filter( 'pum_popup_get_close',
|
25 |
-
add_filter( 'pum_popup_get_triggers',
|
26 |
-
add_filter( 'pum_popup_get_cookies',
|
27 |
-
add_filter( 'pum_popup_get_conditions',
|
28 |
-
add_filter( 'pum_popup_get_theme_id',
|
29 |
-
add_filter( 'pum_popup_mobile_disabled',
|
30 |
-
add_filter( 'pum_popup_tablet_disabled',
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* @param $popup
|
35 |
-
* @param null
|
36 |
*
|
37 |
* @return \PUM_Model_Popup
|
38 |
*/
|
39 |
public static function pum_popup( $popup, $popup_id = null ) {
|
40 |
if ( self::is_new_popup_translation( $popup_id ) ) {
|
41 |
-
remove_filter( 'pum_popup',
|
42 |
$popup = pum_get_popup( self::source_id( $popup_id ) );
|
43 |
-
add_filter( 'pum_popup',
|
44 |
}
|
45 |
|
46 |
return $popup;
|
@@ -92,7 +92,7 @@ class PUM_WPML_Integration {
|
|
92 |
|
93 |
static $trid;
|
94 |
|
95 |
-
if ( ! isset( $trid )
|
96 |
$trid = absint( $sitepress->get_element_trid( $post_id, 'post_popup' ) );
|
97 |
}
|
98 |
|
@@ -107,9 +107,9 @@ class PUM_WPML_Integration {
|
|
107 |
*/
|
108 |
public static function popup_mobile_disabled( $disabled, $post_id ) {
|
109 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
110 |
-
remove_filter( 'pum_popup_mobile_disabled',
|
111 |
$disabled = pum_get_popup( self::source_id( $post_id ) )->mobile_disabled();
|
112 |
-
add_filter( 'pum_popup_mobile_disabled',
|
113 |
}
|
114 |
|
115 |
return $disabled;
|
@@ -123,9 +123,9 @@ class PUM_WPML_Integration {
|
|
123 |
*/
|
124 |
public static function popup_tablet_disabled( $disabled, $post_id ) {
|
125 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
126 |
-
remove_filter( 'pum_popup_tablet_disabled',
|
127 |
$disabled = pum_get_popup( self::source_id( $post_id ) )->tablet_disabled();
|
128 |
-
add_filter( 'pum_popup_tablet_disabled',
|
129 |
}
|
130 |
|
131 |
return $disabled;
|
@@ -139,9 +139,9 @@ class PUM_WPML_Integration {
|
|
139 |
*/
|
140 |
public static function popup_get_triggers( $triggers, $post_id ) {
|
141 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
142 |
-
remove_filter( 'pum_popup_get_triggers',
|
143 |
$triggers = pum_get_popup( self::source_id( $post_id ) )->get_triggers();
|
144 |
-
add_filter( 'pum_popup_get_triggers',
|
145 |
}
|
146 |
|
147 |
return $triggers;
|
@@ -155,9 +155,9 @@ class PUM_WPML_Integration {
|
|
155 |
*/
|
156 |
public static function popup_get_display( $display, $post_id ) {
|
157 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
158 |
-
remove_filter( 'pum_popup_get_display',
|
159 |
$display = pum_get_popup( self::source_id( $post_id ) )->get_display();
|
160 |
-
add_filter( 'pum_popup_get_display',
|
161 |
}
|
162 |
|
163 |
return $display;
|
@@ -171,9 +171,9 @@ class PUM_WPML_Integration {
|
|
171 |
*/
|
172 |
public static function popup_get_close( $close, $post_id ) {
|
173 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
174 |
-
remove_filter( 'pum_popup_get_close',
|
175 |
$close = pum_get_popup( self::source_id( $post_id ) )->get_close();
|
176 |
-
add_filter( 'pum_popup_get_close',
|
177 |
}
|
178 |
|
179 |
return $close;
|
@@ -187,9 +187,9 @@ class PUM_WPML_Integration {
|
|
187 |
*/
|
188 |
public static function popup_get_cookies( $cookies, $post_id ) {
|
189 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
190 |
-
remove_filter( 'pum_popup_get_cookies',
|
191 |
$cookies = pum_get_popup( self::source_id( $post_id ) )->get_cookies();
|
192 |
-
add_filter( 'pum_popup_get_cookies',
|
193 |
}
|
194 |
|
195 |
return $cookies;
|
@@ -203,9 +203,9 @@ class PUM_WPML_Integration {
|
|
203 |
*/
|
204 |
public static function popup_get_theme_id( $theme_id, $post_id ) {
|
205 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
206 |
-
remove_filter( 'pum_popup_get_theme_id',
|
207 |
$theme_id = pum_get_popup( self::source_id( $post_id ) )->get_theme_id();
|
208 |
-
add_filter( 'pum_popup_get_theme_id',
|
209 |
}
|
210 |
|
211 |
return $theme_id;
|
@@ -213,7 +213,7 @@ class PUM_WPML_Integration {
|
|
213 |
|
214 |
/**
|
215 |
* @param $conditions
|
216 |
-
* @param null
|
217 |
*
|
218 |
* @return mixed
|
219 |
*/
|
@@ -232,13 +232,13 @@ class PUM_WPML_Integration {
|
|
232 |
|
233 |
$target = $condition['target'];
|
234 |
|
235 |
-
$tests =
|
236 |
strpos( $target, '_selected' ) !== false,
|
237 |
strpos( $target, '_ID' ) !== false,
|
238 |
strpos( $target, '_children' ) !== false,
|
239 |
strpos( $target, '_ancestors' ) !== false,
|
240 |
strpos( $target, '_w_' ) !== false,
|
241 |
-
|
242 |
|
243 |
if ( ! in_array( true, $tests ) ) {
|
244 |
continue;
|
@@ -270,7 +270,7 @@ class PUM_WPML_Integration {
|
|
270 |
}
|
271 |
|
272 |
// To hold the newly remapped selection.
|
273 |
-
$selected =
|
274 |
|
275 |
foreach ( wp_parse_id_list( $condition['selected'] ) as $object_id ) {
|
276 |
// Insert the translated post_id or the original if no translation exists.
|
@@ -293,14 +293,14 @@ class PUM_WPML_Integration {
|
|
293 |
*/
|
294 |
public static function popup_get_conditions( $conditions, $post_id ) {
|
295 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
296 |
-
remove_filter( 'pum_popup_get_conditions',
|
297 |
|
298 |
-
$popup
|
299 |
$conditions = $popup->get_conditions();
|
300 |
|
301 |
$conditions = self::remap_conditions( $conditions, $post_id );
|
302 |
|
303 |
-
add_filter( 'pum_popup_get_conditions',
|
304 |
}
|
305 |
|
306 |
return $conditions;
|
@@ -310,15 +310,18 @@ class PUM_WPML_Integration {
|
|
310 |
* @return mixed|void
|
311 |
*/
|
312 |
public static function untranslatable_meta_keys() {
|
313 |
-
return apply_filters(
|
314 |
-
'
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
|
|
|
|
|
|
322 |
}
|
323 |
|
324 |
|
@@ -326,10 +329,13 @@ class PUM_WPML_Integration {
|
|
326 |
* @return mixed|void
|
327 |
*/
|
328 |
public static function translatable_meta_keys() {
|
329 |
-
return apply_filters(
|
330 |
-
'
|
331 |
-
|
332 |
-
|
|
|
|
|
|
|
333 |
}
|
334 |
|
335 |
|
@@ -340,7 +346,7 @@ class PUM_WPML_Integration {
|
|
340 |
*
|
341 |
* @param $master_post_id int Original post_ID.
|
342 |
* @param $lang string The new language.
|
343 |
-
* @param
|
344 |
* @param $id int The post_ID for the new/duplicate post.
|
345 |
*/
|
346 |
public static function duplicate_post( $master_post_id, $lang, $post_array, $id ) {
|
15 |
*
|
16 |
*/
|
17 |
public static function init() {
|
18 |
+
add_action( 'icl_make_duplicate', [ __CLASS__, 'duplicate_post' ], 10, 4 );
|
19 |
/*
|
20 |
add_filter( 'pum_popup', array( __CLASS__, 'pum_popup' ), 10, 2 );
|
21 |
TODO Further testing of this filter may prove 80+% of the following unneeded.
|
22 |
*/
|
23 |
+
add_filter( 'pum_popup_get_display', [ __CLASS__, 'popup_get_display' ], 10, 2 );
|
24 |
+
add_filter( 'pum_popup_get_close', [ __CLASS__, 'popup_get_close' ], 10, 2 );
|
25 |
+
add_filter( 'pum_popup_get_triggers', [ __CLASS__, 'popup_get_triggers' ], 10, 2 );
|
26 |
+
add_filter( 'pum_popup_get_cookies', [ __CLASS__, 'popup_get_cookies' ], 10, 2 );
|
27 |
+
add_filter( 'pum_popup_get_conditions', [ __CLASS__, 'popup_get_conditions' ], 10, 2 );
|
28 |
+
add_filter( 'pum_popup_get_theme_id', [ __CLASS__, 'popup_get_theme_id' ], 10, 2 );
|
29 |
+
add_filter( 'pum_popup_mobile_disabled', [ __CLASS__, 'popup_mobile_disabled' ], 10, 2 );
|
30 |
+
add_filter( 'pum_popup_tablet_disabled', [ __CLASS__, 'popup_tablet_disabled' ], 10, 2 );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
* @param $popup
|
35 |
+
* @param null $popup_id
|
36 |
*
|
37 |
* @return \PUM_Model_Popup
|
38 |
*/
|
39 |
public static function pum_popup( $popup, $popup_id = null ) {
|
40 |
if ( self::is_new_popup_translation( $popup_id ) ) {
|
41 |
+
remove_filter( 'pum_popup', [ __CLASS__, 'pum_popup' ], 10 );
|
42 |
$popup = pum_get_popup( self::source_id( $popup_id ) );
|
43 |
+
add_filter( 'pum_popup', [ __CLASS__, 'pum_popup' ], 10, 2 );
|
44 |
}
|
45 |
|
46 |
return $popup;
|
92 |
|
93 |
static $trid;
|
94 |
|
95 |
+
if ( ! isset( $trid ) && ! empty( $sitepress ) && method_exists( $sitepress, 'get_element_trid' ) ) {
|
96 |
$trid = absint( $sitepress->get_element_trid( $post_id, 'post_popup' ) );
|
97 |
}
|
98 |
|
107 |
*/
|
108 |
public static function popup_mobile_disabled( $disabled, $post_id ) {
|
109 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
110 |
+
remove_filter( 'pum_popup_mobile_disabled', [ __CLASS__, 'popup_mobile_disabled' ], 10 );
|
111 |
$disabled = pum_get_popup( self::source_id( $post_id ) )->mobile_disabled();
|
112 |
+
add_filter( 'pum_popup_mobile_disabled', [ __CLASS__, 'popup_mobile_disabled' ], 10, 2 );
|
113 |
}
|
114 |
|
115 |
return $disabled;
|
123 |
*/
|
124 |
public static function popup_tablet_disabled( $disabled, $post_id ) {
|
125 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
126 |
+
remove_filter( 'pum_popup_tablet_disabled', [ __CLASS__, 'popup_tablet_disabled' ], 10 );
|
127 |
$disabled = pum_get_popup( self::source_id( $post_id ) )->tablet_disabled();
|
128 |
+
add_filter( 'pum_popup_tablet_disabled', [ __CLASS__, 'popup_tablet_disabled' ], 10, 2 );
|
129 |
}
|
130 |
|
131 |
return $disabled;
|
139 |
*/
|
140 |
public static function popup_get_triggers( $triggers, $post_id ) {
|
141 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
142 |
+
remove_filter( 'pum_popup_get_triggers', [ __CLASS__, 'popup_get_triggers' ], 10 );
|
143 |
$triggers = pum_get_popup( self::source_id( $post_id ) )->get_triggers();
|
144 |
+
add_filter( 'pum_popup_get_triggers', [ __CLASS__, 'popup_get_triggers' ], 10, 2 );
|
145 |
}
|
146 |
|
147 |
return $triggers;
|
155 |
*/
|
156 |
public static function popup_get_display( $display, $post_id ) {
|
157 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
158 |
+
remove_filter( 'pum_popup_get_display', [ __CLASS__, 'popup_get_display' ], 10 );
|
159 |
$display = pum_get_popup( self::source_id( $post_id ) )->get_display();
|
160 |
+
add_filter( 'pum_popup_get_display', [ __CLASS__, 'popup_get_display' ], 10, 2 );
|
161 |
}
|
162 |
|
163 |
return $display;
|
171 |
*/
|
172 |
public static function popup_get_close( $close, $post_id ) {
|
173 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
174 |
+
remove_filter( 'pum_popup_get_close', [ __CLASS__, 'popup_get_close' ], 10 );
|
175 |
$close = pum_get_popup( self::source_id( $post_id ) )->get_close();
|
176 |
+
add_filter( 'pum_popup_get_close', [ __CLASS__, 'popup_get_close' ], 10, 2 );
|
177 |
}
|
178 |
|
179 |
return $close;
|
187 |
*/
|
188 |
public static function popup_get_cookies( $cookies, $post_id ) {
|
189 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
190 |
+
remove_filter( 'pum_popup_get_cookies', [ __CLASS__, 'popup_get_cookies' ], 10 );
|
191 |
$cookies = pum_get_popup( self::source_id( $post_id ) )->get_cookies();
|
192 |
+
add_filter( 'pum_popup_get_cookies', [ __CLASS__, 'popup_get_cookies' ], 10, 2 );
|
193 |
}
|
194 |
|
195 |
return $cookies;
|
203 |
*/
|
204 |
public static function popup_get_theme_id( $theme_id, $post_id ) {
|
205 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
206 |
+
remove_filter( 'pum_popup_get_theme_id', [ __CLASS__, 'popup_get_theme_id' ], 10 );
|
207 |
$theme_id = pum_get_popup( self::source_id( $post_id ) )->get_theme_id();
|
208 |
+
add_filter( 'pum_popup_get_theme_id', [ __CLASS__, 'popup_get_theme_id' ], 10, 2 );
|
209 |
}
|
210 |
|
211 |
return $theme_id;
|
213 |
|
214 |
/**
|
215 |
* @param $conditions
|
216 |
+
* @param null $new_lang
|
217 |
*
|
218 |
* @return mixed
|
219 |
*/
|
232 |
|
233 |
$target = $condition['target'];
|
234 |
|
235 |
+
$tests = [
|
236 |
strpos( $target, '_selected' ) !== false,
|
237 |
strpos( $target, '_ID' ) !== false,
|
238 |
strpos( $target, '_children' ) !== false,
|
239 |
strpos( $target, '_ancestors' ) !== false,
|
240 |
strpos( $target, '_w_' ) !== false,
|
241 |
+
];
|
242 |
|
243 |
if ( ! in_array( true, $tests ) ) {
|
244 |
continue;
|
270 |
}
|
271 |
|
272 |
// To hold the newly remapped selection.
|
273 |
+
$selected = [];
|
274 |
|
275 |
foreach ( wp_parse_id_list( $condition['selected'] ) as $object_id ) {
|
276 |
// Insert the translated post_id or the original if no translation exists.
|
293 |
*/
|
294 |
public static function popup_get_conditions( $conditions, $post_id ) {
|
295 |
if ( self::is_new_popup_translation( $post_id ) ) {
|
296 |
+
remove_filter( 'pum_popup_get_conditions', [ __CLASS__, 'popup_get_conditions' ], 10 );
|
297 |
|
298 |
+
$popup = pum_get_popup( self::source_id( $post_id ) );
|
299 |
$conditions = $popup->get_conditions();
|
300 |
|
301 |
$conditions = self::remap_conditions( $conditions, $post_id );
|
302 |
|
303 |
+
add_filter( 'pum_popup_get_conditions', [ __CLASS__, 'popup_get_conditions' ], 10, 2 );
|
304 |
}
|
305 |
|
306 |
return $conditions;
|
310 |
* @return mixed|void
|
311 |
*/
|
312 |
public static function untranslatable_meta_keys() {
|
313 |
+
return apply_filters(
|
314 |
+
'pum_wpml_untranslatable_meta_keys',
|
315 |
+
[
|
316 |
+
'popup_display',
|
317 |
+
'popup_theme',
|
318 |
+
'popup_triggers',
|
319 |
+
'popup_cookies',
|
320 |
+
'popup_conditions',
|
321 |
+
'popup_mobile_disabled',
|
322 |
+
'popup_tablet_disabled',
|
323 |
+
]
|
324 |
+
);
|
325 |
}
|
326 |
|
327 |
|
329 |
* @return mixed|void
|
330 |
*/
|
331 |
public static function translatable_meta_keys() {
|
332 |
+
return apply_filters(
|
333 |
+
'pum_wpml_translatable_meta_keys',
|
334 |
+
[
|
335 |
+
'popup_close',
|
336 |
+
'popup_title',
|
337 |
+
]
|
338 |
+
);
|
339 |
}
|
340 |
|
341 |
|
346 |
*
|
347 |
* @param $master_post_id int Original post_ID.
|
348 |
* @param $lang string The new language.
|
349 |
+
* @param post_array array The $post array for the new/duplicate post.
|
350 |
* @param $id int The post_ID for the new/duplicate post.
|
351 |
*/
|
352 |
public static function duplicate_post( $master_post_id, $lang, $post_array, $id ) {
|
includes/integrations/ninja-forms/Actions/ClosePopup.php
CHANGED
@@ -15,7 +15,7 @@ final class NF_PUM_Actions_ClosePopup extends NF_Abstracts_Action {
|
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
-
protected $_tags =
|
19 |
|
20 |
/**
|
21 |
* @var string
|
@@ -35,8 +35,8 @@ final class NF_PUM_Actions_ClosePopup extends NF_Abstracts_Action {
|
|
35 |
|
36 |
$this->_nicename = __( 'Close Popup', 'popup-maker' );
|
37 |
|
38 |
-
$settings =
|
39 |
-
'close_delay' =>
|
40 |
'name' => 'close_delay',
|
41 |
'type' => 'number',
|
42 |
'group' => 'primary',
|
@@ -44,8 +44,8 @@ final class NF_PUM_Actions_ClosePopup extends NF_Abstracts_Action {
|
|
44 |
'placeholder' => '',
|
45 |
'width' => 'full',
|
46 |
'value' => __( '0', 'popup-maker' ),
|
47 |
-
|
48 |
-
|
49 |
|
50 |
$this->_settings = array_merge( $this->_settings, $settings );
|
51 |
}
|
15 |
/**
|
16 |
* @var array
|
17 |
*/
|
18 |
+
protected $_tags = [];
|
19 |
|
20 |
/**
|
21 |
* @var string
|
35 |
|
36 |
$this->_nicename = __( 'Close Popup', 'popup-maker' );
|
37 |
|
38 |
+
$settings = [
|
39 |
+
'close_delay' => [
|
40 |
'name' => 'close_delay',
|
41 |
'type' => 'number',
|
42 |
'group' => 'primary',
|
44 |
'placeholder' => '',
|
45 |
'width' => 'full',
|
46 |
'value' => __( '0', 'popup-maker' ),
|
47 |
+
],
|
48 |
+
];
|
49 |
|
50 |
$this->_settings = array_merge( $this->_settings, $settings );
|
51 |
}
|
includes/integrations/ninja-forms/Actions/OpenPopup.php
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
-
<?php if ( ! defined( 'ABSPATH' ) )
|
|
|
2 |
|
3 |
/**
|
4 |
* Class NF_Action_SuccessMessage
|
5 |
*/
|
6 |
-
final class NF_PUM_Actions_OpenPopup extends NF_Abstracts_Action
|
7 |
-
|
8 |
/**
|
9 |
* @var string
|
10 |
*/
|
11 |
-
protected $_name
|
12 |
|
13 |
/**
|
14 |
* @var array
|
15 |
*/
|
16 |
-
protected $_tags =
|
17 |
|
18 |
/**
|
19 |
* @var string
|
@@ -28,23 +29,22 @@ final class NF_PUM_Actions_OpenPopup extends NF_Abstracts_Action
|
|
28 |
/**
|
29 |
* Constructor
|
30 |
*/
|
31 |
-
public function __construct()
|
32 |
-
|
33 |
-
parent::__construct();
|
34 |
|
35 |
$this->_nicename = __( 'Open Popup', 'popup-maker' );
|
36 |
|
37 |
-
$settings =
|
38 |
-
'popup' =>
|
39 |
-
'name'
|
40 |
-
'type'
|
41 |
-
'group'
|
42 |
-
'label'
|
43 |
'placeholder' => '',
|
44 |
-
'width'
|
45 |
-
'options'
|
46 |
-
|
47 |
-
|
48 |
|
49 |
$this->_settings = array_merge( $this->_settings, $settings );
|
50 |
}
|
@@ -53,13 +53,10 @@ final class NF_PUM_Actions_OpenPopup extends NF_Abstracts_Action
|
|
53 |
* PUBLIC METHODS
|
54 |
*/
|
55 |
|
56 |
-
public function save( $action_settings )
|
57 |
-
{
|
58 |
-
|
59 |
}
|
60 |
|
61 |
-
public function process( $action_settings, $form_id, $data )
|
62 |
-
{
|
63 |
if ( ! isset( $data['actions'] ) || ! isset( $data['actions']['openpopup'] ) ) {
|
64 |
$data['actions']['openpopup'] = false;
|
65 |
}
|
@@ -72,20 +69,20 @@ final class NF_PUM_Actions_OpenPopup extends NF_Abstracts_Action
|
|
72 |
}
|
73 |
|
74 |
public function get_popup_list() {
|
75 |
-
$popup_list =
|
76 |
-
|
77 |
'value' => '',
|
78 |
-
'label' => __( 'Select a popup', 'popup-maker' )
|
79 |
-
|
80 |
-
|
81 |
|
82 |
$popups = pum_get_all_popups();
|
83 |
|
84 |
foreach ( $popups as $popup ) {
|
85 |
-
$popup_list[] =
|
86 |
'value' => $popup->ID,
|
87 |
-
'label' => $popup->post_title
|
88 |
-
|
89 |
}
|
90 |
|
91 |
return $popup_list;
|
1 |
+
<?php if ( ! defined( 'ABSPATH' ) ) {
|
2 |
+
exit;}
|
3 |
|
4 |
/**
|
5 |
* Class NF_Action_SuccessMessage
|
6 |
*/
|
7 |
+
final class NF_PUM_Actions_OpenPopup extends NF_Abstracts_Action {
|
8 |
+
|
9 |
/**
|
10 |
* @var string
|
11 |
*/
|
12 |
+
protected $_name = 'openpopup';
|
13 |
|
14 |
/**
|
15 |
* @var array
|
16 |
*/
|
17 |
+
protected $_tags = [];
|
18 |
|
19 |
/**
|
20 |
* @var string
|
29 |
/**
|
30 |
* Constructor
|
31 |
*/
|
32 |
+
public function __construct() {
|
33 |
+
parent::__construct();
|
|
|
34 |
|
35 |
$this->_nicename = __( 'Open Popup', 'popup-maker' );
|
36 |
|
37 |
+
$settings = [
|
38 |
+
'popup' => [
|
39 |
+
'name' => 'popup',
|
40 |
+
'type' => 'select',
|
41 |
+
'group' => 'primary',
|
42 |
+
'label' => __( 'Popup ID', 'popup-maker' ),
|
43 |
'placeholder' => '',
|
44 |
+
'width' => 'full',
|
45 |
+
'options' => isset( $_GET['page'] ) && 'ninja-forms' === $_GET['page'] && ! empty( $_GET['form_id'] ) ? $this->get_popup_list() : [],
|
46 |
+
],
|
47 |
+
];
|
48 |
|
49 |
$this->_settings = array_merge( $this->_settings, $settings );
|
50 |
}
|
53 |
* PUBLIC METHODS
|
54 |
*/
|
55 |
|
56 |
+
public function save( $action_settings ) {
|
|
|
|
|
57 |
}
|
58 |
|
59 |
+
public function process( $action_settings, $form_id, $data ) {
|
|
|
60 |
if ( ! isset( $data['actions'] ) || ! isset( $data['actions']['openpopup'] ) ) {
|
61 |
$data['actions']['openpopup'] = false;
|
62 |
}
|
69 |
}
|
70 |
|
71 |
public function get_popup_list() {
|
72 |
+
$popup_list = [
|
73 |
+
[
|
74 |
'value' => '',
|
75 |
+
'label' => __( 'Select a popup', 'popup-maker' ),
|
76 |
+
],
|
77 |
+
];
|
78 |
|
79 |
$popups = pum_get_all_popups();
|
80 |
|
81 |
foreach ( $popups as $popup ) {
|
82 |
+
$popup_list[] = [
|
83 |
'value' => $popup->ID,
|
84 |
+
'label' => $popup->post_title,
|
85 |
+
];
|
86 |
}
|
87 |
|
88 |
return $popup_list;
|
includes/modules/admin-bar.php
CHANGED
@@ -18,9 +18,9 @@ class PUM_Modules_Admin_Bar {
|
|
18 |
* Initializes this module.
|
19 |
*/
|
20 |
public static function init() {
|
21 |
-
add_action( 'admin_bar_menu',
|
22 |
-
add_action( 'wp_enqueue_scripts',
|
23 |
-
add_action( 'init',
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -43,13 +43,13 @@ class PUM_Modules_Admin_Bar {
|
|
43 |
* @return bool
|
44 |
*/
|
45 |
public static function should_render() {
|
46 |
-
$tests =
|
47 |
is_user_logged_in(),
|
48 |
! is_admin(),
|
49 |
is_admin_bar_showing(),
|
50 |
! pum_get_option( 'disabled_admin_bar' ),
|
51 |
( current_user_can( 'edit_others_posts' ) || current_user_can( 'manage_options' ) ),
|
52 |
-
|
53 |
|
54 |
return ! in_array( false, $tests );
|
55 |
}
|
@@ -65,22 +65,26 @@ class PUM_Modules_Admin_Bar {
|
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
-
$wp_admin_bar->add_node(
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
|
76 |
-
$wp_admin_bar->add_node(
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
82 |
|
83 |
-
$popups =
|
84 |
|
85 |
if ( count( $popups ) ) {
|
86 |
|
@@ -94,123 +98,144 @@ class PUM_Modules_Admin_Bar {
|
|
94 |
$edit_url = $can_edit ? admin_url( 'post.php?post=' . $popup->ID . '&action=edit' ) : '#';
|
95 |
|
96 |
// Single Popup Menu Node
|
97 |
-
$wp_admin_bar->add_node(
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
103 |
|
104 |
// Trigger Link
|
105 |
-
$wp_admin_bar->add_node(
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
'
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
if ( pum_get_popup( $popup->ID )->has_conditions( array( 'js_only' => true ) ) ) {
|
126 |
-
$wp_admin_bar->add_node( array(
|
127 |
-
'id' => $node_id . '-conditions',
|
128 |
-
'title' => __( 'Check Conditions', 'popup-maker' ),
|
129 |
-
'meta' => array(
|
130 |
-
'onclick' => 'alert(PUM.checkConditions(' . $popup->ID . ') ? "Pass" : "Fail"); return false;',
|
131 |
-
),
|
132 |
-
'href' => '#popup-maker-check-conditions-popup-' . $popup->ID,
|
133 |
'parent' => $node_id,
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
|
137 |
-
$wp_admin_bar->add_node(
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
'
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
146 |
|
147 |
if ( $can_edit ) {
|
148 |
// Edit Popup Link
|
149 |
-
$wp_admin_bar->add_node(
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
155 |
}
|
156 |
-
|
157 |
}
|
158 |
} else {
|
159 |
-
$wp_admin_bar->add_node(
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
'
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
}
|
170 |
|
171 |
if ( current_user_can( 'edit_posts' ) ) {
|
172 |
-
$wp_admin_bar->add_node(
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
|
186 |
/**
|
187 |
* Tools
|
188 |
*/
|
189 |
-
$wp_admin_bar->add_node(
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
195 |
|
196 |
$wp_admin_bar->add_node(
|
197 |
-
|
198 |
'id' => 'flush-popup-cache',
|
199 |
'title' => __( 'Flush Popup Cache', 'popup-maker' ),
|
200 |
'href' => add_query_arg( 'flush_popup_cache', 'yes' ),
|
201 |
'parent' => 'pum-tools',
|
202 |
-
|
203 |
);
|
204 |
|
205 |
/**
|
206 |
* Get Selector
|
207 |
*/
|
208 |
-
$wp_admin_bar->add_node(
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
|
|
|
|
214 |
}
|
215 |
|
216 |
/**
|
@@ -237,13 +262,13 @@ class PUM_Modules_Admin_Bar {
|
|
237 |
return;
|
238 |
}
|
239 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
240 |
-
wp_enqueue_script( 'pum-admin-bar', Popup_Maker::$URL . 'assets/js/admin-bar' . $suffix . '.js',
|
241 |
-
wp_enqueue_style( 'pum-admin-bar-style', Popup_Maker::$URL . 'assets/css/pum-admin-bar' . $suffix . '.css',
|
242 |
|
243 |
-
$admin_bar_text =
|
244 |
'instructions' => __( 'After clicking ok, click the element you want a selector for.', 'popup-maker' ),
|
245 |
-
'results'
|
246 |
-
|
247 |
wp_localize_script( 'pum-admin-bar', 'pumAdminBarText', $admin_bar_text );
|
248 |
}
|
249 |
}
|
18 |
* Initializes this module.
|
19 |
*/
|
20 |
public static function init() {
|
21 |
+
add_action( 'admin_bar_menu', [ __CLASS__, 'toolbar_links' ], 999 );
|
22 |
+
add_action( 'wp_enqueue_scripts', [ __CLASS__, 'enqueue_files' ] );
|
23 |
+
add_action( 'init', [ __CLASS__, 'show_debug_bar' ] );
|
24 |
}
|
25 |
|
26 |
/**
|
43 |
* @return bool
|
44 |
*/
|
45 |
public static function should_render() {
|
46 |
+
$tests = [
|
47 |
is_user_logged_in(),
|
48 |
! is_admin(),
|
49 |
is_admin_bar_showing(),
|
50 |
! pum_get_option( 'disabled_admin_bar' ),
|
51 |
( current_user_can( 'edit_others_posts' ) || current_user_can( 'manage_options' ) ),
|
52 |
+
];
|
53 |
|
54 |
return ! in_array( false, $tests );
|
55 |
}
|
65 |
return;
|
66 |
}
|
67 |
|
68 |
+
$wp_admin_bar->add_node(
|
69 |
+
[
|
70 |
+
'id' => 'popup-maker',
|
71 |
+
'title' => __( 'Popup Maker', 'popup-maker' ),
|
72 |
+
'href' => '#popup-maker',
|
73 |
+
'meta' => [ 'class' => 'popup-maker-toolbar' ],
|
74 |
+
'parent' => false,
|
75 |
+
]
|
76 |
+
);
|
77 |
|
78 |
+
$wp_admin_bar->add_node(
|
79 |
+
[
|
80 |
+
'id' => 'popups',
|
81 |
+
'title' => __( 'Popups', 'popup-maker' ),
|
82 |
+
'href' => '#',
|
83 |
+
'parent' => 'popup-maker',
|
84 |
+
]
|
85 |
+
);
|
86 |
|
87 |
+
$popups = self::loaded_popups();
|
88 |
|
89 |
if ( count( $popups ) ) {
|
90 |
|
98 |
$edit_url = $can_edit ? admin_url( 'post.php?post=' . $popup->ID . '&action=edit' ) : '#';
|
99 |
|
100 |
// Single Popup Menu Node
|
101 |
+
$wp_admin_bar->add_node(
|
102 |
+
[
|
103 |
+
'id' => $node_id,
|
104 |
+
'title' => esc_html( $popup->post_title ),
|
105 |
+
'href' => $edit_url,
|
106 |
+
'parent' => 'popups',
|
107 |
+
]
|
108 |
+
);
|
109 |
|
110 |
// Trigger Link
|
111 |
+
$wp_admin_bar->add_node(
|
112 |
+
[
|
113 |
+
'id' => $node_id . '-open',
|
114 |
+
'title' => __( 'Open Popup', 'popup-maker' ),
|
115 |
+
'meta' => [
|
116 |
+
'onclick' => 'PUM.open(' . $popup->ID . '); return false;',
|
117 |
+
],
|
118 |
+
'href' => '#popup-maker-open-popup-' . $popup->ID,
|
119 |
+
'parent' => $node_id,
|
120 |
+
]
|
121 |
+
);
|
122 |
+
|
123 |
+
$wp_admin_bar->add_node(
|
124 |
+
[
|
125 |
+
'id' => $node_id . '-close',
|
126 |
+
'title' => __( 'Close Popup', 'popup-maker' ),
|
127 |
+
'meta' => [
|
128 |
+
'onclick' => 'PUM.close(' . $popup->ID . '); return false;',
|
129 |
+
],
|
130 |
+
'href' => '#popup-maker-close-popup-' . $popup->ID,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
'parent' => $node_id,
|
132 |
+
]
|
133 |
+
);
|
134 |
+
|
135 |
+
if ( pum_get_popup( $popup->ID )->has_conditions( [ 'js_only' => true ] ) ) {
|
136 |
+
$wp_admin_bar->add_node(
|
137 |
+
[
|
138 |
+
'id' => $node_id . '-conditions',
|
139 |
+
'title' => __( 'Check Conditions', 'popup-maker' ),
|
140 |
+
'meta' => [
|
141 |
+
'onclick' => 'alert(PUM.checkConditions(' . $popup->ID . ') ? "Pass" : "Fail"); return false;',
|
142 |
+
],
|
143 |
+
'href' => '#popup-maker-check-conditions-popup-' . $popup->ID,
|
144 |
+
'parent' => $node_id,
|
145 |
+
]
|
146 |
+
);
|
147 |
}
|
148 |
|
149 |
+
$wp_admin_bar->add_node(
|
150 |
+
[
|
151 |
+
'id' => $node_id . '-reset-cookies',
|
152 |
+
'title' => __( 'Reset Cookies', 'popup-maker' ),
|
153 |
+
'meta' => [
|
154 |
+
'onclick' => 'PUM.clearCookies(' . $popup->ID . '); alert("' . __( 'Success', 'popup-maker' ) . '"); return false;',
|
155 |
+
],
|
156 |
+
'href' => '#popup-maker-reset-cookies-popup-' . $popup->ID,
|
157 |
+
'parent' => $node_id,
|
158 |
+
]
|
159 |
+
);
|
160 |
|
161 |
if ( $can_edit ) {
|
162 |
// Edit Popup Link
|
163 |
+
$wp_admin_bar->add_node(
|
164 |
+
[
|
165 |
+
'id' => $node_id . '-edit',
|
166 |
+
'title' => __( 'Edit Popup', 'popup-maker' ),
|
167 |
+
'href' => $edit_url,
|
168 |
+
'parent' => $node_id,
|
169 |
+
]
|
170 |
+
);
|
171 |
}
|
|
|
172 |
}
|
173 |
} else {
|
174 |
+
$wp_admin_bar->add_node(
|
175 |
+
[
|
176 |
+
'id' => 'no-popups-loaded',
|
177 |
+
'title' => __( 'No Popups Loaded', 'popup-maker' ) . '<strong style="color:#fff; margin-left: 5px;">?</strong>',
|
178 |
+
'href' => 'https://docs.wppopupmaker.com/article/265-my-popup-wont-work-how-can-i-fix-it?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=plugin-admin-bar&utm_content=no-popups-loaded',
|
179 |
+
'parent' => 'popups',
|
180 |
+
'meta' => [
|
181 |
+
'target' => '_blank',
|
182 |
+
],
|
183 |
+
|
184 |
+
]
|
185 |
+
);
|
186 |
}
|
187 |
|
188 |
if ( current_user_can( 'edit_posts' ) ) {
|
189 |
+
$wp_admin_bar->add_node(
|
190 |
+
[
|
191 |
+
'id' => 'all-popups',
|
192 |
+
'title' => __( 'All Popups', 'popup-maker' ),
|
193 |
+
'href' => admin_url( 'edit.php?post_type=popup' ),
|
194 |
+
'parent' => 'popup-maker',
|
195 |
+
]
|
196 |
+
);
|
197 |
+
$wp_admin_bar->add_node(
|
198 |
+
[
|
199 |
+
'id' => 'new-popups', // Just `new-popup` moves this to the top of the menu for some reason. Leave the `s` to keep it in the right place.
|
200 |
+
'title' => __( 'Create New Popup', 'popup-maker' ),
|
201 |
+
'href' => admin_url( 'post-new.php?post_type=popup' ),
|
202 |
+
'parent' => 'popup-maker',
|
203 |
+
]
|
204 |
+
);
|
205 |
}
|
206 |
|
207 |
/**
|
208 |
* Tools
|
209 |
*/
|
210 |
+
$wp_admin_bar->add_node(
|
211 |
+
[
|
212 |
+
'id' => 'pum-tools',
|
213 |
+
'title' => __( 'Tools', 'popup-maker' ),
|
214 |
+
'href' => '#popup-maker-tools',
|
215 |
+
'parent' => 'popup-maker',
|
216 |
+
]
|
217 |
+
);
|
218 |
|
219 |
$wp_admin_bar->add_node(
|
220 |
+
[
|
221 |
'id' => 'flush-popup-cache',
|
222 |
'title' => __( 'Flush Popup Cache', 'popup-maker' ),
|
223 |
'href' => add_query_arg( 'flush_popup_cache', 'yes' ),
|
224 |
'parent' => 'pum-tools',
|
225 |
+
]
|
226 |
);
|
227 |
|
228 |
/**
|
229 |
* Get Selector
|
230 |
*/
|
231 |
+
$wp_admin_bar->add_node(
|
232 |
+
[
|
233 |
+
'id' => 'pum-get-selector',
|
234 |
+
'title' => __( 'Get Selector', 'popup-maker' ),
|
235 |
+
'href' => '#popup-maker-get-selector-tool',
|
236 |
+
'parent' => 'pum-tools',
|
237 |
+
]
|
238 |
+
);
|
239 |
}
|
240 |
|
241 |
/**
|
262 |
return;
|
263 |
}
|
264 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
265 |
+
wp_enqueue_script( 'pum-admin-bar', Popup_Maker::$URL . 'assets/js/admin-bar' . $suffix . '.js', [ 'jquery' ], Popup_Maker::$VER, true );
|
266 |
+
wp_enqueue_style( 'pum-admin-bar-style', Popup_Maker::$URL . 'assets/css/pum-admin-bar' . $suffix . '.css', [], Popup_Maker::$VER );
|
267 |
|
268 |
+
$admin_bar_text = [
|
269 |
'instructions' => __( 'After clicking ok, click the element you want a selector for.', 'popup-maker' ),
|
270 |
+
'results' => _x( 'Selector', 'JS alert for CSS get selector tool', 'popup-maker' ),
|
271 |
+
];
|
272 |
wp_localize_script( 'pum-admin-bar', 'pumAdminBarText', $admin_bar_text );
|
273 |
}
|
274 |
}
|
includes/modules/menus.php
CHANGED
@@ -19,39 +19,42 @@ class PUM_Modules_Menu {
|
|
19 |
* Initializes this module.
|
20 |
*/
|
21 |
public static function init() {
|
22 |
-
add_filter( 'popmake_settings_misc',
|
23 |
|
24 |
if ( PUM_Utils_Options::get( 'disabled_menu_editor', false ) ) {
|
25 |
return;
|
26 |
}
|
27 |
|
28 |
// Merge Menu Item Options
|
29 |
-
add_filter( 'wp_setup_nav_menu_item',
|
30 |
// Admin Menu Editor
|
31 |
-
add_filter( 'wp_edit_nav_menu_walker',
|
32 |
// Admin Menu Editor Fields.
|
33 |
-
add_action( 'wp_nav_menu_item_custom_fields',
|
34 |
-
add_action( 'wp_update_nav_menu_item',
|
35 |
-
add_filter( 'manage_nav-menus_columns',
|
36 |
}
|
37 |
|
38 |
public static function settings( $settings ) {
|
39 |
-
return array_merge(
|
40 |
-
|
41 |
-
|
42 |
-
'
|
43 |
-
|
44 |
-
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
public static function nav_menu_columns( $columns =
|
55 |
$columns['popup_id'] = __( 'Popup', 'popup-maker' );
|
56 |
|
57 |
return $columns;
|
@@ -106,7 +109,7 @@ class PUM_Modules_Menu {
|
|
106 |
}
|
107 |
|
108 |
// Merge Rules.
|
109 |
-
foreach (
|
110 |
$item->$key = $value;
|
111 |
}
|
112 |
|
@@ -144,7 +147,7 @@ class PUM_Modules_Menu {
|
|
144 |
// Fetch all rules for this menu item.
|
145 |
$item_options = get_post_meta( $item_id, '_pum_nav_item_options', true );
|
146 |
|
147 |
-
return PUM
|
19 |
* Initializes this module.
|
20 |
*/
|
21 |
public static function init() {
|
22 |
+
add_filter( 'popmake_settings_misc', [ __CLASS__, 'settings' ] );
|
23 |
|
24 |
if ( PUM_Utils_Options::get( 'disabled_menu_editor', false ) ) {
|
25 |
return;
|
26 |
}
|
27 |
|
28 |
// Merge Menu Item Options
|
29 |
+
add_filter( 'wp_setup_nav_menu_item', [ __CLASS__, 'merge_item_data' ] );
|
30 |
// Admin Menu Editor
|
31 |
+
add_filter( 'wp_edit_nav_menu_walker', [ __CLASS__, 'nav_menu_walker' ], 999999999 );
|
32 |
// Admin Menu Editor Fields.
|
33 |
+
add_action( 'wp_nav_menu_item_custom_fields', [ __CLASS__, 'fields' ], 10, 4 );
|
34 |
+
add_action( 'wp_update_nav_menu_item', [ __CLASS__, 'save' ], 10, 2 );
|
35 |
+
add_filter( 'manage_nav-menus_columns', [ __CLASS__, 'nav_menu_columns' ], 11 );
|
36 |
}
|
37 |
|
38 |
public static function settings( $settings ) {
|
39 |
+
return array_merge(
|
40 |
+
$settings,
|
41 |
+
[
|
42 |
+
'disabled_menu_editor' => [
|
43 |
+
'id' => 'disabled_menu_editor',
|
44 |
+
'name' => __( 'Disable Popups Menu Editor', 'popup-maker' ),
|
45 |
+
'desc' => sprintf(
|
46 |
+
esc_html_x( 'Use this if there is a conflict with your theme or another plugin in the nav menu editor. %1$sLearn more%2$s', '%s represent opening and closing link html', 'popup-maker' ),
|
47 |
+
'<a href="https://docs.wppopupmaker.com/article/297-popup-maker-is-overwriting-my-menu-editor-functions-how-can-i-fix-this?utm_campaign=contextual-help&utm_medium=inline-doclink&utm_source=settings-page&utm_content=disable-popup-menu-editor" target="_blank" rel="noreferrer noopener">',
|
48 |
+
'</a>'
|
49 |
+
),
|
50 |
+
'type' => 'checkbox',
|
51 |
+
],
|
52 |
+
|
53 |
+
]
|
54 |
+
);
|
55 |
}
|
56 |
|
57 |
+
public static function nav_menu_columns( $columns = [] ) {
|
58 |
$columns['popup_id'] = __( 'Popup', 'popup-maker' );
|
59 |
|
60 |
return $columns;
|
109 |
}
|
110 |
|
111 |
// Merge Rules.
|
112 |
+
foreach ( self::get_item_options( $item->ID ) as $key => $value ) {
|
113 |
$item->$key = $value;
|
114 |
}
|
115 |
|
147 |
// Fetch all rules for this menu item.
|
148 |
$item_options = get_post_meta( $item_id, '_pum_nav_item_options', true );
|
149 |
|
|