@@ -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 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $context = rgpost( 'context' ); |
| 70 | 70 | |
| 71 | 71 | // Return markup for a single or multiple contexts |
| 72 | - if( $context ) { |
|
| 72 | + if ( $context ) { |
|
| 73 | 73 | $data = array( |
| 74 | 74 | esc_attr( $context ) => '' |
| 75 | 75 | ); |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | function get_active_areas() { |
| 114 | 114 | $this->check_ajax_nonce(); |
| 115 | 115 | |
| 116 | - if( empty( $_POST['template_id'] ) ) { |
|
| 116 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 117 | 117 | $this->_exit( false ); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | ob_start(); |
| 121 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 122 | - $response['directory'] = ob_get_clean(); |
|
| 121 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true ); |
|
| 122 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 123 | 123 | |
| 124 | 124 | ob_start(); |
| 125 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 126 | - $response['single'] = ob_get_clean(); |
|
| 125 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true ); |
|
| 126 | + $response[ 'single' ] = ob_get_clean(); |
|
| 127 | 127 | |
| 128 | 128 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 129 | 129 | |
@@ -138,20 +138,20 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $this->check_ajax_nonce(); |
| 140 | 140 | |
| 141 | - if( empty( $_POST['template_id'] ) ) { |
|
| 141 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 142 | 142 | $this->_exit( false ); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // get the fields xml config file for this specific preset |
| 146 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 146 | + $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] ); |
|
| 147 | 147 | // import fields |
| 148 | - if( !empty( $preset_fields_path ) ) { |
|
| 148 | + if ( ! empty( $preset_fields_path ) ) { |
|
| 149 | 149 | $presets = $this->import_fields( $preset_fields_path ); |
| 150 | 150 | } else { |
| 151 | 151 | $presets = array( 'widgets' => array(), 'fields' => array() ); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 154 | + $template_id = esc_attr( $_POST[ 'template_id' ] ); |
|
| 155 | 155 | |
| 156 | 156 | // template areas |
| 157 | 157 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
@@ -161,20 +161,20 @@ discard block |
||
| 161 | 161 | $default_widget_areas = \GV\Widget::get_default_widget_areas(); |
| 162 | 162 | |
| 163 | 163 | ob_start(); |
| 164 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 165 | - $response['header'] = ob_get_clean(); |
|
| 164 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 165 | + $response[ 'header' ] = ob_get_clean(); |
|
| 166 | 166 | |
| 167 | 167 | ob_start(); |
| 168 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 169 | - $response['footer'] = ob_get_clean(); |
|
| 168 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 169 | + $response[ 'footer' ] = ob_get_clean(); |
|
| 170 | 170 | |
| 171 | 171 | ob_start(); |
| 172 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 173 | - $response['directory'] = ob_get_clean(); |
|
| 172 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] ); |
|
| 173 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 174 | 174 | |
| 175 | 175 | ob_start(); |
| 176 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 177 | - $response['single'] = ob_get_clean(); |
|
| 176 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] ); |
|
| 177 | + $response[ 'single' ] = ob_get_clean(); |
|
| 178 | 178 | |
| 179 | 179 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 180 | 180 | |
@@ -192,26 +192,26 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $this->check_ajax_nonce(); |
| 194 | 194 | |
| 195 | - if( empty( $_POST['template_id'] ) ) { |
|
| 195 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 196 | 196 | gravityview()->log->error( 'Cannot create preset form; the template_id is empty.' ); |
| 197 | 197 | $this->_exit( false ); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // get the xml for this specific template_id |
| 201 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 201 | + $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] ); |
|
| 202 | 202 | |
| 203 | 203 | // import form |
| 204 | 204 | $form = $this->import_form( $preset_form_xml_path ); |
| 205 | 205 | |
| 206 | 206 | // get the form ID |
| 207 | - if( false === $form ) { |
|
| 207 | + if ( false === $form ) { |
|
| 208 | 208 | // send error to user |
| 209 | - gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int) $_POST['template_id'] ) ); |
|
| 209 | + gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int)$_POST[ 'template_id' ] ) ); |
|
| 210 | 210 | |
| 211 | 211 | $this->_exit( false ); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 214 | + $this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' ); |
|
| 215 | 215 | |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | gravityview()->log->debug( '[import_form] Import Preset Form. (File) {path}', array( 'path' => $xml_or_json_path ) ); |
| 227 | 227 | |
| 228 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 228 | + if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) { |
|
| 229 | 229 | gravityview()->log->error( 'Class GFExport or file not found. file: {path}', array( 'path' => $xml_or_json_path ) ); |
| 230 | 230 | return false; |
| 231 | 231 | } |
@@ -237,13 +237,13 @@ discard block |
||
| 237 | 237 | gravityview()->log->debug( '[import_form] Importing form (Result) {count}', array( 'count' => $count ) ); |
| 238 | 238 | gravityview()->log->debug( '[import_form] Importing form (Form) ', array( 'data' => $forms ) ); |
| 239 | 239 | |
| 240 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 240 | + if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) { |
|
| 241 | 241 | gravityview()->log->error( 'Form Import Failed!' ); |
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // import success - return form id |
| 246 | - return $forms[0]; |
|
| 246 | + return $forms[ 0 ]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | function get_field_options() { |
| 258 | 258 | $this->check_ajax_nonce(); |
| 259 | 259 | |
| 260 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 260 | + if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) { |
|
| 261 | 261 | gravityview()->log->error( 'Required fields were not set in the $_POST request. ' ); |
| 262 | 262 | $this->_exit( false ); |
| 263 | 263 | } |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | $_post = array_map( 'esc_attr', $_post ); |
| 270 | 270 | |
| 271 | 271 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 272 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 273 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 272 | + $input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL; |
|
| 273 | + $context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL; |
|
| 274 | 274 | |
| 275 | - $form_id = empty( $_post['form_id'] ) ? null : $_post['form_id']; |
|
| 276 | - $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 ); |
|
| 275 | + $form_id = empty( $_post[ 'form_id' ] ) ? null : $_post[ 'form_id' ]; |
|
| 276 | + $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 ); |
|
| 277 | 277 | |
| 278 | 278 | $response = gravityview_strip_whitespace( $response ); |
| 279 | 279 | |
@@ -294,15 +294,15 @@ discard block |
||
| 294 | 294 | $form = ''; |
| 295 | 295 | |
| 296 | 296 | // if form id is set, use it, else, get form from preset |
| 297 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 297 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 298 | 298 | |
| 299 | - $form = (int) $_POST['form_id']; |
|
| 299 | + $form = (int)$_POST[ 'form_id' ]; |
|
| 300 | 300 | |
| 301 | 301 | } |
| 302 | 302 | // get form from preset |
| 303 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 303 | + elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 304 | 304 | |
| 305 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 305 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
@@ -318,27 +318,27 @@ discard block |
||
| 318 | 318 | * @param string $template_id Preset template |
| 319 | 319 | * |
| 320 | 320 | */ |
| 321 | - static function pre_get_form_fields( $template_id = '') { |
|
| 321 | + static function pre_get_form_fields( $template_id = '' ) { |
|
| 322 | 322 | |
| 323 | - if( empty( $template_id ) ) { |
|
| 323 | + if ( empty( $template_id ) ) { |
|
| 324 | 324 | gravityview()->log->error( 'Template ID not set.' ); |
| 325 | 325 | return false; |
| 326 | 326 | } else { |
| 327 | 327 | $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
| 328 | - if( !file_exists( $form_file ) ) { |
|
| 328 | + if ( ! file_exists( $form_file ) ) { |
|
| 329 | 329 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. File not found. file: {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 330 | 330 | return false; |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Load xml parser (from GravityForms) |
| 335 | - if( class_exists( 'GFCommon' ) ) { |
|
| 335 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 336 | 336 | $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
| 337 | 337 | } else { |
| 338 | 338 | $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if( file_exists( $xml_parser ) ) { |
|
| 341 | + if ( file_exists( $xml_parser ) ) { |
|
| 342 | 342 | require_once( $xml_parser ); |
| 343 | 343 | } else { |
| 344 | 344 | gravityview()->log->debug( ' - Gravity Forms XML Parser not found {path}.', array( 'path' => $xml_parser ) ); |
@@ -349,32 +349,32 @@ discard block |
||
| 349 | 349 | $xmlstr = file_get_contents( $form_file ); |
| 350 | 350 | |
| 351 | 351 | $options = array( |
| 352 | - "page" => array("unserialize_as_array" => true), |
|
| 353 | - "form"=> array("unserialize_as_array" => true), |
|
| 354 | - "field"=> array("unserialize_as_array" => true), |
|
| 355 | - "rule"=> array("unserialize_as_array" => true), |
|
| 356 | - "choice"=> array("unserialize_as_array" => true), |
|
| 357 | - "input"=> array("unserialize_as_array" => true), |
|
| 358 | - "routing_item"=> array("unserialize_as_array" => true), |
|
| 359 | - "creditCard"=> array("unserialize_as_array" => true), |
|
| 360 | - "routin"=> array("unserialize_as_array" => true), |
|
| 361 | - "confirmation" => array("unserialize_as_array" => true), |
|
| 362 | - "notification" => array("unserialize_as_array" => true) |
|
| 352 | + "page" => array( "unserialize_as_array" => true ), |
|
| 353 | + "form"=> array( "unserialize_as_array" => true ), |
|
| 354 | + "field"=> array( "unserialize_as_array" => true ), |
|
| 355 | + "rule"=> array( "unserialize_as_array" => true ), |
|
| 356 | + "choice"=> array( "unserialize_as_array" => true ), |
|
| 357 | + "input"=> array( "unserialize_as_array" => true ), |
|
| 358 | + "routing_item"=> array( "unserialize_as_array" => true ), |
|
| 359 | + "creditCard"=> array( "unserialize_as_array" => true ), |
|
| 360 | + "routin"=> array( "unserialize_as_array" => true ), |
|
| 361 | + "confirmation" => array( "unserialize_as_array" => true ), |
|
| 362 | + "notification" => array( "unserialize_as_array" => true ) |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | - $xml = new RGXML($options); |
|
| 366 | - $forms = $xml->unserialize($xmlstr); |
|
| 365 | + $xml = new RGXML( $options ); |
|
| 366 | + $forms = $xml->unserialize( $xmlstr ); |
|
| 367 | 367 | |
| 368 | - if( !$forms ) { |
|
| 368 | + if ( ! $forms ) { |
|
| 369 | 369 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 370 | 370 | return false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 374 | - $form = $forms[0]; |
|
| 373 | + if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) { |
|
| 374 | + $form = $forms[ 0 ]; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if( empty( $form ) ) { |
|
| 377 | + if ( empty( $form ) ) { |
|
| 378 | 378 | gravityview()->log->error( '$form not set.', array( 'data' => $forms ) ); |
| 379 | 379 | return false; |
| 380 | 380 | } |
@@ -393,38 +393,38 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | function import_fields( $file ) { |
| 395 | 395 | |
| 396 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 396 | + if ( empty( $file ) || ! file_exists( $file ) ) { |
|
| 397 | 397 | gravityview()->log->error( 'Importing Preset Fields. File not found. (File) {path}', array( 'path' => $file ) ); |
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if( !class_exists('WXR_Parser') ) { |
|
| 401 | + if ( ! class_exists( 'WXR_Parser' ) ) { |
|
| 402 | 402 | include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $parser = new WXR_Parser(); |
| 406 | 406 | $presets = $parser->parse( $file ); |
| 407 | 407 | |
| 408 | - if(is_wp_error( $presets )) { |
|
| 408 | + if ( is_wp_error( $presets ) ) { |
|
| 409 | 409 | gravityview()->log->error( 'Importing Preset Fields failed. Threw WP_Error.', array( 'data' => $presets ) ); |
| 410 | 410 | return false; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 413 | + if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) { |
|
| 414 | 414 | gravityview()->log->error( 'Importing Preset Fields failed. Meta not found in file. {path}', array( 'path' => $file ) ); |
| 415 | 415 | return false; |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets['posts'][0]['postmeta'] ) ); |
|
| 418 | + gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ); |
|
| 419 | 419 | |
| 420 | 420 | $fields = $widgets = array(); |
| 421 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 422 | - switch ($meta['key']) { |
|
| 421 | + foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) { |
|
| 422 | + switch ( $meta[ 'key' ] ) { |
|
| 423 | 423 | case '_gravityview_directory_fields': |
| 424 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 424 | + $fields = maybe_unserialize( $meta[ 'value' ] ); |
|
| 425 | 425 | break; |
| 426 | 426 | case '_gravityview_directory_widgets': |
| 427 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 427 | + $widgets = maybe_unserialize( $meta[ 'value' ] ); |
|
| 428 | 428 | break; |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -115,12 +115,12 @@ discard block |
||
| 115 | 115 | public function duplicate_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 116 | 116 | |
| 117 | 117 | // Always a link, never a filter, always same window |
| 118 | - unset( $field_options['show_as_link'], $field_options['search_filter'], $field_options['new_window'] ); |
|
| 118 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ], $field_options[ 'new_window' ] ); |
|
| 119 | 119 | |
| 120 | 120 | // Duplicate Entry link should only appear to visitors capable of editing entries |
| 121 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 121 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 122 | 122 | |
| 123 | - $add_option['duplicate_link'] = array( |
|
| 123 | + $add_option[ 'duplicate_link' ] = array( |
|
| 124 | 124 | 'type' => 'text', |
| 125 | 125 | 'label' => __( 'Duplicate Link Text', 'gravityview' ), |
| 126 | 126 | 'desc' => NULL, |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | 'merge_tags' => true, |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - $field_options['allow_duplicate_cap'] = array( |
|
| 131 | + $field_options[ 'allow_duplicate_cap' ] = array( |
|
| 132 | 132 | 'type' => 'select', |
| 133 | 133 | 'label' => __( 'Allow the following users to duplicate the entry:', 'gravityview' ), |
| 134 | 134 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | public function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
| 156 | 156 | |
| 157 | 157 | if ( 'edit' !== $zone ) { |
| 158 | - $entry_default_fields['duplicate_link'] = array( |
|
| 158 | + $entry_default_fields[ 'duplicate_link' ] = array( |
|
| 159 | 159 | 'label' => __( 'Duplicate Entry', 'gravityview' ), |
| 160 | 160 | 'type' => 'duplicate_link', |
| 161 | 161 | 'desc' => __( 'A link to duplicate the entry. Respects the Duplicate Entry permissions.', 'gravityview' ), |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function add_available_field( $available_fields = array() ) { |
| 178 | 178 | |
| 179 | - $available_fields['duplicate_link'] = array( |
|
| 179 | + $available_fields[ 'duplicate_link' ] = array( |
|
| 180 | 180 | 'label_text' => __( 'Duplicate Entry', 'gravityview' ), |
| 181 | 181 | 'field_id' => 'duplicate_link', |
| 182 | 182 | 'label_type' => 'field', |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | if ( 'duplicate_link' === $field_id ) { |
| 210 | 210 | |
| 211 | 211 | // Remove other built-in caps. |
| 212 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['duplicate_others_posts'] ); |
|
| 212 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'duplicate_others_posts' ] ); |
|
| 213 | 213 | |
| 214 | - $caps['read'] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 214 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | return $caps; |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | */ |
| 247 | 247 | public static function get_duplicate_link( $entry, $view_id, $post_id = null ) { |
| 248 | 248 | |
| 249 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
| 249 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
| 250 | 250 | |
| 251 | 251 | if ( empty( $base ) ) { |
| 252 | 252 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $actionurl = add_query_arg( array( |
| 257 | 257 | 'action' => 'duplicate', |
| 258 | - 'entry_id' => $entry['id'], |
|
| 258 | + 'entry_id' => $entry[ 'id' ], |
|
| 259 | 259 | 'gvid' => $view_id, |
| 260 | 260 | 'view_id' => $view_id, |
| 261 | 261 | ), $base ); |
| 262 | 262 | |
| 263 | - return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry['id'] ) ), $actionurl ); |
|
| 263 | + return add_query_arg( 'duplicate', wp_create_nonce( self::get_nonce_key( $entry[ 'id' ] ) ), $actionurl ); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -281,12 +281,12 @@ discard block |
||
| 281 | 281 | public function process_duplicate() { |
| 282 | 282 | |
| 283 | 283 | // If the form is submitted |
| 284 | - if ( ( ! isset( $_GET['action'] ) ) || 'duplicate' !== $_GET['action'] || ( ! isset( $_GET['entry_id'] ) ) ) { |
|
| 284 | + if ( ( ! isset( $_GET[ 'action' ] ) ) || 'duplicate' !== $_GET[ 'action' ] || ( ! isset( $_GET[ 'entry_id' ] ) ) ) { |
|
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | // Make sure it's a GravityView request |
| 289 | - $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET['entry_id'] ) ); |
|
| 289 | + $valid_nonce_key = wp_verify_nonce( \GV\Utils::_GET( 'duplicate' ), self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
| 290 | 290 | |
| 291 | 291 | if ( ! $valid_nonce_key ) { |
| 292 | 292 | gravityview()->log->debug( 'Duplicate entry not processed: nonce validation failed.' ); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Get the entry slug |
| 297 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
| 297 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
| 298 | 298 | |
| 299 | 299 | // See if there's an entry there |
| 300 | 300 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
@@ -388,15 +388,15 @@ discard block |
||
| 388 | 388 | return new WP_Error( 'gravityview-duplicate-entry-missing', __( 'The entry does not exist.', 'gravityview' ) ); |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $row['id'] = null; |
|
| 392 | - $row['date_created'] = date( 'Y-m-d H:i:s', time() ); |
|
| 393 | - $row['date_updated'] = $row['date_created']; |
|
| 394 | - $row['is_starred'] = false; |
|
| 395 | - $row['is_read'] = false; |
|
| 396 | - $row['ip'] = GFFormsModel::get_ip(); |
|
| 397 | - $row['source_url'] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
| 398 | - $row['user_agent'] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
| 399 | - $row['created_by'] = wp_get_current_user()->ID; |
|
| 391 | + $row[ 'id' ] = null; |
|
| 392 | + $row[ 'date_created' ] = date( 'Y-m-d H:i:s', time() ); |
|
| 393 | + $row[ 'date_updated' ] = $row[ 'date_created' ]; |
|
| 394 | + $row[ 'is_starred' ] = false; |
|
| 395 | + $row[ 'is_read' ] = false; |
|
| 396 | + $row[ 'ip' ] = GFFormsModel::get_ip(); |
|
| 397 | + $row[ 'source_url' ] = esc_url_raw( remove_query_arg( array( 'action', 'gvid' ) ) ); |
|
| 398 | + $row[ 'user_agent' ] = \GV\Utils::_SERVER( 'HTTP_USER_AGENT' ); |
|
| 399 | + $row[ 'created_by' ] = wp_get_current_user()->ID; |
|
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | 402 | * @filter `gravityview/entry/duplicate/details` Modify the new entry details before it's created. |
@@ -424,15 +424,15 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | $save_this_meta = array(); |
| 426 | 426 | foreach ( $duplicate_meta->get_output() as $m ) { |
| 427 | - $save_this_meta[] = array( |
|
| 428 | - 'meta_key' => $m['meta_key'], |
|
| 429 | - 'meta_value' => $m['meta_value'], |
|
| 430 | - 'item_index' => $m['item_index'], |
|
| 427 | + $save_this_meta[ ] = array( |
|
| 428 | + 'meta_key' => $m[ 'meta_key' ], |
|
| 429 | + 'meta_value' => $m[ 'meta_value' ], |
|
| 430 | + 'item_index' => $m[ 'item_index' ], |
|
| 431 | 431 | ); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // Update the row ID for later usage |
| 435 | - $row['id'] = $duplicated_id; |
|
| 435 | + $row[ 'id' ] = $duplicated_id; |
|
| 436 | 436 | |
| 437 | 437 | /** |
| 438 | 438 | * @filter `gravityview/entry/duplicate/meta` Modify the new entry meta details. |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | $save_this_meta = apply_filters( 'gravityview/entry/duplicate/meta', $save_this_meta, $row, $entry ); |
| 444 | 444 | |
| 445 | 445 | foreach ( $save_this_meta as $data ) { |
| 446 | - $data['form_id'] = $entry['form_id']; |
|
| 447 | - $data['entry_id'] = $duplicated_id; |
|
| 446 | + $data[ 'form_id' ] = $entry[ 'form_id' ]; |
|
| 447 | + $data[ 'entry_id' ] = $duplicated_id; |
|
| 448 | 448 | |
| 449 | 449 | if ( ! $wpdb->insert( $entry_meta_table, $data ) ) { |
| 450 | 450 | return new WP_Error( 'gravityview-duplicate-entry-db-meta', __( 'There was an error duplicating the entry.', 'gravityview' ) ); |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | public function verify_nonce() { |
| 479 | 479 | |
| 480 | 480 | // No duplicate entry request was made |
| 481 | - if ( empty( $_GET['entry_id'] ) || empty( $_GET['duplicate'] ) ) { |
|
| 481 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
| 482 | 482 | return false; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
| 485 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
| 486 | 486 | |
| 487 | - $valid = wp_verify_nonce( $_GET['duplicate'], $nonce_key ); |
|
| 487 | + $valid = wp_verify_nonce( $_GET[ 'duplicate' ], $nonce_key ); |
|
| 488 | 488 | |
| 489 | 489 | /** |
| 490 | 490 | * @filter `gravityview/duplicate-entry/verify_nonce` Override Duplicate Entry nonce validation. Return true to declare nonce valid. |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | return ''; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
| 523 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | public static function check_user_cap_duplicate_entry( $entry, $field = array(), $view_id = 0 ) { |
| 575 | 575 | $current_user = wp_get_current_user(); |
| 576 | 576 | |
| 577 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : null; |
|
| 577 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : null; |
|
| 578 | 578 | |
| 579 | 579 | // Or if they can duplicate any entries (as defined in Gravity Forms), we're good. |
| 580 | 580 | if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gform_full_access', 'gravityview_full_access' ), $entry_id ) ) { |
@@ -589,17 +589,17 @@ discard block |
||
| 589 | 589 | if ( ! empty( $field ) ) { |
| 590 | 590 | |
| 591 | 591 | // If capability is not defined, something is not right! |
| 592 | - if ( empty( $field['allow_duplicate_cap'] ) ) { |
|
| 592 | + if ( empty( $field[ 'allow_duplicate_cap' ] ) ) { |
|
| 593 | 593 | |
| 594 | 594 | gravityview()->log->error( 'Cannot read duplicate entry field caps', array( 'data' => $field ) ); |
| 595 | 595 | |
| 596 | 596 | return false; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - if ( GVCommon::has_cap( $field['allow_duplicate_cap'] ) ) { |
|
| 599 | + if ( GVCommon::has_cap( $field[ 'allow_duplicate_cap' ] ) ) { |
|
| 600 | 600 | |
| 601 | 601 | // Do not return true if cap is read, as we need to check if the current user created the entry |
| 602 | - if ( 'read' !== $field['allow_duplicate_cap'] ) { |
|
| 602 | + if ( 'read' !== $field[ 'allow_duplicate_cap' ] ) { |
|
| 603 | 603 | return true; |
| 604 | 604 | } |
| 605 | 605 | |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if ( ! isset( $entry['created_by'] ) ) { |
|
| 615 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
| 616 | 616 | |
| 617 | 617 | gravityview()->log->error( 'Cannot duplicate entry; entry `created_by` doesn\'t exist.' ); |
| 618 | 618 | |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // If the logged-in user is the same as the user who created the entry, we're good. |
| 640 | - if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
| 640 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
| 641 | 641 | |
| 642 | 642 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
| 643 | 643 | |
@@ -661,12 +661,12 @@ discard block |
||
| 661 | 661 | * @return void |
| 662 | 662 | */ |
| 663 | 663 | public function maybe_display_message( $current_view_id = 0 ) { |
| 664 | - if ( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
| 664 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
| 665 | 665 | return; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | // Entry wasn't duplicated from current View |
| 669 | - if ( isset( $_GET['view_id'] ) && ( intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) ) { |
|
| 669 | + if ( isset( $_GET[ 'view_id' ] ) && ( intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) ) { |
|
| 670 | 670 | return; |
| 671 | 671 | } |
| 672 | 672 | |
@@ -674,11 +674,11 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | public function display_message() { |
| 677 | - if ( empty( $_GET['status'] ) || empty( $_GET['duplicate'] ) ) { |
|
| 677 | + if ( empty( $_GET[ 'status' ] ) || empty( $_GET[ 'duplicate' ] ) ) { |
|
| 678 | 678 | return; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - $status = esc_attr( $_GET['status'] ); |
|
| 681 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
| 682 | 682 | $message_from_url = \GV\Utils::_GET( 'message' ); |
| 683 | 683 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
| 684 | 684 | $class = ''; |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | $message = apply_filters( 'gravityview/duplicate-entry/message', esc_attr( $message ), $status, $message_from_url ); |
| 705 | 705 | |
| 706 | 706 | // DISPLAY ERROR/SUCCESS MESSAGE |
| 707 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
| 707 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | ?> |
| 736 | 736 | <span class="gv-duplicate"> |
| 737 | 737 | | |
| 738 | - <a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry['id'] ), self::get_nonce_key( $entry['id'] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a> |
|
| 738 | + <a href="<?php echo wp_nonce_url( add_query_arg( 'entry_id', $entry[ 'id' ] ), self::get_nonce_key( $entry[ 'id' ] ), 'duplicate' ); ?>"><?php esc_html_e( 'Duplicate', 'gravityview' ); ?></a> |
|
| 739 | 739 | </span> |
| 740 | 740 | <?php |
| 741 | 741 | } |
@@ -757,9 +757,9 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | if ( 'success' === \GV\Utils::_GET( 'result' ) ) { |
| 759 | 759 | add_filter( 'gform_admin_messages', function( $messages ) { |
| 760 | - $messages = (array) $messages; |
|
| 760 | + $messages = (array)$messages; |
|
| 761 | 761 | |
| 762 | - $messages[] = esc_html__( 'Entry duplicated.', 'gravityview' ); |
|
| 762 | + $messages[ ] = esc_html__( 'Entry duplicated.', 'gravityview' ); |
|
| 763 | 763 | return $messages; |
| 764 | 764 | } ); |
| 765 | 765 | } |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | $check_logs_message = ''; |
| 772 | 772 | |
| 773 | - if( $is_logging_active ) { |
|
| 773 | + if ( $is_logging_active ) { |
|
| 774 | 774 | $check_logs_message = sprintf( ' <a href="%s">%s</a>', |
| 775 | 775 | esc_url( admin_url( 'admin.php?page=gf_settings&subview=gravityformslogging' ) ), |
| 776 | 776 | esc_html_x( 'Check the GravityView logs for more information.', 'Error message links to logging page', 'gravityview' ) |
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | add_filter( 'gform_admin_error_messages', function( $messages ) use ( $check_logs_message ) { |
| 781 | - $messages = (array) $messages; |
|
| 781 | + $messages = (array)$messages; |
|
| 782 | 782 | |
| 783 | - $messages[] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message; |
|
| 783 | + $messages[ ] = esc_html__( 'There was an error duplicating the entry.', 'gravityview' ) . $check_logs_message; |
|
| 784 | 784 | |
| 785 | 785 | return $messages; |
| 786 | 786 | } ); |