@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @since 1.15 |
| 29 | 29 | * @param bool|false $mixed |
| 30 | 30 | * |
| 31 | - * @return bool |
|
| 31 | + * @return boolean|null |
|
| 32 | 32 | */ |
| 33 | 33 | private function _exit( $mixed = NULL ) { |
| 34 | 34 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * Import Gravity Form XML or JSON |
| 201 | 201 | * |
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
| 203 | - * @return int|bool Imported form ID or false |
|
| 203 | + * @return false|string Imported form ID or false |
|
| 204 | 204 | */ |
| 205 | 205 | function import_form( $xml_or_json_path = '' ) { |
| 206 | 206 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | // template areas |
| 140 | 140 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
| 141 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 141 | + $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 142 | 142 | |
| 143 | 143 | // widget areas |
| 144 | 144 | $default_widget_areas = \GV\Widget::get_default_widget_areas(); |
@@ -331,40 +331,40 @@ discard block |
||
| 331 | 331 | // load file |
| 332 | 332 | $xmlstr = file_get_contents( $form_file ); |
| 333 | 333 | |
| 334 | - $options = array( |
|
| 335 | - "page" => array("unserialize_as_array" => true), |
|
| 336 | - "form"=> array("unserialize_as_array" => true), |
|
| 337 | - "field"=> array("unserialize_as_array" => true), |
|
| 338 | - "rule"=> array("unserialize_as_array" => true), |
|
| 339 | - "choice"=> array("unserialize_as_array" => true), |
|
| 340 | - "input"=> array("unserialize_as_array" => true), |
|
| 341 | - "routing_item"=> array("unserialize_as_array" => true), |
|
| 342 | - "creditCard"=> array("unserialize_as_array" => true), |
|
| 343 | - "routin"=> array("unserialize_as_array" => true), |
|
| 344 | - "confirmation" => array("unserialize_as_array" => true), |
|
| 345 | - "notification" => array("unserialize_as_array" => true) |
|
| 346 | - ); |
|
| 334 | + $options = array( |
|
| 335 | + "page" => array("unserialize_as_array" => true), |
|
| 336 | + "form"=> array("unserialize_as_array" => true), |
|
| 337 | + "field"=> array("unserialize_as_array" => true), |
|
| 338 | + "rule"=> array("unserialize_as_array" => true), |
|
| 339 | + "choice"=> array("unserialize_as_array" => true), |
|
| 340 | + "input"=> array("unserialize_as_array" => true), |
|
| 341 | + "routing_item"=> array("unserialize_as_array" => true), |
|
| 342 | + "creditCard"=> array("unserialize_as_array" => true), |
|
| 343 | + "routin"=> array("unserialize_as_array" => true), |
|
| 344 | + "confirmation" => array("unserialize_as_array" => true), |
|
| 345 | + "notification" => array("unserialize_as_array" => true) |
|
| 346 | + ); |
|
| 347 | 347 | |
| 348 | 348 | $xml = new RGXML($options); |
| 349 | - $forms = $xml->unserialize($xmlstr); |
|
| 349 | + $forms = $xml->unserialize($xmlstr); |
|
| 350 | 350 | |
| 351 | - if( !$forms ) { |
|
| 352 | - gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
|
| 353 | - return false; |
|
| 354 | - } |
|
| 351 | + if( !$forms ) { |
|
| 352 | + gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
|
| 353 | + return false; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 357 | - $form = $forms[0]; |
|
| 358 | - } |
|
| 356 | + if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 357 | + $form = $forms[0]; |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if( empty( $form ) ) { |
|
| 361 | - gravityview()->log->error( '$form not set.', array( 'data' => $forms ) ); |
|
| 362 | - return false; |
|
| 363 | - } |
|
| 360 | + if( empty( $form ) ) { |
|
| 361 | + gravityview()->log->error( '$form not set.', array( 'data' => $forms ) ); |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - gravityview()->log->debug( '[pre_get_available_fields] Importing Form Fields for preset [{template_id}]. (Form)', array( 'template_id' => $template_id, 'data' => $form ) ); |
|
| 365 | + gravityview()->log->debug( '[pre_get_available_fields] Importing Form Fields for preset [{template_id}]. (Form)', array( 'template_id' => $template_id, 'data' => $form ) ); |
|
| 366 | 366 | |
| 367 | - return $form; |
|
| 367 | + return $form; |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Don't exit if we're running test suite. |
| 37 | 37 | * @since 1.15 |
| 38 | 38 | */ |
| 39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 39 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 40 | 40 | return $mixed; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function check_ajax_nonce() { |
| 53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
| 53 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxviews' ) ) { |
|
| 54 | 54 | $this->_exit( false ); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | //check nonce |
| 68 | 68 | $this->check_ajax_nonce(); |
| 69 | 69 | |
| 70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
| 70 | + $context = isset( $_POST[ 'context' ] ) ? esc_attr( $_POST[ 'context' ] ) : 'directory'; |
|
| 71 | 71 | |
| 72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
| 73 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
| 73 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 74 | + do_action( 'gravityview_render_available_fields', (int)$_POST[ 'form_id' ], $context ); |
|
| 75 | 75 | $this->_exit(); |
| 76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
| 77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 76 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 77 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 78 | 78 | |
| 79 | 79 | /** @see GravityView_Admin_Views::render_available_fields */ |
| 80 | 80 | do_action( 'gravityview_render_available_fields', $form, $context ); |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | function get_active_areas() { |
| 97 | 97 | $this->check_ajax_nonce(); |
| 98 | 98 | |
| 99 | - if( empty( $_POST['template_id'] ) ) { |
|
| 99 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 100 | 100 | $this->_exit( false ); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | ob_start(); |
| 104 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 105 | - $response['directory'] = ob_get_clean(); |
|
| 104 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true ); |
|
| 105 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 106 | 106 | |
| 107 | 107 | ob_start(); |
| 108 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 109 | - $response['single'] = ob_get_clean(); |
|
| 108 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true ); |
|
| 109 | + $response[ 'single' ] = ob_get_clean(); |
|
| 110 | 110 | |
| 111 | 111 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 112 | 112 | |
@@ -121,20 +121,20 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $this->check_ajax_nonce(); |
| 123 | 123 | |
| 124 | - if( empty( $_POST['template_id'] ) ) { |
|
| 124 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 125 | 125 | $this->_exit( false ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // get the fields xml config file for this specific preset |
| 129 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 129 | + $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] ); |
|
| 130 | 130 | // import fields |
| 131 | - if( !empty( $preset_fields_path ) ) { |
|
| 131 | + if ( ! empty( $preset_fields_path ) ) { |
|
| 132 | 132 | $presets = $this->import_fields( $preset_fields_path ); |
| 133 | 133 | } else { |
| 134 | 134 | $presets = array( 'widgets' => array(), 'fields' => array() ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 137 | + $template_id = esc_attr( $_POST[ 'template_id' ] ); |
|
| 138 | 138 | |
| 139 | 139 | // template areas |
| 140 | 140 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
@@ -144,20 +144,20 @@ discard block |
||
| 144 | 144 | $default_widget_areas = \GV\Widget::get_default_widget_areas(); |
| 145 | 145 | |
| 146 | 146 | ob_start(); |
| 147 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 148 | - $response['header'] = ob_get_clean(); |
|
| 147 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 148 | + $response[ 'header' ] = ob_get_clean(); |
|
| 149 | 149 | |
| 150 | 150 | ob_start(); |
| 151 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 152 | - $response['footer'] = ob_get_clean(); |
|
| 151 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 152 | + $response[ 'footer' ] = ob_get_clean(); |
|
| 153 | 153 | |
| 154 | 154 | ob_start(); |
| 155 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 156 | - $response['directory'] = ob_get_clean(); |
|
| 155 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] ); |
|
| 156 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 157 | 157 | |
| 158 | 158 | ob_start(); |
| 159 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 160 | - $response['single'] = ob_get_clean(); |
|
| 159 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] ); |
|
| 160 | + $response[ 'single' ] = ob_get_clean(); |
|
| 161 | 161 | |
| 162 | 162 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 163 | 163 | |
@@ -175,26 +175,26 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $this->check_ajax_nonce(); |
| 177 | 177 | |
| 178 | - if( empty( $_POST['template_id'] ) ) { |
|
| 178 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 179 | 179 | gravityview()->log->error( 'Cannot create preset form; the template_id is empty.' ); |
| 180 | 180 | $this->_exit( false ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // get the xml for this specific template_id |
| 184 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 184 | + $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] ); |
|
| 185 | 185 | |
| 186 | 186 | // import form |
| 187 | 187 | $form = $this->import_form( $preset_form_xml_path ); |
| 188 | 188 | |
| 189 | 189 | // get the form ID |
| 190 | - if( false === $form ) { |
|
| 190 | + if ( false === $form ) { |
|
| 191 | 191 | // send error to user |
| 192 | - gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int) $_POST['template_id'] ) ); |
|
| 192 | + gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int)$_POST[ 'template_id' ] ) ); |
|
| 193 | 193 | |
| 194 | 194 | $this->_exit( false ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 197 | + $this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' ); |
|
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | gravityview()->log->debug( '[import_form] Import Preset Form. (File) {path}', array( 'path' => $xml_or_json_path ) ); |
| 210 | 210 | |
| 211 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 211 | + if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) { |
|
| 212 | 212 | gravityview()->log->error( 'Class GFExport or file not found. file: {path}', array( 'path' => $xml_or_json_path ) ); |
| 213 | 213 | return false; |
| 214 | 214 | } |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | gravityview()->log->debug( '[import_form] Importing form (Result) {count}', array( 'count' => $count ) ); |
| 221 | 221 | gravityview()->log->debug( '[import_form] Importing form (Form) ', array( 'data' => $forms ) ); |
| 222 | 222 | |
| 223 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 223 | + if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) { |
|
| 224 | 224 | gravityview()->log->error( 'Form Import Failed!' ); |
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // import success - return form id |
| 229 | - return $forms[0]; |
|
| 229 | + return $forms[ 0 ]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | function get_field_options() { |
| 241 | 241 | $this->check_ajax_nonce(); |
| 242 | 242 | |
| 243 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 243 | + if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) { |
|
| 244 | 244 | gravityview()->log->error( 'Required fields were not set in the $_POST request. ' ); |
| 245 | 245 | $this->_exit( false ); |
| 246 | 246 | } |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | $_post = array_map( 'esc_attr', $_post ); |
| 253 | 253 | |
| 254 | 254 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 255 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 256 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 255 | + $input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL; |
|
| 256 | + $context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL; |
|
| 257 | 257 | |
| 258 | - $form_id = empty( $_post['form_id'] ) ? null : $_post['form_id']; |
|
| 259 | - $response = GravityView_Render_Settings::render_field_options( $form_id, $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
| 258 | + $form_id = empty( $_post[ 'form_id' ] ) ? null : $_post[ 'form_id' ]; |
|
| 259 | + $response = GravityView_Render_Settings::render_field_options( $form_id, $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context ); |
|
| 260 | 260 | |
| 261 | 261 | $response = gravityview_strip_whitespace( $response ); |
| 262 | 262 | |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | $form = ''; |
| 278 | 278 | |
| 279 | 279 | // if form id is set, use it, else, get form from preset |
| 280 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 280 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 281 | 281 | |
| 282 | - $form = (int) $_POST['form_id']; |
|
| 282 | + $form = (int)$_POST[ 'form_id' ]; |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | // get form from preset |
| 286 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 286 | + elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 287 | 287 | |
| 288 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 288 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 289 | 289 | |
| 290 | 290 | } |
| 291 | 291 | |
@@ -301,27 +301,27 @@ discard block |
||
| 301 | 301 | * @param string $template_id Preset template |
| 302 | 302 | * |
| 303 | 303 | */ |
| 304 | - static function pre_get_form_fields( $template_id = '') { |
|
| 304 | + static function pre_get_form_fields( $template_id = '' ) { |
|
| 305 | 305 | |
| 306 | - if( empty( $template_id ) ) { |
|
| 306 | + if ( empty( $template_id ) ) { |
|
| 307 | 307 | gravityview()->log->error( 'Template ID not set.' ); |
| 308 | 308 | return false; |
| 309 | 309 | } else { |
| 310 | 310 | $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
| 311 | - if( !file_exists( $form_file ) ) { |
|
| 311 | + if ( ! file_exists( $form_file ) ) { |
|
| 312 | 312 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. File not found. file: {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 313 | 313 | return false; |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Load xml parser (from GravityForms) |
| 318 | - if( class_exists( 'GFCommon' ) ) { |
|
| 318 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 319 | 319 | $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
| 320 | 320 | } else { |
| 321 | 321 | $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if( file_exists( $xml_parser ) ) { |
|
| 324 | + if ( file_exists( $xml_parser ) ) { |
|
| 325 | 325 | require_once( $xml_parser ); |
| 326 | 326 | } else { |
| 327 | 327 | gravityview()->log->debug( ' - Gravity Forms XML Parser not found {path}.', array( 'path' => $xml_parser ) ); |
@@ -332,32 +332,32 @@ discard block |
||
| 332 | 332 | $xmlstr = file_get_contents( $form_file ); |
| 333 | 333 | |
| 334 | 334 | $options = array( |
| 335 | - "page" => array("unserialize_as_array" => true), |
|
| 336 | - "form"=> array("unserialize_as_array" => true), |
|
| 337 | - "field"=> array("unserialize_as_array" => true), |
|
| 338 | - "rule"=> array("unserialize_as_array" => true), |
|
| 339 | - "choice"=> array("unserialize_as_array" => true), |
|
| 340 | - "input"=> array("unserialize_as_array" => true), |
|
| 341 | - "routing_item"=> array("unserialize_as_array" => true), |
|
| 342 | - "creditCard"=> array("unserialize_as_array" => true), |
|
| 343 | - "routin"=> array("unserialize_as_array" => true), |
|
| 344 | - "confirmation" => array("unserialize_as_array" => true), |
|
| 345 | - "notification" => array("unserialize_as_array" => true) |
|
| 335 | + "page" => array( "unserialize_as_array" => true ), |
|
| 336 | + "form"=> array( "unserialize_as_array" => true ), |
|
| 337 | + "field"=> array( "unserialize_as_array" => true ), |
|
| 338 | + "rule"=> array( "unserialize_as_array" => true ), |
|
| 339 | + "choice"=> array( "unserialize_as_array" => true ), |
|
| 340 | + "input"=> array( "unserialize_as_array" => true ), |
|
| 341 | + "routing_item"=> array( "unserialize_as_array" => true ), |
|
| 342 | + "creditCard"=> array( "unserialize_as_array" => true ), |
|
| 343 | + "routin"=> array( "unserialize_as_array" => true ), |
|
| 344 | + "confirmation" => array( "unserialize_as_array" => true ), |
|
| 345 | + "notification" => array( "unserialize_as_array" => true ) |
|
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | - $xml = new RGXML($options); |
|
| 349 | - $forms = $xml->unserialize($xmlstr); |
|
| 348 | + $xml = new RGXML( $options ); |
|
| 349 | + $forms = $xml->unserialize( $xmlstr ); |
|
| 350 | 350 | |
| 351 | - if( !$forms ) { |
|
| 351 | + if ( ! $forms ) { |
|
| 352 | 352 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 357 | - $form = $forms[0]; |
|
| 356 | + if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) { |
|
| 357 | + $form = $forms[ 0 ]; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if( empty( $form ) ) { |
|
| 360 | + if ( empty( $form ) ) { |
|
| 361 | 361 | gravityview()->log->error( '$form not set.', array( 'data' => $forms ) ); |
| 362 | 362 | return false; |
| 363 | 363 | } |
@@ -376,38 +376,38 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | function import_fields( $file ) { |
| 378 | 378 | |
| 379 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 379 | + if ( empty( $file ) || ! file_exists( $file ) ) { |
|
| 380 | 380 | gravityview()->log->error( 'Importing Preset Fields. File not found. (File) {path}', array( 'path' => $file ) ); |
| 381 | 381 | return false; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if( !class_exists('WXR_Parser') ) { |
|
| 384 | + if ( ! class_exists( 'WXR_Parser' ) ) { |
|
| 385 | 385 | include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | $parser = new WXR_Parser(); |
| 389 | 389 | $presets = $parser->parse( $file ); |
| 390 | 390 | |
| 391 | - if(is_wp_error( $presets )) { |
|
| 391 | + if ( is_wp_error( $presets ) ) { |
|
| 392 | 392 | gravityview()->log->error( 'Importing Preset Fields failed. Threw WP_Error.', array( 'data' => $presets ) ); |
| 393 | 393 | return false; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 396 | + if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) { |
|
| 397 | 397 | gravityview()->log->error( 'Importing Preset Fields failed. Meta not found in file. {path}', array( 'path' => $file ) ); |
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets['posts'][0]['postmeta'] ) ); |
|
| 401 | + gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ); |
|
| 402 | 402 | |
| 403 | 403 | $fields = $widgets = array(); |
| 404 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 405 | - switch ($meta['key']) { |
|
| 404 | + foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) { |
|
| 405 | + switch ( $meta[ 'key' ] ) { |
|
| 406 | 406 | case '_gravityview_directory_fields': |
| 407 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 407 | + $fields = maybe_unserialize( $meta[ 'value' ] ); |
|
| 408 | 408 | break; |
| 409 | 409 | case '_gravityview_directory_widgets': |
| 410 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 410 | + $widgets = maybe_unserialize( $meta[ 'value' ] ); |
|
| 411 | 411 | break; |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -195,7 +195,7 @@ |
||
| 195 | 195 | * |
| 196 | 196 | * @since 1.6 |
| 197 | 197 | * |
| 198 | - * @param int $new_view_id The ID of the newly created View |
|
| 198 | + * @param int $new_id The ID of the newly created View |
|
| 199 | 199 | * @param WP_Post $post The View that was just cloned |
| 200 | 200 | * |
| 201 | 201 | * @return void |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | function __construct() { |
| 16 | 16 | |
| 17 | 17 | // Only run on Admin |
| 18 | - if ( !is_admin() ) { |
|
| 18 | + if ( ! is_admin() ) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // If the Duplicate Post plugin is active, don't run. |
| 23 | - if( defined('DUPLICATE_POST_CURRENT_VERSION') ) { |
|
| 23 | + if ( defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) { |
|
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | global $post; |
| 61 | 61 | |
| 62 | 62 | // We only want to add Clone links to the Edit View metabox |
| 63 | - if( !$this->is_all_views_page() ) { |
|
| 63 | + if ( ! $this->is_all_views_page() ) { |
|
| 64 | 64 | |
| 65 | - if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
| 66 | - $links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>'; |
|
| 65 | + if ( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
| 66 | + $links[ ] = '<span>' . $duplicate_links[ 'edit_as_new_draft' ] . '</span>'; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param string|null If string, the status to set for the new View. If empty, use existing View status. |
| 124 | 124 | * @param WP_Post $post View being cloned |
| 125 | 125 | */ |
| 126 | - $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post ); |
|
| 126 | + $new_view_status = apply_filters( 'gravityview/duplicate-view/status', $status, $post ); |
|
| 127 | 127 | |
| 128 | 128 | $new_view = array( |
| 129 | 129 | 'menu_order' => $post->menu_order, |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false` |
| 147 | 147 | * @param WP_Post $post View being cloned |
| 148 | 148 | */ |
| 149 | - $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post ); |
|
| 149 | + $copy_date = apply_filters( 'gravityview/duplicate-view/copy-date', false, $post ); |
|
| 150 | 150 | |
| 151 | 151 | if ( $copy_date ) { |
| 152 | - $new_view['post_date'] = $new_post_date = $post->post_date; |
|
| 153 | - $new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date ); |
|
| 152 | + $new_view[ 'post_date' ] = $new_post_date = $post->post_date; |
|
| 153 | + $new_view[ 'post_date_gmt' ] = get_gmt_from_date( $new_post_date ); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param array $new_view Array of settings to be passed to wp_insert_post() |
| 160 | 160 | * @param WP_Post $post View being cloned |
| 161 | 161 | */ |
| 162 | - $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post ); |
|
| 162 | + $new_view = apply_filters( 'gravityview/duplicate-view/new-view', $new_view, $post ); |
|
| 163 | 163 | |
| 164 | 164 | // Magic happens here. |
| 165 | 165 | $new_view_id = wp_insert_post( $new_view ); |
@@ -241,13 +241,13 @@ discard block |
||
| 241 | 241 | $clone_text = __( 'Clone', 'gravityview' ); |
| 242 | 242 | $clone_title = __( 'Clone this View', 'gravityview' ); |
| 243 | 243 | |
| 244 | - $actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title ); |
|
| 244 | + $actions[ 'clone' ] = gravityview_get_link( $clone_link, $clone_text, 'title=' . $clone_title ); |
|
| 245 | 245 | |
| 246 | 246 | $clone_draft_link = $this->get_clone_view_link( $post->ID ); |
| 247 | 247 | $clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' ); |
| 248 | 248 | $clone_draft_title = __( 'Copy as a new draft View', 'gravityview' ); |
| 249 | 249 | |
| 250 | - $actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title ); |
|
| 250 | + $actions[ 'edit_as_new_draft' ] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title=' . $clone_draft_title ); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | return $actions; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Verify the View exists |
| 274 | - if ( !$view = get_post( $id ) ) { |
|
| 274 | + if ( ! $view = get_post( $id ) ) { |
|
| 275 | 275 | return ''; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $post_type_object = get_post_type_object( $view->post_type ); |
| 287 | 287 | |
| 288 | 288 | /** If there's no gravityview post type for some reason, abort! */ |
| 289 | - if ( !$post_type_object ) { |
|
| 289 | + if ( ! $post_type_object ) { |
|
| 290 | 290 | gravityview()->log->error( 'No gravityview post type exists when trying to clone the View.', array( 'data' => $view ) ); |
| 291 | 291 | return ''; |
| 292 | 292 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * @param int $view_id View ID |
| 299 | 299 | * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display` |
| 300 | 300 | */ |
| 301 | - $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context ); |
|
| 301 | + $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php" . $action ), $view->ID, $context ); |
|
| 302 | 302 | |
| 303 | 303 | return $clone_view_link; |
| 304 | 304 | } |
@@ -325,14 +325,14 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function save_as_new_view( $status = '' ) { |
| 327 | 327 | |
| 328 | - if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) { |
|
| 328 | + if ( ! ( isset( $_GET[ 'post' ] ) || isset( $_POST[ 'post' ] ) ) ) { |
|
| 329 | 329 | wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) ); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Get the original post |
| 333 | - $id = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] ); |
|
| 333 | + $id = ( isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : $_POST[ 'post' ] ); |
|
| 334 | 334 | |
| 335 | - if( ! $this->current_user_can_copy( $id ) ) { |
|
| 335 | + if ( ! $this->current_user_can_copy( $id ) ) { |
|
| 336 | 336 | wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) ); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @since 1.12 |
| 119 | - * @return bool |
|
| 119 | + * @return boolean|null |
|
| 120 | 120 | */ |
| 121 | 121 | private function add_fallback_shortcode() { |
| 122 | 122 | |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | self::$notices['wp_version'] = array( |
| 205 | 205 | 'class' => 'error', |
| 206 | 206 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
| 207 | - 'cap' => 'update_core', |
|
| 207 | + 'cap' => 'update_core', |
|
| 208 | 208 | 'dismiss' => 'wp_version', |
| 209 | 209 | ); |
| 210 | 210 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @return GravityView_Compatibility |
| 77 | 77 | */ |
| 78 | 78 | public static function getInstance() { |
| 79 | - if( self::$instance ) { |
|
| 79 | + if ( self::$instance ) { |
|
| 80 | 80 | return self::$instance; |
| 81 | 81 | } |
| 82 | 82 | return new self; |
@@ -138,10 +138,10 @@ discard block |
||
| 138 | 138 | // If Gravity Forms doesn't exist or is outdated, load the admin view class to |
| 139 | 139 | // show the notice, but not load any post types or process shortcodes. |
| 140 | 140 | // Without Gravity Forms, there is no GravityView. Beautiful, really. |
| 141 | - if( ! self::is_valid() ) { |
|
| 141 | + if ( ! self::is_valid() ) { |
|
| 142 | 142 | |
| 143 | 143 | // If the plugin's not loaded, might as well hide the shortcode for people. |
| 144 | - add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') ); |
|
| 144 | + add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) ); |
|
| 145 | 145 | |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -167,15 +167,15 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) { |
| 169 | 169 | |
| 170 | - if( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
| 170 | + if ( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
| 171 | 171 | return null; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $notices = self::get_notices(); |
| 175 | 175 | |
| 176 | - $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>'; |
|
| 177 | - foreach( (array)$notices as $notice ) { |
|
| 178 | - $message .= wpautop( $notice['message'] ); |
|
| 176 | + $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview' ) . '</em></p>'; |
|
| 177 | + foreach ( (array)$notices as $notice ) { |
|
| 178 | + $message .= wpautop( $notice[ 'message' ] ); |
|
| 179 | 179 | } |
| 180 | 180 | $message .= '</div>'; |
| 181 | 181 | |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | if ( ! gravityview()->plugin->is_compatible_php() ) { |
| 197 | 197 | |
| 198 | - self::$notices['php_version'] = array( |
|
| 198 | + self::$notices[ 'php_version' ] = array( |
|
| 199 | 199 | 'class' => 'error', |
| 200 | - 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
| 200 | + 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ), |
|
| 201 | 201 | 'cap' => 'manage_options', |
| 202 | 202 | 'dismiss' => 'php_version', |
| 203 | 203 | ); |
@@ -208,11 +208,11 @@ discard block |
||
| 208 | 208 | if ( ! gravityview()->plugin->is_compatible_future_php() ) { |
| 209 | 209 | |
| 210 | 210 | // Show the notice on every update. Yes, annoying, but not as annoying as a plugin breaking. |
| 211 | - $key = sprintf('php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version ); |
|
| 211 | + $key = sprintf( 'php_%s_%s', GV_FUTURE_MIN_PHP_VERSION, GravityView_Plugin::version ); |
|
| 212 | 212 | |
| 213 | 213 | self::$notices[ $key ] = array( |
| 214 | 214 | 'class' => 'error', |
| 215 | - 'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
| 215 | + 'message' => sprintf( __( "%sGravityView will soon require PHP Version %s.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_FUTURE_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ), |
|
| 216 | 216 | 'cap' => 'manage_options', |
| 217 | 217 | 'dismiss' => $key, |
| 218 | 218 | ); |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | if ( ! gravityview()->plugin->is_compatible_wordpress() ) { |
| 235 | 235 | |
| 236 | - self::$notices['wp_version'] = array( |
|
| 236 | + self::$notices[ 'wp_version' ] = array( |
|
| 237 | 237 | 'class' => 'error', |
| 238 | - 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
|
| 238 | + 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $wp_version . '</span>' ), |
|
| 239 | 239 | 'cap' => 'update_core', |
| 240 | 240 | 'dismiss' => 'wp_version', |
| 241 | 241 | ); |
@@ -258,17 +258,17 @@ discard block |
||
| 258 | 258 | public static function check_gravityforms() { |
| 259 | 259 | |
| 260 | 260 | // Bypass other checks: if the class exists |
| 261 | - if( class_exists( 'GFCommon' ) ) { |
|
| 261 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 262 | 262 | |
| 263 | 263 | // Does the version meet future requirements? |
| 264 | - if( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) { |
|
| 264 | + if ( true === version_compare( GFCommon::$version, GV_FUTURE_MIN_GF_VERSION, ">=" ) ) { |
|
| 265 | 265 | return true; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Does it meet minimum requirements? |
| 269 | 269 | $meets_minimum = gravityview()->plugin->is_compatible_gravityforms(); |
| 270 | 270 | |
| 271 | - if( $meets_minimum ) { |
|
| 271 | + if ( $meets_minimum ) { |
|
| 272 | 272 | /* translators: first placeholder is the future required version of Gravity Forms. The second placeholder is the current version of Gravity Forms. */ |
| 273 | 273 | $title = __( 'In the future, GravityView will require Gravity Forms Version %s or newer.', 'gravityview' ); |
| 274 | 274 | $version = GV_FUTURE_MIN_GF_VERSION; |
@@ -283,14 +283,14 @@ discard block |
||
| 283 | 283 | $message = '<h3>' . esc_html( sprintf( $title, $version ) ) . '</h3>'; |
| 284 | 284 | |
| 285 | 285 | /* translators: the placeholder is the current version of Gravity Forms. */ |
| 286 | - $message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>' ) . '</p>'; |
|
| 286 | + $message .= '<p>' . sprintf( esc_html__( "You're using Version %s. Please update your Gravity Forms or purchase a license.", 'gravityview' ), '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>' ) . '</p>'; |
|
| 287 | 287 | |
| 288 | 288 | /* translators: In this context, "get" means purchase */ |
| 289 | 289 | $message .= '<p><a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' . esc_html__( 'Get the Latest Gravity Forms', 'gravityview' ) . '</a></p>'; |
| 290 | 290 | |
| 291 | 291 | |
| 292 | 292 | // Show the notice even if the future version requirements aren't met |
| 293 | - self::$notices['gf_version'] = array( |
|
| 293 | + self::$notices[ 'gf_version' ] = array( |
|
| 294 | 294 | 'class' => $class, |
| 295 | 295 | 'message' => $message, |
| 296 | 296 | 'cap' => 'update_plugins', |
@@ -308,42 +308,42 @@ discard block |
||
| 308 | 308 | * OR |
| 309 | 309 | * It's the Network Admin and we just don't know whether the sites have GF activated themselves. |
| 310 | 310 | */ |
| 311 | - if( true === $gf_status || is_network_admin() ) { |
|
| 311 | + if ( true === $gf_status || is_network_admin() ) { |
|
| 312 | 312 | return true; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | // If GFCommon doesn't exist, assume GF not active |
| 316 | 316 | $return = false; |
| 317 | 317 | |
| 318 | - switch( $gf_status ) { |
|
| 318 | + switch ( $gf_status ) { |
|
| 319 | 319 | case 'inactive': |
| 320 | 320 | |
| 321 | 321 | // Required for multisite |
| 322 | - if( ! function_exists('wp_create_nonce') ) { |
|
| 322 | + if ( ! function_exists( 'wp_create_nonce' ) ) { |
|
| 323 | 323 | require_once ABSPATH . WPINC . '/pluggable.php'; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" |
| 327 | - if( is_multisite() ) { |
|
| 327 | + if ( is_multisite() ) { |
|
| 328 | 328 | wp_cookie_constants(); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | $return = false; |
| 332 | 332 | |
| 333 | - $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; |
|
| 333 | + $button = function_exists( 'is_network_admin' ) && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="' . wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php' ) . '" class="button button-large">'; |
|
| 334 | 334 | |
| 335 | - self::$notices['gf_inactive'] = array( |
|
| 335 | + self::$notices[ 'gf_inactive' ] = array( |
|
| 336 | 336 | 'class' => 'error', |
| 337 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ), |
|
| 337 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n" . $button, '</a></strong>' ), |
|
| 338 | 338 | 'cap' => 'activate_plugins', |
| 339 | 339 | 'dismiss' => 'gf_inactive', |
| 340 | 340 | ); |
| 341 | 341 | |
| 342 | 342 | break; |
| 343 | 343 | default: |
| 344 | - self::$notices['gf_installed'] = array( |
|
| 344 | + self::$notices[ 'gf_installed' ] = array( |
|
| 345 | 345 | 'class' => 'error', |
| 346 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
| 346 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $59%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="https://gravityview.co/gravityforms/" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ), |
|
| 347 | 347 | 'cap' => 'install_plugins', |
| 348 | 348 | 'dismiss' => 'gf_installed', |
| 349 | 349 | ); |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | private static function check_gf_directory() { |
| 362 | 362 | |
| 363 | - if( class_exists( 'GFDirectory' ) ) { |
|
| 364 | - self::$notices['gf_directory'] = array( |
|
| 363 | + if ( class_exists( 'GFDirectory' ) ) { |
|
| 364 | + self::$notices[ 'gf_directory' ] = array( |
|
| 365 | 365 | 'class' => 'error is-dismissible', |
| 366 | - 'title' => __('Potential Conflict', 'gravityview' ), |
|
| 366 | + 'title' => __( 'Potential Conflict', 'gravityview' ), |
|
| 367 | 367 | 'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ), |
| 368 | 368 | 'dismiss' => 'gf_directory', |
| 369 | 369 | 'cap' => 'activate_plugins', |
@@ -382,21 +382,21 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public static function get_plugin_status( $location = '' ) { |
| 384 | 384 | |
| 385 | - if( ! function_exists('is_plugin_active') ) { |
|
| 385 | + if ( ! function_exists( 'is_plugin_active' ) ) { |
|
| 386 | 386 | include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
| 389 | + if ( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
| 390 | 390 | return true; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( !is_network_admin() && is_plugin_active( $location ) ) { |
|
| 393 | + if ( ! is_network_admin() && is_plugin_active( $location ) ) { |
|
| 394 | 394 | return true; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if( |
|
| 398 | - !file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
| 399 | - !file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
| 397 | + if ( |
|
| 398 | + ! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
| 399 | + ! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
| 400 | 400 | ) { |
| 401 | 401 | return false; |
| 402 | 402 | } |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 1.15 |
| 223 | 223 | * |
| 224 | - * @param string|null $content Content inside shortcode, if defined |
|
| 225 | 224 | * |
| 226 | 225 | * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false. |
| 227 | 226 | */ |
@@ -316,7 +315,7 @@ discard block |
||
| 316 | 315 | * |
| 317 | 316 | * @since 1.15 |
| 318 | 317 | * |
| 319 | - * @param string $href URL |
|
| 318 | + * @param string|null $url |
|
| 320 | 319 | */ |
| 321 | 320 | private function maybe_add_field_values_query_args( $url ) { |
| 322 | 321 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $atts = shortcode_atts( self::$defaults, $atts ); |
| 77 | 77 | |
| 78 | - $atts['action'] = 'edit'; |
|
| 78 | + $atts[ 'action' ] = 'edit'; |
|
| 79 | 79 | |
| 80 | 80 | return $this->shortcode( $atts, $content, $context ); |
| 81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $atts = shortcode_atts( self::$defaults, $atts ); |
| 93 | 93 | |
| 94 | - $atts['action'] = 'delete'; |
|
| 94 | + $atts[ 'action' ] = 'delete'; |
|
| 95 | 95 | |
| 96 | 96 | return $this->shortcode( $atts, $content, $context ); |
| 97 | 97 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
| 133 | 133 | |
| 134 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
| 134 | + $this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] ); |
|
| 135 | 135 | |
| 136 | 136 | if ( empty( $this->view_id ) ) { |
| 137 | 137 | gravityview()->log->error( 'A View ID was not defined and we are not inside a View' ); |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | return null; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
| 142 | + $this->entry = $this->get_entry( $this->settings[ 'entry_id' ] ); |
|
| 143 | 143 | |
| 144 | 144 | if ( empty( $this->entry ) ) { |
| 145 | - gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings['entry_id'] ) ); |
|
| 145 | + gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings[ 'entry_id' ] ) ); |
|
| 146 | 146 | |
| 147 | 147 | return null; |
| 148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | gravityview()->log->debug( '{context} atts:', array( 'context' => $context, 'data' => $atts ) ); |
| 151 | 151 | |
| 152 | 152 | if ( ! $this->has_cap() ) { |
| 153 | - gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings['action'] ), 'entry_id' => $this->entry['id'] ) ); |
|
| 153 | + gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings[ 'action' ] ), 'entry_id' => $this->entry[ 'id' ] ) ); |
|
| 154 | 154 | |
| 155 | 155 | return null; |
| 156 | 156 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Get just the URL, not the tag |
| 167 | - if ( 'url' === $this->settings['return'] ) { |
|
| 167 | + if ( 'url' === $this->settings[ 'return' ] ) { |
|
| 168 | 168 | return $url; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | private function get_link_atts() { |
| 187 | 187 | |
| 188 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
| 188 | + wp_parse_str( $this->settings[ 'link_atts' ], $link_atts ); |
|
| 189 | 189 | |
| 190 | - if ( 'delete' === $this->settings['action'] ) { |
|
| 191 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 190 | + if ( 'delete' === $this->settings[ 'action' ] ) { |
|
| 191 | + $link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return (array) $link_atts; |
|
| 194 | + return (array)$link_atts; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | return do_shortcode( $content ); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - switch ( $this->settings['action'] ) { |
|
| 214 | + switch ( $this->settings[ 'action' ] ) { |
|
| 215 | 215 | case 'edit': |
| 216 | 216 | $anchor_text = __( 'Edit Entry', 'gravityview' ); |
| 217 | 217 | break; |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | private function get_url() { |
| 240 | 240 | |
| 241 | 241 | // if post_id is not defined, default to view_id |
| 242 | - $post_id = empty( $this->settings['post_id'] ) ? $this->view_id : $this->settings['post_id']; |
|
| 242 | + $post_id = empty( $this->settings[ 'post_id' ] ) ? $this->view_id : $this->settings[ 'post_id' ]; |
|
| 243 | 243 | |
| 244 | - switch ( $this->settings['action'] ) { |
|
| 244 | + switch ( $this->settings[ 'action' ] ) { |
|
| 245 | 245 | case 'edit': |
| 246 | 246 | $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
| 247 | 247 | break; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | private function has_cap() { |
| 268 | 268 | |
| 269 | - switch ( $this->settings['action'] ) { |
|
| 269 | + switch ( $this->settings[ 'action' ] ) { |
|
| 270 | 270 | case 'edit': |
| 271 | 271 | $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
| 272 | 272 | break; |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | private function maybe_add_field_values_query_args( $url ) { |
| 333 | 333 | |
| 334 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
| 334 | + if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) { |
|
| 335 | 335 | |
| 336 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
| 336 | + wp_parse_str( $this->settings[ 'field_values' ], $field_values ); |
|
| 337 | 337 | |
| 338 | 338 | $url = add_query_arg( $field_values, $url ); |
| 339 | 339 | } |
@@ -67,7 +67,6 @@ |
||
| 67 | 67 | * |
| 68 | 68 | * @since 1.15 |
| 69 | 69 | * |
| 70 | - * @param array $allcaps An array of all the user's capabilities. |
|
| 71 | 70 | * @param array $caps Actual capabilities for meta capability. |
| 72 | 71 | * @param array $args Optional parameters passed to has_cap(), typically object ID. |
| 73 | 72 | * @param WP_User|null $user The user object, in WordPress 3.7.0 or higher |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -360,7 +360,6 @@ discard block |
||
| 360 | 360 | * Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against. |
| 361 | 361 | * |
| 362 | 362 | * @since 1.15 |
| 363 | - |
|
| 364 | 363 | * @param array $caps_to_check |
| 365 | 364 | * |
| 366 | 365 | * @return array |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function get_instance() { |
| 35 | 35 | |
| 36 | - if( ! self::$instance ) { |
|
| 36 | + if ( ! self::$instance ) { |
|
| 37 | 37 | self::$instance = new self; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps' ) ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
| 78 | 78 | |
| 79 | 79 | // Empty caps_to_check array |
| 80 | - if( ! $usercaps || ! $caps ) { |
|
| 80 | + if ( ! $usercaps || ! $caps ) { |
|
| 81 | 81 | return $usercaps; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
| 86 | 86 | */ |
| 87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
| 87 | + if ( ! empty( $usercaps[ 'gravityview_full_access' ] ) ) { |
|
| 88 | 88 | |
| 89 | 89 | $all_gravityview_caps = self::all_caps(); |
| 90 | 90 | |
| 91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
| 91 | + foreach ( $all_gravityview_caps as $gv_cap ) { |
|
| 92 | 92 | $usercaps[ $gv_cap ] = true; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | $all = $administrator; |
| 307 | 307 | |
| 308 | 308 | // If role is set, return caps_to_check for just that role. |
| 309 | - if( $single_role ) { |
|
| 309 | + if ( $single_role ) { |
|
| 310 | 310 | $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
| 311 | 311 | return $flat_array ? $caps : array( $single_role => $caps ); |
| 312 | 312 | } |
@@ -355,9 +355,9 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | if ( true === $allow_logged_out ) { |
| 357 | 357 | |
| 358 | - $all_caps = self::all_caps('editor'); |
|
| 358 | + $all_caps = self::all_caps( 'editor' ); |
|
| 359 | 359 | |
| 360 | - if( array_intersect( $all_caps, (array) $caps_to_check ) ) { |
|
| 360 | + if ( array_intersect( $all_caps, (array)$caps_to_check ) ) { |
|
| 361 | 361 | return true; |
| 362 | 362 | } |
| 363 | 363 | } |
@@ -378,13 +378,13 @@ discard block |
||
| 378 | 378 | $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
| 379 | 379 | |
| 380 | 380 | foreach ( $caps_to_check as $cap ) { |
| 381 | - if( ! is_null( $object_id ) ) { |
|
| 381 | + if ( ! is_null( $object_id ) ) { |
|
| 382 | 382 | $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
| 383 | 383 | } else { |
| 384 | 384 | $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
| 385 | 385 | } |
| 386 | 386 | // At the first successful response, stop checking |
| 387 | - if( $has_cap ) { |
|
| 387 | + if ( $has_cap ) { |
|
| 388 | 388 | break; |
| 389 | 389 | } |
| 390 | 390 | } |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | $all_gravityview_caps = self::all_caps(); |
| 409 | 409 | |
| 410 | 410 | // Are there any $caps_to_check that are from GravityView? |
| 411 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 412 | - $caps_to_check[] = 'gravityview_full_access'; |
|
| 411 | + if ( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 412 | + $caps_to_check[ ] = 'gravityview_full_access'; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
| 416 | 416 | |
| 417 | 417 | // Are there any $caps_to_check that are from Gravity Forms? |
| 418 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 419 | - $caps_to_check[] = 'gform_full_access'; |
|
| 418 | + if ( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 419 | + $caps_to_check[ ] = 'gform_full_access'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | return array_unique( $caps_to_check ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $capabilities = self::all_caps(); |
| 439 | 439 | |
| 440 | 440 | // Loop through each role and remove GV caps_to_check |
| 441 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 441 | + foreach ( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 442 | 442 | foreach ( $capabilities as $cap ) { |
| 443 | 443 | $wp_roles->remove_cap( $role_slug, $cap ); |
| 444 | 444 | } |
@@ -37,6 +37,9 @@ discard block |
||
| 37 | 37 | public $active_areas; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $id |
|
| 42 | + */ |
|
| 40 | 43 | function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
| 41 | 44 | |
| 42 | 45 | if ( empty( $id ) ) { |
@@ -144,6 +147,9 @@ discard block |
||
| 144 | 147 | return $areas; |
| 145 | 148 | } |
| 146 | 149 | |
| 150 | + /** |
|
| 151 | + * @param string $context |
|
| 152 | + */ |
|
| 147 | 153 | public function get_active_areas( $context ) { |
| 148 | 154 | if ( isset( $this->active_areas[ $context ] ) ) { |
| 149 | 155 | return $this->active_areas[ $context ]; |
@@ -156,8 +162,8 @@ discard block |
||
| 156 | 162 | /** |
| 157 | 163 | * Assign template specific field options |
| 158 | 164 | * |
| 159 | - * @param array $options (default: array()) |
|
| 160 | - * @param string $template (default: '') |
|
| 165 | + * @param array $field_options (default: array()) |
|
| 166 | + * @param string $template_id (default: '') |
|
| 161 | 167 | * @param string $field_id key for the field |
| 162 | 168 | * @param string|array $context Context for the field; `directory` or `single` for example. |
| 163 | 169 | * |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | * @return string Path to XML file |
| 194 | 194 | */ |
| 195 | 195 | public function assign_form_xml( $xml = '', $template = '' ) { |
| 196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
| 197 | - return $this->settings['preset_form']; |
|
| 196 | + if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_form' ] ) && $this->template_id === $template ) { |
|
| 197 | + return $this->settings[ 'preset_form' ]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | return $xml; |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | * @return string Path to XML file |
| 208 | 208 | */ |
| 209 | 209 | public function assign_fields_xml( $xml = '', $template = '' ) { |
| 210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
| 211 | - return $this->settings['preset_fields']; |
|
| 210 | + if ( $this->settings[ 'type' ] === 'preset' && ! empty( $this->settings[ 'preset_fields' ] ) && $this->template_id === $template ) { |
|
| 211 | + return $this->settings[ 'preset_fields' ]; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $xml; |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function assign_view_slug( $default, $context ) { |
| 228 | 228 | |
| 229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
| 230 | - return $this->settings['slug']; |
|
| 229 | + if ( ! empty( $this->settings[ 'slug' ] ) ) { |
|
| 230 | + return $this->settings[ 'slug' ]; |
|
| 231 | 231 | } |
| 232 | 232 | if ( ! empty( $default ) ) { |
| 233 | 233 | return $default; |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | * @return void |
| 245 | 245 | */ |
| 246 | 246 | public function register_styles() { |
| 247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
| 248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
| 247 | + if ( ! empty( $this->settings[ 'css_source' ] ) ) { |
|
| 248 | + wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings[ 'css_source' ], array(), GravityView_Plugin::version, 'all' ); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -170,7 +170,6 @@ |
||
| 170 | 170 | * |
| 171 | 171 | * @since 1.5.1 |
| 172 | 172 | * @param array $visibility_caps Array of capabilities to display in field dropdown. |
| 173 | - * @param string $field_type Type of field options to render (`field` or `widget`) |
|
| 174 | 173 | * @param string $template_id Table slug |
| 175 | 174 | * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by` |
| 176 | 175 | * @param string $context What context are we in? Example: `single` or `directory` |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | self::getInstance()->set_entry( $entry ); |
| 241 | 241 | |
| 242 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 242 | + $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 243 | 243 | |
| 244 | 244 | if ( empty( $base ) ) { |
| 245 | 245 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | 'action' => 'delete', |
| 254 | 254 | 'entry_id' => $entry_slug, |
| 255 | 255 | 'gvid' => $view_id, |
| 256 | - 'view_id' => $view_id, |
|
| 256 | + 'view_id' => $view_id, |
|
| 257 | 257 | ), $base ); |
| 258 | 258 | |
| 259 | 259 | $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @since 1.16.4 |
| 428 | 428 | * @param int $entry_id ID of the Gravity Forms entry |
| 429 | 429 | * @param array $entry Deleted entry array |
| 430 | - */ |
|
| 430 | + */ |
|
| 431 | 431 | do_action( 'gravityview/delete-entry/deleted', $entry_id, $entry ); |
| 432 | 432 | } |
| 433 | 433 | |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | add_action( 'wp', array( $this, 'process_delete' ), 10000 ); |
| 44 | 44 | |
| 45 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 ); |
|
| 45 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
| 46 | 46 | |
| 47 | 47 | add_action( 'gravityview_before', array( $this, 'display_message' ) ); |
| 48 | 48 | |
| 49 | 49 | // For the Delete Entry Link, you don't want visible to all users. |
| 50 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 ); |
|
| 50 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
| 51 | 51 | |
| 52 | 52 | // Modify the field options based on the name of the field type |
| 53 | 53 | add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 ); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | // add template path to check for field |
| 56 | 56 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
| 57 | 57 | |
| 58 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 4 ); |
|
| 58 | + add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 4 ); |
|
| 59 | 59 | |
| 60 | - add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 61 | - add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 60 | + add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 61 | + add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | static function getInstance() { |
| 71 | 71 | |
| 72 | - if( empty( self::$instance ) ) { |
|
| 72 | + if ( empty( self::$instance ) ) { |
|
| 73 | 73 | self::$instance = new self; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -105,20 +105,20 @@ discard block |
||
| 105 | 105 | function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 106 | 106 | |
| 107 | 107 | // Always a link, never a filter |
| 108 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
| 108 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
| 109 | 109 | |
| 110 | 110 | // Delete Entry link should only appear to visitors capable of editing entries |
| 111 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 111 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 112 | 112 | |
| 113 | - $add_option['delete_link'] = array( |
|
| 113 | + $add_option[ 'delete_link' ] = array( |
|
| 114 | 114 | 'type' => 'text', |
| 115 | 115 | 'label' => __( 'Delete Link Text', 'gravityview' ), |
| 116 | 116 | 'desc' => NULL, |
| 117 | - 'value' => __('Delete Entry', 'gravityview'), |
|
| 117 | + 'value' => __( 'Delete Entry', 'gravityview' ), |
|
| 118 | 118 | 'merge_tags' => true, |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | - $field_options['allow_edit_cap'] = array( |
|
| 121 | + $field_options[ 'allow_edit_cap' ] = array( |
|
| 122 | 122 | 'type' => 'select', |
| 123 | 123 | 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ), |
| 124 | 124 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
| 144 | 144 | |
| 145 | - if( 'edit' !== $zone ) { |
|
| 146 | - $entry_default_fields['delete_link'] = array( |
|
| 145 | + if ( 'edit' !== $zone ) { |
|
| 146 | + $entry_default_fields[ 'delete_link' ] = array( |
|
| 147 | 147 | 'label' => __( 'Delete Entry', 'gravityview' ), |
| 148 | 148 | 'type' => 'delete_link', |
| 149 | 149 | 'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ), |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function add_available_field( $available_fields = array() ) { |
| 162 | 162 | |
| 163 | - $available_fields['delete_link'] = array( |
|
| 163 | + $available_fields[ 'delete_link' ] = array( |
|
| 164 | 164 | 'label_text' => __( 'Delete Entry', 'gravityview' ), |
| 165 | 165 | 'field_id' => 'delete_link', |
| 166 | 166 | 'label_type' => 'field', |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | $caps = $visibility_caps; |
| 189 | 189 | |
| 190 | 190 | // If we're configuring fields in the edit context, we want a limited selection |
| 191 | - if( $field_id === 'delete_link' ) { |
|
| 191 | + if ( $field_id === 'delete_link' ) { |
|
| 192 | 192 | |
| 193 | 193 | // Remove other built-in caps. |
| 194 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
| 194 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
| 195 | 195 | |
| 196 | - $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); |
|
| 196 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | return $caps; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param [type] $entry [description] |
| 207 | 207 | */ |
| 208 | 208 | function set_entry( $entry = null ) { |
| 209 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
| 209 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | |
| 240 | 240 | self::getInstance()->set_entry( $entry ); |
| 241 | 241 | |
| 242 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 242 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
| 243 | 243 | |
| 244 | 244 | if ( empty( $base ) ) { |
| 245 | 245 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Use the slug instead of the ID for consistent security |
| 250 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 250 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 251 | 251 | |
| 252 | 252 | $actionurl = add_query_arg( array( |
| 253 | 253 | 'action' => 'delete', |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | 'view_id' => $view_id, |
| 257 | 257 | ), $base ); |
| 258 | 258 | |
| 259 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
|
| 259 | + $url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' ); |
|
| 260 | 260 | |
| 261 | 261 | return $url; |
| 262 | 262 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function add_delete_button( $form = array(), $entry = array(), $view_id = null, $post_id = null ) { |
| 279 | 279 | |
| 280 | 280 | // Only show the link to those who are allowed to see it. |
| 281 | - if( !self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 281 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 282 | 282 | return; |
| 283 | 283 | } |
| 284 | 284 | |
@@ -289,13 +289,13 @@ discard block |
||
| 289 | 289 | $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true ); |
| 290 | 290 | |
| 291 | 291 | // If the button is hidden by the filter, don't show. |
| 292 | - if( !$show_delete_button ) { |
|
| 292 | + if ( ! $show_delete_button ) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | $attributes = array( |
| 297 | 297 | 'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete', |
| 298 | - 'tabindex' => ( GFCommon::$tab_index ++ ), |
|
| 298 | + 'tabindex' => ( GFCommon::$tab_index++ ), |
|
| 299 | 299 | 'onclick' => self::get_confirm_dialog(), |
| 300 | 300 | ); |
| 301 | 301 | |
@@ -319,27 +319,27 @@ discard block |
||
| 319 | 319 | function process_delete() { |
| 320 | 320 | |
| 321 | 321 | // If the form is submitted |
| 322 | - if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) { |
|
| 322 | + if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) { |
|
| 323 | 323 | |
| 324 | 324 | // Make sure it's a GravityView request |
| 325 | - $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
| 325 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
| 326 | 326 | |
| 327 | - if( ! $valid_nonce_key ) { |
|
| 327 | + if ( ! $valid_nonce_key ) { |
|
| 328 | 328 | gravityview()->log->debug( 'Delete entry not processed: nonce validation failed.' ); |
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Get the entry slug |
| 333 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
| 333 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
| 334 | 334 | |
| 335 | 335 | // See if there's an entry there |
| 336 | 336 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
| 337 | 337 | |
| 338 | - if( $entry ) { |
|
| 338 | + if ( $entry ) { |
|
| 339 | 339 | |
| 340 | 340 | $has_permission = $this->user_can_delete_entry( $entry ); |
| 341 | 341 | |
| 342 | - if( is_wp_error( $has_permission ) ) { |
|
| 342 | + if ( is_wp_error( $has_permission ) ) { |
|
| 343 | 343 | |
| 344 | 344 | $messages = array( |
| 345 | 345 | 'message' => urlencode( $has_permission->get_error_message() ), |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | // Delete the entry |
| 352 | 352 | $delete_response = $this->delete_or_trash_entry( $entry ); |
| 353 | 353 | |
| 354 | - if( is_wp_error( $delete_response ) ) { |
|
| 354 | + if ( is_wp_error( $delete_response ) ) { |
|
| 355 | 355 | |
| 356 | 356 | $messages = array( |
| 357 | 357 | 'message' => urlencode( $delete_response->get_error_message() ), |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | gravityview()->log->debug( 'Delete entry failed: there was no entry with the entry slug {entry_slug}', array( 'entry_slug' => $entry_slug ) ); |
| 374 | 374 | |
| 375 | 375 | $messages = array( |
| 376 | - 'message' => urlencode( __('The entry does not exist.', 'gravityview') ), |
|
| 376 | + 'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ), |
|
| 377 | 377 | 'status' => 'error', |
| 378 | 378 | ); |
| 379 | 379 | } |
@@ -413,18 +413,18 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | private function delete_or_trash_entry( $entry ) { |
| 415 | 415 | |
| 416 | - $entry_id = $entry['id']; |
|
| 416 | + $entry_id = $entry[ 'id' ]; |
|
| 417 | 417 | |
| 418 | 418 | $mode = $this->get_delete_mode(); |
| 419 | 419 | |
| 420 | - if( 'delete' === $mode ) { |
|
| 420 | + if ( 'delete' === $mode ) { |
|
| 421 | 421 | |
| 422 | 422 | gravityview()->log->debug( 'Starting delete entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
| 423 | 423 | |
| 424 | 424 | // Delete the entry |
| 425 | 425 | $delete_response = GFAPI::delete_entry( $entry_id ); |
| 426 | 426 | |
| 427 | - if( ! is_wp_error( $delete_response ) ) { |
|
| 427 | + if ( ! is_wp_error( $delete_response ) ) { |
|
| 428 | 428 | $delete_response = 'deleted'; |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' ); |
| 446 | 446 | new GravityView_Cache; |
| 447 | 447 | |
| 448 | - if( ! $trashed ) { |
|
| 449 | - $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); |
|
| 448 | + if ( ! $trashed ) { |
|
| 449 | + $delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) ); |
|
| 450 | 450 | } else { |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | public function process_connected_posts( $entry_id = 0, $entry = array() ) { |
| 478 | 478 | |
| 479 | 479 | // The entry had no connected post |
| 480 | - if( empty( $entry['post_id'] ) ) { |
|
| 480 | + if ( empty( $entry[ 'post_id' ] ) ) { |
|
| 481 | 481 | return; |
| 482 | 482 | } |
| 483 | 483 | |
@@ -488,19 +488,19 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true ); |
| 490 | 490 | |
| 491 | - if( false === $delete_post ) { |
|
| 491 | + if ( false === $delete_post ) { |
|
| 492 | 492 | return; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | $action = current_action(); |
| 496 | 496 | |
| 497 | - if( 'gravityview/delete-entry/deleted' === $action ) { |
|
| 498 | - $result = wp_delete_post( $entry['post_id'], true ); |
|
| 497 | + if ( 'gravityview/delete-entry/deleted' === $action ) { |
|
| 498 | + $result = wp_delete_post( $entry[ 'post_id' ], true ); |
|
| 499 | 499 | } else { |
| 500 | - $result = wp_trash_post( $entry['post_id'] ); |
|
| 500 | + $result = wp_trash_post( $entry[ 'post_id' ] ); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - if( false === $result ) { |
|
| 503 | + if ( false === $result ) { |
|
| 504 | 504 | gravityview()->log->error( '(called by {action}): Error processing the Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
| 505 | 505 | } else { |
| 506 | 506 | gravityview()->log->debug( '(called by {action}): Successfully processed Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
@@ -516,13 +516,13 @@ discard block |
||
| 516 | 516 | public function verify_nonce() { |
| 517 | 517 | |
| 518 | 518 | // No delete entry request was made |
| 519 | - if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
| 519 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
| 523 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
| 524 | 524 | |
| 525 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
| 525 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key ); |
|
| 526 | 526 | |
| 527 | 527 | /** |
| 528 | 528 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | public static function get_confirm_dialog() { |
| 546 | 546 | |
| 547 | - $confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview'); |
|
| 547 | + $confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' ); |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm ); |
| 554 | 554 | |
| 555 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
| 555 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -570,16 +570,16 @@ discard block |
||
| 570 | 570 | |
| 571 | 571 | $error = NULL; |
| 572 | 572 | |
| 573 | - if( ! $this->verify_nonce() ) { |
|
| 574 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
| 573 | + if ( ! $this->verify_nonce() ) { |
|
| 574 | + $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 578 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview'); |
|
| 577 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
| 578 | + $error = __( 'You do not have permission to delete this entry.', 'gravityview' ); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if( $entry['status'] === 'trash' ) { |
|
| 582 | - if( 'trash' === $this->get_delete_mode() ) { |
|
| 581 | + if ( $entry[ 'status' ] === 'trash' ) { |
|
| 582 | + if ( 'trash' === $this->get_delete_mode() ) { |
|
| 583 | 583 | $error = __( 'The entry is already in the trash.', 'gravityview' ); |
| 584 | 584 | } else { |
| 585 | 585 | $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' ); |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | // No errors; everything's fine here! |
| 590 | - if( empty( $error ) ) { |
|
| 590 | + if ( empty( $error ) ) { |
|
| 591 | 591 | return true; |
| 592 | 592 | } |
| 593 | 593 | |
@@ -616,10 +616,10 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $current_user = wp_get_current_user(); |
| 618 | 618 | |
| 619 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
| 619 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
| 620 | 620 | |
| 621 | 621 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
| 622 | - if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
| 622 | + if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
| 623 | 623 | |
| 624 | 624 | gravityview()->log->debug( 'Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
| 625 | 625 | |
@@ -628,20 +628,20 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | |
| 630 | 630 | // If field options are passed, check if current user can view the link |
| 631 | - if( !empty( $field ) ) { |
|
| 631 | + if ( ! empty( $field ) ) { |
|
| 632 | 632 | |
| 633 | 633 | // If capability is not defined, something is not right! |
| 634 | - if( empty( $field['allow_edit_cap'] ) ) { |
|
| 634 | + if ( empty( $field[ 'allow_edit_cap' ] ) ) { |
|
| 635 | 635 | |
| 636 | 636 | gravityview()->log->error( 'Cannot read delete entry field caps', array( 'data' => $field ) ); |
| 637 | 637 | |
| 638 | 638 | return false; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
| 641 | + if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { |
|
| 642 | 642 | |
| 643 | 643 | // Do not return true if cap is read, as we need to check if the current user created the entry |
| 644 | - if( $field['allow_edit_cap'] !== 'read' ) { |
|
| 644 | + if ( $field[ 'allow_edit_cap' ] !== 'read' ) { |
|
| 645 | 645 | return true; |
| 646 | 646 | } |
| 647 | 647 | |
@@ -654,21 +654,21 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if( !isset( $entry['created_by'] ) ) { |
|
| 657 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 658 | 658 | |
| 659 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
| 659 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
| 660 | 660 | |
| 661 | 661 | return false; |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | // Only checks user_delete view option if view is already set |
| 665 | - if( $view_id ) { |
|
| 665 | + if ( $view_id ) { |
|
| 666 | 666 | |
| 667 | 667 | $current_view = gravityview_get_current_view_data( $view_id ); |
| 668 | 668 | |
| 669 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false; |
|
| 669 | + $user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false; |
|
| 670 | 670 | |
| 671 | - if( empty( $user_delete ) ) { |
|
| 671 | + if ( empty( $user_delete ) ) { |
|
| 672 | 672 | |
| 673 | 673 | gravityview()->log->debug( 'User Delete is disabled. Returning false.' ); |
| 674 | 674 | |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | // If the logged-in user is the same as the user who created the entry, we're good. |
| 680 | - if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 680 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 681 | 681 | |
| 682 | 682 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
| 683 | 683 | |
@@ -702,16 +702,16 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | public function display_message( $current_view_id = 0 ) { |
| 704 | 704 | |
| 705 | - if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
| 705 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
| 706 | 706 | return; |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Entry wasn't deleted from current View |
| 710 | - if( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
| 710 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
| 711 | 711 | return; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - $status = esc_attr( $_GET['status'] ); |
|
| 714 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
| 715 | 715 | $message_from_url = \GV\Utils::_GET( 'message' ); |
| 716 | 716 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
| 717 | 717 | $class = ''; |
@@ -719,14 +719,14 @@ discard block |
||
| 719 | 719 | switch ( $status ) { |
| 720 | 720 | case 'error': |
| 721 | 721 | $class = ' gv-error error'; |
| 722 | - $error_message = __('There was an error deleting the entry: %s', 'gravityview'); |
|
| 722 | + $error_message = __( 'There was an error deleting the entry: %s', 'gravityview' ); |
|
| 723 | 723 | $message = sprintf( $error_message, $message_from_url ); |
| 724 | 724 | break; |
| 725 | 725 | case 'trashed': |
| 726 | - $message = __('The entry was successfully moved to the trash.', 'gravityview'); |
|
| 726 | + $message = __( 'The entry was successfully moved to the trash.', 'gravityview' ); |
|
| 727 | 727 | break; |
| 728 | 728 | default: |
| 729 | - $message = __('The entry was successfully deleted.', 'gravityview'); |
|
| 729 | + $message = __( 'The entry was successfully deleted.', 'gravityview' ); |
|
| 730 | 730 | break; |
| 731 | 731 | } |
| 732 | 732 | |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url ); |
| 741 | 741 | |
| 742 | 742 | // DISPLAY ERROR/SUCCESS MESSAGE |
| 743 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
| 743 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | |
@@ -69,7 +69,6 @@ |
||
| 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` |
@@ -10,175 +10,175 @@ |
||
| 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/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
| 42 | - |
|
| 43 | - // custom fields' options for zone EDIT |
|
| 44 | - add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
| 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 | - */ |
|
| 40 | + // add tooltips |
|
| 41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
| 42 | + |
|
| 43 | + // custom fields' options for zone EDIT |
|
| 44 | + add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 6 ); |
|
| 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 | 149 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
| 150 | 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 | - } |
|
| 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 |
@@ -24,7 +24,7 @@ discard block |
||
| 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 |
||
| 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/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
| 41 | + add_filter( 'gravityview/metaboxes/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, 6 ); |
@@ -52,12 +52,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 149 | 149 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
| 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 |
||
| 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( |
@@ -57,7 +57,7 @@ |
||
| 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 ) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | if ( ! defined( 'WPINC' ) ) { |
| 14 | - die; |
|
| 14 | + die; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -22,104 +22,104 @@ discard block |
||
| 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' ) ) { |
|
| 76 | - gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
|
| 77 | - return; |
|
| 78 | - } elseif( empty( $entry_id ) ) { |
|
| 79 | - gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
|
| 80 | - return; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** @var GF_User_Registration $gf_user_registration */ |
|
| 84 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 85 | - |
|
| 86 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 90 | - * @since 1.11 |
|
| 91 | - * @param array $entry Gravity Forms entry |
|
| 92 | - * @param array $form Gravity Forms form |
|
| 93 | - */ |
|
| 94 | - $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 95 | - |
|
| 96 | - $config = $this->get_feed_configuration( $entry, $form ); |
|
| 97 | - |
|
| 98 | - // Make sure the feed is active |
|
| 99 | - if ( ! \GV\Utils::get( $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' ) ) { |
|
| 76 | + gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
|
| 100 | 77 | return; |
| 101 | - } |
|
| 78 | + } elseif( empty( $entry_id ) ) { |
|
| 79 | + gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
|
| 80 | + return; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** @var GF_User_Registration $gf_user_registration */ |
|
| 84 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 85 | + |
|
| 86 | + $entry = GFAPI::get_entry( $entry_id ); |
|
| 102 | 87 | |
| 103 | - // If an Update feed, make sure the conditions are met. |
|
| 104 | - if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
|
| 105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - } |
|
| 88 | + /** |
|
| 89 | + * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on |
|
| 90 | + * @since 1.11 |
|
| 91 | + * @param array $entry Gravity Forms entry |
|
| 92 | + * @param array $form Gravity Forms form |
|
| 93 | + */ |
|
| 94 | + $entry = apply_filters( 'gravityview/edit_entry/user_registration/entry', $entry, $form ); |
|
| 95 | + |
|
| 96 | + $config = $this->get_feed_configuration( $entry, $form ); |
|
| 97 | + |
|
| 98 | + // Make sure the feed is active |
|
| 99 | + if ( ! \GV\Utils::get( $config, 'is_active', false ) ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 109 | 102 | |
| 110 | - // The priority is set to 3 so that default priority (10) will still override it |
|
| 111 | - add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 112 | - add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 103 | + // If an Update feed, make sure the conditions are met. |
|
| 104 | + if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
|
| 105 | + if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + } |
|
| 113 | 109 | |
| 114 | - // Trigger the User Registration update user method |
|
| 115 | - $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 110 | + // The priority is set to 3 so that default priority (10) will still override it |
|
| 111 | + add_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 112 | + add_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 116 | 113 | |
| 117 | - remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 118 | - remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 114 | + // Trigger the User Registration update user method |
|
| 115 | + $gf_user_registration->update_user( $entry, $form, $config ); |
|
| 119 | 116 | |
| 120 | - // Prevent double-triggering by removing the hook |
|
| 121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
| 122 | - } |
|
| 117 | + remove_filter( 'send_password_change_email', '__return_false', 3 ); |
|
| 118 | + remove_filter( 'send_email_change_email', '__return_false', 3 ); |
|
| 119 | + |
|
| 120 | + // Prevent double-triggering by removing the hook |
|
| 121 | + remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Get the User Registration feed configuration for the entry & form |
@@ -134,185 +134,185 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return array |
| 136 | 136 | */ |
| 137 | - public function get_feed_configuration( $entry, $form ) { |
|
| 138 | - |
|
| 139 | - /** @var GF_User_Registration $gf_user_registration */ |
|
| 140 | - $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 141 | - |
|
| 142 | - $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 146 | - * @since 1.15 |
|
| 147 | - * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 148 | - * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 149 | - * @param[in] array $form Gravity Forms form array |
|
| 150 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 151 | - */ |
|
| 152 | - $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 153 | - |
|
| 154 | - if( $preserve_role ) { |
|
| 155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Make sure the current display name is not changed with the update user method. |
|
| 162 | - * @since 1.15 |
|
| 163 | - */ |
|
| 164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 168 | - * @since 1.14 |
|
| 169 | - * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 170 | - * @param[in] array $form Gravity Forms form array |
|
| 171 | - * @param[in] array $entry Gravity Forms entry being edited |
|
| 172 | - */ |
|
| 173 | - $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 174 | - |
|
| 175 | - return $config; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Calculate the user display name format |
|
| 180 | - * |
|
| 181 | - * @since 1.15 |
|
| 182 | - * @since 1.20 Returns false if user not found at $user_id |
|
| 183 | - * |
|
| 184 | - * @param int $user_id WP User ID |
|
| 185 | - * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 186 | - */ |
|
| 187 | - public function match_current_display_name( $user_id ) { |
|
| 188 | - |
|
| 189 | - $user = get_userdata( $user_id ); |
|
| 190 | - |
|
| 191 | - if( ! $user ) { |
|
| 192 | - return false; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $names = $this->generate_display_names( $user ); |
|
| 196 | - |
|
| 197 | - $format = array_search( $user->display_name, $names, true ); |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 201 | - * @see restore_display_name |
|
| 202 | - */ |
|
| 203 | - if( false === $format ) { |
|
| 204 | - $this->_user_before_update = $user; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $format; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Generate an array of all the user display names possibilities |
|
| 212 | - * |
|
| 213 | - * @since 1.15 |
|
| 214 | - * |
|
| 215 | - * @param object $profileuser WP_User object |
|
| 216 | - * @return array List all the possible display names for a certain User object |
|
| 217 | - */ |
|
| 218 | - public function generate_display_names( $profileuser ) { |
|
| 219 | - |
|
| 220 | - $public_display = array(); |
|
| 221 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 222 | - $public_display['username'] = $profileuser->user_login; |
|
| 223 | - |
|
| 224 | - if ( !empty($profileuser->first_name) ) { |
|
| 225 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if ( !empty($profileuser->last_name) ) { |
|
| 229 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - $public_display = array_map( 'trim', $public_display ); |
|
| 238 | - $public_display = array_unique( $public_display ); |
|
| 239 | - |
|
| 240 | - return $public_display; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 246 | - * |
|
| 247 | - * @see GFUser::update_user() |
|
| 248 | - * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 249 | - * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 250 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 251 | - * @param string $password User password |
|
| 252 | - * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
| 253 | - */ |
|
| 254 | - public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 258 | - * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 259 | - * @since 1.14.4 |
|
| 260 | - * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 261 | - */ |
|
| 262 | - $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 263 | - |
|
| 264 | - $is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' ); |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Don't restore display name: |
|
| 268 | - * - either disabled, |
|
| 269 | - * - or it is an Update feed (we only care about Create feed) |
|
| 270 | - * - or we don't need as we found the correct format before updating user. |
|
| 271 | - * @since 1.14.4 |
|
| 272 | - */ |
|
| 273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 274 | - return null; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - $user_after_update = get_userdata( $user_id ); |
|
| 278 | - |
|
| 279 | - // User not found |
|
| 280 | - if ( ! $user_after_update ) { |
|
| 281 | - gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) ); |
|
| 282 | - return false; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - $restored_user = $user_after_update; |
|
| 286 | - |
|
| 287 | - // Restore previous display_name |
|
| 288 | - $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 289 | - |
|
| 290 | - // Don't have WP update the password. |
|
| 291 | - unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 295 | - * @since 1.14 |
|
| 296 | - * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 297 | - * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 298 | - * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 299 | - * @param array $entry The Gravity Forms entry that was just updated |
|
| 300 | - */ |
|
| 301 | - $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 302 | - |
|
| 303 | - $updated = wp_update_user( $restored_user ); |
|
| 304 | - |
|
| 305 | - if( is_wp_error( $updated ) ) { |
|
| 306 | - gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
|
| 307 | - } else { |
|
| 308 | - gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - $this->_user_before_update = null; |
|
| 312 | - |
|
| 313 | - unset( $restored_user, $user_after_update ); |
|
| 314 | - |
|
| 315 | - return $updated; |
|
| 316 | - } |
|
| 137 | + public function get_feed_configuration( $entry, $form ) { |
|
| 138 | + |
|
| 139 | + /** @var GF_User_Registration $gf_user_registration */ |
|
| 140 | + $gf_user_registration = GF_User_Registration::get_instance(); |
|
| 141 | + |
|
| 142 | + $config = $gf_user_registration->get_single_submission_feed( $entry, $form ); |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed |
|
| 146 | + * @since 1.15 |
|
| 147 | + * @param[in,out] boolean $preserve_role Preserve current user role Default: true |
|
| 148 | + * @param[in] array $config Gravity Forms User Registration feed configuration for the form |
|
| 149 | + * @param[in] array $form Gravity Forms form array |
|
| 150 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 151 | + */ |
|
| 152 | + $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
|
| 153 | + |
|
| 154 | + if( $preserve_role ) { |
|
| 155 | + $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Make sure the current display name is not changed with the update user method. |
|
| 162 | + * @since 1.15 |
|
| 163 | + */ |
|
| 164 | + $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
|
| 168 | + * @since 1.14 |
|
| 169 | + * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form |
|
| 170 | + * @param[in] array $form Gravity Forms form array |
|
| 171 | + * @param[in] array $entry Gravity Forms entry being edited |
|
| 172 | + */ |
|
| 173 | + $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry ); |
|
| 174 | + |
|
| 175 | + return $config; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Calculate the user display name format |
|
| 180 | + * |
|
| 181 | + * @since 1.15 |
|
| 182 | + * @since 1.20 Returns false if user not found at $user_id |
|
| 183 | + * |
|
| 184 | + * @param int $user_id WP User ID |
|
| 185 | + * @return false|string Display name format as used inside Gravity Forms User Registration. Returns false if user not found. |
|
| 186 | + */ |
|
| 187 | + public function match_current_display_name( $user_id ) { |
|
| 188 | + |
|
| 189 | + $user = get_userdata( $user_id ); |
|
| 190 | + |
|
| 191 | + if( ! $user ) { |
|
| 192 | + return false; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $names = $this->generate_display_names( $user ); |
|
| 196 | + |
|
| 197 | + $format = array_search( $user->display_name, $names, true ); |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
|
| 201 | + * @see restore_display_name |
|
| 202 | + */ |
|
| 203 | + if( false === $format ) { |
|
| 204 | + $this->_user_before_update = $user; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $format; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Generate an array of all the user display names possibilities |
|
| 212 | + * |
|
| 213 | + * @since 1.15 |
|
| 214 | + * |
|
| 215 | + * @param object $profileuser WP_User object |
|
| 216 | + * @return array List all the possible display names for a certain User object |
|
| 217 | + */ |
|
| 218 | + public function generate_display_names( $profileuser ) { |
|
| 219 | + |
|
| 220 | + $public_display = array(); |
|
| 221 | + $public_display['nickname'] = $profileuser->nickname; |
|
| 222 | + $public_display['username'] = $profileuser->user_login; |
|
| 223 | + |
|
| 224 | + if ( !empty($profileuser->first_name) ) { |
|
| 225 | + $public_display['firstname'] = $profileuser->first_name; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if ( !empty($profileuser->last_name) ) { |
|
| 229 | + $public_display['lastname'] = $profileuser->last_name; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 233 | + $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | + $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + $public_display = array_map( 'trim', $public_display ); |
|
| 238 | + $public_display = array_unique( $public_display ); |
|
| 239 | + |
|
| 240 | + return $public_display; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon |
|
| 246 | + * |
|
| 247 | + * @see GFUser::update_user() |
|
| 248 | + * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon |
|
| 249 | + * @param array $config Gravity Forms User Registration Addon form feed configuration |
|
| 250 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 251 | + * @param string $password User password |
|
| 252 | + * @return int|false|WP_Error|null True: User updated; False: $user_id not a valid User ID; WP_Error: User update error; Null: Method didn't process |
|
| 253 | + */ |
|
| 254 | + public function restore_display_name( $user_id = 0, $config = array(), $entry = array(), $password = '' ) { |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. |
|
| 258 | + * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed |
|
| 259 | + * @since 1.14.4 |
|
| 260 | + * @param boolean $restore_display_name Restore Display Name? Default: true |
|
| 261 | + */ |
|
| 262 | + $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
|
| 263 | + |
|
| 264 | + $is_update_feed = ( $config && \GV\Utils::get( $config, 'meta/feed_type' ) === 'update' ); |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Don't restore display name: |
|
| 268 | + * - either disabled, |
|
| 269 | + * - or it is an Update feed (we only care about Create feed) |
|
| 270 | + * - or we don't need as we found the correct format before updating user. |
|
| 271 | + * @since 1.14.4 |
|
| 272 | + */ |
|
| 273 | + if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 274 | + return null; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + $user_after_update = get_userdata( $user_id ); |
|
| 278 | + |
|
| 279 | + // User not found |
|
| 280 | + if ( ! $user_after_update ) { |
|
| 281 | + gravityview()->log->error( 'User not found at $user_id #{user_id}', array( 'user_id' => $user_id ) ); |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + $restored_user = $user_after_update; |
|
| 286 | + |
|
| 287 | + // Restore previous display_name |
|
| 288 | + $restored_user->display_name = $this->_user_before_update->display_name; |
|
| 289 | + |
|
| 290 | + // Don't have WP update the password. |
|
| 291 | + unset( $restored_user->data->user_pass, $restored_user->user_pass ); |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView |
|
| 295 | + * @since 1.14 |
|
| 296 | + * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() |
|
| 297 | + * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration |
|
| 298 | + * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration |
|
| 299 | + * @param array $entry The Gravity Forms entry that was just updated |
|
| 300 | + */ |
|
| 301 | + $restored_user = apply_filters( 'gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry ); |
|
| 302 | + |
|
| 303 | + $updated = wp_update_user( $restored_user ); |
|
| 304 | + |
|
| 305 | + if( is_wp_error( $updated ) ) { |
|
| 306 | + gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
|
| 307 | + } else { |
|
| 308 | + gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + $this->_user_before_update = null; |
|
| 312 | + |
|
| 313 | + unset( $restored_user, $user_after_update ); |
|
| 314 | + |
|
| 315 | + return $updated; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | 318 | } //end class |
@@ -52,9 +52,9 @@ discard block |
||
| 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,10 +72,10 @@ discard block |
||
| 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' ) ) { |
|
| 75 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) { |
|
| 76 | 76 | gravityview()->log->error( 'GFAPI or User Registration class not found; not updating the user' ); |
| 77 | 77 | return; |
| 78 | - } elseif( empty( $entry_id ) ) { |
|
| 78 | + } elseif ( empty( $entry_id ) ) { |
|
| 79 | 79 | gravityview()->log->error( 'Entry ID is empty [{entry_id}]; not updating the user', array( 'entry_id' => $entry_id ) ); |
| 80 | 80 | return; |
| 81 | 81 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // If an Update feed, make sure the conditions are met. |
| 104 | 104 | if ( \GV\Utils::get( $config, 'meta/feedType' ) === 'update' ) { |
| 105 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 105 | + if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | remove_filter( 'send_email_change_email', '__return_false', 3 ); |
| 119 | 119 | |
| 120 | 120 | // Prevent double-triggering by removing the hook |
| 121 | - remove_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10 ); |
|
| 121 | + remove_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10 ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
| 153 | 153 | |
| 154 | - if( $preserve_role ) { |
|
| 155 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 154 | + if ( $preserve_role ) { |
|
| 155 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $displayname = $this->match_current_display_name( $entry['created_by'] ); |
|
| 158 | + $displayname = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * Make sure the current display name is not changed with the update user method. |
| 162 | 162 | * @since 1.15 |
| 163 | 163 | */ |
| 164 | - $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname']; |
|
| 164 | + $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ]; |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $user = get_userdata( $user_id ); |
| 190 | 190 | |
| 191 | - if( ! $user ) { |
|
| 191 | + if ( ! $user ) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook |
| 201 | 201 | * @see restore_display_name |
| 202 | 202 | */ |
| 203 | - if( false === $format ) { |
|
| 203 | + if ( false === $format ) { |
|
| 204 | 204 | $this->_user_before_update = $user; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -218,20 +218,20 @@ discard block |
||
| 218 | 218 | public function generate_display_names( $profileuser ) { |
| 219 | 219 | |
| 220 | 220 | $public_display = array(); |
| 221 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 222 | - $public_display['username'] = $profileuser->user_login; |
|
| 221 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
| 222 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
| 223 | 223 | |
| 224 | - if ( !empty($profileuser->first_name) ) { |
|
| 225 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 224 | + if ( ! empty( $profileuser->first_name ) ) { |
|
| 225 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( !empty($profileuser->last_name) ) { |
|
| 229 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 228 | + if ( ! empty( $profileuser->last_name ) ) { |
|
| 229 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 233 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 232 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
| 233 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 234 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $public_display = array_map( 'trim', $public_display ); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * - or we don't need as we found the correct format before updating user. |
| 271 | 271 | * @since 1.14.4 |
| 272 | 272 | */ |
| 273 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 273 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 274 | 274 | return null; |
| 275 | 275 | } |
| 276 | 276 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $updated = wp_update_user( $restored_user ); |
| 304 | 304 | |
| 305 | - if( is_wp_error( $updated ) ) { |
|
| 305 | + if ( is_wp_error( $updated ) ) { |
|
| 306 | 306 | gravityview()->log->error( 'There was an error updating user #{user_id} details', array( 'user_id' => $user_id, 'data' => $updated ) ); |
| 307 | 307 | } else { |
| 308 | 308 | gravityview()->log->debug( 'User #{user_id} details restored', array( 'user_id' => $user_id ) ); |