@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | $delete = $this->get_delete_setting(); |
| 36 | 36 | |
| 37 | - if( GravityView_Roles_Capabilities::has_cap( 'gravityview_uninstall' ) && 'delete' === $delete ) { |
|
| 37 | + if ( GravityView_Roles_Capabilities::has_cap( 'gravityview_uninstall' ) && 'delete' === $delete ) { |
|
| 38 | 38 | $this->fire_everything(); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $notes_table = class_exists( 'GFFormsModel' ) ? GFFormsModel::get_lead_notes_table_name() : $wpdb->prefix . 'rg_lead_notes'; |
| 99 | 99 | |
| 100 | - $disapproved = __('Disapproved the Entry for GravityView', 'gravityview'); |
|
| 101 | - $approved = __('Approved the Entry for GravityView', 'gravityview'); |
|
| 100 | + $disapproved = __( 'Disapproved the Entry for GravityView', 'gravityview' ); |
|
| 101 | + $approved = __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
| 102 | 102 | |
| 103 | 103 | $sql = $wpdb->prepare( " |
| 104 | 104 | DELETE FROM $notes_table |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param mixed $field_id Field ID or Field array |
| 290 | 290 | * @return string field type |
| 291 | 291 | */ |
| 292 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
| 293 | - return GVCommon::get_field_type( $form, $field_id ); |
|
| 292 | +function gravityview_get_field_type( $form = null, $field_id = '' ) { |
|
| 293 | + return GVCommon::get_field_type( $form, $field_id ); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | * @return string HTML of the output. Empty string if $view_id is empty. |
| 304 | 304 | */ |
| 305 | 305 | function get_gravityview( $view_id = '', $atts = array() ) { |
| 306 | - if( !empty( $view_id ) ) { |
|
| 307 | - $atts['id'] = $view_id; |
|
| 306 | + if ( ! empty( $view_id ) ) { |
|
| 307 | + $atts[ 'id' ] = $view_id; |
|
| 308 | 308 | $args = wp_parse_args( $atts, GravityView_View_Data::get_default_args() ); |
| 309 | 309 | $GravityView_frontend = GravityView_frontend::getInstance(); |
| 310 | 310 | $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
@@ -347,15 +347,15 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
| 349 | 349 | |
| 350 | - if( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 350 | + if ( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 351 | 351 | |
| 352 | 352 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
| 353 | - foreach( $form_fields as $form_field ) { |
|
| 353 | + foreach ( $form_fields as $form_field ) { |
|
| 354 | 354 | $field_id = $form_field->id; |
| 355 | - foreach( $view_fields as $zone ) { |
|
| 356 | - foreach( $zone as $field ) { |
|
| 355 | + foreach ( $view_fields as $zone ) { |
|
| 356 | + foreach ( $zone as $field ) { |
|
| 357 | 357 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
| 358 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
| 358 | + if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) { |
|
| 359 | 359 | return true; |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -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 | do_action( 'gravityview_render_available_fields', $form, $context ); |
| 79 | 79 | $this->_exit(); |
| 80 | 80 | } |
@@ -94,17 +94,17 @@ discard block |
||
| 94 | 94 | function get_active_areas() { |
| 95 | 95 | $this->check_ajax_nonce(); |
| 96 | 96 | |
| 97 | - if( empty( $_POST['template_id'] ) ) { |
|
| 97 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 98 | 98 | $this->_exit( false ); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | ob_start(); |
| 102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 103 | - $response['directory'] = ob_get_clean(); |
|
| 102 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true ); |
|
| 103 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 104 | 104 | |
| 105 | 105 | ob_start(); |
| 106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 107 | - $response['single'] = ob_get_clean(); |
|
| 106 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true ); |
|
| 107 | + $response[ 'single' ] = ob_get_clean(); |
|
| 108 | 108 | |
| 109 | 109 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 110 | 110 | |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->check_ajax_nonce(); |
| 121 | 121 | |
| 122 | - if( empty( $_POST['template_id'] ) ) { |
|
| 122 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 123 | 123 | $this->_exit( false ); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // get the fields xml config file for this specific preset |
| 127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 127 | + $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] ); |
|
| 128 | 128 | // import fields |
| 129 | - if( !empty( $preset_fields_path ) ) { |
|
| 129 | + if ( ! empty( $preset_fields_path ) ) { |
|
| 130 | 130 | $presets = $this->import_fields( $preset_fields_path ); |
| 131 | 131 | } else { |
| 132 | 132 | $presets = array( 'widgets' => array(), 'fields' => array() ); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 135 | + $template_id = esc_attr( $_POST[ 'template_id' ] ); |
|
| 136 | 136 | |
| 137 | 137 | // template areas |
| 138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
@@ -142,20 +142,20 @@ discard block |
||
| 142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
| 143 | 143 | |
| 144 | 144 | ob_start(); |
| 145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 146 | - $response['header'] = ob_get_clean(); |
|
| 145 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 146 | + $response[ 'header' ] = ob_get_clean(); |
|
| 147 | 147 | |
| 148 | 148 | ob_start(); |
| 149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 150 | - $response['footer'] = ob_get_clean(); |
|
| 149 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 150 | + $response[ 'footer' ] = ob_get_clean(); |
|
| 151 | 151 | |
| 152 | 152 | ob_start(); |
| 153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 154 | - $response['directory'] = ob_get_clean(); |
|
| 153 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] ); |
|
| 154 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 155 | 155 | |
| 156 | 156 | ob_start(); |
| 157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 158 | - $response['single'] = ob_get_clean(); |
|
| 157 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] ); |
|
| 158 | + $response[ 'single' ] = ob_get_clean(); |
|
| 159 | 159 | |
| 160 | 160 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 161 | 161 | |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $this->check_ajax_nonce(); |
| 175 | 175 | |
| 176 | - if( empty( $_POST['template_id'] ) ) { |
|
| 176 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 177 | 177 | do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
| 178 | 178 | $this->_exit( false ); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // get the xml for this specific template_id |
| 182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 182 | + $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] ); |
|
| 183 | 183 | |
| 184 | 184 | // import form |
| 185 | 185 | $form = $this->import_form( $preset_form_xml_path ); |
| 186 | 186 | |
| 187 | 187 | // get the form ID |
| 188 | - if( false === $form ) { |
|
| 188 | + if ( false === $form ) { |
|
| 189 | 189 | // send error to user |
| 190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
| 190 | + do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int)$_POST[ 'template_id' ] ); |
|
| 191 | 191 | |
| 192 | 192 | $this->_exit( false ); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 195 | + $this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' ); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
| 208 | 208 | |
| 209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 209 | + if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) { |
|
| 210 | 210 | do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
| 211 | 211 | return false; |
| 212 | 212 | } |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
| 219 | 219 | do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
| 220 | 220 | |
| 221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 221 | + if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) { |
|
| 222 | 222 | do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // import success - return form id |
| 227 | - return $forms[0]; |
|
| 227 | + return $forms[ 0 ]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | function get_field_options() { |
| 239 | 239 | $this->check_ajax_nonce(); |
| 240 | 240 | |
| 241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 241 | + if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) { |
|
| 242 | 242 | do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
| 243 | 243 | $this->_exit( false ); |
| 244 | 244 | } |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | $_post = array_map( 'esc_attr', $_post ); |
| 251 | 251 | |
| 252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 253 | + $input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL; |
|
| 254 | + $context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL; |
|
| 255 | 255 | |
| 256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
| 256 | + $response = GravityView_Render_Settings::render_field_options( $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context ); |
|
| 257 | 257 | |
| 258 | 258 | $response = gravityview_strip_whitespace( $response ); |
| 259 | 259 | |
@@ -274,15 +274,15 @@ discard block |
||
| 274 | 274 | $form = ''; |
| 275 | 275 | |
| 276 | 276 | // if form id is set, use it, else, get form from preset |
| 277 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 277 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 278 | 278 | |
| 279 | - $form = (int) $_POST['form_id']; |
|
| 279 | + $form = (int)$_POST[ 'form_id' ]; |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | // get form from preset |
| 283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 283 | + elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 284 | 284 | |
| 285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 285 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 286 | 286 | |
| 287 | 287 | } |
| 288 | 288 | |
@@ -298,27 +298,27 @@ discard block |
||
| 298 | 298 | * @param string $template_id Preset template |
| 299 | 299 | * |
| 300 | 300 | */ |
| 301 | - static function pre_get_form_fields( $template_id = '') { |
|
| 301 | + static function pre_get_form_fields( $template_id = '' ) { |
|
| 302 | 302 | |
| 303 | - if( empty( $template_id ) ) { |
|
| 303 | + if ( empty( $template_id ) ) { |
|
| 304 | 304 | do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
| 305 | 305 | return false; |
| 306 | 306 | } else { |
| 307 | 307 | $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
| 308 | - if( !file_exists( $form_file ) ) { |
|
| 309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
| 308 | + if ( ! file_exists( $form_file ) ) { |
|
| 309 | + do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset [' . $template_id . ']. File not found. file: ' . $form_file ); |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Load xml parser (from GravityForms) |
| 315 | - if( class_exists( 'GFCommon' ) ) { |
|
| 315 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 316 | 316 | $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
| 317 | 317 | } else { |
| 318 | 318 | $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if( file_exists( $xml_parser ) ) { |
|
| 321 | + if ( file_exists( $xml_parser ) ) { |
|
| 322 | 322 | require_once( $xml_parser ); |
| 323 | 323 | } else { |
| 324 | 324 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
@@ -329,37 +329,37 @@ discard block |
||
| 329 | 329 | $xmlstr = file_get_contents( $form_file ); |
| 330 | 330 | |
| 331 | 331 | $options = array( |
| 332 | - "page" => array("unserialize_as_array" => true), |
|
| 333 | - "form"=> array("unserialize_as_array" => true), |
|
| 334 | - "field"=> array("unserialize_as_array" => true), |
|
| 335 | - "rule"=> array("unserialize_as_array" => true), |
|
| 336 | - "choice"=> array("unserialize_as_array" => true), |
|
| 337 | - "input"=> array("unserialize_as_array" => true), |
|
| 338 | - "routing_item"=> array("unserialize_as_array" => true), |
|
| 339 | - "creditCard"=> array("unserialize_as_array" => true), |
|
| 340 | - "routin"=> array("unserialize_as_array" => true), |
|
| 341 | - "confirmation" => array("unserialize_as_array" => true), |
|
| 342 | - "notification" => array("unserialize_as_array" => true) |
|
| 332 | + "page" => array( "unserialize_as_array" => true ), |
|
| 333 | + "form"=> array( "unserialize_as_array" => true ), |
|
| 334 | + "field"=> array( "unserialize_as_array" => true ), |
|
| 335 | + "rule"=> array( "unserialize_as_array" => true ), |
|
| 336 | + "choice"=> array( "unserialize_as_array" => true ), |
|
| 337 | + "input"=> array( "unserialize_as_array" => true ), |
|
| 338 | + "routing_item"=> array( "unserialize_as_array" => true ), |
|
| 339 | + "creditCard"=> array( "unserialize_as_array" => true ), |
|
| 340 | + "routin"=> array( "unserialize_as_array" => true ), |
|
| 341 | + "confirmation" => array( "unserialize_as_array" => true ), |
|
| 342 | + "notification" => array( "unserialize_as_array" => true ) |
|
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | - $xml = new RGXML($options); |
|
| 346 | - $forms = $xml->unserialize($xmlstr); |
|
| 345 | + $xml = new RGXML( $options ); |
|
| 346 | + $forms = $xml->unserialize( $xmlstr ); |
|
| 347 | 347 | |
| 348 | - if( !$forms ) { |
|
| 349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
| 348 | + if ( ! $forms ) { |
|
| 349 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. Error importing file. (File)', $form_file ); |
|
| 350 | 350 | return false; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 354 | - $form = $forms[0]; |
|
| 353 | + if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) { |
|
| 354 | + $form = $forms[ 0 ]; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if( empty( $form ) ) { |
|
| 357 | + if ( empty( $form ) ) { |
|
| 358 | 358 | do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
| 362 | + do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset [' . $template_id . ']. (Form)', $form ); |
|
| 363 | 363 | |
| 364 | 364 | return $form; |
| 365 | 365 | |
@@ -373,38 +373,38 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | function import_fields( $file ) { |
| 375 | 375 | |
| 376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 376 | + if ( empty( $file ) || ! file_exists( $file ) ) { |
|
| 377 | 377 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( !class_exists('WXR_Parser') ) { |
|
| 381 | + if ( ! class_exists( 'WXR_Parser' ) ) { |
|
| 382 | 382 | include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $parser = new WXR_Parser(); |
| 386 | 386 | $presets = $parser->parse( $file ); |
| 387 | 387 | |
| 388 | - if(is_wp_error( $presets )) { |
|
| 388 | + if ( is_wp_error( $presets ) ) { |
|
| 389 | 389 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 393 | + if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) { |
|
| 394 | 394 | do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
| 395 | 395 | return false; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
| 398 | + do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets[ 'posts' ][ 0 ][ 'postmeta' ] ); |
|
| 399 | 399 | |
| 400 | 400 | $fields = $widgets = array(); |
| 401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 402 | - switch ($meta['key']) { |
|
| 401 | + foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) { |
|
| 402 | + switch ( $meta[ 'key' ] ) { |
|
| 403 | 403 | case '_gravityview_directory_fields': |
| 404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 404 | + $fields = maybe_unserialize( $meta[ 'value' ] ); |
|
| 405 | 405 | break; |
| 406 | 406 | case '_gravityview_directory_widgets': |
| 407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 407 | + $widgets = maybe_unserialize( $meta[ 'value' ] ); |
|
| 408 | 408 | break; |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | /** gf_entries page - entries table screen */ |
| 35 | 35 | |
| 36 | 36 | // capture bulk actions |
| 37 | - add_action( 'init', array( $this, 'process_bulk_action') ); |
|
| 37 | + add_action( 'init', array( $this, 'process_bulk_action' ) ); |
|
| 38 | 38 | // add hidden field with approve status |
| 39 | 39 | add_action( 'gform_entries_first_column', array( $this, 'add_entry_approved_hidden_input' ), 1, 5 ); |
| 40 | 40 | // process ajax approve entry requests |
| 41 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
| 41 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
| 42 | 42 | |
| 43 | 43 | // in case entry is edited (on admin or frontend) |
| 44 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
| 44 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
| 45 | 45 | |
| 46 | 46 | add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
| 47 | 47 | |
| 48 | 48 | // adding styles and scripts |
| 49 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles') ); |
|
| 49 | + add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ) ); |
|
| 50 | 50 | // bypass Gravity Forms no-conflict mode |
| 51 | 51 | add_filter( 'gform_noconflict_scripts', array( $this, 'register_gform_noconflict_script' ) ); |
| 52 | 52 | add_filter( 'gform_noconflict_styles', array( $this, 'register_gform_noconflict_style' ) ); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function tooltips( $tooltips ) { |
| 63 | 63 | |
| 64 | - $tooltips['form_gravityview_fields'] = array( |
|
| 65 | - 'title' => __('GravityView Fields', 'gravityview'), |
|
| 66 | - 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview'), |
|
| 64 | + $tooltips[ 'form_gravityview_fields' ] = array( |
|
| 65 | + 'title' => __( 'GravityView Fields', 'gravityview' ), |
|
| 66 | + 'value' => __( 'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.', 'gravityview' ), |
|
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | 69 | return $tooltips; |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // gforms_update_note is sent when bulk editing entry notes. We don't want to process then. |
| 181 | - if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST['gforms_update_note'] ) ) { |
|
| 181 | + if ( 'bulk' === RGForms::post( 'action' ) && empty( $_POST[ 'gforms_update_note' ] ) ) { |
|
| 182 | 182 | |
| 183 | 183 | check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); |
| 184 | 184 | |
| 185 | 185 | // The action is formatted like: approve-16 or disapprove-16, where the first word is the name of the action and the second is the ID of the form. Bulk action 2 is the bottom bulk action select form. |
| 186 | - $bulk_action = ! empty( $_POST['bulk_action'] ) ? $_POST['bulk_action'] : $_POST['bulk_action2']; |
|
| 186 | + $bulk_action = ! empty( $_POST[ 'bulk_action' ] ) ? $_POST[ 'bulk_action' ] : $_POST[ 'bulk_action2' ]; |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * The extra '-' is to make sure that there are at *least* two items in array. |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | // All entries are set to be updated, not just the visible ones |
| 202 | - if ( ! empty( $_POST['all_entries'] ) ) { |
|
| 202 | + if ( ! empty( $_POST[ 'all_entries' ] ) ) { |
|
| 203 | 203 | |
| 204 | 204 | // Convert the current entry search into GF-formatted search criteria |
| 205 | 205 | $search = array( |
| 206 | - 'search_field' => isset( $_POST['f'] ) ? $_POST['f'][0] : 0, |
|
| 207 | - 'search_value' => isset( $_POST['v'][0] ) ? $_POST['v'][0] : '', |
|
| 208 | - 'search_operator' => isset( $_POST['o'][0] ) ? $_POST['o'][0] : 'contains', |
|
| 206 | + 'search_field' => isset( $_POST[ 'f' ] ) ? $_POST[ 'f' ][ 0 ] : 0, |
|
| 207 | + 'search_value' => isset( $_POST[ 'v' ][ 0 ] ) ? $_POST[ 'v' ][ 0 ] : '', |
|
| 208 | + 'search_operator' => isset( $_POST[ 'o' ][ 0 ] ) ? $_POST[ 'o' ][ 0 ] : 'contains', |
|
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | 211 | $search_criteria = GravityView_frontend::get_search_criteria( $search, $form_id ); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | } else { |
| 217 | 217 | |
| 218 | - $entries = $_POST['lead']; |
|
| 218 | + $entries = $_POST[ 'lead' ]; |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | private static function update_bulk( $entries, $approved, $form_id ) { |
| 258 | 258 | |
| 259 | - if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) { |
|
| 259 | + if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) { |
|
| 260 | 260 | do_action( 'gravityview_log_error', __METHOD__ . ' Entries were empty or malformed.', $entries ); |
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 264 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
| 265 | 265 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 266 | 266 | return false; |
| 267 | 267 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | // calculate approved field id |
| 272 | 272 | $approved_column_id = self::get_approved_column( $form_id ); |
| 273 | 273 | |
| 274 | - foreach( $entries as $entry_id ) { |
|
| 274 | + foreach ( $entries as $entry_id ) { |
|
| 275 | 275 | self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | * @param int $approvedcolumn (default: 0) |
| 291 | 291 | * @return boolean True: It worked; False: it failed |
| 292 | 292 | */ |
| 293 | - public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0) { |
|
| 293 | + public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
|
| 294 | 294 | |
| 295 | - if( !class_exists( 'GFAPI' ) ) { |
|
| 295 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
| 296 | 296 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - if( empty( $approvedcolumn ) ) { |
|
| 300 | + if ( empty( $approvedcolumn ) ) { |
|
| 301 | 301 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | self::update_approved_meta( $entry_id, $approved ); |
| 317 | 317 | |
| 318 | 318 | // add note to entry |
| 319 | - if( $result === true ) { |
|
| 319 | + if ( $result === true ) { |
|
| 320 | 320 | $note = empty( $approved ) ? __( 'Disapproved the Entry for GravityView', 'gravityview' ) : __( 'Approved the Entry for GravityView', 'gravityview' ); |
| 321 | 321 | |
| 322 | - if( class_exists( 'GravityView_Entry_Notes' ) ){ |
|
| 322 | + if ( class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 323 | 323 | global $current_user; |
| 324 | 324 | get_currentuserinfo(); |
| 325 | 325 | GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $current_user->display_name, $note ); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | do_action( 'gravityview_clear_form_cache', $form_id ); |
| 334 | 334 | |
| 335 | - } else if( is_wp_error( $result ) ) { |
|
| 335 | + } else if ( is_wp_error( $result ) ) { |
|
| 336 | 336 | |
| 337 | 337 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
| 338 | 338 | |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public static function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
| 356 | 356 | |
| 357 | - $approvedcolumn = self::get_approved_column( $form['id'] ); |
|
| 357 | + $approvedcolumn = self::get_approved_column( $form[ 'id' ] ); |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * If the form doesn't contain the approve field, don't assume anything. |
| 361 | 361 | */ |
| 362 | - if( empty( $approvedcolumn ) ) { |
|
| 362 | + if ( empty( $approvedcolumn ) ) { |
|
| 363 | 363 | return; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | private static function update_approved_meta( $entry_id, $is_approved ) { |
| 382 | 382 | |
| 383 | 383 | // update entry meta |
| 384 | - if( function_exists('gform_update_meta') ) { |
|
| 384 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
| 385 | 385 | |
| 386 | 386 | gform_update_meta( $entry_id, 'is_approved', $is_approved ); |
| 387 | 387 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | do_action( 'gravityview/approve_entries/updated', $entry_id, $is_approved ); |
| 395 | 395 | |
| 396 | - if( empty( $is_approved ) ) { |
|
| 396 | + if ( empty( $is_approved ) ) { |
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * @action `gravityview/approve_entries/disapproved` Triggered when an entry is rejected |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | } else { |
| 417 | 417 | |
| 418 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 418 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 419 | 419 | |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -427,21 +427,21 @@ discard block |
||
| 427 | 427 | */ |
| 428 | 428 | public function ajax_update_approved() { |
| 429 | 429 | |
| 430 | - if( empty( $_POST['entry_id'] ) || empty( $_POST['form_id'] ) ) { |
|
| 430 | + if ( empty( $_POST[ 'entry_id' ] ) || empty( $_POST[ 'form_id' ] ) ) { |
|
| 431 | 431 | |
| 432 | 432 | do_action( 'gravityview_log_error', __METHOD__ . ' entry_id or form_id are empty.', $_POST ); |
| 433 | 433 | |
| 434 | 434 | $result = false; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - else if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxgfentries' ) ) { |
|
| 437 | + else if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxgfentries' ) ) { |
|
| 438 | 438 | |
| 439 | 439 | do_action( 'gravityview_log_error', __METHOD__ . ' Security check failed.', $_POST ); |
| 440 | 440 | |
| 441 | 441 | $result = false; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - else if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST['entry_id'] ) ) { |
|
| 444 | + else if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $_POST[ 'entry_id' ] ) ) { |
|
| 445 | 445 | |
| 446 | 446 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 447 | 447 | |
@@ -450,11 +450,11 @@ discard block |
||
| 450 | 450 | |
| 451 | 451 | else { |
| 452 | 452 | |
| 453 | - $result = self::update_approved( $_POST['entry_id'], $_POST['approved'], $_POST['form_id'] ); |
|
| 453 | + $result = self::update_approved( $_POST[ 'entry_id' ], $_POST[ 'approved' ], $_POST[ 'form_id' ] ); |
|
| 454 | 454 | |
| 455 | - if( is_wp_error( $result ) ) { |
|
| 455 | + if ( is_wp_error( $result ) ) { |
|
| 456 | 456 | /** @var WP_Error $result */ |
| 457 | - do_action( 'gravityview_log_error', __METHOD__ .' Error updating approval: ' . $result->get_error_message() ); |
|
| 457 | + do_action( 'gravityview_log_error', __METHOD__ . ' Error updating approval: ' . $result->get_error_message() ); |
|
| 458 | 458 | $result = false; |
| 459 | 459 | } |
| 460 | 460 | |
@@ -474,29 +474,29 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | static public function get_approved_column( $form ) { |
| 476 | 476 | |
| 477 | - if( empty( $form ) ) { |
|
| 477 | + if ( empty( $form ) ) { |
|
| 478 | 478 | return null; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if( !is_array( $form ) ) { |
|
| 481 | + if ( ! is_array( $form ) ) { |
|
| 482 | 482 | $form = GVCommon::get_form( $form ); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - foreach( $form['fields'] as $key => $field ) { |
|
| 485 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
| 486 | 486 | |
| 487 | - $field = (array) $field; |
|
| 487 | + $field = (array)$field; |
|
| 488 | 488 | |
| 489 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
| 490 | - if( !empty($field['inputs'][0]['id']) ) { |
|
| 491 | - return $field['inputs'][0]['id']; |
|
| 489 | + if ( ! empty( $field[ 'gravityview_approved' ] ) ) { |
|
| 490 | + if ( ! empty( $field[ 'inputs' ][ 0 ][ 'id' ] ) ) { |
|
| 491 | + return $field[ 'inputs' ][ 0 ][ 'id' ]; |
|
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
| 496 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
| 497 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
| 498 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
| 499 | - return $input['id']; |
|
| 496 | + if ( 'checkbox' == $field[ 'type' ] && isset( $field[ 'inputs' ] ) && is_array( $field[ 'inputs' ] ) ) { |
|
| 497 | + foreach ( $field[ 'inputs' ] as $key2 => $input ) { |
|
| 498 | + if ( strtolower( $input[ 'label' ] ) == 'approved' ) { |
|
| 499 | + return $input[ 'id' ]; |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -507,18 +507,18 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | |
| 509 | 509 | |
| 510 | - static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
| 510 | + static public function add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string ) { |
|
| 511 | 511 | |
| 512 | - if( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry['id'] ) ) { |
|
| 512 | + if ( ! GVCommon::has_cap( 'gravityview_moderate_entries', $entry[ 'id' ] ) ) { |
|
| 513 | 513 | return; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - if( empty( $entry['id'] ) ) { |
|
| 516 | + if ( empty( $entry[ 'id' ] ) ) { |
|
| 517 | 517 | return; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if( gform_get_meta( $entry['id'], 'is_approved' ) ) { |
|
| 521 | - echo '<input type="hidden" class="entry_approved" id="entry_approved_'. $entry['id'] .'" value="true" />'; |
|
| 520 | + if ( gform_get_meta( $entry[ 'id' ], 'is_approved' ) ) { |
|
| 521 | + echo '<input type="hidden" class="entry_approved" id="entry_approved_' . $entry[ 'id' ] . '" value="true" />'; |
|
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | function add_scripts_and_styles( $hook ) { |
| 529 | 529 | |
| 530 | - if( !class_exists( 'RGForms' ) ) { |
|
| 530 | + if ( ! class_exists( 'RGForms' ) ) { |
|
| 531 | 531 | |
| 532 | 532 | do_action( 'gravityview_log_error', 'GravityView_Admin_ApproveEntries[add_scripts_and_styles] RGForms does not exist.' ); |
| 533 | 533 | |
@@ -536,40 +536,40 @@ discard block |
||
| 536 | 536 | |
| 537 | 537 | // enqueue styles & scripts gf_entries |
| 538 | 538 | // But only if we're on the main Entries page, not on reports pages |
| 539 | - if( RGForms::get_page() === 'entry_list' ) { |
|
| 539 | + if ( RGForms::get_page() === 'entry_list' ) { |
|
| 540 | 540 | |
| 541 | - $form_id = RGForms::get('id'); |
|
| 541 | + $form_id = RGForms::get( 'id' ); |
|
| 542 | 542 | |
| 543 | 543 | // If there are no forms identified, use the first form. That's how GF does it. |
| 544 | - if( empty( $form_id ) && class_exists('RGFormsModel') ) { |
|
| 544 | + if ( empty( $form_id ) && class_exists( 'RGFormsModel' ) ) { |
|
| 545 | 545 | $forms = gravityview_get_forms(); |
| 546 | - if( !empty( $forms ) ) { |
|
| 547 | - $form_id = $forms[0]['id']; |
|
| 546 | + if ( ! empty( $forms ) ) { |
|
| 547 | + $form_id = $forms[ 0 ][ 'id' ]; |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 552 | 552 | |
| 553 | - wp_register_style( 'gravityview_entries_list', plugins_url('assets/css/admin-entries-list.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 553 | + wp_register_style( 'gravityview_entries_list', plugins_url( 'assets/css/admin-entries-list.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
| 554 | 554 | wp_enqueue_style( 'gravityview_entries_list' ); |
| 555 | 555 | |
| 556 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 556 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 557 | 557 | |
| 558 | - wp_register_script( 'gravityview_gf_entries_scripts', plugins_url('assets/js/admin-entries-list'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version ); |
|
| 558 | + wp_register_script( 'gravityview_gf_entries_scripts', plugins_url( 'assets/js/admin-entries-list' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version ); |
|
| 559 | 559 | wp_enqueue_script( 'gravityview_gf_entries_scripts' ); |
| 560 | 560 | |
| 561 | 561 | wp_localize_script( 'gravityview_gf_entries_scripts', 'gvGlobals', array( |
| 562 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries'), |
|
| 562 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxgfentries' ), |
|
| 563 | 563 | 'form_id' => $form_id, |
| 564 | 564 | 'show_column' => (int)$this->show_approve_entry_column( $form_id ), |
| 565 | 565 | 'add_bulk_action' => (int)GVCommon::has_cap( 'gravityview_moderate_entries' ), |
| 566 | - 'label_approve' => __( 'Approve', 'gravityview' ) , |
|
| 566 | + 'label_approve' => __( 'Approve', 'gravityview' ), |
|
| 567 | 567 | 'label_disapprove' => __( 'Disapprove', 'gravityview' ), |
| 568 | 568 | 'bulk_message' => $this->bulk_update_message, |
| 569 | - 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview'), |
|
| 570 | - 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview'), |
|
| 571 | - 'column_title' => __( 'Show entry in directory view?', 'gravityview'), |
|
| 572 | - 'column_link' => esc_url( add_query_arg( array('sort' => $approvedcolumn) ) ), |
|
| 569 | + 'approve_title' => __( 'Entry not approved for directory viewing. Click to approve this entry.', 'gravityview' ), |
|
| 570 | + 'unapprove_title' => __( 'Entry approved for directory viewing. Click to disapprove this entry.', 'gravityview' ), |
|
| 571 | + 'column_title' => __( 'Show entry in directory view?', 'gravityview' ), |
|
| 572 | + 'column_link' => esc_url( add_query_arg( array( 'sort' => $approvedcolumn ) ) ), |
|
| 573 | 573 | ) ); |
| 574 | 574 | |
| 575 | 575 | } |
@@ -594,13 +594,13 @@ discard block |
||
| 594 | 594 | * @since 1.7.2 |
| 595 | 595 | * @param boolean $hide_if_no_connections |
| 596 | 596 | */ |
| 597 | - $hide_if_no_connections = apply_filters('gravityview/approve_entries/hide-if-no-connections', false ); |
|
| 597 | + $hide_if_no_connections = apply_filters( 'gravityview/approve_entries/hide-if-no-connections', false ); |
|
| 598 | 598 | |
| 599 | - if( $hide_if_no_connections ) { |
|
| 599 | + if ( $hide_if_no_connections ) { |
|
| 600 | 600 | |
| 601 | 601 | $connected_views = gravityview_get_connected_views( $form_id ); |
| 602 | 602 | |
| 603 | - if( empty( $connected_views ) ) { |
|
| 603 | + if ( empty( $connected_views ) ) { |
|
| 604 | 604 | $show_approve_column = false; |
| 605 | 605 | } |
| 606 | 606 | } |
@@ -610,18 +610,18 @@ discard block |
||
| 610 | 610 | * @param boolean $show_approve_column Whether the column will be shown |
| 611 | 611 | * @param int $form_id The ID of the Gravity Forms form for which entries are being shown |
| 612 | 612 | */ |
| 613 | - $show_approve_column = apply_filters('gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
| 613 | + $show_approve_column = apply_filters( 'gravityview/approve_entries/show-column', $show_approve_column, $form_id ); |
|
| 614 | 614 | |
| 615 | 615 | return $show_approve_column; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | function register_gform_noconflict_script( $scripts ) { |
| 619 | - $scripts[] = 'gravityview_gf_entries_scripts'; |
|
| 619 | + $scripts[ ] = 'gravityview_gf_entries_scripts'; |
|
| 620 | 620 | return $scripts; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | function register_gform_noconflict_style( $styles ) { |
| 624 | - $styles[] = 'gravityview_entries_list'; |
|
| 624 | + $styles[ ] = 'gravityview_entries_list'; |
|
| 625 | 625 | return $styles; |
| 626 | 626 | } |
| 627 | 627 | |
@@ -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 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $all = $administrator; |
| 305 | 305 | |
| 306 | 306 | // If role is set, return caps_to_check for just that role. |
| 307 | - if( $single_role ) { |
|
| 307 | + if ( $single_role ) { |
|
| 308 | 308 | $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
| 309 | 309 | return $flat_array ? $caps : array( $single_role => $caps ); |
| 310 | 310 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $has_cap = false; |
| 336 | 336 | |
| 337 | - if( empty( $caps_to_check ) ) { |
|
| 337 | + if ( empty( $caps_to_check ) ) { |
|
| 338 | 338 | return $has_cap; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -342,13 +342,13 @@ discard block |
||
| 342 | 342 | $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
| 343 | 343 | |
| 344 | 344 | foreach ( $caps_to_check as $cap ) { |
| 345 | - if( ! is_null( $object_id ) ) { |
|
| 345 | + if ( ! is_null( $object_id ) ) { |
|
| 346 | 346 | $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
| 347 | 347 | } else { |
| 348 | 348 | $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
| 349 | 349 | } |
| 350 | 350 | // At the first successful response, stop checking |
| 351 | - if( $has_cap ) { |
|
| 351 | + if ( $has_cap ) { |
|
| 352 | 352 | break; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -372,15 +372,15 @@ discard block |
||
| 372 | 372 | $all_gravityview_caps = self::all_caps(); |
| 373 | 373 | |
| 374 | 374 | // Are there any $caps_to_check that are from GravityView? |
| 375 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 376 | - $caps_to_check[] = 'gravityview_full_access'; |
|
| 375 | + if ( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 376 | + $caps_to_check[ ] = 'gravityview_full_access'; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
| 380 | 380 | |
| 381 | 381 | // Are there any $caps_to_check that are from Gravity Forms? |
| 382 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 383 | - $caps_to_check[] = 'gform_full_access'; |
|
| 382 | + if ( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 383 | + $caps_to_check[ ] = 'gform_full_access'; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | return array_unique( $caps_to_check ); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $capabilities = self::all_caps(); |
| 403 | 403 | |
| 404 | 404 | // Loop through each role and remove GV caps_to_check |
| 405 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 405 | + foreach ( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 406 | 406 | foreach ( $capabilities as $cap ) { |
| 407 | 407 | $wp_roles->remove_cap( $role_slug, $cap ); |
| 408 | 408 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public static function get_instance() { |
| 87 | 87 | |
| 88 | - if( empty( self::$instance ) ) { |
|
| 88 | + if ( empty( self::$instance ) ) { |
|
| 89 | 89 | self::$instance = new self; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
| 120 | 120 | |
| 121 | - if( $with_values ) { |
|
| 121 | + if ( $with_values ) { |
|
| 122 | 122 | $operators_with_values = array(); |
| 123 | - foreach( $operators as $key ) { |
|
| 123 | + foreach ( $operators as $key ) { |
|
| 124 | 124 | $operators_with_values[ $key ] = ''; |
| 125 | 125 | } |
| 126 | 126 | return $operators_with_values; |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | function set_operation( $operation = '' ) { |
| 139 | 139 | |
| 140 | - if( empty( $operation ) ) { |
|
| 140 | + if ( empty( $operation ) ) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $operators = $this->get_operators( false ); |
| 145 | 145 | |
| 146 | - if( !in_array( $operation, $operators ) ) { |
|
| 147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
| 146 | + if ( ! in_array( $operation, $operators ) ) { |
|
| 147 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function setup_operation_and_comparison() { |
| 166 | 166 | |
| 167 | - foreach( $this->atts as $key => $value ) { |
|
| 167 | + foreach ( $this->atts as $key => $value ) { |
|
| 168 | 168 | |
| 169 | 169 | $valid = $this->set_operation( $key ); |
| 170 | 170 | |
| 171 | - if( $valid ) { |
|
| 171 | + if ( $valid ) { |
|
| 172 | 172 | $this->comparison = $value; |
| 173 | 173 | return true; |
| 174 | 174 | } |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | $this->parse_atts(); |
| 199 | 199 | |
| 200 | 200 | // We need an "if" |
| 201 | - if( false === $this->if ) { |
|
| 202 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts ); |
|
| 201 | + if ( false === $this->if ) { |
|
| 202 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->atts ); |
|
| 203 | 203 | return null; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $setup = $this->setup_operation_and_comparison(); |
| 207 | 207 | |
| 208 | 208 | // We need an operation and comparison value |
| 209 | - if( ! $setup ) { |
|
| 210 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
| 209 | + if ( ! $setup ) { |
|
| 210 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
| 211 | 211 | return null; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function get_output() { |
| 240 | 240 | |
| 241 | - if( $this->is_match ) { |
|
| 241 | + if ( $this->is_match ) { |
|
| 242 | 242 | $output = $this->content; |
| 243 | 243 | } else { |
| 244 | 244 | $output = $this->else_content; |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * @param string $output HTML/text output |
| 253 | 253 | * @param GVLogic_Shortcode $this This class |
| 254 | 254 | */ |
| 255 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
| 255 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
| 256 | 256 | |
| 257 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
| 257 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
| 258 | 258 | |
| 259 | 259 | return $output; |
| 260 | 260 | } |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | $content = explode( '[else]', $this->passed_content ); |
| 272 | 272 | |
| 273 | - $this->content = $content[0]; |
|
| 273 | + $this->content = $content[ 0 ]; |
|
| 274 | 274 | |
| 275 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
| 275 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
| 276 | 276 | |
| 277 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
| 277 | + $this->else_content = isset( $content[ 1 ] ) ? $content[ 1 ] : $else_attr; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
| 298 | 298 | |
| 299 | 299 | // Strip whitespace if it's not default false |
| 300 | - $this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false; |
|
| 300 | + $this->if = is_string( $this->atts[ 'if' ] ) ? trim( $this->atts[ 'if' ] ) : false; |
|
| 301 | 301 | |
| 302 | 302 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
| 303 | - unset( $this->atts['if'] ); |
|
| 303 | + unset( $this->atts[ 'if' ] ); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return GV_License_Handler |
| 35 | 35 | */ |
| 36 | 36 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
| 37 | - if( empty( self::$instance ) ) { |
|
| 37 | + if ( empty( self::$instance ) ) { |
|
| 38 | 38 | self::$instance = new self( $GFAddOn ); |
| 39 | 39 | } |
| 40 | 40 | return self::$instance; |
@@ -60,37 +60,37 @@ discard block |
||
| 60 | 60 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
| 61 | 61 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
| 62 | 62 | |
| 63 | - if( !empty( $key ) ) { |
|
| 63 | + if ( ! empty( $key ) ) { |
|
| 64 | 64 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
| 65 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
| 65 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
| 66 | 66 | } else { |
| 67 | 67 | $response = array(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
| 71 | 71 | 'license_box' => $this->get_license_message( $response ) |
| 72 | - )); |
|
| 72 | + ) ); |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | $fields = array( |
| 76 | 76 | array( |
| 77 | 77 | 'name' => 'edd-activate', |
| 78 | - 'value' => __('Activate License', 'gravityview'), |
|
| 79 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
| 78 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
| 79 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
| 80 | 80 | 'data-edd_action' => 'activate_license', |
| 81 | 81 | 'class' => 'button-primary', |
| 82 | 82 | ), |
| 83 | 83 | array( |
| 84 | 84 | 'name' => 'edd-deactivate', |
| 85 | - 'value' => __('Deactivate License', 'gravityview'), |
|
| 86 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
| 85 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
| 86 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
| 87 | 87 | 'data-edd_action' => 'deactivate_license', |
| 88 | 88 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
| 89 | 89 | ), |
| 90 | 90 | array( |
| 91 | 91 | 'name' => 'edd-check', |
| 92 | - 'value' => __('Check License', 'gravityview'), |
|
| 93 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
| 92 | + 'value' => __( 'Check License', 'gravityview' ), |
|
| 93 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
| 94 | 94 | 'title' => 'Check the license before saving it', |
| 95 | 95 | 'data-edd_action' => 'check_license', |
| 96 | 96 | 'class' => 'button-secondary', |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $class = 'button gv-edd-action'; |
| 102 | 102 | |
| 103 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
| 103 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
| 104 | 104 | |
| 105 | 105 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
| 106 | 106 | |
| 107 | 107 | $submit = '<div class="gv-edd-button-wrapper">'; |
| 108 | 108 | foreach ( $fields as $field ) { |
| 109 | - $field['type'] = 'button'; |
|
| 110 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
| 111 | - $field['style'] = 'margin-left: 10px;'; |
|
| 112 | - if( $disabled_attribute ) { |
|
| 113 | - $field['disabled'] = $disabled_attribute; |
|
| 109 | + $field[ 'type' ] = 'button'; |
|
| 110 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
| 111 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
| 112 | + if ( $disabled_attribute ) { |
|
| 113 | + $field[ 'disabled' ] = $disabled_attribute; |
|
| 114 | 114 | } |
| 115 | 115 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
| 116 | 116 | } |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | private function setup_edd() { |
| 128 | 128 | |
| 129 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
| 130 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
| 129 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 130 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // setup the updater |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | 'url' => home_url(), |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | - if( !empty( $action ) ) { |
|
| 167 | - $settings['edd_action'] = esc_attr( $action ); |
|
| 166 | + if ( ! empty( $action ) ) { |
|
| 167 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $settings = array_map( 'urlencode', $settings ); |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | private function _license_get_remote_response( $data, $license = '' ) { |
| 180 | 180 | |
| 181 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
| 181 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
| 182 | 182 | |
| 183 | 183 | $url = add_query_arg( $api_params, self::url ); |
| 184 | 184 | |
| 185 | 185 | $response = wp_remote_get( $url, array( |
| 186 | 186 | 'timeout' => 15, |
| 187 | 187 | 'sslverify' => false, |
| 188 | - )); |
|
| 188 | + ) ); |
|
| 189 | 189 | |
| 190 | 190 | if ( is_wp_error( $response ) ) { |
| 191 | 191 | return array(); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | // Not JSON |
| 197 | 197 | if ( empty( $license_data ) ) { |
| 198 | 198 | |
| 199 | - delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' ); |
|
| 199 | + delete_transient( 'gravityview_' . esc_attr( $data[ 'field_id' ] ) . '_valid' ); |
|
| 200 | 200 | |
| 201 | 201 | // Change status |
| 202 | 202 | return array(); |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function get_license_message( $license_data ) { |
| 220 | 220 | |
| 221 | - if( empty( $license_data ) ) { |
|
| 221 | + if ( empty( $license_data ) ) { |
|
| 222 | 222 | $class = 'hide'; |
| 223 | 223 | $message = ''; |
| 224 | 224 | } else { |
| 225 | 225 | |
| 226 | - if( ! empty( $license_data->error ) ) { |
|
| 226 | + if ( ! empty( $license_data->error ) ) { |
|
| 227 | 227 | $class = 'error'; |
| 228 | 228 | $string_key = $license_data->license; |
| 229 | 229 | } else { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $string_key = $license_data->license; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
| 234 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | return $this->generate_license_box( $message, $class ); |
@@ -272,16 +272,16 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | public function license_call( $array = array() ) { |
| 274 | 274 | |
| 275 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
| 276 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
| 275 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 276 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
| 277 | 277 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
| 278 | 278 | |
| 279 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
| 280 | - die( - 1 ); |
|
| 279 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
| 280 | + die( -1 ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // If the user isn't allowed to edit settings, show an error message |
| 284 | - if( ! $has_cap ) { |
|
| 284 | + if ( ! $has_cap ) { |
|
| 285 | 285 | $license_data = new stdClass(); |
| 286 | 286 | $license_data->error = 'capability'; |
| 287 | 287 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | $json = json_encode( $license_data ); |
| 306 | 306 | |
| 307 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
| 307 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
| 308 | 308 | |
| 309 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 309 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 310 | 310 | |
| 311 | 311 | // Failed is the response from trying to de-activate a license and it didn't work. |
| 312 | 312 | // This likely happened because people entered in a different key and clicked "Deactivate", |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | // most likely a mistake. |
| 315 | 315 | if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
| 316 | 316 | |
| 317 | - if ( ! empty( $data['field_id'] ) ) { |
|
| 318 | - set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS ); |
|
| 317 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
| 318 | + set_transient( 'gravityview_' . esc_attr( $data[ 'field_id' ] ) . '_valid', $license_data, DAY_IN_SECONDS ); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | $this->license_call_update_settings( $license_data, $data ); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | if ( $is_ajax ) { |
| 327 | 327 | exit( $json ); |
| 328 | 328 | } else { // Non-ajax call |
| 329 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
| 329 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | // Update option with passed data license |
| 341 | 341 | $settings = $this->Addon->get_app_settings(); |
| 342 | 342 | |
| 343 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 344 | - $settings['license_key_status'] = $license_data->license; |
|
| 345 | - $settings['license_key_response'] = (array)$license_data; |
|
| 343 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
| 344 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
| 345 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
| 346 | 346 | |
| 347 | 347 | $this->Addon->update_app_settings( $settings ); |
| 348 | 348 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @return string Renewal or account URL |
| 355 | 355 | */ |
| 356 | 356 | private function get_license_renewal_url( $license_data ) { |
| 357 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
| 357 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
| 358 | 358 | return $renew_license_url; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -368,30 +368,30 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | |
| 370 | 370 | $strings = array( |
| 371 | - 'status' => esc_html__('Status', 'gravityview'), |
|
| 372 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
| 373 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
| 374 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
| 375 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
| 376 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
| 377 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
| 378 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
| 379 | - 'missing' => esc_html__('The license key was not defined.', 'gravityview'), |
|
| 380 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
| 381 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
| 371 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
| 372 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
| 373 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
| 374 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
| 375 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
| 376 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
| 377 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
| 378 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
| 379 | + 'missing' => esc_html__( 'The license key was not defined.', 'gravityview' ), |
|
| 380 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
| 381 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
| 382 | 382 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
| 383 | 383 | |
| 384 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
| 385 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
| 386 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
| 387 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
| 384 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
| 385 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
| 386 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
| 387 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | - if( empty( $status ) ) { |
|
| 390 | + if ( empty( $status ) ) { |
|
| 391 | 391 | return $strings; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if( isset( $strings[ $status ] ) ) { |
|
| 394 | + if ( isset( $strings[ $status ] ) ) { |
|
| 395 | 395 | return $strings[ $status ]; |
| 396 | 396 | } |
| 397 | 397 | |
@@ -401,19 +401,19 @@ discard block |
||
| 401 | 401 | public function validate_license_key( $value, $field ) { |
| 402 | 402 | |
| 403 | 403 | // No license? No status. |
| 404 | - if( empty( $value ) ) { |
|
| 404 | + if ( empty( $value ) ) { |
|
| 405 | 405 | return NULL; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $response = $this->license_call(array( |
|
| 408 | + $response = $this->license_call( array( |
|
| 409 | 409 | 'license' => $this->Addon->get_app_setting( 'license_key' ), |
| 410 | 410 | 'edd_action' => 'check_license', |
| 411 | - 'field_id' => $field['name'], |
|
| 412 | - )); |
|
| 411 | + 'field_id' => $field[ 'name' ], |
|
| 412 | + ) ); |
|
| 413 | 413 | |
| 414 | 414 | $response = is_string( $response ) ? json_decode( $response, true ) : $response; |
| 415 | 415 | |
| 416 | - switch( $response['license'] ) { |
|
| 416 | + switch ( $response[ 'license' ] ) { |
|
| 417 | 417 | case 'valid': |
| 418 | 418 | $return = true; |
| 419 | 419 | break; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | parent::add_hooks(); |
| 58 | 58 | |
| 59 | - if( gravityview_is_admin_page() ) { |
|
| 59 | + if ( gravityview_is_admin_page() ) { |
|
| 60 | 60 | |
| 61 | 61 | // Make Yoast metabox go down to the bottom please. |
| 62 | 62 | add_filter( 'wpseo_metabox_prio', array( $this, '__return_low' ) ); |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | global $pagenow; |
| 84 | 84 | |
| 85 | 85 | // New View page |
| 86 | - if( $pagenow === 'post-new.php' ) { |
|
| 87 | - $options['hideeditbox-gravityview'] = true; |
|
| 86 | + if ( $pagenow === 'post-new.php' ) { |
|
| 87 | + $options[ 'hideeditbox-gravityview' ] = true; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return $options; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $function_exists = ! $this->function_name || ( $this->function_name && function_exists( $this->function_name ) ); |
| 94 | 94 | $constant_defined = ! $this->constant_name || ( $this->constant_name && defined( $this->constant_name ) ); |
| 95 | 95 | |
| 96 | - if( $class_exists || $function_exists || $constant_defined ) { |
|
| 96 | + if ( $class_exists || $function_exists || $constant_defined ) { |
|
| 97 | 97 | $this->add_hooks(); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | 106 | protected function add_hooks() { |
| 107 | - if( $this->content_meta_keys ) { |
|
| 107 | + if ( $this->content_meta_keys ) { |
|
| 108 | 108 | add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if( $this->script_handles ) { |
|
| 111 | + if ( $this->script_handles ) { |
|
| 112 | 112 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) ); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if( $this->style_handles ) { |
|
| 115 | + if ( $this->style_handles ) { |
|
| 116 | 116 | add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) ); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if( $this->post_type_support ) { |
|
| 119 | + if ( $this->post_type_support ) { |
|
| 120 | 120 | add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 ); |
| 121 | 121 | } |
| 122 | 122 | } |