Completed
Pull Request — develop (#1713)
by Zack
17:42
created
includes/fields/class-gravityview-field-post-category.php 3 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -4,153 +4,153 @@
 block discarded – undo
4 4
  */
5 5
 class GravityView_Field_Post_Category extends GravityView_Field
6 6
 {
7
-    public $name = 'post_category';
8
-
9
-    public $is_searchable = true;
10
-
11
-    public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains'];
12
-
13
-    public $_gf_field_class_name = 'GF_Field_Post_Category';
14
-
15
-    public $group = 'post';
16
-
17
-    public $icon = 'dashicons-category';
18
-
19
-    public function __construct()
20
-    {
21
-        $this->label = esc_html__('Post Category', 'gravityview');
22
-
23
-        add_action('gravityview/edit-entry/render/before', [$this, 'add_edit_entry_post_category_choices_filter']);
24
-
25
-        add_action('gravityview/edit-entry/render/after', [$this, 'remove_edit_entry_post_category_choices_filter']);
26
-
27
-        add_action('gravityview/edit_entry/after_update', [$this, 'set_post_categories'], 10, 2);
28
-
29
-        parent::__construct();
30
-    }
31
-
32
-    /**
33
-     * Update the post categories based on all post category fields.
34
-     *
35
-     * @since 1.17
36
-     *
37
-     * @param array $form     Gravity Forms form array
38
-     * @param int   $entry_id Numeric ID of the entry that was updated
39
-     *
40
-     * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
41
-     */
42
-    public function set_post_categories($form = [], $entry_id = 0)
43
-    {
44
-        $entry = GFAPI::get_entry($entry_id);
45
-        $post_id = \GV\Utils::get($entry, 'post_id');
46
-
47
-        if (empty($post_id)) {
48
-            return false;
49
-        }
50
-
51
-        $return = false;
52
-
53
-        $post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
54
-
55
-        if ($post_category_fields) {
56
-            $updated_categories = [];
57
-
58
-            foreach ($post_category_fields as $field) {
59
-                // Get the value of the field, including $_POSTed value
60
-                $field_cats = RGFormsModel::get_field_value($field);
61
-                $field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
62
-                $field_cats = gv_map_deep($field_cats, 'intval');
63
-                $updated_categories = array_merge($updated_categories, array_values($field_cats));
64
-            }
65
-
66
-            // Remove `0` values from intval()
67
-            $updated_categories = array_filter($updated_categories);
68
-
69
-            /**
70
-             * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
71
-             *
72
-             * @since 1.17
73
-             *
74
-             * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
75
-             */
76
-            $append = apply_filters('gravityview/edit_entry/post_categories/append', false);
77
-
78
-            $return = wp_set_post_categories($post_id, $updated_categories, $append);
79
-        }
80
-
81
-        return $return;
82
-    }
83
-
84
-    /**
85
-     * Add filter to show live category choices in Edit Entry.
86
-     *
87
-     * @see edit_entry_post_category_choices
88
-     * @since 1.17
89
-     *
90
-     * @return void
91
-     */
92
-    public function add_edit_entry_post_category_choices_filter()
93
-    {
94
-        add_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10, 3);
95
-    }
96
-
97
-    /**
98
-     * Remove filter to show live category choices in Edit Entry.
99
-     *
100
-     * @see edit_entry_post_category_choices
101
-     * @since 1.17
102
-     *
103
-     * @return void
104
-     */
105
-    public function remove_edit_entry_post_category_choices_filter()
106
-    {
107
-        remove_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10);
108
-    }
109
-
110
-    /**
111
-     * Always show the live Category values.
112
-     *
113
-     * By default, Gravity Forms would show unchecked/default choices. We want to show the live Post categories
114
-     *
115
-     * @since 1.17
116
-     *
117
-     * @param $choices
118
-     * @param $field
119
-     * @param $form_id
120
-     *
121
-     * @return mixed
122
-     */
123
-    public function edit_entry_post_category_choices($choices, $field, $form_id)
124
-    {
125
-        $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry();
126
-
127
-        // $entry['post_id'] should always be set, but we check to make sure.
128
-        if ($entry && isset($entry['post_id']) && $post_id = $entry['post_id']) {
129
-            $post_categories = wp_get_post_categories($post_id, ['fields' => 'ids']);
130
-
131
-            // Always use the live value
132
-            foreach ($choices as &$choice) {
133
-                $choice['isSelected'] = in_array($choice['value'], array_values($post_categories));
134
-            }
135
-        }
136
-
137
-        return $choices;
138
-    }
139
-
140
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
141
-    {
142
-        if ('edit' === $context) {
143
-            return $field_options;
144
-        }
145
-
146
-        $this->add_field_support('dynamic_data', $field_options);
147
-        $this->add_field_support('link_to_term', $field_options);
148
-        $this->add_field_support('new_window', $field_options);
149
-
150
-        $field_options['new_window']['requires'] = 'link_to_term';
151
-
152
-        return $field_options;
153
-    }
7
+	public $name = 'post_category';
8
+
9
+	public $is_searchable = true;
10
+
11
+	public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains'];
12
+
13
+	public $_gf_field_class_name = 'GF_Field_Post_Category';
14
+
15
+	public $group = 'post';
16
+
17
+	public $icon = 'dashicons-category';
18
+
19
+	public function __construct()
20
+	{
21
+		$this->label = esc_html__('Post Category', 'gravityview');
22
+
23
+		add_action('gravityview/edit-entry/render/before', [$this, 'add_edit_entry_post_category_choices_filter']);
24
+
25
+		add_action('gravityview/edit-entry/render/after', [$this, 'remove_edit_entry_post_category_choices_filter']);
26
+
27
+		add_action('gravityview/edit_entry/after_update', [$this, 'set_post_categories'], 10, 2);
28
+
29
+		parent::__construct();
30
+	}
31
+
32
+	/**
33
+	 * Update the post categories based on all post category fields.
34
+	 *
35
+	 * @since 1.17
36
+	 *
37
+	 * @param array $form     Gravity Forms form array
38
+	 * @param int   $entry_id Numeric ID of the entry that was updated
39
+	 *
40
+	 * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
41
+	 */
42
+	public function set_post_categories($form = [], $entry_id = 0)
43
+	{
44
+		$entry = GFAPI::get_entry($entry_id);
45
+		$post_id = \GV\Utils::get($entry, 'post_id');
46
+
47
+		if (empty($post_id)) {
48
+			return false;
49
+		}
50
+
51
+		$return = false;
52
+
53
+		$post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
54
+
55
+		if ($post_category_fields) {
56
+			$updated_categories = [];
57
+
58
+			foreach ($post_category_fields as $field) {
59
+				// Get the value of the field, including $_POSTed value
60
+				$field_cats = RGFormsModel::get_field_value($field);
61
+				$field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
62
+				$field_cats = gv_map_deep($field_cats, 'intval');
63
+				$updated_categories = array_merge($updated_categories, array_values($field_cats));
64
+			}
65
+
66
+			// Remove `0` values from intval()
67
+			$updated_categories = array_filter($updated_categories);
68
+
69
+			/**
70
+			 * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
71
+			 *
72
+			 * @since 1.17
73
+			 *
74
+			 * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
75
+			 */
76
+			$append = apply_filters('gravityview/edit_entry/post_categories/append', false);
77
+
78
+			$return = wp_set_post_categories($post_id, $updated_categories, $append);
79
+		}
80
+
81
+		return $return;
82
+	}
83
+
84
+	/**
85
+	 * Add filter to show live category choices in Edit Entry.
86
+	 *
87
+	 * @see edit_entry_post_category_choices
88
+	 * @since 1.17
89
+	 *
90
+	 * @return void
91
+	 */
92
+	public function add_edit_entry_post_category_choices_filter()
93
+	{
94
+		add_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10, 3);
95
+	}
96
+
97
+	/**
98
+	 * Remove filter to show live category choices in Edit Entry.
99
+	 *
100
+	 * @see edit_entry_post_category_choices
101
+	 * @since 1.17
102
+	 *
103
+	 * @return void
104
+	 */
105
+	public function remove_edit_entry_post_category_choices_filter()
106
+	{
107
+		remove_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10);
108
+	}
109
+
110
+	/**
111
+	 * Always show the live Category values.
112
+	 *
113
+	 * By default, Gravity Forms would show unchecked/default choices. We want to show the live Post categories
114
+	 *
115
+	 * @since 1.17
116
+	 *
117
+	 * @param $choices
118
+	 * @param $field
119
+	 * @param $form_id
120
+	 *
121
+	 * @return mixed
122
+	 */
123
+	public function edit_entry_post_category_choices($choices, $field, $form_id)
124
+	{
125
+		$entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry();
126
+
127
+		// $entry['post_id'] should always be set, but we check to make sure.
128
+		if ($entry && isset($entry['post_id']) && $post_id = $entry['post_id']) {
129
+			$post_categories = wp_get_post_categories($post_id, ['fields' => 'ids']);
130
+
131
+			// Always use the live value
132
+			foreach ($choices as &$choice) {
133
+				$choice['isSelected'] = in_array($choice['value'], array_values($post_categories));
134
+			}
135
+		}
136
+
137
+		return $choices;
138
+	}
139
+
140
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
141
+	{
142
+		if ('edit' === $context) {
143
+			return $field_options;
144
+		}
145
+
146
+		$this->add_field_support('dynamic_data', $field_options);
147
+		$this->add_field_support('link_to_term', $field_options);
148
+		$this->add_field_support('new_window', $field_options);
149
+
150
+		$field_options['new_window']['requires'] = 'link_to_term';
151
+
152
+		return $field_options;
153
+	}
154 154
 }
155 155
 
156 156
 new GravityView_Field_Post_Category();
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
     public $is_searchable = true;
10 10
 
11
-    public $search_operators = ['is', 'in', 'not in', 'isnot', 'contains'];
11
+    public $search_operators = [ 'is', 'in', 'not in', 'isnot', 'contains' ];
12 12
 
13 13
     public $_gf_field_class_name = 'GF_Field_Post_Category';
14 14
 
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __construct()
20 20
     {
21
-        $this->label = esc_html__('Post Category', 'gravityview');
21
+        $this->label = esc_html__( 'Post Category', 'gravityview' );
22 22
 
23
-        add_action('gravityview/edit-entry/render/before', [$this, 'add_edit_entry_post_category_choices_filter']);
23
+        add_action( 'gravityview/edit-entry/render/before', [ $this, 'add_edit_entry_post_category_choices_filter' ] );
24 24
 
25
-        add_action('gravityview/edit-entry/render/after', [$this, 'remove_edit_entry_post_category_choices_filter']);
25
+        add_action( 'gravityview/edit-entry/render/after', [ $this, 'remove_edit_entry_post_category_choices_filter' ] );
26 26
 
27
-        add_action('gravityview/edit_entry/after_update', [$this, 'set_post_categories'], 10, 2);
27
+        add_action( 'gravityview/edit_entry/after_update', [ $this, 'set_post_categories' ], 10, 2 );
28 28
 
29 29
         parent::__construct();
30 30
     }
@@ -39,32 +39,32 @@  discard block
 block discarded – undo
39 39
      *
40 40
      * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
41 41
      */
