@@ -95,7 +95,7 @@ |
||
| 95 | 95 | * @param string $icon_class_name Icon class used in vertical tabs. Supports non-dashicon. If dashicons, no need for `dashicons ` prefix |
| 96 | 96 | * @param string $callback Function to render the metabox, if $file is not defined. |
| 97 | 97 | * @param null $callback_args Arguments passed to the callback |
| 98 | - * @return void |
|
| 98 | + * @return GravityView_Metabox_Tab |
|
| 99 | 99 | */ |
| 100 | 100 | function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = null ) { |
| 101 | 101 | |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | * @param array $callback_args Arguments passed to the callback |
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | - function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
| 100 | + function __construct( $id, $title = '', $file = '', $icon_class_name = '', $callback = '', $callback_args = array() ) { |
|
| 101 | 101 | |
| 102 | - $this->id = $this->prefix.$id; |
|
| 102 | + $this->id = $this->prefix . $id; |
|
| 103 | 103 | $this->title = $title; |
| 104 | 104 | $this->render_template_file = $file; |
| 105 | 105 | $this->callback = $callback; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | function parse_icon_class_name( $icon_class_name = '' ) { |
| 120 | 120 | |
| 121 | - if( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
| 121 | + if ( preg_match( '/dashicon/i', $icon_class_name ) ) { |
|
| 122 | 122 | $icon_class_name = 'dashicons ' . $icon_class_name; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -142,29 +142,29 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function render( $post ) { |
| 144 | 144 | |
| 145 | - if( !empty( $this->render_template_file ) ) { |
|
| 145 | + if ( ! empty( $this->render_template_file ) ) { |
|
| 146 | 146 | |
| 147 | 147 | $file = $this->render_template_file; |
| 148 | 148 | |
| 149 | 149 | // If the full path exists, use it |
| 150 | - if( file_exists( $file ) ) { |
|
| 150 | + if ( file_exists( $file ) ) { |
|
| 151 | 151 | $path = $file; |
| 152 | 152 | } else { |
| 153 | - $path = GRAVITYVIEW_DIR .'includes/admin/metaboxes/views/'.$file; |
|
| 153 | + $path = GRAVITYVIEW_DIR . 'includes/admin/metaboxes/views/' . $file; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if( file_exists( $path ) ) { |
|
| 156 | + if ( file_exists( $path ) ) { |
|
| 157 | 157 | include $path; |
| 158 | 158 | } else { |
| 159 | 159 | do_action( 'gravityview_log_error', 'Metabox template file not found', $this ); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - } else if( !empty( $this->callback ) ) { |
|
| 162 | + } else if ( ! empty( $this->callback ) ) { |
|
| 163 | 163 | |
| 164 | - if( is_callable( $this->callback ) ) { |
|
| 164 | + if ( is_callable( $this->callback ) ) { |
|
| 165 | 165 | |
| 166 | 166 | /** @see do_accordion_sections() */ |
| 167 | - call_user_func( $this->callback, $post, (array) $this ); |
|
| 167 | + call_user_func( $this->callback, $post, (array)$this ); |
|
| 168 | 168 | |
| 169 | 169 | } else { |
| 170 | 170 | do_action( 'gravityview_log_error', 'Metabox callback was not callable', $this ); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @since 1.15 |
| 29 | 29 | * @param bool|false $mixed |
| 30 | 30 | * |
| 31 | - * @return bool |
|
| 31 | + * @return boolean|null |
|
| 32 | 32 | */ |
| 33 | 33 | private function _exit( $mixed = NULL ) { |
| 34 | 34 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * Import Gravity Form XML or JSON |
| 201 | 201 | * |
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
| 203 | - * @return int|bool Imported form ID or false |
|
| 203 | + * @return false|string Imported form ID or false |
|
| 204 | 204 | */ |
| 205 | 205 | function import_form( $xml_or_json_path = '' ) { |
| 206 | 206 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | // template areas |
| 138 | 138 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
| 139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 139 | + $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 140 | 140 | |
| 141 | 141 | // widget areas |
| 142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
@@ -328,40 +328,40 @@ discard block |
||
| 328 | 328 | // load file |
| 329 | 329 | $xmlstr = file_get_contents( $form_file ); |
| 330 | 330 | |
| 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) |
|
| 343 | - ); |
|
| 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) |
|
| 343 | + ); |
|
| 344 | 344 | |
| 345 | 345 | $xml = new RGXML($options); |
| 346 | - $forms = $xml->unserialize($xmlstr); |
|
| 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 ); |
|
| 350 | - return false; |
|
| 351 | - } |
|
| 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 | + return false; |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 354 | - $form = $forms[0]; |
|
| 355 | - } |
|
| 353 | + if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 354 | + $form = $forms[0]; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - if( empty( $form ) ) { |
|
| 358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
| 359 | - return false; |
|
| 360 | - } |
|
| 357 | + if( empty( $form ) ) { |
|
| 358 | + do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
| 359 | + return false; |
|
| 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 | - return $form; |
|
| 364 | + return $form; |
|
| 365 | 365 | |
| 366 | 366 | } |
| 367 | 367 | |
@@ -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 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Sets the single entry ID and also the entry |
| 153 | - * @param bool|int $single_entry |
|
| 153 | + * @param boolean|string $single_entry |
|
| 154 | 154 | */ |
| 155 | 155 | public function setSingleEntry( $single_entry ) { |
| 156 | 156 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | 169 | * Set the current entry |
| 170 | - * @param array|int $entry Entry array or entry ID |
|
| 170 | + * @param boolean|string $entry Entry array or entry ID |
|
| 171 | 171 | */ |
| 172 | 172 | public function setEntry( $entry ) { |
| 173 | 173 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * |
| 227 | 227 | * |
| 228 | - * @param null $view_id |
|
| 228 | + * @param string $view_id |
|
| 229 | 229 | */ |
| 230 | 230 | public function set_context_view_id( $view_id = null ) { |
| 231 | 231 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * |
| 935 | 935 | * @uses gravityview_get_entries() |
| 936 | 936 | * @access public |
| 937 | - * @param array $args\n |
|
| 937 | + * @param array $args |
|
| 938 | 938 | * - $id - View id |
| 939 | 939 | * - $page_size - Page |
| 940 | 940 | * - $sort_field - form field id to sort |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | /** |
| 1365 | 1365 | * Checks if field (column) is sortable |
| 1366 | 1366 | * |
| 1367 | - * @param string $field Field settings |
|
| 1367 | + * @param string $field_id Field settings |
|
| 1368 | 1368 | * @param array $form Gravity Forms form array |
| 1369 | 1369 | * |
| 1370 | 1370 | * @since 1.7 |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | $this->context_view_id = $_GET['gvid']; |
| 243 | 243 | |
| 244 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 244 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 245 | 245 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
| 246 | 246 | $this->context_view_id = array_pop( $array_keys ); |
| 247 | 247 | unset( $array_keys ); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | global $post; |
| 270 | 270 | |
| 271 | 271 | // If in admin and NOT AJAX request, get outta here. |
| 272 | - if ( GravityView_Plugin::is_admin() ) { |
|
| 272 | + if ( GravityView_Plugin::is_admin() ) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | // User reported WooCommerce doesn't pass two args. |
| 375 | - if ( empty( $passed_post_id ) ) { |
|
| 375 | + if ( empty( $passed_post_id ) ) { |
|
| 376 | 376 | return $title; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -1108,7 +1108,7 @@ discard block |
||
| 1108 | 1108 | */ |
| 1109 | 1109 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
| 1110 | 1110 | |
| 1111 | - switch( strtolower( $address_part ) ){ |
|
| 1111 | + switch( strtolower( $address_part ) ) { |
|
| 1112 | 1112 | case 'street': |
| 1113 | 1113 | $sort_field_id .= '.1'; |
| 1114 | 1114 | break; |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | */ |
| 1189 | 1189 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
| 1190 | 1190 | |
| 1191 | - if ( empty( $single_entry ) ){ |
|
| 1191 | + if ( empty( $single_entry ) ) { |
|
| 1192 | 1192 | return false; |
| 1193 | 1193 | } else { |
| 1194 | 1194 | return $single_entry; |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | private function __construct() {} |
| 86 | 86 | |
| 87 | 87 | private function initialize() { |
| 88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
| 89 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
| 88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
| 89 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
| 90 | 90 | |
| 91 | 91 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
| 92 | 92 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $this->context_view_id = $view_id; |
| 235 | 235 | |
| 236 | - } elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 236 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) { |
|
| 237 | 237 | /** |
| 238 | 238 | * used on a has_multiple_views context |
| 239 | 239 | * @see GravityView_API::entry_link |
| 240 | 240 | * @see GravityView_View_Data::getInstance()->has_multiple_views() |
| 241 | 241 | */ |
| 242 | - $this->context_view_id = $_GET['gvid']; |
|
| 242 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
| 243 | 243 | |
| 244 | - } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 244 | + } elseif ( ! $this->getGvOutputData()->has_multiple_views() ) { |
|
| 245 | 245 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
| 246 | 246 | $this->context_view_id = array_pop( $array_keys ); |
| 247 | 247 | unset( $array_keys ); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | global $post; |
| 270 | 270 | |
| 271 | 271 | // If in admin and NOT AJAX request, get outta here. |
| 272 | - if ( GravityView_Plugin::is_admin() ) { |
|
| 272 | + if ( GravityView_Plugin::is_admin() ) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
| 283 | 283 | |
| 284 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
| 284 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
| 285 | 285 | $this->setPostId( $post_id ); |
| 286 | 286 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
| 287 | 287 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
| 319 | 319 | |
| 320 | - if( 'post' === $search_method ) { |
|
| 320 | + if ( 'post' === $search_method ) { |
|
| 321 | 321 | $get = $_POST; |
| 322 | 322 | } else { |
| 323 | 323 | $get = $_GET; |
@@ -373,20 +373,20 @@ discard block |
||
| 373 | 373 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
| 374 | 374 | * @param array $entry Current entry |
| 375 | 375 | */ |
| 376 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
| 376 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
| 377 | 377 | |
| 378 | 378 | if ( ! $apply_outside_loop ) { |
| 379 | 379 | return $title; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | // User reported WooCommerce doesn't pass two args. |
| 383 | - if ( empty( $passed_post_id ) ) { |
|
| 383 | + if ( empty( $passed_post_id ) ) { |
|
| 384 | 384 | return $title; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | // Don't modify the title for anything other than the current view/post. |
| 388 | 388 | // This is true for embedded shortcodes and Views. |
| 389 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
| 389 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
| 390 | 390 | return $title; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -396,19 +396,19 @@ discard block |
||
| 396 | 396 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
| 397 | 397 | } else { |
| 398 | 398 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
| 399 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
| 399 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
| 400 | 400 | $view_meta = $view_data; |
| 401 | 401 | break; |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
| 406 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
| 407 | 407 | |
| 408 | - $title = $view_meta['atts']['single_title']; |
|
| 408 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
| 409 | 409 | |
| 410 | 410 | // We are allowing HTML in the fields, so no escaping the output |
| 411 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
| 411 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
| 412 | 412 | |
| 413 | 413 | $title = do_shortcode( $title ); |
| 414 | 414 | } |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | public function render_view( $passed_args ) { |
| 510 | 510 | |
| 511 | 511 | // validate attributes |
| 512 | - if ( empty( $passed_args['id'] ) ) { |
|
| 512 | + if ( empty( $passed_args[ 'id' ] ) ) { |
|
| 513 | 513 | do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args ); |
| 514 | 514 | return null; |
| 515 | 515 | } |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | return null; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - $view_id = $passed_args['id']; |
|
| 534 | + $view_id = $passed_args[ 'id' ]; |
|
| 535 | 535 | |
| 536 | 536 | $view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args ); |
| 537 | 537 | |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | $passed_args = array_filter( $passed_args, 'strlen' ); |
| 545 | 545 | |
| 546 | 546 | //Override shortcode args over View template settings |
| 547 | - $atts = wp_parse_args( $passed_args, $view_data['atts'] ); |
|
| 547 | + $atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] ); |
|
| 548 | 548 | |
| 549 | 549 | do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts ); |
| 550 | 550 | |
@@ -566,11 +566,11 @@ discard block |
||
| 566 | 566 | * Don't render View if user isn't allowed to see it |
| 567 | 567 | * @since 1.15 |
| 568 | 568 | */ |
| 569 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 569 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 570 | 570 | return null; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if( $this->isGravityviewPostType() ) { |
|
| 573 | + if ( $this->isGravityviewPostType() ) { |
|
| 574 | 574 | |
| 575 | 575 | /** |
| 576 | 576 | * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode? |
@@ -582,9 +582,9 @@ discard block |
||
| 582 | 582 | */ |
| 583 | 583 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view_id ); |
| 584 | 584 | |
| 585 | - $embed_only = ! empty( $atts['embed_only'] ); |
|
| 585 | + $embed_only = ! empty( $atts[ 'embed_only' ] ); |
|
| 586 | 586 | |
| 587 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 587 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
| 588 | 588 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
| 589 | 589 | } |
| 590 | 590 | } |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | |
| 600 | 600 | $gravityview_view = new GravityView_View( $view_data ); |
| 601 | 601 | |
| 602 | - $post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId(); |
|
| 602 | + $post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId(); |
|
| 603 | 603 | |
| 604 | 604 | $gravityview_view->setPostId( $post_id ); |
| 605 | 605 | |
@@ -609,20 +609,20 @@ discard block |
||
| 609 | 609 | do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' ); |
| 610 | 610 | |
| 611 | 611 | //fetch template and slug |
| 612 | - $view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' ); |
|
| 612 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' ); |
|
| 613 | 613 | |
| 614 | 614 | do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug ); |
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | 617 | * Disable fetching initial entries for views that don't need it (DataTables) |
| 618 | 618 | */ |
| 619 | - $get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true ); |
|
| 619 | + $get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true ); |
|
| 620 | 620 | |
| 621 | 621 | /** |
| 622 | 622 | * Hide View data until search is performed |
| 623 | 623 | * @since 1.5.4 |
| 624 | 624 | */ |
| 625 | - if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) { |
|
| 625 | + if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) { |
|
| 626 | 626 | $gravityview_view->setHideUntilSearched( true ); |
| 627 | 627 | $get_entries = false; |
| 628 | 628 | } |
@@ -630,23 +630,23 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | if ( $get_entries ) { |
| 632 | 632 | |
| 633 | - if ( ! empty( $atts['sort_columns'] ) ) { |
|
| 633 | + if ( ! empty( $atts[ 'sort_columns' ] ) ) { |
|
| 634 | 634 | // add filter to enable column sorting |
| 635 | - add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 ); |
|
| 635 | + add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 ); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $view_entries = self::get_view_entries( $atts, $view_data['form_id'] ); |
|
| 638 | + $view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] ); |
|
| 639 | 639 | |
| 640 | - do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) ); |
|
| 640 | + do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) ); |
|
| 641 | 641 | |
| 642 | 642 | } else { |
| 643 | 643 | |
| 644 | 644 | $view_entries = array( 'count' => null, 'entries' => null, 'paging' => null ); |
| 645 | 645 | |
| 646 | - do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' ); |
|
| 646 | + do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' ); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - $gravityview_view->setPaging( $view_entries['paging'] ); |
|
| 649 | + $gravityview_view->setPaging( $view_entries[ 'paging' ] ); |
|
| 650 | 650 | $gravityview_view->setContext( 'directory' ); |
| 651 | 651 | $sections = array( 'header', 'body', 'footer' ); |
| 652 | 652 | |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | // user requested Single Entry View |
| 656 | 656 | do_action( 'gravityview_log_debug', '[render_view] Executing Single View' ); |
| 657 | 657 | |
| 658 | - do_action( 'gravityview_render_entry_'.$view_data['id'] ); |
|
| 658 | + do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] ); |
|
| 659 | 659 | |
| 660 | 660 | $entry = $this->getEntry(); |
| 661 | 661 | |
@@ -682,20 +682,20 @@ discard block |
||
| 682 | 682 | // We're in single view, but the view being processed is not the same view the single entry belongs to. |
| 683 | 683 | // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms |
| 684 | 684 | if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) { |
| 685 | - do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id ); |
|
| 685 | + do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id ); |
|
| 686 | 686 | return null; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | //fetch template and slug |
| 690 | - $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' ); |
|
| 690 | + $view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' ); |
|
| 691 | 691 | do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug ); |
| 692 | 692 | |
| 693 | 693 | //fetch entry detail |
| 694 | - $view_entries['count'] = 1; |
|
| 695 | - $view_entries['entries'][] = $entry; |
|
| 696 | - do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] ); |
|
| 694 | + $view_entries[ 'count' ] = 1; |
|
| 695 | + $view_entries[ 'entries' ][ ] = $entry; |
|
| 696 | + do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] ); |
|
| 697 | 697 | |
| 698 | - $back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null; |
|
| 698 | + $back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null; |
|
| 699 | 699 | |
| 700 | 700 | // set back link label |
| 701 | 701 | $gravityview_view->setBackLinkLabel( $back_link_label ); |
@@ -705,11 +705,11 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | // add template style |
| 708 | - self::add_style( $view_data['template_id'] ); |
|
| 708 | + self::add_style( $view_data[ 'template_id' ] ); |
|
| 709 | 709 | |
| 710 | 710 | // Prepare to render view and set vars |
| 711 | - $gravityview_view->setEntries( $view_entries['entries'] ); |
|
| 712 | - $gravityview_view->setTotalEntries( $view_entries['count'] ); |
|
| 711 | + $gravityview_view->setEntries( $view_entries[ 'entries' ] ); |
|
| 712 | + $gravityview_view->setTotalEntries( $view_entries[ 'count' ] ); |
|
| 713 | 713 | |
| 714 | 714 | // If Edit |
| 715 | 715 | if ( 'edit' === gravityview_get_context() ) { |
@@ -722,11 +722,11 @@ discard block |
||
| 722 | 722 | |
| 723 | 723 | } else { |
| 724 | 724 | // finaly we'll render some html |
| 725 | - $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] ); |
|
| 725 | + $sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] ); |
|
| 726 | 726 | |
| 727 | 727 | do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections ); |
| 728 | 728 | foreach ( $sections as $section ) { |
| 729 | - do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' ); |
|
| 729 | + do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' ); |
|
| 730 | 730 | $gravityview_view->render( $view_slug, $section, false ); |
| 731 | 731 | } |
| 732 | 732 | } |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | $datetime_format = 'Y-m-d H:i:s'; |
| 781 | 781 | $search_is_outside_view_bounds = false; |
| 782 | 782 | |
| 783 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
| 783 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
| 784 | 784 | |
| 785 | 785 | $search_date = strtotime( $search_criteria[ $key ] ); |
| 786 | 786 | |
@@ -808,14 +808,14 @@ discard block |
||
| 808 | 808 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
| 809 | 809 | |
| 810 | 810 | // Then we override the search and re-set the start date |
| 811 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
| 811 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
| 816 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 817 | 817 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
| 818 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
| 818 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
| 819 | 819 | do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria ); |
| 820 | 820 | } |
| 821 | 821 | } |
@@ -833,9 +833,9 @@ discard block |
||
| 833 | 833 | */ |
| 834 | 834 | public static function process_search_only_approved( $args, $search_criteria ) { |
| 835 | 835 | |
| 836 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
| 837 | - $search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' ); |
|
| 838 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
| 836 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
| 837 | + $search_criteria[ 'field_filters' ][ ] = array( 'key' => 'is_approved', 'value' => 'Approved' ); |
|
| 838 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
| 839 | 839 | |
| 840 | 840 | do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria ); |
| 841 | 841 | } |
@@ -859,12 +859,12 @@ discard block |
||
| 859 | 859 | */ |
| 860 | 860 | public static function is_entry_approved( $entry, $args = array() ) { |
| 861 | 861 | |
| 862 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
| 862 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
| 863 | 863 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
| 864 | 864 | return true; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - $is_approved = gform_get_meta( $entry['id'], 'is_approved' ); |
|
| 867 | + $is_approved = gform_get_meta( $entry[ 'id' ], 'is_approved' ); |
|
| 868 | 868 | |
| 869 | 869 | if ( $is_approved ) { |
| 870 | 870 | return true; |
@@ -897,26 +897,26 @@ discard block |
||
| 897 | 897 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria ); |
| 898 | 898 | |
| 899 | 899 | // implicity search |
| 900 | - if ( ! empty( $args['search_value'] ) ) { |
|
| 900 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
| 901 | 901 | |
| 902 | 902 | // Search operator options. Options: `is` or `contains` |
| 903 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
| 903 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
| 904 | 904 | |
| 905 | - $search_criteria['field_filters'][] = array( |
|
| 905 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 906 | 906 | 'key' => rgget( 'search_field', $args ), // The field ID to search |
| 907 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
| 907 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
| 908 | 908 | 'operator' => $operator, |
| 909 | 909 | ); |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 912 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 913 | 913 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria ); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | // Handle setting date range |
| 917 | 917 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
| 918 | 918 | |
| 919 | - if( $search_criteria !== $original_search_criteria ) { |
|
| 919 | + if ( $search_criteria !== $original_search_criteria ) { |
|
| 920 | 920 | do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria ); |
| 921 | 921 | } |
| 922 | 922 | |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
| 928 | 928 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
| 929 | 929 | */ |
| 930 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 930 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
| 931 | 931 | |
| 932 | 932 | return $search_criteria; |
| 933 | 933 | } |
@@ -973,16 +973,16 @@ discard block |
||
| 973 | 973 | $search_criteria = self::get_search_criteria( $args, $form_id ); |
| 974 | 974 | |
| 975 | 975 | // Paging & offset |
| 976 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 976 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 ); |
|
| 977 | 977 | |
| 978 | 978 | if ( -1 === $page_size ) { |
| 979 | 979 | $page_size = PHP_INT_MAX; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - if ( isset( $args['offset'] ) ) { |
|
| 983 | - $offset = intval( $args['offset'] ); |
|
| 982 | + if ( isset( $args[ 'offset' ] ) ) { |
|
| 983 | + $offset = intval( $args[ 'offset' ] ); |
|
| 984 | 984 | } else { |
| 985 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
| 985 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
| 986 | 986 | $offset = ( $curr_page - 1 ) * $page_size; |
| 987 | 987 | } |
| 988 | 988 | |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | 'search_criteria' => $search_criteria, |
| 1001 | 1001 | 'sorting' => $sorting, |
| 1002 | 1002 | 'paging' => $paging, |
| 1003 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
| 1003 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
| 1004 | 1004 | ); |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
@@ -1025,7 +1025,7 @@ discard block |
||
| 1025 | 1025 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
| 1026 | 1026 | * @param array $args View configuration args. |
| 1027 | 1027 | */ |
| 1028 | - $parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id ); |
|
| 1028 | + $parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id ); |
|
| 1029 | 1029 | |
| 1030 | 1030 | do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters ); |
| 1031 | 1031 | |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | */ |
| 1066 | 1066 | public static function updateViewSorting( $args, $form_id ) { |
| 1067 | 1067 | $sorting = array(); |
| 1068 | - $sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' ); |
|
| 1069 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' ); |
|
| 1068 | + $sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' ); |
|
| 1069 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' ); |
|
| 1070 | 1070 | |
| 1071 | 1071 | $sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id ); |
| 1072 | 1072 | |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | |
| 1107 | 1107 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
| 1108 | 1108 | |
| 1109 | - switch ( $sort_field['type'] ) { |
|
| 1109 | + switch ( $sort_field[ 'type' ] ) { |
|
| 1110 | 1110 | |
| 1111 | 1111 | case 'address': |
| 1112 | 1112 | // Sorting by full address |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | */ |
| 1124 | 1124 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
| 1125 | 1125 | |
| 1126 | - switch( strtolower( $address_part ) ){ |
|
| 1126 | + switch ( strtolower( $address_part ) ) { |
|
| 1127 | 1127 | case 'street': |
| 1128 | 1128 | $sort_field_id .= '.1'; |
| 1129 | 1129 | break; |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | */ |
| 1204 | 1204 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
| 1205 | 1205 | |
| 1206 | - if ( empty( $single_entry ) ){ |
|
| 1206 | + if ( empty( $single_entry ) ) { |
|
| 1207 | 1207 | return false; |
| 1208 | 1208 | } else { |
| 1209 | 1209 | return $single_entry; |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
| 1231 | 1231 | * @since 1.15 |
| 1232 | 1232 | */ |
| 1233 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1233 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
| 1234 | 1234 | continue; |
| 1235 | 1235 | } |
| 1236 | 1236 | |
@@ -1239,19 +1239,19 @@ discard block |
||
| 1239 | 1239 | $css_dependencies = array(); |
| 1240 | 1240 | |
| 1241 | 1241 | // If the thickbox is enqueued, add dependencies |
| 1242 | - if ( ! empty( $data['atts']['lightbox'] ) ) { |
|
| 1242 | + if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) { |
|
| 1243 | 1243 | |
| 1244 | 1244 | /** |
| 1245 | 1245 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
| 1246 | 1246 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
| 1247 | 1247 | */ |
| 1248 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1248 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
| 1249 | 1249 | |
| 1250 | 1250 | /** |
| 1251 | 1251 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
| 1252 | 1252 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
| 1253 | 1253 | */ |
| 1254 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1254 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
@@ -1259,25 +1259,25 @@ discard block |
||
| 1259 | 1259 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
| 1260 | 1260 | * @since 1.15 |
| 1261 | 1261 | */ |
| 1262 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
| 1263 | - $css_dependencies[] = 'dashicons'; |
|
| 1262 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
| 1263 | + $css_dependencies[ ] = 'dashicons'; |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
| 1267 | 1267 | |
| 1268 | 1268 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1269 | 1269 | |
| 1270 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
| 1270 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
| 1271 | 1271 | |
| 1272 | 1272 | wp_enqueue_script( 'gravityview-fe-view' ); |
| 1273 | 1273 | |
| 1274 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
| 1274 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
| 1275 | 1275 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
| 1279 | 1279 | |
| 1280 | - self::add_style( $data['template_id'] ); |
|
| 1280 | + self::add_style( $data[ 'template_id' ] ); |
|
| 1281 | 1281 | |
| 1282 | 1282 | } |
| 1283 | 1283 | |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | } elseif ( empty( $template_id ) ) { |
| 1314 | 1314 | do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' ); |
| 1315 | 1315 | } else { |
| 1316 | - do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) ); |
|
| 1316 | + do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) ); |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | } |
@@ -1338,11 +1338,11 @@ discard block |
||
| 1338 | 1338 | * Not a table-based template; don't add sort icons |
| 1339 | 1339 | * @since 1.12 |
| 1340 | 1340 | */ |
| 1341 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1341 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
| 1342 | 1342 | return $label; |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
| 1345 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
| 1346 | 1346 | return $label; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
@@ -1350,29 +1350,29 @@ discard block |
||
| 1350 | 1350 | |
| 1351 | 1351 | $class = 'gv-sort'; |
| 1352 | 1352 | |
| 1353 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
| 1353 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
| 1354 | 1354 | |
| 1355 | 1355 | $sort_args = array( |
| 1356 | - 'sort' => $field['id'], |
|
| 1356 | + 'sort' => $field[ 'id' ], |
|
| 1357 | 1357 | 'dir' => 'asc', |
| 1358 | 1358 | ); |
| 1359 | 1359 | |
| 1360 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
| 1360 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
| 1361 | 1361 | //toggle sorting direction. |
| 1362 | - if ( 'asc' === $sorting['direction'] ) { |
|
| 1363 | - $sort_args['dir'] = 'desc'; |
|
| 1362 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
| 1363 | + $sort_args[ 'dir' ] = 'desc'; |
|
| 1364 | 1364 | $class .= ' gv-icon-sort-desc'; |
| 1365 | 1365 | } else { |
| 1366 | - $sort_args['dir'] = 'asc'; |
|
| 1366 | + $sort_args[ 'dir' ] = 'asc'; |
|
| 1367 | 1367 | $class .= ' gv-icon-sort-asc'; |
| 1368 | 1368 | } |
| 1369 | 1369 | } else { |
| 1370 | 1370 | $class .= ' gv-icon-caret-up-down'; |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
| 1373 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
| 1374 | 1374 | |
| 1375 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
| 1375 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
| 1376 | 1376 | |
| 1377 | 1377 | } |
| 1378 | 1378 | |
@@ -1390,7 +1390,7 @@ discard block |
||
| 1390 | 1390 | |
| 1391 | 1391 | $field_type = $field_id; |
| 1392 | 1392 | |
| 1393 | - if( is_numeric( $field_id ) ) { |
|
| 1393 | + if ( is_numeric( $field_id ) ) { |
|
| 1394 | 1394 | $field = GFFormsModel::get_field( $form, $field_id ); |
| 1395 | 1395 | $field_type = $field->type; |
| 1396 | 1396 | } |
@@ -1413,7 +1413,7 @@ discard block |
||
| 1413 | 1413 | return false; |
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1416 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
| 1417 | 1417 | |
| 1418 | 1418 | } |
| 1419 | 1419 | |
@@ -195,7 +195,7 @@ |
||
| 195 | 195 | * |
| 196 | 196 | * @since 1.6 |
| 197 | 197 | * |
| 198 | - * @param int $new_view_id The ID of the newly created View |
|
| 198 | + * @param int $new_id The ID of the newly created View |
|
| 199 | 199 | * @param WP_Post $post The View that was just cloned |
| 200 | 200 | * |
| 201 | 201 | * @return void |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | function __construct() { |
| 16 | 16 | |
| 17 | 17 | // Only run on Admin |
| 18 | - if ( !is_admin() ) { |
|
| 18 | + if ( ! is_admin() ) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // If the Duplicate Post plugin is active, don't run. |
| 23 | - if( defined('DUPLICATE_POST_CURRENT_VERSION') ) { |
|
| 23 | + if ( defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) { |
|
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | global $post; |
| 61 | 61 | |
| 62 | 62 | // We only want to add Clone links to the Edit View metabox |
| 63 | - if( !$this->is_all_views_page() ) { |
|
| 63 | + if ( ! $this->is_all_views_page() ) { |
|
| 64 | 64 | |
| 65 | - if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
| 66 | - $links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>'; |
|
| 65 | + if ( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
| 66 | + $links[ ] = '<span>' . $duplicate_links[ 'edit_as_new_draft' ] . '</span>'; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param string|null If string, the status to set for the new View. If empty, use existing View status. |
| 120 | 120 | * @param WP_Post $post View being cloned |
| 121 | 121 | */ |
| 122 | - $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post ); |
|
| 122 | + $new_view_status = apply_filters( 'gravityview/duplicate-view/status', $status, $post ); |
|
| 123 | 123 | |
| 124 | 124 | $new_view = array( |
| 125 | 125 | 'menu_order' => $post->menu_order, |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false` |
| 143 | 143 | * @param WP_Post $post View being cloned |
| 144 | 144 | */ |
| 145 | - $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post ); |
|
| 145 | + $copy_date = apply_filters( 'gravityview/duplicate-view/copy-date', false, $post ); |
|
| 146 | 146 | |
| 147 | 147 | if ( $copy_date ) { |
| 148 | - $new_view['post_date'] = $new_post_date = $post->post_date; |
|
| 149 | - $new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date ); |
|
| 148 | + $new_view[ 'post_date' ] = $new_post_date = $post->post_date; |
|
| 149 | + $new_view[ 'post_date_gmt' ] = get_gmt_from_date( $new_post_date ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param array $new_view Array of settings to be passed to wp_insert_post() |
| 156 | 156 | * @param WP_Post $post View being cloned |
| 157 | 157 | */ |
| 158 | - $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post ); |
|
| 158 | + $new_view = apply_filters( 'gravityview/duplicate-view/new-view', $new_view, $post ); |
|
| 159 | 159 | |
| 160 | 160 | // Magic happens here. |
| 161 | 161 | $new_view_id = wp_insert_post( $new_view ); |
@@ -237,13 +237,13 @@ discard block |
||
| 237 | 237 | $clone_text = __( 'Clone', 'gravityview' ); |
| 238 | 238 | $clone_title = __( 'Clone this View', 'gravityview' ); |
| 239 | 239 | |
| 240 | - $actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title ); |
|
| 240 | + $actions[ 'clone' ] = gravityview_get_link( $clone_link, $clone_text, 'title=' . $clone_title ); |
|
| 241 | 241 | |
| 242 | 242 | $clone_draft_link = $this->get_clone_view_link( $post->ID ); |
| 243 | 243 | $clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' ); |
| 244 | 244 | $clone_draft_title = __( 'Copy as a new draft View', 'gravityview' ); |
| 245 | 245 | |
| 246 | - $actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title ); |
|
| 246 | + $actions[ 'edit_as_new_draft' ] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title=' . $clone_draft_title ); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | return $actions; |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Verify the View exists |
| 270 | - if ( !$view = get_post( $id ) ) { |
|
| 270 | + if ( ! $view = get_post( $id ) ) { |
|
| 271 | 271 | return ''; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $post_type_object = get_post_type_object( $view->post_type ); |
| 283 | 283 | |
| 284 | 284 | /** If there's no gravityview post type for some reason, abort! */ |
| 285 | - if ( !$post_type_object ) { |
|
| 285 | + if ( ! $post_type_object ) { |
|
| 286 | 286 | do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view ); |
| 287 | 287 | return ''; |
| 288 | 288 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @param int $view_id View ID |
| 295 | 295 | * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display` |
| 296 | 296 | */ |
| 297 | - $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context ); |
|
| 297 | + $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php" . $action ), $view->ID, $context ); |
|
| 298 | 298 | |
| 299 | 299 | return $clone_view_link; |
| 300 | 300 | } |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function save_as_new_view( $status = '' ) { |
| 323 | 323 | |
| 324 | - if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) { |
|
| 324 | + if ( ! ( isset( $_GET[ 'post' ] ) || isset( $_POST[ 'post' ] ) ) ) { |
|
| 325 | 325 | wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) ); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // Get the original post |
| 329 | - $id = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] ); |
|
| 329 | + $id = ( isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : $_POST[ 'post' ] ); |
|
| 330 | 330 | |
| 331 | - if( ! $this->current_user_can_copy( $id ) ) { |
|
| 331 | + if ( ! $this->current_user_can_copy( $id ) ) { |
|
| 332 | 332 | wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) ); |
| 333 | 333 | } |
| 334 | 334 | |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @since 1.12 |
| 119 | - * @return bool |
|
| 119 | + * @return boolean|null |
|
| 120 | 120 | */ |
| 121 | 121 | private function add_fallback_shortcode() { |
| 122 | 122 | |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | self::$notices['wp_version'] = array( |
| 205 | 205 | 'class' => 'error', |
| 206 | 206 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
| 207 | - 'cap' => 'update_core', |
|
| 207 | + 'cap' => 'update_core', |
|
| 208 | 208 | 'dismiss' => 'wp_version', |
| 209 | 209 | ); |
| 210 | 210 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @return GravityView_Compatibility |
| 77 | 77 | */ |
| 78 | 78 | public static function getInstance() { |
| 79 | - if( self::$instance ) { |
|
| 79 | + if ( self::$instance ) { |
|
| 80 | 80 | return self::$instance; |
| 81 | 81 | } |
| 82 | 82 | return new self; |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | // If Gravity Forms doesn't exist or is outdated, load the admin view class to |
| 124 | 124 | // show the notice, but not load any post types or process shortcodes. |
| 125 | 125 | // Without Gravity Forms, there is no GravityView. Beautiful, really. |
| 126 | - if( ! self::is_valid() ) { |
|
| 126 | + if ( ! self::is_valid() ) { |
|
| 127 | 127 | |
| 128 | 128 | // If the plugin's not loaded, might as well hide the shortcode for people. |
| 129 | - add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') ); |
|
| 129 | + add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice' ) ); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) { |
| 154 | 154 | |
| 155 | - if( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
| 155 | + if ( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $notices = self::get_notices(); |
| 160 | 160 | |
| 161 | - $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>'; |
|
| 162 | - foreach( (array)$notices as $notice ) { |
|
| 163 | - $message .= wpautop( $notice['message'] ); |
|
| 161 | + $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview' ) . '</em></p>'; |
|
| 162 | + foreach ( (array)$notices as $notice ) { |
|
| 163 | + $message .= wpautop( $notice[ 'message' ] ); |
|
| 164 | 164 | } |
| 165 | 165 | $message .= '</div>'; |
| 166 | 166 | |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | * @return boolean |
| 176 | 176 | */ |
| 177 | 177 | public static function check_php() { |
| 178 | - if( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) ) { |
|
| 178 | + if ( false === version_compare( phpversion(), GV_MIN_PHP_VERSION, '>=' ) ) { |
|
| 179 | 179 | |
| 180 | - self::$notices['php_version'] = array( |
|
| 180 | + self::$notices[ 'php_version' ] = array( |
|
| 181 | 181 | 'class' => 'error', |
| 182 | - 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
| 182 | + 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . phpversion() . '</span>' ), |
|
| 183 | 183 | 'cap' => 'manage_options', |
| 184 | 184 | 'dismiss' => 'php_version', |
| 185 | 185 | ); |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | public static function check_wordpress() { |
| 200 | 200 | global $wp_version; |
| 201 | 201 | |
| 202 | - if( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) { |
|
| 202 | + if ( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) { |
|
| 203 | 203 | |
| 204 | - self::$notices['wp_version'] = array( |
|
| 204 | + self::$notices[ 'wp_version' ] = array( |
|
| 205 | 205 | 'class' => 'error', |
| 206 | - 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
|
| 206 | + 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $wp_version . '</span>' ), |
|
| 207 | 207 | 'cap' => 'update_core', |
| 208 | 208 | 'dismiss' => 'wp_version', |
| 209 | 209 | ); |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | public static function check_gravityforms() { |
| 227 | 227 | |
| 228 | 228 | // Bypass other checks: if the class exists |
| 229 | - if( class_exists( 'GFCommon' ) ) { |
|
| 229 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 230 | 230 | |
| 231 | 231 | // and the version's right, we're good. |
| 232 | - if( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) { |
|
| 232 | + if ( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) { |
|
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Or the version's wrong |
| 237 | - self::$notices['gf_version'] = array( |
|
| 237 | + self::$notices[ 'gf_version' ] = array( |
|
| 238 | 238 | 'class' => 'error', |
| 239 | - 'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
| 239 | + 'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>', "\n\n" . '<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ), |
|
| 240 | 240 | 'cap' => 'update_plugins', |
| 241 | 241 | 'dismiss' => 'gf_version', |
| 242 | 242 | ); |
@@ -251,42 +251,42 @@ discard block |
||
| 251 | 251 | * OR |
| 252 | 252 | * It's the Network Admin and we just don't know whether the sites have GF activated themselves. |
| 253 | 253 | */ |
| 254 | - if( true === $gf_status || is_network_admin() ) { |
|
| 254 | + if ( true === $gf_status || is_network_admin() ) { |
|
| 255 | 255 | return true; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // If GFCommon doesn't exist, assume GF not active |
| 259 | 259 | $return = false; |
| 260 | 260 | |
| 261 | - switch( $gf_status ) { |
|
| 261 | + switch ( $gf_status ) { |
|
| 262 | 262 | case 'inactive': |
| 263 | 263 | |
| 264 | 264 | // Required for multisite |
| 265 | - if( ! function_exists('wp_create_nonce') ) { |
|
| 265 | + if ( ! function_exists( 'wp_create_nonce' ) ) { |
|
| 266 | 266 | require_once ABSPATH . WPINC . '/pluggable.php'; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" |
| 270 | - if( is_multisite() ) { |
|
| 270 | + if ( is_multisite() ) { |
|
| 271 | 271 | wp_cookie_constants(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $return = false; |
| 275 | 275 | |
| 276 | - $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; |
|
| 276 | + $button = function_exists( 'is_network_admin' ) && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="' . wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php' ) . '" class="button button-large">'; |
|
| 277 | 277 | |
| 278 | - self::$notices['gf_inactive'] = array( |
|
| 278 | + self::$notices[ 'gf_inactive' ] = array( |
|
| 279 | 279 | 'class' => 'error', |
| 280 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ), |
|
| 280 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n" . $button, '</a></strong>' ), |
|
| 281 | 281 | 'cap' => 'activate_plugins', |
| 282 | 282 | 'dismiss' => 'gf_inactive', |
| 283 | 283 | ); |
| 284 | 284 | |
| 285 | 285 | break; |
| 286 | 286 | default: |
| 287 | - self::$notices['gf_installed'] = array( |
|
| 287 | + self::$notices[ 'gf_installed' ] = array( |
|
| 288 | 288 | 'class' => 'error', |
| 289 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
| 289 | + 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n" . '<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>' ), |
|
| 290 | 290 | 'cap' => 'install_plugins', |
| 291 | 291 | 'dismiss' => 'gf_installed', |
| 292 | 292 | ); |
@@ -303,10 +303,10 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | private static function check_gf_directory() { |
| 305 | 305 | |
| 306 | - if( class_exists( 'GFDirectory' ) ) { |
|
| 307 | - self::$notices['gf_directory'] = array( |
|
| 306 | + if ( class_exists( 'GFDirectory' ) ) { |
|
| 307 | + self::$notices[ 'gf_directory' ] = array( |
|
| 308 | 308 | 'class' => 'error is-dismissible', |
| 309 | - 'title' => __('Potential Conflict', 'gravityview' ), |
|
| 309 | + 'title' => __( 'Potential Conflict', 'gravityview' ), |
|
| 310 | 310 | 'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ), |
| 311 | 311 | 'dismiss' => 'gf_directory', |
| 312 | 312 | 'cap' => 'activate_plugins', |
@@ -325,21 +325,21 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public static function get_plugin_status( $location = '' ) { |
| 327 | 327 | |
| 328 | - if( ! function_exists('is_plugin_active') ) { |
|
| 328 | + if ( ! function_exists( 'is_plugin_active' ) ) { |
|
| 329 | 329 | include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
| 332 | + if ( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
| 333 | 333 | return true; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if( !is_network_admin() && is_plugin_active( $location ) ) { |
|
| 336 | + if ( ! is_network_admin() && is_plugin_active( $location ) ) { |
|
| 337 | 337 | return true; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if( |
|
| 341 | - !file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
| 342 | - !file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
| 340 | + if ( |
|
| 341 | + ! file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
| 342 | + ! file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
| 343 | 343 | ) { |
| 344 | 344 | return false; |
| 345 | 345 | } |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 1.15 |
| 223 | 223 | * |
| 224 | - * @param string|null $content Content inside shortcode, if defined |
|
| 225 | 224 | * |
| 226 | 225 | * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false. |
| 227 | 226 | */ |
@@ -316,7 +315,7 @@ discard block |
||
| 316 | 315 | * |
| 317 | 316 | * @since 1.15 |
| 318 | 317 | * |
| 319 | - * @param string $href URL |
|
| 318 | + * @param string|null $url |
|
| 320 | 319 | */ |
| 321 | 320 | private function maybe_add_field_values_query_args( $url ) { |
| 322 | 321 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
| 73 | 73 | */ |
| 74 | 74 | public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) { |
| 75 | - $atts['action'] = 'edit'; |
|
| 75 | + $atts[ 'action' ] = 'edit'; |
|
| 76 | 76 | |
| 77 | 77 | return $this->shortcode( $atts, $content, $context ); |
| 78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
| 86 | 86 | */ |
| 87 | 87 | public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) { |
| 88 | - $atts['action'] = 'delete'; |
|
| 88 | + $atts[ 'action' ] = 'delete'; |
|
| 89 | 89 | |
| 90 | 90 | return $this->shortcode( $atts, $content, $context ); |
| 91 | 91 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
| 128 | 128 | |
| 129 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
| 129 | + $this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] ); |
|
| 130 | 130 | |
| 131 | 131 | if ( empty( $this->view_id ) ) { |
| 132 | 132 | do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' ); |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return null; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
| 137 | + $this->entry = $this->get_entry( $this->settings[ 'entry_id' ] ); |
|
| 138 | 138 | |
| 139 | 139 | do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts ); |
| 140 | 140 | |
| 141 | 141 | if ( ! $this->has_cap() ) { |
| 142 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings['action'] ) . ' this entry: ' . $this->entry['id'] ); |
|
| 142 | + do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings[ 'action' ] ) . ' this entry: ' . $this->entry[ 'id' ] ); |
|
| 143 | 143 | |
| 144 | 144 | return null; |
| 145 | 145 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Get just the URL, not the tag |
| 156 | - if ( 'url' === $this->settings['return'] ) { |
|
| 156 | + if ( 'url' === $this->settings[ 'return' ] ) { |
|
| 157 | 157 | return $url; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | private function get_link_atts() { |
| 176 | 176 | |
| 177 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
| 177 | + wp_parse_str( $this->settings[ 'link_atts' ], $link_atts ); |
|
| 178 | 178 | |
| 179 | - if ( 'delete' === $this->settings['action'] ) { |
|
| 180 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 179 | + if ( 'delete' === $this->settings[ 'action' ] ) { |
|
| 180 | + $link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return (array) $link_atts; |
|
| 183 | + return (array)$link_atts; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | return $content; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - switch ( $this->settings['action'] ) { |
|
| 203 | + switch ( $this->settings[ 'action' ] ) { |
|
| 204 | 204 | case 'edit': |
| 205 | 205 | $anchor_text = __( 'Edit Entry', 'gravityview' ); |
| 206 | 206 | break; |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | private function get_url() { |
| 229 | 229 | |
| 230 | 230 | // if post_id is not defined, default to view_id |
| 231 | - $post_id = empty( $this->settings['post_id'] ) ? $this->view_id : absint( $this->settings['post_id'] ); |
|
| 231 | + $post_id = empty( $this->settings[ 'post_id' ] ) ? $this->view_id : absint( $this->settings[ 'post_id' ] ); |
|
| 232 | 232 | |
| 233 | - switch ( $this->settings['action'] ) { |
|
| 233 | + switch ( $this->settings[ 'action' ] ) { |
|
| 234 | 234 | case 'edit': |
| 235 | 235 | $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
| 236 | 236 | break; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | private function has_cap() { |
| 257 | 257 | |
| 258 | - switch ( $this->settings['action'] ) { |
|
| 258 | + switch ( $this->settings[ 'action' ] ) { |
|
| 259 | 259 | case 'edit': |
| 260 | 260 | $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
| 261 | 261 | break; |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | private function maybe_add_field_values_query_args( $url ) { |
| 322 | 322 | |
| 323 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
| 323 | + if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) { |
|
| 324 | 324 | |
| 325 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
| 325 | + wp_parse_str( $this->settings[ 'field_values' ], $field_values ); |
|
| 326 | 326 | |
| 327 | 327 | $url = add_query_arg( $field_values, $url ); |
| 328 | 328 | } |
@@ -278,7 +278,7 @@ |
||
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * Add a notice to be displayed in the admin. |
| 281 | - * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
|
| 281 | + * @param string $notice Array with `class` and `message` keys. The message is not escaped. |
|
| 282 | 282 | */ |
| 283 | 283 | public static function add_notice( $notice = array() ) { |
| 284 | 284 | |
@@ -244,13 +244,13 @@ |
||
| 244 | 244 | $this->_remote_update_url, |
| 245 | 245 | $this->_path, |
| 246 | 246 | array( |
| 247 | - 'version' => $this->_version, // current version number |
|
| 248 | - 'license' => $license['license'], |
|
| 249 | - 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 250 | - 'item_name' => $this->_title, // name of this plugin |
|
| 251 | - 'author' => strip_tags( $this->_author ) // author of this plugin |
|
| 252 | - ) |
|
| 253 | - ); |
|
| 247 | + 'version' => $this->_version, // current version number |
|
| 248 | + 'license' => $license['license'], |
|
| 249 | + 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 250 | + 'item_name' => $this->_title, // name of this plugin |
|
| 251 | + 'author' => strip_tags( $this->_author ) // author of this plugin |
|
| 252 | + ) |
|
| 253 | + ); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -71,13 +71,13 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
| 73 | 73 | |
| 74 | - add_action( 'admin_init', array( $this, 'settings') ); |
|
| 74 | + add_action( 'admin_init', array( $this, 'settings' ) ); |
|
| 75 | 75 | |
| 76 | 76 | add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
| 77 | 77 | |
| 78 | 78 | add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) ); |
| 79 | 79 | |
| 80 | - if( false === $this->is_extension_supported() ) { |
|
| 80 | + if ( false === $this->is_extension_supported() ) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $tab_settings = $this->tab_settings(); |
| 117 | 117 | |
| 118 | 118 | // Don't add a tab if it's empty. |
| 119 | - if( empty( $tab_settings ) ) { |
|
| 119 | + if ( empty( $tab_settings ) ) { |
|
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -134,17 +134,17 @@ discard block |
||
| 134 | 134 | $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
| 135 | 135 | |
| 136 | 136 | // Force the screen to be GravityView |
| 137 | - $tab['screen'] = 'gravityview'; |
|
| 137 | + $tab[ 'screen' ] = 'gravityview'; |
|
| 138 | 138 | |
| 139 | - if( class_exists('GravityView_Metabox_Tab') ) { |
|
| 139 | + if ( class_exists( 'GravityView_Metabox_Tab' ) ) { |
|
| 140 | 140 | |
| 141 | - $metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
| 141 | + $metabox = new GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] ); |
|
| 142 | 142 | |
| 143 | 143 | GravityView_Metabox_Tabs::add( $metabox ); |
| 144 | 144 | |
| 145 | 145 | } else { |
| 146 | 146 | |
| 147 | - add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
| 147 | + add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] ); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function load_plugin_textdomain() { |
| 162 | 162 | |
| 163 | - if( empty( $this->_text_domain ) ) { |
|
| 163 | + if ( empty( $this->_text_domain ) ) { |
|
| 164 | 164 | do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this ); |
| 165 | 165 | return; |
| 166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $lang_dir = dirname( plugin_basename( $path ) ) . '/languages/'; |
| 173 | 173 | |
| 174 | 174 | // Traditional WordPress plugin locale filter |
| 175 | - $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
| 175 | + $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
| 176 | 176 | |
| 177 | 177 | $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
| 178 | 178 | |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function get_license() { |
| 204 | 204 | |
| 205 | - if( !class_exists( 'GravityView_Settings' ) ) { |
|
| 205 | + if ( ! class_exists( 'GravityView_Settings' ) ) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $license = GravityView_Settings::getSetting('license'); |
|
| 209 | + $license = GravityView_Settings::getSetting( 'license' ); |
|
| 210 | 210 | |
| 211 | 211 | return $license; |
| 212 | 212 | } |
@@ -219,16 +219,16 @@ discard block |
||
| 219 | 219 | public function settings() { |
| 220 | 220 | |
| 221 | 221 | // If doing ajax, get outta here |
| 222 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 222 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 223 | 223 | return; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 226 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 227 | 227 | |
| 228 | 228 | $file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php'; |
| 229 | 229 | |
| 230 | 230 | // This file may be in the lib/ directory already |
| 231 | - if( ! file_exists( $file_path ) ) { |
|
| 231 | + if ( ! file_exists( $file_path ) ) { |
|
| 232 | 232 | $file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php'; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | $license = $this->get_license(); |
| 239 | 239 | |
| 240 | 240 | // Don't update if invalid license. |
| 241 | - if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; } |
|
| 241 | + if ( false === $license || empty( $license[ 'status' ] ) || strtolower( $license[ 'status' ] ) !== 'valid' ) { return; } |
|
| 242 | 242 | |
| 243 | 243 | new EDD_SL_Plugin_Updater( |
| 244 | 244 | $this->_remote_update_url, |
| 245 | 245 | $this->_path, |
| 246 | 246 | array( |
| 247 | 247 | 'version' => $this->_version, // current version number |
| 248 | - 'license' => $license['license'], |
|
| 248 | + 'license' => $license[ 'license' ], |
|
| 249 | 249 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
| 250 | - 'item_name' => $this->_title, // name of this plugin |
|
| 250 | + 'item_name' => $this->_title, // name of this plugin |
|
| 251 | 251 | 'author' => strip_tags( $this->_author ) // author of this plugin |
| 252 | 252 | ) |
| 253 | 253 | ); |
@@ -260,14 +260,14 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function admin_notice() { |
| 262 | 262 | |
| 263 | - if( empty( self::$admin_notices ) ) { |
|
| 263 | + if ( empty( self::$admin_notices ) ) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - foreach( self::$admin_notices as $key => $notice ) { |
|
| 267 | + foreach ( self::$admin_notices as $key => $notice ) { |
|
| 268 | 268 | |
| 269 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
| 270 | - echo wpautop( $notice['message'] ); |
|
| 269 | + echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">'; |
|
| 270 | + echo wpautop( $notice[ 'message' ] ); |
|
| 271 | 271 | echo '<div class="clear"></div>'; |
| 272 | 272 | echo '</div>'; |
| 273 | 273 | } |
@@ -282,16 +282,16 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | public static function add_notice( $notice = array() ) { |
| 284 | 284 | |
| 285 | - if( is_array( $notice ) && !isset( $notice['message'] ) ) { |
|
| 286 | - do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice ); |
|
| 285 | + if ( is_array( $notice ) && ! isset( $notice[ 'message' ] ) ) { |
|
| 286 | + do_action( 'gravityview_log_error', __CLASS__ . '[add_notice] Notice not set', $notice ); |
|
| 287 | 287 | return; |
| 288 | - } else if( is_string( $notice ) ) { |
|
| 288 | + } else if ( is_string( $notice ) ) { |
|
| 289 | 289 | $notice = array( 'message' => $notice ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
| 292 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
| 293 | 293 | |
| 294 | - self::$admin_notices[] = $notice; |
|
| 294 | + self::$admin_notices[ ] = $notice; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -346,17 +346,17 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $message = ''; |
| 348 | 348 | |
| 349 | - if( !class_exists( 'GravityView_Plugin' ) ) { |
|
| 349 | + if ( ! class_exists( 'GravityView_Plugin' ) ) { |
|
| 350 | 350 | |
| 351 | - $message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title ); |
|
| 351 | + $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), $this->_title ); |
|
| 352 | 352 | |
| 353 | - } else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) { |
|
| 353 | + } else if ( false === version_compare( GravityView_Plugin::version, $this->_min_gravityview_version, ">=" ) ) { |
|
| 354 | 354 | |
| 355 | - $message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
| 355 | + $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_gravityview_version . '</tt>' ); |
|
| 356 | 356 | |
| 357 | - } else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) { |
|
| 357 | + } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, ">=" ) ) { |
|
| 358 | 358 | |
| 359 | - $message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' ); |
|
| 359 | + $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_php_version . '</tt>' ); |
|
| 360 | 360 | |
| 361 | 361 | } else { |
| 362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | self::add_notice( $message ); |
| 370 | 370 | |
| 371 | - do_action( 'gravityview_log_error', __METHOD__. ' ' . $message ); |
|
| 371 | + do_action( 'gravityview_log_error', __METHOD__ . ' ' . $message ); |
|
| 372 | 372 | |
| 373 | 373 | self::$is_compatible = false; |
| 374 | 374 | } |
@@ -183,12 +183,10 @@ discard block |
||
| 183 | 183 | if ( file_exists( $mofile_global ) ) { |
| 184 | 184 | // Look in global /wp-content/languages/[plugin-dir]/ folder |
| 185 | 185 | load_textdomain( $this->_text_domain, $mofile_global ); |
| 186 | - } |
|
| 187 | - elseif ( file_exists( $mofile_local ) ) { |
|
| 186 | + } elseif ( file_exists( $mofile_local ) ) { |
|
| 188 | 187 | // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder |
| 189 | 188 | load_textdomain( $this->_text_domain, $mofile_local ); |
| 190 | - } |
|
| 191 | - else { |
|
| 189 | + } else { |
|
| 192 | 190 | // Load the default language files |
| 193 | 191 | load_plugin_textdomain( $this->_text_domain, false, $lang_dir ); |
| 194 | 192 | } |
@@ -219,7 +217,7 @@ discard block |
||
| 219 | 217 | public function settings() { |
| 220 | 218 | |
| 221 | 219 | // If doing ajax, get outta here |
| 222 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 220 | + if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 223 | 221 | return; |
| 224 | 222 | } |
| 225 | 223 | |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | * @param bool $url_encode Whether to URL-encode output |
| 136 | 136 | * @param bool $esc_html Whether to apply `esc_html()` to output |
| 137 | 137 | * |
| 138 | - * @return mixed |
|
| 138 | + * @return string |
|
| 139 | 139 | */ |
| 140 | 140 | public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
| 141 | 141 | |
@@ -122,7 +122,7 @@ |
||
| 122 | 122 | |
| 123 | 123 | $atts = array( |
| 124 | 124 | 'format' => self::get_format_from_modifiers( $exploded, false ), |
| 125 | - 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
| 125 | + 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
| 126 | 126 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
| 127 | 127 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
| 128 | 128 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param bool $esc_html Pass return value through `esc_html()` |
| 42 | 42 | * @return string Text with variables maybe replaced |
| 43 | 43 | */ |
| 44 | - public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 44 | + public static function replace_variables( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @internal Reported to GF Support on 12/3 |
| 66 | 66 | */ |
| 67 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
| 68 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
| 69 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
| 67 | + $form[ 'title' ] = isset( $form[ 'title' ] ) ? $form[ 'title' ] : ''; |
|
| 68 | + $form[ 'id' ] = isset( $form[ 'id' ] ) ? $form[ 'id' ] : ''; |
|
| 69 | + $form[ 'fields' ] = isset( $form[ 'fields' ] ) ? $form[ 'fields' ] : array(); |
|
| 70 | 70 | |
| 71 | 71 | return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html ); |
| 72 | 72 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return mixed |
| 88 | 88 | */ |
| 89 | - public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 89 | + public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @see GFCommon::replace_variables_prepopulate() |
| 95 | 95 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
| 96 | 96 | */ |
| 97 | - if( false === $form ) { |
|
| 97 | + if ( false === $form ) { |
|
| 98 | 98 | return $text; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
| 127 | 127 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
| 128 | 128 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
| 129 | - 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
| 129 | + 'time' => in_array( 'time', $exploded ), // {date_created:time} |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | $formatted_date = GVCommon::format_date( $date_created, $atts ); |
@@ -189,14 +189,14 @@ discard block |
||
| 189 | 189 | preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
| 190 | 190 | |
| 191 | 191 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
| 192 | - if( empty( $matches ) ) { |
|
| 192 | + if ( empty( $matches ) ) { |
|
| 193 | 193 | return $text; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | foreach ( $matches as $match ) { |
| 197 | 197 | |
| 198 | - $full_tag = $match[0]; |
|
| 199 | - $property = $match[1]; |
|
| 198 | + $full_tag = $match[ 0 ]; |
|
| 199 | + $property = $match[ 1 ]; |
|
| 200 | 200 | |
| 201 | 201 | $value = stripslashes_deep( rgget( $property ) ); |
| 202 | 202 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @since 1.15 |
| 221 | 221 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
| 222 | 222 | */ |
| 223 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 223 | + $esc_html = apply_filters( 'gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 224 | 224 | |
| 225 | 225 | $value = $esc_html ? esc_html( $value ) : $value; |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param[in] array $form Gravity Forms form array |
| 232 | 232 | * @param[in] array $entry Entry array |
| 233 | 233 | */ |
| 234 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 234 | + $value = apply_filters( 'gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 235 | 235 | |
| 236 | 236 | $text = str_replace( $full_tag, $value, $text ); |
| 237 | 237 | } |
@@ -67,7 +67,6 @@ |
||
| 67 | 67 | * |
| 68 | 68 | * @since 1.15 |
| 69 | 69 | * |
| 70 | - * @param array $allcaps An array of all the user's capabilities. |
|
| 71 | 70 | * @param array $caps Actual capabilities for meta capability. |
| 72 | 71 | * @param array $args Optional parameters passed to has_cap(), typically object ID. |
| 73 | 72 | * @param WP_User|null $user The user object, in WordPress 3.7.0 or higher |
@@ -1,14 +1,14 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Roles and Capabilities |
|
| 4 | - * |
|
| 5 | - * @package GravityView |
|
| 6 | - * @license GPL2+ |
|
| 7 | - * @since 1.14 |
|
| 8 | - * @author Katz Web Services, Inc. |
|
| 9 | - * @link http://gravityview.co |
|
| 10 | - * @copyright Copyright 2015, Katz Web Services, Inc. |
|
| 11 | - */ |
|
| 3 | + * Roles and Capabilities |
|
| 4 | + * |
|
| 5 | + * @package GravityView |
|
| 6 | + * @license GPL2+ |
|
| 7 | + * @since 1.14 |
|
| 8 | + * @author Katz Web Services, Inc. |
|
| 9 | + * @link http://gravityview.co |
|
| 10 | + * @copyright Copyright 2015, Katz Web Services, Inc. |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | 14 | defined( 'ABSPATH' ) || exit; |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -360,7 +360,6 @@ discard block |
||
| 360 | 360 | * Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against. |
| 361 | 361 | * |
| 362 | 362 | * @since 1.15 |
| 363 | - |
|
| 364 | 363 | * @param array $caps_to_check |
| 365 | 364 | * |
| 366 | 365 | * @return array |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function get_instance() { |
| 35 | 35 | |
| 36 | - if( ! self::$instance ) { |
|
| 36 | + if ( ! self::$instance ) { |
|
| 37 | 37 | self::$instance = new self; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps' ) ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
| 78 | 78 | |
| 79 | 79 | // Empty caps_to_check array |
| 80 | - if( ! $usercaps || ! $caps ) { |
|
| 80 | + if ( ! $usercaps || ! $caps ) { |
|
| 81 | 81 | return $usercaps; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
| 86 | 86 | */ |
| 87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
| 87 | + if ( ! empty( $usercaps[ 'gravityview_full_access' ] ) ) { |
|
| 88 | 88 | |
| 89 | 89 | $all_gravityview_caps = self::all_caps(); |
| 90 | 90 | |
| 91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
| 91 | + foreach ( $all_gravityview_caps as $gv_cap ) { |
|
| 92 | 92 | $usercaps[ $gv_cap ] = true; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -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 | } |