Completed
Pull Request — master (#836)
by
unknown
08:57 queued 05:20
created
includes/extensions/edit-entry/class-edit-entry-admin.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,6 @@
 block discarded – undo
69 69
      * Change wording for the Edit context to read Entry Creator
70 70
      *
71 71
      * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73 72
      * @param  string      $template_id Table slug
74 73
      * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75 74
      * @param  string      $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -10,175 +10,175 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 if ( ! defined( 'WPINC' ) ) {
13
-    die;
13
+	die;
14 14
 }
15 15
 
16 16
 
17 17
 class GravityView_Edit_Entry_Admin {
18 18
 
19
-    protected $loader;
19
+	protected $loader;
20 20
 
21
-    function __construct( GravityView_Edit_Entry $loader ) {
22
-        $this->loader = $loader;
23
-    }
21
+	function __construct( GravityView_Edit_Entry $loader ) {
22
+		$this->loader = $loader;
23
+	}
24 24
 
25
-    function load() {
26
-
27
-        if( !is_admin() ) {
28
-            return;
29
-        }
30
-
31
-        // Add Edit Link as a default field, outside those set in the Gravity Form form
32
-        add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
-
34
-        // For the Edit Entry Link, you don't want visible to all users.
35
-        add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
25
+	function load() {
26
+
27
+		if( !is_admin() ) {
28
+			return;
29
+		}
30
+
31
+		// Add Edit Link as a default field, outside those set in the Gravity Form form
32
+		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
33
+
34
+		// For the Edit Entry Link, you don't want visible to all users.
35
+		add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 );
36 36
 
37
-        // Modify the field options based on the name of the field type
38
-        add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
37
+		// Modify the field options based on the name of the field type
38
+		add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40
-        // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
-
43
-        // custom fields' options for zone EDIT
44
-        add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
-    }
46
-
47
-    /**
48
-     * Add Edit Link as a default field, outside those set in the Gravity Form form
49
-     * @param array $entry_default_fields Existing fields
50
-     * @param  string|array $form form_ID or form object
51
-     * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
-     */
53
-    function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
-
55
-        if( $zone !== 'edit' ) {
56
-
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
59
-                'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
-            );
62
-
63
-        }
64
-
65
-        return $entry_default_fields;
66
-    }
67
-
68
-    /**
69
-     * Change wording for the Edit context to read Entry Creator
70
-     *
71
-     * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
-     * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
-     * @param  string      $template_id Table slug
74
-     * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
-     * @param  string      $context     What context are we in? Example: `single` or `directory`
76
-     * @param  string      $input_type  (textarea, list, select, etc.)
77
-     * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
-     */
79
-    function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
-
81
-        $caps = $visibility_caps;
82
-
83
-        // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
85
-
86
-            // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
-
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
-        }
91
-
92
-        return $caps;
93
-    }
94
-
95
-    /**
96
-     * Add "Edit Link Text" setting to the edit_link field settings
97
-     * @param  [type] $field_options [description]
98
-     * @param  [type] $template_id   [description]
99
-     * @param  [type] $field_id      [description]
100
-     * @param  [type] $context       [description]
101
-     * @param  [type] $input_type    [description]
102
-     * @return [type]                [description]
103
-     */
104
-    function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
-
106
-        // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
-
109
-        // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
-
112
-        $add_option['edit_link'] = array(
113
-            'type' => 'text',
114
-            'label' => __( 'Edit Link Text', 'gravityview' ),
115
-            'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
117
-            'merge_tags' => true,
118
-        );
119
-
120
-        return array_merge( $add_option, $field_options );
121
-    }
122
-
123
-    /**
124
-     * Add tooltips
125
-     * @param  array $tooltips Existing tooltips
126
-     * @return array           Modified tooltips
127
-     */
128
-    function tooltips( $tooltips ) {
129
-
130
-        $return = $tooltips;
131
-
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
-        );
136
-
137
-        return $return;
138
-    }
139
-
140
-    /**
141
-     * Manipulate the fields' options for the EDIT ENTRY screen
142
-     * @param  [type] $field_options [description]
143
-     * @param  [type] $template_id   [description]
144
-     * @param  [type] $field_id      [description]
145
-     * @param  [type] $context       [description]
146
-     * @param  [type] $input_type    [description]
147
-     * @return [type]                [description]
148
-     */
149
-    function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
-
151
-        // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
153
-
154
-            /**
155
-             * @since 1.8.4
156
-             */
157
-            $field_options['new_window'] = array(
158
-                'type' => 'checkbox',
159
-                'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
-                'value' => false,
161
-            );
162
-
163
-            return $field_options;
164
-        }
165
-
166
-        //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
-
169
-        $add_options = array(
170
-            'allow_edit_cap' => array(
171
-                'type' => 'select',
172
-                'label' => __( 'Make field editable to:', 'gravityview' ),
173
-                'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
-                'tooltip' => 'allow_edit_cap',
175
-                'class' => 'widefat',
176
-                'value' => 'read', // Default: entry creator
177
-            ),
178
-        );
179
-
180
-        return array_merge( $field_options, $add_options );
181
-    }
40
+		// add tooltips
41
+		add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
42
+
43
+		// custom fields' options for zone EDIT
44
+		add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
45
+	}
46
+
47
+	/**
48
+	 * Add Edit Link as a default field, outside those set in the Gravity Form form
49
+	 * @param array $entry_default_fields Existing fields
50
+	 * @param  string|array $form form_ID or form object
51
+	 * @param  string $zone   Either 'single', 'directory', 'header', 'footer'
52
+	 */
53
+	function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54
+
55
+		if( $zone !== 'edit' ) {
56
+
57
+			$entry_default_fields['edit_link'] = array(
58
+				'label' => __('Edit Entry', 'gravityview'),
59
+				'type' => 'edit_link',
60
+				'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
61
+			);
62
+
63
+		}
64
+
65
+		return $entry_default_fields;
66
+	}
67
+
68
+	/**
69
+	 * Change wording for the Edit context to read Entry Creator
70
+	 *
71
+	 * @param  array 	   $visibility_caps        Array of capabilities to display in field dropdown.
72
+	 * @param  string      $field_type  Type of field options to render (`field` or `widget`)
73
+	 * @param  string      $template_id Table slug
74
+	 * @param  float       $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
75
+	 * @param  string      $context     What context are we in? Example: `single` or `directory`
76
+	 * @param  string      $input_type  (textarea, list, select, etc.)
77
+	 * @return array                   Array of field options with `label`, `value`, `type`, `default` keys
78
+	 */
79
+	function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
80
+
81
+		$caps = $visibility_caps;
82
+
83
+		// If we're configuring fields in the edit context, we want a limited selection
84
+		if( $context === 'edit' ) {
85
+
86
+			// Remove other built-in caps.
87
+			unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
88
+
89
+			$caps['read'] = _x('Entry Creator','User capability', 'gravityview');
90
+		}
91
+
92
+		return $caps;
93
+	}
94
+
95
+	/**
96
+	 * Add "Edit Link Text" setting to the edit_link field settings
97
+	 * @param  [type] $field_options [description]
98
+	 * @param  [type] $template_id   [description]
99
+	 * @param  [type] $field_id      [description]
100
+	 * @param  [type] $context       [description]
101
+	 * @param  [type] $input_type    [description]
102
+	 * @return [type]                [description]
103
+	 */
104
+	function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105
+
106
+		// Always a link, never a filter
107
+		unset( $field_options['show_as_link'], $field_options['search_filter'] );
108
+
109
+		// Edit Entry link should only appear to visitors capable of editing entries
110
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
111
+
112
+		$add_option['edit_link'] = array(
113
+			'type' => 'text',
114
+			'label' => __( 'Edit Link Text', 'gravityview' ),
115
+			'desc' => NULL,
116
+			'value' => __('Edit Entry', 'gravityview'),
117
+			'merge_tags' => true,
118
+		);
119
+
120
+		return array_merge( $add_option, $field_options );
121
+	}
122
+
123
+	/**
124
+	 * Add tooltips
125
+	 * @param  array $tooltips Existing tooltips
126
+	 * @return array           Modified tooltips
127
+	 */
128
+	function tooltips( $tooltips ) {
129
+
130
+		$return = $tooltips;
131
+
132
+		$return['allow_edit_cap'] = array(
133
+			'title' => __('Limiting Edit Access', 'gravityview'),
134
+			'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
135
+		);
136
+
137
+		return $return;
138
+	}
139
+
140
+	/**
141
+	 * Manipulate the fields' options for the EDIT ENTRY screen
142
+	 * @param  [type] $field_options [description]
143
+	 * @param  [type] $template_id   [description]
144
+	 * @param  [type] $field_id      [description]
145
+	 * @param  [type] $context       [description]
146
+	 * @param  [type] $input_type    [description]
147
+	 * @return [type]                [description]
148
+	 */
149
+	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150
+
151
+		// We only want to modify the settings for the edit context
152
+		if( 'edit' !== $context ) {
153
+
154
+			/**
155
+			 * @since 1.8.4
156
+			 */
157
+			$field_options['new_window'] = array(
158
+				'type' => 'checkbox',
159
+				'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160
+				'value' => false,
161
+			);
162
+
163
+			return $field_options;
164
+		}
165
+
166
+		//  Entry field is only for logged in users
167
+		unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
168
+
169
+		$add_options = array(
170
+			'allow_edit_cap' => array(
171
+				'type' => 'select',
172
+				'label' => __( 'Make field editable to:', 'gravityview' ),
173
+				'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
174
+				'tooltip' => 'allow_edit_cap',
175
+				'class' => 'widefat',
176
+				'value' => 'read', // Default: entry creator
177
+			),
178
+		);
179
+
180
+		return array_merge( $field_options, $add_options );
181
+	}
182 182
 
