PluginProbe ʕ •ᴥ•ʔ
Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager / 4.1.41
Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager v4.1.41
4.1.41 4.1.40 4.1.39 4.1.38 trunk 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.3.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.2 1.9.3 2.0.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.4 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.7.0 2.7.1 2.8.0 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.10 3.5.11 3.5.12 3.5.13 3.5.14 3.5.15 3.5.16 3.5.17 3.5.18 3.5.19 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 4.0.0 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.13 4.1.14 4.1.15 4.1.16 4.1.17 4.1.18 4.1.19 4.1.2 4.1.20 4.1.21 4.1.22 4.1.23 4.1.24 4.1.25 4.1.26 4.1.27 4.1.28 4.1.29 4.1.3 4.1.30 4.1.31 4.1.32 4.1.34 4.1.35 4.1.36 4.1.37 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9
flexible-checkout-fields / src / Tracker / DeactivationTracker.php
flexible-checkout-fields / src / Tracker Last commit date
DeactivationTracker.php 1 week ago
DeactivationTracker.php
215 lines
1 <?php
2
3 namespace WPDesk\FCF\Free\Tracker;
4
5 use FcfVendor\WPDesk\DeactivationModal;
6 use FcfVendor\WPDesk\PluginBuilder\Plugin\Hookable;
7 use FcfVendor\WPDesk_Plugin_Info;
8 use WPDesk\FCF\Free\Settings\Form\EditFieldsForm;
9 use WPDesk\FCF\Free\Settings\Option\CustomFieldOption;
10
11 /**
12 * Handles the modal displayed when the plugin is deactivated.
13 */
14 class DeactivationTracker implements Hookable {
15
16 const PLUGIN_SLUG = 'flexible-checkout-fields';
17 const ACTIVATION_OPTION_NAME = 'plugin_activation_%s';
18
19 /**
20 * @var WPDesk_Plugin_Info
21 */
22 private $plugin_info;
23
24 /**
25 * @param WPDesk_Plugin_Info $plugin_info .
26 */
27 public function __construct( WPDesk_Plugin_Info $plugin_info ) {
28 $this->plugin_info = $plugin_info;
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 public function hooks() {
35 add_action( 'admin_init', [ $this, 'load_deactivation_modal' ] );
36 }
37
38 /**
39 * @return void
40 * @internal
41 */
42 public function load_deactivation_modal() {
43 new DeactivationModal\Modal(
44 self::PLUGIN_SLUG,
45 ( new DeactivationModal\Model\FormTemplate( $this->plugin_info->get_plugin_name() ) ),
46 ( new DeactivationModal\Model\FormOptions() )
47 ->set_option(
48 new DeactivationModal\Model\FormOption(
49 'no_checkout_support',
50 10,
51 __( 'The plugin does not work with the default WooCommerce checkout.', 'flexible-checkout-fields' ),
52 sprintf(
53 /* translators: %1$s: Open link tag, %2$s: Close link tag */
54 esc_html__(
55 'Pssst… Did you know that we support block checkout via our Checkout Fields For Blocks plugin? It allows you to add, edit and personalize fields in the WooCommerce block checkout - quickly, conveniently and without coding. It is free - find it %1$shere%2$s',
56 'flexible-checkout-fields'
57 ),
58 '<a href="' . esc_url( 'https://wordpress.org/plugins/checkout-fields-for-blocks/' ) . '" target="_blank">',
59 '</a>'
60 )
61 )
62 )
63 ->set_option(
64 new DeactivationModal\Model\FormOption(
65 'plugin_not_working',
66 10,
67 __( 'The plugin does not work properly', 'flexible-checkout-fields' ),
68 sprintf(
69 /* translators: %1$s: anchor opening tag, %2$s: anchor closing tag, %3$s: anchor opening tag, %4$s: anchor closing tag */
70 __( 'Contact us on %1$sthe support forum%2$s or read %3$sthe plugin FAQ%4$s for help.', 'flexible-checkout-fields' ),
71 '<a href="' . esc_url( apply_filters( 'flexible_checkout_fields/short_url', '#', 'fcf-doesnt-work-properly-support-forum' ) ) . '" target="_blank">',
72 '</a>',
73 '<a href="' . esc_url( apply_filters( 'flexible_checkout_fields/short_url', '#', 'fcf-doesnt-work-properly-faq' ) ) . '" target="_blank">',
74 '</a>'
75 ),
76 __( 'Please tell us what was the problem.', 'flexible-checkout-fields' )
77 )
78 )
79 ->set_option(
80 new DeactivationModal\Model\FormOption(
81 'difficult_to_use',
82 20,
83 __( 'The plugin is difficult to use', 'flexible-checkout-fields' ),
84 sprintf(
85 /* translators: %1$s: anchor opening tag, %2$s: anchor closing tag, %3$s: anchor opening tag, %4$s: anchor closing tag */
86 __( 'Check %1$sthe documentation%2$s or contact us on %3$sthe support forum%4$s for help.', 'flexible-checkout-fields' ),
87 '<a href="' . esc_url( apply_filters( 'flexible_checkout_fields/short_url', '#', 'fcf-plugin-is-difficult-docs' ) ) . '" target="_blank">',
88 '</a>',
89 '<a href="' . esc_url( apply_filters( 'flexible_checkout_fields/short_url', '#', 'fcf-plugin-is-difficult-support-forum' ) ) . '" target="_blank">',
90 '</a>'
91 ),
92 __( 'How can we do it better? Please write what was problematic.', 'flexible-checkout-fields' )
93 )
94 )
95 ->set_option(
96 new DeactivationModal\Model\FormOption(
97 'not_meet_requirements',
98 30,
99 __( 'The plugin does not meet all the requirements', 'flexible-checkout-fields' ),
100 null,
101 __( 'Please write what function is missing.', 'flexible-checkout-fields' )
102 )
103 )
104 ->set_option(
105 new DeactivationModal\Model\FormOption(
106 'found_better_plugin',
107 40,
108 __( 'I found a better plugin', 'flexible-checkout-fields' ),
109 null,
110 __( 'Please write what plugin is it and what was the reason for choosing it.', 'flexible-checkout-fields' )
111 )
112 )
113 ->set_option(
114 new DeactivationModal\Model\FormOption(
115 'no_longer_need',
116 50,
117 __( 'The plugin is no longer needed', 'flexible-checkout-fields' ),
118 null,
119 __( 'What is the reason for that?', 'flexible-checkout-fields' )
120 )
121 )
122 ->set_option(
123 new DeactivationModal\Model\FormOption(
124 'temporary_deactivation',
125 60,
126 __( 'It\'s a temporary deactivation (I\'m just debugging an issue)', 'flexible-checkout-fields' )
127 )
128 )
129 ->set_option(
130 new DeactivationModal\Model\FormOption(
131 'other',
132 70,
133 __( 'Other', 'flexible-checkout-fields' ),
134 null,
135 __( 'Please tell us what made you click this option.', 'flexible-checkout-fields' )
136 )
137 ),
138 ( new DeactivationModal\Model\FormValues() )
139 ->set_value(
140 new DeactivationModal\Model\FormValue(
141 'is_localhost',
142 [ $this, 'is_localhost' ]
143 )
144 )
145 ->set_value(
146 new DeactivationModal\Model\FormValue(
147 'plugin_using_time',
148 [ $this, 'get_time_of_plugin_using' ]
149 )
150 )
151 ->set_value(
152 new DeactivationModal\Model\FormValue(
153 'settings_saved',
154 [ $this, 'check_if_plugin_settings_saved' ]
155 )
156 )
157 ->set_value(
158 new DeactivationModal\Model\FormValue(
159 'custom_fields_added',
160 [ $this, 'check_if_custom_field_created' ]
161 )
162 ),
163 new DeactivationModal\Sender\DataWpdeskSender(
164 $this->plugin_info->get_plugin_file_name(),
165 $this->plugin_info->get_plugin_name()
166 )
167 );
168 }
169
170 /**
171 * @internal
172 */
173 public function is_localhost(): bool {
174 return ( in_array( $_SERVER['REMOTE_ADDR'] ?? '', [ '127.0.0.1', '::1' ], true ) );
175 }
176
177 /**
178 * @return string|null
179 * @internal
180 */
181 public function get_time_of_plugin_using() {
182 $option_activation = sprintf( self::ACTIVATION_OPTION_NAME, $this->plugin_info->get_plugin_file_name() );
183 $activation_date = get_option( $option_activation, null );
184 if ( $activation_date === null ) {
185 return null;
186 }
187
188 $current_date = current_time( 'mysql' );
189 return ( strtotime( $current_date ) - strtotime( $activation_date ) );
190 }
191
192 /**
193 * @internal
194 */
195 public function check_if_plugin_settings_saved(): bool {
196 $settings = get_option( EditFieldsForm::SETTINGS_OPTION_NAME, null );
197 return ( $settings !== null );
198 }
199
200 /**
201 * @internal
202 */
203 public function check_if_custom_field_created(): bool {
204 $settings = get_option( EditFieldsForm::SETTINGS_OPTION_NAME, [] );
205 foreach ( $settings as $section_fields ) {
206 foreach ( $section_fields as $section_field ) {
207 if ( $section_field[ CustomFieldOption::FIELD_NAME ] ?? false ) {
208 return true;
209 }
210 }
211 }
212 return false;
213 }
214 }
215