42
-    public function set_post_categories($form = [], $entry_id = 0)
42
+    public function set_post_categories( $form = [ ], $entry_id = 0 )
43 43
     {
44
-        $entry = GFAPI::get_entry($entry_id);
45
-        $post_id = \GV\Utils::get($entry, 'post_id');
44
+        $entry = GFAPI::get_entry( $entry_id );
45
+        $post_id = \GV\Utils::get( $entry, 'post_id' );
46 46
 
47
-        if (empty($post_id)) {
47
+        if ( empty( $post_id ) ) {
48 48
             return false;
49 49
         }
50 50
 
51 51
         $return = false;
52 52
 
53
-        $post_category_fields = GFAPI::get_fields_by_type($form, 'post_category');
53
+        $post_category_fields = GFAPI::get_fields_by_type( $form, 'post_category' );
54 54
 
55
-        if ($post_category_fields) {
56
-            $updated_categories = [];
55
+        if ( $post_category_fields ) {
56
+            $updated_categories = [ ];
57 57
 
58
-            foreach ($post_category_fields as $field) {
58
+            foreach ( $post_category_fields as $field ) {
59 59
                 // Get the value of the field, including $_POSTed value
60
-                $field_cats = RGFormsModel::get_field_value($field);
61
-                $field_cats = is_array($field_cats) ? array_values($field_cats) : (array) $field_cats;
62
-                $field_cats = gv_map_deep($field_cats, 'intval');
63
-                $updated_categories = array_merge($updated_categories, array_values($field_cats));
60
+                $field_cats = RGFormsModel::get_field_value( $field );
61
+                $field_cats = is_array( $field_cats ) ? array_values( $field_cats ) : (array)$field_cats;
62
+                $field_cats = gv_map_deep( $field_cats, 'intval' );
63
+                $updated_categories = array_merge( $updated_categories, array_values( $field_cats ) );
64 64
             }
65 65
 
66 66
             // Remove `0` values from intval()
67
-            $updated_categories = array_filter($updated_categories);
67
+            $updated_categories = array_filter( $updated_categories );
68 68
 
69 69
             /**
70 70
              * @filter `gravityview/edit_entry/post_categories/append` Should post categories be added to or replaced?
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
              *
74 74
              * @param bool $append If `true`, don't delete existing categories, just add on. If `false`, replace the categories with the submitted categories. Default: `false`
75 75
              */
76
-            $append = apply_filters('gravityview/edit_entry/post_categories/append', false);
76
+            $append = apply_filters( 'gravityview/edit_entry/post_categories/append', false );
77 77
 
78
-            $return = wp_set_post_categories($post_id, $updated_categories, $append);
78
+            $return = wp_set_post_categories( $post_id, $updated_categories, $append );
79 79
         }
80 80
 
81 81
         return $return;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function add_edit_entry_post_category_choices_filter()
93 93
     {
94
-        add_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10, 3);
94
+        add_filter( 'gform_post_category_choices', [ $this, 'edit_entry_post_category_choices' ], 10, 3 );
95 95
     }
96 96
 
97 97
     /**
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function remove_edit_entry_post_category_choices_filter()
106 106
     {
107
-        remove_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10);
107
+        remove_filter( 'gform_post_category_choices', [ $this, 'edit_entry_post_category_choices' ], 10 );
108 108
     }
109 109
 
110 110
     /**
@@ -120,34 +120,34 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @return mixed
122 122
      */
123
-    public function edit_entry_post_category_choices($choices, $field, $form_id)
123
+    public function edit_entry_post_category_choices( $choices, $field, $form_id )
124 124
     {
125
-        $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry();
125
+        $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry();
126 126
 
127 127
         // $entry['post_id'] should always be set, but we check to make sure.
128
-        if ($entry && isset($entry['post_id']) && $post_id = $entry['post_id']) {
129
-            $post_categories = wp_get_post_categories($post_id, ['fields' => 'ids']);
128
+        if ( $entry && isset( $entry[ 'post_id' ] ) && $post_id = $entry[ 'post_id' ] ) {
129
+            $post_categories = wp_get_post_categories( $post_id, [ 'fields' => 'ids' ] );
130 130
 
131 131
             // Always use the live value
132
-            foreach ($choices as &$choice) {
133
-                $choice['isSelected'] = in_array($choice['value'], array_values($post_categories));
132
+            foreach ( $choices as &$choice ) {
133
+                $choice[ 'isSelected' ] = in_array( $choice[ 'value' ], array_values( $post_categories ) );
134 134
             }
135 135
         }
136 136
 
137 137
         return $choices;
138 138
     }
139 139
 
140
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
140
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
141 141
     {
142
-        if ('edit' === $context) {
142
+        if ( 'edit' === $context ) {
143 143
             return $field_options;
144 144
         }
145 145
 
146
-        $this->add_field_support('dynamic_data', $field_options);
147
-        $this->add_field_support('link_to_term', $field_options);
148
-        $this->add_field_support('new_window', $field_options);
146
+        $this->add_field_support( 'dynamic_data', $field_options );
147
+        $this->add_field_support( 'link_to_term', $field_options );
148
+        $this->add_field_support( 'new_window', $field_options );
149 149
 
150
-        $field_options['new_window']['requires'] = 'link_to_term';
150
+        $field_options[ 'new_window' ][ 'requires' ] = 'link_to_term';
151 151
 
152 152
         return $field_options;
153 153
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * @file class-gravityview-field-post-category.php
4 4
  */
5
-class GravityView_Field_Post_Category extends GravityView_Field
6
-{
5
+class GravityView_Field_Post_Category extends GravityView_Field {
7 6
     public $name = 'post_category';
8 7
 
9 8
     public $is_searchable = true;
@@ -16,8 +15,7 @@  discard block
 block discarded – undo
16 15
 
17 16
     public $icon = 'dashicons-category';
18 17
 
19
-    public function __construct()
20
-    {
18
+    public function __construct() {
21 19
         $this->label = esc_html__('Post Category', 'gravityview');
22 20
 
23 21
         add_action('gravityview/edit-entry/render/before', [$this, 'add_edit_entry_post_category_choices_filter']);
@@ -39,8 +37,7 @@  discard block
 block discarded – undo
39 37
      *
40 38
      * @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure. false if there are no post category fields or connected post.
41 39
      */
42
-    public function set_post_categories($form = [], $entry_id = 0)
43
-    {
40
+    public function set_post_categories($form = [], $entry_id = 0) {
44 41
         $entry = GFAPI::get_entry($entry_id);
45 42
         $post_id = \GV\Utils::get($entry, 'post_id');
46 43
 
@@ -89,8 +86,7 @@  discard block
 block discarded – undo
89 86
      *
90 87
      * @return void
91 88
      */
92
-    public function add_edit_entry_post_category_choices_filter()
93
-    {
89
+    public function add_edit_entry_post_category_choices_filter() {
94 90
         add_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10, 3);
95 91
     }
96 92
 
@@ -102,8 +98,7 @@  discard block
 block discarded – undo
102 98
      *
103 99
      * @return void
104 100
      */
105
-    public function remove_edit_entry_post_category_choices_filter()
106
-    {
101
+    public function remove_edit_entry_post_category_choices_filter() {
107 102
         remove_filter('gform_post_category_choices', [$this, 'edit_entry_post_category_choices'], 10);
108 103
     }
109 104
 
@@ -120,8 +115,7 @@  discard block
 block discarded – undo
120 115
      *
121 116
      * @return mixed
122 117
      */
123
-    public function edit_entry_post_category_choices($choices, $field, $form_id)
124
-    {
118
+    public function edit_entry_post_category_choices($choices, $field, $form_id) {
125 119
         $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry();
126 120
 
127 121
         // $entry['post_id'] should always be set, but we check to make sure.
@@ -137,8 +131,7 @@  discard block
 block discarded – undo
137 131
         return $choices;
138 132
     }
139 133
 
140
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
141
-    {
134
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
142 135
         if ('edit' === $context) {
143 136
             return $field_options;
144 137
         }
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-payment-status.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
  */
7 7
 class GravityView_Field_Payment_Status extends GravityView_Field
8 8
 {
9
-    public $name = 'payment_status';
9
+	public $name = 'payment_status';
10 10
 
11
-    public $is_searchable = true;
11
+	public $is_searchable = true;
12 12
 
13
-    public $search_operators = ['is', 'in', 'not in', 'isnot'];
13
+	public $search_operators = ['is', 'in', 'not in', 'isnot'];
14 14
 
15
-    public $group = 'pricing';
15
+	public $group = 'pricing';
16 16
 
17
-    public $_custom_merge_tag = 'payment_status';
17
+	public $_custom_merge_tag = 'payment_status';
18 18
 
19
-    public $icon = 'dashicons-cart';
19
+	public $icon = 'dashicons-cart';
20 20
 
21
-    /**
22
-     * GravityView_Field_Payment_Status constructor.
23
-     */
24
-    public function __construct()
25
-    {
26
-        $this->label = esc_html__('Payment Status', 'gravityview');
27
-        $this->description = esc_html__('The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gravityview');
28
-        parent::__construct();
29
-    }
21
+	/**
22
+	 * GravityView_Field_Payment_Status constructor.
23
+	 */
24
+	public function __construct()
25
+	{
26
+		$this->label = esc_html__('Payment Status', 'gravityview');
27
+		$this->description = esc_html__('The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gravityview');
28
+		parent::__construct();
29
+	}
30 30
 }
31 31
 
32 32
 new GravityView_Field_Payment_Status();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
     public $is_searchable = true;
12 12
 
13
-    public $search_operators = ['is', 'in', 'not in', 'isnot'];
13
+    public $search_operators = [ 'is', 'in', 'not in', 'isnot' ];
14 14
 
15 15
     public $group = 'pricing';
16 16
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct()
25 25
     {
26
-        $this->label = esc_html__('Payment Status', 'gravityview');
27
-        $this->description = esc_html__('The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gravityview');
26
+        $this->label = esc_html__( 'Payment Status', 'gravityview' );
27
+        $this->description = esc_html__( 'The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gravityview' );
28 28
         parent::__construct();
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  * @since 1.16
6 6
  */
7
-class GravityView_Field_Payment_Status extends GravityView_Field
8
-{
7
+class GravityView_Field_Payment_Status extends GravityView_Field {
9 8
     public $name = 'payment_status';
10 9
 
11 10
     public $is_searchable = true;
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
     /**
22 21
      * GravityView_Field_Payment_Status constructor.
23 22
      */
24
-    public function __construct()
25
-    {
23
+    public function __construct() {
26 24
         $this->label = esc_html__('Payment Status', 'gravityview');
27 25
         $this->description = esc_html__('The current payment status of the entry (ie "Processing", "Failed", "Cancelled", "Approved").', 'gravityview');
28 26
         parent::__construct();
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-total.php 3 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -6,97 +6,97 @@
 block discarded – undo
6 6
  */
7 7
 class GravityView_Field_Total extends GravityView_Field
8 8
 {
9
-    public $name = 'total';
10
-
11
-    public $is_searchable = true;
12
-
13
-    public $is_numeric = true;
14
-
15
-    public $search_operators = ['is', 'isnot', 'greater_than', 'less_than', 'contains'];
16
-
17
-    public $group = 'product';
18
-
19
-    public $icon = 'dashicons-cart';
20
-
21
-    /** @see GF_Field_Total */
22
-    public $_gf_field_class_name = 'GF_Field_Total';
23
-
24
-    public function __construct()
25
-    {
26
-        $this->label = esc_html__('Total', 'gravityview');
27
-
28
-        add_action('gravityview/edit_entry/after_update', [$this, 'edit_entry_recalculate_totals'], 10, 3);
29
-
30
-        add_filter('gravityview_blocklist_field_types', [$this, 'add_to_blocklist'], 10, 2);
31
-
32
-        parent::__construct();
33
-    }
34
-
35
-    /**
36
-     * Prevent the Total fields from being displayed in the Edit Entry configuration screen -- for now.
37
-     *
38
-     * Gravity Forms forms need to know all the pricing information available to calculate a Total.
39
-     *
40
-     * If you have an Edit Entry field with just two fields (Quantity and Total), the Total will not be able to calculate
41
-     * without the Product field, and possibly the Option, Shipping, and Coupon fields.
42
-     *
43
-     * The only options currently available are: show the whole form, or don't show the Total
44
-     *
45
-     * @since 1.20
46
-     *
47
-     * @todo Support Total fields in Edit Entry configuration
48
-     *
49
-     * @param array       $blocklist Array of field types not able to be added to Edit Entry
50
-     * @param string|null $context   Context
51
-     *
52
-     * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
53
-     */
54
-    public function add_to_blocklist($blocklist = [], $context = null)
55
-    {
56
-        if (empty($context) || $context !== 'edit') {
57
-            return $blocklist;
58
-        }
59
-
60
-        $blocklist[] = 'total';
61
-
62
-        return $blocklist;
63
-    }
64
-
65
-    /**
66
-     * If entry has totals fields, recalculate them.
67
-     *
68
-     * @since 1.20
69
-     *
70
-     * @param array                         $form              Gravity Forms form array
71
-     * @param int                           $entry_id          Gravity Forms Entry ID
72
-     * @param GravityView_Edit_Entry_Render $Edit_Entry_Render
73
-     *
74
-     * @return void
75
-     */
76
-    public function edit_entry_recalculate_totals($form = [], $entry_id = 0, $Edit_Entry_Render = null)
77
-    {
78
-        $original_form = GFAPI::get_form($form['id']);
79
-
80
-        $total_fields = GFCommon::get_fields_by_type($original_form, 'total');
81
-
82
-        //saving total field as the last field of the form.
83
-        if (!empty($total_fields)) {
84
-            $entry = GFAPI::get_entry($entry_id);
85
-
86
-            /** @var GF_Field_Total $total_field */
87
-            foreach ($total_fields as $total_field) {
88
-                $entry["{$total_field->id}"] = GFCommon::get_order_total($original_form, $entry);
89
-            }
90
-
91
-            $return_entry = GFAPI::update_entry($entry);
92
-
93
-            if (is_wp_error($return_entry)) {
94
-                gravityview()->log->error('Updating the entry total fields failed', ['data' => $return_entry]);
95
-            } else {
96
-                gravityview()->log->debug('Updating the entry total fields succeeded');
97
-            }
98
-        }
99
-    }
9
+	public $name = 'total';
10
+
11
+	public $is_searchable = true;
12
+
13
+	public $is_numeric = true;
14
+
15
+	public $search_operators = ['is', 'isnot', 'greater_than', 'less_than', 'contains'];
16
+
17
+	public $group = 'product';
18
+
19
+	public $icon = 'dashicons-cart';
20
+
21
+	/** @see GF_Field_Total */
22
+	public $_gf_field_class_name = 'GF_Field_Total';
23
+
24
+	public function __construct()
25
+	{
26
+		$this->label = esc_html__('Total', 'gravityview');
27
+
28
+		add_action('gravityview/edit_entry/after_update', [$this, 'edit_entry_recalculate_totals'], 10, 3);
29
+
30
+		add_filter('gravityview_blocklist_field_types', [$this, 'add_to_blocklist'], 10, 2);
31
+
32
+		parent::__construct();
33
+	}
34
+
35
+	/**
36
+	 * Prevent the Total fields from being displayed in the Edit Entry configuration screen -- for now.
37
+	 *
38
+	 * Gravity Forms forms need to know all the pricing information available to calculate a Total.
39
+	 *
40
+	 * If you have an Edit Entry field with just two fields (Quantity and Total), the Total will not be able to calculate
41
+	 * without the Product field, and possibly the Option, Shipping, and Coupon fields.
42
+	 *
43
+	 * The only options currently available are: show the whole form, or don't show the Total
44
+	 *
45
+	 * @since 1.20
46
+	 *
47
+	 * @todo Support Total fields in Edit Entry configuration
48
+	 *
49
+	 * @param array       $blocklist Array of field types not able to be added to Edit Entry
50
+	 * @param string|null $context   Context
51
+	 *
52
+	 * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
53
+	 */
54
+	public function add_to_blocklist($blocklist = [], $context = null)
55
+	{
56
+		if (empty($context) || $context !== 'edit') {
57
+			return $blocklist;
58
+		}
59
+
60
+		$blocklist[] = 'total';
61
+
62
+		return $blocklist;
63
+	}
64
+
65
+	/**
66
+	 * If entry has totals fields, recalculate them.
67
+	 *
68
+	 * @since 1.20
69
+	 *
70
+	 * @param array                         $form              Gravity Forms form array
71
+	 * @param int                           $entry_id          Gravity Forms Entry ID
72
+	 * @param GravityView_Edit_Entry_Render $Edit_Entry_Render
73
+	 *
74
+	 * @return void
75
+	 */
76
+	public function edit_entry_recalculate_totals($form = [], $entry_id = 0, $Edit_Entry_Render = null)
77
+	{
78
+		$original_form = GFAPI::get_form($form['id']);
79
+
80
+		$total_fields = GFCommon::get_fields_by_type($original_form, 'total');
81
+
82
+		//saving total field as the last field of the form.
83
+		if (!empty($total_fields)) {
84
+			$entry = GFAPI::get_entry($entry_id);
85
+
86
+			/** @var GF_Field_Total $total_field */
87
+			foreach ($total_fields as $total_field) {
88
+				$entry["{$total_field->id}"] = GFCommon::get_order_total($original_form, $entry);
89
+			}
90
+
91
+			$return_entry = GFAPI::update_entry($entry);
92
+
93
+			if (is_wp_error($return_entry)) {
94
+				gravityview()->log->error('Updating the entry total fields failed', ['data' => $return_entry]);
95
+			} else {
96
+				gravityview()->log->debug('Updating the entry total fields succeeded');
97
+			}
98
+		}
99
+	}
100 100
 }
101 101
 
102 102
 new GravityView_Field_Total();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     public $is_numeric = true;
14 14
 
15
-    public $search_operators = ['is', 'isnot', 'greater_than', 'less_than', 'contains'];
15
+    public $search_operators = [ 'is', 'isnot', 'greater_than', 'less_than', 'contains' ];
16 16
 
17 17
     public $group = 'product';
18 18
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function __construct()
25 25
     {
26
-        $this->label = esc_html__('Total', 'gravityview');
26
+        $this->label = esc_html__( 'Total', 'gravityview' );
27 27
 
28
-        add_action('gravityview/edit_entry/after_update', [$this, 'edit_entry_recalculate_totals'], 10, 3);
28
+        add_action( 'gravityview/edit_entry/after_update', [ $this, 'edit_entry_recalculate_totals' ], 10, 3 );
29 29
 
30
-        add_filter('gravityview_blocklist_field_types', [$this, 'add_to_blocklist'], 10, 2);
30
+        add_filter( 'gravityview_blocklist_field_types', [ $this, 'add_to_blocklist' ], 10, 2 );
31 31
 
32 32
         parent::__construct();
33 33
     }
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
53 53
      */
54
-    public function add_to_blocklist($blocklist = [], $context = null)
54
+    public function add_to_blocklist( $blocklist = [ ], $context = null )
55 55
     {
56
-        if (empty($context) || $context !== 'edit') {
56
+        if ( empty( $context ) || $context !== 'edit' ) {
57 57
             return $blocklist;
58 58
         }
59 59
 
60
-        $blocklist[] = 'total';
60
+        $blocklist[ ] = 'total';
61 61
 
62 62
         return $blocklist;
63 63
     }
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @return void
75 75
      */
76
-    public function edit_entry_recalculate_totals($form = [], $entry_id = 0, $Edit_Entry_Render = null)
76
+    public function edit_entry_recalculate_totals( $form = [ ], $entry_id = 0, $Edit_Entry_Render = null )
77 77
     {
78
-        $original_form = GFAPI::get_form($form['id']);
78
+        $original_form = GFAPI::get_form( $form[ 'id' ] );
79 79
 
80
-        $total_fields = GFCommon::get_fields_by_type($original_form, 'total');
80
+        $total_fields = GFCommon::get_fields_by_type( $original_form, 'total' );
81 81
 
82 82
         //saving total field as the last field of the form.
83
-        if (!empty($total_fields)) {
84
-            $entry = GFAPI::get_entry($entry_id);
83
+        if ( ! empty( $total_fields ) ) {
84
+            $entry = GFAPI::get_entry( $entry_id );
85 85
 
86 86
             /** @var GF_Field_Total $total_field */
87
-            foreach ($total_fields as $total_field) {
88
-                $entry["{$total_field->id}"] = GFCommon::get_order_total($original_form, $entry);
87
+            foreach ( $total_fields as $total_field ) {
88
+                $entry[ "{$total_field->id}" ] = GFCommon::get_order_total( $original_form, $entry );
89 89
             }
90 90
 
91
-            $return_entry = GFAPI::update_entry($entry);
91
+            $return_entry = GFAPI::update_entry( $entry );
92 92
 
93
-            if (is_wp_error($return_entry)) {
94
-                gravityview()->log->error('Updating the entry total fields failed', ['data' => $return_entry]);
93
+            if ( is_wp_error( $return_entry ) ) {
94
+                gravityview()->log->error( 'Updating the entry total fields failed', [ 'data' => $return_entry ] );
95 95
             } else {
96
-                gravityview()->log->debug('Updating the entry total fields succeeded');
96
+                gravityview()->log->debug( 'Updating the entry total fields succeeded' );
97 97
             }
98 98
         }
99 99
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  * @since 1.20
6 6
  */
7
-class GravityView_Field_Total extends GravityView_Field
8
-{
7
+class GravityView_Field_Total extends GravityView_Field {
9 8
     public $name = 'total';
10 9
 
11 10
     public $is_searchable = true;
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
     /** @see GF_Field_Total */
22 21
     public $_gf_field_class_name = 'GF_Field_Total';
23 22
 
24
-    public function __construct()
25
-    {
23
+    public function __construct() {
26 24
         $this->label = esc_html__('Total', 'gravityview');
27 25
 
28 26
         add_action('gravityview/edit_entry/after_update', [$this, 'edit_entry_recalculate_totals'], 10, 3);
@@ -51,8 +49,7 @@  discard block
 block discarded – undo
51 49
      *
52 50
      * @return array Blocklist, with "total" added. If not edit context, original field blocklist. Otherwise, blocklist including total.
53 51
      */
54
-    public function add_to_blocklist($blocklist = [], $context = null)
55
-    {
52
+    public function add_to_blocklist($blocklist = [], $context = null) {
56 53
         if (empty($context) || $context !== 'edit') {
57 54
             return $blocklist;
58 55
         }
@@ -73,8 +70,7 @@  discard block
 block discarded – undo
73 70
      *
74 71
      * @return void
75 72
      */
76
-    public function edit_entry_recalculate_totals($form = [], $entry_id = 0, $Edit_Entry_Render = null)
77
-    {
73
+    public function edit_entry_recalculate_totals($form = [], $entry_id = 0, $Edit_Entry_Render = null) {
78 74
         $original_form = GFAPI::get_form($form['id']);
79 75
 
80 76
         $total_fields = GFCommon::get_fields_by_type($original_form, 'total');
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-date-created.php 3 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -4,102 +4,102 @@
 block discarded – undo
4 4
  */
5 5
 class GravityView_Field_Date_Created extends GravityView_Field
6 6
 {
7
-    public $name = 'date_created';
8
-
9
-    public $is_searchable = true;
10
-
11
-    public $search_operators = ['less_than', 'greater_than', 'is', 'isnot'];
12
-
13
-    public $group = 'meta';
14
-
15
-    public $contexts = ['single', 'multiple', 'export'];
16
-
17
-    public $_custom_merge_tag = 'date_created';
18
-
19
-    public $icon = 'dashicons-calendar-alt';
20
-
21
-    /**
22
-     * GravityView_Field_Date_Created constructor.
23
-     */
24
-    public function __construct()
25
-    {
26
-        $this->label = esc_html__('Date Created', 'gravityview');
27
-        $this->default_search_label = $this->label;
28
-        $this->description = esc_html__('The date the entry was created.', 'gravityview');
29
-
30
-        add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
31
-
32
-        parent::__construct();
33
-    }
34
-
35
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
36
-    {
37
-        if ('edit' === $context) {
38
-            return $field_options;
39
-        }
40
-
41
-        $this->add_field_support('date_display', $field_options);
42
-
43
-        return $field_options;
44
-    }
45
-
46
-    /**
47
-     * Filter the value of the field.
48
-     *
49
-     * @todo Consider how to add to parent class
50
-     *
51
-     * @since 1.16
52
-     *
53
-     * @param string $output         HTML value output
54
-     * @param array  $entry          The GF entry array
55
-     * @param array  $field_settings Settings for the particular GV field
56
-     * @param array  $field          Current field being displayed
57
-     *
58
-     * @return string values for this field based on the numeric values used by Gravity Forms
59
-     */
60
-    public function get_content($output = '', $entry = [], $field_settings = [], $field = [])
61
-    {
62
-
63
-        /** Overridden by a template. */
64
-        if (!empty($field['field_path'])) {
65
-            return $output;
66
-        }
67
-
68
-        return GVCommon::format_date($field['value'], 'format='.\GV\Utils::get($field_settings, 'date_display'));
69
-    }
70
-
71
-    /**
72
-     * Add {date_created} merge tag and format the values using format_date.
73
-     *
74
-     * @since 1.16
75
-     * @see https://docs.gravityview.co/article/331-date-created-merge-tag for usage information
76
-     *
77
-     * @param array  $matches    Array of Merge Tag matches found in text by preg_match_all
78
-     * @param string $text       Text to replace
79
-     * @param array  $form       Gravity Forms form array
80
-     * @param array  $entry      Entry array
81
-     * @param bool   $url_encode Whether to URL-encode output
82
-     *
83
-     * @return string Original text if {date_created} isn't found. Otherwise, replaced text.
84
-     */
85
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
86
-    {
87
-        $return = $text;
88
-
89
-        /** Use $this->name instead of date_created because Payment Date uses this as well*/
90
-        $date_created = \GV\Utils::get($entry, $this->name);
91
-
92
-        foreach ($matches as $match) {
93
-            $full_tag = $match[0];
94
-            $property = $match[1];
95
-
96
-            $formatted_date = GravityView_Merge_Tags::format_date($date_created, $property);
97
-
98
-            $return = str_replace($full_tag, $formatted_date, $return);
99
-        }
100
-
101
-        return $return;
102
-    }
7
+	public $name = 'date_created';
8
+
9
+	public $is_searchable = true;
10
+
11
+	public $search_operators = ['less_than', 'greater_than', 'is', 'isnot'];
12
+
13
+	public $group = 'meta';
14
+
15
+	public $contexts = ['single', 'multiple', 'export'];
16
+
17
+	public $_custom_merge_tag = 'date_created';
18
+
19
+	public $icon = 'dashicons-calendar-alt';
20
+
21
+	/**
22
+	 * GravityView_Field_Date_Created constructor.
23
+	 */
24
+	public function __construct()
25
+	{
26
+		$this->label = esc_html__('Date Created', 'gravityview');
27
+		$this->default_search_label = $this->label;
28
+		$this->description = esc_html__('The date the entry was created.', 'gravityview');
29
+
30
+		add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
31
+
32
+		parent::__construct();
33
+	}
34
+
35
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
36
+	{
37
+		if ('edit' === $context) {
38
+			return $field_options;
39
+		}
40
+
41
+		$this->add_field_support('date_display', $field_options);
42
+
43
+		return $field_options;
44
+	}
45
+
46
+	/**
47
+	 * Filter the value of the field.
48
+	 *
49
+	 * @todo Consider how to add to parent class
50
+	 *
51
+	 * @since 1.16
52
+	 *
53
+	 * @param string $output         HTML value output
54
+	 * @param array  $entry          The GF entry array
55
+	 * @param array  $field_settings Settings for the particular GV field
56
+	 * @param array  $field          Current field being displayed
57
+	 *
58
+	 * @return string values for this field based on the numeric values used by Gravity Forms
59
+	 */
60
+	public function get_content($output = '', $entry = [], $field_settings = [], $field = [])
61
+	{
62
+
63
+		/** Overridden by a template. */
64
+		if (!empty($field['field_path'])) {
65
+			return $output;
66
+		}
67
+
68
+		return GVCommon::format_date($field['value'], 'format='.\GV\Utils::get($field_settings, 'date_display'));
69
+	}
70
+
71
+	/**
72
+	 * Add {date_created} merge tag and format the values using format_date.
73
+	 *
74
+	 * @since 1.16
75
+	 * @see https://docs.gravityview.co/article/331-date-created-merge-tag for usage information
76
+	 *
77
+	 * @param array  $matches    Array of Merge Tag matches found in text by preg_match_all
78
+	 * @param string $text       Text to replace
79
+	 * @param array  $form       Gravity Forms form array
80
+	 * @param array  $entry      Entry array
81
+	 * @param bool   $url_encode Whether to URL-encode output
82
+	 *
83
+	 * @return string Original text if {date_created} isn't found. Otherwise, replaced text.
84
+	 */
85
+	public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
86
+	{
87
+		$return = $text;
88
+
89
+		/** Use $this->name instead of date_created because Payment Date uses this as well*/
90
+		$date_created = \GV\Utils::get($entry, $this->name);
91
+
92
+		foreach ($matches as $match) {
93
+			$full_tag = $match[0];
94
+			$property = $match[1];
95
+
96
+			$formatted_date = GravityView_Merge_Tags::format_date($date_created, $property);
97
+
98
+			$return = str_replace($full_tag, $formatted_date, $return);
99
+		}
100
+
101
+		return $return;
102
+	}
103 103
 }
104 104
 
105 105
 new GravityView_Field_Date_Created();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
 
9 9
     public $is_searchable = true;
10 10
 
11
-    public $search_operators = ['less_than', 'greater_than', 'is', 'isnot'];
11
+    public $search_operators = [ 'less_than', 'greater_than', 'is', 'isnot' ];
12 12
 
13 13
     public $group = 'meta';
14 14
 
15
-    public $contexts = ['single', 'multiple', 'export'];
15
+    public $contexts = [ 'single', 'multiple', 'export' ];
16 16
 
17 17
     public $_custom_merge_tag = 'date_created';
18 18
 
@@ -23,22 +23,22 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function __construct()
25 25
     {
26
-        $this->label = esc_html__('Date Created', 'gravityview');
26
+        $this->label = esc_html__( 'Date Created', 'gravityview' );
27 27
         $this->default_search_label = $this->label;
28
-        $this->description = esc_html__('The date the entry was created.', 'gravityview');
28
+        $this->description = esc_html__( 'The date the entry was created.', 'gravityview' );
29 29
 
30
-        add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
30
+        add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', [ $this, 'get_content' ], 10, 4 );
31 31
 
32 32
         parent::__construct();
33 33
     }
34 34
 
35
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
35
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
36 36
     {
37
-        if ('edit' === $context) {
37
+        if ( 'edit' === $context ) {
38 38
             return $field_options;
39 39
         }
40 40
 
41
-        $this->add_field_support('date_display', $field_options);
41
+        $this->add_field_support( 'date_display', $field_options );
42 42
 
43 43
         return $field_options;
44 44
     }
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return string values for this field based on the numeric values used by Gravity Forms
59 59
      */
60
-    public function get_content($output = '', $entry = [], $field_settings = [], $field = [])
60
+    public function get_content( $output = '', $entry = [ ], $field_settings = [ ], $field = [ ] )
61 61
     {
62 62
 
63 63
         /** Overridden by a template. */
64
-        if (!empty($field['field_path'])) {
64
+        if ( ! empty( $field[ 'field_path' ] ) ) {
65 65
             return $output;
66 66
         }
67 67
 
68
-        return GVCommon::format_date($field['value'], 'format='.\GV\Utils::get($field_settings, 'date_display'));
68
+        return GVCommon::format_date( $field[ 'value' ], 'format=' . \GV\Utils::get( $field_settings, 'date_display' ) );
69 69
     }
70 70
 
71 71
     /**
@@ -82,20 +82,20 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return string Original text if {date_created} isn't found. Otherwise, replaced text.
84 84
      */
85
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
85
+    public function replace_merge_tag( $matches = [ ], $text = '', $form = [ ], $entry = [ ], $url_encode = false, $esc_html = false )
86 86
     {
87 87
         $return = $text;
88 88
 
89 89
         /** Use $this->name instead of date_created because Payment Date uses this as well*/
90
-        $date_created = \GV\Utils::get($entry, $this->name);
90
+        $date_created = \GV\Utils::get( $entry, $this->name );
91 91
 
92
-        foreach ($matches as $match) {
93
-            $full_tag = $match[0];
94
-            $property = $match[1];
92
+        foreach ( $matches as $match ) {
93
+            $full_tag = $match[ 0 ];
94
+            $property = $match[ 1 ];
95 95
 
96
-            $formatted_date = GravityView_Merge_Tags::format_date($date_created, $property);
96
+            $formatted_date = GravityView_Merge_Tags::format_date( $date_created, $property );
97 97
 
98
-            $return = str_replace($full_tag, $formatted_date, $return);
98
+            $return = str_replace( $full_tag, $formatted_date, $return );
99 99
         }
100 100
 
101 101
         return $return;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * @file class-gravityview-field-date-created.php
4 4
  */
5
-class GravityView_Field_Date_Created extends GravityView_Field
6
-{
5
+class GravityView_Field_Date_Created extends GravityView_Field {
7 6
     public $name = 'date_created';
8 7
 
9 8
     public $is_searchable = true;
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
     /**
22 21
      * GravityView_Field_Date_Created constructor.
23 22
      */
24
-    public function __construct()
25
-    {
23
+    public function __construct() {
26 24
         $this->label = esc_html__('Date Created', 'gravityview');
27 25
         $this->default_search_label = $this->label;
28 26
         $this->description = esc_html__('The date the entry was created.', 'gravityview');
@@ -32,8 +30,7 @@  discard block
 block discarded – undo
32 30
         parent::__construct();
33 31
     }
34 32
 
35
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
36
-    {
33
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
37 34
         if ('edit' === $context) {
38 35
             return $field_options;
39 36
         }
@@ -57,8 +54,7 @@  discard block
 block discarded – undo
57 54
      *
58 55
      * @return string values for this field based on the numeric values used by Gravity Forms
59 56
      */
60
-    public function get_content($output = '', $entry = [], $field_settings = [], $field = [])
61
-    {
57
+    public function get_content($output = '', $entry = [], $field_settings = [], $field = []) {
62 58
 
63 59
         /** Overridden by a template. */
64 60
         if (!empty($field['field_path'])) {
@@ -82,8 +78,7 @@  discard block
 block discarded – undo
82 78
      *
83 79
      * @return string Original text if {date_created} isn't found. Otherwise, replaced text.
84 80
      */
85
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
86
-    {
81
+    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) {
87 82
         $return = $text;
88 83
 
89 84
         /** Use $this->name instead of date_created because Payment Date uses this as well*/
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-pipe_recorder.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,38 +4,38 @@
 block discarded – undo
4 4
  */
5 5
 class GravityView_Field_Pipe_Recorder extends GravityView_Field
6 6
 {
7
-    public $name = 'pipe_recorder';
7
+	public $name = 'pipe_recorder';
8 8
 
9
-    public $_gf_field_class_name = 'GF_Field_Pipe_Recorder';
9
+	public $_gf_field_class_name = 'GF_Field_Pipe_Recorder';
10 10
 
11
-    public $is_searchable = false;
11
+	public $is_searchable = false;
12 12
 
13
-    public $group = 'advanced';
13
+	public $group = 'advanced';
14 14
 
15
-    public function __construct()
16
-    {
17
-        $this->label = esc_html__('Pipe Recorder', 'gravityview');
18
-        parent::__construct();
19
-    }
15
+	public function __construct()
16
+	{
17
+		$this->label = esc_html__('Pipe Recorder', 'gravityview');
18
+		parent::__construct();
19
+	}
20 20
 
21
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
22
-    {
23
-        unset($field_options['search_filter']);
21
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
22
+	{
23
+		unset($field_options['search_filter']);
24 24
 
25
-        if ('edit' === $context) {
26
-            return $field_options;
27
-        }
25
+		if ('edit' === $context) {
26
+			return $field_options;
27
+		}
28 28
 
29
-        $add_options['embed'] = [
30
-            'type'       => 'checkbox',
31
-            'label'      => __('Display as embedded', 'gravityview'),
32
-            'desc'       => __('Display the video in a player, rather than a direct link to the video.', 'gravityview'),
33
-            'value'      => true,
34
-            'merge_tags' => false,
35
-        ];
29
+		$add_options['embed'] = [
30
+			'type'       => 'checkbox',
31
+			'label'      => __('Display as embedded', 'gravityview'),
32
+			'desc'       => __('Display the video in a player, rather than a direct link to the video.', 'gravityview'),
33
+			'value'      => true,
34
+			'merge_tags' => false,
35
+		];
36 36
 
37
-        return $add_options + $field_options;
38
-    }
37
+		return $add_options + $field_options;
38
+	}
39 39
 }
40 40
 
41 41
 new GravityView_Field_Pipe_Recorder();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@
 block discarded – undo
14 14
 
15 15
     public function __construct()
16 16
     {
17
-        $this->label = esc_html__('Pipe Recorder', 'gravityview');
17
+        $this->label = esc_html__( 'Pipe Recorder', 'gravityview' );
18 18
         parent::__construct();
19 19
     }
20 20
 
21
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
21
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
22 22
     {
23
-        unset($field_options['search_filter']);
23
+        unset( $field_options[ 'search_filter' ] );
24 24
 
25
-        if ('edit' === $context) {
25
+        if ( 'edit' === $context ) {
26 26
             return $field_options;
27 27
         }
28 28
 
29
-        $add_options['embed'] = [
29
+        $add_options[ 'embed' ] = [
30 30
             'type'       => 'checkbox',
31
-            'label'      => __('Display as embedded', 'gravityview'),
32
-            'desc'       => __('Display the video in a player, rather than a direct link to the video.', 'gravityview'),
31
+            'label'      => __( 'Display as embedded', 'gravityview' ),
32
+            'desc'       => __( 'Display the video in a player, rather than a direct link to the video.', 'gravityview' ),
33 33
             'value'      => true,
34 34
             'merge_tags' => false,
35 35
         ];
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * @file class-gravityview-field-fileupload.php
4 4
  */
5
-class GravityView_Field_Pipe_Recorder extends GravityView_Field
6
-{
5
+class GravityView_Field_Pipe_Recorder extends GravityView_Field {
7 6
     public $name = 'pipe_recorder';
8 7
 
9 8
     public $_gf_field_class_name = 'GF_Field_Pipe_Recorder';
@@ -12,14 +11,12 @@  discard block
 block discarded – undo
12 11
 
13 12
     public $group = 'advanced';
14 13
 
15
-    public function __construct()
16
-    {
14
+    public function __construct() {
17 15
         $this->label = esc_html__('Pipe Recorder', 'gravityview');
18 16
         parent::__construct();
19 17
     }
20 18
 
21
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
22
-    {
19
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
23 20
         unset($field_options['search_filter']);
24 21
 
25 22
         if ('edit' === $context) {
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-is-fulfilled.php 3 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -6,138 +6,138 @@
 block discarded – undo
6 6
  */
7 7
 class GravityView_Field_Is_Fulfilled extends GravityView_Field
8 8
 {
9
-    public $name = 'is_fulfilled';
10
-
11
-    public $is_searchable = true;
12
-
13
-    public $is_numeric = false;
14
-
15
-    public $search_operators = ['is', 'isnot'];
16
-
17
-    public $group = 'pricing';
18
-
19
-    public $_custom_merge_tag = 'is_fulfilled';
20
-
21
-    /**
22
-     * @var int The value used by Gravity Forms when the order has not been fulfilled
23
-     */
24
-    const NOT_FULFILLED = 0;
25
-
26
-    /**
27
-     * @var int The value used by Gravity Forms when the order has been fulfilled
28
-     */
29
-    const FULFILLED = 1;
30
-
31
-    /**
32
-     * GravityView_Field_Is_Fulfilled constructor.
33
-     */
34
-    public function __construct()
35
-    {
36
-        $this->label = esc_html__('Is Fulfilled', 'gravityview');
37
-        $this->description = esc_html__('Indicates if the entry or order has been fulfilled.', 'gravityview');
38
-        $this->default_search_label = $this->label;
39
-
40
-        add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
41
-        add_filter('gravityview/field/is_fulfilled/value', [$this, 'get_value'], 10);
42
-
43
-        parent::__construct();
44
-    }
45
-
46
-    /**
47
-     * Filter the value of the field.
48
-     *
49
-     * @todo Consider how to add to parent class
50
-     *
51
-     * @since 1.16
52
-     *
53
-     * @param string $output         HTML value output
54
-     * @param array  $entry          The GF entry array
55
-     * @param array  $field_settings Settings for the particular GV field
56
-     * @param array  $field          Current field being displayed
57
-     *
58
-     * @return string values for this field based on the numeric values used by Gravity Forms
59
-     */
60
-    public function get_content($output, $entry = [], $field_settings = [], $field = [])
61
-    {
62
-
63
-        /** Overridden by a template. */
64
-        if (!empty($field['field_path'])) {
65
-            return $output;
66
-        }
67
-
68
-        return $this->get_string_from_value($output);
69
-    }
70
-
71
-    /**
72
-     * Filter the value of the field (future).
73
-     *
74
-     * @since 2.0
75
-     *
76
-     * @param mixed $value The value in.
77
-     *
78
-     * @return mixed The value out.
79
-     */
80
-    public function get_value($value)
81
-    {
82
-        return $this->get_string_from_value($value);
83
-    }
84
-
85
-    /**
86
-     * Get the string output based on the numeric value used by Gravity Forms.
87
-     *
88
-     * @since 1.16
89
-     *
90
-     * @param int|string $value Number value for the field
91
-     *
92
-     * @return string
93
-     */
94
-    private function get_string_from_value($value)
95
-    {
96
-        switch (intval($value)) {
97
-            case self::NOT_FULFILLED:
98
-            default:
99
-                $return = __('Not Fulfilled', 'gravityview');
100
-                break;
101
-
102
-            case self::FULFILLED:
103
-                $return = __('Fulfilled', 'gravityview');
104
-                break;
105
-        }
106
-
107
-        return $return;
108
-    }
109
-
110
-    /**
111
-     * Add {is_fulfilled} merge tag.
112
-     *
113
-     * @since 1.16
114
-     **
115
-     * @param array  $matches    Array of Merge Tag matches found in text by preg_match_all
116
-     * @param string $text       Text to replace
117
-     * @param array  $form       Gravity Forms form array
118
-     * @param array  $entry      Entry array
119
-     * @param bool   $url_encode Whether to URL-encode output
120
-     *
121
-     * @return string Original text if {is_fulfilled} isn't found. Otherwise, "Not Fulfilled" or "Fulfilled"
122
-     */
123
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
124
-    {
125
-        $return = $text;
126
-
127
-        foreach ($matches as $match) {
128
-            $full_tag = $match[0];
129
-
130
-            $fulfilled = \GV\Utils::get($entry, 'is_fulfilled');
131
-
132
-            $value = $this->get_string_from_value($fulfilled);
133
-
134
-            $return = str_replace($full_tag, $value, $return);
135
-        }
136
-
137
-        unset($formatted_amount, $value, $amount, $full_tag, $matches);
138
-
139
-        return $return;
140
-    }
9
+	public $name = 'is_fulfilled';
10
+
11
+	public $is_searchable = true;
12
+
13
+	public $is_numeric = false;
14
+
15
+	public $search_operators = ['is', 'isnot'];
16
+
17
+	public $group = 'pricing';
18
+
19
+	public $_custom_merge_tag = 'is_fulfilled';
20
+
21
+	/**
22
+	 * @var int The value used by Gravity Forms when the order has not been fulfilled
23
+	 */
24
+	const NOT_FULFILLED = 0;
25
+
26
+	/**
27
+	 * @var int The value used by Gravity Forms when the order has been fulfilled
28
+	 */
29
+	const FULFILLED = 1;
30
+
31
+	/**
32
+	 * GravityView_Field_Is_Fulfilled constructor.
33
+	 */
34
+	public function __construct()
35
+	{
36
+		$this->label = esc_html__('Is Fulfilled', 'gravityview');
37
+		$this->description = esc_html__('Indicates if the entry or order has been fulfilled.', 'gravityview');
38
+		$this->default_search_label = $this->label;
39
+
40
+		add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
41
+		add_filter('gravityview/field/is_fulfilled/value', [$this, 'get_value'], 10);
42
+
43
+		parent::__construct();
44
+	}
45
+
46
+	/**
47
+	 * Filter the value of the field.
48
+	 *
49
+	 * @todo Consider how to add to parent class
50
+	 *
51
+	 * @since 1.16
52
+	 *
53
+	 * @param string $output         HTML value output
54
+	 * @param array  $entry          The GF entry array
55
+	 * @param array  $field_settings Settings for the particular GV field
56
+	 * @param array  $field          Current field being displayed
57
+	 *
58
+	 * @return string values for this field based on the numeric values used by Gravity Forms
59
+	 */
60
+	public function get_content($output, $entry = [], $field_settings = [], $field = [])
61
+	{
62
+
63
+		/** Overridden by a template. */
64
+		if (!empty($field['field_path'])) {
65
+			return $output;
66
+		}
67
+
68
+		return $this->get_string_from_value($output);
69
+	}
70
+
71
+	/**
72
+	 * Filter the value of the field (future).
73
+	 *
74
+	 * @since 2.0
75
+	 *
76
+	 * @param mixed $value The value in.
77
+	 *
78
+	 * @return mixed The value out.
79
+	 */
80
+	public function get_value($value)
81
+	{
82
+		return $this->get_string_from_value($value);
83
+	}
84
+
85
+	/**
86
+	 * Get the string output based on the numeric value used by Gravity Forms.
87
+	 *
88
+	 * @since 1.16
89
+	 *
90
+	 * @param int|string $value Number value for the field
91
+	 *
92
+	 * @return string
93
+	 */
94
+	private function get_string_from_value($value)
95
+	{
96
+		switch (intval($value)) {
97
+			case self::NOT_FULFILLED:
98
+			default:
99
+				$return = __('Not Fulfilled', 'gravityview');
100
+				break;
101
+
102
+			case self::FULFILLED:
103
+				$return = __('Fulfilled', 'gravityview');
104
+				break;
105
+		}
106
+
107
+		return $return;
108
+	}
109
+
110
+	/**
111
+	 * Add {is_fulfilled} merge tag.
112
+	 *
113
+	 * @since 1.16
114
+	 **
115
+	 * @param array  $matches    Array of Merge Tag matches found in text by preg_match_all
116
+	 * @param string $text       Text to replace
117
+	 * @param array  $form       Gravity Forms form array
118
+	 * @param array  $entry      Entry array
119
+	 * @param bool   $url_encode Whether to URL-encode output
120
+	 *
121
+	 * @return string Original text if {is_fulfilled} isn't found. Otherwise, "Not Fulfilled" or "Fulfilled"
122
+	 */
123
+	public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
124
+	{
125
+		$return = $text;
126
+
127
+		foreach ($matches as $match) {
128
+			$full_tag = $match[0];
129
+
130
+			$fulfilled = \GV\Utils::get($entry, 'is_fulfilled');
131
+
132
+			$value = $this->get_string_from_value($fulfilled);
133
+
134
+			$return = str_replace($full_tag, $value, $return);
135
+		}
136
+
137
+		unset($formatted_amount, $value, $amount, $full_tag, $matches);
138
+
139
+		return $return;
140
+	}
141 141
 }
142 142
 
143 143
 new GravityView_Field_Is_Fulfilled();
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     public $is_numeric = false;
14 14
 
15
-    public $search_operators = ['is', 'isnot'];
15
+    public $search_operators = [ 'is', 'isnot' ];
16 16
 
17 17
     public $group = 'pricing';
18 18
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function __construct()
35 35
     {
36
-        $this->label = esc_html__('Is Fulfilled', 'gravityview');
37
-        $this->description = esc_html__('Indicates if the entry or order has been fulfilled.', 'gravityview');
36
+        $this->label = esc_html__( 'Is Fulfilled', 'gravityview' );
37
+        $this->description = esc_html__( 'Indicates if the entry or order has been fulfilled.', 'gravityview' );
38 38
         $this->default_search_label = $this->label;
39 39
 
40
-        add_filter('gravityview_field_entry_value_'.$this->name.'_pre_link', [$this, 'get_content'], 10, 4);
41
-        add_filter('gravityview/field/is_fulfilled/value', [$this, 'get_value'], 10);
40
+        add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', [ $this, 'get_content' ], 10, 4 );
41
+        add_filter( 'gravityview/field/is_fulfilled/value', [ $this, 'get_value' ], 10 );
42 42
 
43 43
         parent::__construct();
44 44
     }
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return string values for this field based on the numeric values used by Gravity Forms
59 59
      */
60
-    public function get_content($output, $entry = [], $field_settings = [], $field = [])
60
+    public function get_content( $output, $entry = [ ], $field_settings = [ ], $field = [ ] )
61 61
     {
62 62
 
63 63
         /** Overridden by a template. */
64
-        if (!empty($field['field_path'])) {
64
+        if ( ! empty( $field[ 'field_path' ] ) ) {
65 65
             return $output;
66 66
         }
67 67
 
68
-        return $this->get_string_from_value($output);
68
+        return $this->get_string_from_value( $output );
69 69
     }
70 70
 
71 71
     /**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      *
78 78
      * @return mixed The value out.
79 79
      */
80
-    public function get_value($value)
80
+    public function get_value( $value )
81 81
     {
82
-        return $this->get_string_from_value($value);
82
+        return $this->get_string_from_value( $value );
83 83
     }
84 84
 
85 85
     /**
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @return string
93 93
      */
94
-    private function get_string_from_value($value)
94
+    private function get_string_from_value( $value )
95 95
     {
96
-        switch (intval($value)) {
96
+        switch ( intval( $value ) ) {
97 97
             case self::NOT_FULFILLED:
98 98
             default:
99
-                $return = __('Not Fulfilled', 'gravityview');
99
+                $return = __( 'Not Fulfilled', 'gravityview' );
100 100
                 break;
101 101
 
102 102
             case self::FULFILLED:
103
-                $return = __('Fulfilled', 'gravityview');
103
+                $return = __( 'Fulfilled', 'gravityview' );
104 104
                 break;
105 105
         }
106 106
 
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
      *
121 121
      * @return string Original text if {is_fulfilled} isn't found. Otherwise, "Not Fulfilled" or "Fulfilled"
122 122
      */
123
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
123
+    public function replace_merge_tag( $matches = [ ], $text = '', $form = [ ], $entry = [ ], $url_encode = false, $esc_html = false )
124 124
     {
125 125
         $return = $text;
126 126
 
127
-        foreach ($matches as $match) {
128
-            $full_tag = $match[0];
127
+        foreach ( $matches as $match ) {
128
+            $full_tag = $match[ 0 ];
129 129
 
130
-            $fulfilled = \GV\Utils::get($entry, 'is_fulfilled');
130
+            $fulfilled = \GV\Utils::get( $entry, 'is_fulfilled' );
131 131
 
132
-            $value = $this->get_string_from_value($fulfilled);
132
+            $value = $this->get_string_from_value( $fulfilled );
133 133
 
134
-            $return = str_replace($full_tag, $value, $return);
134
+            $return = str_replace( $full_tag, $value, $return );
135 135
         }
136 136
 
137
-        unset($formatted_amount, $value, $amount, $full_tag, $matches);
137
+        unset( $formatted_amount, $value, $amount, $full_tag, $matches );
138 138
 
139 139
         return $return;
140 140
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  * @since 1.16
6 6
  */
7
-class GravityView_Field_Is_Fulfilled extends GravityView_Field
8
-{
7
+class GravityView_Field_Is_Fulfilled extends GravityView_Field {
9 8
     public $name = 'is_fulfilled';
10 9
 
11 10
     public $is_searchable = true;
@@ -31,8 +30,7 @@  discard block
 block discarded – undo
31 30
     /**
32 31
      * GravityView_Field_Is_Fulfilled constructor.
33 32
      */
34
-    public function __construct()
35
-    {
33
+    public function __construct() {
36 34
         $this->label = esc_html__('Is Fulfilled', 'gravityview');
37 35
         $this->description = esc_html__('Indicates if the entry or order has been fulfilled.', 'gravityview');
38 36
         $this->default_search_label = $this->label;
@@ -57,8 +55,7 @@  discard block
 block discarded – undo
57 55
      *
58 56
      * @return string values for this field based on the numeric values used by Gravity Forms
59 57
      */
60
-    public function get_content($output, $entry = [], $field_settings = [], $field = [])
61
-    {
58
+    public function get_content($output, $entry = [], $field_settings = [], $field = []) {
62 59
 
63 60
         /** Overridden by a template. */
64 61
         if (!empty($field['field_path'])) {
@@ -77,8 +74,7 @@  discard block
 block discarded – undo
77 74
      *
78 75
      * @return mixed The value out.
79 76
      */
80
-    public function get_value($value)
81
-    {
77
+    public function get_value($value) {
82 78
         return $this->get_string_from_value($value);
83 79
     }
84 80
 
@@ -91,8 +87,7 @@  discard block
 block discarded – undo
91 87
      *
92 88
      * @return string
93 89
      */
94
-    private function get_string_from_value($value)
95
-    {
90
+    private function get_string_from_value($value) {
96 91
         switch (intval($value)) {
97 92
             case self::NOT_FULFILLED:
98 93
             default:
@@ -120,8 +115,7 @@  discard block
 block discarded – undo
120 115
      *
121 116
      * @return string Original text if {is_fulfilled} isn't found. Otherwise, "Not Fulfilled" or "Fulfilled"
122 117
      */
123
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
124
-    {
118
+    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) {
125 119
         $return = $text;
126 120
 
127 121
         foreach ($matches as $match) {
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-section.php 3 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -8,48 +8,48 @@
 block discarded – undo
8 8
  */
9 9
 class GravityView_Field_Section extends GravityView_Field
10 10
 {
11
-    public $name = 'section';
11
+	public $name = 'section';
12 12
 
13
-    public $is_searchable = false;
13
+	public $is_searchable = false;
14 14
 
15
-    public $_gf_field_class_name = 'GF_Field_Section';
15
+	public $_gf_field_class_name = 'GF_Field_Section';
16 16
 
17
-    public $group = 'standard';
17
+	public $group = 'standard';
18 18
 
19
-    public $icon = 'dashicons-minus';
19
+	public $icon = 'dashicons-minus';
20 20
 
21
-    public function __construct()
22
-    {
23
-        $this->label = esc_html__('Section', 'gravityview');
21
+	public function __construct()
22
+	{
23
+		$this->label = esc_html__('Section', 'gravityview');
24 24
 
25
-        parent::__construct();
25
+		parent::__construct();
26 26
 
27
-        add_filter('gravityview_field_entry_value_section', [$this, 'prevent_empty_field']);
28
-    }
27
+		add_filter('gravityview_field_entry_value_section', [$this, 'prevent_empty_field']);
28
+	}
29 29
 
30
-    /**
31
-     * Prevent Sections from being hidden when "Hide Empty Fields" is checked in View settings.
32
-     *
33
-     * @since 1.15.1
34
-     *
35
-     * @param string $output Existing section field output
36
-     *
37
-     * @return string If output was empty, return an empty HTML comment tag. Otherwise, return output.
38
-     */
39
-    public function prevent_empty_field($output = '')
40
-    {
41
-        return empty($output) ? '<!-- -->' : $output;
42
-    }
30
+	/**
31
+	 * Prevent Sections from being hidden when "Hide Empty Fields" is checked in View settings.
32
+	 *
33
+	 * @since 1.15.1
34
+	 *
35
+	 * @param string $output Existing section field output
36
+	 *
37
+	 * @return string If output was empty, return an empty HTML comment tag. Otherwise, return output.
38
+	 */
39
+	public function prevent_empty_field($output = '')
40
+	{
41
+		return empty($output) ? '<!-- -->' : $output;
42
+	}
43 43
 
44
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
45
-    {
46
-        unset($field_options['search_filter'], $field_options['show_as_link']);
44
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
45
+	{
46
+		unset($field_options['search_filter'], $field_options['show_as_link']);
47 47
 
48
-        // Set the default CSS class to gv-section, which applies a border and top/bottom margin
49
-        $field_options['custom_class']['value'] = 'gv-section';
48
+		// Set the default CSS class to gv-section, which applies a border and top/bottom margin
49
+		$field_options['custom_class']['value'] = 'gv-section';
50 50
 
51
-        return $field_options;
52
-    }
51
+		return $field_options;
52
+	}
53 53
 }
54 54
 
55 55
 new GravityView_Field_Section();
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct()
22 22
     {
23
-        $this->label = esc_html__('Section', 'gravityview');
23
+        $this->label = esc_html__( 'Section', 'gravityview' );
24 24
 
25 25
         parent::__construct();
26 26
 
27
-        add_filter('gravityview_field_entry_value_section', [$this, 'prevent_empty_field']);
27
+        add_filter( 'gravityview_field_entry_value_section', [ $this, 'prevent_empty_field' ] );
28 28
     }
29 29
 
30 30
     /**
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @return string If output was empty, return an empty HTML comment tag. Otherwise, return output.
38 38
      */
39
-    public function prevent_empty_field($output = '')
39
+    public function prevent_empty_field( $output = '' )
40 40
     {
41
-        return empty($output) ? '<!-- -->' : $output;
41
+        return empty( $output ) ? '<!-- -->' : $output;
42 42
     }
43 43
 
44
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
44
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
45 45
     {
46
-        unset($field_options['search_filter'], $field_options['show_as_link']);
46
+        unset( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] );
47 47
 
48 48
         // Set the default CSS class to gv-section, which applies a border and top/bottom margin
49
-        $field_options['custom_class']['value'] = 'gv-section';
49
+        $field_options[ 'custom_class' ][ 'value' ] = 'gv-section';
50 50
 
51 51
         return $field_options;
52 52
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 /**
7 7
  * Add custom options for HTML field.
8 8
  */
9
-class GravityView_Field_Section extends GravityView_Field
10
-{
9
+class GravityView_Field_Section extends GravityView_Field {
11 10
     public $name = 'section';
12 11
 
13 12
     public $is_searchable = false;
@@ -18,8 +17,7 @@  discard block
 block discarded – undo
18 17
 
19 18
     public $icon = 'dashicons-minus';
20 19
 
21
-    public function __construct()
22
-    {
20
+    public function __construct() {
23 21
         $this->label = esc_html__('Section', 'gravityview');
24 22
 
25 23
         parent::__construct();
@@ -36,13 +34,11 @@  discard block
 block discarded – undo
36 34
      *
37 35
      * @return string If output was empty, return an empty HTML comment tag. Otherwise, return output.
38 36
      */
39
-    public function prevent_empty_field($output = '')
40
-    {
37
+    public function prevent_empty_field($output = '') {
41 38
         return empty($output) ? '<!-- -->' : $output;
42 39
     }
43 40
 
44
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
45
-    {
41
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
46 42
         unset($field_options['search_filter'], $field_options['show_as_link']);
47 43
 
48 44
         // Set the default CSS class to gv-section, which applies a border and top/bottom margin
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-html.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -8,30 +8,30 @@
 block discarded – undo
8 8
  */
9 9
 class GravityView_Field_HTML extends GravityView_Field
10 10
 {
11
-    public $name = 'html';
11
+	public $name = 'html';
12 12
 
13
-    public $is_searchable = false;
13
+	public $is_searchable = false;
14 14
 
15
-    public $is_sortable = false;
15
+	public $is_sortable = false;
16 16
 
17
-    public $_gf_field_class_name = 'GF_Field_HTML';
17
+	public $_gf_field_class_name = 'GF_Field_HTML';
18 18
 
19
-    public $group = 'standard';
19
+	public $group = 'standard';
20 20
 
21
-    public $icon = 'dashicons-media-code';
21
+	public $icon = 'dashicons-media-code';
22 22
 
23
-    public function __construct()
24
-    {
25
-        $this->label = esc_html__('HTML', 'gravityview');
26
-        parent::__construct();
27
-    }
23
+	public function __construct()
24
+	{
25
+		$this->label = esc_html__('HTML', 'gravityview');
26
+		parent::__construct();
27
+	}
28 28
 
29
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
30
-    {
31
-        unset($field_options['search_filter'], $field_options['show_as_link']);
29
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
30
+	{
31
+		unset($field_options['search_filter'], $field_options['show_as_link']);
32 32
 
33
-        return $field_options;
34
-    }
33
+		return $field_options;
34
+	}
35 35
 }
36 36
 
37 37
 new GravityView_Field_HTML();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@
 block discarded – undo
22 22
 
23 23
     public function __construct()
24 24
     {
25
-        $this->label = esc_html__('HTML', 'gravityview');
25
+        $this->label = esc_html__( 'HTML', 'gravityview' );
26 26
         parent::__construct();
27 27
     }
28 28
 
29
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
29
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
30 30
     {
31
-        unset($field_options['search_filter'], $field_options['show_as_link']);
31
+        unset( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] );
32 32
 
33 33
         return $field_options;
34 34
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 /**
7 7
  * Add custom options for HTML field.
8 8
  */
9
-class GravityView_Field_HTML extends GravityView_Field
10
-{
9
+class GravityView_Field_HTML extends GravityView_Field {
11 10
     public $name = 'html';
12 11
 
13 12
     public $is_searchable = false;
@@ -20,14 +19,12 @@  discard block
 block discarded – undo
20 19
 
21 20
     public $icon = 'dashicons-media-code';
22 21
 
23
-    public function __construct()
24
-    {
22
+    public function __construct() {
25 23
         $this->label = esc_html__('HTML', 'gravityview');
26 24
         parent::__construct();
27 25
     }
28 26
 
29
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
30
-    {
27
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
31 28
         unset($field_options['search_filter'], $field_options['show_as_link']);
32 29
 
33 30
         return $field_options;
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-sequence.php 3 patches
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -10,271 +10,271 @@
 block discarded – undo
10 10
  */
11 11
 class GravityView_Field_Sequence extends GravityView_Field
12 12
 {
13
-    public $name = 'sequence';
14
-
15
-    public $contexts = ['single', 'multiple'];
16
-
17
-    /**
18
-     * @var bool
19
-     */
20
-    public $is_sortable = false;
21
-
22
-    /**
23
-     * @var bool
24
-     */
25
-    public $is_searchable = false;
26
-
27
-    /**
28
-     * @var bool
29
-     */
30
-    public $is_numeric = true;
31
-
32
-    public $_custom_merge_tag = 'sequence';
33
-
34
-    public $group = 'gravityview';
35
-
36
-    public $icon = 'dashicons-editor-ol';
37
-
38
-    public function __construct()
39
-    {
40
-        $this->label = esc_html__('Number Sequence', 'gravityview');
41
-        $this->description = esc_html__('Display a sequential result number for each entry.', 'gravityview');
42
-
43
-        add_filter('gravityview/metaboxes/tooltips', [$this, 'field_tooltips']);
44
-
45
-        add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3);
46
-
47
-        parent::__construct();
48
-    }
49
-
50
-    /**
51
-     * Add as a default field, outside those set in the Gravity Form form.
52
-     *
53
-     * @since 2.10 Moved here from GravityView_Admin_Views::get_entry_default_fields
54
-     *
55
-     * @param array        $entry_default_fields Existing fields
56
-     * @param string|array $form                 form_ID or form object
57
-     * @param string       $zone                 Either 'single', 'directory', 'edit', 'header', 'footer'
58
-     *
59
-     * @return array
60
-     */
61
-    public function add_default_field($entry_default_fields, $form = [], $zone = '')
62
-    {
63
-        if ('edit' === $zone) {
64
-            return $entry_default_fields;
65
-        }
66
-
67
-        $entry_default_fields['sequence'] = [
68
-            'label' => __('Result Number', 'gravityview'),
69
-            'type'  => $this->name,
70
-            'desc'  => $this->description,
71
-            'icon'  => $this->icon,
72
-            'group' => 'gravityview',
73
-        ];
74
-
75
-        return $entry_default_fields;
76
-    }
77
-
78
-    /**
79
-     * Add tooltips.
80
-     *
81
-     * @param array $tooltips Existing tooltips
82
-     *
83
-     * @return array Modified tooltips
84
-     */
85
-    public function field_tooltips($tooltips)
86
-    {
87
-        $return = $tooltips;
88
-
89
-        $return['reverse_sequence'] = [
90
-            'title' => __('Reverse the order of the result numbers', 'gravityview'),
91
-            'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'),
92
-        ];
93
-
94
-        return $return;
95
-    }
96
-
97
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
98
-    {
99
-        unset($field_options['search_filter']);
100
-
101
-        $new_fields = [
102
-            'start' => [
103
-                'type'       => 'number',
104
-                'label'      => __('First Number in the Sequence', 'gravityview'),
105
-                'desc'       => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'),
106
-                'value'      => '1',
107
-                'merge_tags' => false,
108
-            ],
109
-            'reverse' => [
110
-                'type'    => 'checkbox',
111
-                'label'   => __('Reverse the order of the number sequence (high to low)', 'gravityview'),
112
-                'tooltip' => 'reverse_sequence',
113
-                'value'   => '',
114
-            ],
115
-        ];
116
-
117
-        return $new_fields + $field_options;
118
-    }
119
-
120
-    /**
121
-     * Replace {sequence} Merge Tags inside Custom Content fields.
122
-     *
123
-     * TODO:
124
-     * - Find a better way to infer current View data (without using legacy code)
125
-     *
126
-     * @param array  $matches
127
-     * @param string $text
128
-     * @param array  $form
129
-     * @param array  $entry
130
-     * @param bool   $url_encode
131
-     * @param bool   $esc_html
132
-     *
133
-     * @return string
134
-     */
135
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
136
-    {
137
-        /**
138
-         * An internal cache for sequence tag reuse within one field.
139
-         * Avoids calling get_sequence over and over again, off-by-many increments, etc.
140
-         */
141
-        static $merge_tag_sequences = [];
142
-
143
-        $view_data = gravityview_get_current_view_data(); // TODO: Don't use legacy code...
144
-
145
-        // If we're not in a View or embed, don't replace the merge tag
146
-        if (empty($view_data)) {
147
-            gravityview()->log->error('{sequence} Merge Tag used outside of a GravityView View.', ['data' => $matches]);
148
-
149
-            return $text;
150
-        }
151
-
152
-        $legacy_field = \GravityView_View::getInstance()->getCurrentField(); // TODO: Don't use legacy code...
153
-
154
-        // If we're outside field context (like a GV widget), don't replace the merge tag
155
-        if (!$legacy_field) {
156
-            gravityview()->log->error('{sequence} Merge Tag was used without outside of the GravityView entry loop.', ['data' => $matches]);
157
-
158
-            return $text;
159
-        }
160
-
161
-        $return = $text;
162
-
163
-        $context = new \GV\Template_Context();
164
-        $context->view = \GV\View::by_id($view_data['view_id']);
165
-        $context->entry = \GV\GF_Entry::from_entry($entry);
166
-
167
-        $gv_field = \GV\Internal_Field::by_id('sequence');
168
-        $merge_tag_context = \GV\Utils::get($legacy_field, 'UID');
169
-        $merge_tag_context = $entry['id']."/{$merge_tag_context}";
170
-
171
-        foreach ($matches as $match) {
172
-            $full_tag = $match[0];
173
-            $property = $match[1];
174
-
175
-            $gv_field->reverse = false;
176
-            $gv_field->start = 1;
177
-
178
-            $modifiers = explode(',', trim($property));
179
-
180
-            foreach ($modifiers as $modifier) {
181
-                $modifier = trim($modifier);
182
-
183
-                if ('reverse' === $modifier) {
184
-                    $gv_field->reverse = true;
185
-                }
186
-
187
-                $maybe_start = explode(':', $modifier);
188
-
189
-                // If there is a field with the ID of the start number, the merge tag won't work.
190
-                // In that case, you can use "=" instead: `{sequence start=10}`
191
-                if (1 === sizeof($maybe_start)) {
192
-                    $maybe_start = explode('=', $modifier);
193
-                }
194
-
195
-                if ('start' === rgar($maybe_start, 0) && is_numeric(rgar($maybe_start, 1))) {
196
-                    $gv_field->start = (int) rgar($maybe_start, 1);
197
-                }
198
-            }
199
-
200
-            /**
201
-             * We make sure that distinct sequence modifiers have their own
202
-             * output counters.
203
-             */
204
-            $merge_tag_context_modifiers = $merge_tag_context.'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
205
-
206
-            if (!isset($merge_tag_sequences[$merge_tag_context_modifiers])) {
207
-                $gv_field->UID = $legacy_field['UID'].'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
208
-                $context->field = $gv_field;
209
-                $sequence = $merge_tag_sequences[$merge_tag_context_modifiers] = $this->get_sequence($context);
210
-            } else {
211
-                $sequence = $merge_tag_sequences[$merge_tag_context_modifiers];
212
-            }
213
-
214
-            $return = str_replace($full_tag, $sequence, $return);
215
-        }
216
-
217
-        return $return;
218
-    }
219
-
220
-    /**
221
-     * Calculate the current sequence number for the context.
222
-     *
223
-     * @param \GV\Template_Context $context The context.
224
-     *
225
-     * @return int The sequence number for the field/entry within the view results.
226
-     */
227
-    public function get_sequence($context)
228
-    {
229
-        static $startlines = [];
230
-
231
-        $context_key = md5(json_encode(
232
-            [
233
-                $context->view->ID,
234
-                \GV\Utils::get($context, 'field/UID'),
235
-            ]
236
-        ));
237
-
238
-        /**
239
-         * Figure out the starting number.
240
-         */
241
-        if ($context->request && $entry = $context->request->is_entry()) {
242
-            $sql_query = [];
243
-
244
-            add_filter('gform_gf_query_sql', $callback = function ($sql) use (&$sql_query) {
245
-                $sql_query = $sql;
246
-
247
-                return $sql;
248
-            });
249
-
250
-            $total = $context->view->get_entries()->total();
251
-            remove_filter('gform_gf_query_sql', $callback);
252
-
253
-            unset($sql_query['paginate']);
254
-
255
-            global $wpdb;
256
-
257
-            foreach ($wpdb->get_results(implode(' ', $sql_query), ARRAY_A) as $n => $result) {
258
-                if (in_array($entry->ID, $result)) {
259
-                    return $context->field->reverse ? ($total - $n) : ($n + 1);
260
-                }
261
-            }
262
-
263
-            return 0;
264
-        } elseif (!isset($startlines[$context_key])) {
265
-            $pagenum = max(0, \GV\Utils::_GET('pagenum', 1) - 1);
266
-            $pagesize = $context->view->settings->get('page_size', 25);
267
-
268
-            if ($context->field->reverse) {
269
-                $startlines[$context_key] = $context->view->get_entries()->total() - ($pagenum * $pagesize);
270
-                $startlines[$context_key] += $context->field->start - 1;
271
-            } else {
272
-                $startlines[$context_key] = ($pagenum * $pagesize) + $context->field->start;
273
-            }
274
-        }
275
-
276
-        return $context->field->reverse ? $startlines[$context_key]-- : $startlines[$context_key]++;
277
-    }
13
+	public $name = 'sequence';
14
+
15
+	public $contexts = ['single', 'multiple'];
16
+
17
+	/**
18
+	 * @var bool
19
+	 */
20
+	public $is_sortable = false;
21
+
22
+	/**
23
+	 * @var bool
24
+	 */
25
+	public $is_searchable = false;
26
+
27
+	/**
28
+	 * @var bool
29
+	 */
30
+	public $is_numeric = true;
31
+
32
+	public $_custom_merge_tag = 'sequence';
33
+
34
+	public $group = 'gravityview';
35
+
36
+	public $icon = 'dashicons-editor-ol';
37
+
38
+	public function __construct()
39
+	{
40
+		$this->label = esc_html__('Number Sequence', 'gravityview');
41
+		$this->description = esc_html__('Display a sequential result number for each entry.', 'gravityview');
42
+
43
+		add_filter('gravityview/metaboxes/tooltips', [$this, 'field_tooltips']);
44
+
45
+		add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3);
46
+
47
+		parent::__construct();
48
+	}
49
+
50
+	/**
51
+	 * Add as a default field, outside those set in the Gravity Form form.
52
+	 *
53
+	 * @since 2.10 Moved here from GravityView_Admin_Views::get_entry_default_fields
54
+	 *
55
+	 * @param array        $entry_default_fields Existing fields
56
+	 * @param string|array $form                 form_ID or form object
57
+	 * @param string       $zone                 Either 'single', 'directory', 'edit', 'header', 'footer'
58
+	 *
59
+	 * @return array
60
+	 */
61
+	public function add_default_field($entry_default_fields, $form = [], $zone = '')
62
+	{
63
+		if ('edit' === $zone) {
64
+			return $entry_default_fields;
65
+		}
66
+
67
+		$entry_default_fields['sequence'] = [
68
+			'label' => __('Result Number', 'gravityview'),
69
+			'type'  => $this->name,
70
+			'desc'  => $this->description,
71
+			'icon'  => $this->icon,
72
+			'group' => 'gravityview',
73
+		];
74
+
75
+		return $entry_default_fields;
76
+	}
77
+
78
+	/**
79
+	 * Add tooltips.
80
+	 *
81
+	 * @param array $tooltips Existing tooltips
82
+	 *
83
+	 * @return array Modified tooltips
84
+	 */
85
+	public function field_tooltips($tooltips)
86
+	{
87
+		$return = $tooltips;
88
+
89
+		$return['reverse_sequence'] = [
90
+			'title' => __('Reverse the order of the result numbers', 'gravityview'),
91
+			'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'),
92
+		];
93
+
94
+		return $return;
95
+	}
96
+
97
+	public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
98
+	{
99
+		unset($field_options['search_filter']);
100
+
101
+		$new_fields = [
102
+			'start' => [
103
+				'type'       => 'number',
104
+				'label'      => __('First Number in the Sequence', 'gravityview'),
105
+				'desc'       => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'),
106
+				'value'      => '1',
107
+				'merge_tags' => false,
108
+			],
109
+			'reverse' => [
110
+				'type'    => 'checkbox',
111
+				'label'   => __('Reverse the order of the number sequence (high to low)', 'gravityview'),
112
+				'tooltip' => 'reverse_sequence',
113
+				'value'   => '',
114
+			],
115
+		];
116
+
117
+		return $new_fields + $field_options;
118
+	}
119
+
120
+	/**
121
+	 * Replace {sequence} Merge Tags inside Custom Content fields.
122
+	 *
123
+	 * TODO:
124
+	 * - Find a better way to infer current View data (without using legacy code)
125
+	 *
126
+	 * @param array  $matches
127
+	 * @param string $text
128
+	 * @param array  $form
129
+	 * @param array  $entry
130
+	 * @param bool   $url_encode
131
+	 * @param bool   $esc_html
132
+	 *
133
+	 * @return string
134
+	 */
135
+	public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
136
+	{
137
+		/**
138
+		 * An internal cache for sequence tag reuse within one field.
139
+		 * Avoids calling get_sequence over and over again, off-by-many increments, etc.
140
+		 */
141
+		static $merge_tag_sequences = [];
142
+
143
+		$view_data = gravityview_get_current_view_data(); // TODO: Don't use legacy code...
144
+
145
+		// If we're not in a View or embed, don't replace the merge tag
146
+		if (empty($view_data)) {
147
+			gravityview()->log->error('{sequence} Merge Tag used outside of a GravityView View.', ['data' => $matches]);
148
+
149
+			return $text;
150
+		}
151
+
152
+		$legacy_field = \GravityView_View::getInstance()->getCurrentField(); // TODO: Don't use legacy code...
153
+
154
+		// If we're outside field context (like a GV widget), don't replace the merge tag
155
+		if (!$legacy_field) {
156
+			gravityview()->log->error('{sequence} Merge Tag was used without outside of the GravityView entry loop.', ['data' => $matches]);
157
+
158
+			return $text;
159
+		}
160
+
161
+		$return = $text;
162
+
163
+		$context = new \GV\Template_Context();
164
+		$context->view = \GV\View::by_id($view_data['view_id']);
165
+		$context->entry = \GV\GF_Entry::from_entry($entry);
166
+
167
+		$gv_field = \GV\Internal_Field::by_id('sequence');
168
+		$merge_tag_context = \GV\Utils::get($legacy_field, 'UID');
169
+		$merge_tag_context = $entry['id']."/{$merge_tag_context}";
170
+
171
+		foreach ($matches as $match) {
172
+			$full_tag = $match[0];
173
+			$property = $match[1];
174
+
175
+			$gv_field->reverse = false;
176
+			$gv_field->start = 1;
177
+
178
+			$modifiers = explode(',', trim($property));
179
+
180
+			foreach ($modifiers as $modifier) {
181
+				$modifier = trim($modifier);
182
+
183
+				if ('reverse' === $modifier) {
184
+					$gv_field->reverse = true;
185
+				}
186
+
187
+				$maybe_start = explode(':', $modifier);
188
+
189
+				// If there is a field with the ID of the start number, the merge tag won't work.
190
+				// In that case, you can use "=" instead: `{sequence start=10}`
191
+				if (1 === sizeof($maybe_start)) {
192
+					$maybe_start = explode('=', $modifier);
193
+				}
194
+
195
+				if ('start' === rgar($maybe_start, 0) && is_numeric(rgar($maybe_start, 1))) {
196
+					$gv_field->start = (int) rgar($maybe_start, 1);
197
+				}
198
+			}
199
+
200
+			/**
201
+			 * We make sure that distinct sequence modifiers have their own
202
+			 * output counters.
203
+			 */
204
+			$merge_tag_context_modifiers = $merge_tag_context.'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
205
+
206
+			if (!isset($merge_tag_sequences[$merge_tag_context_modifiers])) {
207
+				$gv_field->UID = $legacy_field['UID'].'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
208
+				$context->field = $gv_field;
209
+				$sequence = $merge_tag_sequences[$merge_tag_context_modifiers] = $this->get_sequence($context);
210
+			} else {
211
+				$sequence = $merge_tag_sequences[$merge_tag_context_modifiers];
212
+			}
213
+
214
+			$return = str_replace($full_tag, $sequence, $return);
215
+		}
216
+
217
+		return $return;
218
+	}
219
+
220
+	/**
221
+	 * Calculate the current sequence number for the context.
222
+	 *
223
+	 * @param \GV\Template_Context $context The context.
224
+	 *
225
+	 * @return int The sequence number for the field/entry within the view results.
226
+	 */
227
+	public function get_sequence($context)
228
+	{
229
+		static $startlines = [];
230
+
231
+		$context_key = md5(json_encode(
232
+			[
233
+				$context->view->ID,
234
+				\GV\Utils::get($context, 'field/UID'),
235
+			]
236
+		));
237
+
238
+		/**
239
+		 * Figure out the starting number.
240
+		 */
241
+		if ($context->request && $entry = $context->request->is_entry()) {
242
+			$sql_query = [];
243
+
244
+			add_filter('gform_gf_query_sql', $callback = function ($sql) use (&$sql_query) {
245
+				$sql_query = $sql;
246
+
247
+				return $sql;
248
+			});
249
+
250
+			$total = $context->view->get_entries()->total();
251
+			remove_filter('gform_gf_query_sql', $callback);
252
+
253
+			unset($sql_query['paginate']);
254
+
255
+			global $wpdb;
256
+
257
+			foreach ($wpdb->get_results(implode(' ', $sql_query), ARRAY_A) as $n => $result) {
258
+				if (in_array($entry->ID, $result)) {
259
+					return $context->field->reverse ? ($total - $n) : ($n + 1);
260
+				}
261
+			}
262
+
263
+			return 0;
264
+		} elseif (!isset($startlines[$context_key])) {
265
+			$pagenum = max(0, \GV\Utils::_GET('pagenum', 1) - 1);
266
+			$pagesize = $context->view->settings->get('page_size', 25);
267
+
268
+			if ($context->field->reverse) {
269
+				$startlines[$context_key] = $context->view->get_entries()->total() - ($pagenum * $pagesize);
270
+				$startlines[$context_key] += $context->field->start - 1;
271
+			} else {
272
+				$startlines[$context_key] = ($pagenum * $pagesize) + $context->field->start;
273
+			}
274
+		}
275
+
276
+		return $context->field->reverse ? $startlines[$context_key]-- : $startlines[$context_key]++;
277
+	}
278 278
 }
279 279
 
280 280
 new GravityView_Field_Sequence();
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 {
13 13
     public $name = 'sequence';
14 14
 
15
-    public $contexts = ['single', 'multiple'];
15
+    public $contexts = [ 'single', 'multiple' ];
16 16
 
17 17
     /**
18 18
      * @var bool
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 
38 38
     public function __construct()
39 39
     {
40
-        $this->label = esc_html__('Number Sequence', 'gravityview');
41
-        $this->description = esc_html__('Display a sequential result number for each entry.', 'gravityview');
40
+        $this->label = esc_html__( 'Number Sequence', 'gravityview' );
41
+        $this->description = esc_html__( 'Display a sequential result number for each entry.', 'gravityview' );
42 42
 
43
-        add_filter('gravityview/metaboxes/tooltips', [$this, 'field_tooltips']);
43
+        add_filter( 'gravityview/metaboxes/tooltips', [ $this, 'field_tooltips' ] );
44 44
 
45
-        add_filter('gravityview_entry_default_fields', [$this, 'add_default_field'], 10, 3);
45
+        add_filter( 'gravityview_entry_default_fields', [ $this, 'add_default_field' ], 10, 3 );
46 46
 
47 47
         parent::__construct();
48 48
     }
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return array
60 60
      */
61
-    public function add_default_field($entry_default_fields, $form = [], $zone = '')
61
+    public function add_default_field( $entry_default_fields, $form = [ ], $zone = '' )
62 62
     {
63
-        if ('edit' === $zone) {
63
+        if ( 'edit' === $zone ) {
64 64
             return $entry_default_fields;
65 65
         }
66 66
 
67
-        $entry_default_fields['sequence'] = [
68
-            'label' => __('Result Number', 'gravityview'),
67
+        $entry_default_fields[ 'sequence' ] = [
68
+            'label' => __( 'Result Number', 'gravityview' ),
69 69
             'type'  => $this->name,
70 70
             'desc'  => $this->description,
71 71
             'icon'  => $this->icon,
@@ -82,33 +82,33 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return array Modified tooltips
84 84
      */
85
-    public function field_tooltips($tooltips)
85
+    public function field_tooltips( $tooltips )
86 86
     {
87 87
         $return = $tooltips;
88 88
 
89
-        $return['reverse_sequence'] = [
90
-            'title' => __('Reverse the order of the result numbers', 'gravityview'),
91
-            'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'),
89
+        $return[ 'reverse_sequence' ] = [
90
+            'title' => __( 'Reverse the order of the result numbers', 'gravityview' ),
91
+            'value' => __( 'Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview' ),
92 92
         ];
93 93
 
94 94
         return $return;
95 95
     }
96 96
 
97
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
97
+    public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id )
98 98
     {
99
-        unset($field_options['search_filter']);
99
+        unset( $field_options[ 'search_filter' ] );
100 100
 
101 101
         $new_fields = [
102 102
             'start' => [
103 103
                 'type'       => 'number',
104
-                'label'      => __('First Number in the Sequence', 'gravityview'),
105
-                'desc'       => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'),
104
+                'label'      => __( 'First Number in the Sequence', 'gravityview' ),
105
+                'desc'       => __( 'For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview' ),
106 106
                 'value'      => '1',
107 107
                 'merge_tags' => false,
108 108
             ],
109 109
             'reverse' => [
110 110
                 'type'    => 'checkbox',
111
-                'label'   => __('Reverse the order of the number sequence (high to low)', 'gravityview'),
111
+                'label'   => __( 'Reverse the order of the number sequence (high to low)', 'gravityview' ),
112 112
                 'tooltip' => 'reverse_sequence',
113 113
                 'value'   => '',
114 114
             ],
@@ -132,19 +132,19 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return string
134 134
      */
135
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
135
+    public function replace_merge_tag( $matches = [ ], $text = '', $form = [ ], $entry = [ ], $url_encode = false, $esc_html = false )
136 136
     {
137 137
         /**
138 138
          * An internal cache for sequence tag reuse within one field.
139 139
          * Avoids calling get_sequence over and over again, off-by-many increments, etc.
140 140
          */
141
-        static $merge_tag_sequences = [];
141
+        static $merge_tag_sequences = [ ];
142 142
 
143 143
         $view_data = gravityview_get_current_view_data(); // TODO: Don't use legacy code...
144 144
 
145 145
         // If we're not in a View or embed, don't replace the merge tag
146
-        if (empty($view_data)) {
147
-            gravityview()->log->error('{sequence} Merge Tag used outside of a GravityView View.', ['data' => $matches]);
146
+        if ( empty( $view_data ) ) {
147
+            gravityview()->log->error( '{sequence} Merge Tag used outside of a GravityView View.', [ 'data' => $matches ] );
148 148
 
149 149
             return $text;
150 150
         }
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
         $legacy_field = \GravityView_View::getInstance()->getCurrentField(); // TODO: Don't use legacy code...
153 153
 
154 154
         // If we're outside field context (like a GV widget), don't replace the merge tag
155
-        if (!$legacy_field) {
156
-            gravityview()->log->error('{sequence} Merge Tag was used without outside of the GravityView entry loop.', ['data' => $matches]);
155
+        if ( ! $legacy_field ) {
156
+            gravityview()->log->error( '{sequence} Merge Tag was used without outside of the GravityView entry loop.', [ 'data' => $matches ] );
157 157
 
158 158
             return $text;
159 159
         }
@@ -161,39 +161,39 @@  discard block
 block discarded – undo
161 161
         $return = $text;
162 162
 
163 163
         $context = new \GV\Template_Context();
164
-        $context->view = \GV\View::by_id($view_data['view_id']);
165
-        $context->entry = \GV\GF_Entry::from_entry($entry);
164
+        $context->view = \GV\View::by_id( $view_data[ 'view_id' ] );
165
+        $context->entry = \GV\GF_Entry::from_entry( $entry );
166 166
 
167
-        $gv_field = \GV\Internal_Field::by_id('sequence');
168
-        $merge_tag_context = \GV\Utils::get($legacy_field, 'UID');
169
-        $merge_tag_context = $entry['id']."/{$merge_tag_context}";
167
+        $gv_field = \GV\Internal_Field::by_id( 'sequence' );
168
+        $merge_tag_context = \GV\Utils::get( $legacy_field, 'UID' );
169
+        $merge_tag_context = $entry[ 'id' ] . "/{$merge_tag_context}";
170 170
 
171
-        foreach ($matches as $match) {
172
-            $full_tag = $match[0];
173
-            $property = $match[1];
171
+        foreach ( $matches as $match ) {
172
+            $full_tag = $match[ 0 ];
173
+            $property = $match[ 1 ];
174 174
 
175 175
             $gv_field->reverse = false;
176 176
             $gv_field->start = 1;
177 177
 
178
-            $modifiers = explode(',', trim($property));
178
+            $modifiers = explode( ',', trim( $property ) );
179 179
 
180
-            foreach ($modifiers as $modifier) {
181
-                $modifier = trim($modifier);
180
+            foreach ( $modifiers as $modifier ) {
181
+                $modifier = trim( $modifier );
182 182
 
183
-                if ('reverse' === $modifier) {
183
+                if ( 'reverse' === $modifier ) {
184 184
                     $gv_field->reverse = true;
185 185
                 }
186 186
 
187
-                $maybe_start = explode(':', $modifier);
187
+                $maybe_start = explode( ':', $modifier );
188 188
 
189 189
                 // If there is a field with the ID of the start number, the merge tag won't work.
190 190
                 // In that case, you can use "=" instead: `{sequence start=10}`
191
-                if (1 === sizeof($maybe_start)) {
192
-                    $maybe_start = explode('=', $modifier);
191
+                if ( 1 === sizeof( $maybe_start ) ) {
192
+                    $maybe_start = explode( '=', $modifier );
193 193
                 }
194 194
 
195
-                if ('start' === rgar($maybe_start, 0) && is_numeric(rgar($maybe_start, 1))) {
196
-                    $gv_field->start = (int) rgar($maybe_start, 1);
195
+                if ( 'start' === rgar( $maybe_start, 0 ) && is_numeric( rgar( $maybe_start, 1 ) ) ) {
196
+                    $gv_field->start = (int)rgar( $maybe_start, 1 );
197 197
                 }
198 198
             }
199 199
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
              * We make sure that distinct sequence modifiers have their own
202 202
              * output counters.
203 203
              */
204
-            $merge_tag_context_modifiers = $merge_tag_context.'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
204
+            $merge_tag_context_modifiers = $merge_tag_context . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start;
205 205
 
206
-            if (!isset($merge_tag_sequences[$merge_tag_context_modifiers])) {
207
-                $gv_field->UID = $legacy_field['UID'].'/'.var_export($gv_field->reverse, true).'/'.$gv_field->start;
206
+            if ( ! isset( $merge_tag_sequences[ $merge_tag_context_modifiers ] ) ) {
207
+                $gv_field->UID = $legacy_field[ 'UID' ] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start;
208 208
                 $context->field = $gv_field;
209
-                $sequence = $merge_tag_sequences[$merge_tag_context_modifiers] = $this->get_sequence($context);
209
+                $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context );
210 210
             } else {
211
-                $sequence = $merge_tag_sequences[$merge_tag_context_modifiers];
211
+                $sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ];
212 212
             }
213 213
 
214
-            $return = str_replace($full_tag, $sequence, $return);
214
+            $return = str_replace( $full_tag, $sequence, $return );
215 215
         }
216 216
 
217 217
         return $return;
@@ -224,56 +224,56 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @return int The sequence number for the field/entry within the view results.
226 226
      */
227
-    public function get_sequence($context)
227
+    public function get_sequence( $context )
228 228
     {
229
-        static $startlines = [];
229
+        static $startlines = [ ];
230 230
 
231
-        $context_key = md5(json_encode(
231
+        $context_key = md5( json_encode(
232 232
             [
233 233
                 $context->view->ID,
234
-                \GV\Utils::get($context, 'field/UID'),
234
+                \GV\Utils::get( $context, 'field/UID' ),
235 235
             ]
236
-        ));
236
+        ) );
237 237
 
238 238
         /**
239 239
          * Figure out the starting number.
240 240
          */
241
-        if ($context->request && $entry = $context->request->is_entry()) {
242
-            $sql_query = [];
241
+        if ( $context->request && $entry = $context->request->is_entry() ) {
242
+            $sql_query = [ ];
243 243
 
244
-            add_filter('gform_gf_query_sql', $callback = function ($sql) use (&$sql_query) {
244
+            add_filter( 'gform_gf_query_sql', $callback = function( $sql ) use ( &$sql_query ) {
245 245
                 $sql_query = $sql;
246 246
 
247 247
                 return $sql;
248 248
             });
249 249
 
250 250
             $total = $context->view->get_entries()->total();
251
-            remove_filter('gform_gf_query_sql', $callback);
251
+            remove_filter( 'gform_gf_query_sql', $callback );
252 252
 
253
-            unset($sql_query['paginate']);
253
+            unset( $sql_query[ 'paginate' ] );
254 254
 
255 255
             global $wpdb;
256 256
 
257
-            foreach ($wpdb->get_results(implode(' ', $sql_query), ARRAY_A) as $n => $result) {
258
-                if (in_array($entry->ID, $result)) {
259
-                    return $context->field->reverse ? ($total - $n) : ($n + 1);
257
+            foreach ( $wpdb->get_results( implode( ' ', $sql_query ), ARRAY_A ) as $n => $result ) {
258
+                if ( in_array( $entry->ID, $result ) ) {
259
+                    return $context->field->reverse ? ( $total - $n ) : ( $n + 1 );
260 260
                 }
261 261
             }
262 262
 
263 263
             return 0;
264
-        } elseif (!isset($startlines[$context_key])) {
265
-            $pagenum = max(0, \GV\Utils::_GET('pagenum', 1) - 1);
266
-            $pagesize = $context->view->settings->get('page_size', 25);
264
+        } elseif ( ! isset( $startlines[ $context_key ] ) ) {
265
+            $pagenum = max( 0, \GV\Utils::_GET( 'pagenum', 1 ) - 1 );
266
+            $pagesize = $context->view->settings->get( 'page_size', 25 );
267 267
 
268
-            if ($context->field->reverse) {
269
-                $startlines[$context_key] = $context->view->get_entries()->total() - ($pagenum * $pagesize);
270
-                $startlines[$context_key] += $context->field->start - 1;
268
+            if ( $context->field->reverse ) {
269
+                $startlines[ $context_key ] = $context->view->get_entries()->total() - ( $pagenum * $pagesize );
270
+                $startlines[ $context_key ] += $context->field->start - 1;
271 271
             } else {
272
-                $startlines[$context_key] = ($pagenum * $pagesize) + $context->field->start;
272
+                $startlines[ $context_key ] = ( $pagenum * $pagesize ) + $context->field->start;
273 273
             }
274 274
         }
275 275
 
276
-        return $context->field->reverse ? $startlines[$context_key]-- : $startlines[$context_key]++;
276
+        return $context->field->reverse ? $startlines[ $context_key ]-- : $startlines[ $context_key ]++;
277 277
     }
278 278
 }
279 279
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  * @since 2.3.3
10 10
  */
11
-class GravityView_Field_Sequence extends GravityView_Field
12
-{
11
+class GravityView_Field_Sequence extends GravityView_Field {
13 12
     public $name = 'sequence';
14 13
 
15 14
     public $contexts = ['single', 'multiple'];
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
 
36 35
     public $icon = 'dashicons-editor-ol';
37 36
 
38
-    public function __construct()
39
-    {
37
+    public function __construct() {
40 38
         $this->label = esc_html__('Number Sequence', 'gravityview');
41 39
         $this->description = esc_html__('Display a sequential result number for each entry.', 'gravityview');
42 40
 
@@ -58,8 +56,7 @@  discard block
 block discarded – undo
58 56
      *
59 57
      * @return array
60 58
      */
61
-    public function add_default_field($entry_default_fields, $form = [], $zone = '')
62
-    {
59
+    public function add_default_field($entry_default_fields, $form = [], $zone = '') {
63 60
         if ('edit' === $zone) {
64 61
             return $entry_default_fields;
65 62
         }
@@ -82,8 +79,7 @@  discard block
 block discarded – undo
82 79
      *
83 80
      * @return array Modified tooltips
84 81
      */
85
-    public function field_tooltips($tooltips)
86
-    {
82
+    public function field_tooltips($tooltips) {
87 83
         $return = $tooltips;
88 84
 
89 85
         $return['reverse_sequence'] = [
@@ -94,8 +90,7 @@  discard block
 block discarded – undo
94 90
         return $return;
95 91
     }
96 92
 
97
-    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id)
98
-    {
93
+    public function field_options($field_options, $template_id, $field_id, $context, $input_type, $form_id) {
99 94
         unset($field_options['search_filter']);
100 95
 
101 96
         $new_fields = [
@@ -132,8 +127,7 @@  discard block
 block discarded – undo
132 127
      *
133 128
      * @return string
134 129
      */
135
-    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false)
136
-    {
130
+    public function replace_merge_tag($matches = [], $text = '', $form = [], $entry = [], $url_encode = false, $esc_html = false) {
137 131
         /**
138 132
          * An internal cache for sequence tag reuse within one field.
139 133
          * Avoids calling get_sequence over and over again, off-by-many increments, etc.
@@ -224,8 +218,7 @@  discard block
 block discarded – undo
224 218
      *
225 219
      * @return int The sequence number for the field/entry within the view results.
226 220
      */
227
-    public function get_sequence($context)
228
-    {
221
+    public function get_sequence($context) {
229 222
         static $startlines = [];
230 223
 
231 224
         $context_key = md5(json_encode(
Please login to merge, or discard this patch.