183 183
 
184 184
 } // end class
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     function load() {
26 26
 
27
-        if( !is_admin() ) {
27
+        if ( ! is_admin() ) {
28 28
             return;
29 29
         }
30 30
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 );
39 39
 
40 40
         // add tooltips
41
-        add_filter( 'gravityview_tooltips', array( $this, 'tooltips') );
41
+        add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) );
42 42
 
43 43
         // custom fields' options for zone EDIT
44 44
         add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 );
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
      */
53 53
     function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
54 54
 
55
-        if( $zone !== 'edit' ) {
55
+        if ( $zone !== 'edit' ) {
56 56
 
57
-            $entry_default_fields['edit_link'] = array(
58
-                'label' => __('Edit Entry', 'gravityview'),
57
+            $entry_default_fields[ 'edit_link' ] = array(
58
+                'label' => __( 'Edit Entry', 'gravityview' ),
59 59
                 'type' => 'edit_link',
60
-                'desc'	=> __('A link to edit the entry. Visible based on View settings.', 'gravityview'),
60
+                'desc'	=> __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ),
61 61
             );
62 62
 
63 63
         }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
         $caps = $visibility_caps;
82 82
 
83 83
         // If we're configuring fields in the edit context, we want a limited selection
84
-        if( $context === 'edit' ) {
84
+        if ( $context === 'edit' ) {
85 85
 
86 86
             // Remove other built-in caps.
87
-            unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
87
+            unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] );
88 88
 
89
-            $caps['read'] = _x('Entry Creator','User capability', 'gravityview');
89
+            $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' );
90 90
         }
91 91
 
92 92
         return $caps;
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
     function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
105 105
 
106 106
         // Always a link, never a filter
107
-        unset( $field_options['show_as_link'], $field_options['search_filter'] );
107
+        unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] );
108 108
 
109 109
         // Edit Entry link should only appear to visitors capable of editing entries
110
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
110
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
111 111
 
