PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.7.1
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.7.1
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
sureforms / inc / updater-callbacks.php
updater-callbacks.php
107 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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