1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Registers a lightbox provider. |
5
|
|
|
* |
6
|
|
|
* @internal Currently internal; not ready for public usage. |
7
|
|
|
*/ |
8
|
|
|
abstract class GravityView_Lightbox_Provider { |
9
|
|
|
|
10
|
|
|
public static $slug; |
11
|
|
|
|
12
|
|
|
public static $script_slug; |
13
|
|
|
|
14
|
|
|
public static $style_slug; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Adds actions and that modify GravityView to use this lightbox provider |
18
|
|
|
*/ |
19
|
|
|
public function add_hooks() { |
20
|
|
|
add_filter( 'gravityview_lightbox_script', array( $this, 'filter_lightbox_script' ), 1000 ); |
21
|
|
|
add_filter( 'gravityview_lightbox_style', array( $this, 'filter_lightbox_style' ), 1000 ); |
22
|
|
|
|
23
|
|
|
add_filter( 'gravityview/fields/fileupload/link_atts', array( $this, 'fileupload_link_atts' ), 10, 3 ); |
24
|
|
|
add_filter( 'gravityview/get_link/allowed_atts', array( $this, 'allowed_atts' ) ); |
25
|
|
|
|
26
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts') ); |
27
|
|
|
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles') ); |
28
|
|
|
|
29
|
|
|
add_action( 'wp_footer', array( $this, 'output_footer' ) ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Removes actions that were added by {@see GravityView_Lightbox_Provider::add_hooks} |
34
|
|
|
* @internal Do not call directly. Instead, use: |
35
|
|
|
* |
36
|
|
|
* <code> |
37
|
|
|
* do_action( 'gravityview/lightbox/provider', 'slug' ); |
38
|
|
|
* </code> |
39
|
|
|
*/ |
40
|
|
|
public function remove_hooks() { |
41
|
|
|
remove_filter( 'gravityview_lightbox_script', array( $this, 'filter_lightbox_script' ), 1000 ); |
42
|
|
|
remove_filter( 'gravityview_lightbox_style', array( $this, 'filter_lightbox_style' ), 1000 ); |
43
|
|
|
|
44
|
|
|
remove_filter( 'gravityview/fields/fileupload/link_atts', array( $this, 'fileupload_link_atts' ), 10 ); |
45
|
|
|
remove_filter( 'gravityview/get_link/allowed_atts', array( $this, 'allowed_atts' ) ); |
46
|
|
|
|
47
|
|
|
remove_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts') ); |
48
|
|
|
remove_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles') ); |
49
|
|
|
|
50
|
|
|
remove_action( 'wp_footer', array( $this, 'output_footer' ) ); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Modifies the name of the stylesheet to be enqueued when loading thickbox |
55
|
|
|
* |
56
|
|
|
* @param string $script |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function filter_lightbox_script( $script = 'thickbox' ) { |
|
|
|
|
61
|
|
|
return static::$script_slug; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Modifies the name of the stylesheet to be enqueued when loading thickbox |
66
|
|
|
* |
67
|
|
|
* @param string $style |
68
|
|
|
* |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function filter_lightbox_style( $style = 'thickbox' ) { |
|
|
|
|
72
|
|
|
return static::$style_slug; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get default settings for the script |
77
|
|
|
* |
78
|
|
|
* @return array |
79
|
|
|
*/ |
80
|
|
|
protected function default_settings() { |
81
|
|
|
return array(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get the settings for the JavaScript, with filter applied |
86
|
|
|
* |
87
|
|
|
* @internal |
88
|
|
|
* |
89
|
|
|
* @return mixed|void |
90
|
|
|
*/ |
91
|
|
|
protected function get_settings() { |
92
|
|
|
|
93
|
|
|
$settings = static::default_settings(); |
94
|
|
|
|
95
|
|
|
return apply_filters( 'gravityview/lightbox/provider/' . self::$slug . '/settings', $settings ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Output raw HTML in the wp_footer() |
100
|
|
|
* |
101
|
|
|
* @internal |
102
|
|
|
*/ |
103
|
|
|
public function output_footer() {} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Enqueue scripts for the lightbox |
107
|
|
|
* |
108
|
|
|
* @internal |
109
|
|
|
*/ |
110
|
|
|
public function enqueue_scripts() {} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Enqueue styles for the lightbox |
114
|
|
|
* |
115
|
|
|
* @internal |
116
|
|
|
*/ |
117
|
|
|
public function enqueue_styles() {} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Modify the attributes allowed in an anchor tag generated by GravityView |
121
|
|
|
* |
122
|
|
|
* @internal |
123
|
|
|
* |
124
|
|
|
* @param array $atts Attributes allowed in an anchor <a> tag. |
125
|
|
|
* |
126
|
|
|
* @return array |
127
|
|
|
*/ |
128
|
|
|
public function allowed_atts( $atts = array() ) { |
129
|
|
|
return $atts; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Modified File Upload field links to use lightbox |
134
|
|
|
* |
135
|
|
|
* @internal |
136
|
|
|
* |
137
|
|
|
* @param array|string $link_atts Array or attributes string. |
138
|
|
|
* @param array $field_compat Current GravityView field. |
139
|
|
|
* @param \GV\Template_Context|null $context The context. |
140
|
|
|
* |
141
|
|
|
* @return mixed |
142
|
|
|
*/ |
143
|
|
|
public function fileupload_link_atts( $link_atts, $field_compat = array(), $context = null ) { |
|
|
|
|
144
|
|
|
return $link_atts; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.