112
-        $add_option['edit_link'] = array(
112
+        $add_option[ 'edit_link' ] = array(
113 113
             'type' => 'text',
114 114
             'label' => __( 'Edit Link Text', 'gravityview' ),
115 115
             'desc' => NULL,
116
-            'value' => __('Edit Entry', 'gravityview'),
116
+            'value' => __( 'Edit Entry', 'gravityview' ),
117 117
             'merge_tags' => true,
118 118
         );
119 119
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 
130 130
         $return = $tooltips;
131 131
 
132
-        $return['allow_edit_cap'] = array(
133
-            'title' => __('Limiting Edit Access', 'gravityview'),
134
-            'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'),
132
+        $return[ 'allow_edit_cap' ] = array(
133
+            'title' => __( 'Limiting Edit Access', 'gravityview' ),
134
+            'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ),
135 135
         );
136 136
 
137 137
         return $return;
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
     function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
150 150
 
151 151
         // We only want to modify the settings for the edit context
152
-        if( 'edit' !== $context ) {
152
+        if ( 'edit' !== $context ) {
153 153
 
154 154
             /**
155 155
              * @since 1.8.4
156 156
              */
157
-            $field_options['new_window'] = array(
157
+            $field_options[ 'new_window' ] = array(
158 158
                 'type' => 'checkbox',
159 159
                 'label' => __( 'Open link in a new tab or window?', 'gravityview' ),
160 160
                 'value' => false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
 
166 166
         //  Entry field is only for logged in users
167
-        unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
167
+        unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] );
168 168
 
169 169
         $add_options = array(
170 170
             'allow_edit_cap' => array(
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      * @since 1.11
58 58
      *
59 59
      * @param array $form Gravity Forms form array
60
-     * @param string $entry_id Gravity Forms entry ID
60
+     * @param integer $entry_id Gravity Forms entry ID
61 61
      * @return void
62 62
      */
63 63
     public function update_user( $form = array(), $entry_id = 0 ) {
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -171,11 +171,13 @@
 block discarded – undo
171 171
         $public_display['nickname']  = $profileuser->nickname;
172 172
         $public_display['username']  = $profileuser->user_login;
173 173
 
174
-        if ( !empty($profileuser->first_name) )
175
-            $public_display['firstname'] = $profileuser->first_name;
174
+        if ( !empty($profileuser->first_name) ) {
175
+                    $public_display['firstname'] = $profileuser->first_name;
176
+        }
176 177
 
177
-        if ( !empty($profileuser->last_name) )
178
-            $public_display['lastname'] = $profileuser->last_name;
178
+        if ( !empty($profileuser->last_name) ) {
179
+                    $public_display['lastname'] = $profileuser->last_name;
180
+        }
179 181
 
180 182
         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
181 183
             $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
Please login to merge, or discard this patch.
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 if ( ! defined( 'WPINC' ) ) {
14
-    die;
14
+	die;
15 15
 }
16 16
 
17 17
 /**
@@ -22,253 +22,253 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @var GravityView_Edit_Entry
24 24
 	 */
25
-    protected $loader;
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var WP_User|null Temporary storage used by restore_user_details()
29
-     */
30
-    private $_user_before_update = null;
27
+	/**
28
+	 * @var WP_User|null Temporary storage used by restore_user_details()
29
+	 */
30
+	private $_user_before_update = null;
31 31
 
32
-    function __construct( GravityView_Edit_Entry $loader ) {
33
-        $this->loader = $loader;
34
-    }
32
+	function __construct( GravityView_Edit_Entry $loader ) {
33
+		$this->loader = $loader;
34
+	}
35 35
 
36 36
 	/**
37 37
 	 * @since 1.11
38 38
 	 */
39 39
 	public function load() {
40 40
 		add_action( 'wp', array( $this, 'add_hooks' ), 10 );
41
-    }
41
+	}
42 42
 
43 43
 	/**
44 44
 	 * Add hooks to trigger updating the user
45 45
 	 *
46 46
 	 * @since 1.18
47 47
 	 */
48
-    public function add_hooks() {
49
-
50
-	    /**
51
-	     * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
-	     * @since 1.11
53
-	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
-	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
-
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
-
59
-		    // last resort in case the current user display name don't match any of the defaults
60
-		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
-	    }
62
-    }
63
-
64
-    /**
65
-     * Update the WordPress user profile based on the GF User Registration create feed
66
-     *
67
-     * @since 1.11
68
-     *
69
-     * @param array $form Gravity Forms form array
70
-     * @param string $entry_id Gravity Forms entry ID
71
-     * @return void
72
-     */
73
-    public function update_user( $form = array(), $entry_id = 0 ) {
74
-
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76
-            return;
77
-        }
78
-
79
-        /** @var GF_User_Registration $gf_user_registration */
80
-        $gf_user_registration = GF_User_Registration::get_instance();
81
-
82
-        $entry = GFAPI::get_entry( $entry_id );
83
-
84
-	    /**
85
-	     * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
86
-	     * @since 1.11
87
-	     * @param array $entry Gravity Forms entry
88
-	     * @param array $form Gravity Forms form
89
-	     */
90
-        $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
91
-
92
-        $config = $gf_user_registration->get_single_submission_feed( $entry, $form );
93
-
94
-        /**
95
-         * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
96
-         * @since 1.15
97
-         * @param[in,out] boolean $preserve_role Preserve current user role Default: true
98
-         * @param[in] array $config Gravity Forms User Registration feed configuration for the form
99
-         * @param[in] array $form Gravity Forms form array
100
-         * @param[in] array $entry Gravity Forms entry being edited
101
-         */
102
-        $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103
-
104
-        if( $preserve_role ) {
105
-            $config['meta']['role'] = 'gfur_preserve_role';
106
-        }
107
-
108
-        /**
109
-         * Make sure the current display name is not changed with the update user method.
110
-         * @since 1.15
111
-         */
112
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
113
-
114
-
115
-        /**
116
-         * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
117
-         * @since 1.14
118
-         * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
119
-         * @param[in] array $form Gravity Forms form array
120
-         * @param[in] array $entry Gravity Forms entry being edited
121
-         */
122
-        $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
123
-
124
-
125
-        // Make sure the feed is active
126
-	    if ( ! rgar( $config, 'is_active', false ) ) {
48
+	public function add_hooks() {
49
+
50
+		/**
51
+		 * @filter `gravityview/edit_entry/user_registration/trigger_update` Choose whether to update user information via User Registration add-on when an entry is updated?
52
+		 * @since 1.11
53
+		 * @param boolean $boolean Whether to trigger update on user registration (default: true)
54
+		 */
55
+		if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56
+
57
+			add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
58
+
59
+			// last resort in case the current user display name don't match any of the defaults
60
+			add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
61
+		}
62
+	}
63
+
64
+	/**
65
+	 * Update the WordPress user profile based on the GF User Registration create feed
66
+	 *
67
+	 * @since 1.11
68
+	 *
69
+	 * @param array $form Gravity Forms form array
70
+	 * @param string $entry_id Gravity Forms entry ID
71
+	 * @return void
72
+	 */
73
+	public function update_user( $form = array(), $entry_id = 0 ) {
74
+
75
+		if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76
+			return;
77
+		}
78
+
79
+		/** @var GF_User_Registration $gf_user_registration */
80
+		$gf_user_registration = GF_User_Registration::get_instance();
81
+
82
+		$entry = GFAPI::get_entry( $entry_id );
83
+
84
+		/**
85
+		 * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
86
+		 * @since 1.11
87
+		 * @param array $entry Gravity Forms entry
88
+		 * @param array $form Gravity Forms form
89
+		 */
90
+		$entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form );
91
+
92
+		$config = $gf_user_registration->get_single_submission_feed( $entry, $form );
93
+
94
+		/**
95
+		 * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
96
+		 * @since 1.15
97
+		 * @param[in,out] boolean $preserve_role Preserve current user role Default: true
98
+		 * @param[in] array $config Gravity Forms User Registration feed configuration for the form
99
+		 * @param[in] array $form Gravity Forms form array
100
+		 * @param[in] array $entry Gravity Forms entry being edited
101
+		 */
102
+		$preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103
+
104
+		if( $preserve_role ) {
105
+			$config['meta']['role'] = 'gfur_preserve_role';
106
+		}
107
+
108
+		/**
109
+		 * Make sure the current display name is not changed with the update user method.
110
+		 * @since 1.15
111
+		 */
112
+		$config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
113
+
114
+
115
+		/**
116
+		 * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
117
+		 * @since 1.14
118
+		 * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
119
+		 * @param[in] array $form Gravity Forms form array
120
+		 * @param[in] array $entry Gravity Forms entry being edited
121
+		 */
122
+		$config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
123
+
124
+
125
+		// Make sure the feed is active
126
+		if ( ! rgar( $config, 'is_active', false ) ) {
127 127
 			return;
128
-	    }
129
-
130
-	    // If an Update feed, make sure the conditions are met.
131
-	    if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133
-			    return;
134
-		    }
135
-	    }
136
-
137
-        // The priority is set to 3 so that default priority (10) will still override it
138
-        add_filter( 'send_password_change_email', '__return_false', 3 );
139
-        add_filter( 'send_email_change_email', '__return_false', 3 );
140
-
141
-        // Trigger the User Registration update user method
142
-        $gf_user_registration->update_user( $entry, $form, $config );
143
-
144
-        remove_filter( 'send_password_change_email', '__return_false', 3 );
145
-        remove_filter( 'send_email_change_email', '__return_false', 3 );
146
-
147
-    }
148
-
149
-    /**
150
-     * Calculate the user display name format
151
-     *
152
-     * @since 1.15
153
-     *
154
-     * @param int $user_id WP User ID
155
-     * @return string Display name format as used inside Gravity Forms User Registration
156
-     */
157
-    public function match_current_display_name( $user_id ) {
158
-
159
-        $user = get_userdata( $user_id );
160
-
161
-        $names = $this->generate_display_names( $user );
162
-
163
-        $format = array_search( $user->display_name, $names, true );
164
-
165
-        // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166
-        //   trigger last resort method at the 'gform_user_updated' hook
167
-        if( false === $format || 'nickname' === $format ) {
168
-            $this->_user_before_update = $user;
169
-            $format = 'nickname';
170
-        }
171
-
172
-        return $format;
173
-
174
-    }
175
-
176
-    /**
177
-     * Generate an array of all the user display names possibilities
178
-     *
179
-     * @since 1.15
180
-     *
181
-     * @param object $profileuser WP_User object
182
-     * @return array List all the possible display names for a certain User object
183
-     */
184
-    public function generate_display_names( $profileuser ) {
185
-
186
-        $public_display = array();
187
-        $public_display['nickname']  = $profileuser->nickname;
188
-        $public_display['username']  = $profileuser->user_login;
189
-
190
-        if ( !empty($profileuser->first_name) )
191
-            $public_display['firstname'] = $profileuser->first_name;
192
-
193
-        if ( !empty($profileuser->last_name) )
194
-            $public_display['lastname'] = $profileuser->last_name;
195
-
196
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
199
-        }
200
-
201
-        $public_display = array_map( 'trim', $public_display );
202
-        $public_display = array_unique( $public_display );
203
-
204
-        return $public_display;
205
-    }
206
-
207
-
208
-    /**
209
-     * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
210
-     *
211
-     * @see GFUser::update_user()
212
-     * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
213
-     * @param array $config Gravity Forms User Registration Addon form feed configuration
214
-     * @param array $entry The Gravity Forms entry that was just updated
215
-     * @param string $password User password
216
-     * @return void
217
-     */
218
-    public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
219
-
220
-        /**
221
-         * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
222
-         * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
223
-         * @since 1.14.4
224
-         * @param boolean $restore_display_name Restore Display Name? Default: true
225
-         */
226
-        $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227
-
228
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
229
-
230
-        /**
231
-         * Don't restore display name:
232
-         *   - either disabled,
233
-         *   - or it is an Update feed (we only care about Create feed)
234
-         *   - or we don't need as we found the correct format before updating user.
235
-         * @since 1.14.4
236
-         */
237
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238
-            return;
239
-        }
240
-
241
-        $user_after_update = get_userdata( $user_id );
242
-
243
-        $restored_user = $user_after_update;
244
-
245
-	    // Restore previous display_name
246
-        $restored_user->display_name = $this->_user_before_update->display_name;
247
-
248
-	    // Don't have WP update the password.
249
-	    unset( $restored_user->data->user_pass, $restored_user->user_pass );
250
-
251
-        /**
252
-         * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
253
-         * @since 1.14
254
-         * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
255
-         * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
256
-         * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
257
-         * @param array   $entry The Gravity Forms entry that was just updated
258
-         */
259
-        $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
260
-
261
-        $updated = wp_update_user( $restored_user );
262
-
263
-        if( is_wp_error( $updated ) ) {
264
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265
-        } else {
266
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267
-        }
268
-
269
-        $this->_user_before_update = null;
270
-
271
-        unset( $updated, $restored_user, $user_after_update );
272
-    }
128
+		}
129
+
130
+		// If an Update feed, make sure the conditions are met.
131
+		if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
+			if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133
+				return;
134
+			}
135
+		}
136
+
137
+		// The priority is set to 3 so that default priority (10) will still override it
138
+		add_filter( 'send_password_change_email', '__return_false', 3 );
139
+		add_filter( 'send_email_change_email', '__return_false', 3 );
140
+
141
+		// Trigger the User Registration update user method
142
+		$gf_user_registration->update_user( $entry, $form, $config );
143
+
144
+		remove_filter( 'send_password_change_email', '__return_false', 3 );
145
+		remove_filter( 'send_email_change_email', '__return_false', 3 );
146
+
147
+	}
148
+
149
+	/**
150
+	 * Calculate the user display name format
151
+	 *
152
+	 * @since 1.15
153
+	 *
154
+	 * @param int $user_id WP User ID
155
+	 * @return string Display name format as used inside Gravity Forms User Registration
156
+	 */
157
+	public function match_current_display_name( $user_id ) {
158
+
159
+		$user = get_userdata( $user_id );
160
+
161
+		$names = $this->generate_display_names( $user );
162
+
163
+		$format = array_search( $user->display_name, $names, true );
164
+
165
+		// In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166
+		//   trigger last resort method at the 'gform_user_updated' hook
167
+		if( false === $format || 'nickname' === $format ) {
168
+			$this->_user_before_update = $user;
169
+			$format = 'nickname';
170
+		}
171
+
172
+		return $format;
173
+
174
+	}
175
+
176
+	/**
177
+	 * Generate an array of all the user display names possibilities
178
+	 *
179
+	 * @since 1.15
180
+	 *
181
+	 * @param object $profileuser WP_User object
182
+	 * @return array List all the possible display names for a certain User object
183
+	 */
184
+	public function generate_display_names( $profileuser ) {
185
+
186
+		$public_display = array();
187
+		$public_display['nickname']  = $profileuser->nickname;
188
+		$public_display['username']  = $profileuser->user_login;
189
+
190
+		if ( !empty($profileuser->first_name) )
191
+			$public_display['firstname'] = $profileuser->first_name;
192
+
193
+		if ( !empty($profileuser->last_name) )
194
+			$public_display['lastname'] = $profileuser->last_name;
195
+
196
+		if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
+			$public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
+			$public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
199
+		}
200
+
201
+		$public_display = array_map( 'trim', $public_display );
202
+		$public_display = array_unique( $public_display );
203
+
204
+		return $public_display;
205
+	}
206
+
207
+
208
+	/**
209
+	 * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon
210
+	 *
211
+	 * @see GFUser::update_user()
212
+	 * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon
213
+	 * @param array $config Gravity Forms User Registration Addon form feed configuration
214
+	 * @param array $entry The Gravity Forms entry that was just updated
215
+	 * @param string $password User password
216
+	 * @return void
217
+	 */
218
+	public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) {
219
+
220
+		/**
221
+		 * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry.
222
+		 * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed
223
+		 * @since 1.14.4
224
+		 * @param boolean $restore_display_name Restore Display Name? Default: true
225
+		 */
226
+		$restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227
+
228
+		$is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
229
+
230
+		/**
231
+		 * Don't restore display name:
232
+		 *   - either disabled,
233
+		 *   - or it is an Update feed (we only care about Create feed)
234
+		 *   - or we don't need as we found the correct format before updating user.
235
+		 * @since 1.14.4
236
+		 */
237
+		if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238
+			return;
239
+		}
240
+
241
+		$user_after_update = get_userdata( $user_id );
242
+
243
+		$restored_user = $user_after_update;
244
+
245
+		// Restore previous display_name
246
+		$restored_user->display_name = $this->_user_before_update->display_name;
247
+
248
+		// Don't have WP update the password.
249
+		unset( $restored_user->data->user_pass, $restored_user->user_pass );
250
+
251
+		/**
252
+		 * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView
253
+		 * @since 1.14
254
+		 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user()
255
+		 * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration
256
+		 * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration
257
+		 * @param array   $entry The Gravity Forms entry that was just updated
258
+		 */
259
+		$restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry );
260
+
261
+		$updated = wp_update_user( $restored_user );
262
+
263
+		if( is_wp_error( $updated ) ) {
264
+			do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265
+		} else {
266
+			do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267
+		}
268
+
269
+		$this->_user_before_update = null;
270
+
271
+		unset( $updated, $restored_user, $user_after_update );
272
+	}
273 273
 
