Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
310 changes: 161 additions & 149 deletions composer.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,8 @@ function show_nps_notice() {
'plugin_name' => __( 'All In One Schema Rich Snippets', 'rich-snippets' ),
'nps_rating_message' => __( 'How likely are you to recommend All In One Schema Rich Snippets to your friends or colleagues?', 'rich-snippets' ),
// Step 2A i.e. positive.
'feedback_content' => __( 'Could you please do us a favor and give us a 5-star rating on Wordpress? It would help others choose All In One Schema Rich Snippets with confidence. Thank you!', 'rich-snippets' ),
'feedback_title' => __( 'Thanks a lot for your feedback! 😍', 'rich-snippets' ),
'feedback_content' => __( 'Thanks for using Rich Snippets! Got feedback or suggestions to make it even better? We’d love to hear from you.', 'rich-snippets' ),
'plugin_rating_link' => esc_url( 'https://wordpress.org/support/plugin/all-in-one-schemaorg-rich-snippets/reviews/#new-post' ),
// Step 2B i.e. negative.
'plugin_rating_title' => __( 'Thank you for your feedback', 'rich-snippets' ),
Expand Down
15 changes: 15 additions & 0 deletions lib/nps-survey/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Version 1.0.15 - 11-09-2025
- New:
- Added `privacy_policy` option with configurable link and custom content.
- Added `popup.placement` option to customize popup position.

Version 1.0.14 - 18-08-2025
- Improvement:
- Added `rating_min_label` and `rating_max_label` text options for customizable rating labels.

Version 1.0.13 - 18-08-2025
- Fix:
- Fixed issue where incorrect Content-Type header caused NPS survey close and rating submission requests to fail.
- Dev:
- Added filters to ensure compatibility with internal WP NPS Survey plugin on marketing sites.

Version 1.0.12 - 16-07-2025
- Improvement:
- Refactored rating prompt logic to allow disabling the WordPress rating functionality, ensuring a non-discriminatory and guideline-compliant user experience.
Expand Down
110 changes: 101 additions & 9 deletions lib/nps-survey/classes/nps-survey-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,20 @@ public static function show_nps_notice( string $id, array $vars = [] ): void {
$plugin_slug = $vars['plugin_slug'];
$display_after = is_int( $vars['display_after'] ) ? $vars['display_after'] : 0;

if ( ! self::is_show_nps_survey_form( $plugin_slug, $display_after ) ) {
/**
* Filter to check if the NPS survey should be shown.
*
* @param bool $status Whether to show the notice.
* @param string $plugin_slug Plugin slug.
* @since 1.0.13
*/
$show_notice = apply_filters(
'nps_survey_show_notice',
self::is_show_nps_survey_form( $plugin_slug, $display_after ),
$plugin_slug
);

if ( ! $show_notice ) {
return;
}

Expand All @@ -75,7 +88,8 @@ public static function show_nps_notice( string $id, array $vars = [] ): void {
}
$current_screen = get_current_screen();

if ( $current_screen instanceof WP_Screen && ! in_array( $current_screen->id, $show_on_screen, true ) ) {
$admin_only = self::is_nps_survey_enabled_for_admin_only();
if ( $admin_only && $current_screen instanceof WP_Screen && ! in_array( $current_screen->id, $show_on_screen, true ) ) {
return;
}
// Loading script here to confirm if the screen is allowed or not.
Expand Down Expand Up @@ -114,14 +128,15 @@ public static function google_fonts_url() {
*/
public static function editor_load_scripts( $show_on_screens ): void {

if ( ! is_admin() ) {
$admin_only = self::is_nps_survey_enabled_for_admin_only();
if ( $admin_only && ! is_admin() ) {
return;
}

$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';

if ( ! in_array( $screen_id, $show_on_screens, true ) ) {
if ( $admin_only && ! in_array( $screen_id, $show_on_screens, true ) ) {
return;
}

Expand Down Expand Up @@ -247,6 +262,14 @@ public static function get_api_headers() {
* @return object|bool
*/
public static function get_item_permissions_check( $request ) {
/**
* Filter to check if NPS Survey is enabled on API.
*
* @since 1.0.13
*/
if ( apply_filters( 'nps_survey_api_disable_permission_check', false ) ) {
return true;
}

if ( ! current_user_can( 'manage_options' ) ) {
return new \WP_Error(
Expand All @@ -258,6 +281,38 @@ public static function get_item_permissions_check( $request ) {
return true;
}

/**
* Method to determine if the NPS survey status update should be skipped for database option.
*
* @param string $nps_id NPS ID.
* @param string $type Type of action (e.g., 'submit', 'dismiss').
* @param array $data Additional data related to the NPS survey.
*
* @since 1.0.13
* @return bool
* @phpstan-ignore-next-line
*/
public static function should_skip_status_update( $nps_id, $type, $data = array() ): bool {
/**
* Filter to determine if the NPS survey status should be updated.
*
* @param bool $update Default is true, can be modified by the filter.
* @param array $post_data Post data being sent.
* @since 1.0.13
*/
return apply_filters(
'nps_survey_should_skip_status_update',
false, // Default to false, can be modified by the filter.
array_merge(
$data,
array(
'nps_id' => $nps_id,
'action_type' => $type,
)
)
);
}

/**
* Submit Ratings.
*
Expand All @@ -281,12 +336,14 @@ public static function submit_rating( $request ) {
}

$current_user = wp_get_current_user();
$nps_id = $request->get_param( 'nps_id' ) ?? '';

/**
* Filter the post data.
* This can be used to modify the post data before sending it to the API.
*
* @param array<mixed> $post_data Post data.
* @param string $nps_id NPS ID.
* @return array<mixed>
*/
$post_data = apply_filters(
Expand All @@ -299,21 +356,24 @@ public static function submit_rating( $request ) {
'last_name' => $current_user->last_name ?? '',
'source' => ! empty( $request['plugin_slug'] ) ? sanitize_text_field( strval( $request['plugin_slug'] ) ) : '',
'plugin_slug' => ! empty( $request['plugin_slug'] ) ? sanitize_text_field( strval( $request['plugin_slug'] ) ) : '',
)
),
$nps_id
);

/**
* Filter the API endpoint.
*
* @param string $api_endpoint API endpoint.
* @param array<mixed> $post_data Post data.
* @param string $nps_id NPS ID.
*
* @return string
*/
$api_endpoint = apply_filters(
'nps_survey_api_endpoint',
self::get_api_domain() . 'wp-json/bsf-metrics-server/v1/nps-survey/',
$post_data // Pass the post data to the filter, so that the endpoint can be modified based on the data.
$post_data, // Pass the post data to the filter, so that the endpoint can be modified based on the data.
$nps_id
);

$post_data_in_json = wp_json_encode( $post_data );
Expand All @@ -331,14 +391,22 @@ public static function submit_rating( $request ) {
array(
'data' => 'Failed ' . $response->get_error_message(),
'status' => false,

)
);
}

$response_code = wp_remote_retrieve_response_code( $response );

if ( 200 === $response_code ) {
if ( 200 === $response_code || 201 === $response_code ) {

// If the status update should be skipped, return success.
if ( self::should_skip_status_update( $nps_id, 'submit', $post_data ) ) {
wp_send_json_success(
array(
'status' => true,
)
);
}

$nps_form_status = array(
'dismiss_count' => 0,
Expand All @@ -358,7 +426,6 @@ public static function submit_rating( $request ) {
wp_send_json_error(
array(
'status' => false,

)
);
}
Expand Down Expand Up @@ -386,6 +453,16 @@ public static function dismiss_nps_survey_panel( $request ) {
);
}

// If the status update should be skipped, return success.
$nps_id = $request->get_param( 'nps_id' ) ?? '';
if ( self::should_skip_status_update( $nps_id, 'dismiss' ) ) {
wp_send_json_success(
array(
'status' => true,
)
);
}

$nps_form_status = self::get_nps_survey_dismiss_status( strval( $request['plugin_slug'] ) );

// Add dismiss timespan.
Expand Down Expand Up @@ -496,6 +573,21 @@ public static function is_show_nps_survey_form( string $plugin_slug, int $displa
return true;
}

/**
* Check if NPS Survey is enabled for admin only. Default is true.
*
* @since 1.0.13
* @return bool
*/
public static function is_nps_survey_enabled_for_admin_only() {
/**
* Filter to check if NPS Survey is enabled for admin only.
*
* @since 1.0.13
*/
return apply_filters( 'nps_survey_enabled_for_admin_only', true );
}

/**
* Get NPS Dismiss Option Name.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/nps-survey/dist/main.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '9a83e54041811ee7b09c');
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-element', 'wp-i18n'), 'version' => '747a09817c61fd382747');
5 changes: 4 additions & 1 deletion lib/nps-survey/dist/main.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion lib/nps-survey/dist/style-main-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
}.nps-survey-root .absolute {position: absolute
}.nps-survey-root .relative {position: relative
}.nps-survey-root .inset-0 {inset: 0px
}.nps-survey-root .bottom-2 {bottom: 0.5rem
}.nps-survey-root .left-auto {right: auto
}.nps-survey-root .right-2 {left: 0.5rem
}.nps-survey-root .right-3 {left: 0.75rem
}.nps-survey-root .top-3 {top: 0.75rem
}.nps-survey-root .isolate {isolation: isolate
}.nps-survey-root .z-\[9999999999\] {z-index: 9999999999
}.nps-survey-root .z-\[999999999\] {z-index: 999999999
}.nps-survey-root .mx-0 {margin-right: 0px;margin-left: 0px
}.nps-survey-root .my-0 {margin-top: 0px;margin-bottom: 0px
}.nps-survey-root .mb-0 {margin-bottom: 0px
}.nps-survey-root .mt-1 {margin-top: 0.25rem
}.nps-survey-root .mt-2 {margin-top: 0.5rem
}.nps-survey-root .mt-3 {margin-top: 0.75rem
}.nps-survey-root .mt-5 {margin-top: 1.25rem
}.nps-survey-root .box-border {box-sizing: border-box
}.nps-survey-root .block {display: block
}.nps-survey-root .flex {display: flex
}.nps-survey-root .inline-flex {display: inline-flex
Expand All @@ -29,7 +31,10 @@
}.nps-survey-root .w-\[calc\(100\%-8px\)\] {width: calc(100% - 8px)
}.nps-survey-root .w-full {width: 100%
}.nps-survey-root .max-w-\[30rem\] {max-width: 30rem
}.nps-survey-root .max-w-\[36em\] {max-width: 36em
}.nps-survey-root .flex-1 {flex: 1 1 0%
}.nps-survey-root .translate-y-2\.5 {--tw-translate-y: 0.625rem;transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
}.nps-survey-root .transform {transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
}@keyframes spin {to {transform: rotate(-360deg)
}
}.nps-survey-root .animate-spin {animation: spin 1s linear infinite
Expand All @@ -55,6 +60,7 @@
}.nps-survey-root .border-transparent {border-color: transparent
}.nps-survey-root .border-white {--tw-border-opacity: 1;border-color: rgb(255 255 255 / var(--tw-border-opacity))
}.nps-survey-root .border-zip-body-text {--tw-border-opacity: 1;border-color: rgb(var(--zip-body-text) / var(--tw-border-opacity))
}.nps-survey-root .bg-\[\#111827BF\]\/75 {background-color: rgb(17 24 39 / 0.75)
}.nps-survey-root .bg-nps-button-background {--tw-bg-opacity: 1;background-color: rgb(34 113 177 / var(--tw-bg-opacity))
}.nps-survey-root .bg-transparent {background-color: transparent
}.nps-survey-root .bg-white {--tw-bg-opacity: 1;background-color: rgb(255 255 255 / var(--tw-bg-opacity))
Expand All @@ -74,6 +80,8 @@
}.nps-survey-root .pr-4 {padding-left: 1rem
}.nps-survey-root .pr-5 {padding-left: 1.25rem
}.nps-survey-root .pr-6 {padding-left: 1.5rem
}.nps-survey-root .text-right {text-align: left
}.nps-survey-root .text-\[\.625rem\] {font-size: .625rem
}.nps-survey-root .text-base {font-size: 1rem;line-height: 1.5rem
}.nps-survey-root .text-lg {font-size: 1.125rem;line-height: 1.75rem
}.nps-survey-root .text-sm {font-size: 0.875rem;line-height: 1.25rem
Expand All @@ -85,7 +93,10 @@
}.nps-survey-root .leading-5 {line-height: 1.25rem
}.nps-survey-root .leading-6 {line-height: 1.5rem
}.nps-survey-root .leading-7 {line-height: 1.75rem
}.nps-survey-root .leading-normal {line-height: 1.5
}.nps-survey-root .text-border-secondary {--tw-text-opacity: 1;color: rgb(107 114 128 / var(--tw-text-opacity))
}.nps-survey-root .text-gray-400 {--tw-text-opacity: 1;color: rgb(156 163 175 / var(--tw-text-opacity))
}.nps-survey-root .text-inherit {color: inherit
}.nps-survey-root .text-nps-button-background {--tw-text-opacity: 1;color: rgb(34 113 177 / var(--tw-text-opacity))
}.nps-survey-root .text-secondary-text {--tw-text-opacity: 1;color: rgb(156 163 175 / var(--tw-text-opacity))
}.nps-survey-root .text-white {--tw-text-opacity: 1;color: rgb(255 255 255 / var(--tw-text-opacity))
Expand All @@ -108,7 +119,9 @@
}.nps-survey-root * {box-sizing: border-box;font-family: Figtree, sans-serif
}.nps-survey-root .hover\:cursor-pointer:hover {cursor: pointer
}.nps-survey-root .hover\:bg-gray-50:hover {--tw-bg-opacity: 1;background-color: rgb(249 250 251 / var(--tw-bg-opacity))
}.nps-survey-root .hover\:text-white:hover {--tw-text-opacity: 1;color: rgb(255 255 255 / var(--tw-text-opacity))
}.nps-survey-root .focus\:z-10:focus {z-index: 10
}.nps-survey-root .focus\:shadow-none:focus {--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
}.nps-survey-root .focus\:ring-1:focus {--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)
}.nps-survey-root .focus\:ring-nps-button-background:focus {--tw-ring-opacity: 1;--tw-ring-color: rgb(34 113 177 / var(--tw-ring-opacity))
}.nps-survey-root .focus-visible\:outline:focus-visible {outline-style: solid
Expand Down
15 changes: 14 additions & 1 deletion lib/nps-survey/dist/style-main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
}.nps-survey-root .absolute {position: absolute
}.nps-survey-root .relative {position: relative
}.nps-survey-root .inset-0 {inset: 0px
}.nps-survey-root .bottom-2 {bottom: 0.5rem
}.nps-survey-root .left-auto {left: auto
}.nps-survey-root .right-2 {right: 0.5rem
}.nps-survey-root .right-3 {right: 0.75rem
}.nps-survey-root .top-3 {top: 0.75rem
}.nps-survey-root .isolate {isolation: isolate
}.nps-survey-root .z-\[9999999999\] {z-index: 9999999999
}.nps-survey-root .z-\[999999999\] {z-index: 999999999
}.nps-survey-root .mx-0 {margin-left: 0px;margin-right: 0px
}.nps-survey-root .my-0 {margin-top: 0px;margin-bottom: 0px
}.nps-survey-root .mb-0 {margin-bottom: 0px
}.nps-survey-root .mt-1 {margin-top: 0.25rem
}.nps-survey-root .mt-2 {margin-top: 0.5rem
}.nps-survey-root .mt-3 {margin-top: 0.75rem
}.nps-survey-root .mt-5 {margin-top: 1.25rem
}.nps-survey-root .box-border {box-sizing: border-box
}.nps-survey-root .block {display: block
}.nps-survey-root .flex {display: flex
}.nps-survey-root .inline-flex {display: inline-flex
Expand All @@ -29,7 +31,10 @@
}.nps-survey-root .w-\[calc\(100\%-8px\)\] {width: calc(100% - 8px)
}.nps-survey-root .w-full {width: 100%
}.nps-survey-root .max-w-\[30rem\] {max-width: 30rem
}.nps-survey-root .max-w-\[36em\] {max-width: 36em
}.nps-survey-root .flex-1 {flex: 1 1 0%
}.nps-survey-root .translate-y-2\.5 {--tw-translate-y: 0.625rem;transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
}.nps-survey-root .transform {transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
}@keyframes spin {to {transform: rotate(360deg)
}
}.nps-survey-root .animate-spin {animation: spin 1s linear infinite
Expand All @@ -55,6 +60,7 @@
}.nps-survey-root .border-transparent {border-color: transparent
}.nps-survey-root .border-white {--tw-border-opacity: 1;border-color: rgb(255 255 255 / var(--tw-border-opacity))
}.nps-survey-root .border-zip-body-text {--tw-border-opacity: 1;border-color: rgb(var(--zip-body-text) / var(--tw-border-opacity))
}.nps-survey-root .bg-\[\#111827BF\]\/75 {background-color: rgb(17 24 39 / 0.75)
}.nps-survey-root .bg-nps-button-background {--tw-bg-opacity: 1;background-color: rgb(34 113 177 / var(--tw-bg-opacity))
}.nps-survey-root .bg-transparent {background-color: transparent
}.nps-survey-root .bg-white {--tw-bg-opacity: 1;background-color: rgb(255 255 255 / var(--tw-bg-opacity))
Expand All @@ -74,6 +80,8 @@
}.nps-survey-root .pr-4 {padding-right: 1rem
}.nps-survey-root .pr-5 {padding-right: 1.25rem
}.nps-survey-root .pr-6 {padding-right: 1.5rem
}.nps-survey-root .text-right {text-align: right
}.nps-survey-root .text-\[\.625rem\] {font-size: .625rem
}.nps-survey-root .text-base {font-size: 1rem;line-height: 1.5rem
}.nps-survey-root .text-lg {font-size: 1.125rem;line-height: 1.75rem
}.nps-survey-root .text-sm {font-size: 0.875rem;line-height: 1.25rem
Expand All @@ -85,7 +93,10 @@
}.nps-survey-root .leading-5 {line-height: 1.25rem
}.nps-survey-root .leading-6 {line-height: 1.5rem
}.nps-survey-root .leading-7 {line-height: 1.75rem
}.nps-survey-root .leading-normal {line-height: 1.5
}.nps-survey-root .text-border-secondary {--tw-text-opacity: 1;color: rgb(107 114 128 / var(--tw-text-opacity))
}.nps-survey-root .text-gray-400 {--tw-text-opacity: 1;color: rgb(156 163 175 / var(--tw-text-opacity))
}.nps-survey-root .text-inherit {color: inherit
}.nps-survey-root .text-nps-button-background {--tw-text-opacity: 1;color: rgb(34 113 177 / var(--tw-text-opacity))
}.nps-survey-root .text-secondary-text {--tw-text-opacity: 1;color: rgb(156 163 175 / var(--tw-text-opacity))
}.nps-survey-root .text-white {--tw-text-opacity: 1;color: rgb(255 255 255 / var(--tw-text-opacity))
Expand All @@ -108,7 +119,9 @@
}.nps-survey-root * {box-sizing: border-box;font-family: Figtree, sans-serif
}.nps-survey-root .hover\:cursor-pointer:hover {cursor: pointer
}.nps-survey-root .hover\:bg-gray-50:hover {--tw-bg-opacity: 1;background-color: rgb(249 250 251 / var(--tw-bg-opacity))
}.nps-survey-root .hover\:text-white:hover {--tw-text-opacity: 1;color: rgb(255 255 255 / var(--tw-text-opacity))
}.nps-survey-root .focus\:z-10:focus {z-index: 10
}.nps-survey-root .focus\:shadow-none:focus {--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
}.nps-survey-root .focus\:ring-1:focus {--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000)
}.nps-survey-root .focus\:ring-nps-button-background:focus {--tw-ring-opacity: 1;--tw-ring-color: rgb(34 113 177 / var(--tw-ring-opacity))
}.nps-survey-root .focus-visible\:outline:focus-visible {outline-style: solid
Expand Down
Loading