From b03336a9a0cb17f616c95c3019a66366bfdb9290 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Thu, 20 Jun 2024 15:25:47 -0400 Subject: [PATCH 1/6] Fixing console error --- js/pmprolpv.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/js/pmprolpv.js b/js/pmprolpv.js index 50726e9..de490c2 100644 --- a/js/pmprolpv.js +++ b/js/pmprolpv.js @@ -1,17 +1,19 @@ jQuery( document ).ready( function( $ ) { // Make an AJAX call to the pmprolpv_get_restriction_js action. - $.ajax( { - url: pmprolpv.ajaxurl + '?action=pmprolpv_get_restriction_js', - type: 'POST', - data: { - url: window.location.href - }, - success: function( response ) { - // If the response is not empty, eval it. + $.ajax( { + url: pmprolpv.ajaxurl + '?action=pmprolpv_get_restriction_js', + type: 'POST', + data: { + url: window.location.href + }, + success: function( response ) { + // If the response is not empty, eval it. console.log(response); - if ( response.success ) { - eval( response.data ); - } - } - } ); -} ); \ No newline at end of file + if (response.success) { + // Wrap the response data in a function to avoid illegal return statement + var wrappedCode = '(function() {' + response.data + '})();'; + eval(wrappedCode); + } + } + } ); +} ); From ee35ccf7e50a305534544864fe84d3859a638916 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Thu, 20 Jun 2024 15:26:02 -0400 Subject: [PATCH 2/6] Correcting text domain --- pmpro-limit-post-views.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pmpro-limit-post-views.php b/pmpro-limit-post-views.php index 50afe9b..6b66229 100755 --- a/pmpro-limit-post-views.php +++ b/pmpro-limit-post-views.php @@ -54,8 +54,8 @@ function pmprolpv_plugin_action_links( $links ) { function pmprolpv_plugin_row_meta( $links, $file ) { if ( strpos( $file, 'pmpro-limit-post-views.php' ) !== false ) { $new_links = array( - '' . __( 'Docs', 'limit-post-views' ) . '', - '' . __( 'Support', 'limit-post-views' ) . '', + '' . __( 'Docs', 'pmpro-limit-post-views' ) . '', + '' . __( 'Support', 'pmpro-limit-post-views' ) . '', ); $links = array_merge( $links, $new_links ); } From d97ae59afc3dbdf6b48ed1617c64051284cc7701 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Thu, 20 Jun 2024 15:26:23 -0400 Subject: [PATCH 3/6] Defer loading script until footer --- includes/restriction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/restriction.php b/includes/restriction.php index fc78678..27069a8 100644 --- a/includes/restriction.php +++ b/includes/restriction.php @@ -24,7 +24,7 @@ function pmprolpv_has_membership_access_filter( $has_access, $post ) { * @since 1.0 */ function pmprolpv_wp_enqueue_scripts() { - wp_register_script( 'pmprolpv', plugins_url( 'js/pmprolpv.js', PMPROLPV_BASE_FILE ), array( 'jquery' ), PMPROLPV_VERSION ); + wp_register_script( 'pmprolpv', plugins_url( 'js/pmprolpv.js', PMPROLPV_BASE_FILE ), array( 'jquery' ), PMPROLPV_VERSION, array( 'in_footer' => true ) ); wp_localize_script( 'pmprolpv', 'pmprolpv', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); wp_enqueue_script( 'pmprolpv' ); } From 88c344d258afd23a8c9288c5955266d8c675d284 Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Thu, 20 Jun 2024 15:26:45 -0400 Subject: [PATCH 4/6] Fixing capitalized term name --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 2b5c12c..d8faf1c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -9,7 +9,7 @@ function pmprolpv_get_level_limit( $level_id ) { $default_option = array( 'views' => '', - 'period' => 'Month', + 'period' => 'month', ); return get_option( 'pmprolpv_limit_' . $level_id, $default_option ); } From 823615f20216aa22a76a45d237d687a7d5fc3bee Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Thu, 20 Jun 2024 15:27:28 -0400 Subject: [PATCH 5/6] UI for settings page, separating non-member and member limit settings, text domains, --- adminpages/limitpostviews.php | 59 ++++++++++++++++++++++++-------- includes/admin.php | 63 +++++++++++++++++++++++++++-------- 2 files changed, 94 insertions(+), 28 deletions(-) diff --git a/adminpages/limitpostviews.php b/adminpages/limitpostviews.php index 7f428fb..f673ffc 100644 --- a/adminpages/limitpostviews.php +++ b/adminpages/limitpostviews.php @@ -16,12 +16,37 @@ require_once( PMPRO_DIR . '/adminpages/admin_header.php' ); /** - * Display membership limits section. + * Display non-member limits section. * * @since 0.3.0 */ -function pmprolpv_settings_section_limits() { - echo '

' . esc_html( __( 'Allow visitors or members limited access to view posts they do not already have access to view.', 'pmpro-limit-post-views' ) ) . '

'; +function pmprolpv_settings_section_non_member_limits() { ?> +
+ +
+
+

+ +
+ +
+