274 274
 } //end class
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	     * @since 1.11
53 53
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54 54
 	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
55
+	    if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56 56
 
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
57
+	    	add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
58 58
 
59 59
 		    // last resort in case the current user display name don't match any of the defaults
60 60
 		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function update_user( $form = array(), $entry_id = 0 ) {
74 74
 
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
75
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) {
76 76
             return;
77 77
         }
78 78
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
          */
102 102
         $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
103 103
 
104
-        if( $preserve_role ) {
105
-            $config['meta']['role'] = 'gfur_preserve_role';
104
+        if ( $preserve_role ) {
105
+            $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
106 106
         }
107 107
 
108 108
         /**
109 109
          * Make sure the current display name is not changed with the update user method.
110 110
          * @since 1.15
111 111
          */
112
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
112
+        $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] );
113 113
 
114 114
 
115 115
         /**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	    }
129 129
 
130 130
 	    // If an Update feed, make sure the conditions are met.
131
-	    if( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
131
+	    if ( rgars( $config, 'meta/feedType' ) === 'update' ) {
132
+	    	if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
133 133
 			    return;
134 134
 		    }
135 135
 	    }
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
         // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
166 166
         //   trigger last resort method at the 'gform_user_updated' hook
167
-        if( false === $format || 'nickname' === $format ) {
167
+        if ( false === $format || 'nickname' === $format ) {
168 168
             $this->_user_before_update = $user;
169 169
             $format = 'nickname';
170 170
         }
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
     public function generate_display_names( $profileuser ) {
185 185
 
186 186
         $public_display = array();
187
-        $public_display['nickname']  = $profileuser->nickname;
188
-        $public_display['username']  = $profileuser->user_login;
187
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
188
+        $public_display[ 'username' ]  = $profileuser->user_login;
189 189
 
190
-        if ( !empty($profileuser->first_name) )
191
-            $public_display['firstname'] = $profileuser->first_name;
190
+        if ( ! empty( $profileuser->first_name ) )
191
+            $public_display[ 'firstname' ] = $profileuser->first_name;
192 192
 
193
-        if ( !empty($profileuser->last_name) )
194
-            $public_display['lastname'] = $profileuser->last_name;
193
+        if ( ! empty( $profileuser->last_name ) )
194
+            $public_display[ 'lastname' ] = $profileuser->last_name;
195 195
 
196
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
197
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
196
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
197
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
198
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
199 199
         }
200 200
 
201 201
         $public_display = array_map( 'trim', $public_display );
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
          */
226 226
         $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
227 227
 
228
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
228
+        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' );
229 229
 
230 230
         /**
231 231
          * Don't restore display name:
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
          *   - or we don't need as we found the correct format before updating user.
235 235
          * @since 1.14.4
236 236
          */
237
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
237
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238 238
             return;
239 239
         }
240 240
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 
261 261
         $updated = wp_update_user( $restored_user );
262 262
 
263
-        if( is_wp_error( $updated ) ) {
264
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
263
+        if ( is_wp_error( $updated ) ) {
264
+            do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
265 265
         } else {
266
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
266
+            do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267 267
         }
268 268
 
269 269
         $this->_user_before_update = null;
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,6 +65,9 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
 
68
+    /**
69
+     * @param string $component
70
+     */
68 71
     private function load_components( $component ) {
69 72
 
70 73
         $dir = trailingslashit( self::$file );
@@ -141,7 +144,7 @@  discard block
 block discarded – undo
141 144
      * "You can edit this post from the post page" fields, for example.
142 145
      *
143 146
      * @param $entry array Gravity Forms entry object
144
-     * @param $view_id int GravityView view id
147
+     * @param integer $view_id int GravityView view id
145 148
      * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
146 149
      * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
147 150
      * @return string
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
39
+        if ( is_admin() ) {
40 40
             $this->load_components( 'admin' );
41 41
         }
42 42
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
58
+        if ( empty( self::$instance ) ) {
59 59
             self::$instance = new GravityView_Edit_Entry;
60 60
         }
61 61
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
     private function add_hooks() {
82 82
 
83 83
         // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
84
+        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file' ) );
85 85
 
86 86
         // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
87
+        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file' ) );
88 88
 
89 89
         add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	private function addon_specific_hooks() {
101 101
 
102
-		if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
103
-			add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script'));
102
+		if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
103
+			add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) );
104 104
 		}
105 105
 
106 106
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148 148
 
149
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
149
+        $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] );
150 150
 
151 151
         $base = gv_entry_link( $entry, $post_id );
152 152
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	     * Allow passing params to dynamically populate entry with values
161 161
 	     * @since 1.9.2
162 162
 	     */
