Completed
Pull Request — develop (#1713)
by Zack
17:42
created
future/includes/class-gv-collection-entry-offset.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,24 +14,24 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Entry_Offset
16 16
 {
17
-    /** @var int The offset. */
18
-    public $offset = 0;
17
+	/** @var int The offset. */
18
+	public $offset = 0;
19 19
 
20
-    /** @var int The limit. */
21
-    public $limit = 20;
20
+	/** @var int The limit. */
21
+	public $limit = 20;
22 22
 
23
-    /**
24
-     * Return a search_criteria format for this offset.
25
-     *
26
-     * @param int $page The page. Default: 1
27
-     *
28
-     * @return array ['page_size' => N, 'offset' => N]
29
-     */
30
-    public function to_paging($page = 1)
31
-    {
32
-        return [
33
-            'page_size' => $this->limit,
34
-            'offset'    => (($page - 1) * $this->limit) + $this->offset,
35
-        ];
36
-    }
23
+	/**
24
+	 * Return a search_criteria format for this offset.
25
+	 *
26
+	 * @param int $page The page. Default: 1
27
+	 *
28
+	 * @return array ['page_size' => N, 'offset' => N]
29
+	 */
30
+	public function to_paging($page = 1)
31
+	{
32
+		return [
33
+			'page_size' => $this->limit,
34
+			'offset'    => (($page - 1) * $this->limit) + $this->offset,
35
+		];
36
+	}
37 37
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return array ['page_size' => N, 'offset' => N]
29 29
      */
30
-    public function to_paging($page = 1)
30
+    public function to_paging( $page = 1 )
31 31
     {
32 32
         return [
33 33
             'page_size' => $this->limit,
34
-            'offset'    => (($page - 1) * $this->limit) + $this->offset,
34
+            'offset'    => ( ( $page - 1 ) * $this->limit ) + $this->offset,
35 35
         ];
36 36
     }
37 37
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * Offset and limit, pagination.
14 14
  */
15
-class Entry_Offset
16
-{
15
+class Entry_Offset {
17 16
     /** @var int The offset. */
18 17
     public $offset = 0;
19 18
 
@@ -27,8 +26,7 @@  discard block
 block discarded – undo
27 26
      *
28 27
      * @return array ['page_size' => N, 'offset' => N]
29 28
      */
30
-    public function to_paging($page = 1)
31
-    {
29
+    public function to_paging($page = 1) {
32 30
         return [
33 31
             'page_size' => $this->limit,
34 32
             'offset'    => (($page - 1) * $this->limit) + $this->offset,
Please login to merge, or discard this patch.
future/includes/class-gv-collection.php 3 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -12,110 +12,110 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Collection
14 14
 {
15
-    /**
16
-     * @var array Main storage for objects in this collection.
17
-     */
18
-    private $storage = [];
15
+	/**
16
+	 * @var array Main storage for objects in this collection.
17
+	 */
18
+	private $storage = [];
19 19
 
20
-    /**
21
-     * Add an object to this collection.
22
-     *
23
-     * @param mixed $value The object to be added.
24
-     *
25
-     * @api
26
-     *
27
-     * @since 2.0
28
-     *
29
-     * @return void
30
-     */
31
-    public function add($value)
32
-    {
33
-        $this->storage[] = $value;
34
-    }
20
+	/**
21
+	 * Add an object to this collection.
22
+	 *
23
+	 * @param mixed $value The object to be added.
24
+	 *
25
+	 * @api
26
+	 *
27
+	 * @since 2.0
28
+	 *
29
+	 * @return void
30
+	 */
31
+	public function add($value)
32
+	{
33
+		$this->storage[] = $value;
34
+	}
35 35
 
36
-    /**
37
-     * Clear this collection.
38
-     *
39
-     * @api
40
-     *
41
-     * @since 2.0
42
-     *
43
-     * @return void
44
-     */
45
-    public function clear()
46
-    {
47
-        $this->count() && ($this->storage = []);
48
-    }
36
+	/**
37
+	 * Clear this collection.
38
+	 *
39
+	 * @api
40
+	 *
41
+	 * @since 2.0
42
+	 *
43
+	 * @return void
44
+	 */
45
+	public function clear()
46
+	{
47
+		$this->count() && ($this->storage = []);
48
+	}
49 49
 
50
-    /**
51
-     * Merge another collection into here.
52
-     *
53
-     * @param \GV\Collection $collection The collection to be merged.
54
-     *
55
-     * @api
56
-     *
57
-     * @since 2.0
58
-     *
59
-     * @return void
60
-     */
61
-    public function merge(\GV\Collection $collection)
62
-    {
63
-        array_map([$this, 'add'], $collection->all());
64
-    }
50
+	/**
51
+	 * Merge another collection into here.
52
+	 *
53
+	 * @param \GV\Collection $collection The collection to be merged.
54
+	 *
55
+	 * @api
56
+	 *
57
+	 * @since 2.0
58
+	 *
59
+	 * @return void
60
+	 */
61
+	public function merge(\GV\Collection $collection)
62
+	{
63
+		array_map([$this, 'add'], $collection->all());
64
+	}
65 65
 
66
-    /**
67
-     * Returns all the objects in this collection as an an array.
68
-     *
69
-     * @api
70
-     *
71
-     * @since 2.0
72
-     *
73
-     * @return array The objects in this collection.
74
-     */
75
-    public function all()
76
-    {
77
-        return $this->storage;
78
-    }
66
+	/**
67
+	 * Returns all the objects in this collection as an an array.
68
+	 *
69
+	 * @api
70
+	 *
71
+	 * @since 2.0
72
+	 *
73
+	 * @return array The objects in this collection.
74
+	 */
75
+	public function all()
76
+	{
77
+		return $this->storage;
78
+	}
79 79
 
80
-    /**
81
-     * Get the last added object.
82
-     *
83
-     * @api
84
-     *
85
-     * @since 2.0
86
-     *
87
-     * @return mixed|null The last item in here, or null if there are none.
88
-     */
89
-    public function last()
90
-    {
91
-        return end($this->storage);
92
-    }
80
+	/**
81
+	 * Get the last added object.
82
+	 *
83
+	 * @api
84
+	 *
85
+	 * @since 2.0
86
+	 *
87
+	 * @return mixed|null The last item in here, or null if there are none.
88
+	 */
89
+	public function last()
90
+	{
91
+		return end($this->storage);
92
+	}
93 93
 
94
-    /**
95
-     * Get the first added object.
96
-     *
97
-     * @api
98
-     *
99
-     * @since 2.0
100
-     *
101
-     * @return mixed|null The first item in here, or null if there are none.
102
-     */
103
-    public function first()
104
-    {
105
-        return reset($this->storage);
106
-    }
94
+	/**
95
+	 * Get the first added object.
96
+	 *
97
+	 * @api
98
+	 *
99
+	 * @since 2.0
100
+	 *
101
+	 * @return mixed|null The first item in here, or null if there are none.
102
+	 */
103
+	public function first()
104
+	{
105
+		return reset($this->storage);
106
+	}
107 107
 
108
-    /**
109
-     * Returns the count of the objects in this collection.
110
-     *
111
-     * @api
112
-     *
113
-     * @since 2.0
114
-     *
115
-     * @return int The size of this collection.
116
-     */
117
-    public function count()
118
-    {
119
-        return count($this->storage);
120
-    }
108
+	/**
109
+	 * Returns the count of the objects in this collection.
110
+	 *
111
+	 * @api
112
+	 *
113
+	 * @since 2.0
114
+	 *
115
+	 * @return int The size of this collection.
116
+	 */
117
+	public function count()
118
+	{
119
+		return count($this->storage);
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @var array Main storage for objects in this collection.
17 17
      */
18
-    private $storage = [];
18
+    private $storage = [ ];
19 19
 
20 20
     /**
21 21
      * Add an object to this collection.
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return void
30 30
      */
31
-    public function add($value)
31
+    public function add( $value )
32 32
     {
33
-        $this->storage[] = $value;
33
+        $this->storage[ ] = $value;
34 34
     }
35 35
 
36 36
     /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function clear()
46 46
     {
47
-        $this->count() && ($this->storage = []);
47
+        $this->count() && ( $this->storage = [ ] );
48 48
     }
49 49
 
50 50
     /**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return void
60 60
      */
61
-    public function merge(\GV\Collection $collection)
61
+    public function merge( \GV\Collection $collection )
62 62
     {
63
-        array_map([$this, 'add'], $collection->all());
63
+        array_map( [ $this, 'add' ], $collection->all() );
64 64
     }
65 65
 
66 66
     /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function last()
90 90
     {
91
-        return end($this->storage);
91
+        return end( $this->storage );
92 92
     }
93 93
 
94 94
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function first()
104 104
     {
105
-        return reset($this->storage);
105
+        return reset( $this->storage );
106 106
     }
107 107
 
108 108
     /**
@@ -116,6 +116,6 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function count()
118 118
     {
119
-        return count($this->storage);
119
+        return count( $this->storage );
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
 /**
11 11
  * A generic Collection base class.
12 12
  */
13
-class Collection
14
-{
13
+class Collection {
15 14
     /**
16 15
      * @var array Main storage for objects in this collection.
17 16
      */
@@ -28,8 +27,7 @@  discard block
 block discarded – undo
28 27
      *
29 28
      * @return void
30 29
      */
31
-    public function add($value)
32
-    {
30
+    public function add($value) {
33 31
         $this->storage[] = $value;
34 32
     }
35 33
 
@@ -42,8 +40,7 @@  discard block
 block discarded – undo
42 40
      *
43 41
      * @return void
44 42
      */
45
-    public function clear()
46
-    {
43
+    public function clear() {
47 44
         $this->count() && ($this->storage = []);
48 45
     }
49 46
 
@@ -58,8 +55,7 @@  discard block
 block discarded – undo
58 55
      *
59 56
      * @return void
60 57
      */
61
-    public function merge(\GV\Collection $collection)
62
-    {
58
+    public function merge(\GV\Collection $collection) {
63 59
         array_map([$this, 'add'], $collection->all());
64 60
     }
65 61
 
@@ -72,8 +68,7 @@  discard block
 block discarded – undo
72 68
      *
73 69
      * @return array The objects in this collection.
74 70
      */
75
-    public function all()
76
-    {
71
+    public function all() {
77 72
         return $this->storage;
78 73
     }
79 74
 
@@ -86,8 +81,7 @@  discard block
 block discarded – undo
86 81
      *
87 82
      * @return mixed|null The last item in here, or null if there are none.
88 83
      */
89
-    public function last()
90
-    {
84
+    public function last() {
91 85
         return end($this->storage);
92 86
     }
93 87
 
@@ -100,8 +94,7 @@  discard block
 block discarded – undo
100 94
      *
101 95
      * @return mixed|null The first item in here, or null if there are none.
102 96
      */
103
-    public function first()
104
-    {
97
+    public function first() {
105 98
         return reset($this->storage);
106 99
     }
107 100
 
@@ -114,8 +107,7 @@  discard block
 block discarded – undo
114 107
      *
115 108
      * @return int The size of this collection.
116 109
      */
117
-    public function count()
118
-    {
110
+    public function count() {
119 111
         return count($this->storage);
120 112
     }
121 113
 }
Please login to merge, or discard this patch.
future/includes/class-gv-extension.php 3 patches
Indentation   +388 added lines, -388 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,391 +14,391 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class Extension
16 16
 {
17
-    /**
18
-     * @var string Name of the plugin in gravityview.co
19
-     */
20
-    protected $_title = null;
21
-
22
-    /**
23
-     * @var string Version number of the plugin
24
-     */
25
-    protected $_version = null;
26
-
27
-    /**
28
-     * @var int The ID of the download on gravityview.co
29
-     *
30
-     * @since 1.1
31
-     */
32
-    protected $_item_id = null;
33
-
34
-    /**
35
-     * @var string Translation textdomain
36
-     */
37
-    protected $_text_domain = 'gravityview';
38
-
39
-    /**
40
-     * @var string Minimum version of GravityView the Extension requires
41
-     */
42
-    protected $_min_gravityview_version = '2.0-dev';
43
-
44
-    /**
45
-     * @var string Maximum version of GravityView the Extension requires, if any
46
-     */
47
-    protected $_max_gravityview_version = null;
48
-
49
-    /**
50
-     * @var string Minimum version of GravityView the Extension requires
51
-     */
52
-    protected $_min_php_version = '5.3';
53
-
54
-    /**
55
-     * @var string The URL to fetch license info from. Do not change unless you know what you're doing.
56
-     */
57
-    protected $_remote_update_url = 'https://gravityview.co';
58
-
59
-    /**
60
-     * @var string Author of plugin, sent when fetching license info.
61
-     */
62
-    protected $_author = 'Katz Web Services, Inc.';
63
-
64
-    /**
65
-     * @var string The path to the extension.
66
-     */
67
-    protected $_path = '';
68
-
69
-    /**
70
-     * @var array Admin notices to display
71
-     */
72
-    protected static $admin_notices = [];
73
-
74
-    /**
75
-     * @var bool[] An array of extension compatibility.
76
-     *
77
-     * @since 2.0 This is an array of classes instead.
78
-     */
79
-    public static $is_compatible = [];
80
-
81
-    /**
82
-     * Generic initialization.
83
-     */
84
-    public function __construct()
85
-    {
86
-        if (false === $this->is_extension_supported()) {
87
-            return;
88
-        }
89
-
90
-        if (!$this->_path) {
91
-            $this->_path = __FILE__;
92
-        }
93
-
94
-        add_action('init', [$this, 'load_plugin_textdomain']);
95
-
96
-        add_action('admin_init', [$this, 'settings']);
97
-
98
-        add_action('admin_notices', [$this, 'admin_notice'], 100);
99
-
100
-        // Save the view configuration. Run at 14 so that View metadata is already saved (at 10)
101
-        add_action('save_post', [$this, 'save_post'], 14);
102
-
103
-        add_action('gravityview/metaboxes/before_render', [$this, 'add_metabox_tab']);
104
-
105
-        add_filter('gravityview/metaboxes/tooltips', [$this, 'tooltips']);
106
-
107
-        $this->add_hooks();
108
-    }
109
-
110
-    /**
111
-     * Extensions should override this hook to add their hooks.
112
-     *
113
-     * @return void
114
-     */
115
-    public function add_hooks()
116
-    {
117
-    }
118
-
119
-    /**
120
-     * Save extra view configuration.
121
-     *
122
-     * @param int $post_id Post ID
123
-     *
124
-     * @return void
125
-     */
126
-    public function save_post($post_id)
127
-    {
128
-    }
129
-
130
-    /**
131
-     * Add tooltips for the extension.
132
-     *
133
-     * Add a tooltip with an array using the `title` and `value` keys. The `title` key is the H6 tag value of the tooltip; it's the headline. The `value` is the tooltip content, and can contain any HTML.
134
-     *
135
-     * The tooltip key must be `gv_{name_of_setting}`. If the name of the setting is "example_extension_setting", the code would be:
136
-     *
137
-     * <code>
138
-     * $tooltips['gv_example_extension_setting'] = array(
139
-     * 	'title'	=> 'About Example Extension Setting',
140
-     *  'value'	=> 'When you do [x] with [y], [z] happens.'
141
-     * );
142
-     * </code>
143
-     *
144
-     * @param array $tooltips Existing GV tooltips, with `title` and `value` keys
145
-     *
146
-     * @return array Modified tooltips
147
-     */
148
-    public function tooltips($tooltips = [])
149
-    {
150
-        return $tooltips;
151
-    }
152
-
153
-    /**
154
-     * Add a tab to GravityView Edit View tabbed metabox. By overriding this method, you will add a tab to View settings.
155
-     *
156
-     * @since 1.8 (Extension version 1.0.7)
157
-     * @see https://gist.github.com/zackkatz/6cc381bcf54849f2ed41 For example of adding a metabox
158
-     *
159
-     * @return array Array of metabox
160
-     */
161
-    protected function tab_settings()
162
-    {
163
-        // When overriding, return array with expected keys
164
-        return [];
165
-    }
166
-
167
-    /**
168
-     * If Extension overrides tab_settings() and passes its own tab, add it to the tabbed settings metabox.
169
-     *
170
-     * @since 1.8 (Extension version 1.0.7)
171
-     *
172
-     * @return void
173
-     */
174
-    public function add_metabox_tab()
175
-    {
176
-        $tab_settings = $this->tab_settings();
177
-
178
-        // Don't add a tab if it's empty.
179
-        if (empty($tab_settings)) {
180
-            return;
181
-        }
182
-
183
-        $tab_defaults = [
184
-            'id'            => '',
185
-            'title'         => '',
186
-            'callback'      => '',
187
-            'icon-class'    => '',
188
-            'file'          => '',
189
-            'callback_args' => '',
190
-            'context'       => 'side',
191
-            'priority'      => 'default',
192
-        ];
193
-
194
-        $tab = wp_parse_args($tab_settings, $tab_defaults);
195
-
196
-        // Force the screen to be GravityView
197
-        $tab['screen'] = 'gravityview';
198
-
199
-        if (class_exists('GravityView_Metabox_Tab')) {
200
-            $metabox = new \GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']);
201
-            \GravityView_Metabox_Tabs::add($metabox);
202
-        } else {
203
-            add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']);
204
-        }
205
-    }
206
-
207
-    /**
208
-     * Is this extension even compatible?
209
-     *
210
-     * @return bool|null Is or is not. Null if unknown yet.
211
-     */
212
-    public static function is_compatible()
213
-    {
214
-        return Utils::get(self::$is_compatible, get_called_class(), null);
215
-    }
216
-
217
-    /**
218
-     * Check whether the extension is supported:.
219
-     *
220
-     * - Checks if GravityView and Gravity Forms exist
221
-     * - Checks GravityView and Gravity Forms version numbers
222
-     * - Checks PHP version numbers
223
-     * - Sets self::$is_compatible[__CLASS__] to boolean value
224
-     *
225
-     * @return bool Is the extension supported?
226
-     */
227
-    protected function is_extension_supported()
228
-    {
229
-        self::$is_compatible = is_array(self::$is_compatible) ? self::$is_compatible : [get_called_class() => (bool) self::$is_compatible];
230
-
231
-        if (!function_exists('gravityview')) {
232
-            $message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), esc_html($this->_title));
233
-        } elseif (false === version_compare(Plugin::$version, $this->_min_gravityview_version, '>=')) {
234
-            $message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_gravityview_version.'</tt>');
235
-        } elseif (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, '>=')) {
236
-            $message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_php_version.'</tt>');
237
-        } elseif (!empty($this->_max_gravityview_version) && false === version_compare($this->_max_gravityview_version, Plugin::$version, '>')) {
238
-            $message = sprintf(__('The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview'), esc_html($this->_title));
239
-        } else {
240
-            $message = '';
241
-            self::$is_compatible[get_called_class()] = gravityview()->plugin->is_compatible();
242
-        }
243
-
244
-        if (!empty($message)) {
245
-            self::add_notice($message);
246
-            self::$is_compatible[get_called_class()] = false;
247
-            gravityview()->log->error('{message}', ['message' => $message]);
248
-        }
249
-
250
-        return self::is_compatible();
251
-    }
252
-
253
-    /**
254
-     * Load translations for the extension.
255
-     *
256
-     * 1. Check  `wp-content/languages/gravityview/` folder and load using `load_textdomain()`
257
-     * 2. Check  `wp-content/plugins/gravityview/languages/` folder for `gravityview-[locale].mo` file and load using `load_textdomain()`
258
-     * 3. Load default file using `load_plugin_textdomain()` from `wp-content/plugins/gravityview/languages/`
259
-     *
260
-     * @return void
261
-     */
262
-    public function load_plugin_textdomain()
263
-    {
264
-        if (empty($this->_text_domain)) {
265
-            gravityview()->log->debug('Extension translation cannot be loaded; the `_text_domain` variable is not defined', ['data' => $this]);
266
-
267
-            return;
268
-        }
269
-
270
-        // Backward compat for Ratings & Reviews / Maps
271
-        $path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : '');
272
-
273
-        // Set filter for plugin's languages directory
274
-        $lang_dir = dirname(plugin_basename($path)).'/languages/';
275
-
276
-        $locale = get_locale();
277
-
278
-        if (function_exists('get_user_locale') && is_admin()) {
279
-            $locale = get_user_locale();
280
-        }
281
-
282
-        // Traditional WordPress plugin locale filter
283
-        $locale = apply_filters('plugin_locale', $locale, $this->_text_domain);
284
-
285
-        $mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale);
286
-
287
-        // Setup paths to current locale file
288
-        $mofile_local = $lang_dir.$mofile;
289
-        $mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile;
290
-
291
-        if (file_exists($mofile_global)) {
292
-            // Look in global /wp-content/languages/[plugin-dir]/ folder
293
-            load_textdomain($this->_text_domain, $mofile_global);
294
-        } elseif (file_exists($mofile_local)) {
295
-            // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
296
-            load_textdomain($this->_text_domain, $mofile_local);
297
-        } else {
298
-            // Load the default language files
299
-            load_plugin_textdomain($this->_text_domain, false, $lang_dir);
300
-        }
301
-    }
302
-
303
-    /**
304
-     * Register the updater for the Extension using GravityView license information.
305
-     *
306
-     * @return void
307
-     */
308
-    public function settings()
309
-    {
310
-
311
-        // If doing ajax, get outta here.
312
-        if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX && 'update-plugin' !== Utils::_POST('action'))) {
313
-            return;
314
-        }
315
-
316
-        // To support auto-updates, this needs to run during the wp_version_check cron job for privileged users.
317
-        $doing_cron = defined('DOING_CRON') && DOING_CRON;
318
-        if (!current_user_can('manage_options') && !$doing_cron) {
319
-            return;
320
-        }
321
-
322
-        $license = $this->get_license();
323
-
324
-        if (!class_exists('\GV\EDD_SL_Plugin_Updater')) {
325
-            require_once gravityview()->plugin->dir('future/lib/EDD_SL_Plugin_Updater.php');
326
-        }
327
-
328
-        new EDD_SL_Plugin_Updater(
329
-            $this->_remote_update_url,
330
-            $this->_path,
331
-            [
332
-                'version'	    => $this->_version, // current version number
333
-                'license'	    => \GV\Utils::get($license, 'license_key', \GV\Utils::get($license, 'license', null)),
334
-                'item_id'     => $this->_item_id, // The ID of the download on _remote_update_url
335
-                'item_name'   => $this->_title,  // name of this plugin
336
-                'author' 	    => strip_tags($this->_author),  // author of this plugin
337
-                'php_version' => phpversion(),
338
-                'wp_version'  => get_bloginfo('version'),
339
-                'gv_version'  => \GV\Plugin::$version,
340
-                'environment' => function_exists('wp_get_environment_type') ? wp_get_environment_type() : 'production',
341
-            ]
342
-        );
343
-    }
344
-
345
-    /**
346
-     * Get license information from GravityView.
347
-     *
348
-     * @since 1.8 (Extension version 1.0.7)
349
-     *
350
-     * @return bool|array False: \GV\Addon_Settings class does not exist. Array: array of GV license data.
351
-     */
352
-    protected function get_license()
353
-    {
354
-        if (!class_exists('\GV\Addon_Settings')) {
355
-            return false;
356
-        }
357
-
358
-        return gravityview()->plugin->settings->get('license');
359
-    }
360
-
361
-    /**
362
-     * Add a notice to be displayed in the admin.
363
-     *
364
-     * @param array $notice Array with `class` and `message` keys. The message is not escaped.
365
-     *
366
-     * @return void
367
-     */
368
-    public static function add_notice($notice = [])
369
-    {
370
-        if (is_array($notice) && empty($notice['message'])) {
371
-            gravityview()->log->error('Notice not set', ['data' => $notice]);
372
-
373
-            return;
374
-        } elseif (is_string($notice)) {
375
-            $notice = ['message' => $notice];
376
-        }
377
-
378
-        $notice['class'] = empty($notice['class']) ? 'error' : $notice['class'];
379
-
380
-        self::$admin_notices[] = $notice;
381
-    }
382
-
383
-    /**
384
-     * Outputs the admin notices generated by the all plugins.
385
-     *
386
-     * @return void
387
-     */
388
-    public function admin_notice()
389
-    {
390
-        if (empty(self::$admin_notices)) {
391
-            return;
392
-        }
393
-
394
-        foreach (self::$admin_notices as $key => $notice) {
395
-            echo '<div id="message" class="'.esc_attr($notice['class']).'">';
396
-            echo wpautop($notice['message']);
397
-            echo '<div class="clear"></div>';
398
-            echo '</div>';
399
-        }
400
-
401
-        //reset the notices handler
402
-        self::$admin_notices = [];
403
-    }
17
+	/**
18
+	 * @var string Name of the plugin in gravityview.co
19
+	 */
20
+	protected $_title = null;
21
+
22
+	/**
23
+	 * @var string Version number of the plugin
24
+	 */
25
+	protected $_version = null;
26
+
27
+	/**
28
+	 * @var int The ID of the download on gravityview.co
29
+	 *
30
+	 * @since 1.1
31
+	 */
32
+	protected $_item_id = null;
33
+
34
+	/**
35
+	 * @var string Translation textdomain
36
+	 */
37
+	protected $_text_domain = 'gravityview';
38
+
39
+	/**
40
+	 * @var string Minimum version of GravityView the Extension requires
41
+	 */
42
+	protected $_min_gravityview_version = '2.0-dev';
43
+
44
+	/**
45
+	 * @var string Maximum version of GravityView the Extension requires, if any
46
+	 */
47
+	protected $_max_gravityview_version = null;
48
+
49
+	/**
50
+	 * @var string Minimum version of GravityView the Extension requires
51
+	 */
52
+	protected $_min_php_version = '5.3';
53
+
54
+	/**
55
+	 * @var string The URL to fetch license info from. Do not change unless you know what you're doing.
56
+	 */
57
+	protected $_remote_update_url = 'https://gravityview.co';
58
+
59
+	/**
60
+	 * @var string Author of plugin, sent when fetching license info.
61
+	 */
62
+	protected $_author = 'Katz Web Services, Inc.';
63
+
64
+	/**
65
+	 * @var string The path to the extension.
66
+	 */
67
+	protected $_path = '';
68
+
69
+	/**
70
+	 * @var array Admin notices to display
71
+	 */
72
+	protected static $admin_notices = [];
73
+
74
+	/**
75
+	 * @var bool[] An array of extension compatibility.
76
+	 *
77
+	 * @since 2.0 This is an array of classes instead.
78
+	 */
79
+	public static $is_compatible = [];
80
+
81
+	/**
82
+	 * Generic initialization.
83
+	 */
84
+	public function __construct()
85
+	{
86
+		if (false === $this->is_extension_supported()) {
87
+			return;
88
+		}
89
+
90
+		if (!$this->_path) {
91
+			$this->_path = __FILE__;
92
+		}
93
+
94
+		add_action('init', [$this, 'load_plugin_textdomain']);
95
+
96
+		add_action('admin_init', [$this, 'settings']);
97
+
98
+		add_action('admin_notices', [$this, 'admin_notice'], 100);
99
+
100
+		// Save the view configuration. Run at 14 so that View metadata is already saved (at 10)
101
+		add_action('save_post', [$this, 'save_post'], 14);
102
+
103
+		add_action('gravityview/metaboxes/before_render', [$this, 'add_metabox_tab']);
104
+
105
+		add_filter('gravityview/metaboxes/tooltips', [$this, 'tooltips']);
106
+
107
+		$this->add_hooks();
108
+	}
109
+
110
+	/**
111
+	 * Extensions should override this hook to add their hooks.
112
+	 *
113
+	 * @return void
114
+	 */
115
+	public function add_hooks()
116
+	{
117
+	}
118
+
119
+	/**
120
+	 * Save extra view configuration.
121
+	 *
122
+	 * @param int $post_id Post ID
123
+	 *
124
+	 * @return void
125
+	 */
126
+	public function save_post($post_id)
127
+	{
128
+	}
129
+
130
+	/**
131
+	 * Add tooltips for the extension.
132
+	 *
133
+	 * Add a tooltip with an array using the `title` and `value` keys. The `title` key is the H6 tag value of the tooltip; it's the headline. The `value` is the tooltip content, and can contain any HTML.
134
+	 *
135
+	 * The tooltip key must be `gv_{name_of_setting}`. If the name of the setting is "example_extension_setting", the code would be:
136
+	 *
137
+	 * <code>
138
+	 * $tooltips['gv_example_extension_setting'] = array(
139
+	 * 	'title'	=> 'About Example Extension Setting',
140
+	 *  'value'	=> 'When you do [x] with [y], [z] happens.'
141
+	 * );
142
+	 * </code>
143
+	 *
144
+	 * @param array $tooltips Existing GV tooltips, with `title` and `value` keys
145
+	 *
146
+	 * @return array Modified tooltips
147
+	 */
148
+	public function tooltips($tooltips = [])
149
+	{
150
+		return $tooltips;
151
+	}
152
+
153
+	/**
154
+	 * Add a tab to GravityView Edit View tabbed metabox. By overriding this method, you will add a tab to View settings.
155
+	 *
156
+	 * @since 1.8 (Extension version 1.0.7)
157
+	 * @see https://gist.github.com/zackkatz/6cc381bcf54849f2ed41 For example of adding a metabox
158
+	 *
159
+	 * @return array Array of metabox
160
+	 */
161
+	protected function tab_settings()
162
+	{
163
+		// When overriding, return array with expected keys
164
+		return [];
165
+	}
166
+
167
+	/**
168
+	 * If Extension overrides tab_settings() and passes its own tab, add it to the tabbed settings metabox.
169
+	 *
170
+	 * @since 1.8 (Extension version 1.0.7)
171
+	 *
172
+	 * @return void
173
+	 */
174
+	public function add_metabox_tab()
175
+	{
176
+		$tab_settings = $this->tab_settings();
177
+
178
+		// Don't add a tab if it's empty.
179
+		if (empty($tab_settings)) {
180
+			return;
181
+		}
182
+
183
+		$tab_defaults = [
184
+			'id'            => '',
185
+			'title'         => '',
186
+			'callback'      => '',
187
+			'icon-class'    => '',
188
+			'file'          => '',
189
+			'callback_args' => '',
190
+			'context'       => 'side',
191
+			'priority'      => 'default',
192
+		];
193
+
194
+		$tab = wp_parse_args($tab_settings, $tab_defaults);
195
+
196
+		// Force the screen to be GravityView
197
+		$tab['screen'] = 'gravityview';
198
+
199
+		if (class_exists('GravityView_Metabox_Tab')) {
200
+			$metabox = new \GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']);
201
+			\GravityView_Metabox_Tabs::add($metabox);
202
+		} else {
203
+			add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']);
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * Is this extension even compatible?
209
+	 *
210
+	 * @return bool|null Is or is not. Null if unknown yet.
211
+	 */
212
+	public static function is_compatible()
213
+	{
214
+		return Utils::get(self::$is_compatible, get_called_class(), null);
215
+	}
216
+
217
+	/**
218
+	 * Check whether the extension is supported:.
219
+	 *
220
+	 * - Checks if GravityView and Gravity Forms exist
221
+	 * - Checks GravityView and Gravity Forms version numbers
222
+	 * - Checks PHP version numbers
223
+	 * - Sets self::$is_compatible[__CLASS__] to boolean value
224
+	 *
225
+	 * @return bool Is the extension supported?
226
+	 */
227
+	protected function is_extension_supported()
228
+	{
229
+		self::$is_compatible = is_array(self::$is_compatible) ? self::$is_compatible : [get_called_class() => (bool) self::$is_compatible];
230
+
231
+		if (!function_exists('gravityview')) {
232
+			$message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), esc_html($this->_title));
233
+		} elseif (false === version_compare(Plugin::$version, $this->_min_gravityview_version, '>=')) {
234
+			$message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_gravityview_version.'</tt>');
235
+		} elseif (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, '>=')) {
236
+			$message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_php_version.'</tt>');
237
+		} elseif (!empty($this->_max_gravityview_version) && false === version_compare($this->_max_gravityview_version, Plugin::$version, '>')) {
238
+			$message = sprintf(__('The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview'), esc_html($this->_title));
239
+		} else {
240
+			$message = '';
241
+			self::$is_compatible[get_called_class()] = gravityview()->plugin->is_compatible();
242
+		}
243
+
244
+		if (!empty($message)) {
245
+			self::add_notice($message);
246
+			self::$is_compatible[get_called_class()] = false;
247
+			gravityview()->log->error('{message}', ['message' => $message]);
248
+		}
249
+
250
+		return self::is_compatible();
251
+	}
252
+
253
+	/**
254
+	 * Load translations for the extension.
255
+	 *
256
+	 * 1. Check  `wp-content/languages/gravityview/` folder and load using `load_textdomain()`
257
+	 * 2. Check  `wp-content/plugins/gravityview/languages/` folder for `gravityview-[locale].mo` file and load using `load_textdomain()`
258
+	 * 3. Load default file using `load_plugin_textdomain()` from `wp-content/plugins/gravityview/languages/`
259
+	 *
260
+	 * @return void
261
+	 */
262
+	public function load_plugin_textdomain()
263
+	{
264
+		if (empty($this->_text_domain)) {
265
+			gravityview()->log->debug('Extension translation cannot be loaded; the `_text_domain` variable is not defined', ['data' => $this]);
266
+
267
+			return;
268
+		}
269
+
270
+		// Backward compat for Ratings & Reviews / Maps
271
+		$path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : '');
272
+
273
+		// Set filter for plugin's languages directory
274
+		$lang_dir = dirname(plugin_basename($path)).'/languages/';
275
+
276
+		$locale = get_locale();
277
+
278
+		if (function_exists('get_user_locale') && is_admin()) {
279
+			$locale = get_user_locale();
280
+		}
281
+
282
+		// Traditional WordPress plugin locale filter
283
+		$locale = apply_filters('plugin_locale', $locale, $this->_text_domain);
284
+
285
+		$mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale);
286
+
287
+		// Setup paths to current locale file
288
+		$mofile_local = $lang_dir.$mofile;
289
+		$mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile;
290
+
291
+		if (file_exists($mofile_global)) {
292
+			// Look in global /wp-content/languages/[plugin-dir]/ folder
293
+			load_textdomain($this->_text_domain, $mofile_global);
294
+		} elseif (file_exists($mofile_local)) {
295
+			// Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
296
+			load_textdomain($this->_text_domain, $mofile_local);
297
+		} else {
298
+			// Load the default language files
299
+			load_plugin_textdomain($this->_text_domain, false, $lang_dir);
300
+		}
301
+	}
302
+
303
+	/**
304
+	 * Register the updater for the Extension using GravityView license information.
305
+	 *
306
+	 * @return void
307
+	 */
308
+	public function settings()
309
+	{
310
+
311
+		// If doing ajax, get outta here.
312
+		if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX && 'update-plugin' !== Utils::_POST('action'))) {
313
+			return;
314
+		}
315
+
316
+		// To support auto-updates, this needs to run during the wp_version_check cron job for privileged users.
317
+		$doing_cron = defined('DOING_CRON') && DOING_CRON;
318
+		if (!current_user_can('manage_options') && !$doing_cron) {
319
+			return;
320
+		}
321
+
322
+		$license = $this->get_license();
323
+
324
+		if (!class_exists('\GV\EDD_SL_Plugin_Updater')) {
325
+			require_once gravityview()->plugin->dir('future/lib/EDD_SL_Plugin_Updater.php');
326
+		}
327
+
328
+		new EDD_SL_Plugin_Updater(
329
+			$this->_remote_update_url,
330
+			$this->_path,
331
+			[
332
+				'version'	    => $this->_version, // current version number
333
+				'license'	    => \GV\Utils::get($license, 'license_key', \GV\Utils::get($license, 'license', null)),
334
+				'item_id'     => $this->_item_id, // The ID of the download on _remote_update_url
335
+				'item_name'   => $this->_title,  // name of this plugin
336
+				'author' 	    => strip_tags($this->_author),  // author of this plugin
337
+				'php_version' => phpversion(),
338
+				'wp_version'  => get_bloginfo('version'),
339
+				'gv_version'  => \GV\Plugin::$version,
340
+				'environment' => function_exists('wp_get_environment_type') ? wp_get_environment_type() : 'production',
341
+			]
342
+		);
343
+	}
344
+
345
+	/**
346
+	 * Get license information from GravityView.
347
+	 *
348
+	 * @since 1.8 (Extension version 1.0.7)
349
+	 *
350
+	 * @return bool|array False: \GV\Addon_Settings class does not exist. Array: array of GV license data.
351
+	 */
352
+	protected function get_license()
353
+	{
354
+		if (!class_exists('\GV\Addon_Settings')) {
355
+			return false;
356
+		}
357
+
358
+		return gravityview()->plugin->settings->get('license');
359
+	}
360
+
361
+	/**
362
+	 * Add a notice to be displayed in the admin.
363
+	 *
364
+	 * @param array $notice Array with `class` and `message` keys. The message is not escaped.
365
+	 *
366
+	 * @return void
367
+	 */
368
+	public static function add_notice($notice = [])
369
+	{
370
+		if (is_array($notice) && empty($notice['message'])) {
371
+			gravityview()->log->error('Notice not set', ['data' => $notice]);
372
+
373
+			return;
374
+		} elseif (is_string($notice)) {
375
+			$notice = ['message' => $notice];
376
+		}
377
+
378
+		$notice['class'] = empty($notice['class']) ? 'error' : $notice['class'];
379
+
380
+		self::$admin_notices[] = $notice;
381
+	}
382
+
383
+	/**
384
+	 * Outputs the admin notices generated by the all plugins.
385
+	 *
386
+	 * @return void
387
+	 */
388
+	public function admin_notice()
389
+	{
390
+		if (empty(self::$admin_notices)) {
391
+			return;
392
+		}
393
+
394
+		foreach (self::$admin_notices as $key => $notice) {
395
+			echo '<div id="message" class="'.esc_attr($notice['class']).'">';
396
+			echo wpautop($notice['message']);
397
+			echo '<div class="clear"></div>';
398
+			echo '</div>';
399
+		}
400
+
401
+		//reset the notices handler
402
+		self::$admin_notices = [];
403
+	}
404 404
 }
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -69,40 +69,40 @@  discard block
 block discarded – undo
69 69
     /**
70 70
      * @var array Admin notices to display
71 71
      */
72
-    protected static $admin_notices = [];
72
+    protected static $admin_notices = [ ];
73 73
 
74 74
     /**
75 75
      * @var bool[] An array of extension compatibility.
76 76
      *
77 77
      * @since 2.0 This is an array of classes instead.
78 78
      */
79
-    public static $is_compatible = [];
79
+    public static $is_compatible = [ ];
80 80
 
81 81
     /**
82 82
      * Generic initialization.
83 83
      */
84 84
     public function __construct()
85 85
     {
86
-        if (false === $this->is_extension_supported()) {
86
+        if ( false === $this->is_extension_supported() ) {
87 87
             return;
88 88
         }
89 89
 
90
-        if (!$this->_path) {
90
+        if ( ! $this->_path ) {
91 91
             $this->_path = __FILE__;
92 92
         }
93 93
 
94
-        add_action('init', [$this, 'load_plugin_textdomain']);
94
+        add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
95 95
 
96
-        add_action('admin_init', [$this, 'settings']);
96
+        add_action( 'admin_init', [ $this, 'settings' ] );
97 97
 
98
-        add_action('admin_notices', [$this, 'admin_notice'], 100);
98
+        add_action( 'admin_notices', [ $this, 'admin_notice' ], 100 );
99 99
 
100 100
         // Save the view configuration. Run at 14 so that View metadata is already saved (at 10)
101
-        add_action('save_post', [$this, 'save_post'], 14);
101
+        add_action( 'save_post', [ $this, 'save_post' ], 14 );
102 102
 
103
-        add_action('gravityview/metaboxes/before_render', [$this, 'add_metabox_tab']);
103
+        add_action( 'gravityview/metaboxes/before_render', [ $this, 'add_metabox_tab' ] );
104 104
 
105
-        add_filter('gravityview/metaboxes/tooltips', [$this, 'tooltips']);
105
+        add_filter( 'gravityview/metaboxes/tooltips', [ $this, 'tooltips' ] );
106 106
 
107 107
         $this->add_hooks();
108 108
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      *
124 124
      * @return void
125 125
      */
126
-    public function save_post($post_id)
126
+    public function save_post( $post_id )
127 127
     {
128 128
     }
129 129
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      *
146 146
      * @return array Modified tooltips
147 147
      */
148
-    public function tooltips($tooltips = [])
148
+    public function tooltips( $tooltips = [ ] )
149 149
     {
150 150
         return $tooltips;
151 151
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     protected function tab_settings()
162 162
     {
163 163
         // When overriding, return array with expected keys
164
-        return [];
164
+        return [ ];
165 165
     }
166 166
 
167 167
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         $tab_settings = $this->tab_settings();
177 177
 
178 178
         // Don't add a tab if it's empty.
179
-        if (empty($tab_settings)) {
179
+        if ( empty( $tab_settings ) ) {
180 180
             return;
181 181
         }
182 182
 
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
             'priority'      => 'default',
192 192
         ];
193 193
 
194
-        $tab = wp_parse_args($tab_settings, $tab_defaults);
194
+        $tab = wp_parse_args( $tab_settings, $tab_defaults );
195 195
 
196 196
         // Force the screen to be GravityView
197
-        $tab['screen'] = 'gravityview';
197
+        $tab[ 'screen' ] = 'gravityview';
198 198
 
199
-        if (class_exists('GravityView_Metabox_Tab')) {
200
-            $metabox = new \GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']);
201
-            \GravityView_Metabox_Tabs::add($metabox);
199
+        if ( class_exists( 'GravityView_Metabox_Tab' ) ) {
200
+            $metabox = new \GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] );
201
+            \GravityView_Metabox_Tabs::add( $metabox );
202 202
         } else {
203
-            add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']);
203
+            add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] );
204 204
         }
205 205
     }
206 206
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public static function is_compatible()
213 213
     {
214
-        return Utils::get(self::$is_compatible, get_called_class(), null);
214
+        return Utils::get( self::$is_compatible, get_called_class(), null );
215 215
     }
216 216
 
217 217
     /**
@@ -226,25 +226,25 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function is_extension_supported()
228 228
     {
229
-        self::$is_compatible = is_array(self::$is_compatible) ? self::$is_compatible : [get_called_class() => (bool) self::$is_compatible];
230
-
231
-        if (!function_exists('gravityview')) {
232
-            $message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), esc_html($this->_title));
233
-        } elseif (false === version_compare(Plugin::$version, $this->_min_gravityview_version, '>=')) {
234
-            $message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_gravityview_version.'</tt>');
235
-        } elseif (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, '>=')) {
236
-            $message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), esc_html($this->_title), '<tt>'.$this->_min_php_version.'</tt>');
237
-        } elseif (!empty($this->_max_gravityview_version) && false === version_compare($this->_max_gravityview_version, Plugin::$version, '>')) {
238
-            $message = sprintf(__('The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview'), esc_html($this->_title));
229
+        self::$is_compatible = is_array( self::$is_compatible ) ? self::$is_compatible : [ get_called_class() => (bool)self::$is_compatible ];
230
+
231
+        if ( ! function_exists( 'gravityview' ) ) {
232
+            $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), esc_html( $this->_title ) );
233
+        } elseif ( false === version_compare( Plugin::$version, $this->_min_gravityview_version, '>=' ) ) {
234
+            $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_gravityview_version . '</tt>' );
235
+        } elseif ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, '>=' ) ) {
236
+            $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), esc_html( $this->_title ), '<tt>' . $this->_min_php_version . '</tt>' );
237
+        } elseif ( ! empty( $this->_max_gravityview_version ) && false === version_compare( $this->_max_gravityview_version, Plugin::$version, '>' ) ) {
238
+            $message = sprintf( __( 'The %s Extension is not compatible with this version of GravityView. Please update the Extension to the latest version.', 'gravityview' ), esc_html( $this->_title ) );
239 239
         } else {
240 240
             $message = '';
241
-            self::$is_compatible[get_called_class()] = gravityview()->plugin->is_compatible();
241
+            self::$is_compatible[ get_called_class() ] = gravityview()->plugin->is_compatible();
242 242
         }
243 243
 
244
-        if (!empty($message)) {
245
-            self::add_notice($message);
246
-            self::$is_compatible[get_called_class()] = false;
247
-            gravityview()->log->error('{message}', ['message' => $message]);
244
+        if ( ! empty( $message ) ) {
245
+            self::add_notice( $message );
246
+            self::$is_compatible[ get_called_class() ] = false;
247
+            gravityview()->log->error( '{message}', [ 'message' => $message ] );
248 248
         }
249 249
 
250 250
         return self::is_compatible();
@@ -261,42 +261,42 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public function load_plugin_textdomain()
263 263
     {
264
-        if (empty($this->_text_domain)) {
265
-            gravityview()->log->debug('Extension translation cannot be loaded; the `_text_domain` variable is not defined', ['data' => $this]);
264
+        if ( empty( $this->_text_domain ) ) {
265
+            gravityview()->log->debug( 'Extension translation cannot be loaded; the `_text_domain` variable is not defined', [ 'data' => $this ] );
266 266
 
267 267
             return;
268 268
         }
269 269
 
270 270
         // Backward compat for Ratings & Reviews / Maps
271
-        $path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : '');
271
+        $path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file : '' );
272 272
 
273 273
         // Set filter for plugin's languages directory
274
-        $lang_dir = dirname(plugin_basename($path)).'/languages/';
274
+        $lang_dir = dirname( plugin_basename( $path ) ) . '/languages/';
275 275
 
276 276
         $locale = get_locale();
277 277
 
278
-        if (function_exists('get_user_locale') && is_admin()) {
278
+        if ( function_exists( 'get_user_locale' ) && is_admin() ) {
279 279
             $locale = get_user_locale();
280 280
         }
281 281
 
282 282
         // Traditional WordPress plugin locale filter
283
-        $locale = apply_filters('plugin_locale', $locale, $this->_text_domain);
283
+        $locale = apply_filters( 'plugin_locale', $locale, $this->_text_domain );
284 284
 
285
-        $mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale);
285
+        $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale );
286 286
 
287 287
         // Setup paths to current locale file
288
-        $mofile_local = $lang_dir.$mofile;
289
-        $mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile;
288
+        $mofile_local = $lang_dir . $mofile;
289
+        $mofile_global = WP_LANG_DIR . '/' . $this->_text_domain . '/' . $mofile;
290 290
 
291
-        if (file_exists($mofile_global)) {
291
+        if ( file_exists( $mofile_global ) ) {
292 292
             // Look in global /wp-content/languages/[plugin-dir]/ folder
293
-            load_textdomain($this->_text_domain, $mofile_global);
294
-        } elseif (file_exists($mofile_local)) {
293
+            load_textdomain( $this->_text_domain, $mofile_global );
294
+        } elseif ( file_exists( $mofile_local ) ) {
295 295
             // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder
296
-            load_textdomain($this->_text_domain, $mofile_local);
296
+            load_textdomain( $this->_text_domain, $mofile_local );
297 297
         } else {
298 298
             // Load the default language files
299
-            load_plugin_textdomain($this->_text_domain, false, $lang_dir);
299
+            load_plugin_textdomain( $this->_text_domain, false, $lang_dir );
300 300
         }
301 301
     }
302 302
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
     {
310 310
 
311 311
         // If doing ajax, get outta here.
312
-        if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX && 'update-plugin' !== Utils::_POST('action'))) {
312
+        if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-plugin' !== Utils::_POST( 'action' ) ) ) {
313 313
             return;
314 314
         }
315 315
 
316 316
         // To support auto-updates, this needs to run during the wp_version_check cron job for privileged users.
317
-        $doing_cron = defined('DOING_CRON') && DOING_CRON;
318
-        if (!current_user_can('manage_options') && !$doing_cron) {
317
+        $doing_cron = defined( 'DOING_CRON' ) && DOING_CRON;
318
+        if ( ! current_user_can( 'manage_options' ) && ! $doing_cron ) {
319 319
             return;
320 320
         }
321 321
 
322 322
         $license = $this->get_license();
323 323
 
324
-        if (!class_exists('\GV\EDD_SL_Plugin_Updater')) {
325
-            require_once gravityview()->plugin->dir('future/lib/EDD_SL_Plugin_Updater.php');
324
+        if ( ! class_exists( '\GV\EDD_SL_Plugin_Updater' ) ) {
325
+            require_once gravityview()->plugin->dir( 'future/lib/EDD_SL_Plugin_Updater.php' );
326 326
         }
327 327
 
328 328
         new EDD_SL_Plugin_Updater(
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
             $this->_path,
331 331
             [
332 332
                 'version'	    => $this->_version, // current version number
333
-                'license'	    => \GV\Utils::get($license, 'license_key', \GV\Utils::get($license, 'license', null)),
333
+                'license'	    => \GV\Utils::get( $license, 'license_key', \GV\Utils::get( $license, 'license', null ) ),
334 334
                 'item_id'     => $this->_item_id, // The ID of the download on _remote_update_url
335
-                'item_name'   => $this->_title,  // name of this plugin
336
-                'author' 	    => strip_tags($this->_author),  // author of this plugin
335
+                'item_name'   => $this->_title, // name of this plugin
336
+                'author' 	    => strip_tags( $this->_author ), // author of this plugin
337 337
                 'php_version' => phpversion(),
338
-                'wp_version'  => get_bloginfo('version'),
338
+                'wp_version'  => get_bloginfo( 'version' ),
339 339
                 'gv_version'  => \GV\Plugin::$version,
340
-                'environment' => function_exists('wp_get_environment_type') ? wp_get_environment_type() : 'production',
340
+                'environment' => function_exists( 'wp_get_environment_type' ) ? wp_get_environment_type() : 'production',
341 341
             ]
342 342
         );
343 343
     }
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
      */
352 352
     protected function get_license()
353 353
     {
354
-        if (!class_exists('\GV\Addon_Settings')) {
354
+        if ( ! class_exists( '\GV\Addon_Settings' ) ) {
355 355
             return false;
356 356
         }
357 357
 
358
-        return gravityview()->plugin->settings->get('license');
358
+        return gravityview()->plugin->settings->get( 'license' );
359 359
     }
360 360
 
361 361
     /**
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
      *
366 366
      * @return void
367 367
      */
368
-    public static function add_notice($notice = [])
368
+    public static function add_notice( $notice = [ ] )
369 369
     {
370
-        if (is_array($notice) && empty($notice['message'])) {
371
-            gravityview()->log->error('Notice not set', ['data' => $notice]);
370
+        if ( is_array( $notice ) && empty( $notice[ 'message' ] ) ) {
371
+            gravityview()->log->error( 'Notice not set', [ 'data' => $notice ] );
372 372
 
373 373
             return;
374
-        } elseif (is_string($notice)) {
375
-            $notice = ['message' => $notice];
374
+        } elseif ( is_string( $notice ) ) {
375
+            $notice = [ 'message' => $notice ];
376 376
         }
377 377
 
378
-        $notice['class'] = empty($notice['class']) ? 'error' : $notice['class'];
378
+        $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ];
379 379
 
380
-        self::$admin_notices[] = $notice;
380
+        self::$admin_notices[ ] = $notice;
381 381
     }
382 382
 
383 383
     /**
@@ -387,18 +387,18 @@  discard block
 block discarded – undo
387 387
      */
388 388
     public function admin_notice()
389 389
     {
390
-        if (empty(self::$admin_notices)) {
390
+        if ( empty( self::$admin_notices ) ) {
391 391
             return;
392 392
         }
393 393
 
394
-        foreach (self::$admin_notices as $key => $notice) {
395
-            echo '<div id="message" class="'.esc_attr($notice['class']).'">';
396
-            echo wpautop($notice['message']);
394
+        foreach ( self::$admin_notices as $key => $notice ) {
395
+            echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">';
396
+            echo wpautop( $notice[ 'message' ] );
397 397
             echo '<div class="clear"></div>';
398 398
             echo '</div>';
399 399
         }
400 400
 
401 401
         //reset the notices handler
402
-        self::$admin_notices = [];
402
+        self::$admin_notices = [ ];
403 403
     }
404 404
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * An interface that most extensions would want to adhere to and inherit from.
14 14
  */
15
-abstract class Extension
16
-{
15
+abstract class Extension {
17 16
     /**
18 17
      * @var string Name of the plugin in gravityview.co
19 18
      */
@@ -81,8 +80,7 @@  discard block
 block discarded – undo
81 80
     /**
82 81
      * Generic initialization.
83 82
      */
84
-    public function __construct()
85
-    {
83
+    public function __construct() {
86 84
         if (false === $this->is_extension_supported()) {
87 85
             return;
88 86
         }
@@ -112,8 +110,7 @@  discard block
 block discarded – undo
112 110
      *
113 111
      * @return void
114 112
      */
115
-    public function add_hooks()
116
-    {
113
+    public function add_hooks() {
117 114
     }
118 115
 
119 116
     /**
@@ -123,8 +120,7 @@  discard block
 block discarded – undo
123 120
      *
124 121
      * @return void
125 122
      */
126
-    public function save_post($post_id)
127
-    {
123
+    public function save_post($post_id) {
128 124
     }
129 125
 
130 126
     /**
@@ -145,8 +141,7 @@  discard block
 block discarded – undo
145 141
      *
146 142
      * @return array Modified tooltips
147 143
      */
148
-    public function tooltips($tooltips = [])
149
-    {
144
+    public function tooltips($tooltips = []) {
150 145
         return $tooltips;
151 146
     }
152 147
 
@@ -158,8 +153,7 @@  discard block
 block discarded – undo
158 153
      *
159 154
      * @return array Array of metabox
160 155
      */
161
-    protected function tab_settings()
162
-    {
156
+    protected function tab_settings() {
163 157
         // When overriding, return array with expected keys
164 158
         return [];
165 159
     }
@@ -171,8 +165,7 @@  discard block
 block discarded – undo
171 165
      *
172 166
      * @return void
173 167
      */
174
-    public function add_metabox_tab()
175
-    {
168
+    public function add_metabox_tab() {
176 169
         $tab_settings = $this->tab_settings();
177 170
 
178 171
         // Don't add a tab if it's empty.
@@ -209,8 +202,7 @@  discard block
 block discarded – undo
209 202
      *
210 203
      * @return bool|null Is or is not. Null if unknown yet.
211 204
      */
212
-    public static function is_compatible()
213
-    {
205
+    public static function is_compatible() {
214 206
         return Utils::get(self::$is_compatible, get_called_class(), null);
215 207
     }
216 208
 
@@ -224,8 +216,7 @@  discard block
 block discarded – undo
224 216
      *
225 217
      * @return bool Is the extension supported?
226 218
      */
227
-    protected function is_extension_supported()
228
-    {
219
+    protected function is_extension_supported() {
229 220
         self::$is_compatible = is_array(self::$is_compatible) ? self::$is_compatible : [get_called_class() => (bool) self::$is_compatible];
230 221
 
231 222
         if (!function_exists('gravityview')) {
@@ -259,8 +250,7 @@  discard block
 block discarded – undo
259 250
      *
260 251
      * @return void
261 252
      */
262
-    public function load_plugin_textdomain()
263
-    {
253
+    public function load_plugin_textdomain() {
264 254
         if (empty($this->_text_domain)) {
265 255
             gravityview()->log->debug('Extension translation cannot be loaded; the `_text_domain` variable is not defined', ['data' => $this]);
266 256
 
@@ -305,8 +295,7 @@  discard block
 block discarded – undo
305 295
      *
306 296
      * @return void
307 297
      */
308
-    public function settings()
309
-    {
298
+    public function settings() {
310 299
 
311 300
         // If doing ajax, get outta here.
312 301
         if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX && 'update-plugin' !== Utils::_POST('action'))) {
@@ -349,8 +338,7 @@  discard block
 block discarded – undo
349 338
      *
350 339
      * @return bool|array False: \GV\Addon_Settings class does not exist. Array: array of GV license data.
351 340
      */
352
-    protected function get_license()
353
-    {
341
+    protected function get_license() {
354 342
         if (!class_exists('\GV\Addon_Settings')) {
355 343
             return false;
356 344
         }
@@ -365,8 +353,7 @@  discard block
 block discarded – undo
365 353
      *
366 354
      * @return void
367 355
      */
368
-    public static function add_notice($notice = [])
369
-    {
356
+    public static function add_notice($notice = []) {
370 357
         if (is_array($notice) && empty($notice['message'])) {
371 358
             gravityview()->log->error('Notice not set', ['data' => $notice]);
372 359
 
@@ -385,8 +372,7 @@  discard block
 block discarded – undo
385 372
      *
386 373
      * @return void
387 374
      */
388
-    public function admin_notice()
389
-    {
375
+    public function admin_notice() {
390 376
         if (empty(self::$admin_notices)) {
391 377
             return;
392 378
         }
Please login to merge, or discard this patch.
future/includes/class-gv-template-field-html.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Field_HTML_Template extends Field_Template
16 16
 {
17
-    /**
18
-     * @var string The template slug to be loaded (like "table", "list", "plain")
19
-     */
20
-    public static $slug = 'html';
17
+	/**
18
+	 * @var string The template slug to be loaded (like "table", "list", "plain")
19
+	 */
20
+	public static $slug = 'html';
21 21
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
  *
13 13
  * Attached to a \GV\Field and used by a \GV\Field_Renderer.
14 14
  */
15
-class Field_HTML_Template extends Field_Template
16
-{
15
+class Field_HTML_Template extends Field_Template {
17 16
     /**
18 17
      * @var string The template slug to be loaded (like "table", "list", "plain")
19 18
      */
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode.php 3 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,135 +14,135 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Shortcode
16 16
 {
17
-    /*
17
+	/*
18 18
      * @var array All GravityView-registered and loaded shortcodes can be found here.
19 19
      */
20
-    private static $shortcodes;
21
-
22
-    /**
23
-     * @var array The parsed attributes of this shortcode.
24
-     */
25
-    public $atts;
26
-
27
-    /**
28
-     * @var string The parsed name of this shortcode.
29
-     */
30
-    public $name;
31
-
32
-    /**
33
-     * @var string The parsed content between tags of this shortcode.
34
-     */
35
-    public $content;
36
-
37
-    /**
38
-     * The WordPress Shortcode API callback for this shortcode.
39
-     *
40
-     * @param array  $atts    The attributes passed.
41
-     * @param string $content The content inside the shortcode.
42
-     * @param string $tag     The tag.
43
-     *
44
-     * @return string The output.
45
-     */
46
-    public function callback($atts, $content = '', $tag = '')
47
-    {
48
-        gravityview()->log->error('[{shortcode}] shortcode {class}::callback method not implemented.', ['shortcode' => $this->name, 'class' => get_class($this)]);
49
-
50
-        return '';
51
-    }
52
-
53
-    /**
54
-     * Register this shortcode class with the WordPress Shortcode API.
55
-     *
56
-     * @internal
57
-     *
58
-     * @since develop
59
-     *
60
-     * @param string $name A shortcode name override. Default: self::$name
61
-     *
62
-     * @return \GV\Shortcode|null The only internally registered instance of this shortcode, or null on error.
63
-     */
64
-    public static function add($name = null)
65
-    {
66
-        $shortcode = new static();
67
-        $name = $name ? $name : $shortcode->name;
68
-        if (shortcode_exists($name)) {
69
-            if (empty(self::$shortcodes[$name])) {
70
-                gravityview()->log->error('Shortcode [{shortcode}] has already been registered elsewhere.', ['shortcode' => $name]);
71
-
72
-                return null;
73
-            }
74
-        } else {
75
-            add_shortcode($name, [$shortcode, 'callback']);
76
-            self::$shortcodes[$name] = $shortcode;
77
-        }
78
-
79
-        return self::$shortcodes[$name];
80
-    }
81
-
82
-    /**
83
-     * Unregister this shortcode.
84
-     *
85
-     * @internal
86
-     *
87
-     * @return void
88
-     */
89
-    public static function remove()
90
-    {
91
-        $shortcode = new static();
92
-        unset(self::$shortcodes[$shortcode->name]);
93
-        remove_shortcode($shortcode->name);
94
-    }
95
-
96
-    /**
97
-     * Parse a string of content and figure out which ones there are.
98
-     *
99
-     * Only registered shortcodes (via add_shortcode) will show up.
100
-     * Returned order is not guaranteed.
101
-     *
102
-     * @param string $content Some post content to search through.
103
-     *
104
-     * @internal
105
-     *
106
-     * @return \GV\Shortcode[] An array of \GV\Shortcode (and subclass) instances.
107
-     */
108
-    public static function parse($content)
109
-    {
110
-        $shortcodes = [];
111
-
112
-        /**
113
-         * The matches contains:.
114
-         *
115
-         * 1 - An extra [ to allow for escaping shortcodes with double [[]]
116
-         * 2 - The shortcode name
117
-         * 3 - The shortcode argument list
118
-         * 4 - The self closing /
119
-         * 5 - The content of a shortcode when it wraps some content.
120
-         * 6 - An extra ] to allow for escaping shortcodes with double [[]]
121
-         */
122
-        preg_match_all('/'.get_shortcode_regex().'/', $content, $matches, PREG_SET_ORDER);
123
-
124
-        foreach ($matches as $shortcode) {
125
-            $shortcode_name = $shortcode[2];
126
-
127
-            $shortcode_atts = shortcode_parse_atts($shortcode[3]);
128
-            $shortcode_content = $shortcode[5];
129
-
130
-            /** This is a registered GravityView shortcode. */
131
-            if (!empty(self::$shortcodes[$shortcode_name])) {
132
-                $shortcode = clone self::$shortcodes[$shortcode_name];
133
-            } else {
134
-                /** This is some generic shortcode. */
135
-                $shortcode = new self();
136
-                $shortcode->name = $shortcode_name;
137
-            }
138
-
139
-            $shortcode->atts = $shortcode_atts;
140
-            $shortcode->content = $shortcode_content;
141
-
142
-            /** Merge inner shortcodes. */
143
-            $shortcodes = array_merge($shortcodes, [$shortcode], self::parse($shortcode_content));
144
-        }
145
-
146
-        return $shortcodes;
147
-    }
20
+	private static $shortcodes;
21
+
22
+	/**
23
+	 * @var array The parsed attributes of this shortcode.
24
+	 */
25
+	public $atts;
26
+
27
+	/**
28
+	 * @var string The parsed name of this shortcode.
29
+	 */
30
+	public $name;
31
+
32
+	/**
33
+	 * @var string The parsed content between tags of this shortcode.
34
+	 */
35
+	public $content;
36
+
37
+	/**
38
+	 * The WordPress Shortcode API callback for this shortcode.
39
+	 *
40
+	 * @param array  $atts    The attributes passed.
41
+	 * @param string $content The content inside the shortcode.
42
+	 * @param string $tag     The tag.
43
+	 *
44
+	 * @return string The output.
45
+	 */
46
+	public function callback($atts, $content = '', $tag = '')
47
+	{
48
+		gravityview()->log->error('[{shortcode}] shortcode {class}::callback method not implemented.', ['shortcode' => $this->name, 'class' => get_class($this)]);
49
+
50
+		return '';
51
+	}
52
+
53
+	/**
54
+	 * Register this shortcode class with the WordPress Shortcode API.
55
+	 *
56
+	 * @internal
57
+	 *
58
+	 * @since develop
59
+	 *
60
+	 * @param string $name A shortcode name override. Default: self::$name
61
+	 *
62
+	 * @return \GV\Shortcode|null The only internally registered instance of this shortcode, or null on error.
63
+	 */
64
+	public static function add($name = null)
65
+	{
66
+		$shortcode = new static();
67
+		$name = $name ? $name : $shortcode->name;
68
+		if (shortcode_exists($name)) {
69
+			if (empty(self::$shortcodes[$name])) {
70
+				gravityview()->log->error('Shortcode [{shortcode}] has already been registered elsewhere.', ['shortcode' => $name]);
71
+
72
+				return null;
73
+			}
74
+		} else {
75
+			add_shortcode($name, [$shortcode, 'callback']);
76
+			self::$shortcodes[$name] = $shortcode;
77
+		}
78
+
79
+		return self::$shortcodes[$name];
80
+	}
81
+
82
+	/**
83
+	 * Unregister this shortcode.
84
+	 *
85
+	 * @internal
86
+	 *
87
+	 * @return void
88
+	 */
89
+	public static function remove()
90
+	{
91
+		$shortcode = new static();
92
+		unset(self::$shortcodes[$shortcode->name]);
93
+		remove_shortcode($shortcode->name);
94
+	}
95
+
96
+	/**
97
+	 * Parse a string of content and figure out which ones there are.
98
+	 *
99
+	 * Only registered shortcodes (via add_shortcode) will show up.
100
+	 * Returned order is not guaranteed.
101
+	 *
102
+	 * @param string $content Some post content to search through.
103
+	 *
104
+	 * @internal
105
+	 *
106
+	 * @return \GV\Shortcode[] An array of \GV\Shortcode (and subclass) instances.
107
+	 */
108
+	public static function parse($content)
109
+	{
110
+		$shortcodes = [];
111
+
112
+		/**
113
+		 * The matches contains:.
114
+		 *
115
+		 * 1 - An extra [ to allow for escaping shortcodes with double [[]]
116
+		 * 2 - The shortcode name
117
+		 * 3 - The shortcode argument list
118
+		 * 4 - The self closing /
119
+		 * 5 - The content of a shortcode when it wraps some content.
120
+		 * 6 - An extra ] to allow for escaping shortcodes with double [[]]
121
+		 */
122
+		preg_match_all('/'.get_shortcode_regex().'/', $content, $matches, PREG_SET_ORDER);
123
+
124
+		foreach ($matches as $shortcode) {
125
+			$shortcode_name = $shortcode[2];
126
+
127
+			$shortcode_atts = shortcode_parse_atts($shortcode[3]);
128
+			$shortcode_content = $shortcode[5];
129
+
130
+			/** This is a registered GravityView shortcode. */
131
+			if (!empty(self::$shortcodes[$shortcode_name])) {
132
+				$shortcode = clone self::$shortcodes[$shortcode_name];
133
+			} else {
134
+				/** This is some generic shortcode. */
135
+				$shortcode = new self();
136
+				$shortcode->name = $shortcode_name;
137
+			}
138
+
139
+			$shortcode->atts = $shortcode_atts;
140
+			$shortcode->content = $shortcode_content;
141
+
142
+			/** Merge inner shortcodes. */
143
+			$shortcodes = array_merge($shortcodes, [$shortcode], self::parse($shortcode_content));
144
+		}
145
+
146
+		return $shortcodes;
147
+	}
148 148
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
      *
44 44
      * @return string The output.
45 45
      */
46
-    public function callback($atts, $content = '', $tag = '')
46
+    public function callback( $atts, $content = '', $tag = '' )
47 47
     {
48
-        gravityview()->log->error('[{shortcode}] shortcode {class}::callback method not implemented.', ['shortcode' => $this->name, 'class' => get_class($this)]);
48
+        gravityview()->log->error( '[{shortcode}] shortcode {class}::callback method not implemented.', [ 'shortcode' => $this->name, 'class' => get_class( $this ) ] );
49 49
 
50 50
         return '';
51 51
     }
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
      *
62 62
      * @return \GV\Shortcode|null The only internally registered instance of this shortcode, or null on error.
63 63
      */
64
-    public static function add($name = null)
64
+    public static function add( $name = null )
65 65
     {
66 66
         $shortcode = new static();
67 67
         $name = $name ? $name : $shortcode->name;
68
-        if (shortcode_exists($name)) {
69
-            if (empty(self::$shortcodes[$name])) {
70
-                gravityview()->log->error('Shortcode [{shortcode}] has already been registered elsewhere.', ['shortcode' => $name]);
68
+        if ( shortcode_exists( $name ) ) {
69
+            if ( empty( self::$shortcodes[ $name ] ) ) {
70
+                gravityview()->log->error( 'Shortcode [{shortcode}] has already been registered elsewhere.', [ 'shortcode' => $name ] );
71 71
 
72 72
                 return null;
73 73
             }
74 74
         } else {
75
-            add_shortcode($name, [$shortcode, 'callback']);
76
-            self::$shortcodes[$name] = $shortcode;
75
+            add_shortcode( $name, [ $shortcode, 'callback' ] );
76
+            self::$shortcodes[ $name ] = $shortcode;
77 77
         }
78 78
 
79
-        return self::$shortcodes[$name];
79
+        return self::$shortcodes[ $name ];
80 80
     }
81 81
 
82 82
     /**
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
     public static function remove()
90 90
     {
91 91
         $shortcode = new static();
92
-        unset(self::$shortcodes[$shortcode->name]);
93
-        remove_shortcode($shortcode->name);
92
+        unset( self::$shortcodes[ $shortcode->name ] );
93
+        remove_shortcode( $shortcode->name );
94 94
     }
95 95
 
96 96
     /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return \GV\Shortcode[] An array of \GV\Shortcode (and subclass) instances.
107 107
      */
108
-    public static function parse($content)
108
+    public static function parse( $content )
109 109
     {
110
-        $shortcodes = [];
110
+        $shortcodes = [ ];
111 111
 
112 112
         /**
113 113
          * The matches contains:.
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
          * 5 - The content of a shortcode when it wraps some content.
120 120
          * 6 - An extra ] to allow for escaping shortcodes with double [[]]
121 121
          */
122
-        preg_match_all('/'.get_shortcode_regex().'/', $content, $matches, PREG_SET_ORDER);
122
+        preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
123 123
 
124
-        foreach ($matches as $shortcode) {
125
-            $shortcode_name = $shortcode[2];
124
+        foreach ( $matches as $shortcode ) {
125
+            $shortcode_name = $shortcode[ 2 ];
126 126
 
127
-            $shortcode_atts = shortcode_parse_atts($shortcode[3]);
128
-            $shortcode_content = $shortcode[5];
127
+            $shortcode_atts = shortcode_parse_atts( $shortcode[ 3 ] );
128
+            $shortcode_content = $shortcode[ 5 ];
129 129
 
130 130
             /** This is a registered GravityView shortcode. */
131
-            if (!empty(self::$shortcodes[$shortcode_name])) {
132
-                $shortcode = clone self::$shortcodes[$shortcode_name];
131
+            if ( ! empty( self::$shortcodes[ $shortcode_name ] ) ) {
132
+                $shortcode = clone self::$shortcodes[ $shortcode_name ];
133 133
             } else {
134 134
                 /** This is some generic shortcode. */
135 135
                 $shortcode = new self();
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             $shortcode->content = $shortcode_content;
141 141
 
142 142
             /** Merge inner shortcodes. */
143
-            $shortcodes = array_merge($shortcodes, [$shortcode], self::parse($shortcode_content));
143
+            $shortcodes = array_merge( $shortcodes, [ $shortcode ], self::parse( $shortcode_content ) );
144 144
         }
145 145
 
146 146
         return $shortcodes;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * Contains some unitility methods, base class for all GV Shortcodes.
14 14
  */
15
-class Shortcode
16
-{
15
+class Shortcode {
17 16
     /*
18 17
      * @var array All GravityView-registered and loaded shortcodes can be found here.
19 18
      */
@@ -43,8 +42,7 @@  discard block
 block discarded – undo
43 42
      *
44 43
      * @return string The output.
45 44
      */
46
-    public function callback($atts, $content = '', $tag = '')
47
-    {
45
+    public function callback($atts, $content = '', $tag = '') {
48 46
         gravityview()->log->error('[{shortcode}] shortcode {class}::callback method not implemented.', ['shortcode' => $this->name, 'class' => get_class($this)]);
49 47
 
50 48
         return '';
@@ -61,8 +59,7 @@  discard block
 block discarded – undo
61 59
      *
62 60
      * @return \GV\Shortcode|null The only internally registered instance of this shortcode, or null on error.
63 61
      */
64
-    public static function add($name = null)
65
-    {
62
+    public static function add($name = null) {
66 63
         $shortcode = new static();
67 64
         $name = $name ? $name : $shortcode->name;
68 65
         if (shortcode_exists($name)) {
@@ -86,8 +83,7 @@  discard block
 block discarded – undo
86 83
      *
87 84
      * @return void
88 85
      */
89
-    public static function remove()
90
-    {
86
+    public static function remove() {
91 87
         $shortcode = new static();
92 88
         unset(self::$shortcodes[$shortcode->name]);
93 89
         remove_shortcode($shortcode->name);
@@ -105,8 +101,7 @@  discard block
 block discarded – undo
105 101
      *
106 102
      * @return \GV\Shortcode[] An array of \GV\Shortcode (and subclass) instances.
107 103
      */
108
-    public static function parse($content)
109
-    {
104
+    public static function parse($content) {
110 105
         $shortcodes = [];
111 106
 
112 107
         /**
Please login to merge, or discard this patch.
future/includes/class-gv-template.php 3 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @see https://github.com/GaryJones/Gamajo-Template-Loader
14 14
  */
15 15
 if (!class_exists('\GV\Gamajo_Template_Loader')) {
16
-    require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
16
+	require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
17 17
 }
18 18
 
19 19
 /**
@@ -24,104 +24,104 @@  discard block
 block discarded – undo
24 24
  */
25 25
 abstract class Template extends \GV\Gamajo_Template_Loader
26 26
 {
27
-    /**
28
-     * @var array The template data stack.
29
-     */
30
-    private static $data_stack = [];
31
-
32
-    /**
33
-     * @var string The located template.
34
-     */
35
-    public $located_template = '';
36
-
37
-    /**
38
-     * General template initialization.
39
-     *
40
-     * Sets the $plugin_directory field.
41
-     */
42
-    public function __construct()
43
-    {
44
-        /** Set plugin directory. */
45
-        $this->plugin_directory = gravityview()->plugin->dir();
46
-    }
47
-
48
-    /**
49
-     * Disallow any cleanup for fear of loss of global data.
50
-     *
51
-     * The destructor in Gamajo 1.3.0 destroys all of `$wp_query`.
52
-     * This has the chance of inappropriately destroying valid
53
-     *  data that's been stored under the same key.
54
-     *
55
-     * Disallow this.
56
-     */
57
-    public function __destruct()
58
-    {
59
-    }
60
-
61
-    /**
62
-     * Get a directory part and a full slug+name (file) components.
63
-     *
64
-     * @param string $slug The slug, template base.
65
-     * @param string $name The name, template part. Default: null
66
-     *
67
-     * @return array containing slug directory and slug+name.
68
-     */
69
-    public static function split_slug($slug, $name = null)
70
-    {
71
-        $dir_name = (dirname($slug) != '.') ? trailingslashit(dirname($slug)) : '';
72
-        $slug_name = basename($slug).($name ? "-$name" : '');
73
-
74
-        return [$dir_name, $slug_name];
75
-    }
76
-
77
-    /**
78
-     * Push the current template data down the stack and set.
79
-     *
80
-     * This allows us to use the same variable in the template scope
81
-     *  without destroying data under the same variable in a nested
82
-     *  or parallel template.
83
-     *
84
-     * @param mixed  $data     The data to set.
85
-     * @param string $var_name The data variable identifier (Default: "data")
86
-     *
87
-     * @see \Gamajo_Template_Loader::set_template_data
88
-     * @see \GV\Template::pop_template_data
89
-     *
90
-     * @return \GV\Gamajo_Template_Loader The current instance.
91
-     */
92
-    public function push_template_data($data, $var_name = 'data')
93
-    {
94
-        if (!isset(self::$data_stack[$var_name])) {
95
-            self::$data_stack[$var_name] = [];
96
-        }
97
-
98
-        global $wp_query;
99
-
100
-        if (isset($wp_query->query_vars[$var_name])) {
101
-            array_push(self::$data_stack[$var_name], $wp_query->query_vars[$var_name]);
102
-        }
103
-
104
-        $this->set_template_data($data, $var_name);
105
-
106
-        return $this;
107
-    }
108
-
109
-    /**
110
-     * Restore the template data from the stack.
111
-     *
112
-     * @param string $var_name The data variable identifier (Default: "data")
113
-     *
114
-     * @see \Gamajo_Template_Loader::set_template_data
115
-     * @see \GV\Template::pop_template_data
116
-     *
117
-     * @return $this;
118
-     */
119
-    public function pop_template_data($var_name = 'data')
120
-    {
121
-        if (!empty(self::$data_stack[$var_name])) {
122
-            $this->set_template_data(array_pop(self::$data_stack[$var_name]), $var_name);
123
-        }
124
-
125
-        return $this;
126
-    }
27
+	/**
28
+	 * @var array The template data stack.
29
+	 */
30
+	private static $data_stack = [];
31
+
32
+	/**
33
+	 * @var string The located template.
34
+	 */
35
+	public $located_template = '';
36
+
37
+	/**
38
+	 * General template initialization.
39
+	 *
40
+	 * Sets the $plugin_directory field.
41
+	 */
42
+	public function __construct()
43
+	{
44
+		/** Set plugin directory. */
45
+		$this->plugin_directory = gravityview()->plugin->dir();
46
+	}
47
+
48
+	/**
49
+	 * Disallow any cleanup for fear of loss of global data.
50
+	 *
51
+	 * The destructor in Gamajo 1.3.0 destroys all of `$wp_query`.
52
+	 * This has the chance of inappropriately destroying valid
53
+	 *  data that's been stored under the same key.
54
+	 *
55
+	 * Disallow this.
56
+	 */
57
+	public function __destruct()
58
+	{
59
+	}
60
+
61
+	/**
62
+	 * Get a directory part and a full slug+name (file) components.
63
+	 *
64
+	 * @param string $slug The slug, template base.
65
+	 * @param string $name The name, template part. Default: null
66
+	 *
67
+	 * @return array containing slug directory and slug+name.
68
+	 */
69
+	public static function split_slug($slug, $name = null)
70
+	{
71
+		$dir_name = (dirname($slug) != '.') ? trailingslashit(dirname($slug)) : '';
72
+		$slug_name = basename($slug).($name ? "-$name" : '');
73
+
74
+		return [$dir_name, $slug_name];
75
+	}
76
+
77
+	/**
78
+	 * Push the current template data down the stack and set.
79
+	 *
80
+	 * This allows us to use the same variable in the template scope
81
+	 *  without destroying data under the same variable in a nested
82
+	 *  or parallel template.
83
+	 *
84
+	 * @param mixed  $data     The data to set.
85
+	 * @param string $var_name The data variable identifier (Default: "data")
86
+	 *
87
+	 * @see \Gamajo_Template_Loader::set_template_data
88
+	 * @see \GV\Template::pop_template_data
89
+	 *
90
+	 * @return \GV\Gamajo_Template_Loader The current instance.
91
+	 */
92
+	public function push_template_data($data, $var_name = 'data')
93
+	{
94
+		if (!isset(self::$data_stack[$var_name])) {
95
+			self::$data_stack[$var_name] = [];
96
+		}
97
+
98
+		global $wp_query;
99
+
100
+		if (isset($wp_query->query_vars[$var_name])) {
101
+			array_push(self::$data_stack[$var_name], $wp_query->query_vars[$var_name]);
102
+		}
103
+
104
+		$this->set_template_data($data, $var_name);
105
+
106
+		return $this;
107
+	}
108
+
109
+	/**
110
+	 * Restore the template data from the stack.
111
+	 *
112
+	 * @param string $var_name The data variable identifier (Default: "data")
113
+	 *
114
+	 * @see \Gamajo_Template_Loader::set_template_data
115
+	 * @see \GV\Template::pop_template_data
116
+	 *
117
+	 * @return $this;
118
+	 */
119
+	public function pop_template_data($var_name = 'data')
120
+	{
121
+		if (!empty(self::$data_stack[$var_name])) {
122
+			$this->set_template_data(array_pop(self::$data_stack[$var_name]), $var_name);
123
+		}
124
+
125
+		return $this;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * @see https://github.com/GaryJones/Gamajo-Template-Loader
14 14
  */
15
-if (!class_exists('\GV\Gamajo_Template_Loader')) {
16
-    require gravityview()->plugin->dir('future/lib/class-gamajo-template-loader.php');
15
+if ( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) {
16
+    require gravityview()->plugin->dir( 'future/lib/class-gamajo-template-loader.php' );
17 17
 }
18 18
 
19 19
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @var array The template data stack.
29 29
      */
30
-    private static $data_stack = [];
30
+    private static $data_stack = [ ];
31 31
 
32 32
     /**
33 33
      * @var string The located template.
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return array containing slug directory and slug+name.
68 68
      */
69
-    public static function split_slug($slug, $name = null)
69
+    public static function split_slug( $slug, $name = null )
70 70
     {
71
-        $dir_name = (dirname($slug) != '.') ? trailingslashit(dirname($slug)) : '';
72
-        $slug_name = basename($slug).($name ? "-$name" : '');
71
+        $dir_name = ( dirname( $slug ) != '.' ) ? trailingslashit( dirname( $slug ) ) : '';
72
+        $slug_name = basename( $slug ) . ( $name ? "-$name" : '' );
73 73
 
74
-        return [$dir_name, $slug_name];
74
+        return [ $dir_name, $slug_name ];
75 75
     }
76 76
 
77 77
     /**
@@ -89,19 +89,19 @@  discard block
 block discarded – undo
89 89
      *
90 90
      * @return \GV\Gamajo_Template_Loader The current instance.
91 91
      */
92
-    public function push_template_data($data, $var_name = 'data')
92
+    public function push_template_data( $data, $var_name = 'data' )
93 93
     {
94
-        if (!isset(self::$data_stack[$var_name])) {
95
-            self::$data_stack[$var_name] = [];
94
+        if ( ! isset( self::$data_stack[ $var_name ] ) ) {
95
+            self::$data_stack[ $var_name ] = [ ];
96 96
         }
97 97
 
98 98
         global $wp_query;
99 99
 
100
-        if (isset($wp_query->query_vars[$var_name])) {
101
-            array_push(self::$data_stack[$var_name], $wp_query->query_vars[$var_name]);
100
+        if ( isset( $wp_query->query_vars[ $var_name ] ) ) {
101
+            array_push( self::$data_stack[ $var_name ], $wp_query->query_vars[ $var_name ] );
102 102
         }
103 103
 
104
-        $this->set_template_data($data, $var_name);
104
+        $this->set_template_data( $data, $var_name );
105 105
 
106 106
         return $this;
107 107
     }
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return $this;
118 118
      */
119
-    public function pop_template_data($var_name = 'data')
119
+    public function pop_template_data( $var_name = 'data' )
120 120
     {
121
-        if (!empty(self::$data_stack[$var_name])) {
122
-            $this->set_template_data(array_pop(self::$data_stack[$var_name]), $var_name);
121
+        if ( ! empty( self::$data_stack[ $var_name ] ) ) {
122
+            $this->set_template_data( array_pop( self::$data_stack[ $var_name ] ), $var_name );
123 123
         }
124 124
 
125 125
         return $this;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * Sets the $plugin_directory field.
41 41
      */
42
-    public function __construct()
43
-    {
42
+    public function __construct() {
44 43
         /** Set plugin directory. */
45 44
         $this->plugin_directory = gravityview()->plugin->dir();
46 45
     }
@@ -54,8 +53,7 @@  discard block
 block discarded – undo
54 53
      *
55 54
      * Disallow this.
56 55
      */
57
-    public function __destruct()
58
-    {
56
+    public function __destruct() {
59 57
     }
60 58
 
61 59
     /**
@@ -66,8 +64,7 @@  discard block
 block discarded – undo
66 64
      *
67 65
      * @return array containing slug directory and slug+name.
68 66
      */
69
-    public static function split_slug($slug, $name = null)
70
-    {
67
+    public static function split_slug($slug, $name = null) {
71 68
         $dir_name = (dirname($slug) != '.') ? trailingslashit(dirname($slug)) : '';
72 69
         $slug_name = basename($slug).($name ? "-$name" : '');
73 70
 
@@ -89,8 +86,7 @@  discard block
 block discarded – undo
89 86
      *
90 87
      * @return \GV\Gamajo_Template_Loader The current instance.
91 88
      */
92
-    public function push_template_data($data, $var_name = 'data')
93
-    {
89
+    public function push_template_data($data, $var_name = 'data') {
94 90
         if (!isset(self::$data_stack[$var_name])) {
95 91
             self::$data_stack[$var_name] = [];
96 92
         }
@@ -116,8 +112,7 @@  discard block
 block discarded – undo
116 112
      *
117 113
      * @return $this;
118 114
      */
119
-    public function pop_template_data($var_name = 'data')
120
-    {
115
+    public function pop_template_data($var_name = 'data') {
121 116
         if (!empty(self::$data_stack[$var_name])) {
122 117
             $this->set_template_data(array_pop(self::$data_stack[$var_name]), $var_name);
123 118
         }
Please login to merge, or discard this patch.
future/includes/class-gv-settings-addon.php 4 patches
Indentation   +1249 added lines, -1249 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@  discard block
 block discarded – undo
6 6
 
7 7
 /** If this file is called directly, abort. */
8 8
 if (!defined('GRAVITYVIEW_DIR')) {
9
-    exit();
9
+	exit();
10 10
 }
11 11
 
12 12
 if (!class_exists('\GFAddOn')) {
13
-    return;
13
+	return;
14 14
 }
15 15
 
16 16
 /**
@@ -20,367 +20,367 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Addon_Settings extends \GFAddOn
22 22
 {
23
-    /**
24
-     * @var string Title of the plugin to be used on the settings page, form settings and plugins page. Example: 'Gravity Forms MailChimp Add-On'
25
-     */
26
-    protected $_title = 'GravityView';
27
-
28
-    /**
29
-     * @var string Short version of the plugin title to be used on menus and other places where a less verbose string is useful. Example: 'MailChimp'
30
-     */
31
-    protected $_short_title = 'GravityView';
32
-
33
-    /**
34
-     * @var string URL-friendly identifier used for form settings, add-on settings, text domain localization...
35
-     */
36
-    protected $_slug = 'gravityview';
37
-
38
-    /**
39
-     * @var string|array A string or an array of capabilities or roles that can uninstall the plugin
40
-     */
41
-    protected $_capabilities_uninstall = 'gravityview_uninstall';
42
-
43
-    /**
44
-     * @var string|array A string or an array of capabilities or roles that have access to the settings page
45
-     */
46
-    protected $_capabilities_app_settings = 'gravityview_view_settings';
47
-
48
-    /**
49
-     * @var string|array A string or an array of capabilities or roles that have access to the settings page
50
-     */
51
-    protected $_capabilities_app_menu = 'gravityview_view_settings';
52
-
53
-    /**
54
-     * @var string The hook suffix for the app menu
55
-     */
56
-    public $app_hook_suffix = 'gravityview';
57
-
58
-    /**
59
-     * @var \GV\License_Handler Process license validation
60
-     */
61
-    private $License_Handler;
62
-
63
-    /**
64
-     * @var bool Whether we have initialized already or not.
65
-     */
66
-    private static $initialized = false;
67
-
68
-    public function __construct()
69
-    {
70
-        $this->_version = Plugin::$version;
71
-        $this->_min_gravityforms_version = Plugin::$min_gf_version;
72
-
73
-        /**
74
-         * Hook everywhere, but only once.
75
-         */
76
-        if (!self::$initialized) {
77
-            parent::__construct();
78
-            self::$initialized = true;
79
-        }
80
-    }
81
-
82
-    /**
83
-     * Run actions when initializing admin.
84
-     *
85
-     * Triggers the license key notice, etc.
86
-     *
87
-     * @return void
88
-     */
89
-    public function init_admin()
90
-    {
91
-        $this->_load_license_handler();
92
-
93
-        add_filter('admin_body_class', [$this, 'body_class']);
94
-
95
-        add_action('admin_head', [$this, 'license_key_notice']);
96
-
97
-        add_filter('gform_addon_app_settings_menu_gravityview', [$this, 'modify_app_settings_menu_title']);
98
-
99
-        add_filter('gform_settings_save_button', [$this, 'modify_gform_settings_save_button'], 10, 2);
100
-
101
-        /** @since 1.7.6 */
102
-        add_action('network_admin_menu', [$this, 'add_network_menu']);
103
-
104
-        add_filter('gravityview_noconflict_styles', [$this, 'register_no_conflict']);
105
-
106
-        parent::init_admin();
107
-    }
108
-
109
-    /**
110
-     * Return tabs for GV Settings page.
111
-     *
112
-     * @since XXX
113
-     *
114
-     * @return array
115
-     */
116
-    public function get_app_settings_tabs()
117
-    {
118
-        $setting_tabs = parent::get_app_settings_tabs();
119
-
120
-        foreach ($setting_tabs as &$tab) {
121
-            if ('uninstall' !== $tab['name']) {
122
-                continue;
123
-            }
124
-
125
-            // Do not display uninstall tab if user is lacking permissions/this is a multisite
126
-            if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
127
-                $tab = null;
128
-                continue;
129
-            }
130
-
131
-            // Add trash can icon to resemble the look and feel of the GF Settings page
132
-            $tab['icon'] = 'dashicons-trash';
133
-        }
134
-
135
-        return array_filter($setting_tabs);
136
-    }
137
-
138
-    /**
139
-     * Allow GF styles to load in no-conflict mode.
140
-     *
141
-     * @param array $items Styles to exclude from no-conflict
142
-     *
143
-     * @return array
144
-     */
145
-    public function register_no_conflict($items)
146
-    {
147
-        $items[] = 'gform_settings';
148
-        $items[] = 'gv-admin-edd-license';
149
-
150
-        return $items;
151
-    }
152
-
153
-    /**
154
-     * Adds a CSS class to the <body> of the admin page if running GF 2.5 or newer.
155
-     *
156
-     * @param $css_class
157
-     *
158
-     * @return string
159
-     */
160
-    public function body_class($css_class)
161
-    {
162
-        if (!gravityview()->request->is_admin('', 'settings')) {
163
-            return $css_class;
164
-        }
165
-
166
-        if (gravityview()->plugin->is_GF_25()) {
167
-            $css_class .= ' gf-2-5';
168
-        }
169
-
170
-        return $css_class;
171
-    }
172
-
173
-    /**
174
-     * Adds an "Uninstall" button next to the GF 2.5 Save Settings button.
175
-     *
176
-     * @since 2.9.1
177
-     *
178
-     * @param string                                     $html      HTML of the save button.
179
-     * @param \Gravity_Forms\Gravity_Forms\Settings|null $framework Current instance of the Settings Framework. Or null if < 2.5.
180
-     */
181
-    public function modify_gform_settings_save_button($html, $framework = null)
182
-    {
183
-        if (!gravityview()->request->is_admin('', 'settings')) {
184
-            return $html;
185
-        }
186
-
187
-        if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
188
-            return $html;
189
-        }
190
-
191
-        if (gravityview()->plugin->is_GF_25()) {
192
-            $html_class = 'button outline secondary alignright button-danger';
193
-        } else {
194
-            $html_class = 'button button-secondary button-large alignright button-danger';
195
-        }
196
-
197
-        $href = add_query_arg(['post_type' => 'gravityview', 'page' => 'gravityview_settings', 'view' => 'uninstall'], admin_url('edit.php'));
198
-
199
-        $uninstall_button = '<a href="'.esc_url($href).'" class="'.gravityview_sanitize_html_class($html_class).'">'.esc_html__('Uninstall GravityView', 'gravityview').'</a>';
200
-
201
-        $html .= $uninstall_button;
202
-
203
-        return $html;
204
-    }
205
-
206
-    /**
207
-     * Roll our own "Hero" Save button with an Unsubscribe button attached.
208
-     *
209
-     * @since 2.9.1
210
-     *
211
-     * @param array $field
212
-     * @param bool  $echo
213
-     *
214
-     * @return string|null HTML of the button.
215
-     */
216
-    public function settings_save($field, $echo = true)
217
-    {
218
-        $field['type'] = 'submit';
219
-        $field['name'] = 'gform-settings-save';
220
-        $field['class'] = 'button button-primary primary button-hero';
221
-        $field['value'] = Utils::get($field, 'value', __('Update Settings', 'gravityview'));
222
-
223
-        $html = $this->as_html($field, false);
224
-
225
-        $html = $this->modify_gform_settings_save_button($html);
226
-
227
-        if ($echo) {
228
-            echo $html;
229
-        }
230
-
231
-        return $html;
232
-    }
233
-
234
-    /**
235
-     * Change the settings page header title to "GravityView".
236
-     *
237
-     * @param $setting_tabs
238
-     *
239
-     * @return array
240
-     */
241
-    public function modify_app_settings_menu_title($setting_tabs)
242
-    {
243
-        $setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview');
244
-        $setting_tabs[0]['icon'] = 'dashicons-admin-settings';
245
-
246
-        return $setting_tabs;
247
-    }
248
-
249
-    /**
250
-     * Load license handler in admin-ajax.php.
251
-     *
252
-     * @return void
253
-     */
254
-    public function init_ajax()
255
-    {
256
-        $this->_load_license_handler();
257
-    }
258
-
259
-    /**
260
-     * Make sure the license handler is available.
261
-     *
262
-     * @return void
263
-     */
264
-    private function _load_license_handler()
265
-    {
266
-        if (!empty($this->License_Handler)) {
267
-            return;
268
-        }
269
-        $this->License_Handler = License_Handler::get($this);
270
-    }
271
-
272
-    /**
273
-     * Add global Settings page for Multisite.
274
-     *
275
-     * @since 1.7.6
276
-     *
277
-     * @return void
278
-     */
279
-    public function add_network_menu()
280
-    {
281
-        if (!gravityview()->plugin->is_network_activated()) {
282
-            return;
283
-        }
284
-
285
-        add_menu_page(__('Settings', 'gravityview'), __('GravityView', 'gravityview'), $this->_capabilities_app_settings, "{$this->_slug}_settings", [$this, 'app_tab_page'], 'none');
286
-    }
287
-
288
-    /**
289
-     * Uninstall all traces of GravityView.
290
-     *
291
-     * Note: method is public because parent method is public
292
-     *
293
-     * @return bool
294
-     */
295
-    public function uninstall()
296
-    {
297
-        gravityview()->plugin->uninstall();
298
-
299
-        /**
300
-         * Set the path so that Gravity Forms can de-activate GravityView.
301
-         *
302
-         * @see  GFAddOn::uninstall_addon
303
-         *
304
-         * @uses deactivate_plugins()
305
-         */
306
-        $this->_path = GRAVITYVIEW_FILE;
307
-
308
-        return true;
309
-    }
310
-
311
-    /**
312
-     * Prevent uninstall tab from being shown by returning false for the uninstall capability check. Otherwise:.
313
-     *
314
-     * @inheritDoc
315
-     *
316
-     * @hack
317
-     *
318
-     * @param array|string $caps
319
-     *
320
-     * @return bool
321
-     */
322
-    public function current_user_can_any($caps)
323
-    {
324
-        if (empty($caps)) {
325
-            $caps = ['gravityview_full_access'];
326
-        }
327
-
328
-        return \GVCommon::has_cap($caps);
329
-    }
330
-
331
-    public function uninstall_warning_message()
332
-    {
333
-        $heading = esc_html__('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview');
334
-        $message = esc_html__('Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview');
335
-
336
-        return sprintf('<h4>%s</h4><p>%s</p>', $heading, $message);
337
-    }
23
+	/**
24
+	 * @var string Title of the plugin to be used on the settings page, form settings and plugins page. Example: 'Gravity Forms MailChimp Add-On'
25
+	 */
26
+	protected $_title = 'GravityView';
27
+
28
+	/**
29
+	 * @var string Short version of the plugin title to be used on menus and other places where a less verbose string is useful. Example: 'MailChimp'
30
+	 */
31
+	protected $_short_title = 'GravityView';
32
+
33
+	/**
34
+	 * @var string URL-friendly identifier used for form settings, add-on settings, text domain localization...
35
+	 */
36
+	protected $_slug = 'gravityview';
37
+
38
+	/**
39
+	 * @var string|array A string or an array of capabilities or roles that can uninstall the plugin
40
+	 */
41
+	protected $_capabilities_uninstall = 'gravityview_uninstall';
42
+
43
+	/**
44
+	 * @var string|array A string or an array of capabilities or roles that have access to the settings page
45
+	 */
46
+	protected $_capabilities_app_settings = 'gravityview_view_settings';
47
+
48
+	/**
49
+	 * @var string|array A string or an array of capabilities or roles that have access to the settings page
50
+	 */
51
+	protected $_capabilities_app_menu = 'gravityview_view_settings';
52
+
53
+	/**
54
+	 * @var string The hook suffix for the app menu
55
+	 */
56
+	public $app_hook_suffix = 'gravityview';
57
+
58
+	/**
59
+	 * @var \GV\License_Handler Process license validation
60
+	 */
61
+	private $License_Handler;
62
+
63
+	/**
64
+	 * @var bool Whether we have initialized already or not.
65
+	 */
66
+	private static $initialized = false;
67
+
68
+	public function __construct()
69
+	{
70
+		$this->_version = Plugin::$version;
71
+		$this->_min_gravityforms_version = Plugin::$min_gf_version;
72
+
73
+		/**
74
+		 * Hook everywhere, but only once.
75
+		 */
76
+		if (!self::$initialized) {
77
+			parent::__construct();
78
+			self::$initialized = true;
79
+		}
80
+	}
81
+
82
+	/**
83
+	 * Run actions when initializing admin.
84
+	 *
85
+	 * Triggers the license key notice, etc.
86
+	 *
87
+	 * @return void
88
+	 */
89
+	public function init_admin()
90
+	{
91
+		$this->_load_license_handler();
92
+
93
+		add_filter('admin_body_class', [$this, 'body_class']);
94
+
95
+		add_action('admin_head', [$this, 'license_key_notice']);
96
+
97
+		add_filter('gform_addon_app_settings_menu_gravityview', [$this, 'modify_app_settings_menu_title']);
98
+
99
+		add_filter('gform_settings_save_button', [$this, 'modify_gform_settings_save_button'], 10, 2);
100
+
101
+		/** @since 1.7.6 */
102
+		add_action('network_admin_menu', [$this, 'add_network_menu']);
103
+
104
+		add_filter('gravityview_noconflict_styles', [$this, 'register_no_conflict']);
105
+
106
+		parent::init_admin();
107
+	}
108
+
109
+	/**
110
+	 * Return tabs for GV Settings page.
111
+	 *
112
+	 * @since XXX
113
+	 *
114
+	 * @return array
115
+	 */
116
+	public function get_app_settings_tabs()
117
+	{
118
+		$setting_tabs = parent::get_app_settings_tabs();
119
+
120
+		foreach ($setting_tabs as &$tab) {
121
+			if ('uninstall' !== $tab['name']) {
122
+				continue;
123
+			}
338 124
 
339
-    /**
340
-     * Get an array of reasons why the plugin might be uninstalled.
341
-     *
342
-     * @since 1.17.5
343
-     *
344
-     * @return array Array of reasons with the label and followup questions for each uninstall reason
345
-     */
346
-    private function get_uninstall_reasons()
347
-    {
348
-        $reasons = [
349
-            'will-continue'  => [
350
-                'label' => esc_html__('I am going to continue using GravityView', 'gravityview'),
351
-            ],
352
-            'no-longer-need' => [
353
-                'label' => esc_html__('I no longer need GravityView', 'gravityview'),
354
-            ],
355
-            'doesnt-work'    => [
356
-                'label' => esc_html__('The plugin doesn\'t work', 'gravityview'),
357
-            ],
358
-            'found-other'    => [
359
-                'label'    => esc_html__('I found a better plugin', 'gravityview'),
360
-                'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'),
361
-            ],
362
-            'other'          => [
363
-                'label' => esc_html__('Other', 'gravityview'),
364
-            ],
365
-        ];
366
-
367
-        shuffle($reasons);
368
-
369
-        return $reasons;
370
-    }
371
-
372
-    /**
373
-     * Display a feedback form when the plugin is uninstalled.
374
-     *
375
-     * @since 1.17.5
376
-     *
377
-     * @return string HTML of the uninstallation form
378
-     */
379
-    public function uninstall_form()
380
-    {
381
-        ob_start();
125
+			// Do not display uninstall tab if user is lacking permissions/this is a multisite
126
+			if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
127
+				$tab = null;
128
+				continue;
129
+			}
382 130
 
383
-        $user = wp_get_current_user(); ?>
131
+			// Add trash can icon to resemble the look and feel of the GF Settings page
132
+			$tab['icon'] = 'dashicons-trash';
133
+		}
134
+
135
+		return array_filter($setting_tabs);
136
+	}
137
+
138
+	/**
139
+	 * Allow GF styles to load in no-conflict mode.
140
+	 *
141
+	 * @param array $items Styles to exclude from no-conflict
142
+	 *
143
+	 * @return array
144
+	 */
145
+	public function register_no_conflict($items)
146
+	{
147
+		$items[] = 'gform_settings';
148
+		$items[] = 'gv-admin-edd-license';
149
+
150
+		return $items;
151
+	}
152
+
153
+	/**
154
+	 * Adds a CSS class to the <body> of the admin page if running GF 2.5 or newer.
155
+	 *
156
+	 * @param $css_class
157
+	 *
158
+	 * @return string
159
+	 */
160
+	public function body_class($css_class)
161
+	{
162
+		if (!gravityview()->request->is_admin('', 'settings')) {
163
+			return $css_class;
164
+		}
165
+
166
+		if (gravityview()->plugin->is_GF_25()) {
167
+			$css_class .= ' gf-2-5';
168
+		}
169
+
170
+		return $css_class;
171
+	}
172
+
173
+	/**
174
+	 * Adds an "Uninstall" button next to the GF 2.5 Save Settings button.
175
+	 *
176
+	 * @since 2.9.1
177
+	 *
178
+	 * @param string                                     $html      HTML of the save button.
179
+	 * @param \Gravity_Forms\Gravity_Forms\Settings|null $framework Current instance of the Settings Framework. Or null if < 2.5.
180
+	 */
181
+	public function modify_gform_settings_save_button($html, $framework = null)
182
+	{
183
+		if (!gravityview()->request->is_admin('', 'settings')) {
184
+			return $html;
185
+		}
186
+
187
+		if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
188
+			return $html;
189
+		}
190
+
191
+		if (gravityview()->plugin->is_GF_25()) {
192
+			$html_class = 'button outline secondary alignright button-danger';
193
+		} else {
194
+			$html_class = 'button button-secondary button-large alignright button-danger';
195
+		}
196
+
197
+		$href = add_query_arg(['post_type' => 'gravityview', 'page' => 'gravityview_settings', 'view' => 'uninstall'], admin_url('edit.php'));
198
+
199
+		$uninstall_button = '<a href="'.esc_url($href).'" class="'.gravityview_sanitize_html_class($html_class).'">'.esc_html__('Uninstall GravityView', 'gravityview').'</a>';
200
+
201
+		$html .= $uninstall_button;
202
+
203
+		return $html;
204
+	}
205
+
206
+	/**
207
+	 * Roll our own "Hero" Save button with an Unsubscribe button attached.
208
+	 *
209
+	 * @since 2.9.1
210
+	 *
211
+	 * @param array $field
212
+	 * @param bool  $echo
213
+	 *
214
+	 * @return string|null HTML of the button.
215
+	 */
216
+	public function settings_save($field, $echo = true)
217
+	{
218
+		$field['type'] = 'submit';
219
+		$field['name'] = 'gform-settings-save';
220
+		$field['class'] = 'button button-primary primary button-hero';
221
+		$field['value'] = Utils::get($field, 'value', __('Update Settings', 'gravityview'));
222
+
223
+		$html = $this->as_html($field, false);
224
+
225
+		$html = $this->modify_gform_settings_save_button($html);
226
+
227
+		if ($echo) {
228
+			echo $html;
229
+		}
230
+
231
+		return $html;
232
+	}
233
+
234
+	/**
235
+	 * Change the settings page header title to "GravityView".
236
+	 *
237
+	 * @param $setting_tabs
238
+	 *
239
+	 * @return array
240
+	 */
241
+	public function modify_app_settings_menu_title($setting_tabs)
242
+	{
243
+		$setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview');
244
+		$setting_tabs[0]['icon'] = 'dashicons-admin-settings';
245
+
246
+		return $setting_tabs;
247
+	}
248
+
249
+	/**
250
+	 * Load license handler in admin-ajax.php.
251
+	 *
252
+	 * @return void
253
+	 */
254
+	public function init_ajax()
255
+	{
256
+		$this->_load_license_handler();
257
+	}
258
+
259
+	/**
260
+	 * Make sure the license handler is available.
261
+	 *
262
+	 * @return void
263
+	 */
264
+	private function _load_license_handler()
265
+	{
266
+		if (!empty($this->License_Handler)) {
267
+			return;
268
+		}
269
+		$this->License_Handler = License_Handler::get($this);
270
+	}
271
+
272
+	/**
273
+	 * Add global Settings page for Multisite.
274
+	 *
275
+	 * @since 1.7.6
276
+	 *
277
+	 * @return void
278
+	 */
279
+	public function add_network_menu()
280
+	{
281
+		if (!gravityview()->plugin->is_network_activated()) {
282
+			return;
283
+		}
284
+
285
+		add_menu_page(__('Settings', 'gravityview'), __('GravityView', 'gravityview'), $this->_capabilities_app_settings, "{$this->_slug}_settings", [$this, 'app_tab_page'], 'none');
286
+	}
287
+
288
+	/**
289
+	 * Uninstall all traces of GravityView.
290
+	 *
291
+	 * Note: method is public because parent method is public
292
+	 *
293
+	 * @return bool
294
+	 */
295
+	public function uninstall()
296
+	{
297
+		gravityview()->plugin->uninstall();
298
+
299
+		/**
300
+		 * Set the path so that Gravity Forms can de-activate GravityView.
301
+		 *
302
+		 * @see  GFAddOn::uninstall_addon
303
+		 *
304
+		 * @uses deactivate_plugins()
305
+		 */
306
+		$this->_path = GRAVITYVIEW_FILE;
307
+
308
+		return true;
309
+	}
310
+
311
+	/**
312
+	 * Prevent uninstall tab from being shown by returning false for the uninstall capability check. Otherwise:.
313
+	 *
314
+	 * @inheritDoc
315
+	 *
316
+	 * @hack
317
+	 *
318
+	 * @param array|string $caps
319
+	 *
320
+	 * @return bool
321
+	 */
322
+	public function current_user_can_any($caps)
323
+	{
324
+		if (empty($caps)) {
325
+			$caps = ['gravityview_full_access'];
326
+		}
327
+
328
+		return \GVCommon::has_cap($caps);
329
+	}
330
+
331
+	public function uninstall_warning_message()
332
+	{
333
+		$heading = esc_html__('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview');
334
+		$message = esc_html__('Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview');
335
+
336
+		return sprintf('<h4>%s</h4><p>%s</p>', $heading, $message);
337
+	}
338
+
339
+	/**
340
+	 * Get an array of reasons why the plugin might be uninstalled.
341
+	 *
342
+	 * @since 1.17.5
343
+	 *
344
+	 * @return array Array of reasons with the label and followup questions for each uninstall reason
345
+	 */
346
+	private function get_uninstall_reasons()
347
+	{
348
+		$reasons = [
349
+			'will-continue'  => [
350
+				'label' => esc_html__('I am going to continue using GravityView', 'gravityview'),
351
+			],
352
+			'no-longer-need' => [
353
+				'label' => esc_html__('I no longer need GravityView', 'gravityview'),
354
+			],
355
+			'doesnt-work'    => [
356
+				'label' => esc_html__('The plugin doesn\'t work', 'gravityview'),
357
+			],
358
+			'found-other'    => [
359
+				'label'    => esc_html__('I found a better plugin', 'gravityview'),
360
+				'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'),
361
+			],
362
+			'other'          => [
363
+				'label' => esc_html__('Other', 'gravityview'),
364
+			],
365
+		];
366
+
367
+		shuffle($reasons);
368
+
369
+		return $reasons;
370
+	}
371
+
372
+	/**
373
+	 * Display a feedback form when the plugin is uninstalled.
374
+	 *
375
+	 * @since 1.17.5
376
+	 *
377
+	 * @return string HTML of the uninstallation form
378
+	 */
379
+	public function uninstall_form()
380
+	{
381
+		ob_start();
382
+
383
+		$user = wp_get_current_user(); ?>
384 384
 		<style>
385 385
 			#gv-reason-details {
386 386
 				min-height: 100px;
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 		</style>
413 413
 
414 414
 		<?php
415
-        if (gravityview()->plugin->is_GF_25()) {
416
-            $uninstall_title = esc_html__('Uninstall GravityView', 'gravityview');
415
+		if (gravityview()->plugin->is_GF_25()) {
416
+			$uninstall_title = esc_html__('Uninstall GravityView', 'gravityview');
417 417
 
418
-            echo <<<HTML
418
+			echo <<<HTML
419 419
 <div class="gform-settings-panel">
420 420
     <header class="gform-settings-panel__header">
421 421
         <h4 class="gform-settings-panel__title">{$uninstall_title}</h4>
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
     <div class="gform-settings-panel__content" style="padding: 0 1rem 1.25rem">
424 424
 
425 425
 HTML;
426
-        } else {
427
-            echo '<div class="gv-uninstall-form-wrapper" style="font-size: 110%; padding: 15px 0;">';
428
-        } ?>
426
+		} else {
427
+			echo '<div class="gv-uninstall-form-wrapper" style="font-size: 110%; padding: 15px 0;">';
428
+		} ?>
429 429
 		<script>
430 430
 			jQuery( function( $ ) {
431 431
 				$( '#gv-uninstall-feedback' ).on( 'change', function( e ) {
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
 			<h2><?php esc_html_e('Why did you uninstall GravityView?', 'gravityview'); ?></h2>
473 473
 			<ul>
474 474
 				<?php
475
-                $reasons = $this->get_uninstall_reasons();
476
-        foreach ($reasons as $reason) {
477
-            printf('<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get($reason, 'followup'), Utils::get($reason, 'label'));
478
-        } ?>
475
+				$reasons = $this->get_uninstall_reasons();
476
+		foreach ($reasons as $reason) {
477
+			printf('<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get($reason, 'followup'), Utils::get($reason, 'label'));
478
+		} ?>
479 479
 			</ul>
480 480
 			<div class="gv-followup widefat">
481 481
 				<p><strong><label for="gv-reason-details"><?php esc_html_e('Comments', 'gravityview'); ?></label></strong></p>
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
 				<p><strong><?php esc_html_e('How likely are you to recommend GravityView?', 'gravityview'); ?></strong></p>
486 486
 				<ul class="inline">
487 487
 					<?php
488
-                    $i = 0;
489
-        while ($i < 11) {
490
-            echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>';
491
-            $i++;
492
-        } ?>
488
+					$i = 0;
489
+		while ($i < 11) {
490
+			echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>';
491
+			$i++;
492
+		} ?>
493 493
 				</ul>
494 494
 				<p class="description"><?php printf(esc_html_x('%s ("Not at all likely") to %s ("Extremely likely")', 'A scale from 0 (bad) to 10 (good)', 'gravityview'), '<label for="likely_to_refer_0"><code>0</code></label>', '<label for="likely_to_refer_10"><code>10</code></label>'); ?></p>
495 495
 			</div>
@@ -515,178 +515,178 @@  discard block
 block discarded – undo
515 515
 		</div>
516 516
 		</div>
517 517
 		<?php
518
-        if (gravityview()->plugin->is_GF_25()) {
519
-            echo '</div>';
520
-        }
521
-
522
-        $form = ob_get_clean();
523
-
524
-        return $form;
525
-    }
526
-
527
-    public function app_settings_tab()
528
-    {
529
-        parent::app_settings_tab();
530
-
531
-        if ($this->maybe_uninstall()) {
532
-            echo $this->uninstall_form();
533
-        }
534
-    }
535
-
536
-    /**
537
-     * The Settings title.
538
-     *
539
-     * @return string
540
-     */
541
-    public function app_settings_title()
542
-    {
543
-        return null;
544
-    }
545
-
546
-    /**
547
-     * Prevent displaying of any icon.
548
-     *
549
-     * @return string
550
-     */
551
-    public function app_settings_icon()
552
-    {
553
-        return '&nbsp;';
554
-    }
555
-
556
-    /**
557
-     * Retrieve a setting.
558
-     *
559
-     * @param string $setting_name The setting key.
560
-     *
561
-     * @return mixed The setting or null
562
-     *
563
-     * @deprecated Use \GV\Addon_Settings::get
564
-     */
565
-    public function get_app_setting($setting_name)
566
-    {
567
-        return $this->get($setting_name);
568
-    }
569
-
570
-    /**
571
-     * Retrieve a setting.
572
-     *
573
-     * @param string $key     The setting key.
574
-     * @param string $default A default if not found.
575
-     *
576
-     * @return mixed The setting value.
577
-     */
578
-    public function get($key, $default = null)
579
-    {
580
-
581
-        /**
582
-         * Backward compatibility with Redux.
583
-         */
584
-        if ($key === 'license') {
585
-            return [
586
-                'license'  => $this->get('license_key'),
587
-                'status'   => $this->get('license_key_status'),
588
-                'response' => $this->get('license_key_response'),
589
-            ];
590
-        }
591
-
592
-        if ('license_key' === $key && defined('GRAVITYVIEW_LICENSE_KEY')) {
593
-            return GRAVITYVIEW_LICENSE_KEY;
594
-        }
595
-
596
-        return Utils::get($this->all(), $key, $default);
597
-    }
598
-
599
-    /**
600
-     * Get the setting for GravityView by name.
601
-     *
602
-     * @param string $key Option key to fetch
603
-     *
604
-     * @return mixed
605
-     *
606
-     * @deprecated Use gravityview()->plugin->settings->get()
607
-     */
608
-    public static function getSetting($key)
609
-    {
610
-        if (gravityview()->plugin->settings instanceof Addon_Settings) {
611
-            return gravityview()->plugin->settings->get($key);
612
-        }
613
-    }
614
-
615
-    /**
616
-     * Get all settings.
617
-     *
618
-     * @return array The settings.
619
-     *
620
-     * @deprecated Use \GV\Addon_Settings::all() or \GV\Addon_Settings::get()
621
-     */
622
-    public function get_app_settings()
623
-    {
624
-        return $this->all();
625
-    }
626
-
627
-    /**
628
-     * Get all the settings.
629
-     *
630
-     * @return array The settings.
631
-     */
632
-    public function all()
633
-    {
634
-        $option_name = 'gravityformsaddon_'.$this->_slug.'_app_settings';
635
-
636
-        if ($this->has_site_settings()) {
637
-            $defaults = $this->defaults();
638
-            $option_value = get_option($option_name, []);
639
-        } else {
640
-            $defaults = get_blog_option(get_main_site_id(), $option_name);
641
-            $option_value = get_blog_option(get_main_site_id(), $option_name);
642
-        }
643
-
644
-        return wp_parse_args($option_value, $defaults);
645
-    }
646
-
647
-    /**
648
-     * Default settings.
649
-     *
650
-     * @return array The defaults.
651
-     *
652
-     * @deprecated Use \GV\Addon_Settings::defaults()
653
-     */
654
-    public function get_default_settings()
655
-    {
656
-        return $this->defaults();
657
-    }
658
-
659
-    /**
660
-     * Default settings.
661
-     *
662
-     * @return array The defaults.
663
-     */
664
-    private function defaults()
665
-    {
666
-        $defaults = [
667
-            // Set the default license in wp-config.php
668
-            'license_key'          => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '',
669
-            'license_key_response' => '',
670
-            'license_key_status'   => '',
671
-            'support-email'        => get_bloginfo('admin_email'),
672
-            'no-conflict-mode'     => '1',
673
-            'support_port'         => '1',
674
-            'flexbox_search'       => '1',
675
-            'lightbox'             => 'fancybox',
676
-            'rest_api'             => '0',
677
-            'beta'                 => '0',
678
-            'powered_by'           => '0',
679
-        ];
680
-
681
-        /**
682
-         * @filter `gravityview/settings/default` Filter default global settings.
683
-         *
684
-         * @param  [in,out] array The defaults.
685
-         */
686
-        return apply_filters('gravityview/settings/defaults', $defaults);
687
-    }
688
-
689
-    /***
518
+		if (gravityview()->plugin->is_GF_25()) {
519
+			echo '</div>';
520
+		}
521
+
522
+		$form = ob_get_clean();
523
+
524
+		return $form;
525
+	}
526
+
527
+	public function app_settings_tab()
528
+	{
529
+		parent::app_settings_tab();
530
+
531
+		if ($this->maybe_uninstall()) {
532
+			echo $this->uninstall_form();
533
+		}
534
+	}
535
+
536
+	/**
537
+	 * The Settings title.
538
+	 *
539
+	 * @return string
540
+	 */
541
+	public function app_settings_title()
542
+	{
543
+		return null;
544
+	}
545
+
546
+	/**
547
+	 * Prevent displaying of any icon.
548
+	 *
549
+	 * @return string
550
+	 */
551
+	public function app_settings_icon()
552
+	{
553
+		return '&nbsp;';
554
+	}
555
+
556
+	/**
557
+	 * Retrieve a setting.
558
+	 *
559
+	 * @param string $setting_name The setting key.
560
+	 *
561
+	 * @return mixed The setting or null
562
+	 *
563
+	 * @deprecated Use \GV\Addon_Settings::get
564
+	 */
565
+	public function get_app_setting($setting_name)
566
+	{
567
+		return $this->get($setting_name);
568
+	}
569
+
570
+	/**
571
+	 * Retrieve a setting.
572
+	 *
573
+	 * @param string $key     The setting key.
574
+	 * @param string $default A default if not found.
575
+	 *
576
+	 * @return mixed The setting value.
577
+	 */
578
+	public function get($key, $default = null)
579
+	{
580
+
581
+		/**
582
+		 * Backward compatibility with Redux.
583
+		 */
584
+		if ($key === 'license') {
585
+			return [
586
+				'license'  => $this->get('license_key'),
587
+				'status'   => $this->get('license_key_status'),
588
+				'response' => $this->get('license_key_response'),
589
+			];
590
+		}
591
+
592
+		if ('license_key' === $key && defined('GRAVITYVIEW_LICENSE_KEY')) {
593
+			return GRAVITYVIEW_LICENSE_KEY;
594
+		}
595
+
596
+		return Utils::get($this->all(), $key, $default);
597
+	}
598
+
599
+	/**
600
+	 * Get the setting for GravityView by name.
601
+	 *
602
+	 * @param string $key Option key to fetch
603
+	 *
604
+	 * @return mixed
605
+	 *
606
+	 * @deprecated Use gravityview()->plugin->settings->get()
607
+	 */
608
+	public static function getSetting($key)
609
+	{
610
+		if (gravityview()->plugin->settings instanceof Addon_Settings) {
611
+			return gravityview()->plugin->settings->get($key);
612
+		}
613
+	}
614
+
615
+	/**
616
+	 * Get all settings.
617
+	 *
618
+	 * @return array The settings.
619
+	 *
620
+	 * @deprecated Use \GV\Addon_Settings::all() or \GV\Addon_Settings::get()
621
+	 */
622
+	public function get_app_settings()
623
+	{
624
+		return $this->all();
625
+	}
626
+
627
+	/**
628
+	 * Get all the settings.
629
+	 *
630
+	 * @return array The settings.
631
+	 */
632
+	public function all()
633
+	{
634
+		$option_name = 'gravityformsaddon_'.$this->_slug.'_app_settings';
635
+
636
+		if ($this->has_site_settings()) {
637
+			$defaults = $this->defaults();
638
+			$option_value = get_option($option_name, []);
639
+		} else {
640
+			$defaults = get_blog_option(get_main_site_id(), $option_name);
641
+			$option_value = get_blog_option(get_main_site_id(), $option_name);
642
+		}
643
+
644
+		return wp_parse_args($option_value, $defaults);
645
+	}
646
+
647
+	/**
648
+	 * Default settings.
649
+	 *
650
+	 * @return array The defaults.
651
+	 *
652
+	 * @deprecated Use \GV\Addon_Settings::defaults()
653
+	 */
654
+	public function get_default_settings()
655
+	{
656
+		return $this->defaults();
657
+	}
658
+
659
+	/**
660
+	 * Default settings.
661
+	 *
662
+	 * @return array The defaults.
663
+	 */
664
+	private function defaults()
665
+	{
666
+		$defaults = [
667
+			// Set the default license in wp-config.php
668
+			'license_key'          => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '',
669
+			'license_key_response' => '',
670
+			'license_key_status'   => '',
671
+			'support-email'        => get_bloginfo('admin_email'),
672
+			'no-conflict-mode'     => '1',
673
+			'support_port'         => '1',
674
+			'flexbox_search'       => '1',
675
+			'lightbox'             => 'fancybox',
676
+			'rest_api'             => '0',
677
+			'beta'                 => '0',
678
+			'powered_by'           => '0',
679
+		];
680
+
681
+		/**
682
+		 * @filter `gravityview/settings/default` Filter default global settings.
683
+		 *
684
+		 * @param  [in,out] array The defaults.
685
+		 */
686
+		return apply_filters('gravityview/settings/defaults', $defaults);
687
+	}
688
+
689
+	/***
690 690
      * Renders the save button for settings pages
691 691
      *
692 692
      * @param array $field - Field array containing the configuration options of this field
@@ -694,635 +694,635 @@  discard block
 block discarded – undo
694 694
      *
695 695
      * @return string The HTML
696 696
      */
697
-    public function as_html($field, $echo = true)
698
-    {
699
-        $field['type'] = (isset($field['type']) && in_array($field['type'], ['submit', 'reset', 'button'])) ? $field['type'] : 'submit';
697
+	public function as_html($field, $echo = true)
698
+	{
699
+		$field['type'] = (isset($field['type']) && in_array($field['type'], ['submit', 'reset', 'button'])) ? $field['type'] : 'submit';
700 700
 
701
-        $attributes = $this->get_field_attributes($field);
702
-        $default_value = Utils::get($field, 'value', Utils::get($field, 'default_value'));
703
-        $value = $this->get($field['name'], $default_value);
701
+		$attributes = $this->get_field_attributes($field);
702
+		$default_value = Utils::get($field, 'value', Utils::get($field, 'default_value'));
703
+		$value = $this->get($field['name'], $default_value);
704 704
 
705
-        $attributes['class'] = isset($attributes['class']) ? esc_attr($attributes['class']) : 'button-primary primary gfbutton';
706
-        $name = ($field['name'] === 'gform-settings-save') ? $field['name'] : '_gaddon_setting_'.$field['name'];
705
+		$attributes['class'] = isset($attributes['class']) ? esc_attr($attributes['class']) : 'button-primary primary gfbutton';
706
+		$name = ($field['name'] === 'gform-settings-save') ? $field['name'] : '_gaddon_setting_'.$field['name'];
707 707
 
708
-        if (empty($value)) {
709
-            $value = __('Update Settings', 'gravityview');
710
-        }
708
+		if (empty($value)) {
709
+			$value = __('Update Settings', 'gravityview');
710
+		}
711 711
 
712
-        $attributes = $this->get_field_attributes($field);
712
+		$attributes = $this->get_field_attributes($field);
713 713
 
714
-        $html = '<input
714
+		$html = '<input
715 715
                     type="'.$field['type'].'"
716 716
                     name="'.esc_attr($name).'"
717 717
                     value="'.$value.'" '.
718
-                implode(' ', $attributes).
719
-                ' />';
720
-
721
-        if ($echo) {
722
-            echo $html;
723
-        }
724
-
725
-        return $html;
726
-    }
727
-
728
-    /**
729
-     * @deprecated Use \GV\Addon_Settings::as_html
730
-     */
731
-    public function settings_submit($field, $echo = true)
732
-    {
733
-        gravityview()->log->warning('\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html');
734
-
735
-        return $this->as_html($field, $echo);
736
-    }
737
-
738
-    /**
739
-     * Check whether GravityView is being saved.
740
-     *
741
-     * The generic is_save_postback() is true for all addons
742
-     *
743
-     * @since 2.0.8
744
-     *
745
-     * @return bool
746
-     */
747
-    public function is_save_postback()
748
-    {
749
-        return isset($_POST['gform-settings-save']) && isset($_POST['_gravityview_save_settings_nonce']);
750
-    }
751
-
752
-    /**
753
-     * Display a notice if the plugin is inactive.
754
-     *
755
-     * @return void
756
-     */
757
-    public function license_key_notice()
758
-    {
759
-        if ('uninstall' === rgget('view')) {
760
-            return; // Do not display license notice on the uninstall page in GF 2.5
761
-        }
762
-
763
-        if ($this->is_save_postback()) {
764
-            $settings = $this->get_posted_settings();
765
-            $license_key = defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get($settings, 'license_key');
766
-            $license_status = \GV\Utils::get($settings, 'license_key_status', 'inactive');
767
-        } else {
768
-            $license_status = $this->get('license_key_status', 'inactive');
769
-            $license_key = $this->get('license_key');
770
-        }
771
-
772
-        if (empty($license_key)) {
773
-            $license_id = 'license';
774
-            $license_status = '';
775
-        } else {
776
-            $license_id = $license_key;
777
-        }
778
-
779
-        $message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
780
-
781
-        /** @internal Do not use! Will change without notice (pun slightly intended). */
782
-        $message = apply_filters('gravityview/settings/license-key-notice', $message);
783
-
784
-        /**
785
-         * I wanted to remove the period from after the buttons in the string,
786
-         * but didn't want to mess up the translation strings for the translators.
787
-         */
788
-        $message = mb_substr($message, 0, mb_strlen($message) - 1);
789
-        $title = __('Inactive License', 'gravityview');
790
-        $status = '';
791
-        $update_below = false;
792
-        $primary_button_link = admin_url('edit.php?post_type=gravityview&amp;page=gravityview_settings');
793
-
794
-        switch ($license_status) {
795
-            /** @since 1.17 */
796
-            case 'expired':
797
-                $title = __('Expired License', 'gravityview');
798
-                $status = __('has expired', 'gravityview');
799
-                $message = $this->get_license_handler()->strings('expired', $this->get('license_key_response'));
800
-                break;
801
-            case 'invalid':
802
-                $title = __('Invalid License', 'gravityview');
803
-                $status = __('is invalid', 'gravityview');
804
-                break;
805
-            case 'deactivated':
806
-                $status = __('is inactive', 'gravityview');
807
-                $update_below = __('Activate your license key below.', 'gravityview');
808
-                break;
809
-            /** @noinspection PhpMissingBreakStatementInspection */
810
-            case '':
811
-                $license_status = 'site_inactive';
812
-            // break intentionally left blank
813
-            case 'inactive':
814
-            case 'site_inactive':
815
-                $status = __('has not been activated', 'gravityview');
816
-                $update_below = __('Activate your license key below.', 'gravityview');
817
-                break;
818
-        }
819
-        $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
820
-
821
-        // Show a different notice on settings page for inactive licenses (hide the buttons)
822
-        if ($update_below && gravityview()->request->is_admin('', 'settings')) {
823
-            $message = sprintf($message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">'.$update_below.'</a>');
824
-        } else {
825
-            $message = sprintf($message, $status, "\n\n".'<a href="'.esc_url($primary_button_link).'" class="button button-primary primary">', '</a>', '<a href="'.esc_url($url).'" class="button button-secondary">', '</a>');
826
-        }
827
-
828
-        if (empty($status)) {
829
-            return;
830
-        }
831
-
832
-        \GravityView_Admin_Notices::add_notice([
833
-            'message' => $message,
834
-            'class'   => 'notice notice-warning gv-license-warning',
835
-            'title'   => $title,
836
-            'cap'     => 'gravityview_edit_settings',
837
-            'dismiss' => sha1($license_status.'_'.$license_id.'_'.date('z')), // Show every day, instead of every 8 weeks (which is the default)
838
-        ]);
839
-    }
840
-
841
-    /**
842
-     * Allow public access to the GV\License_Handler class.
843
-     *
844
-     * @since 1.7.4
845
-     *
846
-     * @return \GV\License_Handler
847
-     */
848
-    public function get_license_handler()
849
-    {
850
-        return $this->License_Handler;
851
-    }
852
-
853
-    /**
854
-     * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason.
855
-     *
856
-     * @since 1.21.5
857
-     * @see   GFAddOn::scripts()
858
-     *
859
-     * @return array Array of scripts
860
-     */
861
-    public function scripts()
862
-    {
863
-        $scripts = parent::scripts();
864
-
865
-        $scripts[] = [
866
-            'handle'  => 'gform_tooltip_init',
867
-            'enqueue' => [
868
-                [
869
-                    'admin_page' => ['app_settings'],
870
-                ],
871
-            ],
872
-        ];
873
-
874
-        return $scripts;
875
-    }
876
-
877
-    /**
878
-     * Register styles in the app admin page.
879
-     *
880
-     * @return array
881
-     */
882
-    public function styles()
883
-    {
884
-        $styles = parent::styles();
885
-
886
-        $deps = [
887
-            'gform_admin',
888
-            'gaddon_form_settings_css',
889
-            'gform_font_awesome',
890
-        ];
891
-
892
-        // This file was removed from 2.5
893
-        if (!gravityview()->plugin->is_GF_25()) {
894
-            $deps[] = 'gform_tooltip';
895
-        }
896
-
897
-        $styles[] = [
898
-            'handle'  => 'gravityview_settings',
899
-            'src'     => plugins_url('assets/css/admin-settings.css', GRAVITYVIEW_FILE),
900
-            'version' => Plugin::$version,
901
-            'deps'    => $deps,
902
-            'enqueue' => [
903
-                [
904
-                    'admin_page' => [
905
-                        'app_settings',
906
-                        'plugin_settings',
907
-                    ],
908
-                ],
909
-            ],
910
-        ];
911
-
912
-        return $styles;
913
-    }
914
-
915
-    /**
916
-     * Does the current site have its own settings?
917
-     *
918
-     * - If not multisite, returns true.
919
-     * - If multisite and the plugin is network activated, returns true; we need to register the submenu page for the Network Admin settings to work.
920
-     * - If multisite and not network admin, return false.
921
-     *
922
-     * @since 2.8.2
923
-     *
924
-     * @return bool
925
-     */
926
-    private function has_site_settings()
927
-    {
928
-        return (!is_multisite()) || is_main_site() || (!gravityview()->plugin->is_network_activated()) || (is_network_admin() && gravityview()->plugin->is_network_activated());
929
-    }
930
-
931
-    /**
932
-     * Add Settings link to GravityView menu.
933
-     *
934
-     * @return void
935
-     */
936
-    public function create_app_menu()
937
-    {
938
-
939
-        /**
940
-         * Override whether to show the Settings menu on a per-blog basis.
941
-         *
942
-         * @since 1.7.6
943
-         *
944
-         * @param bool $hide_if_network_activated Default: true
945
-         */
946
-        $show_submenu = apply_filters('gravityview/show-settings-menu', $this->has_site_settings());
947
-
948
-        if (!$show_submenu) {
949
-            return;
950
-        }
951
-
952
-        add_submenu_page('edit.php?post_type=gravityview', __('Settings', 'gravityview'), __('Settings', 'gravityview'), $this->_capabilities_app_settings, $this->_slug.'_settings', [$this, 'app_tab_page']);
953
-    }
954
-
955
-    /**
956
-     * Gets the required indicator
957
-     * Gets the markup of the required indicator symbol to highlight fields that are required.
958
-     *
959
-     * @param $field - The field meta.
960
-     *
961
-     * @return string - Returns markup of the required indicator symbol
962
-     */
963
-    public function get_required_indicator($field)
964
-    {
965
-        return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>';
966
-    }
967
-
968
-    /**
969
-     * Specify the settings fields to be rendered on the plugin settings page.
970
-     *
971
-     * @return array
972
-     */
973
-    public function app_settings_fields()
974
-    {
975
-        $default_settings = $this->defaults();
976
-
977
-        $disabled_attribute = \GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
978
-
979
-        $affiliate_link = 'https://gravityview.co/account/affiliate/?utm_source=in-plugin&utm_medium=setting&utm_content=Register as an affiliate';
980
-
981
-        $fields = [
982
-            [
983
-                'name'          => 'support-email',
984
-                'type'          => 'text',
985
-                'validate'      => 'email',
986
-                'default_value' => $default_settings['support-email'],
987
-                'label'         => __('Support Email', 'gravityview'),
988
-                'description'   => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'),
989
-                'class'         => 'code regular-text',
990
-            ],
991
-            /**
992
-             * @since 1.15 Added Support Port support
993
-             */
994
-            [
995
-                'name'          => 'support_port',
996
-                'type'          => 'radio',
997
-                'label'         => __('Show Support Port?', 'gravityview'),
998
-                'default_value' => $default_settings['support_port'],
999
-                'horizontal'    => 1,
1000
-                'choices'       => [
1001
-                    [
1002
-                        'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
1003
-                        'value' => '1',
1004
-                    ],
1005
-                    [
1006
-                        'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
1007
-                        'value' => '0',
1008
-                    ],
1009
-                ],
1010
-                'tooltip'     => '<p>'.esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview').'<img src="'.esc_url_raw(plugins_url('assets/images/beacon.png', GRAVITYVIEW_FILE)).'" alt="'.esc_attr__('The Support Port looks like this.', 'gravityview').'" class="aligncenter" style="display: block; max-width:100%; margin:1em auto;" /></p>',
1011
-                'description' => __('Show the Support Port on GravityView pages?', 'gravityview'),
1012
-            ],
1013
-            [
1014
-                'name'          => 'no-conflict-mode',
1015
-                'type'          => 'radio',
1016
-                'label'         => __('No-Conflict Mode', 'gravityview'),
1017
-                'default_value' => $default_settings['no-conflict-mode'],
1018
-                'horizontal'    => 1,
1019
-                'choices'       => [
1020
-                    [
1021
-                        'label' => _x('On', 'Setting: On or off', 'gravityview'),
1022
-                        'value' => '1',
1023
-                    ],
1024
-                    [
1025
-                        'label' => _x('Off', 'Setting: On or off', 'gravityview'),
1026
-                        'value' => '0',
1027
-                    ],
1028
-                ],
1029
-                'description'   => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview').' '.__('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
1030
-            ],
1031
-            /**
1032
-             * @since 2.0 Added REST API
1033
-             */
1034
-            gravityview()->plugin->supports(Plugin::FEATURE_REST) ?
1035
-                    [
1036
-                        'name'          => 'rest_api',
1037
-                        'type'          => 'radio',
1038
-                        'label'         => __('REST API', 'gravityview'),
1039
-                        'default_value' => $default_settings['rest_api'],
1040
-                        'horizontal'    => 1,
1041
-                        'choices'       => [
1042
-                            [
1043
-                                'label' => _x('Enable', 'Setting: Enable or Disable', 'gravityview'),
1044
-                                'value' => '1',
1045
-                            ],
1046
-                            [
1047
-                                'label' => _x('Disable', 'Setting: Enable or Disable', 'gravityview'),
1048
-                                'value' => '0',
1049
-                            ],
1050
-                        ],
1051
-                        'description'   => __('Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gravityview'),
1052
-                        'tooltip'       => '<p>'.esc_html__('If you are unsure, choose the Disable setting.', 'gravityview').'</p>',
1053
-                    ] : [],
1054
-            [
1055
-                'name'          => 'powered_by',
1056
-                'type'          => 'checkbox',
1057
-                'label'         => __('Display "Powered By" Link', 'gravityview'),
1058
-                'default_value' => $default_settings['powered_by'],
1059
-                'choices'       => [
1060
-                    [
1061
-                        'label' => esc_html__('Display a "Powered by GravityView" link', 'gravityview'),
1062
-                        'value' => '1',
1063
-                        'name'  => 'powered_by',
1064
-                    ],
1065
-                ],
1066
-                'description'   => __('When enabled, a "Powered by GravityView" link will be displayed below Views. Help us spread the word!', 'gravityview'),
1067
-            ],
1068
-            [
1069
-                'name'          => 'affiliate_id',
1070
-                'type'          => 'text',
1071
-                'input_type'    => 'number',
1072
-                'default_value' => null,
1073
-                'label'         => __('Affiliate ID', 'gravityview'),
1074
-                'description'   => sprintf(__('Earn money when people clicking your links become GravityView customers. <a href="%s" rel="external">Register as an affiliate</a>!', 'gravityview'), esc_url($affiliate_link)),
1075
-                'class'         => 'code',
1076
-                'placeholder'   => '123',
1077
-                'data-requires' => 'powered_by',
1078
-            ],
1079
-            [
1080
-                'name'          => 'beta',
1081
-                'type'          => 'checkbox',
1082
-                'label'         => __('Become a Beta Tester', 'gravityview'),
1083
-                'default_value' => $default_settings['beta'],
1084
-                'horizontal'    => 1,
1085
-                'choices'       => [
1086
-                    [
1087
-                        'label' => esc_html__('Show me beta versions if they are available.', 'gravityview'),
1088
-                        'value' => '1',
1089
-                        'name'  => 'beta',
1090
-                    ],
1091
-                ],
1092
-                'description'   => __('You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview'),
1093
-            ],
1094
-        ];
1095
-
1096
-        $fields = array_filter($fields, 'count');
1097
-
1098
-        /**
1099
-         * @filter     `gravityview_settings_fields` Filter the settings fields.
1100
-         *
1101
-         * @param array $fields The fields to filter.
1102
-         *
1103
-         * @deprecated Use `gravityview/settings/fields`.
1104
-         */
1105
-        $fields = apply_filters('gravityview_settings_fields', $fields);
1106
-
1107
-        /**
1108
-         * @filter `gravityview/settings/fields` Filter the settings fields.
1109
-         *
1110
-         * @param array $fields The fields to filter.
1111
-         */
1112
-        $fields = apply_filters('gravityview/settings/fields', $fields);
1113
-
1114
-        /**
1115
-         * Redux backward compatibility.
1116
-         *
1117
-         * @since 1.7.4
1118
-         */
1119
-        foreach ($fields as &$field) {
1120
-            $field['name'] = isset($field['name']) ? $field['name'] : Utils::get($field, 'id');
1121
-            $field['label'] = isset($field['label']) ? $field['label'] : Utils::get($field, 'title');
1122
-            $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : Utils::get($field, 'default');
1123
-            $field['description'] = isset($field['description']) ? $field['description'] : Utils::get($field, 'subtitle');
1124
-
1125
-            if ($disabled_attribute) {
1126
-                $field['disabled'] = $disabled_attribute;
1127
-            }
1128
-
1129
-            if (empty($field['disabled'])) {
1130
-                unset($field['disabled']);
1131
-            }
1132
-        }
1133
-
1134
-        $license_fields = [
1135
-            [
1136
-                'name'              => 'license_key',
1137
-                'required'          => !defined('GRAVITYVIEW_LICENSE_KEY') || !GRAVITYVIEW_LICENSE_KEY,
1138
-                'label'             => __('License Key', 'gravityview'),
1139
-                'description'       => __('Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview'),
1140
-                'type'              => 'edd_license',
1141
-                'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
1142
-                'default_value'     => $default_settings['license_key'],
1143
-                'class'             => ('' == $this->get('license_key')) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
1144
-            ],
1145
-            [
1146
-                'name'          => 'license_key_response',
1147
-                'default_value' => $default_settings['license_key_response'],
1148
-                'type'          => 'hidden',
1149
-            ],
1150
-            [
1151
-                'name'          => 'license_key_status',
1152
-                'default_value' => $default_settings['license_key_status'],
1153
-                'type'          => 'hidden',
1154
-            ],
1155
-        ];
1156
-
1157
-        if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1158
-            $license_fields[0] = array_merge($license_fields[0], [
1159
-                'disabled' => true,
1160
-                'title'    => __('The license key is defined by your site\'s configuration file.', 'gravityview'),
1161
-            ]);
1162
-        }
1163
-
1164
-        $sections = [];
1165
-        $version_info = '<span class="gv-version-info" title="'.sprintf(__('You are running GravityView version %s', 'gravityview'), Plugin::$version).'">Version '.esc_html(Plugin::$version).'</span>';
1166
-
1167
-        if (\gravityview()->plugin->is_GF_25()) {
1168
-            $sections[] = [
1169
-                'title'       => __('GravityView License', 'gravityview'),
1170
-                'class'       => 'gform-settings-panel--full gv-settings-panel--license',
1171
-                'description' => $version_info,
1172
-                'fields'      => $license_fields,
1173
-            ];
1174
-        } else {
1175
-            $fields = array_merge($license_fields, $fields);
1176
-
1177
-            array_unshift($fields, [
1178
-                'name'  => 'gv_header',
1179
-                'value' => $version_info,
1180
-                'type'  => 'html',
1181
-            ]);
1182
-        }
1183
-
1184
-        $sections[] = [
1185
-            'title'       => (gravityview()->plugin->is_GF_25() ? __('GravityView Settings', 'gravityview') : null),
1186
-            'class'       => 'gform-settings-panel--full gv-settings-panel--core',
1187
-            'fields'      => $fields,
1188
-        ];
1189
-
1190
-        /**
1191
-         * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
1192
-         * Extensions can tap in here to insert their own section and settings.
1193
-         * <code>
1194
-         *   $sections[] = array(
1195
-         *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
1196
-         *      'fields' => $settings,
1197
-         *   );
1198
-         * </code>
1199
-         *
1200
-         * @param array $extension_settings Empty array, ready for extension settings!
1201
-         */
1202
-        $extension_sections = apply_filters('gravityview/settings/extension/sections', []);
1203
-
1204
-        // If there are extensions, add a section for them
1205
-        if (!empty($extension_sections)) {
1206
-            if ($disabled_attribute) {
1207
-                foreach ($extension_sections as &$section) {
1208
-                    foreach ($section['fields'] as &$field) {
1209
-                        $field['disabled'] = $disabled_attribute;
1210
-                    }
1211
-                }
1212
-            }
1213
-
1214
-            $sections = array_merge($sections, $extension_sections);
1215
-        }
1216
-
1217
-        return $sections;
1218
-    }
1219
-
1220
-    /**
1221
-     * Updates app settings with the provided settings.
1222
-     *
1223
-     * Same as the GFAddon, except it returns the value from update_option()
1224
-     *
1225
-     * @param array $settings - App settings to be saved
1226
-     *
1227
-     * @return bool False if value was not updated and true if value was updated.
1228
-     *
1229
-     * @deprecated Use \GV\Addon_Settings::set or \GV\Addon_Settings::update
1230
-     */
1231
-    public function update_app_settings($settings)
1232
-    {
1233
-        return $this->update($settings);
1234
-    }
1235
-
1236
-    /**
1237
-     * Sets a subset of settings.
1238
-     *
1239
-     * @param array|string An array of settings to update, or string (key) and $value to update one setting.
1240
-     * @param mixed $value A value if $settings is string (key). Default: null.
1241
-     */
1242
-    public function set($settings, $value = null)
1243
-    {
1244
-        if (is_string($settings)) {
1245
-            $settings = [$settings => $value];
1246
-        }
1247
-        $settings = wp_parse_args($settings, $this->all());
1248
-
1249
-        return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1250
-    }
1251
-
1252
-    /**
1253
-     * Updates settings.
1254
-     *
1255
-     * @param array $settings The settings array.
1256
-     *
1257
-     * @return bool False if value was not updated and true if value was updated.
1258
-     */
1259
-    public function update($settings)
1260
-    {
1261
-        return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1262
-    }
1263
-
1264
-    /**
1265
-     * Register the settings field for the EDD License field type.
1266
-     *
1267
-     * @param array $field
1268
-     * @param bool  $echo  Whether to echo the
1269
-     *
1270
-     * @return string
1271
-     */
1272
-    public function settings_edd_license($field, $echo = true)
1273
-    {
1274
-        if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1275
-            $field['input_type'] = 'password';
1276
-        }
1277
-
1278
-        $text = $this->settings_text($field, false);
1279
-
1280
-        $activation = $this->License_Handler->settings_edd_license_activation($field, false);
1281
-
1282
-        $return = $text.$activation;
1283
-
1284
-        $return .= $this->get_license_handler()->license_details(\GV\Addon_Settings::get('license_key_response'));
1285
-
1286
-        if ($echo) {
1287
-            echo $return;
1288
-        }
1289
-
1290
-        return $return;
1291
-    }
1292
-
1293
-    /**
1294
-     * Allow pure HTML settings row.
1295
-     *
1296
-     * @since 2.0.6
1297
-     *
1298
-     * @param array $field
1299
-     * @param bool  $echo  Whether to echo the
1300
-     *
1301
-     * @return string
1302
-     */
1303
-    protected function settings_html($field, $echo = true)
1304
-    {
1305
-        $return = \GV\Utils::get($field, 'value', '');
1306
-
1307
-        if ($echo) {
1308
-            echo $return;
1309
-        }
718
+				implode(' ', $attributes).
719
+				' />';
720
+
721
+		if ($echo) {
722
+			echo $html;
723
+		}
724
+
725
+		return $html;
726
+	}
727
+
728
+	/**
729
+	 * @deprecated Use \GV\Addon_Settings::as_html
730
+	 */
731
+	public function settings_submit($field, $echo = true)
732
+	{
733
+		gravityview()->log->warning('\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html');
734
+
735
+		return $this->as_html($field, $echo);
736
+	}
737
+
738
+	/**
739
+	 * Check whether GravityView is being saved.
740
+	 *
741
+	 * The generic is_save_postback() is true for all addons
742
+	 *
743
+	 * @since 2.0.8
744
+	 *
745
+	 * @return bool
746
+	 */
747
+	public function is_save_postback()
748
+	{
749
+		return isset($_POST['gform-settings-save']) && isset($_POST['_gravityview_save_settings_nonce']);
750
+	}
751
+
752
+	/**
753
+	 * Display a notice if the plugin is inactive.
754
+	 *
755
+	 * @return void
756
+	 */
757
+	public function license_key_notice()
758
+	{
759
+		if ('uninstall' === rgget('view')) {
760
+			return; // Do not display license notice on the uninstall page in GF 2.5
761
+		}
762
+
763
+		if ($this->is_save_postback()) {
764
+			$settings = $this->get_posted_settings();
765
+			$license_key = defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get($settings, 'license_key');
766
+			$license_status = \GV\Utils::get($settings, 'license_key_status', 'inactive');
767
+		} else {
768
+			$license_status = $this->get('license_key_status', 'inactive');
769
+			$license_key = $this->get('license_key');
770
+		}
771
+
772
+		if (empty($license_key)) {
773
+			$license_id = 'license';
774
+			$license_status = '';
775
+		} else {
776
+			$license_id = $license_key;
777
+		}
778
+
779
+		$message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
780
+
781
+		/** @internal Do not use! Will change without notice (pun slightly intended). */
782
+		$message = apply_filters('gravityview/settings/license-key-notice', $message);
783
+
784
+		/**
785
+		 * I wanted to remove the period from after the buttons in the string,
786
+		 * but didn't want to mess up the translation strings for the translators.
787
+		 */
788
+		$message = mb_substr($message, 0, mb_strlen($message) - 1);
789
+		$title = __('Inactive License', 'gravityview');
790
+		$status = '';
791
+		$update_below = false;
792
+		$primary_button_link = admin_url('edit.php?post_type=gravityview&amp;page=gravityview_settings');
793
+
794
+		switch ($license_status) {
795
+			/** @since 1.17 */
796
+			case 'expired':
797
+				$title = __('Expired License', 'gravityview');
798
+				$status = __('has expired', 'gravityview');
799
+				$message = $this->get_license_handler()->strings('expired', $this->get('license_key_response'));
800
+				break;
801
+			case 'invalid':
802
+				$title = __('Invalid License', 'gravityview');
803
+				$status = __('is invalid', 'gravityview');
804
+				break;
805
+			case 'deactivated':
806
+				$status = __('is inactive', 'gravityview');
807
+				$update_below = __('Activate your license key below.', 'gravityview');
808
+				break;
809
+			/** @noinspection PhpMissingBreakStatementInspection */
810
+			case '':
811
+				$license_status = 'site_inactive';
812
+			// break intentionally left blank
813
+			case 'inactive':
814
+			case 'site_inactive':
815
+				$status = __('has not been activated', 'gravityview');
816
+				$update_below = __('Activate your license key below.', 'gravityview');
817
+				break;
818
+		}
819
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
820
+
821
+		// Show a different notice on settings page for inactive licenses (hide the buttons)
822
+		if ($update_below && gravityview()->request->is_admin('', 'settings')) {
823
+			$message = sprintf($message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">'.$update_below.'</a>');
824
+		} else {
825
+			$message = sprintf($message, $status, "\n\n".'<a href="'.esc_url($primary_button_link).'" class="button button-primary primary">', '</a>', '<a href="'.esc_url($url).'" class="button button-secondary">', '</a>');
826
+		}
827
+
828
+		if (empty($status)) {
829
+			return;
830
+		}
831
+
832
+		\GravityView_Admin_Notices::add_notice([
833
+			'message' => $message,
834
+			'class'   => 'notice notice-warning gv-license-warning',
835
+			'title'   => $title,
836
+			'cap'     => 'gravityview_edit_settings',
837
+			'dismiss' => sha1($license_status.'_'.$license_id.'_'.date('z')), // Show every day, instead of every 8 weeks (which is the default)
838
+		]);
839
+	}
840
+
841
+	/**
842
+	 * Allow public access to the GV\License_Handler class.
843
+	 *
844
+	 * @since 1.7.4
845
+	 *
846
+	 * @return \GV\License_Handler
847
+	 */
848
+	public function get_license_handler()
849
+	{
850
+		return $this->License_Handler;
851
+	}
852
+
853
+	/**
854
+	 * Add tooltip script to app settings page. Not enqueued by Gravity Forms for some reason.
855
+	 *
856
+	 * @since 1.21.5
857
+	 * @see   GFAddOn::scripts()
858
+	 *
859
+	 * @return array Array of scripts
860
+	 */
861
+	public function scripts()
862
+	{
863
+		$scripts = parent::scripts();
864
+
865
+		$scripts[] = [
866
+			'handle'  => 'gform_tooltip_init',
867
+			'enqueue' => [
868
+				[
869
+					'admin_page' => ['app_settings'],
870
+				],
871
+			],
872
+		];
873
+
874
+		return $scripts;
875
+	}
876
+
877
+	/**
878
+	 * Register styles in the app admin page.
879
+	 *
880
+	 * @return array
881
+	 */
882
+	public function styles()
883
+	{
884
+		$styles = parent::styles();
885
+
886
+		$deps = [
887
+			'gform_admin',
888
+			'gaddon_form_settings_css',
889
+			'gform_font_awesome',
890
+		];
891
+
892
+		// This file was removed from 2.5
893
+		if (!gravityview()->plugin->is_GF_25()) {
894
+			$deps[] = 'gform_tooltip';
895
+		}
896
+
897
+		$styles[] = [
898
+			'handle'  => 'gravityview_settings',
899
+			'src'     => plugins_url('assets/css/admin-settings.css', GRAVITYVIEW_FILE),
900
+			'version' => Plugin::$version,
901
+			'deps'    => $deps,
902
+			'enqueue' => [
903
+				[
904
+					'admin_page' => [
905
+						'app_settings',
906
+						'plugin_settings',
907
+					],
908
+				],
909
+			],
910
+		];
911
+
912
+		return $styles;
913
+	}
914
+
915
+	/**
916
+	 * Does the current site have its own settings?
917
+	 *
918
+	 * - If not multisite, returns true.
919
+	 * - If multisite and the plugin is network activated, returns true; we need to register the submenu page for the Network Admin settings to work.
920
+	 * - If multisite and not network admin, return false.
921
+	 *
922
+	 * @since 2.8.2
923
+	 *
924
+	 * @return bool
925
+	 */
926
+	private function has_site_settings()
927
+	{
928
+		return (!is_multisite()) || is_main_site() || (!gravityview()->plugin->is_network_activated()) || (is_network_admin() && gravityview()->plugin->is_network_activated());
929
+	}
930
+
931
+	/**
932
+	 * Add Settings link to GravityView menu.
933
+	 *
934
+	 * @return void
935
+	 */
936
+	public function create_app_menu()
937
+	{
938
+
939
+		/**
940
+		 * Override whether to show the Settings menu on a per-blog basis.
941
+		 *
942
+		 * @since 1.7.6
943
+		 *
944
+		 * @param bool $hide_if_network_activated Default: true
945
+		 */
946
+		$show_submenu = apply_filters('gravityview/show-settings-menu', $this->has_site_settings());
947
+
948
+		if (!$show_submenu) {
949
+			return;
950
+		}
951
+
952
+		add_submenu_page('edit.php?post_type=gravityview', __('Settings', 'gravityview'), __('Settings', 'gravityview'), $this->_capabilities_app_settings, $this->_slug.'_settings', [$this, 'app_tab_page']);
953
+	}
954
+
955
+	/**
956
+	 * Gets the required indicator
957
+	 * Gets the markup of the required indicator symbol to highlight fields that are required.
958
+	 *
959
+	 * @param $field - The field meta.
960
+	 *
961
+	 * @return string - Returns markup of the required indicator symbol
962
+	 */
963
+	public function get_required_indicator($field)
964
+	{
965
+		return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>';
966
+	}
967
+
968
+	/**
969
+	 * Specify the settings fields to be rendered on the plugin settings page.
970
+	 *
971
+	 * @return array
972
+	 */
973
+	public function app_settings_fields()
974
+	{
975
+		$default_settings = $this->defaults();
976
+
977
+		$disabled_attribute = \GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
978
+
979
+		$affiliate_link = 'https://gravityview.co/account/affiliate/?utm_source=in-plugin&utm_medium=setting&utm_content=Register as an affiliate';
980
+
981
+		$fields = [
982
+			[
983
+				'name'          => 'support-email',
984
+				'type'          => 'text',
985
+				'validate'      => 'email',
986
+				'default_value' => $default_settings['support-email'],
987
+				'label'         => __('Support Email', 'gravityview'),
988
+				'description'   => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'),
989
+				'class'         => 'code regular-text',
990
+			],
991
+			/**
992
+			 * @since 1.15 Added Support Port support
993
+			 */
994
+			[
995
+				'name'          => 'support_port',
996
+				'type'          => 'radio',
997
+				'label'         => __('Show Support Port?', 'gravityview'),
998
+				'default_value' => $default_settings['support_port'],
999
+				'horizontal'    => 1,
1000
+				'choices'       => [
1001
+					[
1002
+						'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
1003
+						'value' => '1',
1004
+					],
1005
+					[
1006
+						'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
1007
+						'value' => '0',
1008
+					],
1009
+				],
1010
+				'tooltip'     => '<p>'.esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview').'<img src="'.esc_url_raw(plugins_url('assets/images/beacon.png', GRAVITYVIEW_FILE)).'" alt="'.esc_attr__('The Support Port looks like this.', 'gravityview').'" class="aligncenter" style="display: block; max-width:100%; margin:1em auto;" /></p>',
1011
+				'description' => __('Show the Support Port on GravityView pages?', 'gravityview'),
1012
+			],
1013
+			[
1014
+				'name'          => 'no-conflict-mode',
1015
+				'type'          => 'radio',
1016
+				'label'         => __('No-Conflict Mode', 'gravityview'),
1017
+				'default_value' => $default_settings['no-conflict-mode'],
1018
+				'horizontal'    => 1,
1019
+				'choices'       => [
1020
+					[
1021
+						'label' => _x('On', 'Setting: On or off', 'gravityview'),
1022
+						'value' => '1',
1023
+					],
1024
+					[
1025
+						'label' => _x('Off', 'Setting: On or off', 'gravityview'),
1026
+						'value' => '0',
1027
+					],
1028
+				],
1029
+				'description'   => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview').' '.__('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
1030
+			],
1031
+			/**
1032
+			 * @since 2.0 Added REST API
1033
+			 */
1034
+			gravityview()->plugin->supports(Plugin::FEATURE_REST) ?
1035
+					[
1036
+						'name'          => 'rest_api',
1037
+						'type'          => 'radio',
1038
+						'label'         => __('REST API', 'gravityview'),
1039
+						'default_value' => $default_settings['rest_api'],
1040
+						'horizontal'    => 1,
1041
+						'choices'       => [
1042
+							[
1043
+								'label' => _x('Enable', 'Setting: Enable or Disable', 'gravityview'),
1044
+								'value' => '1',
1045
+							],
1046
+							[
1047
+								'label' => _x('Disable', 'Setting: Enable or Disable', 'gravityview'),
1048
+								'value' => '0',
1049
+							],
1050
+						],
1051
+						'description'   => __('Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gravityview'),
1052
+						'tooltip'       => '<p>'.esc_html__('If you are unsure, choose the Disable setting.', 'gravityview').'</p>',
1053
+					] : [],
1054
+			[
1055
+				'name'          => 'powered_by',
1056
+				'type'          => 'checkbox',
1057
+				'label'         => __('Display "Powered By" Link', 'gravityview'),
1058
+				'default_value' => $default_settings['powered_by'],
1059
+				'choices'       => [
1060
+					[
1061
+						'label' => esc_html__('Display a "Powered by GravityView" link', 'gravityview'),
1062
+						'value' => '1',
1063
+						'name'  => 'powered_by',
1064
+					],
1065
+				],
1066
+				'description'   => __('When enabled, a "Powered by GravityView" link will be displayed below Views. Help us spread the word!', 'gravityview'),
1067
+			],
1068
+			[
1069
+				'name'          => 'affiliate_id',
1070
+				'type'          => 'text',
1071
+				'input_type'    => 'number',
1072
+				'default_value' => null,
1073
+				'label'         => __('Affiliate ID', 'gravityview'),
1074
+				'description'   => sprintf(__('Earn money when people clicking your links become GravityView customers. <a href="%s" rel="external">Register as an affiliate</a>!', 'gravityview'), esc_url($affiliate_link)),
1075
+				'class'         => 'code',
1076
+				'placeholder'   => '123',
1077
+				'data-requires' => 'powered_by',
1078
+			],
1079
+			[
1080
+				'name'          => 'beta',
1081
+				'type'          => 'checkbox',
1082
+				'label'         => __('Become a Beta Tester', 'gravityview'),
1083
+				'default_value' => $default_settings['beta'],
1084
+				'horizontal'    => 1,
1085
+				'choices'       => [
1086
+					[
1087
+						'label' => esc_html__('Show me beta versions if they are available.', 'gravityview'),
1088
+						'value' => '1',
1089
+						'name'  => 'beta',
1090
+					],
1091
+				],
1092
+				'description'   => __('You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview'),
1093
+			],
1094
+		];
1095
+
1096
+		$fields = array_filter($fields, 'count');
1097
+
1098
+		/**
1099
+		 * @filter     `gravityview_settings_fields` Filter the settings fields.
1100
+		 *
1101
+		 * @param array $fields The fields to filter.
1102
+		 *
1103
+		 * @deprecated Use `gravityview/settings/fields`.
1104
+		 */
1105
+		$fields = apply_filters('gravityview_settings_fields', $fields);
1106
+
1107
+		/**
1108
+		 * @filter `gravityview/settings/fields` Filter the settings fields.
1109
+		 *
1110
+		 * @param array $fields The fields to filter.
1111
+		 */
1112
+		$fields = apply_filters('gravityview/settings/fields', $fields);
1113
+
1114
+		/**
1115
+		 * Redux backward compatibility.
1116
+		 *
1117
+		 * @since 1.7.4
1118
+		 */
1119
+		foreach ($fields as &$field) {
1120
+			$field['name'] = isset($field['name']) ? $field['name'] : Utils::get($field, 'id');
1121
+			$field['label'] = isset($field['label']) ? $field['label'] : Utils::get($field, 'title');
1122
+			$field['default_value'] = isset($field['default_value']) ? $field['default_value'] : Utils::get($field, 'default');
1123
+			$field['description'] = isset($field['description']) ? $field['description'] : Utils::get($field, 'subtitle');
1124
+
1125
+			if ($disabled_attribute) {
1126
+				$field['disabled'] = $disabled_attribute;
1127
+			}
1310 1128
 
1311
-        return $return;
1312
-    }
1129
+			if (empty($field['disabled'])) {
1130
+				unset($field['disabled']);
1131
+			}
1132
+		}
1133
+
1134
+		$license_fields = [
1135
+			[
1136
+				'name'              => 'license_key',
1137
+				'required'          => !defined('GRAVITYVIEW_LICENSE_KEY') || !GRAVITYVIEW_LICENSE_KEY,
1138
+				'label'             => __('License Key', 'gravityview'),
1139
+				'description'       => __('Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview'),
1140
+				'type'              => 'edd_license',
1141
+				'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
1142
+				'default_value'     => $default_settings['license_key'],
1143
+				'class'             => ('' == $this->get('license_key')) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
1144
+			],
1145
+			[
1146
+				'name'          => 'license_key_response',
1147
+				'default_value' => $default_settings['license_key_response'],
1148
+				'type'          => 'hidden',
1149
+			],
1150
+			[
1151
+				'name'          => 'license_key_status',
1152
+				'default_value' => $default_settings['license_key_status'],
1153
+				'type'          => 'hidden',
1154
+			],
1155
+		];
1156
+
1157
+		if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1158
+			$license_fields[0] = array_merge($license_fields[0], [
1159
+				'disabled' => true,
1160
+				'title'    => __('The license key is defined by your site\'s configuration file.', 'gravityview'),
1161
+			]);
1162
+		}
1163
+
1164
+		$sections = [];
1165
+		$version_info = '<span class="gv-version-info" title="'.sprintf(__('You are running GravityView version %s', 'gravityview'), Plugin::$version).'">Version '.esc_html(Plugin::$version).'</span>';
1166
+
1167
+		if (\gravityview()->plugin->is_GF_25()) {
1168
+			$sections[] = [
1169
+				'title'       => __('GravityView License', 'gravityview'),
1170
+				'class'       => 'gform-settings-panel--full gv-settings-panel--license',
1171
+				'description' => $version_info,
1172
+				'fields'      => $license_fields,
1173
+			];
1174
+		} else {
1175
+			$fields = array_merge($license_fields, $fields);
1176
+
1177
+			array_unshift($fields, [
1178
+				'name'  => 'gv_header',
1179
+				'value' => $version_info,
1180
+				'type'  => 'html',
1181
+			]);
1182
+		}
1183
+
1184
+		$sections[] = [
1185
+			'title'       => (gravityview()->plugin->is_GF_25() ? __('GravityView Settings', 'gravityview') : null),
1186
+			'class'       => 'gform-settings-panel--full gv-settings-panel--core',
1187
+			'fields'      => $fields,
1188
+		];
1189
+
1190
+		/**
1191
+		 * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
1192
+		 * Extensions can tap in here to insert their own section and settings.
1193
+		 * <code>
1194
+		 *   $sections[] = array(
1195
+		 *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
1196
+		 *      'fields' => $settings,
1197
+		 *   );
1198
+		 * </code>
1199
+		 *
1200
+		 * @param array $extension_settings Empty array, ready for extension settings!
1201
+		 */
1202
+		$extension_sections = apply_filters('gravityview/settings/extension/sections', []);
1203
+
1204
+		// If there are extensions, add a section for them
1205
+		if (!empty($extension_sections)) {
1206
+			if ($disabled_attribute) {
1207
+				foreach ($extension_sections as &$section) {
1208
+					foreach ($section['fields'] as &$field) {
1209
+						$field['disabled'] = $disabled_attribute;
1210
+					}
1211
+				}
1212
+			}
1313 1213
 
1314
-    /**
1315
-     * No <th> needed for pure HTML settings row.
1316
-     *
1317
-     * @since 2.0.6
1318
-     *
1319
-     * @param array $field
1320
-     *
1321
-     * @return void
1322
-     */
1323
-    public function single_setting_row_html($field)
1324
-    {
1325
-        ?>
1214
+			$sections = array_merge($sections, $extension_sections);
1215
+		}
1216
+
1217
+		return $sections;
1218
+	}
1219
+
1220
+	/**
1221
+	 * Updates app settings with the provided settings.
1222
+	 *
1223
+	 * Same as the GFAddon, except it returns the value from update_option()
1224
+	 *
1225
+	 * @param array $settings - App settings to be saved
1226
+	 *
1227
+	 * @return bool False if value was not updated and true if value was updated.
1228
+	 *
1229
+	 * @deprecated Use \GV\Addon_Settings::set or \GV\Addon_Settings::update
1230
+	 */
1231
+	public function update_app_settings($settings)
1232
+	{
1233
+		return $this->update($settings);
1234
+	}
1235
+
1236
+	/**
1237
+	 * Sets a subset of settings.
1238
+	 *
1239
+	 * @param array|string An array of settings to update, or string (key) and $value to update one setting.
1240
+	 * @param mixed $value A value if $settings is string (key). Default: null.
1241
+	 */
1242
+	public function set($settings, $value = null)
1243
+	{
1244
+		if (is_string($settings)) {
1245
+			$settings = [$settings => $value];
1246
+		}
1247
+		$settings = wp_parse_args($settings, $this->all());
1248
+
1249
+		return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1250
+	}
1251
+
1252
+	/**
1253
+	 * Updates settings.
1254
+	 *
1255
+	 * @param array $settings The settings array.
1256
+	 *
1257
+	 * @return bool False if value was not updated and true if value was updated.
1258
+	 */
1259
+	public function update($settings)
1260
+	{
1261
+		return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1262
+	}
1263
+
1264
+	/**
1265
+	 * Register the settings field for the EDD License field type.
1266
+	 *
1267
+	 * @param array $field
1268
+	 * @param bool  $echo  Whether to echo the
1269
+	 *
1270
+	 * @return string
1271
+	 */
1272
+	public function settings_edd_license($field, $echo = true)
1273
+	{
1274
+		if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1275
+			$field['input_type'] = 'password';
1276
+		}
1277
+
1278
+		$text = $this->settings_text($field, false);
1279
+
1280
+		$activation = $this->License_Handler->settings_edd_license_activation($field, false);
1281
+
1282
+		$return = $text.$activation;
1283
+
1284
+		$return .= $this->get_license_handler()->license_details(\GV\Addon_Settings::get('license_key_response'));
1285
+
1286
+		if ($echo) {
1287
+			echo $return;
1288
+		}
1289
+
1290
+		return $return;
1291
+	}
1292
+
1293
+	/**
1294
+	 * Allow pure HTML settings row.
1295
+	 *
1296
+	 * @since 2.0.6
1297
+	 *
1298
+	 * @param array $field
1299
+	 * @param bool  $echo  Whether to echo the
1300
+	 *
1301
+	 * @return string
1302
+	 */
1303
+	protected function settings_html($field, $echo = true)
1304
+	{
1305
+		$return = \GV\Utils::get($field, 'value', '');
1306
+
1307
+		if ($echo) {
1308
+			echo $return;
1309
+		}
1310
+
1311
+		return $return;
1312
+	}
1313
+
1314
+	/**
1315
+	 * No <th> needed for pure HTML settings row.
1316
+	 *
1317
+	 * @since 2.0.6
1318
+	 *
1319
+	 * @param array $field
1320
+	 *
1321
+	 * @return void
1322
+	 */
1323
+	public function single_setting_row_html($field)
1324
+	{
1325
+		?>
1326 1326
 
1327 1327
 		<tr id="gaddon-setting-row-<?php echo esc_attr($field['name']); ?>">
1328 1328
 			<td colspan="2">
@@ -1331,95 +1331,95 @@  discard block
 block discarded – undo
1331 1331
 		</tr>
1332 1332
 
1333 1333
 		<?php
1334
-    }
1334
+	}
1335
+
1336
+	/**
1337
+	 * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it.
1338
+	 *
1339
+	 * Converts `$field['description']` to `$field['gv_description']`
1340
+	 * Converts `$field['subtitle']` to `$field['description']`
1341
+	 *
1342
+	 * @since 1.21.5.2
1343
+	 * @see   http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description
1344
+	 * @see   \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description`
1345
+	 *
1346
+	 * @param array $field
1347
+	 *
1348
+	 * @return void
1349
+	 */
1350
+	public function single_setting_row($field)
1351
+	{
1352
+		$field['gv_description'] = Utils::get($field, 'description');
1353
+		$field['description'] = Utils::get($field, 'subtitle');
1354
+		parent::single_setting_row($field);
1355
+	}
1356
+
1357
+	/**
1358
+	 * The same as the parent, except added support for field descriptions.
1359
+	 *
1360
+	 * @inheritDoc
1361
+	 *
1362
+	 * @param $field array
1363
+	 */
1364
+	public function single_setting_label($field)
1365
+	{
1366
+		parent::single_setting_label($field);
1367
+		if ($description = Utils::get($field, 'gv_description')) {
1368
+			echo '<span class="description">'.$description.'</span>';
1369
+		}
1370
+	}
1371
+
1372
+	/**
1373
+	 * Check for the `gravityview_edit_settings` capability before saving plugin settings.
1374
+	 * Gravity Forms says you're able to edit if you're able to view settings. GravityView allows two different permissions.
1375
+	 *
1376
+	 * @since 1.15
1377
+	 *
1378
+	 * @return void
1379
+	 */
1380
+	public function maybe_save_app_settings()
1381
+	{
1382
+		if ($this->is_save_postback()) {
1383
+			if (!\GVCommon::has_cap('gravityview_edit_settings')) {
1384
+				$_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
1385
+				\GFCommon::add_error_message(__('You don\'t have the ability to edit plugin settings.', 'gravityview'));
1386
+
1387
+				return;
1388
+			}
1389
+		}
1390
+		parent::maybe_save_app_settings();
1391
+	}
1335 1392
 
1336
-    /**
1337
-     * Keep GravityView styling for `$field['description']`, even though Gravity Forms added support for it.
1338
-     *
1339
-     * Converts `$field['description']` to `$field['gv_description']`
1340
-     * Converts `$field['subtitle']` to `$field['description']`
1341
-     *
1342
-     * @since 1.21.5.2
1343
-     * @see   http://share.gravityview.co/P28uGp/2OIRKxog for image that shows subtitle vs description
1344
-     * @see   \GV\Addon_Settings::single_setting_label Converts `gv_description` back to `description`
1345
-     *
1346
-     * @param array $field
1347
-     *
1348
-     * @return void
1349
-     */
1350
-    public function single_setting_row($field)
1351
-    {
1352
-        $field['gv_description'] = Utils::get($field, 'description');
1353
-        $field['description'] = Utils::get($field, 'subtitle');
1354
-        parent::single_setting_row($field);
1355
-    }
1356
-
1357
-    /**
1358
-     * The same as the parent, except added support for field descriptions.
1359
-     *
1360
-     * @inheritDoc
1361
-     *
1362
-     * @param $field array
1363
-     */
1364
-    public function single_setting_label($field)
1365
-    {
1366
-        parent::single_setting_label($field);
1367
-        if ($description = Utils::get($field, 'gv_description')) {
1368
-            echo '<span class="description">'.$description.'</span>';
1369
-        }
1370
-    }
1371
-
1372
-    /**
1373
-     * Check for the `gravityview_edit_settings` capability before saving plugin settings.
1374
-     * Gravity Forms says you're able to edit if you're able to view settings. GravityView allows two different permissions.
1375
-     *
1376
-     * @since 1.15
1377
-     *
1378
-     * @return void
1379
-     */
1380
-    public function maybe_save_app_settings()
1381
-    {
1382
-        if ($this->is_save_postback()) {
1383
-            if (!\GVCommon::has_cap('gravityview_edit_settings')) {
1384
-                $_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
1385
-                \GFCommon::add_error_message(__('You don\'t have the ability to edit plugin settings.', 'gravityview'));
1386
-
1387
-                return;
1388
-            }
1389
-        }
1390
-        parent::maybe_save_app_settings();
1391
-    }
1392
-
1393
-    /**
1394
-     * When the settings are saved, make sure the license key matches the previously activated key.
1395
-     *
1396
-     * @return array settings from parent::get_posted_settings(), with `license_key_response` and `license_key_status` potentially unset
1397
-     */
1398
-    public function get_posted_settings()
1399
-    {
1400
-        $posted_settings = parent::get_posted_settings();
1393
+	/**
1394
+	 * When the settings are saved, make sure the license key matches the previously activated key.
1395
+	 *
1396
+	 * @return array settings from parent::get_posted_settings(), with `license_key_response` and `license_key_status` potentially unset
1397
+	 */
1398
+	public function get_posted_settings()
1399
+	{
1400
+		$posted_settings = parent::get_posted_settings();
1401 1401
 
1402
-        $local_key = Utils::get($posted_settings, 'license_key');
1402
+		$local_key = Utils::get($posted_settings, 'license_key');
1403 1403
 
1404
-        if (!$local_key && defined('GRAVITYVIEW_LICENSE_KEY')) {
1405
-            $local_key = GRAVITYVIEW_LICENSE_KEY;
1406
-        }
1404
+		if (!$local_key && defined('GRAVITYVIEW_LICENSE_KEY')) {
1405
+			$local_key = GRAVITYVIEW_LICENSE_KEY;
1406
+		}
1407 1407
 
1408
-        $response_key = Utils::get($posted_settings, 'license_key_response/license_key');
1408
+		$response_key = Utils::get($posted_settings, 'license_key_response/license_key');
1409 1409
 
1410
-        static $added_message = false;
1410
+		static $added_message = false;
1411 1411
 
1412
-        // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1413
-        // then we assume it's changed. If it's changed, unset the status and the previous response.
1414
-        if (!$added_message && ($local_key !== $response_key)) {
1415
-            unset($posted_settings['license_key_response']);
1416
-            unset($posted_settings['license_key_status']);
1412
+		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1413
+		// then we assume it's changed. If it's changed, unset the status and the previous response.
1414
+		if (!$added_message && ($local_key !== $response_key)) {
1415
+			unset($posted_settings['license_key_response']);
1416
+			unset($posted_settings['license_key_status']);
1417 1417
 
1418
-            \GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview'));
1418
+			\GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview'));
1419 1419
 
1420
-            $added_message = true;
1421
-        }
1420
+			$added_message = true;
1421
+		}
1422 1422
 
1423
-        return $posted_settings;
1424
-    }
1423
+		return $posted_settings;
1424
+	}
1425 1425
 }
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
 use GV\Shortcodes\gravityview;
6 6
 
7 7
 /** If this file is called directly, abort. */
8
-if (!defined('GRAVITYVIEW_DIR')) {
8
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
9 9
     exit();
10 10
 }
11 11
 
12
-if (!class_exists('\GFAddOn')) {
12
+if ( ! class_exists( '\GFAddOn' ) ) {
13 13
     return;
14 14
 }
15 15
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         /**
74 74
          * Hook everywhere, but only once.
75 75
          */
76
-        if (!self::$initialized) {
76
+        if ( ! self::$initialized ) {
77 77
             parent::__construct();
78 78
             self::$initialized = true;
79 79
         }
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $this->_load_license_handler();
92 92
 
93
-        add_filter('admin_body_class', [$this, 'body_class']);
93
+        add_filter( 'admin_body_class', [ $this, 'body_class' ] );
94 94
 
95
-        add_action('admin_head', [$this, 'license_key_notice']);
95
+        add_action( 'admin_head', [ $this, 'license_key_notice' ] );
96 96
 
97
-        add_filter('gform_addon_app_settings_menu_gravityview', [$this, 'modify_app_settings_menu_title']);
97
+        add_filter( 'gform_addon_app_settings_menu_gravityview', [ $this, 'modify_app_settings_menu_title' ] );
98 98
 
99
-        add_filter('gform_settings_save_button', [$this, 'modify_gform_settings_save_button'], 10, 2);
99
+        add_filter( 'gform_settings_save_button', [ $this, 'modify_gform_settings_save_button' ], 10, 2 );
100 100
 
101 101
         /** @since 1.7.6 */
102
-        add_action('network_admin_menu', [$this, 'add_network_menu']);
102
+        add_action( 'network_admin_menu', [ $this, 'add_network_menu' ] );
103 103
 
104
-        add_filter('gravityview_noconflict_styles', [$this, 'register_no_conflict']);
104
+        add_filter( 'gravityview_noconflict_styles', [ $this, 'register_no_conflict' ] );
105 105
 
106 106
         parent::init_admin();
107 107
     }
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $setting_tabs = parent::get_app_settings_tabs();
119 119
 
120
-        foreach ($setting_tabs as &$tab) {
121
-            if ('uninstall' !== $tab['name']) {
120
+        foreach ( $setting_tabs as &$tab ) {
121
+            if ( 'uninstall' !== $tab[ 'name' ] ) {
122 122
                 continue;
123 123
             }
124 124
 
125 125
             // Do not display uninstall tab if user is lacking permissions/this is a multisite
126
-            if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
126
+            if ( ! ( $this->current_user_can_any( $this->_capabilities_uninstall ) && ( ! function_exists( 'is_multisite' ) || ! is_multisite() || is_super_admin() ) ) ) {
127 127
                 $tab = null;
128 128
                 continue;
129 129
             }
130 130
 
131 131
             // Add trash can icon to resemble the look and feel of the GF Settings page
132
-            $tab['icon'] = 'dashicons-trash';
132
+            $tab[ 'icon' ] = 'dashicons-trash';
133 133
         }
134 134
 
135
-        return array_filter($setting_tabs);
135
+        return array_filter( $setting_tabs );
136 136
     }
137 137
 
138 138
     /**
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      *
143 143
      * @return array
144 144
      */
145
-    public function register_no_conflict($items)
145
+    public function register_no_conflict( $items )
146 146
     {
147
-        $items[] = 'gform_settings';
148
-        $items[] = 'gv-admin-edd-license';
147
+        $items[ ] = 'gform_settings';
148
+        $items[ ] = 'gv-admin-edd-license';
149 149
 
150 150
         return $items;
151 151
     }
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
      *
158 158
      * @return string
159 159
      */
160
-    public function body_class($css_class)
160
+    public function body_class( $css_class )
161 161
     {
162
-        if (!gravityview()->request->is_admin('', 'settings')) {
162
+        if ( ! gravityview()->request->is_admin( '', 'settings' ) ) {
163 163
             return $css_class;
164 164
         }
165 165
 
166
-        if (gravityview()->plugin->is_GF_25()) {
166
+        if ( gravityview()->plugin->is_GF_25() ) {
167 167
             $css_class .= ' gf-2-5';
168 168
         }
169 169
 
@@ -178,25 +178,25 @@  discard block
 block discarded – undo
178 178
      * @param string                                     $html      HTML of the save button.
179 179
      * @param \Gravity_Forms\Gravity_Forms\Settings|null $framework Current instance of the Settings Framework. Or null if < 2.5.
180 180
      */
181
-    public function modify_gform_settings_save_button($html, $framework = null)
181
+    public function modify_gform_settings_save_button( $html, $framework = null )
182 182
     {
183
-        if (!gravityview()->request->is_admin('', 'settings')) {
183
+        if ( ! gravityview()->request->is_admin( '', 'settings' ) ) {
184 184
             return $html;
185 185
         }
186 186
 
187
-        if (!($this->current_user_can_any($this->_capabilities_uninstall) && (!function_exists('is_multisite') || !is_multisite() || is_super_admin()))) {
187
+        if ( ! ( $this->current_user_can_any( $this->_capabilities_uninstall ) && ( ! function_exists( 'is_multisite' ) || ! is_multisite() || is_super_admin() ) ) ) {
188 188
             return $html;
189 189
         }
190 190
 
191
-        if (gravityview()->plugin->is_GF_25()) {
191
+        if ( gravityview()->plugin->is_GF_25() ) {
192 192
             $html_class = 'button outline secondary alignright button-danger';
193 193
         } else {
194 194
             $html_class = 'button button-secondary button-large alignright button-danger';
195 195
         }
196 196
 
197
-        $href = add_query_arg(['post_type' => 'gravityview', 'page' => 'gravityview_settings', 'view' => 'uninstall'], admin_url('edit.php'));
197
+        $href = add_query_arg( [ 'post_type' => 'gravityview', 'page' => 'gravityview_settings', 'view' => 'uninstall' ], admin_url( 'edit.php' ) );
198 198
 
199
-        $uninstall_button = '<a href="'.esc_url($href).'" class="'.gravityview_sanitize_html_class($html_class).'">'.esc_html__('Uninstall GravityView', 'gravityview').'</a>';
199
+        $uninstall_button = '<a href="' . esc_url( $href ) . '" class="' . gravityview_sanitize_html_class( $html_class ) . '">' . esc_html__( 'Uninstall GravityView', 'gravityview' ) . '</a>';
200 200
 
201 201
         $html .= $uninstall_button;
202 202
 
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return string|null HTML of the button.
215 215
      */
216
-    public function settings_save($field, $echo = true)
216
+    public function settings_save( $field, $echo = true )
217 217
     {
218
-        $field['type'] = 'submit';
219
-        $field['name'] = 'gform-settings-save';
220
-        $field['class'] = 'button button-primary primary button-hero';
221
-        $field['value'] = Utils::get($field, 'value', __('Update Settings', 'gravityview'));
218
+        $field[ 'type' ] = 'submit';
219
+        $field[ 'name' ] = 'gform-settings-save';
220
+        $field[ 'class' ] = 'button button-primary primary button-hero';
221
+        $field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) );
222 222
 
223
-        $html = $this->as_html($field, false);
223
+        $html = $this->as_html( $field, false );
224 224
 
225
-        $html = $this->modify_gform_settings_save_button($html);
225
+        $html = $this->modify_gform_settings_save_button( $html );
226 226
 
227
-        if ($echo) {
227
+        if ( $echo ) {
228 228
             echo $html;
229 229
         }
230 230
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
      *
239 239
      * @return array
240 240
      */
241
-    public function modify_app_settings_menu_title($setting_tabs)
241
+    public function modify_app_settings_menu_title( $setting_tabs )
242 242
     {
243
-        $setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview');
244
-        $setting_tabs[0]['icon'] = 'dashicons-admin-settings';
243
+        $setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
244
+        $setting_tabs[ 0 ][ 'icon' ] = 'dashicons-admin-settings';
245 245
 
246 246
         return $setting_tabs;
247 247
     }
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
      */
264 264
     private function _load_license_handler()
265 265
     {
266
-        if (!empty($this->License_Handler)) {
266
+        if ( ! empty( $this->License_Handler ) ) {
267 267
             return;
268 268
         }
269
-        $this->License_Handler = License_Handler::get($this);
269
+        $this->License_Handler = License_Handler::get( $this );
270 270
     }
271 271
 
272 272
     /**
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public function add_network_menu()
280 280
     {
281
-        if (!gravityview()->plugin->is_network_activated()) {
281
+        if ( ! gravityview()->plugin->is_network_activated() ) {
282 282
             return;
283 283
         }
284 284
 
285
-        add_menu_page(__('Settings', 'gravityview'), __('GravityView', 'gravityview'), $this->_capabilities_app_settings, "{$this->_slug}_settings", [$this, 'app_tab_page'], 'none');
285
+        add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", [ $this, 'app_tab_page' ], 'none' );
286 286
     }
287 287
 
288 288
     /**
@@ -319,21 +319,21 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @return bool
321 321
      */
322
-    public function current_user_can_any($caps)
322
+    public function current_user_can_any( $caps )
323 323
     {
324
-        if (empty($caps)) {
325
-            $caps = ['gravityview_full_access'];
324
+        if ( empty( $caps ) ) {
325
+            $caps = [ 'gravityview_full_access' ];
326 326
         }
327 327
 
328
-        return \GVCommon::has_cap($caps);
328
+        return \GVCommon::has_cap( $caps );
329 329
     }
330 330
 
331 331
     public function uninstall_warning_message()
332 332
     {
333
-        $heading = esc_html__('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview');
334
-        $message = esc_html__('Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview');
333
+        $heading = esc_html__( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' );
334
+        $message = esc_html__( 'Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview' );
335 335
 
336
-        return sprintf('<h4>%s</h4><p>%s</p>', $heading, $message);
336
+        return sprintf( '<h4>%s</h4><p>%s</p>', $heading, $message );
337 337
     }
338 338
 
339 339
     /**
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
     {
348 348
         $reasons = [
349 349
             'will-continue'  => [
350
-                'label' => esc_html__('I am going to continue using GravityView', 'gravityview'),
350
+                'label' => esc_html__( 'I am going to continue using GravityView', 'gravityview' ),
351 351
             ],
352 352
             'no-longer-need' => [
353
-                'label' => esc_html__('I no longer need GravityView', 'gravityview'),
353
+                'label' => esc_html__( 'I no longer need GravityView', 'gravityview' ),
354 354
             ],
355 355
             'doesnt-work'    => [
356
-                'label' => esc_html__('The plugin doesn\'t work', 'gravityview'),
356
+                'label' => esc_html__( 'The plugin doesn\'t work', 'gravityview' ),
357 357
             ],
358 358
             'found-other'    => [
359
-                'label'    => esc_html__('I found a better plugin', 'gravityview'),
360
-                'followup' => esc_attr__('What plugin you are using, and why?', 'gravityview'),
359
+                'label'    => esc_html__( 'I found a better plugin', 'gravityview' ),
360
+                'followup' => esc_attr__( 'What plugin you are using, and why?', 'gravityview' ),
361 361
             ],
362 362
             'other'          => [
363
-                'label' => esc_html__('Other', 'gravityview'),
363
+                'label' => esc_html__( 'Other', 'gravityview' ),
364 364
             ],
365 365
         ];
366 366
 
367
-        shuffle($reasons);
367
+        shuffle( $reasons );
368 368
 
369 369
         return $reasons;
370 370
     }
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
 		</style>
413 413
 
414 414
 		<?php
415
-        if (gravityview()->plugin->is_GF_25()) {
416
-            $uninstall_title = esc_html__('Uninstall GravityView', 'gravityview');
415
+        if ( gravityview()->plugin->is_GF_25() ) {
416
+            $uninstall_title = esc_html__( 'Uninstall GravityView', 'gravityview' );
417 417
 
418 418
             echo <<<HTML
419 419
 <div class="gform-settings-panel">
@@ -463,59 +463,59 @@  discard block
 block discarded – undo
463 463
 				} );
464 464
 
465 465
 				function gv_feedback_append_error_message() {
466
-					$( '#gv-uninstall-thanks' ).append( '<div class="notice error">' + <?php echo json_encode(esc_html(__('There was an error sharing your feedback. Sorry! Please email us at [email protected]', 'gravityview'))) ?> +'</div>' );
466
+					$( '#gv-uninstall-thanks' ).append( '<div class="notice error">' + <?php echo json_encode( esc_html( __( 'There was an error sharing your feedback. Sorry! Please email us at [email protected]', 'gravityview' ) ) ) ?> +'</div>' );
467 467
 				}
468 468
 			} );
469 469
 		</script>
470 470
 
471 471
 		<form id="gv-uninstall-feedback" method="post" action="https://hooks.zapier.com/hooks/catch/28670/6haevn/">
472
-			<h2><?php esc_html_e('Why did you uninstall GravityView?', 'gravityview'); ?></h2>
472
+			<h2><?php esc_html_e( 'Why did you uninstall GravityView?', 'gravityview' ); ?></h2>
473 473
 			<ul>
474 474
 				<?php
475 475
                 $reasons = $this->get_uninstall_reasons();
476
-        foreach ($reasons as $reason) {
477
-            printf('<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get($reason, 'followup'), Utils::get($reason, 'label'));
476
+        foreach ( $reasons as $reason ) {
477
+            printf( '<li><label><input name="reason" type="radio" value="other" data-followup="%s"> %s</label></li>', Utils::get( $reason, 'followup' ), Utils::get( $reason, 'label' ) );
478 478
         } ?>
479 479
 			</ul>
480 480
 			<div class="gv-followup widefat">
481
-				<p><strong><label for="gv-reason-details"><?php esc_html_e('Comments', 'gravityview'); ?></label></strong></p>
482
-				<textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview') ?>" placeholder="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview'); ?>" class="large-text"></textarea>
481
+				<p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p>
482
+				<textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea>
483 483
 			</div>
484 484
 			<div class="scale-description">
485
-				<p><strong><?php esc_html_e('How likely are you to recommend GravityView?', 'gravityview'); ?></strong></p>
485
+				<p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p>
486 486
 				<ul class="inline">
487 487
 					<?php
488 488
                     $i = 0;
489
-        while ($i < 11) {
490
-            echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>';
489
+        while ( $i < 11 ) {
490
+            echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>';
491 491
             $i++;
492 492
         } ?>
493 493
 				</ul>
494
-				<p class="description"><?php printf(esc_html_x('%s ("Not at all likely") to %s ("Extremely likely")', 'A scale from 0 (bad) to 10 (good)', 'gravityview'), '<label for="likely_to_refer_0"><code>0</code></label>', '<label for="likely_to_refer_10"><code>10</code></label>'); ?></p>
494
+				<p class="description"><?php printf( esc_html_x( '%s ("Not at all likely") to %s ("Extremely likely")', 'A scale from 0 (bad) to 10 (good)', 'gravityview' ), '<label for="likely_to_refer_0"><code>0</code></label>', '<label for="likely_to_refer_10"><code>10</code></label>' ); ?></p>
495 495
 			</div>
496 496
 
497 497
 			<div class="gv-form-field-wrapper">
498
-				<label><input type="checkbox" class="checkbox" name="follow_up_with_me" value="1" /> <?php esc_html_e('Please follow up with me about my feedback', 'gravityview'); ?></label>
498
+				<label><input type="checkbox" class="checkbox" name="follow_up_with_me" value="1" /> <?php esc_html_e( 'Please follow up with me about my feedback', 'gravityview' ); ?></label>
499 499
 			</div>
500 500
 
501 501
 			<div class="submit">
502
-				<input type="hidden" name="siteurl" value="<?php echo esc_url(get_bloginfo('url')); ?>" />
503
-				<input type="hidden" name="email" value="<?php echo esc_attr($user->user_email); ?>" />
504
-				<input type="hidden" name="display_name" value="<?php echo esc_attr($user->display_name); ?>" />
505
-				<input type="submit" value="<?php esc_html_e('Send Us Your Feedback', 'gravityview'); ?>" class="button button-primary primary button-hero" />
502
+				<input type="hidden" name="siteurl" value="<?php echo esc_url( get_bloginfo( 'url' ) ); ?>" />
503
+				<input type="hidden" name="email" value="<?php echo esc_attr( $user->user_email ); ?>" />
504
+				<input type="hidden" name="display_name" value="<?php echo esc_attr( $user->display_name ); ?>" />
505
+				<input type="submit" value="<?php esc_html_e( 'Send Us Your Feedback', 'gravityview' ); ?>" class="button button-primary primary button-hero" />
506 506
 			</div>
507 507
 		</form>
508 508
 
509
-		<div id="gv-uninstall-thanks" class="<?php echo (gravityview()->plugin->is_GF_25()) ? 'notice-large' : 'notice notice-large notice-updated below-h2'; ?>" style="display:none;">
510
-			<h3 class="notice-title"><?php esc_html_e('Thank you for using GravityView!', 'gravityview'); ?></h3>
509
+		<div id="gv-uninstall-thanks" class="<?php echo ( gravityview()->plugin->is_GF_25() ) ? 'notice-large' : 'notice notice-large notice-updated below-h2'; ?>" style="display:none;">
510
+			<h3 class="notice-title"><?php esc_html_e( 'Thank you for using GravityView!', 'gravityview' ); ?></h3>
511 511
 			<p><?php echo gravityview_get_floaty(); ?>
512
-				<?php echo make_clickable(esc_html__('Your feedback helps us improve GravityView. If you have any questions or comments, email us: [email protected]', 'gravityview')); ?>
512
+				<?php echo make_clickable( esc_html__( 'Your feedback helps us improve GravityView. If you have any questions or comments, email us: [email protected]', 'gravityview' ) ); ?>
513 513
 			</p>
514 514
 			<div class="wp-clearfix"></div>
515 515
 		</div>
516 516
 		</div>
517 517
 		<?php
518
-        if (gravityview()->plugin->is_GF_25()) {
518
+        if ( gravityview()->plugin->is_GF_25() ) {
519 519
             echo '</div>';
520 520
         }
521 521
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     {
529 529
         parent::app_settings_tab();
530 530
 
531
-        if ($this->maybe_uninstall()) {
531
+        if ( $this->maybe_uninstall() ) {
532 532
             echo $this->uninstall_form();
533 533
         }
534 534
     }
@@ -562,9 +562,9 @@  discard block
 block discarded – undo
562 562
      *
563 563
      * @deprecated Use \GV\Addon_Settings::get
564 564
      */
565
-    public function get_app_setting($setting_name)
565
+    public function get_app_setting( $setting_name )
566 566
     {
567
-        return $this->get($setting_name);
567
+        return $this->get( $setting_name );
568 568
     }
569 569
 
570 570
     /**
@@ -575,25 +575,25 @@  discard block
 block discarded – undo
575 575
      *
576 576
      * @return mixed The setting value.
577 577
      */
578
-    public function get($key, $default = null)
578
+    public function get( $key, $default = null )
579 579
     {
580 580
 
581 581
         /**
582 582
          * Backward compatibility with Redux.
583 583
          */
584
-        if ($key === 'license') {
584
+        if ( $key === 'license' ) {
585 585
             return [
586
-                'license'  => $this->get('license_key'),
587
-                'status'   => $this->get('license_key_status'),
588
-                'response' => $this->get('license_key_response'),
586
+                'license'  => $this->get( 'license_key' ),
587
+                'status'   => $this->get( 'license_key_status' ),
588
+                'response' => $this->get( 'license_key_response' ),
589 589
             ];
590 590
         }
591 591
 
592
-        if ('license_key' === $key && defined('GRAVITYVIEW_LICENSE_KEY')) {
592
+        if ( 'license_key' === $key && defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) {
593 593
             return GRAVITYVIEW_LICENSE_KEY;
594 594
         }
595 595
 
596
-        return Utils::get($this->all(), $key, $default);
596
+        return Utils::get( $this->all(), $key, $default );
597 597
     }
598 598
 
599 599
     /**
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
      *
606 606
      * @deprecated Use gravityview()->plugin->settings->get()
607 607
      */
608
-    public static function getSetting($key)
608
+    public static function getSetting( $key )
609 609
     {
610
-        if (gravityview()->plugin->settings instanceof Addon_Settings) {
611
-            return gravityview()->plugin->settings->get($key);
610
+        if ( gravityview()->plugin->settings instanceof Addon_Settings ) {
611
+            return gravityview()->plugin->settings->get( $key );
612 612
         }
613 613
     }
614 614
 
@@ -631,17 +631,17 @@  discard block
 block discarded – undo
631 631
      */
632 632
     public function all()
633 633
     {
634
-        $option_name = 'gravityformsaddon_'.$this->_slug.'_app_settings';
634
+        $option_name = 'gravityformsaddon_' . $this->_slug . '_app_settings';
635 635
 
636
-        if ($this->has_site_settings()) {
636
+        if ( $this->has_site_settings() ) {
637 637
             $defaults = $this->defaults();
638
-            $option_value = get_option($option_name, []);
638
+            $option_value = get_option( $option_name, [ ] );
639 639
         } else {
640
-            $defaults = get_blog_option(get_main_site_id(), $option_name);
641
-            $option_value = get_blog_option(get_main_site_id(), $option_name);
640
+            $defaults = get_blog_option( get_main_site_id(), $option_name );
641
+            $option_value = get_blog_option( get_main_site_id(), $option_name );
642 642
         }
643 643
 
644
-        return wp_parse_args($option_value, $defaults);
644
+        return wp_parse_args( $option_value, $defaults );
645 645
     }
646 646
 
647 647
     /**
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
     {
666 666
         $defaults = [
667 667
             // Set the default license in wp-config.php
668
-            'license_key'          => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '',
668
+            'license_key'          => defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : '',
669 669
             'license_key_response' => '',
670 670
             'license_key_status'   => '',
671
-            'support-email'        => get_bloginfo('admin_email'),
671
+            'support-email'        => get_bloginfo( 'admin_email' ),
672 672
             'no-conflict-mode'     => '1',
673 673
             'support_port'         => '1',
674 674
             'flexbox_search'       => '1',
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
          *
684 684
          * @param  [in,out] array The defaults.
685 685
          */
686
-        return apply_filters('gravityview/settings/defaults', $defaults);
686
+        return apply_filters( 'gravityview/settings/defaults', $defaults );
687 687
     }
688 688
 
689 689
     /***
@@ -694,31 +694,31 @@  discard block
 block discarded – undo
694 694
      *
695 695
      * @return string The HTML
696 696
      */
697
-    public function as_html($field, $echo = true)
697
+    public function as_html( $field, $echo = true )
698 698
     {
699
-        $field['type'] = (isset($field['type']) && in_array($field['type'], ['submit', 'reset', 'button'])) ? $field['type'] : 'submit';
699
+        $field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], [ 'submit', 'reset', 'button' ] ) ) ? $field[ 'type' ] : 'submit';
700 700
 
701
-        $attributes = $this->get_field_attributes($field);
702
-        $default_value = Utils::get($field, 'value', Utils::get($field, 'default_value'));
703
-        $value = $this->get($field['name'], $default_value);
701
+        $attributes = $this->get_field_attributes( $field );
702
+        $default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) );
703
+        $value = $this->get( $field[ 'name' ], $default_value );
704 704
 
705
-        $attributes['class'] = isset($attributes['class']) ? esc_attr($attributes['class']) : 'button-primary primary gfbutton';
706
-        $name = ($field['name'] === 'gform-settings-save') ? $field['name'] : '_gaddon_setting_'.$field['name'];
705
+        $attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary primary gfbutton';
706
+        $name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
707 707
 
708
-        if (empty($value)) {
709
-            $value = __('Update Settings', 'gravityview');
708
+        if ( empty( $value ) ) {
709
+            $value = __( 'Update Settings', 'gravityview' );
710 710
         }
711 711
 
712
-        $attributes = $this->get_field_attributes($field);
712
+        $attributes = $this->get_field_attributes( $field );
713 713
 
714 714
         $html = '<input
715
-                    type="'.$field['type'].'"
716
-                    name="'.esc_attr($name).'"
717
-                    value="'.$value.'" '.
718
-                implode(' ', $attributes).
715
+                    type="'.$field[ 'type' ] . '"
716
+                    name="'.esc_attr( $name ) . '"
717
+                    value="'.$value . '" ' .
718
+                implode( ' ', $attributes ) .
719 719
                 ' />';
720 720
 
721
-        if ($echo) {
721
+        if ( $echo ) {
722 722
             echo $html;
723 723
         }
724 724
 
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
     /**
729 729
      * @deprecated Use \GV\Addon_Settings::as_html
730 730
      */
731
-    public function settings_submit($field, $echo = true)
731
+    public function settings_submit( $field, $echo = true )
732 732
     {
733
-        gravityview()->log->warning('\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html');
733
+        gravityview()->log->warning( '\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html' );
734 734
 
735
-        return $this->as_html($field, $echo);
735
+        return $this->as_html( $field, $echo );
736 736
     }
737 737
 
738 738
     /**
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
      */
747 747
     public function is_save_postback()
748 748
     {
749
-        return isset($_POST['gform-settings-save']) && isset($_POST['_gravityview_save_settings_nonce']);
749
+        return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] );
750 750
     }
751 751
 
752 752
     /**
@@ -756,55 +756,55 @@  discard block
 block discarded – undo
756 756
      */
757 757
     public function license_key_notice()
758 758
     {
759
-        if ('uninstall' === rgget('view')) {
759
+        if ( 'uninstall' === rgget( 'view' ) ) {
760 760
             return; // Do not display license notice on the uninstall page in GF 2.5
761 761
         }
762 762
 
763
-        if ($this->is_save_postback()) {
763
+        if ( $this->is_save_postback() ) {
764 764
             $settings = $this->get_posted_settings();
765
-            $license_key = defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get($settings, 'license_key');
766
-            $license_status = \GV\Utils::get($settings, 'license_key_status', 'inactive');
765
+            $license_key = defined( 'GRAVITYVIEW_LICENSE_KEY' ) ? GRAVITYVIEW_LICENSE_KEY : \GV\Utils::get( $settings, 'license_key' );
766
+            $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' );
767 767
         } else {
768
-            $license_status = $this->get('license_key_status', 'inactive');
769
-            $license_key = $this->get('license_key');
768
+            $license_status = $this->get( 'license_key_status', 'inactive' );
769
+            $license_key = $this->get( 'license_key' );
770 770
         }
771 771
 
772
-        if (empty($license_key)) {
772
+        if ( empty( $license_key ) ) {
773 773
             $license_id = 'license';
774 774
             $license_status = '';
775 775
         } else {
776 776
             $license_id = $license_key;
777 777
         }
778 778
 
779
-        $message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
779
+        $message = esc_html__( 'Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' );
780 780
 
781 781
         /** @internal Do not use! Will change without notice (pun slightly intended). */
782
-        $message = apply_filters('gravityview/settings/license-key-notice', $message);
782
+        $message = apply_filters( 'gravityview/settings/license-key-notice', $message );
783 783
 
784 784
         /**
785 785
          * I wanted to remove the period from after the buttons in the string,
786 786
          * but didn't want to mess up the translation strings for the translators.
787 787
          */
788
-        $message = mb_substr($message, 0, mb_strlen($message) - 1);
789
-        $title = __('Inactive License', 'gravityview');
788
+        $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
789
+        $title = __( 'Inactive License', 'gravityview' );
790 790
         $status = '';
791 791
         $update_below = false;
792
-        $primary_button_link = admin_url('edit.php?post_type=gravityview&amp;page=gravityview_settings');
792
+        $primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
793 793
 
794
-        switch ($license_status) {
794
+        switch ( $license_status ) {
795 795
             /** @since 1.17 */
796 796
             case 'expired':
797
-                $title = __('Expired License', 'gravityview');
798
-                $status = __('has expired', 'gravityview');
799
-                $message = $this->get_license_handler()->strings('expired', $this->get('license_key_response'));
797
+                $title = __( 'Expired License', 'gravityview' );
798
+                $status = __( 'has expired', 'gravityview' );
799
+                $message = $this->get_license_handler()->strings( 'expired', $this->get( 'license_key_response' ) );
800 800
                 break;
801 801
             case 'invalid':
802
-                $title = __('Invalid License', 'gravityview');
803
-                $status = __('is invalid', 'gravityview');
802
+                $title = __( 'Invalid License', 'gravityview' );
803
+                $status = __( 'is invalid', 'gravityview' );
804 804
                 break;
805 805
             case 'deactivated':
806
-                $status = __('is inactive', 'gravityview');
807
-                $update_below = __('Activate your license key below.', 'gravityview');
806
+                $status = __( 'is inactive', 'gravityview' );
807
+                $update_below = __( 'Activate your license key below.', 'gravityview' );
808 808
                 break;
809 809
             /** @noinspection PhpMissingBreakStatementInspection */
810 810
             case '':
@@ -812,30 +812,30 @@  discard block
 block discarded – undo
812 812
             // break intentionally left blank
813 813
             case 'inactive':
814 814
             case 'site_inactive':
815
-                $status = __('has not been activated', 'gravityview');
816
-                $update_below = __('Activate your license key below.', 'gravityview');
815
+                $status = __( 'has not been activated', 'gravityview' );
816
+                $update_below = __( 'Activate your license key below.', 'gravityview' );
817 817
                 break;
818 818
         }
819
-        $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
819
+        $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
820 820
 
821 821
         // Show a different notice on settings page for inactive licenses (hide the buttons)
822
-        if ($update_below && gravityview()->request->is_admin('', 'settings')) {
823
-            $message = sprintf($message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">'.$update_below.'</a>');
822
+        if ( $update_below && gravityview()->request->is_admin( '', 'settings' ) ) {
823
+            $message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' );
824 824
         } else {
825
-            $message = sprintf($message, $status, "\n\n".'<a href="'.esc_url($primary_button_link).'" class="button button-primary primary">', '</a>', '<a href="'.esc_url($url).'" class="button button-secondary">', '</a>');
825
+            $message = sprintf( $message, $status, "\n\n" . '<a href="' . esc_url( $primary_button_link ) . '" class="button button-primary primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' );
826 826
         }
827 827
 
828
-        if (empty($status)) {
828
+        if ( empty( $status ) ) {
829 829
             return;
830 830
         }
831 831
 
832
-        \GravityView_Admin_Notices::add_notice([
832
+        \GravityView_Admin_Notices::add_notice( [
833 833
             'message' => $message,
834 834
             'class'   => 'notice notice-warning gv-license-warning',
835 835
             'title'   => $title,
836 836
             'cap'     => 'gravityview_edit_settings',
837
-            'dismiss' => sha1($license_status.'_'.$license_id.'_'.date('z')), // Show every day, instead of every 8 weeks (which is the default)
838
-        ]);
837
+            'dismiss' => sha1( $license_status . '_' . $license_id . '_' . date( 'z' ) ), // Show every day, instead of every 8 weeks (which is the default)
838
+        ] );
839 839
     }
840 840
 
841 841
     /**
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
     {
863 863
         $scripts = parent::scripts();
864 864
 
865
-        $scripts[] = [
865
+        $scripts[ ] = [
866 866
             'handle'  => 'gform_tooltip_init',
867 867
             'enqueue' => [
868 868
                 [
869
-                    'admin_page' => ['app_settings'],
869
+                    'admin_page' => [ 'app_settings' ],
870 870
                 ],
871 871
             ],
872 872
         ];
@@ -890,13 +890,13 @@  discard block
 block discarded – undo
890 890
         ];
891 891
 
892 892
         // This file was removed from 2.5
893
-        if (!gravityview()->plugin->is_GF_25()) {
894
-            $deps[] = 'gform_tooltip';
893
+        if ( ! gravityview()->plugin->is_GF_25() ) {
894
+            $deps[ ] = 'gform_tooltip';
895 895
         }
896 896
 
897
-        $styles[] = [
897
+        $styles[ ] = [
898 898
             'handle'  => 'gravityview_settings',
899
-            'src'     => plugins_url('assets/css/admin-settings.css', GRAVITYVIEW_FILE),
899
+            'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
900 900
             'version' => Plugin::$version,
901 901
             'deps'    => $deps,
902 902
             'enqueue' => [
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
      */
926 926
     private function has_site_settings()
927 927
     {
928
-        return (!is_multisite()) || is_main_site() || (!gravityview()->plugin->is_network_activated()) || (is_network_admin() && gravityview()->plugin->is_network_activated());
928
+        return ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() );
929 929
     }
930 930
 
931 931
     /**
@@ -943,13 +943,13 @@  discard block
 block discarded – undo
943 943
          *
944 944
          * @param bool $hide_if_network_activated Default: true
945 945
          */
946
-        $show_submenu = apply_filters('gravityview/show-settings-menu', $this->has_site_settings());
946
+        $show_submenu = apply_filters( 'gravityview/show-settings-menu', $this->has_site_settings() );
947 947
 
948
-        if (!$show_submenu) {
948
+        if ( ! $show_submenu ) {
949 949
             return;
950 950
         }
951 951
 
952
-        add_submenu_page('edit.php?post_type=gravityview', __('Settings', 'gravityview'), __('Settings', 'gravityview'), $this->_capabilities_app_settings, $this->_slug.'_settings', [$this, 'app_tab_page']);
952
+        add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', [ $this, 'app_tab_page' ] );
953 953
     }
954 954
 
955 955
     /**
@@ -960,9 +960,9 @@  discard block
 block discarded – undo
960 960
      *
961 961
      * @return string - Returns markup of the required indicator symbol
962 962
      */
963
-    public function get_required_indicator($field)
963
+    public function get_required_indicator( $field )
964 964
     {
965
-        return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>';
965
+        return '<span class="required" title="' . esc_attr__( 'Required', 'gravityview' ) . '">*</span>';
966 966
     }
967 967
 
968 968
     /**
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
     {
975 975
         $default_settings = $this->defaults();
976 976
 
977
-        $disabled_attribute = \GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
977
+        $disabled_attribute = \GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled';
978 978
 
979 979
         $affiliate_link = 'https://gravityview.co/account/affiliate/?utm_source=in-plugin&utm_medium=setting&utm_content=Register as an affiliate';
980 980
 
@@ -983,9 +983,9 @@  discard block
 block discarded – undo
983 983
                 'name'          => 'support-email',
984 984
                 'type'          => 'text',
985 985
                 'validate'      => 'email',
986
-                'default_value' => $default_settings['support-email'],
987
-                'label'         => __('Support Email', 'gravityview'),
988
-                'description'   => __('In order to provide responses to your support requests, please provide your email address.', 'gravityview'),
986
+                'default_value' => $default_settings[ 'support-email' ],
987
+                'label'         => __( 'Support Email', 'gravityview' ),
988
+                'description'   => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
989 989
                 'class'         => 'code regular-text',
990 990
             ],
991 991
             /**
@@ -994,84 +994,84 @@  discard block
 block discarded – undo
994 994
             [
995 995
                 'name'          => 'support_port',
996 996
                 'type'          => 'radio',
997
-                'label'         => __('Show Support Port?', 'gravityview'),
998
-                'default_value' => $default_settings['support_port'],
997
+                'label'         => __( 'Show Support Port?', 'gravityview' ),
998
+                'default_value' => $default_settings[ 'support_port' ],
999 999
                 'horizontal'    => 1,
1000 1000
                 'choices'       => [
1001 1001
                     [
1002
-                        'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
1002
+                        'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ),
1003 1003
                         'value' => '1',
1004 1004
                     ],
1005 1005
                     [
1006
-                        'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
1006
+                        'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ),
1007 1007
                         'value' => '0',
1008 1008
                     ],
1009 1009
                 ],
1010
-                'tooltip'     => '<p>'.esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview').'<img src="'.esc_url_raw(plugins_url('assets/images/beacon.png', GRAVITYVIEW_FILE)).'" alt="'.esc_attr__('The Support Port looks like this.', 'gravityview').'" class="aligncenter" style="display: block; max-width:100%; margin:1em auto;" /></p>',
1011
-                'description' => __('Show the Support Port on GravityView pages?', 'gravityview'),
1010
+                'tooltip'     => '<p>' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '<img src="' . esc_url_raw( plugins_url( 'assets/images/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="aligncenter" style="display: block; max-width:100%; margin:1em auto;" /></p>',
1011
+                'description' => __( 'Show the Support Port on GravityView pages?', 'gravityview' ),
1012 1012
             ],
1013 1013
             [
1014 1014
                 'name'          => 'no-conflict-mode',
1015 1015
                 'type'          => 'radio',
1016
-                'label'         => __('No-Conflict Mode', 'gravityview'),
1017
-                'default_value' => $default_settings['no-conflict-mode'],
1016
+                'label'         => __( 'No-Conflict Mode', 'gravityview' ),
1017
+                'default_value' => $default_settings[ 'no-conflict-mode' ],
1018 1018
                 'horizontal'    => 1,
1019 1019
                 'choices'       => [
1020 1020
                     [
1021
-                        'label' => _x('On', 'Setting: On or off', 'gravityview'),
1021
+                        'label' => _x( 'On', 'Setting: On or off', 'gravityview' ),
1022 1022
                         'value' => '1',
1023 1023
                     ],
1024 1024
                     [
1025
-                        'label' => _x('Off', 'Setting: On or off', 'gravityview'),
1025
+                        'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ),
1026 1026
                         'value' => '0',
1027 1027
                     ],
1028 1028
                 ],
1029
-                'description'   => __('Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview').' '.__('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
1029
+                'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ),
1030 1030
             ],
1031 1031
             /**
1032 1032
              * @since 2.0 Added REST API
1033 1033
              */
1034
-            gravityview()->plugin->supports(Plugin::FEATURE_REST) ?
1034
+            gravityview()->plugin->supports( Plugin::FEATURE_REST ) ?
1035 1035
                     [
1036 1036
                         'name'          => 'rest_api',
1037 1037
                         'type'          => 'radio',
1038
-                        'label'         => __('REST API', 'gravityview'),
1039
-                        'default_value' => $default_settings['rest_api'],
1038
+                        'label'         => __( 'REST API', 'gravityview' ),
1039
+                        'default_value' => $default_settings[ 'rest_api' ],
1040 1040
                         'horizontal'    => 1,
1041 1041
                         'choices'       => [
1042 1042
                             [
1043
-                                'label' => _x('Enable', 'Setting: Enable or Disable', 'gravityview'),
1043
+                                'label' => _x( 'Enable', 'Setting: Enable or Disable', 'gravityview' ),
1044 1044
                                 'value' => '1',
1045 1045
                             ],
1046 1046
                             [
1047
-                                'label' => _x('Disable', 'Setting: Enable or Disable', 'gravityview'),
1047
+                                'label' => _x( 'Disable', 'Setting: Enable or Disable', 'gravityview' ),
1048 1048
                                 'value' => '0',
1049 1049
                             ],
1050 1050
                         ],
1051
-                        'description'   => __('Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gravityview'),
1052
-                        'tooltip'       => '<p>'.esc_html__('If you are unsure, choose the Disable setting.', 'gravityview').'</p>',
1053
-                    ] : [],
1051
+                        'description'   => __( 'Enable View and Entry access via the REST API? Regular per-View restrictions apply (private, password protected, etc.).', 'gravityview' ),
1052
+                        'tooltip'       => '<p>' . esc_html__( 'If you are unsure, choose the Disable setting.', 'gravityview' ) . '</p>',
1053
+                    ] : [ ],
1054 1054
             [
1055 1055
                 'name'          => 'powered_by',
1056 1056
                 'type'          => 'checkbox',
1057
-                'label'         => __('Display "Powered By" Link', 'gravityview'),
1058
-                'default_value' => $default_settings['powered_by'],
1057
+                'label'         => __( 'Display "Powered By" Link', 'gravityview' ),
1058
+                'default_value' => $default_settings[ 'powered_by' ],
1059 1059
                 'choices'       => [
1060 1060
                     [
1061
-                        'label' => esc_html__('Display a "Powered by GravityView" link', 'gravityview'),
1061
+                        'label' => esc_html__( 'Display a "Powered by GravityView" link', 'gravityview' ),
1062 1062
                         'value' => '1',
1063 1063
                         'name'  => 'powered_by',
1064 1064
                     ],
1065 1065
                 ],
1066
-                'description'   => __('When enabled, a "Powered by GravityView" link will be displayed below Views. Help us spread the word!', 'gravityview'),
1066
+                'description'   => __( 'When enabled, a "Powered by GravityView" link will be displayed below Views. Help us spread the word!', 'gravityview' ),
1067 1067
             ],
1068 1068
             [
1069 1069
                 'name'          => 'affiliate_id',
1070 1070
                 'type'          => 'text',
1071 1071
                 'input_type'    => 'number',
1072 1072
                 'default_value' => null,
1073
-                'label'         => __('Affiliate ID', 'gravityview'),
1074
-                'description'   => sprintf(__('Earn money when people clicking your links become GravityView customers. <a href="%s" rel="external">Register as an affiliate</a>!', 'gravityview'), esc_url($affiliate_link)),
1073
+                'label'         => __( 'Affiliate ID', 'gravityview' ),
1074
+                'description'   => sprintf( __( 'Earn money when people clicking your links become GravityView customers. <a href="%s" rel="external">Register as an affiliate</a>!', 'gravityview' ), esc_url( $affiliate_link ) ),
1075 1075
                 'class'         => 'code',
1076 1076
                 'placeholder'   => '123',
1077 1077
                 'data-requires' => 'powered_by',
@@ -1079,21 +1079,21 @@  discard block
 block discarded – undo
1079 1079
             [
1080 1080
                 'name'          => 'beta',
1081 1081
                 'type'          => 'checkbox',
1082
-                'label'         => __('Become a Beta Tester', 'gravityview'),
1083
-                'default_value' => $default_settings['beta'],
1082
+                'label'         => __( 'Become a Beta Tester', 'gravityview' ),
1083
+                'default_value' => $default_settings[ 'beta' ],
1084 1084
                 'horizontal'    => 1,
1085 1085
                 'choices'       => [
1086 1086
                     [
1087
-                        'label' => esc_html__('Show me beta versions if they are available.', 'gravityview'),
1087
+                        'label' => esc_html__( 'Show me beta versions if they are available.', 'gravityview' ),
1088 1088
                         'value' => '1',
1089 1089
                         'name'  => 'beta',
1090 1090
                     ],
1091 1091
                 ],
1092
-                'description'   => __('You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview'),
1092
+                'description'   => __( 'You will have early access to the latest GravityView features and improvements. There may be bugs! If you encounter an issue, help make GravityView better by reporting it!', 'gravityview' ),
1093 1093
             ],
1094 1094
         ];
1095 1095
 
1096
-        $fields = array_filter($fields, 'count');
1096
+        $fields = array_filter( $fields, 'count' );
1097 1097
 
1098 1098
         /**
1099 1099
          * @filter     `gravityview_settings_fields` Filter the settings fields.
@@ -1102,87 +1102,87 @@  discard block
 block discarded – undo
1102 1102
          *
1103 1103
          * @deprecated Use `gravityview/settings/fields`.
1104 1104
          */
1105
-        $fields = apply_filters('gravityview_settings_fields', $fields);
1105
+        $fields = apply_filters( 'gravityview_settings_fields', $fields );
1106 1106
 
1107 1107
         /**
1108 1108
          * @filter `gravityview/settings/fields` Filter the settings fields.
1109 1109
          *
1110 1110
          * @param array $fields The fields to filter.
1111 1111
          */
1112
-        $fields = apply_filters('gravityview/settings/fields', $fields);
1112
+        $fields = apply_filters( 'gravityview/settings/fields', $fields );
1113 1113
 
1114 1114
         /**
1115 1115
          * Redux backward compatibility.
1116 1116
          *
1117 1117
          * @since 1.7.4
1118 1118
          */
1119
-        foreach ($fields as &$field) {
1120
-            $field['name'] = isset($field['name']) ? $field['name'] : Utils::get($field, 'id');
1121
-            $field['label'] = isset($field['label']) ? $field['label'] : Utils::get($field, 'title');
1122
-            $field['default_value'] = isset($field['default_value']) ? $field['default_value'] : Utils::get($field, 'default');
1123
-            $field['description'] = isset($field['description']) ? $field['description'] : Utils::get($field, 'subtitle');
1124
-
1125
-            if ($disabled_attribute) {
1126
-                $field['disabled'] = $disabled_attribute;
1119
+        foreach ( $fields as &$field ) {
1120
+            $field[ 'name' ] = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' );
1121
+            $field[ 'label' ] = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' );
1122
+            $field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' );
1123
+            $field[ 'description' ] = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' );
1124
+
1125
+            if ( $disabled_attribute ) {
1126
+                $field[ 'disabled' ] = $disabled_attribute;
1127 1127
             }
1128 1128
 
1129
-            if (empty($field['disabled'])) {
1130
-                unset($field['disabled']);
1129
+            if ( empty( $field[ 'disabled' ] ) ) {
1130
+                unset( $field[ 'disabled' ] );
1131 1131
             }
1132 1132
         }
1133 1133
 
1134 1134
         $license_fields = [
1135 1135
             [
1136 1136
                 'name'              => 'license_key',
1137
-                'required'          => !defined('GRAVITYVIEW_LICENSE_KEY') || !GRAVITYVIEW_LICENSE_KEY,
1138
-                'label'             => __('License Key', 'gravityview'),
1139
-                'description'       => __('Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview'),
1137
+                'required'          => ! defined( 'GRAVITYVIEW_LICENSE_KEY' ) || ! GRAVITYVIEW_LICENSE_KEY,
1138
+                'label'             => __( 'License Key', 'gravityview' ),
1139
+                'description'       => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ),
1140 1140
                 'type'              => 'edd_license',
1141
-                'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
1142
-                'default_value'     => $default_settings['license_key'],
1143
-                'class'             => ('' == $this->get('license_key')) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
1141
+                'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
1142
+                'default_value'     => $default_settings[ 'license_key' ],
1143
+                'class'             => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
1144 1144
             ],
1145 1145
             [
1146 1146
                 'name'          => 'license_key_response',
1147
-                'default_value' => $default_settings['license_key_response'],
1147
+                'default_value' => $default_settings[ 'license_key_response' ],
1148 1148
                 'type'          => 'hidden',
1149 1149
             ],
1150 1150
             [
1151 1151
                 'name'          => 'license_key_status',
1152
-                'default_value' => $default_settings['license_key_status'],
1152
+                'default_value' => $default_settings[ 'license_key_status' ],
1153 1153
                 'type'          => 'hidden',
1154 1154
             ],
1155 1155
         ];
1156 1156
 
1157
-        if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1158
-            $license_fields[0] = array_merge($license_fields[0], [
1157
+        if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1158
+            $license_fields[ 0 ] = array_merge( $license_fields[ 0 ], [
1159 1159
                 'disabled' => true,
1160
-                'title'    => __('The license key is defined by your site\'s configuration file.', 'gravityview'),
1161
-            ]);
1160
+                'title'    => __( 'The license key is defined by your site\'s configuration file.', 'gravityview' ),
1161
+            ] );
1162 1162
         }
1163 1163
 
1164
-        $sections = [];
1165
-        $version_info = '<span class="gv-version-info" title="'.sprintf(__('You are running GravityView version %s', 'gravityview'), Plugin::$version).'">Version '.esc_html(Plugin::$version).'</span>';
1164
+        $sections = [ ];
1165
+        $version_info = '<span class="gv-version-info" title="' . sprintf( __( 'You are running GravityView version %s', 'gravityview' ), Plugin::$version ) . '">Version ' . esc_html( Plugin::$version ) . '</span>';
1166 1166
 
1167
-        if (\gravityview()->plugin->is_GF_25()) {
1168
-            $sections[] = [
1169
-                'title'       => __('GravityView License', 'gravityview'),
1167
+        if ( \gravityview()->plugin->is_GF_25() ) {
1168
+            $sections[ ] = [
1169
+                'title'       => __( 'GravityView License', 'gravityview' ),
1170 1170
                 'class'       => 'gform-settings-panel--full gv-settings-panel--license',
1171 1171
                 'description' => $version_info,
1172 1172
                 'fields'      => $license_fields,
1173 1173
             ];
1174 1174
         } else {
1175
-            $fields = array_merge($license_fields, $fields);
1175
+            $fields = array_merge( $license_fields, $fields );
1176 1176
 
1177
-            array_unshift($fields, [
1177
+            array_unshift( $fields, [
1178 1178
                 'name'  => 'gv_header',
1179 1179
                 'value' => $version_info,
1180 1180
                 'type'  => 'html',
1181
-            ]);
1181
+            ] );
1182 1182
         }
1183 1183
 
1184
-        $sections[] = [
1185
-            'title'       => (gravityview()->plugin->is_GF_25() ? __('GravityView Settings', 'gravityview') : null),
1184
+        $sections[ ] = [
1185
+            'title'       => ( gravityview()->plugin->is_GF_25() ? __( 'GravityView Settings', 'gravityview' ) : null ),
1186 1186
             'class'       => 'gform-settings-panel--full gv-settings-panel--core',
1187 1187
             'fields'      => $fields,
1188 1188
         ];
@@ -1199,19 +1199,19 @@  discard block
 block discarded – undo
1199 1199
          *
1200 1200
          * @param array $extension_settings Empty array, ready for extension settings!
1201 1201
          */
1202
-        $extension_sections = apply_filters('gravityview/settings/extension/sections', []);
1202
+        $extension_sections = apply_filters( 'gravityview/settings/extension/sections', [ ] );
1203 1203
 
1204 1204
         // If there are extensions, add a section for them
1205
-        if (!empty($extension_sections)) {
1206
-            if ($disabled_attribute) {
1207
-                foreach ($extension_sections as &$section) {
1208
-                    foreach ($section['fields'] as &$field) {
1209
-                        $field['disabled'] = $disabled_attribute;
1205
+        if ( ! empty( $extension_sections ) ) {
1206
+            if ( $disabled_attribute ) {
1207
+                foreach ( $extension_sections as &$section ) {
1208
+                    foreach ( $section[ 'fields' ] as &$field ) {
1209
+                        $field[ 'disabled' ] = $disabled_attribute;
1210 1210
                     }
1211 1211
                 }
1212 1212
             }
1213 1213
 
1214
-            $sections = array_merge($sections, $extension_sections);
1214
+            $sections = array_merge( $sections, $extension_sections );
1215 1215
         }
1216 1216
 
1217 1217
         return $sections;
@@ -1228,9 +1228,9 @@  discard block
 block discarded – undo
1228 1228
      *
1229 1229
      * @deprecated Use \GV\Addon_Settings::set or \GV\Addon_Settings::update
1230 1230
      */
1231
-    public function update_app_settings($settings)
1231
+    public function update_app_settings( $settings )
1232 1232
     {
1233
-        return $this->update($settings);
1233
+        return $this->update( $settings );
1234 1234
     }
1235 1235
 
1236 1236
     /**
@@ -1239,14 +1239,14 @@  discard block
 block discarded – undo
1239 1239
      * @param array|string An array of settings to update, or string (key) and $value to update one setting.
1240 1240
      * @param mixed $value A value if $settings is string (key). Default: null.
1241 1241
      */
1242
-    public function set($settings, $value = null)
1242
+    public function set( $settings, $value = null )
1243 1243
     {
1244
-        if (is_string($settings)) {
1245
-            $settings = [$settings => $value];
1244
+        if ( is_string( $settings ) ) {
1245
+            $settings = [ $settings => $value ];
1246 1246
         }
1247
-        $settings = wp_parse_args($settings, $this->all());
1247
+        $settings = wp_parse_args( $settings, $this->all() );
1248 1248
 
1249
-        return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1249
+        return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings );
1250 1250
     }
1251 1251
 
1252 1252
     /**
@@ -1256,9 +1256,9 @@  discard block
 block discarded – undo
1256 1256
      *
1257 1257
      * @return bool False if value was not updated and true if value was updated.
1258 1258
      */
1259
-    public function update($settings)
1259
+    public function update( $settings )
1260 1260
     {
1261
-        return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1261
+        return update_option( 'gravityformsaddon_' . $this->_slug . '_app_settings', $settings );
1262 1262
     }
1263 1263
 
1264 1264
     /**
@@ -1269,21 +1269,21 @@  discard block
 block discarded – undo
1269 1269
      *
1270 1270
      * @return string
1271 1271
      */
1272
-    public function settings_edd_license($field, $echo = true)
1272
+    public function settings_edd_license( $field, $echo = true )
1273 1273
     {
1274
-        if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1275
-            $field['input_type'] = 'password';
1274
+        if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) {
1275
+            $field[ 'input_type' ] = 'password';
1276 1276
         }
1277 1277
 
1278
-        $text = $this->settings_text($field, false);
1278
+        $text = $this->settings_text( $field, false );
1279 1279
 
1280
-        $activation = $this->License_Handler->settings_edd_license_activation($field, false);
1280
+        $activation = $this->License_Handler->settings_edd_license_activation( $field, false );
1281 1281
 
1282
-        $return = $text.$activation;
1282
+        $return = $text . $activation;
1283 1283
 
1284
-        $return .= $this->get_license_handler()->license_details(\GV\Addon_Settings::get('license_key_response'));
1284
+        $return .= $this->get_license_handler()->license_details( \GV\Addon_Settings::get( 'license_key_response' ) );
1285 1285
 
1286
-        if ($echo) {
1286
+        if ( $echo ) {
1287 1287
             echo $return;
1288 1288
         }
1289 1289
 
@@ -1300,11 +1300,11 @@  discard block
 block discarded – undo
1300 1300
      *
1301 1301
      * @return string
1302 1302
      */
1303
-    protected function settings_html($field, $echo = true)
1303
+    protected function settings_html( $field, $echo = true )
1304 1304
     {
1305
-        $return = \GV\Utils::get($field, 'value', '');
1305
+        $return = \GV\Utils::get( $field, 'value', '' );
1306 1306
 
1307
-        if ($echo) {
1307
+        if ( $echo ) {
1308 1308
             echo $return;
1309 1309
         }
1310 1310
 
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
      *
1321 1321
      * @return void
1322 1322
      */
1323
-    public function single_setting_row_html($field)
1323
+    public function single_setting_row_html( $field )
1324 1324
     {
1325 1325
         ?>
1326 1326
 
1327
-		<tr id="gaddon-setting-row-<?php echo esc_attr($field['name']); ?>">
1327
+		<tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>">
1328 1328
 			<td colspan="2">
1329
-				<?php $this->single_setting($field); ?>
1329
+				<?php $this->single_setting( $field ); ?>
1330 1330
 			</td>
1331 1331
 		</tr>
1332 1332
 
@@ -1347,11 +1347,11 @@  discard block
 block discarded – undo
1347 1347
      *
1348 1348
      * @return void
1349 1349
      */
1350
-    public function single_setting_row($field)
1350
+    public function single_setting_row( $field )
1351 1351
     {
1352
-        $field['gv_description'] = Utils::get($field, 'description');
1353
-        $field['description'] = Utils::get($field, 'subtitle');
1354
-        parent::single_setting_row($field);
1352
+        $field[ 'gv_description' ] = Utils::get( $field, 'description' );
1353
+        $field[ 'description' ] = Utils::get( $field, 'subtitle' );
1354
+        parent::single_setting_row( $field );
1355 1355
     }
1356 1356
 
1357 1357
     /**
@@ -1361,11 +1361,11 @@  discard block
 block discarded – undo
1361 1361
      *
1362 1362
      * @param $field array
1363 1363
      */
1364
-    public function single_setting_label($field)
1364
+    public function single_setting_label( $field )
1365 1365
     {
1366
-        parent::single_setting_label($field);
1367
-        if ($description = Utils::get($field, 'gv_description')) {
1368
-            echo '<span class="description">'.$description.'</span>';
1366
+        parent::single_setting_label( $field );
1367
+        if ( $description = Utils::get( $field, 'gv_description' ) ) {
1368
+            echo '<span class="description">' . $description . '</span>';
1369 1369
         }
1370 1370
     }
1371 1371
 
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
      */
1380 1380
     public function maybe_save_app_settings()
1381 1381
     {
1382
-        if ($this->is_save_postback()) {
1383
-            if (!\GVCommon::has_cap('gravityview_edit_settings')) {
1384
-                $_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
1385
-                \GFCommon::add_error_message(__('You don\'t have the ability to edit plugin settings.', 'gravityview'));
1382
+        if ( $this->is_save_postback() ) {
1383
+            if ( ! \GVCommon::has_cap( 'gravityview_edit_settings' ) ) {
1384
+                $_POST = [ ]; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
1385
+                \GFCommon::add_error_message( __( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ) );
1386 1386
 
1387 1387
                 return;
1388 1388
             }
@@ -1399,23 +1399,23 @@  discard block
 block discarded – undo
1399 1399
     {
1400 1400
         $posted_settings = parent::get_posted_settings();
1401 1401
 
1402
-        $local_key = Utils::get($posted_settings, 'license_key');
1402
+        $local_key = Utils::get( $posted_settings, 'license_key' );
1403 1403
 
1404
-        if (!$local_key && defined('GRAVITYVIEW_LICENSE_KEY')) {
1404
+        if ( ! $local_key && defined( 'GRAVITYVIEW_LICENSE_KEY' ) ) {
1405 1405
             $local_key = GRAVITYVIEW_LICENSE_KEY;
1406 1406
         }
1407 1407
 
1408
-        $response_key = Utils::get($posted_settings, 'license_key_response/license_key');
1408
+        $response_key = Utils::get( $posted_settings, 'license_key_response/license_key' );
1409 1409
 
1410 1410
         static $added_message = false;
1411 1411
 
1412 1412
         // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
1413 1413
         // then we assume it's changed. If it's changed, unset the status and the previous response.
1414
-        if (!$added_message && ($local_key !== $response_key)) {
1415
-            unset($posted_settings['license_key_response']);
1416
-            unset($posted_settings['license_key_status']);
1414
+        if ( ! $added_message && ( $local_key !== $response_key ) ) {
1415
+            unset( $posted_settings[ 'license_key_response' ] );
1416
+            unset( $posted_settings[ 'license_key_status' ] );
1417 1417
 
1418
-            \GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview'));
1418
+            \GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
1419 1419
 
1420 1420
             $added_message = true;
1421 1421
         }
Please login to merge, or discard this patch.
Braces   +47 added lines, -94 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private static $initialized = false;
67 67
 
68
-    public function __construct()
69
-    {
68
+    public function __construct() {
70 69
         $this->_version = Plugin::$version;
71 70
         $this->_min_gravityforms_version = Plugin::$min_gf_version;
72 71
 
@@ -86,8 +85,7 @@  discard block
 block discarded – undo
86 85
      *
87 86
      * @return void
88 87
      */
89
-    public function init_admin()
90
-    {
88
+    public function init_admin() {
91 89
         $this->_load_license_handler();
92 90
 
93 91
         add_filter('admin_body_class', [$this, 'body_class']);
@@ -113,8 +111,7 @@  discard block
 block discarded – undo
113 111
      *
114 112
      * @return array
115 113
      */
116
-    public function get_app_settings_tabs()
117
-    {
114
+    public function get_app_settings_tabs() {
118 115
         $setting_tabs = parent::get_app_settings_tabs();
119 116
 
120 117
         foreach ($setting_tabs as &$tab) {
@@ -142,8 +139,7 @@  discard block
 block discarded – undo
142 139
      *
143 140
      * @return array
144 141
      */
145
-    public function register_no_conflict($items)
146
-    {
142
+    public function register_no_conflict($items) {
147 143
         $items[] = 'gform_settings';
148 144
         $items[] = 'gv-admin-edd-license';
149 145
 
@@ -157,8 +153,7 @@  discard block
 block discarded – undo
157 153
      *
158 154
      * @return string
159 155
      */
160
-    public function body_class($css_class)
161
-    {
156
+    public function body_class($css_class) {
162 157
         if (!gravityview()->request->is_admin('', 'settings')) {
163 158
             return $css_class;
164 159
         }
@@ -178,8 +173,7 @@  discard block
 block discarded – undo
178 173
      * @param string                                     $html      HTML of the save button.
179 174
      * @param \Gravity_Forms\Gravity_Forms\Settings|null $framework Current instance of the Settings Framework. Or null if < 2.5.
180 175
      */
181
-    public function modify_gform_settings_save_button($html, $framework = null)
182
-    {
176
+    public function modify_gform_settings_save_button($html, $framework = null) {
183 177
         if (!gravityview()->request->is_admin('', 'settings')) {
184 178
             return $html;
185 179
         }
@@ -213,8 +207,7 @@  discard block
 block discarded – undo
213 207
      *
214 208
      * @return string|null HTML of the button.
215 209
      */
216
-    public function settings_save($field, $echo = true)
217
-    {
210
+    public function settings_save($field, $echo = true) {
218 211
         $field['type'] = 'submit';
219 212
         $field['name'] = 'gform-settings-save';
220 213
         $field['class'] = 'button button-primary primary button-hero';
@@ -238,8 +231,7 @@  discard block
 block discarded – undo
238 231
      *
239 232
      * @return array
240 233
      */
241
-    public function modify_app_settings_menu_title($setting_tabs)
242
-    {
234
+    public function modify_app_settings_menu_title($setting_tabs) {
243 235
         $setting_tabs[0]['label'] = __('GravityView Settings', 'gravityview');
244 236
         $setting_tabs[0]['icon'] = 'dashicons-admin-settings';
245 237
 
@@ -251,8 +243,7 @@  discard block
 block discarded – undo
251 243
      *
252 244
      * @return void
253 245
      */
254
-    public function init_ajax()
255
-    {
246
+    public function init_ajax() {
256 247
         $this->_load_license_handler();
257 248
     }
258 249
 
@@ -261,8 +252,7 @@  discard block
 block discarded – undo
261 252
      *
262 253
      * @return void
263 254
      */
264
-    private function _load_license_handler()
265
-    {
255
+    private function _load_license_handler() {
266 256
         if (!empty($this->License_Handler)) {
267 257
             return;
268 258
         }
@@ -276,8 +266,7 @@  discard block
 block discarded – undo
276 266
      *
277 267
      * @return void
278 268
      */
279
-    public function add_network_menu()
280
-    {
269
+    public function add_network_menu() {
281 270
         if (!gravityview()->plugin->is_network_activated()) {
282 271
             return;
283 272
         }
@@ -292,8 +281,7 @@  discard block
 block discarded – undo
292 281
      *
293 282
      * @return bool
294 283
      */
295
-    public function uninstall()
296
-    {
284
+    public function uninstall() {
297 285
         gravityview()->plugin->uninstall();
298 286
 
299 287
         /**
@@ -319,8 +307,7 @@  discard block
 block discarded – undo
319 307
      *
320 308
      * @return bool
321 309
      */
322
-    public function current_user_can_any($caps)
323
-    {
310
+    public function current_user_can_any($caps) {
324 311
         if (empty($caps)) {
325 312
             $caps = ['gravityview_full_access'];
326 313
         }
@@ -328,8 +315,7 @@  discard block
 block discarded – undo
328 315
         return \GVCommon::has_cap($caps);
329 316
     }
330 317
 
331
-    public function uninstall_warning_message()
332
-    {
318
+    public function uninstall_warning_message() {
333 319
         $heading = esc_html__('If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview');
334 320
         $message = esc_html__('Delete all Views, GravityView entry approval status, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings.', 'gravityview');
335 321
 
@@ -343,8 +329,7 @@  discard block
 block discarded – undo
343 329
      *
344 330
      * @return array Array of reasons with the label and followup questions for each uninstall reason
345 331
      */
346
-    private function get_uninstall_reasons()
347
-    {
332
+    private function get_uninstall_reasons() {
348 333
         $reasons = [
349 334
             'will-continue'  => [
350 335
                 'label' => esc_html__('I am going to continue using GravityView', 'gravityview'),
@@ -376,8 +361,7 @@  discard block
 block discarded – undo
376 361
      *
377 362
      * @return string HTML of the uninstallation form
378 363
      */
379
-    public function uninstall_form()
380
-    {
364
+    public function uninstall_form() {
381 365
         ob_start();
382 366
 
383 367
         $user = wp_get_current_user(); ?>
@@ -524,8 +508,7 @@  discard block
 block discarded – undo
524 508
         return $form;
525 509
     }
526 510
 
527
-    public function app_settings_tab()
528
-    {
511
+    public function app_settings_tab() {
529 512
         parent::app_settings_tab();
530 513
 
531 514
         if ($this->maybe_uninstall()) {
@@ -538,8 +521,7 @@  discard block
 block discarded – undo
538 521
      *
539 522
      * @return string
540 523
      */
541
-    public function app_settings_title()
542
-    {
524
+    public function app_settings_title() {
543 525
         return null;
544 526
     }
545 527
 
@@ -548,8 +530,7 @@  discard block
 block discarded – undo
548 530
      *
549 531
      * @return string
550 532
      */
551
-    public function app_settings_icon()
552
-    {
533
+    public function app_settings_icon() {
553 534
         return '&nbsp;';
554 535
     }
555 536
 
@@ -562,8 +543,7 @@  discard block
 block discarded – undo
562 543
      *
563 544
      * @deprecated Use \GV\Addon_Settings::get
564 545
      */
565
-    public function get_app_setting($setting_name)
566
-    {
546
+    public function get_app_setting($setting_name) {
567 547
         return $this->get($setting_name);
568 548
     }
569 549
 
@@ -575,8 +555,7 @@  discard block
 block discarded – undo
575 555
      *
576 556
      * @return mixed The setting value.
577 557
      */
578
-    public function get($key, $default = null)
579
-    {
558
+    public function get($key, $default = null) {
580 559
 
581 560
         /**
582 561
          * Backward compatibility with Redux.
@@ -605,8 +584,7 @@  discard block
 block discarded – undo
605 584
      *
606 585
      * @deprecated Use gravityview()->plugin->settings->get()
607 586
      */
608
-    public static function getSetting($key)
609
-    {
587
+    public static function getSetting($key) {
610 588
         if (gravityview()->plugin->settings instanceof Addon_Settings) {
611 589
             return gravityview()->plugin->settings->get($key);
612 590
         }
@@ -619,8 +597,7 @@  discard block
 block discarded – undo
619 597
      *
620 598
      * @deprecated Use \GV\Addon_Settings::all() or \GV\Addon_Settings::get()
621 599
      */
622
-    public function get_app_settings()
623
-    {
600
+    public function get_app_settings() {
624 601
         return $this->all();
625 602
     }
626 603
 
@@ -629,8 +606,7 @@  discard block
 block discarded – undo
629 606
      *
630 607
      * @return array The settings.
631 608
      */
632
-    public function all()
633
-    {
609
+    public function all() {
634 610
         $option_name = 'gravityformsaddon_'.$this->_slug.'_app_settings';
635 611
 
636 612
         if ($this->has_site_settings()) {
@@ -651,8 +627,7 @@  discard block
 block discarded – undo
651 627
      *
652 628
      * @deprecated Use \GV\Addon_Settings::defaults()
653 629
      */
654
-    public function get_default_settings()
655
-    {
630
+    public function get_default_settings() {
656 631
         return $this->defaults();
657 632
     }
658 633
 
@@ -661,8 +636,7 @@  discard block
 block discarded – undo
661 636
      *
662 637
      * @return array The defaults.
663 638
      */
664
-    private function defaults()
665
-    {
639
+    private function defaults() {
666 640
         $defaults = [
667 641
             // Set the default license in wp-config.php
668 642
             'license_key'          => defined('GRAVITYVIEW_LICENSE_KEY') ? GRAVITYVIEW_LICENSE_KEY : '',
@@ -694,8 +668,7 @@  discard block
 block discarded – undo
694 668
      *
695 669
      * @return string The HTML
696 670
      */
697
-    public function as_html($field, $echo = true)
698
-    {
671
+    public function as_html($field, $echo = true) {
699 672
         $field['type'] = (isset($field['type']) && in_array($field['type'], ['submit', 'reset', 'button'])) ? $field['type'] : 'submit';
700 673
 
701 674
         $attributes = $this->get_field_attributes($field);
@@ -728,8 +701,7 @@  discard block
 block discarded – undo
728 701
     /**
729 702
      * @deprecated Use \GV\Addon_Settings::as_html
730 703
      */
731
-    public function settings_submit($field, $echo = true)
732
-    {
704
+    public function settings_submit($field, $echo = true) {
733 705
         gravityview()->log->warning('\GV\Addon_Settings::settings_submit has been deprecated for \GV\Addon_Settings::as_html');
734 706
 
735 707
         return $this->as_html($field, $echo);
@@ -744,8 +716,7 @@  discard block
 block discarded – undo
744 716
      *
745 717
      * @return bool
746 718
      */
747
-    public function is_save_postback()
748
-    {
719
+    public function is_save_postback() {
749 720
         return isset($_POST['gform-settings-save']) && isset($_POST['_gravityview_save_settings_nonce']);
750 721
     }
751 722
 
@@ -754,8 +725,7 @@  discard block
 block discarded – undo
754 725
      *
755 726
      * @return void
756 727
      */
757
-    public function license_key_notice()
758
-    {
728
+    public function license_key_notice() {
759 729
         if ('uninstall' === rgget('view')) {
760 730
             return; // Do not display license notice on the uninstall page in GF 2.5
761 731
         }
@@ -845,8 +815,7 @@  discard block
 block discarded – undo
845 815
      *
846 816
      * @return \GV\License_Handler
847 817
      */
848
-    public function get_license_handler()
849
-    {
818
+    public function get_license_handler() {
850 819
         return $this->License_Handler;
851 820
     }
852 821
 
@@ -858,8 +827,7 @@  discard block
 block discarded – undo
858 827
      *
859 828
      * @return array Array of scripts
860 829
      */
861
-    public function scripts()
862
-    {
830
+    public function scripts() {
863 831
         $scripts = parent::scripts();
864 832
 
865 833
         $scripts[] = [
@@ -879,8 +847,7 @@  discard block
 block discarded – undo
879 847
      *
880 848
      * @return array
881 849
      */
882
-    public function styles()
883
-    {
850
+    public function styles() {
884 851
         $styles = parent::styles();
885 852
 
886 853
         $deps = [
@@ -923,8 +890,7 @@  discard block
 block discarded – undo
923 890
      *
924 891
      * @return bool
925 892
      */
926
-    private function has_site_settings()
927
-    {
893
+    private function has_site_settings() {
928 894
         return (!is_multisite()) || is_main_site() || (!gravityview()->plugin->is_network_activated()) || (is_network_admin() && gravityview()->plugin->is_network_activated());
929 895
     }
930 896
 
@@ -933,8 +899,7 @@  discard block
 block discarded – undo
933 899
      *
934 900
      * @return void
935 901
      */
936
-    public function create_app_menu()
937
-    {
902
+    public function create_app_menu() {
938 903
 
939 904
         /**
940 905
          * Override whether to show the Settings menu on a per-blog basis.
@@ -960,8 +925,7 @@  discard block
 block discarded – undo
960 925
      *
961 926
      * @return string - Returns markup of the required indicator symbol
962 927
      */
963
-    public function get_required_indicator($field)
964
-    {
928
+    public function get_required_indicator($field) {
965 929
         return '<span class="required" title="'.esc_attr__('Required', 'gravityview').'">*</span>';
966 930
     }
967 931
 
@@ -970,8 +934,7 @@  discard block
 block discarded – undo
970 934
      *
971 935
      * @return array
972 936
      */
973
-    public function app_settings_fields()
974
-    {
937
+    public function app_settings_fields() {
975 938
         $default_settings = $this->defaults();
976 939
 
977 940
         $disabled_attribute = \GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled';
@@ -1228,8 +1191,7 @@  discard block
 block discarded – undo
1228 1191
      *
1229 1192
      * @deprecated Use \GV\Addon_Settings::set or \GV\Addon_Settings::update
1230 1193
      */
1231
-    public function update_app_settings($settings)
1232
-    {
1194
+    public function update_app_settings($settings) {
1233 1195
         return $this->update($settings);
1234 1196
     }
1235 1197
 
@@ -1239,8 +1201,7 @@  discard block
 block discarded – undo
1239 1201
      * @param array|string An array of settings to update, or string (key) and $value to update one setting.
1240 1202
      * @param mixed $value A value if $settings is string (key). Default: null.
1241 1203
      */
1242
-    public function set($settings, $value = null)
1243
-    {
1204
+    public function set($settings, $value = null) {
1244 1205
         if (is_string($settings)) {
1245 1206
             $settings = [$settings => $value];
1246 1207
         }
@@ -1256,8 +1217,7 @@  discard block
 block discarded – undo
1256 1217
      *
1257 1218
      * @return bool False if value was not updated and true if value was updated.
1258 1219
      */
1259
-    public function update($settings)
1260
-    {
1220
+    public function update($settings) {
1261 1221
         return update_option('gravityformsaddon_'.$this->_slug.'_app_settings', $settings);
1262 1222
     }
1263 1223
 
@@ -1269,8 +1229,7 @@  discard block
 block discarded – undo
1269 1229
      *
1270 1230
      * @return string
1271 1231
      */
1272
-    public function settings_edd_license($field, $echo = true)
1273
-    {
1232
+    public function settings_edd_license($field, $echo = true) {
1274 1233
         if (defined('GRAVITYVIEW_LICENSE_KEY') && GRAVITYVIEW_LICENSE_KEY) {
1275 1234
             $field['input_type'] = 'password';
1276 1235
         }
@@ -1300,8 +1259,7 @@  discard block
 block discarded – undo
1300 1259
      *
1301 1260
      * @return string
1302 1261
      */
1303
-    protected function settings_html($field, $echo = true)
1304
-    {
1262
+    protected function settings_html($field, $echo = true) {
1305 1263
         $return = \GV\Utils::get($field, 'value', '');
1306 1264
 
1307 1265
         if ($echo) {
@@ -1320,8 +1278,7 @@  discard block
 block discarded – undo
1320 1278
      *
1321 1279
      * @return void
1322 1280
      */
1323
-    public function single_setting_row_html($field)
1324
-    {
1281
+    public function single_setting_row_html($field) {
1325 1282
         ?>
1326 1283
 
1327 1284
 		<tr id="gaddon-setting-row-<?php echo esc_attr($field['name']); ?>">
@@ -1347,8 +1304,7 @@  discard block
 block discarded – undo
1347 1304
      *
1348 1305
      * @return void
1349 1306
      */
1350
-    public function single_setting_row($field)
1351
-    {
1307
+    public function single_setting_row($field) {
1352 1308
         $field['gv_description'] = Utils::get($field, 'description');
1353 1309
         $field['description'] = Utils::get($field, 'subtitle');
1354 1310
         parent::single_setting_row($field);
@@ -1361,8 +1317,7 @@  discard block
 block discarded – undo
1361 1317
      *
1362 1318
      * @param $field array
1363 1319
      */
1364
-    public function single_setting_label($field)
1365
-    {
1320
+    public function single_setting_label($field) {
1366 1321
         parent::single_setting_label($field);
1367 1322
         if ($description = Utils::get($field, 'gv_description')) {
1368 1323
             echo '<span class="description">'.$description.'</span>';
@@ -1377,8 +1332,7 @@  discard block
 block discarded – undo
1377 1332
      *
1378 1333
      * @return void
1379 1334
      */
1380
-    public function maybe_save_app_settings()
1381
-    {
1335
+    public function maybe_save_app_settings() {
1382 1336
         if ($this->is_save_postback()) {
1383 1337
             if (!\GVCommon::has_cap('gravityview_edit_settings')) {
1384 1338
                 $_POST = []; // If you don't reset the $_POST array, it *looks* like the settings were changed, but they weren't
@@ -1395,8 +1349,7 @@  discard block
 block discarded – undo
1395 1349
      *
1396 1350
      * @return array settings from parent::get_posted_settings(), with `license_key_response` and `license_key_status` potentially unset
1397 1351
      */
1398
-    public function get_posted_settings()
1399
-    {
1352
+    public function get_posted_settings() {
1400 1353
         $posted_settings = parent::get_posted_settings();
1401 1354
 
1402 1355
         $local_key = Utils::get($posted_settings, 'license_key');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -422,7 +422,7 @@
 block discarded – undo
422 422
     </header>
423 423
     <div class="gform-settings-panel__content" style="padding: 0 1rem 1.25rem">
424 424
 
425
-HTML;
425
+html;
426 426
         } else {
427 427
             echo '<div class="gv-uninstall-form-wrapper" style="font-size: 110%; padding: 15px 0;">';
428 428
         } ?>
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gravityview.php 3 patches
Indentation   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -12,376 +12,376 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class gravityview extends \GV\Shortcode
14 14
 {
15
-    /**
16
-     * {@inheritDoc}
17
-     */
18
-    public $name = 'gravityview';
19
-
20
-    /**
21
-     * A stack of calls to track nested shortcodes.
22
-     */
23
-    public static $callstack = [];
24
-
25
-    /**
26
-     * Process and output the [gravityview] shortcode.
27
-     *
28
-     * @param array  $passed_atts The attributes passed.
29
-     * @param string $content     The content inside the shortcode.
30
-     * @param string $tag         The shortcode tag.
31
-     *
32
-     * @return string|null The output.
33
-     */
34
-    public function callback($passed_atts, $content = '', $tag = '')
35
-    {
36
-        $request = gravityview()->request;
37
-
38
-        if ($request->is_admin()) {
39
-            return '';
40
-        }
41
-
42
-        $atts = wp_parse_args($passed_atts, [
43
-            'id'      => 0,
44
-            'view_id' => 0,
45
-            'detail'  => null,
46
-            'class'   => '',
47
-        ]);
48
-
49
-        if (!$view_id = $atts['id'] ?: $atts['view_id']) {
50
-            if ($atts['detail'] && $view = $request->is_view()) {
51
-                $view_id = $view->ID;
52
-            }
53
-        }
54
-
55
-        $view = \GV\View::by_id($view_id);
56
-
57
-        if (!$view) {
58
-            gravityview()->log->error('View does not exist #{view_id}', ['view_id' => $view_id]);
59
-
60
-            return '';
61
-        }
62
-
63
-        $post = get_post($view->ID);
64
-
65
-        $gv_view_data = \GravityView_View_Data::getInstance();
66
-
67
-        if (!$gv_view_data->views->contains($view->ID)) {
68
-            $gv_view_data->views->add($view);
69
-        }
70
-
71
-        /**
72
-         * @action `gravityview/shortcode/before-processing` Runs before the GV shortcode is processed; can be used to load additional scripts/styles
73
-         *
74
-         * @since  2.13.4
75
-         *
76
-         * @param \GV\View $view GV View
77
-         * @param \WP_Post $post Associated WP post
78
-         */
79
-        do_action('gravityview/shortcode/before-processing', $view, $post);
80
-
81
-        gravityview()->views->set($view);
82
-
83
-        /**
84
-         * When this shortcode is embedded inside a View we can only display it as a directory. There's no other way.
85
-         * Try to detect that we're not embedded to allow edit and single contexts.
86
-         */
87
-        $is_reembedded = false; // Assume not embedded unless detected otherwise.
88
-        if (in_array(get_class($request), ['GV\Frontend_Request', 'GV\Mock_Request'])) {
89
-            if (($_view = $request->is_view()) && $_view->ID !== $view->ID) {
90
-                $is_reembedded = true;
91
-            } elseif ($request->is_entry($view->form ? $view->form->ID : 0) && self::$callstack) {
92
-                $is_reembedded = true;
93
-            }
94
-        }
95
-
96
-        array_push(self::$callstack, true);
97
-
98
-        /**
99
-         * Remove Widgets on a nested embedded View.
100
-         */
101
-        if ($is_reembedded) {
102
-            $view->widgets = new \GV\Widget_Collection();
103
-        }
104
-
105
-        $atts = $this->parse_and_sanitize_atts($atts);
106
-
107
-        $view->settings->update(['shortcode_atts' => $atts]);
108
-        $view->settings->update($atts);
109
-
110
-        /**
111
-         * Check permissions.
112
-         */
113
-        while ($error = $view->can_render(['shortcode'], $request)) {
114
-            if (!is_wp_error($error)) {
115
-                break;
116
-            }
117
-
118
-            switch (str_replace('gravityview/', '', $error->get_error_code())) {
119
-                case 'post_password_required':
120
-                    return self::_return(get_the_password_form($view->ID));
121
-                case 'no_form_attached':
122
-                    /**
123
-                     * This View has no data source. There's nothing to show really.
124
-                     * ...apart from a nice message if the user can do anything about it.
125
-                     */
126
-                    if (\GVCommon::has_cap(['edit_gravityviews', 'edit_gravityview'], $view->ID)) {
127
-                        return self::_return(sprintf(__('This View is not configured properly. Start by <a href="%s">selecting a form</a>.', 'gravityview'), esc_url(get_edit_post_link($view->ID, false))));
128
-                    }
129
-                    break;
130
-                case 'no_direct_access':
131
-                case 'embed_only':
132
-                case 'not_public':
133
-                default:
134
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
135
-            }
136
-        }
137
-
138
-        $is_admin_and_can_view = $view->settings->get('admin_show_all_statuses') && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID);
139
-
140
-        /**
141
-         * View details.
142
-         */
143
-        if ($atts['detail']) {
144
-            $entries = $view->get_entries($request);
145
-
146
-            return self::_return($this->detail($view, $entries, $atts));
147
-
148
-        /**
149
-         * Editing a single entry.
150
-         */
151
-        } elseif (!$is_reembedded && ($entry = $request->is_edit_entry($view->form ? $view->form->ID : 0))) {
152
-
153
-            /**
154
-             * When editing an entry don't render multiple views.
155
-             */
156
-            if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
157
-                gravityview()->log->notice('Entry ID #{entry_id} not rendered because another View ID was passed using `?gvid`: #{selected}', ['entry_id' => $entry->ID, 'selected' => $selected]);
158
-
159
-                return self::_return('');
160
-            }
161
-
162
-            if ($entry['status'] != 'active') {
163
-                gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $entry->ID]);
164
-
165
-                return self::_return(__('You are not allowed to view this content.', 'gravityview'));
166
-            }
167
-
168
-            if (apply_filters('gravityview_custom_entry_slug', false) && $entry->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
169
-                gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $entry->ID]);
170
-
171
-                return self::_return(__('You are not allowed to view this content.', 'gravityview'));
172
-            }
173
-
174
-            if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
175
-                if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($entry->ID, \GravityView_Entry_Approval::meta_key))) {
176
-                    gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $entry->ID]);
177
-
178
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
179
-                }
180
-            }
181
-
182
-            $renderer = new \GV\Edit_Entry_Renderer();
183
-
184
-            return self::_return($renderer->render($entry, $view, $request));
185
-
186
-        /**
187
-         * Viewing a single entry.
188
-         */
189
-        } elseif (!$is_reembedded && ($entry = $request->is_entry($view->form ? $view->form->ID : 0))) {
190
-            /**
191
-             * When viewing an entry don't render multiple views.
192
-             */
193
-            if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
194
-                return self::_return('');
195
-            }
196
-
197
-            $entryset = $entry->is_multi() ? $entry->entries : [$entry];
198
-
199
-            foreach ($entryset as $e) {
200
-                if ($e['status'] != 'active') {
201
-                    gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $e->ID]);
202
-
203
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
204
-                }
205
-
206
-                if (apply_filters('gravityview_custom_entry_slug', false) && $e->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
207
-                    gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $e->ID]);
208
-
209
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
210
-                }
211
-
212
-                if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
213
-                    if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($e->ID, \GravityView_Entry_Approval::meta_key))) {
214
-                        gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $e->ID]);
215
-
216
-                        return self::_return(__('You are not allowed to view this content.', 'gravityview'));
217
-                    }
218
-                }
219
-
220
-                $error = \GVCommon::check_entry_display($e->as_entry(), $view);
221
-
222
-                if (is_wp_error($error)) {
223
-                    gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing: {message}', ['entry_id' => $e->ID, 'message' => $error->get_error_message()]);
224
-
225
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
226
-                }
227
-            }
228
-
229
-            $renderer = new \GV\Entry_Renderer();
230
-
231
-            return self::_return($renderer->render($entry, $view, $request));
232
-
233
-        /**
234
-         * Just this view.
235
-         */
236
-        } else {
237
-            if ($is_reembedded) {
238
-
239
-                // Mock the request with the actual View, not the global one
240
-                $mock_request = new \GV\Mock_Request();
241
-                $mock_request->returns['is_view'] = $view;
242
-                $mock_request->returns['is_entry'] = $request->is_entry($view->form ? $view->form->ID : 0);
243
-                $mock_request->returns['is_edit_entry'] = $request->is_edit_entry($view->form ? $view->form->ID : 0);
244
-                $mock_request->returns['is_search'] = $request->is_search();
245
-
246
-                $request = $mock_request;
247
-            }
248
-
249
-            $renderer = new \GV\View_Renderer();
250
-
251
-            return self::_return($renderer->render($view, $request));
252
-        }
253
-    }
254
-
255
-    /**
256
-     * Validate attributes passed to the [gravityview] shortcode. Supports {get} Merge Tags values.
257
-     *
258
-     * Attributes passed to the shortcode are compared to registered attributes {@see \GV\View_Settings::defaults}
259
-     * Only attributes that are defined will be allowed through.
260
-     *
261
-     * Then, {get} merge tags are replaced with their $_GET values, if passed
262
-     *
263
-     * Then, attributes are sanitized based on the type of setting (number, checkbox, select, radio, text)
264
-     *
265
-     * @see \GV\View_Settings::defaults() Only attributes defined in default() are valid to be passed via the shortcode
266
-     *
267
-     * @param array $passed_atts Attribute pairs defined to render the View
268
-     *
269
-     * @return array Valid and sanitized attribute pairs
270
-     */
271
-    private function parse_and_sanitize_atts($passed_atts)
272
-    {
273
-        $defaults = \GV\View_Settings::defaults(true);
274
-
275
-        $supported_atts = array_fill_keys(array_keys($defaults), '');
276
-
277
-        // Whittle down the attributes to only valid pairs
278
-        $filtered_atts = shortcode_atts($supported_atts, $passed_atts, 'gravityview');
279
-
280
-        // Only keep the passed attributes after making sure that they're valid pairs
281
-        $filtered_atts = array_intersect_key((array) $passed_atts, $filtered_atts);
282
-
283
-        $atts = [];
284
-
285
-        foreach ($filtered_atts as $key => $passed_value) {
286
-
287
-            // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
288
-            $passed_value = \GravityView_Merge_Tags::replace_variables($passed_value);
289
-
290
-            switch ($defaults[$key]['type']) {
291
-
292
-                /**
293
-                 * Make sure number fields are numeric.
294
-                 * Also, convert mixed number strings to numbers.
295
-                 *
296
-                 * @see http://php.net/manual/en/function.is-numeric.php#107326
297
-                 */
298
-                case 'number':
299
-                    if (is_numeric($passed_value)) {
300
-                        $atts[$key] = ($passed_value + 0);
301
-                    }
302
-                    break;
303
-
304
-                // Checkboxes should be 1 or 0
305
-                case 'checkbox':
306
-                    $atts[$key] = gv_empty($passed_value, true, false) ? 0 : 1;
307
-                    break;
308
-
309
-                /**
310
-                 * Only allow values that are defined in the settings.
311
-                 */
312
-                case 'select':
313
-                case 'radio':
314
-                    $options = isset($defaults[$key]['choices']) ? $defaults[$key]['choices'] : $defaults[$key]['options'];
315
-                    if (in_array($passed_value, array_keys($options))) {
316
-                        $atts[$key] = $passed_value;
317
-                    }
318
-                    break;
319
-
320
-                case 'text':
321
-                default:
322
-                    $atts[$key] = $passed_value;
323
-                    break;
324
-            }
325
-        }
326
-
327
-        $atts['detail'] = \GV\Utils::get($passed_atts, 'detail', null);
328
-
329
-        return $atts;
330
-    }
331
-
332
-    /**
333
-     * Output view details.
334
-     *
335
-     * @param \GV\View             $view    The View.
336
-     * @param \GV\Entry_Collection $entries The calculated entries.
337
-     * @param array                $atts    The shortcode attributes (with defaults).
338
-     *
339
-     * @return string The output.
340
-     */
341
-    private function detail($view, $entries, $atts)
342
-    {
343
-        $output = '';
344
-
345
-        switch ($key = $atts['detail']) {
346
-            case 'total_entries':
347
-                $output = number_format_i18n($entries->total());
348
-                break;
349
-            case 'first_entry':
350
-                $output = number_format_i18n(min($entries->total(), $view->settings->get('offset') + 1));
351
-                break;
352
-            case 'last_entry':
353
-                $output = number_format_i18n($view->settings->get('page_size') + $view->settings->get('offset'));
354
-                break;
355
-            case 'page_size':
356
-                $output = number_format_i18n($view->settings->get($key));
357
-                break;
358
-        }
359
-
360
-        /**
361
-         * @filter `gravityview/shortcode/detail/{$detail}` Filter the detail output returned from `[gravityview detail="$detail"]`
362
-         *
363
-         * @since 1.13
364
-         *
365
-         * @param string[in,out] $output Existing output
366
-         *
367
-         * @since 2.0.3
368
-         *
369
-         * @param \GV\View             $view    The view.
370
-         * @param \GV\Entry_Collection $entries The entries.
371
-         * @param array                $atts    The shortcode atts with defaults.
372
-         */
373
-        $output = apply_filters("gravityview/shortcode/detail/$key", $output, $view);
374
-
375
-        return $output;
376
-    }
377
-
378
-    /**
379
-     * Pop the callstack and return the value.
380
-     */
381
-    private static function _return($value)
382
-    {
383
-        array_pop(self::$callstack);
384
-
385
-        return $value;
386
-    }
15
+	/**
16
+	 * {@inheritDoc}
17
+	 */
18
+	public $name = 'gravityview';
19
+
20
+	/**
21
+	 * A stack of calls to track nested shortcodes.
22
+	 */
23
+	public static $callstack = [];
24
+
25
+	/**
26
+	 * Process and output the [gravityview] shortcode.
27
+	 *
28
+	 * @param array  $passed_atts The attributes passed.
29
+	 * @param string $content     The content inside the shortcode.
30
+	 * @param string $tag         The shortcode tag.
31
+	 *
32
+	 * @return string|null The output.
33
+	 */
34
+	public function callback($passed_atts, $content = '', $tag = '')
35
+	{
36
+		$request = gravityview()->request;
37
+
38
+		if ($request->is_admin()) {
39
+			return '';
40
+		}
41
+
42
+		$atts = wp_parse_args($passed_atts, [
43
+			'id'      => 0,
44
+			'view_id' => 0,
45
+			'detail'  => null,
46
+			'class'   => '',
47
+		]);
48
+
49
+		if (!$view_id = $atts['id'] ?: $atts['view_id']) {
50
+			if ($atts['detail'] && $view = $request->is_view()) {
51
+				$view_id = $view->ID;
52
+			}
53
+		}
54
+
55
+		$view = \GV\View::by_id($view_id);
56
+
57
+		if (!$view) {
58
+			gravityview()->log->error('View does not exist #{view_id}', ['view_id' => $view_id]);
59
+
60
+			return '';
61
+		}
62
+
63
+		$post = get_post($view->ID);
64
+
65
+		$gv_view_data = \GravityView_View_Data::getInstance();
66
+
67
+		if (!$gv_view_data->views->contains($view->ID)) {
68
+			$gv_view_data->views->add($view);
69
+		}
70
+
71
+		/**
72
+		 * @action `gravityview/shortcode/before-processing` Runs before the GV shortcode is processed; can be used to load additional scripts/styles
73
+		 *
74
+		 * @since  2.13.4
75
+		 *
76
+		 * @param \GV\View $view GV View
77
+		 * @param \WP_Post $post Associated WP post
78
+		 */
79
+		do_action('gravityview/shortcode/before-processing', $view, $post);
80
+
81
+		gravityview()->views->set($view);
82
+
83
+		/**
84
+		 * When this shortcode is embedded inside a View we can only display it as a directory. There's no other way.
85
+		 * Try to detect that we're not embedded to allow edit and single contexts.
86
+		 */
87
+		$is_reembedded = false; // Assume not embedded unless detected otherwise.
88
+		if (in_array(get_class($request), ['GV\Frontend_Request', 'GV\Mock_Request'])) {
89
+			if (($_view = $request->is_view()) && $_view->ID !== $view->ID) {
90
+				$is_reembedded = true;
91
+			} elseif ($request->is_entry($view->form ? $view->form->ID : 0) && self::$callstack) {
92
+				$is_reembedded = true;
93
+			}
94
+		}
95
+
96
+		array_push(self::$callstack, true);
97
+
98
+		/**
99
+		 * Remove Widgets on a nested embedded View.
100
+		 */
101
+		if ($is_reembedded) {
102
+			$view->widgets = new \GV\Widget_Collection();
103
+		}
104
+
105
+		$atts = $this->parse_and_sanitize_atts($atts);
106
+
107
+		$view->settings->update(['shortcode_atts' => $atts]);
108
+		$view->settings->update($atts);
109
+
110
+		/**
111
+		 * Check permissions.
112
+		 */
113
+		while ($error = $view->can_render(['shortcode'], $request)) {
114
+			if (!is_wp_error($error)) {
115
+				break;
116
+			}
117
+
118
+			switch (str_replace('gravityview/', '', $error->get_error_code())) {
119
+				case 'post_password_required':
120
+					return self::_return(get_the_password_form($view->ID));
121
+				case 'no_form_attached':
122
+					/**
123
+					 * This View has no data source. There's nothing to show really.
124
+					 * ...apart from a nice message if the user can do anything about it.
125
+					 */
126
+					if (\GVCommon::has_cap(['edit_gravityviews', 'edit_gravityview'], $view->ID)) {
127
+						return self::_return(sprintf(__('This View is not configured properly. Start by <a href="%s">selecting a form</a>.', 'gravityview'), esc_url(get_edit_post_link($view->ID, false))));
128
+					}
129
+					break;
130
+				case 'no_direct_access':
131
+				case 'embed_only':
132
+				case 'not_public':
133
+				default:
134
+					return self::_return(__('You are not allowed to view this content.', 'gravityview'));
135
+			}
136
+		}
137
+
138
+		$is_admin_and_can_view = $view->settings->get('admin_show_all_statuses') && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID);
139
+
140
+		/**
141
+		 * View details.
142
+		 */
143
+		if ($atts['detail']) {
144
+			$entries = $view->get_entries($request);
145
+
146
+			return self::_return($this->detail($view, $entries, $atts));
147
+
148
+		/**
149
+		 * Editing a single entry.
150
+		 */
151
+		} elseif (!$is_reembedded && ($entry = $request->is_edit_entry($view->form ? $view->form->ID : 0))) {
152
+
153
+			/**
154
+			 * When editing an entry don't render multiple views.
155
+			 */
156
+			if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
157
+				gravityview()->log->notice('Entry ID #{entry_id} not rendered because another View ID was passed using `?gvid`: #{selected}', ['entry_id' => $entry->ID, 'selected' => $selected]);
158
+
159
+				return self::_return('');
160
+			}
161
+
162
+			if ($entry['status'] != 'active') {
163
+				gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $entry->ID]);
164
+
165
+				return self::_return(__('You are not allowed to view this content.', 'gravityview'));
166
+			}
167
+
168
+			if (apply_filters('gravityview_custom_entry_slug', false) && $entry->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
169
+				gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $entry->ID]);
170
+
171
+				return self::_return(__('You are not allowed to view this content.', 'gravityview'));
172
+			}
173
+
174
+			if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
175
+				if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($entry->ID, \GravityView_Entry_Approval::meta_key))) {
176
+					gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $entry->ID]);
177
+
178
+					return self::_return(__('You are not allowed to view this content.', 'gravityview'));
179
+				}
180
+			}
181
+
182
+			$renderer = new \GV\Edit_Entry_Renderer();
183
+
184
+			return self::_return($renderer->render($entry, $view, $request));
185
+
186
+		/**
187
+		 * Viewing a single entry.
188
+		 */
189
+		} elseif (!$is_reembedded && ($entry = $request->is_entry($view->form ? $view->form->ID : 0))) {
190
+			/**
191
+			 * When viewing an entry don't render multiple views.
192
+			 */
193
+			if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
194
+				return self::_return('');
195
+			}
196
+
197
+			$entryset = $entry->is_multi() ? $entry->entries : [$entry];
198
+
199
+			foreach ($entryset as $e) {
200
+				if ($e['status'] != 'active') {
201
+					gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $e->ID]);
202
+
203
+					return self::_return(__('You are not allowed to view this content.', 'gravityview'));
204
+				}
205
+
206
+				if (apply_filters('gravityview_custom_entry_slug', false) && $e->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
207
+					gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $e->ID]);
208
+
209
+					return self::_return(__('You are not allowed to view this content.', 'gravityview'));
210
+				}
211
+
212
+				if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
213
+					if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($e->ID, \GravityView_Entry_Approval::meta_key))) {
214
+						gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $e->ID]);
215
+
216
+						return self::_return(__('You are not allowed to view this content.', 'gravityview'));
217
+					}
218
+				}
219
+
220
+				$error = \GVCommon::check_entry_display($e->as_entry(), $view);
221
+
222
+				if (is_wp_error($error)) {
223
+					gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing: {message}', ['entry_id' => $e->ID, 'message' => $error->get_error_message()]);
224
+
225
+					return self::_return(__('You are not allowed to view this content.', 'gravityview'));
226
+				}
227
+			}
228
+
229
+			$renderer = new \GV\Entry_Renderer();
230
+
231
+			return self::_return($renderer->render($entry, $view, $request));
232
+
233
+		/**
234
+		 * Just this view.
235
+		 */
236
+		} else {
237
+			if ($is_reembedded) {
238
+
239
+				// Mock the request with the actual View, not the global one
240
+				$mock_request = new \GV\Mock_Request();
241
+				$mock_request->returns['is_view'] = $view;
242
+				$mock_request->returns['is_entry'] = $request->is_entry($view->form ? $view->form->ID : 0);
243
+				$mock_request->returns['is_edit_entry'] = $request->is_edit_entry($view->form ? $view->form->ID : 0);
244
+				$mock_request->returns['is_search'] = $request->is_search();
245
+
246
+				$request = $mock_request;
247
+			}
248
+
249
+			$renderer = new \GV\View_Renderer();
250
+
251
+			return self::_return($renderer->render($view, $request));
252
+		}
253
+	}
254
+
255
+	/**
256
+	 * Validate attributes passed to the [gravityview] shortcode. Supports {get} Merge Tags values.
257
+	 *
258
+	 * Attributes passed to the shortcode are compared to registered attributes {@see \GV\View_Settings::defaults}
259
+	 * Only attributes that are defined will be allowed through.
260
+	 *
261
+	 * Then, {get} merge tags are replaced with their $_GET values, if passed
262
+	 *
263
+	 * Then, attributes are sanitized based on the type of setting (number, checkbox, select, radio, text)
264
+	 *
265
+	 * @see \GV\View_Settings::defaults() Only attributes defined in default() are valid to be passed via the shortcode
266
+	 *
267
+	 * @param array $passed_atts Attribute pairs defined to render the View
268
+	 *
269
+	 * @return array Valid and sanitized attribute pairs
270
+	 */
271
+	private function parse_and_sanitize_atts($passed_atts)
272
+	{
273
+		$defaults = \GV\View_Settings::defaults(true);
274
+
275
+		$supported_atts = array_fill_keys(array_keys($defaults), '');
276
+
277
+		// Whittle down the attributes to only valid pairs
278
+		$filtered_atts = shortcode_atts($supported_atts, $passed_atts, 'gravityview');
279
+
280
+		// Only keep the passed attributes after making sure that they're valid pairs
281
+		$filtered_atts = array_intersect_key((array) $passed_atts, $filtered_atts);
282
+
283
+		$atts = [];
284
+
285
+		foreach ($filtered_atts as $key => $passed_value) {
286
+
287
+			// Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
288
+			$passed_value = \GravityView_Merge_Tags::replace_variables($passed_value);
289
+
290
+			switch ($defaults[$key]['type']) {
291
+
292
+				/**
293
+				 * Make sure number fields are numeric.
294
+				 * Also, convert mixed number strings to numbers.
295
+				 *
296
+				 * @see http://php.net/manual/en/function.is-numeric.php#107326
297
+				 */
298
+				case 'number':
299
+					if (is_numeric($passed_value)) {
300
+						$atts[$key] = ($passed_value + 0);
301
+					}
302
+					break;
303
+
304
+				// Checkboxes should be 1 or 0
305
+				case 'checkbox':
306
+					$atts[$key] = gv_empty($passed_value, true, false) ? 0 : 1;
307
+					break;
308
+
309
+				/**
310
+				 * Only allow values that are defined in the settings.
311
+				 */
312
+				case 'select':
313
+				case 'radio':
314
+					$options = isset($defaults[$key]['choices']) ? $defaults[$key]['choices'] : $defaults[$key]['options'];
315
+					if (in_array($passed_value, array_keys($options))) {
316
+						$atts[$key] = $passed_value;
317
+					}
318
+					break;
319
+
320
+				case 'text':
321
+				default:
322
+					$atts[$key] = $passed_value;
323
+					break;
324
+			}
325
+		}
326
+
327
+		$atts['detail'] = \GV\Utils::get($passed_atts, 'detail', null);
328
+
329
+		return $atts;
330
+	}
331
+
332
+	/**
333
+	 * Output view details.
334
+	 *
335
+	 * @param \GV\View             $view    The View.
336
+	 * @param \GV\Entry_Collection $entries The calculated entries.
337
+	 * @param array                $atts    The shortcode attributes (with defaults).
338
+	 *
339
+	 * @return string The output.
340
+	 */
341
+	private function detail($view, $entries, $atts)
342
+	{
343
+		$output = '';
344
+
345
+		switch ($key = $atts['detail']) {
346
+			case 'total_entries':
347
+				$output = number_format_i18n($entries->total());
348
+				break;
349
+			case 'first_entry':
350
+				$output = number_format_i18n(min($entries->total(), $view->settings->get('offset') + 1));
351
+				break;
352
+			case 'last_entry':
353
+				$output = number_format_i18n($view->settings->get('page_size') + $view->settings->get('offset'));
354
+				break;
355
+			case 'page_size':
356
+				$output = number_format_i18n($view->settings->get($key));
357
+				break;
358
+		}
359
+
360
+		/**
361
+		 * @filter `gravityview/shortcode/detail/{$detail}` Filter the detail output returned from `[gravityview detail="$detail"]`
362
+		 *
363
+		 * @since 1.13
364
+		 *
365
+		 * @param string[in,out] $output Existing output
366
+		 *
367
+		 * @since 2.0.3
368
+		 *
369
+		 * @param \GV\View             $view    The view.
370
+		 * @param \GV\Entry_Collection $entries The entries.
371
+		 * @param array                $atts    The shortcode atts with defaults.
372
+		 */
373
+		$output = apply_filters("gravityview/shortcode/detail/$key", $output, $view);
374
+
375
+		return $output;
376
+	}
377
+
378
+	/**
379
+	 * Pop the callstack and return the value.
380
+	 */
381
+	private static function _return($value)
382
+	{
383
+		array_pop(self::$callstack);
384
+
385
+		return $value;
386
+	}
387 387
 }
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV\Shortcodes;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * A stack of calls to track nested shortcodes.
22 22
      */
23
-    public static $callstack = [];
23
+    public static $callstack = [ ];
24 24
 
25 25
     /**
26 26
      * Process and output the [gravityview] shortcode.
@@ -31,41 +31,41 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return string|null The output.
33 33
      */
34
-    public function callback($passed_atts, $content = '', $tag = '')
34
+    public function callback( $passed_atts, $content = '', $tag = '' )
35 35
     {
36 36
         $request = gravityview()->request;
37 37
 
38
-        if ($request->is_admin()) {
38
+        if ( $request->is_admin() ) {
39 39
             return '';
40 40
         }
41 41
 
42
-        $atts = wp_parse_args($passed_atts, [
42
+        $atts = wp_parse_args( $passed_atts, [
43 43
             'id'      => 0,
44 44
             'view_id' => 0,
45 45
             'detail'  => null,
46 46
             'class'   => '',
47
-        ]);
47
+        ] );
48 48
 
49
-        if (!$view_id = $atts['id'] ?: $atts['view_id']) {
50
-            if ($atts['detail'] && $view = $request->is_view()) {
49
+        if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) {
50
+            if ( $atts[ 'detail' ] && $view = $request->is_view() ) {
51 51
                 $view_id = $view->ID;
52 52
             }
53 53
         }
54 54
 
55
-        $view = \GV\View::by_id($view_id);
55
+        $view = \GV\View::by_id( $view_id );
56 56
 
57
-        if (!$view) {
58
-            gravityview()->log->error('View does not exist #{view_id}', ['view_id' => $view_id]);
57
+        if ( ! $view ) {
58
+            gravityview()->log->error( 'View does not exist #{view_id}', [ 'view_id' => $view_id ] );
59 59
 
60 60
             return '';
61 61
         }
62 62
 
63
-        $post = get_post($view->ID);
63
+        $post = get_post( $view->ID );
64 64
 
65 65
         $gv_view_data = \GravityView_View_Data::getInstance();
66 66
 
67
-        if (!$gv_view_data->views->contains($view->ID)) {
68
-            $gv_view_data->views->add($view);
67
+        if ( ! $gv_view_data->views->contains( $view->ID ) ) {
68
+            $gv_view_data->views->add( $view );
69 69
         }
70 70
 
71 71
         /**
@@ -76,179 +76,179 @@  discard block
 block discarded – undo
76 76
          * @param \GV\View $view GV View
77 77
          * @param \WP_Post $post Associated WP post
78 78
          */
79
-        do_action('gravityview/shortcode/before-processing', $view, $post);
79
+        do_action( 'gravityview/shortcode/before-processing', $view, $post );
80 80
 
81
-        gravityview()->views->set($view);
81
+        gravityview()->views->set( $view );
82 82
 
83 83
         /**
84 84
          * When this shortcode is embedded inside a View we can only display it as a directory. There's no other way.
85 85
          * Try to detect that we're not embedded to allow edit and single contexts.
86 86
          */
87 87
         $is_reembedded = false; // Assume not embedded unless detected otherwise.
88
-        if (in_array(get_class($request), ['GV\Frontend_Request', 'GV\Mock_Request'])) {
89
-            if (($_view = $request->is_view()) && $_view->ID !== $view->ID) {
88
+        if ( in_array( get_class( $request ), [ 'GV\Frontend_Request', 'GV\Mock_Request' ] ) ) {
89
+            if ( ( $_view = $request->is_view() ) && $_view->ID !== $view->ID ) {
90 90
                 $is_reembedded = true;
91
-            } elseif ($request->is_entry($view->form ? $view->form->ID : 0) && self::$callstack) {
91
+            } elseif ( $request->is_entry( $view->form ? $view->form->ID : 0 ) && self::$callstack ) {
92 92
                 $is_reembedded = true;
93 93
             }
94 94
         }
95 95
 
96
-        array_push(self::$callstack, true);
96
+        array_push( self::$callstack, true );
97 97
 
98 98
         /**
99 99
          * Remove Widgets on a nested embedded View.
100 100
          */
101
-        if ($is_reembedded) {
101
+        if ( $is_reembedded ) {
102 102
             $view->widgets = new \GV\Widget_Collection();
103 103
         }
104 104
 
105
-        $atts = $this->parse_and_sanitize_atts($atts);
105
+        $atts = $this->parse_and_sanitize_atts( $atts );
106 106
 
107
-        $view->settings->update(['shortcode_atts' => $atts]);
108
-        $view->settings->update($atts);
107
+        $view->settings->update( [ 'shortcode_atts' => $atts ] );
108
+        $view->settings->update( $atts );
109 109
 
110 110
         /**
111 111
          * Check permissions.
112 112
          */
113
-        while ($error = $view->can_render(['shortcode'], $request)) {
114
-            if (!is_wp_error($error)) {
113
+        while ( $error = $view->can_render( [ 'shortcode' ], $request ) ) {
114
+            if ( ! is_wp_error( $error ) ) {
115 115
                 break;
116 116
             }
117 117
 
118
-            switch (str_replace('gravityview/', '', $error->get_error_code())) {
118
+            switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
119 119
                 case 'post_password_required':
120
-                    return self::_return(get_the_password_form($view->ID));
120
+                    return self::_return( get_the_password_form( $view->ID ) );
121 121
                 case 'no_form_attached':
122 122
                     /**
123 123
                      * This View has no data source. There's nothing to show really.
124 124
                      * ...apart from a nice message if the user can do anything about it.
125 125
                      */
126
-                    if (\GVCommon::has_cap(['edit_gravityviews', 'edit_gravityview'], $view->ID)) {
127
-                        return self::_return(sprintf(__('This View is not configured properly. Start by <a href="%s">selecting a form</a>.', 'gravityview'), esc_url(get_edit_post_link($view->ID, false))));
126
+                    if ( \GVCommon::has_cap( [ 'edit_gravityviews', 'edit_gravityview' ], $view->ID ) ) {
127
+                        return self::_return( sprintf( __( 'This View is not configured properly. Start by <a href="%s">selecting a form</a>.', 'gravityview' ), esc_url( get_edit_post_link( $view->ID, false ) ) ) );
128 128
                     }
129 129
                     break;
130 130
                 case 'no_direct_access':
131 131
                 case 'embed_only':
132 132
                 case 'not_public':
133 133
                 default:
134
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
134
+                    return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
135 135
             }
136 136
         }
137 137
 
138
-        $is_admin_and_can_view = $view->settings->get('admin_show_all_statuses') && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID);
138
+        $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
139 139
 
140 140
         /**
141 141
          * View details.
142 142
          */
143
-        if ($atts['detail']) {
144
-            $entries = $view->get_entries($request);
143
+        if ( $atts[ 'detail' ] ) {
144
+            $entries = $view->get_entries( $request );
145 145
 
146
-            return self::_return($this->detail($view, $entries, $atts));
146
+            return self::_return( $this->detail( $view, $entries, $atts ) );
147 147
 
148 148
         /**
149 149
          * Editing a single entry.
150 150
          */
151
-        } elseif (!$is_reembedded && ($entry = $request->is_edit_entry($view->form ? $view->form->ID : 0))) {
151
+        } elseif ( ! $is_reembedded && ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) ) {
152 152
 
153 153
             /**
154 154
              * When editing an entry don't render multiple views.
155 155
              */
156
-            if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
157
-                gravityview()->log->notice('Entry ID #{entry_id} not rendered because another View ID was passed using `?gvid`: #{selected}', ['entry_id' => $entry->ID, 'selected' => $selected]);
156
+            if ( ( $selected = \GV\Utils::_GET( 'gvid' ) ) && $view->ID != $selected ) {
157
+                gravityview()->log->notice( 'Entry ID #{entry_id} not rendered because another View ID was passed using `?gvid`: #{selected}', [ 'entry_id' => $entry->ID, 'selected' => $selected ] );
158 158
 
159
-                return self::_return('');
159
+                return self::_return( '' );
160 160
             }
161 161
 
162
-            if ($entry['status'] != 'active') {
163
-                gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $entry->ID]);
162
+            if ( $entry[ 'status' ] != 'active' ) {
163
+                gravityview()->log->notice( 'Entry ID #{entry_id} is not active', [ 'entry_id' => $entry->ID ] );
164 164
 
165
-                return self::_return(__('You are not allowed to view this content.', 'gravityview'));
165
+                return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
166 166
             }
167 167
 
168
-            if (apply_filters('gravityview_custom_entry_slug', false) && $entry->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
169
-                gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $entry->ID]);
168
+            if ( apply_filters( 'gravityview_custom_entry_slug', false ) && $entry->slug != get_query_var( \GV\Entry::get_endpoint_name() ) ) {
169
+                gravityview()->log->error( 'Entry ID #{entry_id} was accessed by a bad slug', [ 'entry_id' => $entry->ID ] );
170 170
 
171
-                return self::_return(__('You are not allowed to view this content.', 'gravityview'));
171
+                return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
172 172
             }
173 173
 
174
-            if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
175
-                if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($entry->ID, \GravityView_Entry_Approval::meta_key))) {
176
-                    gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $entry->ID]);
174
+            if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
175
+                if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
176
+                    gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', [ 'entry_id' => $entry->ID ] );
177 177
 
178
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
178
+                    return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
179 179
                 }
180 180
             }
181 181
 
182 182
             $renderer = new \GV\Edit_Entry_Renderer();
183 183
 
184
-            return self::_return($renderer->render($entry, $view, $request));
184
+            return self::_return( $renderer->render( $entry, $view, $request ) );
185 185
 
186 186
         /**
187 187
          * Viewing a single entry.
188 188
          */
189
-        } elseif (!$is_reembedded && ($entry = $request->is_entry($view->form ? $view->form->ID : 0))) {
189
+        } elseif ( ! $is_reembedded && ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) ) {
190 190
             /**
191 191
              * When viewing an entry don't render multiple views.
192 192
              */
193
-            if (($selected = \GV\Utils::_GET('gvid')) && $view->ID != $selected) {
194
-                return self::_return('');
193
+            if ( ( $selected = \GV\Utils::_GET( 'gvid' ) ) && $view->ID != $selected ) {
194
+                return self::_return( '' );
195 195
             }
196 196
 
197
-            $entryset = $entry->is_multi() ? $entry->entries : [$entry];
197
+            $entryset = $entry->is_multi() ? $entry->entries : [ $entry ];
198 198
 
199
-            foreach ($entryset as $e) {
200
-                if ($e['status'] != 'active') {
201
-                    gravityview()->log->notice('Entry ID #{entry_id} is not active', ['entry_id' => $e->ID]);
199
+            foreach ( $entryset as $e ) {
200
+                if ( $e[ 'status' ] != 'active' ) {
201
+                    gravityview()->log->notice( 'Entry ID #{entry_id} is not active', [ 'entry_id' => $e->ID ] );
202 202
 
203
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
203
+                    return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
204 204
                 }
205 205
 
206
-                if (apply_filters('gravityview_custom_entry_slug', false) && $e->slug != get_query_var(\GV\Entry::get_endpoint_name())) {
207
-                    gravityview()->log->error('Entry ID #{entry_id} was accessed by a bad slug', ['entry_id' => $e->ID]);
206
+                if ( apply_filters( 'gravityview_custom_entry_slug', false ) && $e->slug != get_query_var( \GV\Entry::get_endpoint_name() ) ) {
207
+                    gravityview()->log->error( 'Entry ID #{entry_id} was accessed by a bad slug', [ 'entry_id' => $e->ID ] );
208 208
 
209
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
209
+                    return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
210 210
                 }
211 211
 
212
-                if ($view->settings->get('show_only_approved') && !$is_admin_and_can_view) {
213
-                    if (!\GravityView_Entry_Approval_Status::is_approved(gform_get_meta($e->ID, \GravityView_Entry_Approval::meta_key))) {
214
-                        gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing', ['entry_id' => $e->ID]);
212
+                if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
213
+                    if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
214
+                        gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', [ 'entry_id' => $e->ID ] );
215 215
 
216
-                        return self::_return(__('You are not allowed to view this content.', 'gravityview'));
216
+                        return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
217 217
                     }
218 218
                 }
219 219
 
220
-                $error = \GVCommon::check_entry_display($e->as_entry(), $view);
220
+                $error = \GVCommon::check_entry_display( $e->as_entry(), $view );
221 221
 
222
-                if (is_wp_error($error)) {
223
-                    gravityview()->log->error('Entry ID #{entry_id} is not approved for viewing: {message}', ['entry_id' => $e->ID, 'message' => $error->get_error_message()]);
222
+                if ( is_wp_error( $error ) ) {
223
+                    gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', [ 'entry_id' => $e->ID, 'message' => $error->get_error_message() ] );
224 224
 
225
-                    return self::_return(__('You are not allowed to view this content.', 'gravityview'));
225
+                    return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
226 226
                 }
227 227
             }
228 228
 
229 229
             $renderer = new \GV\Entry_Renderer();
230 230
 
231
-            return self::_return($renderer->render($entry, $view, $request));
231
+            return self::_return( $renderer->render( $entry, $view, $request ) );
232 232
 
233 233
         /**
234 234
          * Just this view.
235 235
          */
236 236
         } else {
237
-            if ($is_reembedded) {
237
+            if ( $is_reembedded ) {
238 238
 
239 239
                 // Mock the request with the actual View, not the global one
240 240
                 $mock_request = new \GV\Mock_Request();
241
-                $mock_request->returns['is_view'] = $view;
242
-                $mock_request->returns['is_entry'] = $request->is_entry($view->form ? $view->form->ID : 0);
243
-                $mock_request->returns['is_edit_entry'] = $request->is_edit_entry($view->form ? $view->form->ID : 0);
244
-                $mock_request->returns['is_search'] = $request->is_search();
241
+                $mock_request->returns[ 'is_view' ] = $view;
242
+                $mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 );
243
+                $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 );
244
+                $mock_request->returns[ 'is_search' ] = $request->is_search();
245 245
 
246 246
                 $request = $mock_request;
247 247
             }
248 248
 
249 249
             $renderer = new \GV\View_Renderer();
250 250
 
251
-            return self::_return($renderer->render($view, $request));
251
+            return self::_return( $renderer->render( $view, $request ) );
252 252
         }
253 253
     }
254 254
 
@@ -268,26 +268,26 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @return array Valid and sanitized attribute pairs
270 270
      */
271
-    private function parse_and_sanitize_atts($passed_atts)
271
+    private function parse_and_sanitize_atts( $passed_atts )
272 272
     {
273
-        $defaults = \GV\View_Settings::defaults(true);
273
+        $defaults = \GV\View_Settings::defaults( true );
274 274
 
275
-        $supported_atts = array_fill_keys(array_keys($defaults), '');
275
+        $supported_atts = array_fill_keys( array_keys( $defaults ), '' );
276 276
 
277 277
         // Whittle down the attributes to only valid pairs
278
-        $filtered_atts = shortcode_atts($supported_atts, $passed_atts, 'gravityview');
278
+        $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' );
279 279
 
280 280
         // Only keep the passed attributes after making sure that they're valid pairs
281
-        $filtered_atts = array_intersect_key((array) $passed_atts, $filtered_atts);
281
+        $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts );
282 282
 
283
-        $atts = [];
283
+        $atts = [ ];
284 284
 
285
-        foreach ($filtered_atts as $key => $passed_value) {
285
+        foreach ( $filtered_atts as $key => $passed_value ) {
286 286
 
287 287
             // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
288
-            $passed_value = \GravityView_Merge_Tags::replace_variables($passed_value);
288
+            $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value );
289 289
 
290
-            switch ($defaults[$key]['type']) {
290
+            switch ( $defaults[ $key ][ 'type' ] ) {
291 291
 
292 292
                 /**
293 293
                  * Make sure number fields are numeric.
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
                  * @see http://php.net/manual/en/function.is-numeric.php#107326
297 297
                  */
298 298
                 case 'number':
299
-                    if (is_numeric($passed_value)) {
300
-                        $atts[$key] = ($passed_value + 0);
299
+                    if ( is_numeric( $passed_value ) ) {
300
+                        $atts[ $key ] = ( $passed_value + 0 );
301 301
                     }
302 302
                     break;
303 303
 
304 304
                 // Checkboxes should be 1 or 0
305 305
                 case 'checkbox':
306
-                    $atts[$key] = gv_empty($passed_value, true, false) ? 0 : 1;
306
+                    $atts[ $key ] = gv_empty( $passed_value, true, false ) ? 0 : 1;
307 307
                     break;
308 308
 
309 309
                 /**
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
                  */
312 312
                 case 'select':
313 313
                 case 'radio':
314
-                    $options = isset($defaults[$key]['choices']) ? $defaults[$key]['choices'] : $defaults[$key]['options'];
315
-                    if (in_array($passed_value, array_keys($options))) {
316
-                        $atts[$key] = $passed_value;
314
+                    $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ];
315
+                    if ( in_array( $passed_value, array_keys( $options ) ) ) {
316
+                        $atts[ $key ] = $passed_value;
317 317
                     }
318 318
                     break;
319 319
 
320 320
                 case 'text':
321 321
                 default:
322
-                    $atts[$key] = $passed_value;
322
+                    $atts[ $key ] = $passed_value;
323 323
                     break;
324 324
             }
325 325
         }
326 326
 
327
-        $atts['detail'] = \GV\Utils::get($passed_atts, 'detail', null);
327
+        $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null );
328 328
 
329 329
         return $atts;
330 330
     }
@@ -338,22 +338,22 @@  discard block
 block discarded – undo
338 338
      *
339 339
      * @return string The output.
340 340
      */
341
-    private function detail($view, $entries, $atts)
341
+    private function detail( $view, $entries, $atts )
342 342
     {
343 343
         $output = '';
344 344
 
345
-        switch ($key = $atts['detail']) {
345
+        switch ( $key = $atts[ 'detail' ] ) {
346 346
             case 'total_entries':
347
-                $output = number_format_i18n($entries->total());
347
+                $output = number_format_i18n( $entries->total() );
348 348
                 break;
349 349
             case 'first_entry':
350
-                $output = number_format_i18n(min($entries->total(), $view->settings->get('offset') + 1));
350
+                $output = number_format_i18n( min( $entries->total(), $view->settings->get( 'offset' ) + 1 ) );
351 351
                 break;
352 352
             case 'last_entry':
353
-                $output = number_format_i18n($view->settings->get('page_size') + $view->settings->get('offset'));
353
+                $output = number_format_i18n( $view->settings->get( 'page_size' ) + $view->settings->get( 'offset' ) );
354 354
                 break;
355 355
             case 'page_size':
356
-                $output = number_format_i18n($view->settings->get($key));
356
+                $output = number_format_i18n( $view->settings->get( $key ) );
357 357
                 break;
358 358
         }
359 359
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
          * @param \GV\Entry_Collection $entries The entries.
371 371
          * @param array                $atts    The shortcode atts with defaults.
372 372
          */
373
-        $output = apply_filters("gravityview/shortcode/detail/$key", $output, $view);
373
+        $output = apply_filters( "gravityview/shortcode/detail/$key", $output, $view );
374 374
 
375 375
         return $output;
376 376
     }
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
     /**
379 379
      * Pop the callstack and return the value.
380 380
      */
381
-    private static function _return($value)
381
+    private static function _return( $value )
382 382
     {
383
-        array_pop(self::$callstack);
383
+        array_pop( self::$callstack );
384 384
 
385 385
         return $value;
386 386
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return string|null The output.
33 33
      */
34
-    public function callback($passed_atts, $content = '', $tag = '')
35
-    {
34
+    public function callback($passed_atts, $content = '', $tag = '') {
36 35
         $request = gravityview()->request;
37 36
 
38 37
         if ($request->is_admin()) {
@@ -268,8 +267,7 @@  discard block
 block discarded – undo
268 267
      *
269 268
      * @return array Valid and sanitized attribute pairs
270 269
      */
271
-    private function parse_and_sanitize_atts($passed_atts)
272
-    {
270
+    private function parse_and_sanitize_atts($passed_atts) {
273 271
         $defaults = \GV\View_Settings::defaults(true);
274 272
 
275 273
         $supported_atts = array_fill_keys(array_keys($defaults), '');
@@ -338,8 +336,7 @@  discard block
 block discarded – undo
338 336
      *
339 337
      * @return string The output.
340 338
      */
341
-    private function detail($view, $entries, $atts)
342
-    {
339
+    private function detail($view, $entries, $atts) {
343 340
         $output = '';
344 341
 
345 342
         switch ($key = $atts['detail']) {
@@ -378,8 +375,7 @@  discard block
 block discarded – undo
378 375
     /**
379 376
      * Pop the callstack and return the value.
380 377
      */
381
-    private static function _return($value)
382
-    {
378
+    private static function _return($value) {
383 379
         array_pop(self::$callstack);
384 380
 
385 381
         return $value;
Please login to merge, or discard this patch.
future/includes/class-gv-form-gravityforms.php 3 patches
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 /** If this file is called directly, abort. */
6 6
 if (!defined('GRAVITYVIEW_DIR')) {
7
-    exit();
7
+	exit();
8 8
 }
9 9
 
10 10
 /**
@@ -14,273 +14,273 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class GF_Form extends Form implements \ArrayAccess
16 16
 {
17
-    /**
18
-     * @var string The identifier of the backend used for this form.
19
-     *
20
-     * @api
21
-     *
22
-     * @since 2.0
23
-     */
24
-    public static $backend = self::BACKEND_GRAVITYFORMS;
25
-
26
-    /**
27
-     * Initialization.
28
-     */
29
-    private function __construct()
30
-    {
31
-        if (!class_exists('GFAPI')) {
32
-            gravityview()->log->error('Gravity Forms plugin is not active.');
33
-        }
34
-    }
35
-
36
-    /**
37
-     * Construct a \GV\GF_Form instance by ID.
38
-     *
39
-     * @param int|string $form_id The internal form ID.
40
-     *
41
-     * @api
42
-     *
43
-     * @since 2.0
44
-     *
45
-     * @return \GV\GF_Form|null An instance of this form or null if not found.
46
-     */
47
-    public static function by_id($form_id)
48
-    {
49
-        $form = wp_cache_get('gf_form_'.$form_id, 'gravityview');
50
-
51
-        if (!$form) {
52
-            $form = \GFAPI::get_form($form_id);
53
-        }
54
-
55
-        if (!$form) {
56
-            return null;
57
-        }
58
-
59
-        wp_cache_set('gf_form_'.$form_id, $form, 'gravityview');
60
-
61
-        $self = new self();
62
-        $self->form = $form;
63
-
64
-        $self->ID = intval($self->form['id']);
65
-
66
-        return $self;
67
-    }
68
-
69
-    /**
70
-     * Construct a \GV\Form instance from a Gravity Forms form array.
71
-     *
72
-     * @since 2.0.7
73
-     *
74
-     * @param array $form The form array
75
-     *
76
-     * @return \GV\GF_Form|null An instance of this form or null if not found.
77
-     */
78
-    public static function from_form($form)
79
-    {
80
-        if (empty($form['id'])) {
81
-            return null;
82
-        }
83
-
84
-        $self = new self();
85
-        $self->form = $form;
86
-        $self->ID = $self->form['id'];
87
-
88
-        return $self;
89
-    }
90
-
91
-    /**
92
-     * Get all entries for this form.
93
-     *
94
-     * @api
95
-     *
96
-     * @since 2.0
97
-     *
98
-     * @return \GV\Entry_Collection The \GV\Entry_Collection
99
-     */
100
-    public function get_entries()
101
-    {
102
-        $entries = new \GV\Entry_Collection();
103
-
104
-        $form = &$this;
105
-
106
-        /** Add the fetcher lazy callback. */
107
-        $entries->add_fetch_callback(function ($filters, $sorts, $offset) use ($form) {
108
-            $entries = new \GV\Entry_Collection();
109
-
110
-            $search_criteria = [];
111
-            $sorting = [];
112
-            $paging = [];
113
-
114
-            /** Apply the filters */
115
-            foreach ($filters as $filter) {
116
-                $search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
117
-            }
118
-
119
-            /** Apply the sorts */
120
-            foreach ($sorts as $sort) {
121
-                /** Gravity Forms does not have multi-sorting, so just overwrite. */
122
-                $sorting = [
123
-                    'key'        => $sort->field->ID,
124
-                    'direction'  => $sort->direction,
125
-                    'is_numeric' => $sort->mode == Entry_Sort::NUMERIC,
126
-                ];
127
-            }
128
-
129
-            /** The offset and limit */
130
-            if (!empty($offset->limit)) {
131
-                $paging['page_size'] = $offset->limit;
132
-            }
133
-
134
-            if (!empty($offset->offset)) {
135
-                $paging['offset'] = $offset->offset;
136
-            }
137
-
138
-            foreach (\GFAPI::get_entries($form->ID, $search_criteria, $sorting, $paging) as $entry) {
139
-                $entries->add(\GV\GF_Entry::from_entry($entry));
140
-            }
141
-
142
-            return $entries;
143
-        });
144
-
145
-        /** Add the counter lazy callback. */
146
-        $entries->add_count_callback(function ($filters) use ($form) {
147
-            $search_criteria = [];
148
-            $sorting = [];
149
-
150
-            /** Apply the filters */
151
-            /** @var \GV\GF_Entry_Filter|\GV\Entry_Filter $filter */
152
-            foreach ($filters as $filter) {
153
-                $search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
154
-            }
155
-
156
-            return \GFAPI::count_entries($form->ID, $search_criteria);
157
-        });
158
-
159
-        return $entries;
160
-    }
161
-
162
-    /**
163
-     * Get a \GV\Field by Form and Field ID for this data source.
164
-     *
165
-     * @param \GV\GF_Form $form     The Gravity Form form ID.
166
-     * @param int         $field_id The Gravity Form field ID for the $form_id.
167
-     *
168
-     * @return \GV\Field|null The requested field or null if not found.
169
-     */
170
-    public static function get_field(/** varargs */)
171
-    {
172
-        $args = func_get_args();
173
-
174
-        if (!is_array($args) || count($args) != 2) {
175
-            gravityview()->log->error('{source} expects 2 arguments for ::get_field ($form, $field_id)', ['source' => __CLASS__]);
176
-
177
-            return null;
178
-        }
179
-
180
-        /** Unwrap the arguments. */
181
-        list($form, $field_id) = $args;
182
-
183
-        /** Wrap it up into a \GV\Field. */
184
-        return GF_Field::by_id($form, $field_id);
185
-    }
186
-
187
-    /**
188
-     * Get an array of GV Fields for this data source.
189
-     *
190
-     * @return \GV\Field[]|array Empty array if no fields
191
-     */
192
-    public function get_fields()
193
-    {
194
-        $fields = [];
195
-        foreach ($this['fields'] as $field) {
196
-            foreach (empty($field['inputs']) ? [$field['id']] : wp_list_pluck($field['inputs'], 'id') as $id) {
197
-                if (is_numeric($id)) {
198
-                    $fields[$id] = self::get_field($this, $id);
199
-                } else {
200
-                    $fields[$id] = Internal_Field::by_id($id);
201
-                }
202
-            }
203
-        }
204
-
205
-        return array_filter($fields);
206
-    }
207
-
208
-    /**
209
-     * Proxies.
210
-     *
211
-     * @param string $key The property to get.
212
-     *
213
-     * @return mixed
214
-     */
215
-    public function __get($key)
216
-    {
217
-        switch ($key) {
218
-            case 'fields':
219
-                return $this->get_fields();
220
-            default:
221
-                return parent::__get($key);
222
-        }
223
-    }
224
-
225
-    /**
226
-     * ArrayAccess compatibility layer with a Gravity Forms form array.
227
-     *
228
-     * @internal
229
-     *
230
-     * @deprecated
231
-     * @since 2.0
232
-     *
233
-     * @return bool Whether the offset exists or not.
234
-     */
235
-    public function offsetExists($offset)
236
-    {
237
-        return isset($this->form[$offset]);
238
-    }
239
-
240
-    /**
241
-     * ArrayAccess compatibility layer with a Gravity Forms form array.
242
-     *
243
-     * Maps the old keys to the new data;
244
-     *
245
-     * @internal
246
-     *
247
-     * @deprecated
248
-     * @since 2.0
249
-     *
250
-     * @return mixed The value of the requested form data.
251
-     */
252
-    public function offsetGet($offset)
253
-    {
254
-        return $this->form[$offset];
255
-    }
256
-
257
-    /**
258
-     * ArrayAccess compatibility layer with a Gravity Forms form array.
259
-     *
260
-     * @internal
261
-     *
262
-     * @deprecated
263
-     * @since 2.0
264
-     *
265
-     * @return void
266
-     */
267
-    public function offsetSet($offset, $value)
268
-    {
269
-        gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
270
-    }
271
-
272
-    /**
273
-     * ArrayAccess compatibility layer with a Gravity Forms form array.
274
-     *
275
-     * @internal
276
-     *
277
-     * @deprecated
278
-     * @since 2.0
279
-     *
280
-     * @return void
281
-     */
282
-    public function offsetUnset($offset)
283
-    {
284
-        gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
285
-    }
17
+	/**
18
+	 * @var string The identifier of the backend used for this form.
19
+	 *
20
+	 * @api
21
+	 *
22
+	 * @since 2.0
23
+	 */
24
+	public static $backend = self::BACKEND_GRAVITYFORMS;
25
+
26
+	/**
27
+	 * Initialization.
28
+	 */
29
+	private function __construct()
30
+	{
31
+		if (!class_exists('GFAPI')) {
32
+			gravityview()->log->error('Gravity Forms plugin is not active.');
33
+		}
34
+	}
35
+
36
+	/**
37
+	 * Construct a \GV\GF_Form instance by ID.
38
+	 *
39
+	 * @param int|string $form_id The internal form ID.
40
+	 *
41
+	 * @api
42
+	 *
43
+	 * @since 2.0
44
+	 *
45
+	 * @return \GV\GF_Form|null An instance of this form or null if not found.
46
+	 */
47
+	public static function by_id($form_id)
48
+	{
49
+		$form = wp_cache_get('gf_form_'.$form_id, 'gravityview');
50
+
51
+		if (!$form) {
52
+			$form = \GFAPI::get_form($form_id);
53
+		}
54
+
55
+		if (!$form) {
56
+			return null;
57
+		}
58
+
59
+		wp_cache_set('gf_form_'.$form_id, $form, 'gravityview');
60
+
61
+		$self = new self();
62
+		$self->form = $form;
63
+
64
+		$self->ID = intval($self->form['id']);
65
+
66
+		return $self;
67
+	}
68
+
69
+	/**
70
+	 * Construct a \GV\Form instance from a Gravity Forms form array.
71
+	 *
72
+	 * @since 2.0.7
73
+	 *
74
+	 * @param array $form The form array
75
+	 *
76
+	 * @return \GV\GF_Form|null An instance of this form or null if not found.
77
+	 */
78
+	public static function from_form($form)
79
+	{
80
+		if (empty($form['id'])) {
81
+			return null;
82
+		}
83
+
84
+		$self = new self();
85
+		$self->form = $form;
86
+		$self->ID = $self->form['id'];
87
+
88
+		return $self;
89
+	}
90
+
91
+	/**
92
+	 * Get all entries for this form.
93
+	 *
94
+	 * @api
95
+	 *
96
+	 * @since 2.0
97
+	 *
98
+	 * @return \GV\Entry_Collection The \GV\Entry_Collection
99
+	 */
100
+	public function get_entries()
101
+	{
102
+		$entries = new \GV\Entry_Collection();
103
+
104
+		$form = &$this;
105
+
106
+		/** Add the fetcher lazy callback. */
107
+		$entries->add_fetch_callback(function ($filters, $sorts, $offset) use ($form) {
108
+			$entries = new \GV\Entry_Collection();
109
+
110
+			$search_criteria = [];
111
+			$sorting = [];
112
+			$paging = [];
113
+
114
+			/** Apply the filters */
115
+			foreach ($filters as $filter) {
116
+				$search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
117
+			}
118
+
119
+			/** Apply the sorts */
120
+			foreach ($sorts as $sort) {
121
+				/** Gravity Forms does not have multi-sorting, so just overwrite. */
122
+				$sorting = [
123
+					'key'        => $sort->field->ID,
124
+					'direction'  => $sort->direction,
125
+					'is_numeric' => $sort->mode == Entry_Sort::NUMERIC,
126
+				];
127
+			}
128
+
129
+			/** The offset and limit */
130
+			if (!empty($offset->limit)) {
131
+				$paging['page_size'] = $offset->limit;
132
+			}
133
+
134
+			if (!empty($offset->offset)) {
135
+				$paging['offset'] = $offset->offset;
136
+			}
137
+
138
+			foreach (\GFAPI::get_entries($form->ID, $search_criteria, $sorting, $paging) as $entry) {
139
+				$entries->add(\GV\GF_Entry::from_entry($entry));
140
+			}
141
+
142
+			return $entries;
143
+		});
144
+
145
+		/** Add the counter lazy callback. */
146
+		$entries->add_count_callback(function ($filters) use ($form) {
147
+			$search_criteria = [];
148
+			$sorting = [];
149
+
150
+			/** Apply the filters */
151
+			/** @var \GV\GF_Entry_Filter|\GV\Entry_Filter $filter */
152
+			foreach ($filters as $filter) {
153
+				$search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
154
+			}
155
+
156
+			return \GFAPI::count_entries($form->ID, $search_criteria);
157
+		});
158
+
159
+		return $entries;
160
+	}
161
+
162
+	/**
163
+	 * Get a \GV\Field by Form and Field ID for this data source.
164
+	 *
165
+	 * @param \GV\GF_Form $form     The Gravity Form form ID.
166
+	 * @param int         $field_id The Gravity Form field ID for the $form_id.
167
+	 *
168
+	 * @return \GV\Field|null The requested field or null if not found.
169
+	 */
170
+	public static function get_field(/** varargs */)
171
+	{
172
+		$args = func_get_args();
173
+
174
+		if (!is_array($args) || count($args) != 2) {
175
+			gravityview()->log->error('{source} expects 2 arguments for ::get_field ($form, $field_id)', ['source' => __CLASS__]);
176
+
177
+			return null;
178
+		}
179
+
180
+		/** Unwrap the arguments. */
181
+		list($form, $field_id) = $args;
182
+
183
+		/** Wrap it up into a \GV\Field. */
184
+		return GF_Field::by_id($form, $field_id);
185
+	}
186
+
187
+	/**
188
+	 * Get an array of GV Fields for this data source.
189
+	 *
190
+	 * @return \GV\Field[]|array Empty array if no fields
191
+	 */
192
+	public function get_fields()
193
+	{
194
+		$fields = [];
195
+		foreach ($this['fields'] as $field) {
196
+			foreach (empty($field['inputs']) ? [$field['id']] : wp_list_pluck($field['inputs'], 'id') as $id) {
197
+				if (is_numeric($id)) {
198
+					$fields[$id] = self::get_field($this, $id);
199
+				} else {
200
+					$fields[$id] = Internal_Field::by_id($id);
201
+				}
202
+			}
203
+		}
204
+
205
+		return array_filter($fields);
206
+	}
207
+
208
+	/**
209
+	 * Proxies.
210
+	 *
211
+	 * @param string $key The property to get.
212
+	 *
213
+	 * @return mixed
214
+	 */
215
+	public function __get($key)
216
+	{
217
+		switch ($key) {
218
+			case 'fields':
219
+				return $this->get_fields();
220
+			default:
221
+				return parent::__get($key);
222
+		}
223
+	}
224
+
225
+	/**
226
+	 * ArrayAccess compatibility layer with a Gravity Forms form array.
227
+	 *
228
+	 * @internal
229
+	 *
230
+	 * @deprecated
231
+	 * @since 2.0
232
+	 *
233
+	 * @return bool Whether the offset exists or not.
234
+	 */
235
+	public function offsetExists($offset)
236
+	{
237
+		return isset($this->form[$offset]);
238
+	}
239
+
240
+	/**
241
+	 * ArrayAccess compatibility layer with a Gravity Forms form array.
242
+	 *
243
+	 * Maps the old keys to the new data;
244
+	 *
245
+	 * @internal
246
+	 *
247
+	 * @deprecated
248
+	 * @since 2.0
249
+	 *
250
+	 * @return mixed The value of the requested form data.
251
+	 */
252
+	public function offsetGet($offset)
253
+	{
254
+		return $this->form[$offset];
255
+	}
256
+
257
+	/**
258
+	 * ArrayAccess compatibility layer with a Gravity Forms form array.
259
+	 *
260
+	 * @internal
261
+	 *
262
+	 * @deprecated
263
+	 * @since 2.0
264
+	 *
265
+	 * @return void
266
+	 */
267
+	public function offsetSet($offset, $value)
268
+	{
269
+		gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
270
+	}
271
+
272
+	/**
273
+	 * ArrayAccess compatibility layer with a Gravity Forms form array.
274
+	 *
275
+	 * @internal
276
+	 *
277
+	 * @deprecated
278
+	 * @since 2.0
279
+	 *
280
+	 * @return void
281
+	 */
282
+	public function offsetUnset($offset)
283
+	{
284
+		gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
285
+	}
286 286
 }
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 namespace GV;
4 4
 
5 5
 /** If this file is called directly, abort. */
6
-if (!defined('GRAVITYVIEW_DIR')) {
6
+if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
7 7
     exit();
8 8
 }
9 9
 
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
      */
29 29
     private function __construct()
30 30
     {
31
-        if (!class_exists('GFAPI')) {
32
-            gravityview()->log->error('Gravity Forms plugin is not active.');
31
+        if ( ! class_exists( 'GFAPI' ) ) {
32
+            gravityview()->log->error( 'Gravity Forms plugin is not active.' );
33 33
         }
34 34
     }
35 35
 
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
      *
45 45
      * @return \GV\GF_Form|null An instance of this form or null if not found.
46 46
      */
47
-    public static function by_id($form_id)
47
+    public static function by_id( $form_id )
48 48
     {
49
-        $form = wp_cache_get('gf_form_'.$form_id, 'gravityview');
49
+        $form = wp_cache_get( 'gf_form_' . $form_id, 'gravityview' );
50 50
 
51
-        if (!$form) {
52
-            $form = \GFAPI::get_form($form_id);
51
+        if ( ! $form ) {
52
+            $form = \GFAPI::get_form( $form_id );
53 53
         }
54 54
 
55
-        if (!$form) {
55
+        if ( ! $form ) {
56 56
             return null;
57 57
         }
58 58
 
59
-        wp_cache_set('gf_form_'.$form_id, $form, 'gravityview');
59
+        wp_cache_set( 'gf_form_' . $form_id, $form, 'gravityview' );
60 60
 
61 61
         $self = new self();
62 62
         $self->form = $form;
63 63
 
64
-        $self->ID = intval($self->form['id']);
64
+        $self->ID = intval( $self->form[ 'id' ] );
65 65
 
66 66
         return $self;
67 67
     }
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
      *
76 76
      * @return \GV\GF_Form|null An instance of this form or null if not found.
77 77
      */
78
-    public static function from_form($form)
78
+    public static function from_form( $form )
79 79
     {
80
-        if (empty($form['id'])) {
80
+        if ( empty( $form[ 'id' ] ) ) {
81 81
             return null;
82 82
         }
83 83
 
84 84
         $self = new self();
85 85
         $self->form = $form;
86
-        $self->ID = $self->form['id'];
86
+        $self->ID = $self->form[ 'id' ];
87 87
 
88 88
         return $self;
89 89
     }
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
         $form = &$this;
105 105
 
106 106
         /** Add the fetcher lazy callback. */
107
-        $entries->add_fetch_callback(function ($filters, $sorts, $offset) use ($form) {
107
+        $entries->add_fetch_callback( function( $filters, $sorts, $offset ) use ( $form ) {
108 108
             $entries = new \GV\Entry_Collection();
109 109
 
110
-            $search_criteria = [];
111
-            $sorting = [];
112
-            $paging = [];
110
+            $search_criteria = [ ];
111
+            $sorting = [ ];
112
+            $paging = [ ];
113 113
 
114 114
             /** Apply the filters */
115
-            foreach ($filters as $filter) {
116
-                $search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
115
+            foreach ( $filters as $filter ) {
116
+                $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() );
117 117
             }
118 118
 
119 119
             /** Apply the sorts */
120
-            foreach ($sorts as $sort) {
120
+            foreach ( $sorts as $sort ) {
121 121
                 /** Gravity Forms does not have multi-sorting, so just overwrite. */
122 122
                 $sorting = [
123 123
                     'key'        => $sort->field->ID,
@@ -127,33 +127,33 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
             /** The offset and limit */
130
-            if (!empty($offset->limit)) {
131
-                $paging['page_size'] = $offset->limit;
130
+            if ( ! empty( $offset->limit ) ) {
131
+                $paging[ 'page_size' ] = $offset->limit;
132 132
             }
133 133
 
134
-            if (!empty($offset->offset)) {
135
-                $paging['offset'] = $offset->offset;
134
+            if ( ! empty( $offset->offset ) ) {
135
+                $paging[ 'offset' ] = $offset->offset;
136 136
             }
137 137
 
138
-            foreach (\GFAPI::get_entries($form->ID, $search_criteria, $sorting, $paging) as $entry) {
139
-                $entries->add(\GV\GF_Entry::from_entry($entry));
138
+            foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) {
139
+                $entries->add( \GV\GF_Entry::from_entry( $entry ) );
140 140
             }
141 141
 
142 142
             return $entries;
143 143
         });
144 144
 
145 145
         /** Add the counter lazy callback. */
146
-        $entries->add_count_callback(function ($filters) use ($form) {
147
-            $search_criteria = [];
148
-            $sorting = [];
146
+        $entries->add_count_callback( function( $filters ) use ( $form ) {
147
+            $search_criteria = [ ];
148
+            $sorting = [ ];
149 149
 
150 150
             /** Apply the filters */
151 151
             /** @var \GV\GF_Entry_Filter|\GV\Entry_Filter $filter */
152
-            foreach ($filters as $filter) {
153
-                $search_criteria = $filter::merge_search_criteria($search_criteria, $filter->as_search_criteria());
152
+            foreach ( $filters as $filter ) {
153
+                $search_criteria = $filter::merge_search_criteria( $search_criteria, $filter->as_search_criteria() );
154 154
             }
155 155
 
156
-            return \GFAPI::count_entries($form->ID, $search_criteria);
156
+            return \GFAPI::count_entries( $form->ID, $search_criteria );
157 157
         });
158 158
 
159 159
         return $entries;
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
      *
168 168
      * @return \GV\Field|null The requested field or null if not found.
169 169
      */
170
-    public static function get_field(/** varargs */)
170
+    public static function get_field( /** varargs */ )
171 171
     {
172 172
         $args = func_get_args();
173 173
 
174
-        if (!is_array($args) || count($args) != 2) {
175
-            gravityview()->log->error('{source} expects 2 arguments for ::get_field ($form, $field_id)', ['source' => __CLASS__]);
174
+        if ( ! is_array( $args ) || count( $args ) != 2 ) {
175
+            gravityview()->log->error( '{source} expects 2 arguments for ::get_field ($form, $field_id)', [ 'source' => __CLASS__ ] );
176 176
 
177 177
             return null;
178 178
         }
179 179
 
180 180
         /** Unwrap the arguments. */
181
-        list($form, $field_id) = $args;
181
+        list( $form, $field_id ) = $args;
182 182
 
183 183
         /** Wrap it up into a \GV\Field. */
184
-        return GF_Field::by_id($form, $field_id);
184
+        return GF_Field::by_id( $form, $field_id );
185 185
     }
186 186
 
187 187
     /**
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
      */
192 192
     public function get_fields()
193 193
     {
194
-        $fields = [];
195
-        foreach ($this['fields'] as $field) {
196
-            foreach (empty($field['inputs']) ? [$field['id']] : wp_list_pluck($field['inputs'], 'id') as $id) {
197
-                if (is_numeric($id)) {
198
-                    $fields[$id] = self::get_field($this, $id);
194
+        $fields = [ ];
195
+        foreach ( $this[ 'fields' ] as $field ) {
196
+            foreach ( empty( $field[ 'inputs' ] ) ? [ $field[ 'id' ] ] : wp_list_pluck( $field[ 'inputs' ], 'id' ) as $id ) {
197
+                if ( is_numeric( $id ) ) {
198
+                    $fields[ $id ] = self::get_field( $this, $id );
199 199
                 } else {
200
-                    $fields[$id] = Internal_Field::by_id($id);
200
+                    $fields[ $id ] = Internal_Field::by_id( $id );
201 201
                 }
202 202
             }
203 203
         }
204 204
 
205
-        return array_filter($fields);
205
+        return array_filter( $fields );
206 206
     }
207 207
 
208 208
     /**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
      *
213 213
      * @return mixed
214 214
      */
215
-    public function __get($key)
215
+    public function __get( $key )
216 216
     {
217
-        switch ($key) {
217
+        switch ( $key ) {
218 218
             case 'fields':
219 219
                 return $this->get_fields();
220 220
             default:
221
-                return parent::__get($key);
221
+                return parent::__get( $key );
222 222
         }
223 223
     }
224 224
 
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
      *
233 233
      * @return bool Whether the offset exists or not.
234 234
      */
235
-    public function offsetExists($offset)
235
+    public function offsetExists( $offset )
236 236
     {
237
-        return isset($this->form[$offset]);
237
+        return isset( $this->form[ $offset ] );
238 238
     }
239 239
 
240 240
     /**
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @return mixed The value of the requested form data.
251 251
      */
252
-    public function offsetGet($offset)
252
+    public function offsetGet( $offset )
253 253
     {
254
-        return $this->form[$offset];
254
+        return $this->form[ $offset ];
255 255
     }
256 256
 
257 257
     /**
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
      *
265 265
      * @return void
266 266
      */
267
-    public function offsetSet($offset, $value)
267
+    public function offsetSet( $offset, $value )
268 268
     {
269
-        gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
269
+        gravityview()->log->error( 'The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.' );
270 270
     }
271 271
 
272 272
     /**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
      *
280 280
      * @return void
281 281
      */
282
-    public function offsetUnset($offset)
282
+    public function offsetUnset( $offset )
283 283
     {
284
-        gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
284
+        gravityview()->log->error( 'The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.' );
285 285
     }
286 286
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * Initialization.
28 28
      */
29
-    private function __construct()
30
-    {
29
+    private function __construct() {
31 30
         if (!class_exists('GFAPI')) {
32 31
             gravityview()->log->error('Gravity Forms plugin is not active.');
33 32
         }
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
      *
45 44
      * @return \GV\GF_Form|null An instance of this form or null if not found.
46 45
      */
47
-    public static function by_id($form_id)
48
-    {
46
+    public static function by_id($form_id) {
49 47
         $form = wp_cache_get('gf_form_'.$form_id, 'gravityview');
50 48
 
51 49
         if (!$form) {
@@ -75,8 +73,7 @@  discard block
 block discarded – undo
75 73
      *
76 74
      * @return \GV\GF_Form|null An instance of this form or null if not found.
77 75
      */
78
-    public static function from_form($form)
79
-    {
76
+    public static function from_form($form) {
80 77
         if (empty($form['id'])) {
81 78
             return null;
82 79
         }
@@ -97,8 +94,7 @@  discard block
 block discarded – undo
97 94
      *
98 95
      * @return \GV\Entry_Collection The \GV\Entry_Collection
99 96
      */
100
-    public function get_entries()
101
-    {
97
+    public function get_entries() {
102 98
         $entries = new \GV\Entry_Collection();
103 99
 
104 100
         $form = &$this;
@@ -167,8 +163,7 @@  discard block
 block discarded – undo
167 163
      *
168 164
      * @return \GV\Field|null The requested field or null if not found.
169 165
      */
170
-    public static function get_field(/** varargs */)
171
-    {
166
+    public static function get_field(/** varargs */) {
172 167
         $args = func_get_args();
173 168
 
174 169
         if (!is_array($args) || count($args) != 2) {
@@ -189,8 +184,7 @@  discard block
 block discarded – undo
189 184
      *
190 185
      * @return \GV\Field[]|array Empty array if no fields
191 186
      */
192
-    public function get_fields()
193
-    {
187
+    public function get_fields() {
194 188
         $fields = [];
195 189
         foreach ($this['fields'] as $field) {
196 190
             foreach (empty($field['inputs']) ? [$field['id']] : wp_list_pluck($field['inputs'], 'id') as $id) {
@@ -212,8 +206,7 @@  discard block
 block discarded – undo
212 206
      *
213 207
      * @return mixed
214 208
      */
215
-    public function __get($key)
216
-    {
209
+    public function __get($key) {
217 210
         switch ($key) {
218 211
             case 'fields':
219 212
                 return $this->get_fields();
@@ -232,8 +225,7 @@  discard block
 block discarded – undo
232 225
      *
233 226
      * @return bool Whether the offset exists or not.
234 227
      */
235
-    public function offsetExists($offset)
236
-    {
228
+    public function offsetExists($offset) {
237 229
         return isset($this->form[$offset]);
238 230
     }
239 231
 
@@ -249,8 +241,7 @@  discard block
 block discarded – undo
249 241
      *
250 242
      * @return mixed The value of the requested form data.
251 243
      */
252
-    public function offsetGet($offset)
253
-    {
244
+    public function offsetGet($offset) {
254 245
         return $this->form[$offset];
255 246
     }
256 247
 
@@ -264,8 +255,7 @@  discard block
 block discarded – undo
264 255
      *
265 256
      * @return void
266 257
      */
267
-    public function offsetSet($offset, $value)
268
-    {
258
+    public function offsetSet($offset, $value) {
269 259
         gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
270 260
     }
271 261
 
@@ -279,8 +269,7 @@  discard block
 block discarded – undo
279 269
      *
280 270
      * @return void
281 271
      */
282
-    public function offsetUnset($offset)
283
-    {
272
+    public function offsetUnset($offset) {
284 273
         gravityview()->log->error('The underlying Gravity Forms form is immutable. This is a \GV\Form object and should not be accessed as an array.');
285 274
     }
286 275
 }
Please login to merge, or discard this patch.