-
Notifications
You must be signed in to change notification settings - Fork 151
Fix: Disable Update Post Notification in free version #1614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sapayth
merged 1 commit into
weDevsOfficial:develop
from
arifulhoque7:fix/update-post-notification-free-version
Jul 7, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| <?php | ||
|
|
||
| namespace WeDevs\Wpuf\Hooks; | ||
|
|
||
| /** | ||
| * Form Settings Cleanup | ||
| * | ||
| * Cleans up pro-only settings from form configurations in the free version | ||
| * to prevent unintended activation of premium features. | ||
| */ | ||
| class Form_Settings_Cleanup { | ||
|
|
||
| /** | ||
| * Constructor | ||
| */ | ||
| public function __construct() { | ||
| add_action( 'wpuf_form_builder_save_form', [ $this, 'cleanup_pro_settings' ], 10, 1 ); | ||
| add_action( 'save_post', [ $this, 'cleanup_form_meta_pro_settings' ], 10, 2 ); | ||
| } | ||
|
|
||
| /** | ||
| * Clean up pro settings after form save | ||
| * | ||
| * @param int $form_id Form ID | ||
| */ | ||
| public function cleanup_pro_settings( $form_id ) { | ||
| if ( wpuf_is_pro_active() ) { | ||
| return; | ||
| } | ||
|
|
||
| $form_settings = wpuf_get_form_settings( $form_id ); | ||
|
|
||
| if ( empty( $form_settings ) ) { | ||
| return; | ||
| } | ||
|
|
||
| $cleaned_settings = $this->remove_pro_notification_settings( $form_settings ); | ||
|
|
||
| // Update if settings were modified | ||
| if ( $cleaned_settings !== $form_settings ) { | ||
| update_post_meta( $form_id, 'wpuf_form_settings', $cleaned_settings ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Clean up pro settings from post meta | ||
| * | ||
| * @param int $post_id Post ID | ||
| * @param \WP_Post $post Post object | ||
| */ | ||
| public function cleanup_form_meta_pro_settings( $post_id, $post ) { | ||
| if ( wpuf_is_pro_active() || $post->post_type !== 'wpuf_forms' ) { | ||
| return; | ||
| } | ||
|
|
||
| $form_settings = get_post_meta( $post_id, 'wpuf_form_settings', true ); | ||
|
|
||
| if ( empty( $form_settings ) ) { | ||
| return; | ||
| } | ||
|
|
||
| $cleaned_settings = $this->remove_pro_notification_settings( $form_settings ); | ||
|
|
||
| // Update if settings were modified | ||
| if ( $cleaned_settings !== $form_settings ) { | ||
| update_post_meta( $post_id, 'wpuf_form_settings', $cleaned_settings ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Remove pro notification settings from form settings | ||
| * | ||
| * @param array $form_settings Form settings array | ||
| * @return array Cleaned form settings | ||
| */ | ||
| private function remove_pro_notification_settings( $form_settings ) { | ||
| if ( ! is_array( $form_settings ) ) { | ||
| return $form_settings; | ||
| } | ||
|
|
||
| // List of pro-only notification settings to remove | ||
| $pro_notification_keys = [ | ||
| 'notification_edit', | ||
| 'notification_edit_to', | ||
| 'notification_edit_subject', | ||
| 'notification_edit_body' | ||
| ]; | ||
|
|
||
| foreach ( $pro_notification_keys as $key ) { | ||
| if ( isset( $form_settings[ $key ] ) ) { | ||
| unset( $form_settings[ $key ] ); | ||
| } | ||
| } | ||
|
|
||
| if ( isset( $form_settings['notification'] ) && is_array( $form_settings['notification'] ) ) { | ||
| $notification_pro_keys = [ 'edit', 'edit_to', 'edit_subject', 'edit_body' ]; | ||
|
|
||
| foreach ( $notification_pro_keys as $key ) { | ||
| if ( isset( $form_settings['notification'][ $key ] ) ) { | ||
| unset( $form_settings['notification'][ $key ] ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return $form_settings; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix code formatting issues identified by PHPCS.
The logic is correct, but there are several formatting issues that need to be addressed.
Apply this diff to fix the formatting issues:
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 97-97:
Whitespace found at end of line
[failure] 86-86:
There should be a comma after the last array item in a multi-line array.
[failure] 84-84:
Whitespace found at end of line
🤖 Prompt for AI Agents