163
-	    if( !empty( $field_values ) ) {
163
+	    if ( ! empty( $field_values ) ) {
164 164
 
165
-		    if( is_array( $field_values ) ) {
165
+		    if ( is_array( $field_values ) ) {
166 166
 			    // If already an array, no parse_str() needed
167 167
 			    $params = $field_values;
168 168
 		    } else {
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function modify_field_blacklist( $fields = array(), $context = NULL ) {
186 186
 
187
-		if( empty( $context ) || $context !== 'edit' ) {
187
+		if ( empty( $context ) || $context !== 'edit' ) {
188 188
 			return $fields;
189 189
 		}
190 190
 
@@ -226,24 +226,24 @@  discard block
 block discarded – undo
226 226
         // If they can edit any entries (as defined in Gravity Forms)
227 227
         // Or if they can edit other people's entries
228 228
         // Then we're good.
229
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
229
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) {
230 230
 
231
-            do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
231
+            do_action( 'gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.' );
232 232
 
233 233
             $user_can_edit = true;
234 234
 
235
-        } else if( !isset( $entry['created_by'] ) ) {
235
+        } else if ( ! isset( $entry[ 'created_by' ] ) ) {
236 236
 
237
-            do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
237
+            do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.' );
238 238
 
239 239
             $user_can_edit = false;
240 240
 
241 241
         } else {
242 242
 
243 243
             // get user_edit setting
244
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
244
+            if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
245 245
                 // if View ID not specified or is the current view
246
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
246
+                $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' );
247 247
             } else {
248 248
                 // in case is specified and not the current view
249 249
                 $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
@@ -252,21 +252,21 @@  discard block
 block discarded – undo
252 252
             $current_user = wp_get_current_user();
253 253
 
254 254
             // User edit is disabled
255
-            if( empty( $user_edit ) ) {
255
+            if ( empty( $user_edit ) ) {
256 256
 
257
-                do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
257
+                do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
258 258
 
259 259
                 $user_can_edit = false;
260 260
             }
261 261
 
262 262
             // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
263
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
263
+            else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
264 264
 
265
-                do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
265
+                do_action( 'gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
266 266
 
267 267
                 $user_can_edit = true;
268 268
 
269
-            } else if( ! is_user_logged_in() ) {
269
+            } else if ( ! is_user_logged_in() ) {
270 270
 
271 271
                 do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
272 272
             }
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -18,80 +18,80 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 
44
-        $this->load_components( 'render' );
44
+		$this->load_components( 'render' );
45 45
 
46
-        // If GF User Registration Add-on exists
47
-        $this->load_components( 'user-registration' );
46
+		// If GF User Registration Add-on exists
47
+		$this->load_components( 'user-registration' );
48 48
 
49
-        $this->add_hooks();
49
+		$this->add_hooks();
50 50
 
51 51
 		// Process hooks for addons that may or may not be present
52 52
 		$this->addon_specific_hooks();
53 53
 	}
54 54
 
55 55
 
56
-    static function getInstance() {
56
+	static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
59
-            self::$instance = new GravityView_Edit_Entry;
60
-        }
58
+		if( empty( self::$instance ) ) {
59
+			self::$instance = new GravityView_Edit_Entry;
60
+		}
61 61
 
62
-        return self::$instance;
63
-    }
62
+		return self::$instance;
63
+	}
64 64
 
65 65
 
66
-    private function load_components( $component ) {
66
+	private function load_components( $component ) {
67 67
 
68
-        $dir = trailingslashit( self::$file );
68
+		$dir = trailingslashit( self::$file );
69 69
 
70
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
70
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
72 72
 
73
-        // Loads component and pass extension's instance so that component can
74
-        // talk each other.
75
-        require_once $filename;
76
-        $this->instances[ $component ] = new $classname( $this );
77
-        $this->instances[ $component ]->load();
73
+		// Loads component and pass extension's instance so that component can
74
+		// talk each other.
75
+		require_once $filename;
76
+		$this->instances[ $component ] = new $classname( $this );
77
+		$this->instances[ $component ]->load();
78 78
 
79
-    }
79
+	}
80 80
 
81
-    private function add_hooks() {
81
+	private function add_hooks() {
82 82
 
83
-        // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
83
+		// Add front-end access to Gravity Forms delete file action
84
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
85 85
 
86
-        // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
86
+		// Make sure this hook is run for non-admins
87
+		add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
88 88
 
89
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
89
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
91
-        // add template path to check for field
92
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
91
+		// add template path to check for field
92
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
93 93
 
94
-    }
94
+	}
95 95
 
96 96
 	/**
97 97
 	 * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin
@@ -105,75 +105,75 @@  discard block
 block discarded – undo
105 105
 
106 106
 	}
107 107
 
108
-    /**
109
-     * Include this extension templates path
110
-     * @param array $file_paths List of template paths ordered
111
-     */
112
-    public function add_template_path( $file_paths ) {
113
-
114
-        // Index 100 is the default GravityView template path.
115
-        $file_paths[ 110 ] = self::$file;
116
-
117
-        return $file_paths;
118
-    }
119
-
120
-    /**
121
-     *
122
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
-     *
124
-     * @param $view_id int GravityView view id
125
-     * @param $form_id int Gravity Forms form id
126
-     * @param $entry_id int Gravity Forms entry id
127
-     * @return string
128
-     */
129
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
-    }
132
-
133
-
134
-    /**
135
-     * The edit entry link creates a secure link with a nonce
136
-     *
137
-     * It also mimics the URL structure Gravity Forms expects to have so that
138
-     * it formats the display of the edit form like it does in the backend, like
139
-     * "You can edit this post from the post page" fields, for example.
140
-     *
141
-     * @param $entry array Gravity Forms entry object
142
-     * @param $view_id int GravityView view id
143
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
-     * @return string
146
-     */
147
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
-
149
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
-
151
-        $base = gv_entry_link( $entry, $post_id );
152
-
153
-        $url = add_query_arg( array(
154
-            'page' => 'gf_entries', // Needed for GFForms::get_page()
155
-            'view' => 'entry', // Needed for GFForms::get_page()
156
-            'edit' => wp_create_nonce( $nonce_key )
157
-        ), $base );
158
-
159
-	    /**
160
-	     * Allow passing params to dynamically populate entry with values
161
-	     * @since 1.9.2
162
-	     */
163
-	    if( !empty( $field_values ) ) {
164
-
165
-		    if( is_array( $field_values ) ) {
166
-			    // If already an array, no parse_str() needed
167
-			    $params = $field_values;
168
-		    } else {
169
-			    parse_str( $field_values, $params );
170
-		    }
171
-
172
-		    $url = add_query_arg( $params, $url );
173
-	    }
174
-
175
-        return $url;
176
-    }
108
+	/**
109
+	 * Include this extension templates path
110
+	 * @param array $file_paths List of template paths ordered
111
+	 */
112
+	public function add_template_path( $file_paths ) {
113
+
114
+		// Index 100 is the default GravityView template path.
115
+		$file_paths[ 110 ] = self::$file;
116
+
117
+		return $file_paths;
118
+	}
119
+
120
+	/**
121
+	 *
122
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
+	 *
124
+	 * @param $view_id int GravityView view id
125
+	 * @param $form_id int Gravity Forms form id
126
+	 * @param $entry_id int Gravity Forms entry id
127
+	 * @return string
128
+	 */
129
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
+	}
132
+
133
+
134
+	/**
135
+	 * The edit entry link creates a secure link with a nonce
136
+	 *
137
+	 * It also mimics the URL structure Gravity Forms expects to have so that
138
+	 * it formats the display of the edit form like it does in the backend, like
139
+	 * "You can edit this post from the post page" fields, for example.
140
+	 *
141
+	 * @param $entry array Gravity Forms entry object
142
+	 * @param $view_id int GravityView view id
143
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
+	 * @return string
146
+	 */
147
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
+
149
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
+
151
+		$base = gv_entry_link( $entry, $post_id );
152
+
153
+		$url = add_query_arg( array(
154
+			'page' => 'gf_entries', // Needed for GFForms::get_page()
155
+			'view' => 'entry', // Needed for GFForms::get_page()
156
+			'edit' => wp_create_nonce( $nonce_key )
157
+		), $base );
158
+
159
+		/**
160
+		 * Allow passing params to dynamically populate entry with values
161
+		 * @since 1.9.2
162
+		 */
163
+		if( !empty( $field_values ) ) {
164
+
165
+			if( is_array( $field_values ) ) {
166
+				// If already an array, no parse_str() needed
167
+				$params = $field_values;
168
+			} else {
169
+				parse_str( $field_values, $params );
170
+			}
171
+
172
+			$url = add_query_arg( $params, $url );
173
+		}
174
+
175
+		return $url;
176
+	}
177 177
 
178 178
 	/**
179 179
 	 * Edit mode doesn't allow certain field types.
@@ -225,81 +225,81 @@  discard block
 block discarded – undo
225 225
 	}
226 226
 
227 227
 
228
-    /**
229
-     * checks if user has permissions to edit a specific entry
230
-     *
231
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
232
-     *
233
-     * @param  array $entry Gravity Forms entry array
234
-     * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
235
-     * @return bool
236
-     */
237
-    public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
228
+	/**
229
+	 * checks if user has permissions to edit a specific entry
230
+	 *
231
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
232
+	 *
233
+	 * @param  array $entry Gravity Forms entry array
234
+	 * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}
235
+	 * @return bool
236
+	 */
237
+	public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
238 238
 
239
-        // No permission by default
240
-        $user_can_edit = false;
239
+		// No permission by default
240
+		$user_can_edit = false;
241 241
 
242
-        // If they can edit any entries (as defined in Gravity Forms)
243
-        // Or if they can edit other people's entries
244
-        // Then we're good.
245
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
242
+		// If they can edit any entries (as defined in Gravity Forms)
243
+		// Or if they can edit other people's entries
244
+		// Then we're good.
245
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
246 246
 
247
-            do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
247
+			do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
248 248
 
249
-            $user_can_edit = true;
249
+			$user_can_edit = true;
250 250
 
251
-        } else if( !isset( $entry['created_by'] ) ) {
251
+		} else if( !isset( $entry['created_by'] ) ) {
252 252
 
253
-            do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
253
+			do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
254 254
 
255
-            $user_can_edit = false;
255
+			$user_can_edit = false;
256 256
 
257
-        } else {
257
+		} else {
258 258
 
259
-            // get user_edit setting
260
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
261
-                // if View ID not specified or is the current view
262
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
263
-            } else {
264
-                // in case is specified and not the current view
265
-                $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
266
-            }
259
+			// get user_edit setting
260
+			if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
261
+				// if View ID not specified or is the current view
262
+				$user_edit = GravityView_View::getInstance()->getAtts('user_edit');
263
+			} else {
264
+				// in case is specified and not the current view
265
+				$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
266
+			}
267 267
 
268
-            $current_user = wp_get_current_user();
268
+			$current_user = wp_get_current_user();
269 269
 
270
-            // User edit is disabled
271
-            if( empty( $user_edit ) ) {
270
+			// User edit is disabled
271
+			if( empty( $user_edit ) ) {
272 272
 
273
-                do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
273
+				do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
274 274
 
275
-                $user_can_edit = false;
276
-            }
275
+				$user_can_edit = false;
276
+			}
277 277
 
278
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
279
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
278
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
279
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
280 280
 
281
-                do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
281
+				do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
282 282
 
283
-                $user_can_edit = true;
283
+				$user_can_edit = true;
284 284
 
285
-            } else if( ! is_user_logged_in() ) {
285
+			} else if( ! is_user_logged_in() ) {
286 286
 
287
-                do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
288
-            }
287
+				do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
288
+			}
289 289
 
290
-        }
290
+		}
291 291
 
292
-        /**
293
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
294
-         * @since 1.15 Added `$entry` and `$view_id` parameters
295
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
296
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
297
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
298
-         */
299
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
292
+		/**
293
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
294
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
295
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
296
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
297
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
298
+		 */
299
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
300 300
 
301
-        return (bool)$user_can_edit;
302
-    }
301
+		return (bool)$user_can_edit;
302
+	}
303 303
 
304 304
 
305 305
 
Please login to merge, or discard this patch.
plugin-and-theme-hooks/abstract-gravityview-plugin-and-theme-hooks.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -169,7 +169,6 @@
 block discarded – undo
169 169
 	 *
170 170
 	 * @since 1.15.2
