From ff8d81cd47991a368a7e10c03a7473822839a67f Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Tue, 6 Aug 2024 13:53:51 +0700 Subject: [PATCH 01/23] Temp commit --- .../FrmDeactivationFeedbackController.php | 43 +++++++++++++++++++ classes/controllers/FrmHooksController.php | 4 ++ js/admin/deactivation-feedback.js | 34 +++++++++++++++ js/formidable.js | 1 + 4 files changed, 82 insertions(+) create mode 100644 classes/controllers/FrmDeactivationFeedbackController.php create mode 100644 js/admin/deactivation-feedback.js diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php new file mode 100644 index 0000000000..d3db0cc677 --- /dev/null +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -0,0 +1,43 @@ +id; + } + + public static function enqueue_assets() { + if ( ! self::is_plugins_page() ) { + return; + } + wp_enqueue_script( 'frm-deactivation-feedback', FrmAppHelper::plugin_url() . '/js/admin/deactivation-feedback.js', array( 'formidable', 'formidable_dom', 'jquery' ), FrmAppHelper::plugin_version(), true ); + wp_enqueue_style( 'formidable-admin' ); + + FrmAppHelper::localize_script( 'front' ); + } + + public static function footer_html() { + if ( ! self::is_plugins_page() ) { + return; + } + ?> +
+ +
+
+
+
+ + +
+
+
+ { + console.log( json ); + const form = json.renderedHtml.replace( /]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' ); + jQuery( '#frmapi-feedback' ).html( form ); + } + }); + } + + const onClickDeactivate = event => { + event.preventDefault(); + frmapiGetData( jQuery( event.target ) ); + }; + + frmDom.util.documentOn( 'click', selectors, onClickDeactivate ); + + document.addEventListener( 'frmFormCompleteBeforeReplace', function( a, b ) { + console.log( a ); + console.log( b ); + }); + + // jQuery.on( document, 'frmFormComplete', function( a, b ) { + // console.log( a ); + // console.log( b ); + // }); +}() ); diff --git a/js/formidable.js b/js/formidable.js index de7bc1eb5a..e663bd111f 100644 --- a/js/formidable.js +++ b/js/formidable.js @@ -856,6 +856,7 @@ function frmFrontFormJS() { function afterFormSubmittedBeforeReplace( object, response ) { const formCompleted = jQuery( response.content ).find( '.frm_message' ); if ( formCompleted.length ) { + console.log( 'asfsdfds' ); triggerCustomEvent( document, 'frmFormCompleteBeforeReplace', { object, response }); } } From b075d5267c9aabce862cfcc799d24b7f71b8d37f Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Fri, 9 Aug 2024 23:05:23 +0700 Subject: [PATCH 02/23] Temp commit --- classes/controllers/FrmFormsController.php | 4 ++-- js/admin/deactivation-feedback.js | 12 ++++++------ js/formidable.js | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index 981c9121b8..d1de4be0fd 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -1182,7 +1182,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c $reset_fields = false; FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields ); - +error_log( $reset_fields ); if ( $reset_fields ) { $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); } @@ -1191,7 +1191,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c $args = array( 'parent_form_id' => $form->id ); $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); - +//error_log( print_r( $fields, true ) ); /** * Allows modifying the list of fields in the form builder. * diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index d28d055ecd..b92e571a57 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -22,13 +22,13 @@ frmDom.util.documentOn( 'click', selectors, onClickDeactivate ); - document.addEventListener( 'frmFormCompleteBeforeReplace', function( a, b ) { + /*document.addEventListener( 'frmFormCompleteBeforeReplace', function( a, b ) { console.log( a ); console.log( b ); - }); + });*/ - // jQuery.on( document, 'frmFormComplete', function( a, b ) { - // console.log( a ); - // console.log( b ); - // }); + jQuery.on( document, 'frmFormComplete', function( a, b ) { + console.log( a ); + console.log( b ); + }); }() ); diff --git a/js/formidable.js b/js/formidable.js index e663bd111f..de7bc1eb5a 100644 --- a/js/formidable.js +++ b/js/formidable.js @@ -856,7 +856,6 @@ function frmFrontFormJS() { function afterFormSubmittedBeforeReplace( object, response ) { const formCompleted = jQuery( response.content ).find( '.frm_message' ); if ( formCompleted.length ) { - console.log( 'asfsdfds' ); triggerCustomEvent( document, 'frmFormCompleteBeforeReplace', { object, response }); } } From 1da5aca72421086e9a9aefd1afa8ee66f7492ba4 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Mon, 12 Aug 2024 22:02:06 +0700 Subject: [PATCH 03/23] Handled submission deactivation feedback --- .../FrmDeactivationFeedbackController.php | 78 +++++++++++- js/admin/deactivation-feedback.js | 113 +++++++++++++++--- 2 files changed, 167 insertions(+), 24 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index d3db0cc677..45ba160944 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -20,6 +20,14 @@ public static function enqueue_assets() { wp_enqueue_style( 'formidable-admin' ); FrmAppHelper::localize_script( 'front' ); + + wp_localize_script( + 'frm-deactivation-feedback', + 'FrmDeactivationFeedbackI18n', + array( + 'skip_text' => __( 'Skip & Deactivate', 'formidable' ), + ) + ); } public static function footer_html() { @@ -27,17 +35,75 @@ public static function footer_html() { return; } ?> -
- -
-
+
- - +
+ +
+ +
+
+ + + + + { - console.log( json ); - const form = json.renderedHtml.replace( /]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' ); - jQuery( '#frmapi-feedback' ).html( form ); + let deactivationModal, deactivationUrl; + + const Modal = { + init: function( id, width ) { + const $info = jQuery( id ); + const self = this; + + if ( ! $info.length ) { + return false; + } + + if ( typeof width === 'undefined' ) { + width = '550px'; } + + const dialogArgs = { + dialogClass: 'frm-dialog', + modal: true, + autoOpen: false, + closeOnEscape: true, + width: width, + resizable: false, + draggable: false, + open: function() { + jQuery( '.ui-dialog-titlebar' ).addClass( 'frm_hidden' ).removeClass( 'ui-helper-clearfix' ); + jQuery( '#wpwrap' ).addClass( 'frm_overlay' ); + jQuery( '.frm-dialog' ).removeClass( 'ui-widget ui-widget-content ui-corner-all' ); + $info.removeClass( 'ui-dialog-content ui-widget-content' ); + self.bindClickForDialogClose( $info ); + }, + close: function() { + jQuery( '#wpwrap' ).removeClass( 'frm_overlay' ); + jQuery( '.spinner' ).css( 'visibility', 'hidden' ); + + this.removeAttribute( 'data-option-type' ); + const optionType = document.getElementById( 'bulk-option-type' ); + if ( optionType ) { + optionType.value = ''; + } + } + }; + + $info.dialog( dialogArgs ); + + return $info; + }, + + bindClickForDialogClose: function( $modal ) { + const closeModal = function() { + $modal.dialog( 'close' ); + }; + jQuery( '.ui-widget-overlay' ).on( 'click', closeModal ); + $modal.on( 'click', 'a.dismiss', closeModal ); + } + }; + + const addSkipBtn = formEl => { + const btn = frmDom.a( { + text: FrmDeactivationFeedbackI18n.skip_text, + href: deactivationUrl }); - } + + formEl.querySelector( '.frm_submit' ).prepend( btn ); + }; const onClickDeactivate = event => { event.preventDefault(); - frmapiGetData( jQuery( event.target ) ); + + if ( ! deactivationModal ) { + deactivationModal = Modal.init( + '#frm-deactivation-modal', + '440px' + ); + } + + deactivationUrl = event.target.href; + + const pluginName = event.target.closest( '.plugin-title' ).querySelector( 'strong' ).innerText; + + const url = 'http://frmdev.test/wp-json/frm/v2/forms/deactivation-feedback?plugin_name=' + pluginName + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; + + const response = fetch( url, { + method: 'GET' + }); + + response + .then( response => response.json() ) + .then( response => { + const wrapper = document.getElementById( 'frm-deactivation-form-wrapper' ); + const form = response.renderedHtml.replace( /]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' ); + + wrapper.innerHTML = form; + addSkipBtn( wrapper ); + deactivationModal.dialog( 'open' ); + }) + .catch( error => { + console.error( error ); + }); }; frmDom.util.documentOn( 'click', selectors, onClickDeactivate ); - /*document.addEventListener( 'frmFormCompleteBeforeReplace', function( a, b ) { - console.log( a ); - console.log( b ); - });*/ - - jQuery.on( document, 'frmFormComplete', function( a, b ) { - console.log( a ); - console.log( b ); + document.addEventListener( 'frmFormCompleteBeforeReplace', function( event ) { + window.location.href = deactivationUrl; }); }() ); From e0a0958eb8c92f0072a4265ea7d969ad643c1f39 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Wed, 14 Aug 2024 23:32:51 +0700 Subject: [PATCH 04/23] Make script run --- js/admin/deactivation-feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 7178bf48e6..f2b1d59937 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -94,7 +94,7 @@ const wrapper = document.getElementById( 'frm-deactivation-form-wrapper' ); const form = response.renderedHtml.replace( /]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' ); - wrapper.innerHTML = form; + jQuery( wrapper ).html( form ); addSkipBtn( wrapper ); deactivationModal.dialog( 'open' ); }) From ca8c7bd77fb7cb574c251276edcc658054304bc6 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 15 Aug 2024 17:06:46 +0700 Subject: [PATCH 05/23] Improve styling --- classes/controllers/FrmDeactivationFeedbackController.php | 3 ++- js/admin/deactivation-feedback.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 45ba160944..20a0409512 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -88,7 +88,8 @@ public static function footer_html() { padding-right: 0; } - #frm-deactivation-modal input[name="item_key"] + div { + #frm-deactivation-modal input[name="item_key"] + div, + #frm-deactivation-modal .frm_primary_label { display: none; } diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index f2b1d59937..6d171b38a1 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -62,7 +62,8 @@ const addSkipBtn = formEl => { const btn = frmDom.a( { text: FrmDeactivationFeedbackI18n.skip_text, - href: deactivationUrl + href: deactivationUrl, + className: 'button button-primary frm-button-secondary' }); formEl.querySelector( '.frm_submit' ).prepend( btn ); From 3aa0c04b8a5b65860a1d673a163d1611f91a927e Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 15 Aug 2024 19:17:05 +0700 Subject: [PATCH 06/23] Remove debug code --- classes/controllers/FrmFormsController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index d1de4be0fd..981c9121b8 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -1182,7 +1182,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c $reset_fields = false; FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); FrmSubmitHelper::maybe_create_submit_field( $form, $fields, $reset_fields ); -error_log( $reset_fields ); + if ( $reset_fields ) { $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); } @@ -1191,7 +1191,7 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c $args = array( 'parent_form_id' => $form->id ); $values = FrmAppHelper::setup_edit_vars( $form, 'forms', '', true, array(), $args ); -//error_log( print_r( $fields, true ) ); + /** * Allows modifying the list of fields in the form builder. * From a4341f7e1bf09776e731894c43ee307cb1730a1f Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 15 Aug 2024 19:39:13 +0700 Subject: [PATCH 07/23] Update event selector --- js/admin/deactivation-feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 6d171b38a1..7105df7004 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -1,7 +1,7 @@ ( function() { 'use strict'; - const selectors = '#deactivate-formidable, #deactivate-formidable-pro'; + const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-forms-pro"] .deactivate a,'; let deactivationModal, deactivationUrl; From b8077b77d78b5d9c04b66efb4a55ade16020107d Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 15 Aug 2024 19:44:49 +0700 Subject: [PATCH 08/23] Fix JS error --- js/admin/deactivation-feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 7105df7004..0df60eb22f 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -1,7 +1,7 @@ ( function() { 'use strict'; - const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-forms-pro"] .deactivate a,'; + const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-forms-pro"] .deactivate a'; let deactivationModal, deactivationUrl; From 578792cfeb008273861808f69177a4a33053d912 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 15 Aug 2024 23:34:57 +0700 Subject: [PATCH 09/23] Add dismiss link --- .../FrmDeactivationFeedbackController.php | 14 +++++++++++++- js/admin/deactivation-feedback.js | 7 ++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 20a0409512..91dd86db93 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -38,6 +38,10 @@ public static function footer_html() {
+ + + +
@@ -71,6 +75,13 @@ public static function footer_html() { left: var(--padding); } + #frm-deactivation-modal .frm-modal-close { + position: absolute; + top: 20px; + right: var(--padding); + z-index: 1000; + } + #frm-deactivation-modal .frm_form_title { padding: 20px var(--padding) 20px calc(2 * var(--padding)); margin-top: 0; @@ -89,7 +100,8 @@ public static function footer_html() { } #frm-deactivation-modal input[name="item_key"] + div, - #frm-deactivation-modal .frm_primary_label { + #frm-deactivation-modal .frm_primary_label, + #frm-deactivation-form-wrapper[data-slug="formidable"] #frm_radio_1601-5 { /* Hide too expensive option */ display: none; } diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 0df60eb22f..356f9244e3 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -1,7 +1,7 @@ ( function() { 'use strict'; - const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-forms-pro"] .deactivate a'; + const selectors = 'tr[data-slug="formidable"] .deactivate a, tr[data-slug="formidable-pro"] .deactivate a'; let deactivationModal, deactivationUrl; @@ -81,9 +81,9 @@ deactivationUrl = event.target.href; - const pluginName = event.target.closest( '.plugin-title' ).querySelector( 'strong' ).innerText; + const pluginSlug = event.target.closest( 'tr' ).dataset.slug; - const url = 'http://frmdev.test/wp-json/frm/v2/forms/deactivation-feedback?plugin_name=' + pluginName + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; + const url = 'http://frmdev.test/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=' + pluginSlug + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; const response = fetch( url, { method: 'GET' @@ -96,6 +96,7 @@ const form = response.renderedHtml.replace( /]*(formidableforms.css|action=frmpro_css)[^>]*>/gi, '' ); jQuery( wrapper ).html( form ); + wrapper.setAttribute( 'data-slug', pluginSlug ); addSkipBtn( wrapper ); deactivationModal.dialog( 'open' ); }) From 9b5df2ed90dcd9ac0cd4c00ecfe6f31e9b812a16 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Sat, 17 Aug 2024 03:45:22 +0700 Subject: [PATCH 10/23] Update feedback form URL --- js/admin/deactivation-feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 356f9244e3..756965c235 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -83,7 +83,7 @@ const pluginSlug = event.target.closest( 'tr' ).dataset.slug; - const url = 'http://frmdev.test/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=' + pluginSlug + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; + const url = 'https://feedback.strategy11.com/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=' + pluginSlug + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; const response = fetch( url, { method: 'GET' From c75691b698ddf1c3b2a77468407b8d6095d1908a Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Sat, 17 Aug 2024 03:53:54 +0700 Subject: [PATCH 11/23] Add site data for feedback form --- js/admin/deactivation-feedback.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 756965c235..6cc71f82a9 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -83,7 +83,7 @@ const pluginSlug = event.target.closest( 'tr' ).dataset.slug; - const url = 'https://feedback.strategy11.com/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=' + pluginSlug + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; + const url = 'https://feedback.strategy11.com/wp-json/frm/v2/forms/deactivation-feedback?plugin_slug=' + pluginSlug + '&site=' + window.location.host + '&return=html&exclude_script=jquery&exclude_style=formidable-css'; const response = fetch( url, { method: 'GET' From 2393ba1abdaf54327d2464aa5e832bf04d7dc3e5 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Wed, 21 Aug 2024 21:00:36 +0700 Subject: [PATCH 12/23] Fix phpcs --- .../FrmDeactivationFeedbackController.php | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 91dd86db93..86d55b251f 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -6,6 +6,9 @@ * @since x.x */ +/** + * Class FrmDeactivationFeedbackController + */ class FrmDeactivationFeedbackController { private static function is_plugins_page() { @@ -16,8 +19,14 @@ public static function enqueue_assets() { if ( ! self::is_plugins_page() ) { return; } - wp_enqueue_script( 'frm-deactivation-feedback', FrmAppHelper::plugin_url() . '/js/admin/deactivation-feedback.js', array( 'formidable', 'formidable_dom', 'jquery' ), FrmAppHelper::plugin_version(), true ); - wp_enqueue_style( 'formidable-admin' ); + wp_enqueue_script( + 'frm-deactivation-feedback', + FrmAppHelper::plugin_url() . '/js/admin/deactivation-feedback.js', + array( 'formidable', 'formidable_dom', 'jquery' ), + FrmAppHelper::plugin_version(), + true + ); + wp_enqueue_style( 'formidable-admin' ); FrmAppHelper::localize_script( 'front' ); @@ -39,7 +48,9 @@ public static function footer_html() {
- + + +
@@ -114,8 +125,16 @@ public static function footer_html() { private static function modal_icon() { ?> - - + + + + Date: Wed, 21 Aug 2024 21:18:45 +0700 Subject: [PATCH 13/23] Use existing logo for deactivation modal --- classes/controllers/FrmDeactivationFeedbackController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 86d55b251f..6d8089b37a 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -54,7 +54,7 @@ public static function footer_html() {
- +
@@ -80,7 +80,7 @@ public static function footer_html() { word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ } - .frm_deactivation_modal_icon { + #frm-deactivation-modal .inside .frmsvg { position: absolute; top: calc(var(--padding) - 1px); left: var(--padding); From bac77620bc6be5b1863a78bb767186502bffbfc3 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Thu, 22 Aug 2024 01:24:22 +0700 Subject: [PATCH 14/23] Update styling --- .../FrmDeactivationFeedbackController.php | 71 ++++++++++++++++++- js/admin/deactivation-feedback.js | 4 +- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 6d8089b37a..e90c93dbf6 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -84,6 +84,8 @@ public static function footer_html() { position: absolute; top: calc(var(--padding) - 1px); left: var(--padding); + width: 20px; + height: 20px; } #frm-deactivation-modal .frm-modal-close { @@ -94,9 +96,12 @@ public static function footer_html() { } #frm-deactivation-modal .frm_form_title { - padding: 20px var(--padding) 20px calc(2 * var(--padding)); + padding: 20px var(--padding) 12px calc(28px + var(--padding)); margin-top: 0; border-bottom: 1px solid #f2f4f7; + font-weight: 400; + font-size: 14px; + line-height: 26px; } #frm-deactivation-modal .frm_description, @@ -105,19 +110,81 @@ public static function footer_html() { padding-right: var(--padding); } + #frm-deactivation-modal .frm_description p { + font-size: 12px; + margin-top: 16px; + margin-bottom: 16px; + color: #667085; + } + #frm-deactivation-modal .inside { padding-left: 0; padding-right: 0; } + #frm-deactivation-modal .frm_radio { + margin-bottom: 15px; + } + + #frm-deactivation-modal .frm_radio .frm_form_field { + padding-left: 0; + padding-right: 0; + margin-bottom: -5px; + } + + #frm-deactivation-modal .frm_radio .frm_form_field textarea { + margin-top: 5px; + height: 65px; + border-radius: 8px; + padding: 5px 12px; + font-size: 14px; + } + + #frm-deactivation-modal .frm_radio .frm_form_field textarea:focus { + border-color: #4199FD; + box-shadow: none; + } + + #frm-deactivation-modal .frm_radio .frm_form_field textarea::placeholder { + color: #98A2B3; + } + + #frm-deactivation-modal .frm_radio .frm_html_container { + padding: 6px; + background-color: #F9FAFB; + margin-top: 8px; + margin-bottom: 15px; + border-radius: 8px; + } + + #frm-deactivation-modal .frm_radio .frm_html_container p { + margin: 0; + font-size: 14px; + line-height: 20px; + color: #667085; + } + #frm-deactivation-modal input[name="item_key"] + div, #frm-deactivation-modal .frm_primary_label, - #frm-deactivation-form-wrapper[data-slug="formidable"] #frm_radio_1601-5 { /* Hide too expensive option */ + #frm-deactivation-form-wrapper[data-slug="formidable"] .frm_radio:nth-of-type(5) { /* Hide too expensive option */ display: none; } #frm-deactivation-modal .frm_submit { text-align: right; + margin-top: 38px; + } + + #frm-deactivation-modal .frm_button_submit { + margin-right: 0; + } + + #frm-deactivation-modal .frm-skip-link { + color: #98A2B3; + display: inline-block; + font-size: 14px; + line-height: 40px; + padding: 0 13px; } Date: Thu, 22 Aug 2024 01:28:47 +0700 Subject: [PATCH 15/23] Fix phpcs --- .../FrmDeactivationFeedbackController.php | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index e90c93dbf6..1031e0af13 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -11,10 +11,20 @@ */ class FrmDeactivationFeedbackController { + /** + * Checks if is plugins page. + * + * @return bool + */ private static function is_plugins_page() { return 'plugins' === get_current_screen()->id; } + /** + * Enqueues assets. + * + * @return void + */ public static function enqueue_assets() { if ( ! self::is_plugins_page() ) { return; @@ -39,6 +49,11 @@ public static function enqueue_assets() { ); } + /** + * Prints footer HTML. + * + * @return void + */ public static function footer_html() { if ( ! self::is_plugins_page() ) { return; @@ -62,6 +77,18 @@ public static function footer_html() {
+ - - - - - - Date: Fri, 23 Aug 2024 17:52:17 +0700 Subject: [PATCH 16/23] Only show feedback form once in 6 months --- .../FrmDeactivationFeedbackController.php | 43 +++++++++++++++++-- classes/controllers/FrmHooksController.php | 1 + js/admin/deactivation-feedback.js | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 1031e0af13..53add6f4c3 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -20,13 +20,49 @@ private static function is_plugins_page() { return 'plugins' === get_current_screen()->id; } + /** + * Checks if feedback is expired. + * + * @return bool + */ + private static function feedback_is_expired() { + $feedback_expired = get_option( 'frm_feedback_expired' ); + if ( ! $feedback_expired ) { + return true; + } + + $expired_date = strtotime( $feedback_expired ); + if ( ! $expired_date ) { + return true; + } + + return $expired_date < time(); + } + + /** + * Sets feedback expired date. + * + * @param string $plugin Path to the plugin file relative to the plugins directory. + * + * @return void + */ + public static function set_feedback_expired_date( $plugin ) { + if ( empty( $_GET['frm_feedback_submitted'] ) ) { + return; + } + if ( ! strpos( $plugin, 'formidable.php' ) && ! strpos( $plugin, 'formidable-pro.php' ) ) { + return; + } + update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 6 months' ) ) ); + } + /** * Enqueues assets. * * @return void */ public static function enqueue_assets() { - if ( ! self::is_plugins_page() ) { + if ( ! self::is_plugins_page() || ! self::feedback_is_expired() ) { return; } wp_enqueue_script( @@ -55,7 +91,7 @@ public static function enqueue_assets() { * @return void */ public static function footer_html() { - if ( ! self::is_plugins_page() ) { + if ( ! self::is_plugins_page() || ! self::feedback_is_expired() ) { return; } ?> @@ -192,8 +228,7 @@ private static function modal_style() { } #frm-deactivation-modal input[name="item_key"] + div, - #frm-deactivation-modal .frm_primary_label, - #frm-deactivation-form-wrapper[data-slug="formidable"] .frm_radio:nth-of-type(5) { /* Hide too expensive option */ + #frm-deactivation-modal .frm_primary_label { display: none; } diff --git a/classes/controllers/FrmHooksController.php b/classes/controllers/FrmHooksController.php index f5532854a1..a70c222959 100644 --- a/classes/controllers/FrmHooksController.php +++ b/classes/controllers/FrmHooksController.php @@ -201,6 +201,7 @@ public static function load_admin_hooks() { // Deactivation feedback. add_action( 'admin_enqueue_scripts', 'FrmDeactivationFeedbackController::enqueue_assets' ); add_action( 'admin_footer', 'FrmDeactivationFeedbackController::footer_html' ); + add_action( 'deactivated_plugin', 'FrmDeactivationFeedbackController::set_feedback_expired_date' ); FrmDashboardController::load_admin_hooks(); FrmTransLiteHooksController::load_admin_hooks(); diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 7bafeee1b6..6c75d76932 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -79,7 +79,7 @@ ); } - deactivationUrl = event.target.href; + deactivationUrl = event.target.href + '&frm_feedback_submitted=1'; const pluginSlug = event.target.closest( 'tr' ).dataset.slug; From c902eaa0df1505b58e0fc0e59e7660f9f3dbd4a3 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Fri, 23 Aug 2024 22:32:05 +0700 Subject: [PATCH 17/23] Temporary change feedback expired time period --- classes/controllers/FrmDeactivationFeedbackController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 53add6f4c3..30ef9a3b2d 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -53,7 +53,7 @@ public static function set_feedback_expired_date( $plugin ) { if ( ! strpos( $plugin, 'formidable.php' ) && ! strpos( $plugin, 'formidable-pro.php' ) ) { return; } - update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 6 months' ) ) ); + update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 15 minutes' ) ) ); } /** From bc775d1e43fbf0b3092341314f0015bd8198606b Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Fri, 23 Aug 2024 22:38:18 +0700 Subject: [PATCH 18/23] Hide feedback modal icon when success --- classes/controllers/FrmDeactivationFeedbackController.php | 4 ++-- js/admin/deactivation-feedback.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 30ef9a3b2d..12a285fad6 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -105,7 +105,7 @@ public static function footer_html() {
- +
@@ -143,7 +143,7 @@ private static function modal_style() { word-wrap: normal !important; /* many screen reader and browser combinations announce broken words as they would appear visually */ } - #frm-deactivation-modal .inside .frmsvg { + #frm-deactivation-modal-icon { position: absolute; top: calc(var(--padding) - 1px); left: var(--padding); diff --git a/js/admin/deactivation-feedback.js b/js/admin/deactivation-feedback.js index 6c75d76932..5c99b8c74e 100644 --- a/js/admin/deactivation-feedback.js +++ b/js/admin/deactivation-feedback.js @@ -108,6 +108,7 @@ frmDom.util.documentOn( 'click', selectors, onClickDeactivate ); document.addEventListener( 'frmFormCompleteBeforeReplace', function( event ) { + document.getElementById( 'frm-deactivation-modal-icon' ).remove(); window.location.href = deactivationUrl; }); }() ); From 8d6dc768164d09eef72dffc77c545efa41a0c689 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Mon, 26 Aug 2024 15:06:11 +0700 Subject: [PATCH 19/23] Update temp feedback expired time --- classes/controllers/FrmDeactivationFeedbackController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 12a285fad6..59ded0de6b 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -53,7 +53,7 @@ public static function set_feedback_expired_date( $plugin ) { if ( ! strpos( $plugin, 'formidable.php' ) && ! strpos( $plugin, 'formidable-pro.php' ) ) { return; } - update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 15 minutes' ) ) ); + update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 1 day' ) ) ); } /** From 06e997ecc80354aa3130bdb533305e69cd453a32 Mon Sep 17 00:00:00 2001 From: Truong Giang Date: Mon, 26 Aug 2024 15:11:09 +0700 Subject: [PATCH 20/23] Fix phpcs --- .../FrmDeactivationFeedbackController.php | 49 +++---------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index 59ded0de6b..dabf3cf934 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -53,7 +53,7 @@ public static function set_feedback_expired_date( $plugin ) { if ( ! strpos( $plugin, 'formidable.php' ) && ! strpos( $plugin, 'formidable-pro.php' ) ) { return; } - update_option( 'frm_feedback_expired', date( 'Y-m-d', strtotime( '+ 1 day' ) ) ); + update_option( 'frm_feedback_expired', gmdate( 'Y-m-d', strtotime( '+ 1 day' ) ) ); } /** @@ -126,9 +126,7 @@ public static function footer_html() { private static function modal_style() { ?> - Date: Tue, 1 Oct 2024 11:30:28 -0300 Subject: [PATCH 23/23] Add abspath check --- classes/controllers/FrmDeactivationFeedbackController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/controllers/FrmDeactivationFeedbackController.php b/classes/controllers/FrmDeactivationFeedbackController.php index f5bc5ad923..e853678224 100644 --- a/classes/controllers/FrmDeactivationFeedbackController.php +++ b/classes/controllers/FrmDeactivationFeedbackController.php @@ -6,6 +6,10 @@ * @since x.x */ +if ( ! defined( 'ABSPATH' ) ) { + die( 'You are not allowed to call this page directly.' ); +} + /** * Class FrmDeactivationFeedbackController */