-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathGravityForms.php
More file actions
80 lines (69 loc) · 1.82 KB
/
GravityForms.php
File metadata and controls
80 lines (69 loc) · 1.82 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
<?php
declare(strict_types=1);
namespace Imagify\ThirdParty\Plugins;
use GFForms;
use Imagify\EventManagement\SubscriberInterface;
/**
* Subscriber for compatibility with GravityForms
*/
class GravityForms implements SubscriberInterface {
/**
* Returns an array of events that this subscriber wants to listen to.
*
* @return array
*/
public static function get_subscribed_events(): array {
if ( ! class_exists( 'GFCommon' ) ) {
return [];
}
return [
// @filter
'gform_noconflict_styles' => 'imagify_gf_noconflict_styles',
// @filter
'gform_noconflict_scripts' => 'imagify_gf_noconflict_scripts',
];
}
/**
* Register imagify styles to gravity forms conflict styles
*
* @param array $styles Array fo registered styles.
*
* @return array
*/
public function imagify_gf_noconflict_styles( $styles ): array {
if ( ! $this->is_gravity_forms_no_conflict_mode_enabled() ) {
return $styles;
}
$styles[] = 'imagify-admin-bar';
$styles[] = 'imagify-admin';
$styles[] = 'imagify-notices';
$styles[] = 'imagify-pricing-modal';
return $styles;
}
/**
* Register Imagify scripts to gravity forms conflict scripts
*
* @param array $scripts Array fo registered scripts.
*
* @return array
*/
public function imagify_gf_noconflict_scripts( $scripts ): array {
if ( ! $this->is_gravity_forms_no_conflict_mode_enabled() ) {
return $scripts;
}
$scripts[] = 'imagify-admin-bar';
$scripts[] = 'imagify-sweetalert';
$scripts[] = 'imagify-admin';
$scripts[] = 'imagify-notices';
$scripts[] = 'imagify-pricing-modal';
return $scripts;
}
/**
* Check if gravity form is active and no_conflict mode is enabled.
*
* @return bool
*/
private function is_gravity_forms_no_conflict_mode_enabled(): bool {
return (bool) get_option( 'gform_enable_noconflict', false );
}
}