171 171
 	 *
172
-	 * @param array $handles Array of meta keys to check for existence of shortcodes
173 172
 	 * @param int $post_id The ID being checked by GravityView
174 173
 	 *
175 174
 	 * @return array Meta key array, merged with existing meta keys
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	private function maybe_add_hooks() {
92 92
 		$class_exists = $this->class_name && class_exists( $this->class_name );
93 93
 		$function_exists = $this->function_name && function_exists( $this->function_name );
94
-		$constant_defined = $this->constant_name && defined("{$this->constant_name}");
94
+		$constant_defined = $this->constant_name && defined( "{$this->constant_name}" );
95 95
 
96
-		if( $class_exists || $function_exists || $constant_defined ) {
96
+		if ( $class_exists || $function_exists || $constant_defined ) {
97 97
 			$this->add_hooks();
98 98
 		}
99 99
 	}
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 */
106 106
 	protected function add_hooks() {
107
-		if( $this->content_meta_keys ) {
107
+		if ( $this->content_meta_keys ) {
108 108
 			add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 );
109 109
 		}
110 110
 
111
-		if( $this->script_handles ) {
111
+		if ( $this->script_handles ) {
112 112
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) );
113 113
 		}
114 114
 
115
-		if( $this->style_handles ) {
115
+		if ( $this->style_handles ) {
116 116
 			add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) );
117 117
 		}
118 118
 
119
-		if( $this->post_type_support ) {
119
+		if ( $this->post_type_support ) {
120 120
 			add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 );
121 121
 		}
122 122
 	}
Please login to merge, or discard this patch.
includes/widgets/class-gravityview-widget.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -51,6 +51,9 @@
 block discarded – undo
51 51
 	// hold widget View options
52 52
 	private $widget_options;
53 53
 
54
+	/**
55
+	 * @param string $widget_id
56
+	 */
54 57
 	function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) {
55 58
 
56 59
 
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -116,12 +116,12 @@
 block discarded – undo
116 116
 		return $settings;
117 117
 	}
118 118
 
119
-    /**
120
-     * @return string
121
-     */
122
-    public function get_widget_id() {
123
-        return $this->widget_id;
124
-    }
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function get_widget_id() {
123
+		return $this->widget_id;
124
+	}
125 125
 
126 126
 	/**
127 127
 	 * Get the widget settings
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	// hold widget View options
52 52
 	private $widget_options;
53 53
 
54
-	function __construct( $widget_label , $widget_id , $defaults = array(), $settings = array() ) {
54
+	function __construct( $widget_label, $widget_id, $defaults = array(), $settings = array() ) {
55 55
 
56 56
 
57 57
 		/**
58 58
 		 * The shortcode name is set to the lowercase name of the widget class, unless overridden by the class specifying a different value for $shortcode_name
59 59
 		 * @var string
60 60
 		 */
61
-		$this->shortcode_name = !isset( $this->shortcode_name ) ? strtolower( get_class($this) ) : $this->shortcode_name;
61
+		$this->shortcode_name = ! isset( $this->shortcode_name ) ? strtolower( get_class( $this ) ) : $this->shortcode_name;
62 62
 
63 63
 		$this->widget_label = $widget_label;
64 64
 		$this->widget_id = $widget_id;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$this->settings = wp_parse_args( $settings, $this->settings );
70 70
 
71 71
 		// register widgets to be listed in the View Configuration
72
-		add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget') );
72
+		add_filter( 'gravityview_register_directory_widgets', array( $this, 'register_widget' ) );
73 73
 
74 74
 		// widget options
75 75
 		add_filter( 'gravityview_template_widget_options', array( $this, 'assign_widget_options' ), 10, 3 );
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 		add_action( "gravityview_render_widget_{$widget_id}", array( $this, 'render_frontend' ), 10, 1 );
79 79
 
80 80
 		// register shortcodes
81
-		add_action( 'wp', array( $this, 'add_shortcode') );
81
+		add_action( 'wp', array( $this, 'add_shortcode' ) );
82 82
 
83 83
 		// Use shortcodes in text widgets.
84
-		add_filter('widget_text', array( $this, 'maybe_do_shortcode' ) );
84
+		add_filter( 'widget_text', array( $this, 'maybe_do_shortcode' ) );
85 85
 	}
86 86
 
87 87
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 		 * @param boolean $enable_custom_class False by default. Return true if you want to enable.
100 100
 		 * @param GravityView_Widget $this Current instance of GravityView_Widget
101 101
 		 */
102
-		$enable_custom_class = apply_filters('gravityview/widget/enable_custom_class', false, $this );
102
+		$enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this );
103 103
 
