-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpowerform.php
More file actions
582 lines (509 loc) · 16 KB
/
powerform.php
File metadata and controls
582 lines (509 loc) · 16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<?php
/**
* Plugin Name: Powerform
* Version: 1.2.4
* Plugin URI: https://cp-psource.github.io/powerform/
* Description: Erfasse Benutzerinformationen (so detailliert wie Sie möchten), beteilige Benutzer an interaktiven Umfragen, die Echtzeitergebnisse und Grafiken, Quizfragen im Facebook-Stil und Wissenstests ohne falsche Antwort anzeigen.
* Author: PSOURCE
* Author URI: https://github.com/cp-psource
* Text Domain: powerform
* Domain Path: /languages/
*/
/*
Copyright 2009-2025 PSOURCE (https://github.com/cp-psource)
Author – DerN3rd
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License (Version 2 – GPLv2) as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if ( ! defined( 'ABSPATH' ) ) {
die();
}
if ( ! defined( 'POWERFORM_VERSION' ) ) {
define( 'POWERFORM_VERSION', '1.2.4' );
}
if ( ! defined( 'POWERFORM_SUI_VERSION' ) ) {
define( 'POWERFORM_SUI_VERSION', '2.6.0' );
}
if ( ! defined( 'POWERFORM_STRIPE_LIB_VERSION' ) ) {
define( 'POWERFORM_STRIPE_LIB_VERSION', '7.21.1' );
}
if ( ! defined( 'POWERFORM_STRIPE_LIB_DATE' ) ) {
define( 'POWERFORM_STRIPE_LIB_DATE', '2019-12-03' );
}
if ( ! defined( 'POWERFORM_STRIPE_PARTNER_ID' ) ) {
define( 'POWERFORM_STRIPE_PARTNER_ID', 'pp_partner_GeDaq2odDgGkDJ' );
}
if ( ! defined( 'POWERFORM_PAYPAL_LIB_VERSION' ) ) {
define( 'POWERFORM_PAYPAL_LIB_VERSION', '1.14.0' );
}
if ( ! defined( 'POWERFORM_PRO' ) ) {
define( 'POWERFORM_PRO', true );
}
if ( ! defined( 'POWERFORM_PLUGIN_BASENAME' ) ) {
define( 'POWERFORM_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
}
/*if ( ! defined( 'POWERFORM_PRO_URL' ) ) {
define( 'POWERFORM_PRO_URL', 'https://n3rds.work/project/powerform-pro/' );
}*/
// Include API
require_once plugin_dir_path( __FILE__ ) . 'library/class-api.php';
// Register activation hook
register_activation_hook( __FILE__, array( 'Powerform', 'activation_hook' ) );
// Register deactivation hook
register_deactivation_hook( __FILE__, array( 'Powerform', 'deactivation_hook' ) );
/**
* Class Powerform
*
* Main class. Initialize plugin
*
* @since 1.0
*/
if ( ! class_exists( 'Powerform' ) ) {
class Powerform {
const DOMAIN = 'powerform';
/**
* Plugin instance
*
* @var null
*/
private static $instance = null;
/**
* @var Powerform_Core
*/
public $powerform;
/**
* @var Powerform_Addon_Loader
*/
private $powerform_addon_loader;
/**
* Return the plugin instance
*
* @since 1.0
* @return Powerform
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Powerform constructor.
*
* @since 1.0
*/
public function __construct() {
add_action( 'admin_init', [ $this, 'initialize_admin' ] );
// WICHTIG: Klassen direkt laden, aber NUR wenn powerform_plugin_dir() funktioniert
$this->includes();
// Diese beiden laufen sauber erst beim 'init'-Hook (wie WordPress es erwartet)
add_action( 'init', [ $this, 'init' ] );
add_action( 'init', [ $this, 'load_textdomain' ] );
// Optional: Addons erst initialisieren, wenn alles andere safe ist
if ( self::is_addons_feature_enabled() ) {
add_action( 'init', [ $this, 'init_addons' ] );
}
}
/**
* Called on plugin activation
*
* @since 1.3
*/
public static function activation_hook() {
add_option( 'powerform_activation_hook', 'activated' );
self::set_free_installation_timestamp();
}
/**
* Called on plugin deactivation
*
* @since 1.11
*/
public static function deactivation_hook() {
wp_clear_scheduled_hook( 'powerform_general_data_protection_cleanup' );
}
/**
* Called on admin_init
*
* Flush rewrite rules are not called directly on activation hook, because CPT are not initialized yet
*
* @since 1.3
*/
public function initialize_admin() {
if ( is_admin() && 'activated' === get_option( 'powerform_activation_hook' ) ) {
delete_option( 'powerform_activation_hook' );
flush_rewrite_rules();
}
}
/**
* Return status of Addon feature
*
* If this function return false, then addon functionality will be disabled
*
* @since 1.1
*
* @return bool
*/
public static function is_addons_feature_enabled() {
// force enable addon on entire planet
$enabled = true;
/**
* Filter the status of addons feature
*
* @since 1.1
*
* @param bool $enabled current status of addons feature
*/
$enabled = apply_filters( 'powerform_is_addons_feature_enabled', $enabled );
return $enabled;
}
/**
* Return status of Import/export feature
*
* If this function return false, then Import/export functionality will be disabled
*
* @since 1.4
* @since 1.5 enabled by default
*
* @return bool
*/
public static function is_import_export_feature_enabled() {
// enable import export feature for entire planet by default
$enabled = true;
/**
* Filter the status of Import/export feature
*
* @since 1.4
*
* @param bool $enabled current status of Import/export feature
*/
$enabled = apply_filters( 'powerform_is_import_export_feature_enabled', $enabled );
return $enabled;
}
/**
* Return status of Import integrations feature
*
* If this function return false, then Import integrations functionality will be disabled
*
* @since 1.4
*
* @return bool
*/
public static function is_import_integrations_feature_enabled() {
// default is disabled unless `POWERFORM_ENABLE_IMPORT_INTEGRATIONS` = true,
// integrations data probably contains sensitive content
// not 100% will worked if current addon not enabled / not setup properly
$enabled = ( defined( 'POWERFORM_ENABLE_IMPORT_INTEGRATIONS' ) && POWERFORM_ENABLE_IMPORT_INTEGRATIONS );
/**
* Filter the status of Import integrations feature
*
* @since 1.4
*
* @param bool $enabled current status of Import integrations feature
*/
$enabled = apply_filters( 'powerform_is_import_integrations_feature_enabled', $enabled );
return $enabled;
}
/**
* Return status of Export integrations feature
*
* If this function return false, then Import integrations functionality will be disabled
*
* @since 1.4
*
* @return bool
*/
public static function is_export_integrations_feature_enabled() {
// default is disabled unless `POWERFORM_ENABLE_EXPORT_INTEGRATIONS` = true,
// integrations data probably contains sensitive content
// not 100% will worked if current addon not enabled / not setup properly
$enabled = ( defined( 'POWERFORM_ENABLE_EXPORT_INTEGRATIONS' ) && POWERFORM_ENABLE_EXPORT_INTEGRATIONS );
/**
* Filter the status of Export integrations feature
*
* @since 1.4
*
* @param bool $enabled current status of export integrations feature
*/
$enabled = apply_filters( 'powerform_is_export_integrations_feature_enabled', $enabled );
return $enabled;
}
/**
* Return status of Internal Page Cache support
*
* @since 1.6.1
* @return bool
*/
public static function is_internal_page_cache_support_enabled() {
// default is enabled unless `POWERFORM_ENABLE_INTERNAL_PAGE_CACHE_SUPPORT` = false,
$enabled = true;
if ( defined( 'POWERFORM_ENABLE_INTERNAL_PAGE_CACHE_SUPPORT' ) && ! POWERFORM_ENABLE_INTERNAL_PAGE_CACHE_SUPPORT ) {
$enabled = false;
}
/**
* Filter the status of Internal Page Cache support
*
* @since 1.6.1
*
* @param bool $enabled current status of internal page cache support
*/
$enabled = apply_filters( 'powerform_is_internal_page_cache_support_enabled', $enabled );
return $enabled;
}
/**
* Initiate Addons Helper and Register internal Addons
*
* This function will also trigger action `powerform_addons_loaded`
*
* @since 1.1
*/
public function init_addons() {
/**
* Triggered before load and registering internal addons
*
* Only triggered when addons feature is enabled @see Powerform::is_addons_feature_enabled()
* Keep in mind that @see Powerform_Addon_Loader not yet instantiated
*
* @since 1.1
*/
do_action( 'powerform_before_load_addons' );
include_once powerform_plugin_dir() . 'library/helpers/helper-addon.php';
$this->powerform_addon_loader = Powerform_Addon_Loader::get_instance();
$this->load_powerform_addons();
/**
* Triggered after internal addons of powerform loaded
*
* This action will be used by external addon to register
* Registering addon will use @see Powerform_Addon_Loader::register()
*
* @since 1.1
*/
do_action( 'powerform_addons_loaded' );
}
/**
* Load internal addons
*
* Load pre-packaged addons
*
* @since 1.1
*/
public function load_powerform_addons() {
$addons_directory = powerform_addons_dir();
if ( file_exists( $addons_directory . '/class-addon-autoload.php' ) ) {
include_once $addons_directory . '/class-addon-autoload.php';
$autoloader = new Powerform_Addon_Autoload();
$autoloader->load();
}
}
/**
* Load plugin files
*
* @since 1.0
*/
private function includes() {
// Core files.
/* @noinspection PhpIncludeInspection */
include_once powerform_plugin_dir() . 'library/class-core.php';
include_once powerform_plugin_dir() . 'library/class-addon-loader.php';
include_once powerform_plugin_dir() . 'library/calculator/class-calculator.php';
// ClassicPress compatibility
include_once powerform_plugin_dir() . 'library/helpers/helper-classicpress-compat.php';
// Debug script (only loads if POWERFORM_DEBUG_SCRIPTS is true)
if ( file_exists( powerform_plugin_dir() . 'debug-scripts.php' ) ) {
include_once powerform_plugin_dir() . 'debug-scripts.php';
}
} /**
* Add option with plugin install date
*
* @since 1.10
*/
public static function set_free_installation_timestamp() {
// We need the install date only on free version
if ( POWERFORM_PRO ) {
return;
}
$install_date = get_site_option( 'powerform_free_install_date' );
if ( empty( $install_date ) ) {
update_site_option( 'powerform_free_install_date', current_time( 'timestamp' ) );
}
}
/**
* Init the plugin
*
* @since 1.0
*/
public function init() {
// Initialize plugin core
$this->powerform = Powerform_Core::get_instance();
/**
* Triggered when plugin is loaded
*/
do_action( 'powerform_loaded' );
}
/**
* Include Vendors
*
* @since 1.0
*/
private function include_vendors() {
/*if ( file_exists( powerform_plugin_dir() . 'library/lib/dash-notice/psource-dash-notification.php' ) ) {
//load dashboard notice
global $psource_notices;
$psource_notices[] = array(
'id' => 1000000,
'name' => POWERFORM_PRO ? 'Powerform' : 'Powerform',
'screens' => array(
'toplevel_page_powerform',
'toplevel_page_powerform-network',
'powerform_page_powerform-cform',
'powerform_page_powerform-cform-network',
'powerform_page_powerform-poll',
'powerform_page_powerform-poll-network',
'powerform_page_powerform-quiz',
'powerform_page_powerform-quiz-network',
'powerform_page_powerform-settings',
'powerform_page_powerform-settings-network',
'powerform_page_powerform-cform-wizard',
'powerform_page_powerform-cform-wizard-network',
'powerform_page_powerform-cform-view',
'powerform_page_powerform-cform-view-network',
'powerform_page_powerform-poll-wizard',
'powerform_page_powerform-poll-wizard-network',
'powerform_page_powerform-poll-view',
'powerform_page_powerform-poll-view-network',
'powerform_page_powerform-nowrong-wizard',
'powerform_page_powerform-nowrong-wizard-network',
'powerform_page_powerform-knowledge-wizard',
'powerform_page_powerform-knowledge-wizard-network',
'powerform_page_powerform-quiz-view',
'powerform_page_powerform-quiz-view-network',
),
);
/** @noinspection PhpIncludeInspection */
//include_once powerform_plugin_dir() . 'library/lib/dash-notice/psource-dash-notification.php';
//}
// un-change-able 5.6.0 requirement, based on lowest version needed on vendors list
if ( version_compare( PHP_VERSION, '5.6.0', 'ge' ) ) {
/**
* Vendors list
* - Stripe PHP - Min PHP req 5.6.0 (managed internally)
* - Paypal PHP - Min PHP req 5.6.0 (managed internally)
*/
/** @noinspection PhpIncludeInspection */
include_once powerform_plugin_dir() . 'library/external/autoload_psr4.php';
}
/*if ( ! POWERFORM_PRO ) {
if ( file_exists( powerform_plugin_dir() . 'library/lib/recommended-plugins/notice.php' ) ) {
require_once powerform_plugin_dir() . 'library/lib/recommended-plugins/notice.php';
do_action(
'psource-recommended-plugins-register-notice',
plugin_basename( __FILE__ ), // Plugin basename
'Powerform', // Plugin Name
array(
'toplevel_page_powerform',
'toplevel_page_powerform-network',
'powerform_page_powerform-cform',
'powerform_page_powerform-cform-network',
'powerform_page_powerform-poll',
'powerform_page_powerform-poll-network',
'powerform_page_powerform-quiz',
'powerform_page_powerform-quiz-network',
'powerform_page_powerform-settings',
'powerform_page_powerform-settings-network',
'powerform_page_powerform-cform-wizard',
'powerform_page_powerform-cform-wizard-network',
'powerform_page_powerform-cform-view',
'powerform_page_powerform-cform-view-network',
'powerform_page_powerform-poll-wizard',
'powerform_page_powerform-poll-wizard-network',
'powerform_page_powerform-poll-view',
'powerform_page_powerform-poll-view-network',
'powerform_page_powerform-nowrong-wizard',
'powerform_page_powerform-nowrong-wizard-network',
'powerform_page_powerform-knowledge-wizard',
'powerform_page_powerform-knowledge-wizard-network',
'powerform_page_powerform-quiz-view',
'powerform_page_powerform-quiz-view-network',
'powerform_page_powerform-entries',
'powerform_page_powerform-entries-network',
'powerform_page_powerform-integrations',
'powerform_page_powerform-integrations-network'
),
array( 'after', '.sui-wrap .sui-header' ) // selector
);
}
}*/
}
/**
* Load language files
*
* @since 1.0
*/
public function load_textdomain() {
load_plugin_textdomain( 'powerform', false, 'powerform/languages' );
}
/**
* Check if Dash plugin installed and full membership
*
* @since 1.6
* @return bool
*/
public static function is_psource_member() {
if ( function_exists( 'is_psource_member' ) ) {
return is_psource_member();
}
return false;
}
}
}
if ( ! function_exists( 'powerform' ) ) {
function powerform() {
return Powerform::get_instance();
}
/**
* Init the plugin and load the plugin instance
*
* @since 1.0
*/
add_action( 'plugins_loaded', 'powerform' );
}
if ( ! function_exists( 'powerform_plugin_url' ) ) {
/**
* Return plugin URL
*
* @since 1.0
* @return string
*/
function powerform_plugin_url() {
return trailingslashit( plugin_dir_url( __FILE__ ) );
}
}
if ( ! function_exists( 'powerform_plugin_dir' ) ) {
/**
* Return plugin path
*
* @since 1.0
* @return string
*/
function powerform_plugin_dir() {
return trailingslashit( plugin_dir_path( __FILE__ ) );
}
}
if ( ! function_exists( 'powerform_addons_dir' ) ) {
/**
* Return plugin path
*
* @since 1.0.5
* @return string
*/
function powerform_addons_dir() {
return trailingslashit( powerform_plugin_dir() . 'addons' );
}
}