abilities
1 month ago
admin
3 months ago
ai-form-builder
1 month ago
blocks
2 months ago
compatibility
2 months ago
database
2 months ago
email
5 months ago
fields
2 months ago
global-settings
1 month ago
lib
1 month ago
migrator
2 months ago
page-builders
2 months ago
payments
1 month ago
single-form-settings
2 months ago
traits
2 months ago
activator.php
1 year ago
admin-ajax.php
2 months ago
background-process.php
9 months ago
create-new-form.php
3 months ago
duplicate-form.php
3 months ago
entries.php
2 months ago
events-scheduler.php
2 years ago
export.php
3 months ago
field-validation.php
1 month ago
form-restriction.php
2 months ago
form-styling.php
5 months ago
form-submit.php
2 months ago
forms-data.php
5 months ago
frontend-assets.php
1 month ago
generate-form-markup.php
2 months ago
gutenberg-hooks.php
2 months ago
helper.php
2 months ago
learn.php
4 months ago
onboarding.php
2 months ago
post-types.php
2 months ago
rest-api.php
1 month ago
smart-tags.php
4 months ago
submit-token.php
5 months ago
translatable.php
1 month ago
updater-callbacks.php
1 year ago
updater.php
1 year ago
updater-callbacks.php
107 lines
| 1 | <?php |
| 2 | /** |
| 3 | * SureForms Updater Callbacks. |
| 4 | * Provides static methods for the updater class. |
| 5 | * |
| 6 | * @package sureforms. |
| 7 | * @since 1.0.0 |
| 8 | */ |
| 9 | |
| 10 | namespace SRFM\Inc; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; // Exit if accessed directly. |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Updater class. |
| 18 | * |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class Updater_Callbacks { |
| 22 | /** |
| 23 | * Update callback method to handle the default dynamic block options in the global settings. |
| 24 | * |
| 25 | * @since 1.0.2 |
| 26 | * @return void |
| 27 | */ |
| 28 | public static function manage_default_dynamic_options() { |
| 29 | |
| 30 | $previous_options = get_option( 'get_default_dynamic_block_option' ); |
| 31 | |
| 32 | if ( ! empty( $previous_options ) && is_array( $previous_options ) ) { |
| 33 | update_option( 'srfm_default_dynamic_block_option', $previous_options ); |
| 34 | delete_option( 'get_default_dynamic_block_option' ); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Update callback method to handle the default dynamic block options in the global settings. |
| 40 | * |
| 41 | * @since 1.0.4 |
| 42 | * @return void |
| 43 | */ |
| 44 | public static function manage_empty_default_dynamic_options() { |
| 45 | |
| 46 | $previous_options = get_option( 'srfm_default_dynamic_block_option' ); |
| 47 | |
| 48 | if ( ! empty( $previous_options ) && is_array( $previous_options ) ) { |
| 49 | // get default options values. |
| 50 | $default_options = Helper::default_dynamic_block_option(); |
| 51 | // merge previous options with default options after filtering empty values. |
| 52 | $previous_options = array_merge( $default_options, array_filter( $previous_options ) ); |
| 53 | // update the options. |
| 54 | update_option( 'srfm_default_dynamic_block_option', $previous_options ); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Update callback method to handle the honeypot option in the global settings. |
| 60 | * |
| 61 | * @since 1.2.1 |
| 62 | * @return void |
| 63 | */ |
| 64 | public static function manage_honeypot_option() { |
| 65 | // Retrieve the previous general settings options. |
| 66 | $general_options = get_option( 'srfm_general_settings_options' ); |
| 67 | if ( ! empty( $general_options ) && is_array( $general_options ) && isset( $general_options['srfm_honeypot'] ) ) { |
| 68 | // Retrieve the security settings options. |
| 69 | $security_options = get_option( 'srfm_security_settings_options' ); |
| 70 | if ( is_array( $security_options ) ) { |
| 71 | // Set the honeypot setting in the security options. |
| 72 | $security_options['srfm_honeypot'] = $general_options['srfm_honeypot']; |
| 73 | // Update the security options. |
| 74 | update_option( 'srfm_security_settings_options', $security_options ); |
| 75 | } |
| 76 | // Remove the honeypot setting from the general options and update it. |
| 77 | unset( $general_options['srfm_honeypot'] ); |
| 78 | update_option( 'srfm_general_settings_options', $general_options ); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Update callback method to handle the default dynamic block options in the global settings. |
| 84 | * |
| 85 | * @since 1.2.1 |
| 86 | * @return void |
| 87 | */ |
| 88 | public static function manage_empty_global_dynamic_options() { |
| 89 | $previous_options = get_option( 'srfm_default_dynamic_block_option' ); |
| 90 | $new_options = Translatable::dynamic_messages(); |
| 91 | |
| 92 | if ( ! empty( $previous_options ) && is_array( $previous_options ) ) { |
| 93 | // Iterate and update the options. |
| 94 | foreach ( $new_options as $key => $value ) { |
| 95 | if ( ! isset( $previous_options[ $key ] ) ) { |
| 96 | $previous_options[ $key ] = $value; |
| 97 | } |
| 98 | } |
| 99 | } else { |
| 100 | $previous_options = Helper::default_dynamic_block_option(); |
| 101 | } |
| 102 | |
| 103 | // update the options. |
| 104 | update_option( 'srfm_default_dynamic_block_option', $previous_options ); |
| 105 | } |
| 106 | } |
| 107 |