104
-		if( $enable_custom_class ) {
104
+		if ( $enable_custom_class ) {
105 105
 
106
-			$settings['custom_class'] = array(
106
+			$settings[ 'custom_class' ] = array(
107 107
 				'type' => 'text',
108 108
 				'label' => __( 'Custom CSS Class:', 'gravityview' ),
109
-				'desc' => __( 'This class will be added to the widget container', 'gravityview'),
109
+				'desc' => __( 'This class will be added to the widget container', 'gravityview' ),
110 110
 				'value' => '',
111 111
 				'merge_tags' => true,
112 112
 			);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array|null   Settings array; NULL if not set
129 129
 	 */
130 130
 	public function get_settings() {
131
-		return !empty( $this->settings ) ? $this->settings : NULL;
131
+		return ! empty( $this->settings ) ? $this->settings : NULL;
132 132
 	}
133 133
 
134 134
 	/**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	public function get_setting( $key ) {
140 140
 		$setting = NULL;
141 141
 
142
-		if( isset( $this->settings ) && is_array( $this->settings ) ) {
142
+		if ( isset( $this->settings ) && is_array( $this->settings ) ) {
143 143
 			$setting = isset( $this->settings[ $key ] ) ? $this->settings[ $key ] : NULL;
144 144
 		}
145 145
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	function maybe_do_shortcode( $text, $widget = NULL ) {
156 156
 
157
-		if( !empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) {
157
+		if ( ! empty( $this->shortcode_name ) && has_shortcode( $text, $this->shortcode_name ) ) {
158 158
 			return do_shortcode( $text );
159 159
 		}
160 160
 
@@ -183,26 +183,26 @@  discard block
 block discarded – undo
183 183
 			return;
184 184
 		}
185 185
 
186
-		if( empty( $this->shortcode_name ) ) { return; }
186
+		if ( empty( $this->shortcode_name ) ) { return; }
187 187
 
188 188
 		// If the widget shouldn't output on single entries, don't show it
189
-		if( empty( $this->show_on_single ) && class_exists('GravityView_frontend') && GravityView_frontend::is_single_entry() ) {
190
-			do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class($this)) );
189
+		if ( empty( $this->show_on_single ) && class_exists( 'GravityView_frontend' ) && GravityView_frontend::is_single_entry() ) {
190
+			do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: Skipping; set to not run on single entry.', get_class( $this ) ) );
191 191
 
192 192
 			add_shortcode( $this->shortcode_name, '__return_null' );
193 193
 			return;
194 194
 		}
195 195
 
196 196
 
197
-		if( !has_gravityview_shortcode( $post ) ) {
197
+		if ( ! has_gravityview_shortcode( $post ) ) {
198 198
 
199
-			do_action('gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class($this)) );
199
+			do_action( 'gravityview_log_debug', sprintf( '%s[add_shortcode]: No shortcode present; not adding render_frontend shortcode.', get_class( $this ) ) );
200 200
 
201 201
 			add_shortcode( $this->shortcode_name, '__return_null' );
202 202
 			return;
203 203
 		}
204 204
 
205
-		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') );
205
+		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) );
206 206
 	}
207 207
 
208 208
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	function register_widget( $widgets ) {
214 214
 		$widgets[ $this->widget_id ] = array(
215
-			'label' => $this->widget_label ,
215
+			'label' => $this->widget_label,
216 216
 			'description' => $this->widget_description,
217 217
 			'subtitle' => $this->widget_subtitle,
218 218
 		);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function assign_widget_options( $options = array(), $template = '', $widget = '' ) {
231 231
 
232
-		if( $this->widget_id === $widget ) {
232
+		if ( $this->widget_id === $widget ) {
233 233
 			$options = array_merge( $options, $this->settings );
234 234
 		}
235 235
 
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return void
244 244
 	 */
245
-	public function render_frontend( $widget_args, $content = '', $context = '') {
245
+	public function render_frontend( $widget_args, $content = '', $context = '' ) {
246 246
 		// to be defined by child class
247
-		if( !$this->pre_render_frontend() ) {
247
+		if ( ! $this->pre_render_frontend() ) {
248 248
 			return;
249 249
 		}
250 250
 	}
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	public function pre_render_frontend() {
257 257
 		$gravityview_view = GravityView_View::getInstance();
258 258
 
259
-		if( empty( $gravityview_view ) ) {
260
-			do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class($this)) );
259
+		if ( empty( $gravityview_view ) ) {
260
+			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: $gravityview_view not instantiated yet.', get_class( $this ) ) );
261 261
 			return false;
262 262
 		}
263 263
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 		 */
269 269
 		$hide_until_search = apply_filters( 'gravityview/widget/hide_until_searched', $gravityview_view->hide_until_searched, $this );
270 270
 
271
-		if( $hide_until_search ) {
272
-			do_action('gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class($this)) );
271
+		if ( $hide_until_search ) {
272
+			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend]: Hide View data until search is performed', get_class( $this ) ) );
273 273
 			return false;
274 274
 		}
275 275
 
Please login to merge, or discard this patch.
gravityview.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
313 313
 
314 314
 
315
-        /**
316
-         * When an entry is created, check if we need to update the custom slug meta
317
-         * todo: move this to its own class..
318
-         */
319
-        add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
315
+		/**
316
+		 * When an entry is created, check if we need to update the custom slug meta
317
+		 * todo: move this to its own class..
318
+		 */
319
+		add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
320 320
 
321 321
 		/**
322 322
 		 * @action `gravityview_include_frontend_actions` Triggered after all GravityView frontend files are loaded
@@ -347,34 +347,34 @@  discard block
 block discarded – undo
347 347
 
348 348
 	/** DEBUG */
349 349
 
350
-    /**
351
-     * Logs messages using Gravity Forms logging add-on
352
-     * @param  string $message log message
353
-     * @param mixed $data Additional data to display
354
-     * @return void
355
-     */
356
-    public static function log_debug( $message, $data = null ){
357
-	    /**
358
-	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
359
-	     * @param string $message Message to display
360
-	     * @param mixed $data Supporting data to print alongside it
361
-	     */
362
-    	do_action( 'gravityview_log_debug', $message, $data );
363
-    }
364
-
365
-    /**
366
-     * Logs messages using Gravity Forms logging add-on
367
-     * @param  string $message log message
368
-     * @return void
369
-     */
370
-    public static function log_error( $message, $data = null ){
371
-	    /**
372
-	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
373
-	     * @param string $message Error message to display
374
-	     * @param mixed $data Supporting data to print alongside it
375
-	     */
376
-    	do_action( 'gravityview_log_error', $message, $data );
377
-    }
350
+	/**
351
+	 * Logs messages using Gravity Forms logging add-on
352
+	 * @param  string $message log message
353
+	 * @param mixed $data Additional data to display
354
+	 * @return void
355
+	 */
356
+	public static function log_debug( $message, $data = null ){
357
+		/**
358
+		 * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
359
+		 * @param string $message Message to display
360
+		 * @param mixed $data Supporting data to print alongside it
361
+		 */
362
+		do_action( 'gravityview_log_debug', $message, $data );
363
+	}
364
+
365
+	/**
366
+	 * Logs messages using Gravity Forms logging add-on
367
+	 * @param  string $message log message
368
+	 * @return void
369
+	 */
370
+	public static function log_error( $message, $data = null ){
371
+		/**
372
+		 * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
373
+		 * @param string $message Error message to display
374
+		 * @param mixed $data Supporting data to print alongside it
375
+		 */
376
+		do_action( 'gravityview_log_error', $message, $data );
377
+	}
378 378
 
379 379
 } // end class GravityView_Plugin
380 380
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public static function getInstance() {
74 74
 
75
-		if( empty( self::$instance ) ) {
75
+		if ( empty( self::$instance ) ) {
76 76
 			self::$instance = new self;
77 77
 		}
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 		self::require_files();
85 85
 
86
-		if( ! GravityView_Compatibility::is_valid() ) {
86
+		if ( ! GravityView_Compatibility::is_valid() ) {
87 87
 			return;
88 88
 		}
89 89
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	private static function require_files() {
100 100
 		require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' );
101
-		require_once( GRAVITYVIEW_DIR . 'includes/class-common.php');
102
-		require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php');
101
+		require_once( GRAVITYVIEW_DIR . 'includes/class-common.php' );
102
+		require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php' );
103 103
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' );
104 104
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' );
105 105
 		require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' );
106
-		require_once( GRAVITYVIEW_DIR .'includes/class-admin.php' );
107
-		require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php');
108
-		require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php');
106
+		require_once( GRAVITYVIEW_DIR . 'includes/class-admin.php' );
107
+		require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php' );
108
+		require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php' );
109 109
 	}
110 110
 
111 111
 	/**
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 		}
139 139
 
140 140
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval-status.php' );
141
-		include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-approval.php' );
141
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-approval.php' );
142 142
 
143
-		include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' );
144
-		include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' );
143
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-notes.php' );
144
+		include_once( GRAVITYVIEW_DIR . 'includes/load-plugin-and-theme-hooks.php' );
145 145
 
146 146
 		// Load Extensions
147 147
 		// @todo: Convert to a scan of the directory or a method where this all lives
148
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' );
149
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' );
150
-		include_once( GRAVITYVIEW_DIR .'includes/extensions/entry-notes/class-gravityview-field-notes.php' );
148
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php' );
149
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php' );
150
+		include_once( GRAVITYVIEW_DIR . 'includes/extensions/entry-notes/class-gravityview-field-notes.php' );
151 151
 
152 152
 		// Load WordPress Widgets
153
-		include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' );
153
+		include_once( GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php' );
154 154
 
155 155
 		// Load GravityView Widgets
156
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' );
156
+		include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' );
157 157
 
158 158
 		// Add oEmbed
159 159
 		include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' );
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 		include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
167 167
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' );
168 168
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' );
169
-		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */
169
+		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php' ); /** @since 1.8.4 */
170 170
 		include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' );
171 171
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' );
172 172
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' );
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return bool
182 182
 	 */
183 183
 	public static function is_network_activated() {
184
-		return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) );
184
+		return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'gravityview/gravityview.php' ) );
185 185
 	}
186 186
 
187 187
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * @since 1.7.5.1
247 247
 	 */
248 248
 	public static function include_widget_class() {
249
-		include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' );
249
+		include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' );
250 250
 	}
251 251
 
252 252
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		}
269 269
 		if ( ! $loaded ) {
270 270
 			$locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' );
271
-			$mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo';
271
+			$mofile = dirname( __FILE__ ) . '/languages/gravityview-' . $locale . '.mo';
272 272
 			load_textdomain( 'gravityview', $mofile );
273 273
 		}
274 274
 
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function frontend_actions( $force = false ) {
301 301
 
302
-		if( self::is_admin() && ! $force ) { return; }
302
+		if ( self::is_admin() && ! $force ) { return; }
303 303
 
304 304
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' );
305
-		include_once( GRAVITYVIEW_DIR .'includes/class-template.php' );
306
-		include_once( GRAVITYVIEW_DIR .'includes/class-api.php' );
307
-		include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' );
305
+		include_once( GRAVITYVIEW_DIR . 'includes/class-template.php' );
306
+		include_once( GRAVITYVIEW_DIR . 'includes/class-api.php' );
307
+		include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' );
308 308
 		include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' );
309 309
 
310 310
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 */
330 330
 	public static function get_default_widget_areas() {
331 331
 		$default_areas = array(
332
-			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ),
333
-			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ),
332
+			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ),
333
+			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ),
334 334
 		);
335 335
 
336 336
 		/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * @param mixed $data Additional data to display
349 349
      * @return void
350 350
      */
351
-    public static function log_debug( $message, $data = null ){
351
+    public static function log_debug( $message, $data = null ) {
352 352
 	    /**
353 353
 	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
354 354
 	     * @param string $message Message to display
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
      * @param  string $message log message
363 363
      * @return void
364 364
      */
365
-    public static function log_error( $message, $data = null ){
365
+    public static function log_error( $message, $data = null ) {
366 366
 	    /**
367 367
 	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
368 368
 	     * @param string $message Error message to display
@@ -373,4 +373,4 @@  discard block
 block discarded – undo
373 373
 
374 374
 } // end class GravityView_Plugin
375 375
 
376
-add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1);
376
+add_action( 'plugins_loaded', array( 'GravityView_Plugin', 'getInstance' ), 1 );
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -312,8 +312,9 @@  discard block
 block discarded – undo
312 312
 	 */
313 313
 	public static function is_admin() {
314 314
 
315
-		if ( function_exists( 'gravityview' ) )
316
-			return gravityview()->request->is_admin();
315
+		if ( function_exists( 'gravityview' ) ) {
316
+					return gravityview()->request->is_admin();
317
+		}
317 318
 
318 319
 		$doing_ajax = defined( 'DOING_AJAX' ) ? DOING_AJAX : false;
319 320
 
@@ -382,7 +383,7 @@  discard block
 block discarded – undo
382 383
      * @param mixed $data Additional data to display
383 384
      * @return void
384 385
      */
385
-    public static function log_debug( $message, $data = null ){
386
+    public static function log_debug( $message, $data = null ) {
386 387
 	    /**
387 388
 	     * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
388 389
 	     * @param string $message Message to display
@@ -396,7 +397,7 @@  discard block
 block discarded – undo
396 397
      * @param  string $message log message
397 398
      * @return void
398 399
      */
399
-    public static function log_error( $message, $data = null ){
400
+    public static function log_error( $message, $data = null ) {
400 401
 	    /**
401 402
 	     * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output
402 403
 	     * @param string $message Error message to display
Please login to merge, or discard this patch.
includes/admin/field-types/type_hidden.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 			return;
16 16
 		}
17 17
 
18
-        $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
18
+		$class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
19 19
 
20 20
 		?>
21 21
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" />
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
 
11 11
 	function render_input( $override_input = null ) {
12 12
 
13
-		if( isset( $override_input ) ) {
13
+		if ( isset( $override_input ) ) {
14 14
 			echo $override_input;
15 15
 			return;
16 16
 		}
17 17
 
18
-        $class = !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
18
+        $class = ! empty( $this->field[ 'class' ] ) ? $this->field[ 'class' ] : 'widefat';
19 19
 
20 20
 		?>
21 21
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="hidden" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>" />
Please login to merge, or discard this patch.
includes/admin/field-types/type_number.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
 
19 19
 		$show_mt = $this->show_merge_tags();
20 20
 
21
-        if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
22
-            $class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
23
-        }
24
-        $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
21
+		if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
22
+			$class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
23
+		}
24
+		$class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
25 25
 
26 26
 		?>
27 27
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>">
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
  * number input type
4 4
  */
5 5
 
6
-if( !class_exists('GravityView_FieldType_text') ) {
6
+if ( ! class_exists( 'GravityView_FieldType_text' ) ) {
7 7
 	include_once( GRAVITYVIEW_DIR . 'includes/admin/field-types/type_text.php' );
8 8
 }
9 9
 class GravityView_FieldType_number extends GravityView_FieldType_text {
10 10
 
11 11
 	function render_input( $override_input = null ) {
12
-		if( isset( $override_input ) ) {
12
+		if ( isset( $override_input ) ) {
13 13
 			echo $override_input;
14 14
 			return;
15 15
 		}
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 
19 19
 		$show_mt = $this->show_merge_tags();
20 20
 
21
-        if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
21
+        if ( $show_mt && $this->field[ 'merge_tags' ] !== false || $this->field[ 'merge_tags' ] === 'force' ) {
22 22
             $class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
23 23
         }
24
-        $class .= !empty( $this->field['class'] ) ? $this->field['class'] : 'widefat';
24
+        $class .= ! empty( $this->field[ 'class' ] ) ? $this->field[ 'class' ] : 'widefat';
25 25
 
26 26
 		?>
27 27
 		<input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>" type="number" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>">
Please login to merge, or discard this patch.
includes/admin/metaboxes/class-gravityview-admin-metaboxes.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 		if( !GravityView_Compatibility::is_valid() ) { return; }
16 16
 
17
-        self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/';
17
+		self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/';
18 18
 
19 19
 		include_once self::$metaboxes_dir . 'class-gravityview-metabox-tab.php';
20 20
 
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 		$get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL;
229 229
 
230 230
 		if( isset( $form['id'] ) ) {
231
-		    $form_script = 'var form = ' . GFCommon::json_encode($form) . ';';
231
+			$form_script = 'var form = ' . GFCommon::json_encode($form) . ';';
232 232
 
233
-		    // The `gf_vars()` method needs a $_GET[id] variable set with the form ID.
234
-		    $_GET['id'] = $form['id'];
233
+			// The `gf_vars()` method needs a $_GET[id] variable set with the form ID.
234
+			$_GET['id'] = $form['id'];
235 235
 
236 236
 		} else {
237
-		    $form_script = 'var form = new Form();';
237
+			$form_script = 'var form = new Form();';
238 238
 		}
239 239
 
240 240
 		$output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>';
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	function __construct() {
19 19
 
20
-		if( !GravityView_Compatibility::is_valid() ) { return; }
20
+		if ( ! GravityView_Compatibility::is_valid() ) { return; }
21 21
 
22 22
         self::$metaboxes_dir = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/';
23 23
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	function initialize() {
37 37
 
38
-		add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' ));
38
+		add_action( 'add_meta_boxes', array( $this, 'register_metaboxes' ) );
39 39
 
40
-		add_action( 'add_meta_boxes_gravityview' , array( $this, 'update_priority' ) );
40
+		add_action( 'add_meta_boxes_gravityview', array( $this, 'update_priority' ) );
41 41
 
42 42
 		// information box
43 43
 		add_action( 'post_submitbox_misc_actions', array( $this, 'render_shortcode_hint' ) );
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 	function update_priority() {
52 52
 		global $wp_meta_boxes;
53 53
 
54
-		if( ! empty( $wp_meta_boxes['gravityview'] ) ) {
55
-			foreach( array( 'high', 'core', 'low' ) as $position ) {
56
-				if( isset( $wp_meta_boxes['gravityview']['normal'][ $position ] ) ) {
57
-					foreach( $wp_meta_boxes['gravityview']['normal'][ $position ] as $key => $meta_box ) {
58
-						if( ! preg_match( '/^gravityview_/ism', $key ) ) {
59
-							$wp_meta_boxes['gravityview']['advanced'][ $position ][ $key ] = $meta_box;
60
-							unset( $wp_meta_boxes['gravityview']['normal'][ $position ][ $key ] );
54
+		if ( ! empty( $wp_meta_boxes[ 'gravityview' ] ) ) {
55
+			foreach ( array( 'high', 'core', 'low' ) as $position ) {
56
+				if ( isset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] ) ) {
57
+					foreach ( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ] as $key => $meta_box ) {
58
+						if ( ! preg_match( '/^gravityview_/ism', $key ) ) {
59
+							$wp_meta_boxes[ 'gravityview' ][ 'advanced' ][ $position ][ $key ] = $meta_box;
60
+							unset( $wp_meta_boxes[ 'gravityview' ][ 'normal' ][ $position ][ $key ] );
61 61
 						}
62 62
 					}
63 63
 				}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		global $post;
70 70
 
71 71
 		// On Comment Edit, for example, $post isn't set.
72
-		if( empty( $post ) || !is_object( $post ) || !isset( $post->ID ) ) {
72
+		if ( empty( $post ) || ! is_object( $post ) || ! isset( $post->ID ) ) {
73 73
 			return;
74 74
 		}
75 75
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		 */
153 153
 		$metaboxes = apply_filters( 'gravityview/metaboxes/default', $metaboxes );
154 154
 
155
-		foreach( $metaboxes as $m ) {
155
+		foreach ( $metaboxes as $m ) {
156 156
 
157
-			$tab = new GravityView_Metabox_Tab( $m['id'], $m['title'], $m['file'], $m['icon-class'], $m['callback'], $m['callback_args'] );
157
+			$tab = new GravityView_Metabox_Tab( $m[ 'id' ], $m[ 'title' ], $m[ 'file' ], $m[ 'icon-class' ], $m[ 'callback' ], $m[ 'callback_args' ] );
158 158
 
159 159
 			GravityView_Metabox_Tabs::add( $tab );
160 160
 
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$links = GravityView_Admin_Views::get_connected_form_links( $current_form, false );
182 182
 
183
-		if( !empty( $links ) ) {
184
-			$links = '<span class="alignright gv-form-links">'. $links .'</span>';
183
+		if ( ! empty( $links ) ) {
184
+			$links = '<span class="alignright gv-form-links">' . $links . '</span>';
185 185
 		}
186 186
 
187 187
 		return __( 'Data Source', 'gravityview' ) . $links;
@@ -220,28 +220,28 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	public static function render_merge_tags_scripts( $curr_form ) {
222 222
 
223
-		if( empty( $curr_form )) {
223
+		if ( empty( $curr_form ) ) {
224 224
 			return NULL;
225 225
 		}
226 226
 
227 227
 		$form = gravityview_get_form( $curr_form );
228 228
 
229
-		$get_id_backup = isset($_GET['id']) ? $_GET['id'] : NULL;
229
+		$get_id_backup = isset( $_GET[ 'id' ] ) ? $_GET[ 'id' ] : NULL;
230 230
 
231
-		if( isset( $form['id'] ) ) {
232
-		    $form_script = 'var form = ' . GFCommon::json_encode($form) . ';';
231
+		if ( isset( $form[ 'id' ] ) ) {
232
+		    $form_script = 'var form = ' . GFCommon::json_encode( $form ) . ';';
233 233
 
234 234
 		    // The `gf_vars()` method needs a $_GET[id] variable set with the form ID.
235
-		    $_GET['id'] = $form['id'];
235
+		    $_GET[ 'id' ] = $form[ 'id' ];
236 236
 
237 237
 		} else {
238 238
 		    $form_script = 'var form = new Form();';
239 239
 		}
240 240
 
241
-		$output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars(false) . '</script>';
241
+		$output = '<script type="text/javascript" data-gv-merge-tags="1">' . $form_script . "\n" . GFCommon::gf_vars( false ) . '</script>';
242 242
 
243 243
 		// Restore previous $_GET setting
244
-		$_GET['id'] = $get_id_backup;
244
+		$_GET[ 'id' ] = $get_id_backup;
245 245
 
246 246
 		return $output;
247 247
 	}
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 		global $post;
298 298
 
299 299
 		// Only show this on GravityView post types.
300
-		if( false === gravityview_is_admin_page() ) { return; }
300
+		if ( false === gravityview_is_admin_page() ) { return; }
301 301
 
302 302
 		// If the View hasn't been configured yet, don't show embed shortcode
303
-		if( !gravityview_get_directory_fields( $post->ID ) ) { return; }
303
+		if ( ! gravityview_get_directory_fields( $post->ID ) ) { return; }
304 304
 
305 305
 		include self::$metaboxes_dir . 'views/shortcode-hint.php';
306 306
 	}
Please login to merge, or discard this patch.