@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | function load() { |
| 26 | 26 | |
| 27 | - if( !is_admin() ) { |
|
| 27 | + if ( ! is_admin() ) { |
|
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | add_filter( 'gravityview_template_edit_link_options', array( $this, 'edit_link_field_options' ), 10, 5 ); |
| 39 | 39 | |
| 40 | 40 | // add tooltips |
| 41 | - add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips') ); |
|
| 41 | + add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'tooltips' ) ); |
|
| 42 | 42 | |
| 43 | 43 | // custom fields' options for zone EDIT |
| 44 | 44 | add_filter( 'gravityview_template_field_options', array( $this, 'field_options' ), 10, 5 ); |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
| 54 | 54 | |
| 55 | - if( $zone !== 'edit' ) { |
|
| 55 | + if ( $zone !== 'edit' ) { |
|
| 56 | 56 | |
| 57 | - $entry_default_fields['edit_link'] = array( |
|
| 58 | - 'label' => __('Edit Entry', 'gravityview'), |
|
| 57 | + $entry_default_fields[ 'edit_link' ] = array( |
|
| 58 | + 'label' => __( 'Edit Entry', 'gravityview' ), |
|
| 59 | 59 | 'type' => 'edit_link', |
| 60 | - 'desc' => __('A link to edit the entry. Visible based on View settings.', 'gravityview'), |
|
| 60 | + 'desc' => __( 'A link to edit the entry. Visible based on View settings.', 'gravityview' ), |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | } |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | $caps = $visibility_caps; |
| 82 | 82 | |
| 83 | 83 | // If we're configuring fields in the edit context, we want a limited selection |
| 84 | - if( $context === 'edit' ) { |
|
| 84 | + if ( $context === 'edit' ) { |
|
| 85 | 85 | |
| 86 | 86 | // Remove other built-in caps. |
| 87 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
| 87 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
| 88 | 88 | |
| 89 | - $caps['read'] = _x('Entry Creator','User capability', 'gravityview'); |
|
| 89 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $caps; |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | function edit_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 105 | 105 | |
| 106 | 106 | // Always a link, never a filter |
| 107 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
| 107 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
| 108 | 108 | |
| 109 | 109 | // Edit Entry link should only appear to visitors capable of editing entries |
| 110 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 110 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 111 | 111 | |
| 112 | - $add_option['edit_link'] = array( |
|
| 112 | + $add_option[ 'edit_link' ] = array( |
|
| 113 | 113 | 'type' => 'text', |
| 114 | 114 | 'label' => __( 'Edit Link Text', 'gravityview' ), |
| 115 | 115 | 'desc' => NULL, |
| 116 | - 'value' => __('Edit Entry', 'gravityview'), |
|
| 116 | + 'value' => __( 'Edit Entry', 'gravityview' ), |
|
| 117 | 117 | 'merge_tags' => true, |
| 118 | 118 | ); |
| 119 | 119 | |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $return = $tooltips; |
| 131 | 131 | |
| 132 | - $return['allow_edit_cap'] = array( |
|
| 133 | - 'title' => __('Limiting Edit Access', 'gravityview'), |
|
| 134 | - 'value' => __('Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview'), |
|
| 132 | + $return[ 'allow_edit_cap' ] = array( |
|
| 133 | + 'title' => __( 'Limiting Edit Access', 'gravityview' ), |
|
| 134 | + 'value' => __( 'Change this setting if you don\'t want the user who created the entry to be able to edit this field.', 'gravityview' ), |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | return $return; |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 150 | 150 | |
| 151 | 151 | // We only want to modify the settings for the edit context |
| 152 | - if( 'edit' !== $context ) { |
|
| 152 | + if ( 'edit' !== $context ) { |
|
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * @since 1.8.4 |
| 156 | 156 | */ |
| 157 | - $field_options['new_window'] = array( |
|
| 157 | + $field_options[ 'new_window' ] = array( |
|
| 158 | 158 | 'type' => 'checkbox', |
| 159 | 159 | 'label' => __( 'Open link in a new tab or window?', 'gravityview' ), |
| 160 | 160 | 'value' => false, |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Entry field is only for logged in users |
| 167 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
| 167 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
| 168 | 168 | |
| 169 | 169 | $add_options = array( |
| 170 | 170 | 'allow_edit_cap' => array( |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | static function getInstance() { |
| 43 | 43 | gravityview()->log->notice( '\GravityView_oEmbed is deprecated. Use \GV\oEmbed instead.' ); |
| 44 | 44 | |
| 45 | - if( empty( self::$instance ) ) { |
|
| 45 | + if ( empty( self::$instance ) ) { |
|
| 46 | 46 | self::$instance = new self; |
| 47 | 47 | self::$instance->initialize(); |
| 48 | 48 | } |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | public function get_output() { |
| 180 | 180 | |
| 181 | 181 | // No Entries |
| 182 | - if( empty( $this->entries ) ) { |
|
| 183 | - return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
|
| 182 | + if ( empty( $this->entries ) ) { |
|
| 183 | + return '<div class="gv-no-results">' . $this->empty_message . '</div>'; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $output = ''; |
@@ -191,18 +191,18 @@ discard block |
||
| 191 | 191 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
| 194 | + $output .= '<' . $this->wrapper_tag . '>'; |
|
| 195 | 195 | |
| 196 | - foreach( $this->entries as $entry ) { |
|
| 196 | + foreach ( $this->entries as $entry ) { |
|
| 197 | 197 | |
| 198 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 198 | + if ( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 199 | 199 | continue; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $output .= $this->get_item_output( $entry ); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
| 205 | + $output .= '</' . $this->wrapper_tag . '>'; |
|
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | private function skip_entry( $entry, $current_entry ) { |
| 226 | 226 | |
| 227 | 227 | // If skip entry is off, or there's no current entry, return false |
| 228 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 228 | + if ( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 229 | 229 | return false; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | // If in Single or Edit mode, $current_entry will be an array. |
| 233 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
| 233 | + $current_entry_id = is_array( $current_entry ) ? $current_entry[ 'id' ] : $current_entry; |
|
| 234 | 234 | |
| 235 | 235 | // If the entry ID matches the current entry, yes: skip |
| 236 | - if( $entry['id'] === $current_entry_id ) { |
|
| 236 | + if ( $entry[ 'id' ] === $current_entry_id ) { |
|
| 237 | 237 | return true; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $item_output = gravityview_get_link( $link, $this->link_format ); |
| 262 | 262 | |
| 263 | - if( !empty( $this->after_link ) ) { |
|
| 263 | + if ( ! empty( $this->after_link ) ) { |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | * @param array $entry Gravity Forms entry array |
| 270 | 270 | * @param GravityView_Entry_List $this The current class instance |
| 271 | 271 | */ |
| 272 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
| 272 | + $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this ); |
|
| 273 | 273 | |
| 274 | 274 | $item_output .= $after_link; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
| 278 | 278 | |
| 279 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
| 279 | + $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>'; |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | function __construct( ) { |
| 14 | 14 | |
| 15 | - $name = __('GravityView Recent Entries', 'gravityview'); |
|
| 15 | + $name = __( 'GravityView Recent Entries', 'gravityview' ); |
|
| 16 | 16 | |
| 17 | 17 | $widget_options = array( |
| 18 | 18 | 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private function initialize() { |
| 27 | 27 | |
| 28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
| 28 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 29 | 29 | |
| 30 | 30 | add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
| 31 | 31 | |
@@ -38,21 +38,21 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function ajax_get_view_merge_tag_data() { |
| 40 | 40 | |
| 41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
| 41 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajax_widget' ) ) { |
|
| 42 | 42 | exit( false ); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 45 | + $form_id = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 46 | 46 | |
| 47 | 47 | $form = RGFormsModel::get_form_meta( $form_id ); |
| 48 | 48 | |
| 49 | 49 | $output = array( |
| 50 | 50 | 'form' => array( |
| 51 | - 'id' => $form['id'], |
|
| 52 | - 'title' => $form['title'], |
|
| 53 | - 'fields' => $form['fields'], |
|
| 51 | + 'id' => $form[ 'id' ], |
|
| 52 | + 'title' => $form[ 'title' ], |
|
| 53 | + 'fields' => $form[ 'fields' ], |
|
| 54 | 54 | ), |
| 55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
| 55 | + 'mergeTags' => GFCommon::get_merge_tags( $form[ 'fields' ], '', false ), |
|
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | 58 | echo json_encode( $output ); |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | function admin_enqueue_scripts() { |
| 69 | 69 | global $pagenow; |
| 70 | 70 | |
| 71 | - if( $pagenow === 'widgets.php' ) { |
|
| 71 | + if ( $pagenow === 'widgets.php' ) { |
|
| 72 | 72 | |
| 73 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
| 73 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
| 74 | 74 | |
| 75 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
| 75 | + wp_enqueue_script( 'gravityview_widgets', plugins_url( 'assets/js/admin-widgets' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
| 76 | 76 | |
| 77 | 77 | wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
| 78 | 78 | 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
| 79 | - )); |
|
| 79 | + ) ); |
|
| 80 | 80 | |
| 81 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
| 81 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons' ), GravityView_Plugin::version ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | } |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | function widget( $args, $instance ) { |
| 94 | 94 | |
| 95 | 95 | // Don't have the Customizer render too soon. |
| 96 | - if( empty( $instance['view_id'] ) ) { |
|
| 96 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
| 101 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
| 100 | + $args[ 'id' ] = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries'; |
|
| 101 | + $instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : ''; |
|
| 102 | 102 | |
| 103 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
| 103 | + $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] ); |
|
| 104 | 104 | |
| 105 | - echo $args['before_widget']; |
|
| 105 | + echo $args[ 'before_widget' ]; |
|
| 106 | 106 | |
| 107 | - if ( !empty( $title ) ) { |
|
| 108 | - echo $args['before_title'] . $title . $args['after_title']; |
|
| 107 | + if ( ! empty( $title ) ) { |
|
| 108 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
| 127 | 127 | |
| 128 | - echo $args['after_widget']; |
|
| 128 | + echo $args[ 'after_widget' ]; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | private function get_output( $instance ) { |
| 141 | 141 | |
| 142 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
| 142 | + $form_id = gravityview_get_form_id( $instance[ 'view_id' ] ); |
|
| 143 | 143 | |
| 144 | 144 | $form = gravityview_get_form( $form_id ); |
| 145 | 145 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | * @since 1.6.1 |
| 150 | 150 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
| 151 | 151 | */ |
| 152 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
| 152 | + $entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ]; |
|
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Generate list output |
| 156 | 156 | * @since 1.7.2 |
| 157 | 157 | */ |
| 158 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget' ); |
|
| 158 | + $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget' ); |
|
| 159 | 159 | |
| 160 | 160 | $output = $List->get_output(); |
| 161 | 161 | |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | private function get_entries( $instance, $form_id ) { |
| 181 | 181 | |
| 182 | 182 | // Get the settings for the View ID |
| 183 | - $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
|
| 183 | + $view_settings = gravityview_get_template_settings( $instance[ 'view_id' ] ); |
|
| 184 | 184 | |
| 185 | 185 | // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
| 186 | - $criteria['context_view_id'] = $instance['view_id']; |
|
| 186 | + $criteria[ 'context_view_id' ] = $instance[ 'view_id' ]; |
|
| 187 | 187 | |
| 188 | - $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
| 189 | - $view_settings['id'] = $instance['view_id']; |
|
| 190 | - $view_settings['page_size'] = $instance['limit']; |
|
| 188 | + $instance[ 'limit' ] = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10; |
|
| 189 | + $view_settings[ 'id' ] = $instance[ 'view_id' ]; |
|
| 190 | + $view_settings[ 'page_size' ] = $instance[ 'limit' ]; |
|
| 191 | 191 | |
| 192 | 192 | // Prepare paging criteria |
| 193 | - $criteria['paging'] = array( |
|
| 193 | + $criteria[ 'paging' ] = array( |
|
| 194 | 194 | 'offset' => 0, |
| 195 | - 'page_size' => $instance['limit'] |
|
| 195 | + 'page_size' => $instance[ 'limit' ] |
|
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | 198 | // Prepare Search Criteria |
| 199 | - $criteria['search_criteria'] = array( 'field_filters' => array() ); |
|
| 200 | - $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria['search_criteria']); |
|
| 201 | - $criteria['search_criteria']['status'] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
| 199 | + $criteria[ 'search_criteria' ] = array( 'field_filters' => array() ); |
|
| 200 | + $criteria[ 'search_criteria' ] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria[ 'search_criteria' ] ); |
|
| 201 | + $criteria[ 'search_criteria' ][ 'status' ] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | 204 | * Modify the search parameters before the entries are fetched |
| 205 | 205 | */ |
| 206 | - $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
| 206 | + $criteria = apply_filters( 'gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
| 207 | 207 | |
| 208 | 208 | $results = GVCommon::get_entries( $form_id, $criteria ); |
| 209 | 209 | |
@@ -224,23 +224,23 @@ discard block |
||
| 224 | 224 | $instance = $new_instance; |
| 225 | 225 | |
| 226 | 226 | // Force positive number |
| 227 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
| 227 | + $instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] ); |
|
| 228 | 228 | |
| 229 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
| 229 | + $instance[ 'view_id' ] = intval( $instance[ 'view_id' ] ); |
|
| 230 | 230 | |
| 231 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
| 231 | + $instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) ); |
|
| 232 | 232 | |
| 233 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
| 233 | + $instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ]; |
|
| 234 | 234 | |
| 235 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
| 235 | + $instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] ); |
|
| 236 | 236 | |
| 237 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'] ); |
|
| 237 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ] ); |
|
| 238 | 238 | |
| 239 | 239 | //check if post_id is a valid post with embedded View |
| 240 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 240 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 241 | 241 | |
| 242 | 242 | // Share that the widget isn't brand new |
| 243 | - $instance['updated'] = 1; |
|
| 243 | + $instance[ 'updated' ] = 1; |
|
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -262,22 +262,22 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | // Set up some default widget settings. |
| 264 | 264 | $defaults = array( |
| 265 | - 'title' => __('Recent Entries', 'gravityview'), |
|
| 265 | + 'title' => __( 'Recent Entries', 'gravityview' ), |
|
| 266 | 266 | 'view_id' => NULL, |
| 267 | 267 | 'post_id' => NULL, |
| 268 | 268 | 'limit' => 10, |
| 269 | - 'link_format' => __('Entry #{entry_id}', 'gravityview'), |
|
| 269 | + 'link_format' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
| 270 | 270 | 'after_link' => '' |
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
| 273 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
| 274 | 274 | |
| 275 | 275 | ?> |
| 276 | 276 | |
| 277 | 277 | <!-- Title --> |
| 278 | 278 | <p> |
| 279 | 279 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
| 280 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
| 280 | + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" /> |
|
| 281 | 281 | </p> |
| 282 | 282 | |
| 283 | 283 | <!-- Download --> |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $views = get_posts( $args ); |
| 291 | 291 | |
| 292 | 292 | // If there are no views set up yet, we get outta here. |
| 293 | - if( empty( $views ) ) { |
|
| 293 | + if ( empty( $views ) ) { |
|
| 294 | 294 | echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Admin::no_views_text() . '</div></div>'; |
| 295 | 295 | return; |
| 296 | 296 | } |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | * Display errors generated for invalid embed IDs |
| 303 | 303 | * @see GravityView_View_Data::is_valid_embed_id |
| 304 | 304 | */ |
| 305 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
| 305 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
| 306 | 306 | ?> |
| 307 | 307 | <div class="error inline hide-on-view-change"> |
| 308 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
| 308 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
| 309 | 309 | </div> |
| 310 | 310 | <?php |
| 311 | 311 | unset ( $error ); |
@@ -313,14 +313,14 @@ discard block |
||
| 313 | 313 | ?> |
| 314 | 314 | |
| 315 | 315 | <p> |
| 316 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
| 316 | + <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label> |
|
| 317 | 317 | <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
| 318 | 318 | <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
| 319 | 319 | <?php |
| 320 | 320 | |
| 321 | - foreach( $views as $view ) { |
|
| 322 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
| 323 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
| 321 | + foreach ( $views as $view ) { |
|
| 322 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
| 323 | + echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | ?> |
@@ -332,10 +332,10 @@ discard block |
||
| 332 | 332 | * Display errors generated for invalid embed IDs |
| 333 | 333 | * @see GravityView_View_Data::is_valid_embed_id |
| 334 | 334 | */ |
| 335 | - if( !empty( $instance['error_post_id'] ) ) { |
|
| 335 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
| 336 | 336 | ?> |
| 337 | 337 | <div class="error inline"> |
| 338 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
| 338 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
| 339 | 339 | </div> |
| 340 | 340 | <?php |
| 341 | 341 | unset ( $error ); |
@@ -343,11 +343,11 @@ discard block |
||
| 343 | 343 | ?> |
| 344 | 344 | |
| 345 | 345 | <p> |
| 346 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
| 347 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
| 346 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
| 347 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'post_id' ] ); ?>" /> |
|
| 348 | 348 | <span class="howto"><?php |
| 349 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
| 350 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 349 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
| 350 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 351 | 351 | ?></span> |
| 352 | 352 | </p> |
| 353 | 353 | |
@@ -355,21 +355,21 @@ discard block |
||
| 355 | 355 | <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
| 356 | 356 | <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
| 357 | 357 | </label> |
| 358 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
| 358 | + <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance[ 'limit' ] ); ?>" size="3" /> |
|
| 359 | 359 | </p> |
| 360 | 360 | |
| 361 | 361 | <p> |
| 362 | 362 | <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
| 363 | 363 | <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
| 364 | 364 | </label> |
| 365 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
| 365 | + <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'link_format' ] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
| 366 | 366 | </p> |
| 367 | 367 | |
| 368 | 368 | <p> |
| 369 | 369 | <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
| 370 | 370 | <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
| 371 | 371 | </label> |
| 372 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
| 372 | + <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance[ 'after_link' ] ); ?></textarea> |
|
| 373 | 373 | </p> |
| 374 | 374 | |
| 375 | 375 | <?php |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
| 380 | 380 | * @param array $instance Current widget instance |
| 381 | 381 | */ |
| 382 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
| 382 | + do_action( 'gravityview_recent_entries_widget_form', $this, $instance ); |
|
| 383 | 383 | |
| 384 | 384 | ?> |
| 385 | 385 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | $widget_ops = array( |
| 13 | 13 | 'classname' => 'widget_gravityview_search', |
| 14 | - 'description' => __( 'A search form for a specific GravityView.', 'gravityview') |
|
| 14 | + 'description' => __( 'A search form for a specific GravityView.', 'gravityview' ) |
|
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | 17 | $widget_display = array( |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | private function load_required_files() { |
| 37 | - if( !class_exists( 'GravityView_Widget_Search' ) ) { |
|
| 37 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
| 38 | 38 | gravityview_register_gravityview_widgets(); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public function widget( $args, $instance ) { |
| 54 | 54 | |
| 55 | 55 | // Don't show unless a View ID has been set. |
| 56 | - if( empty( $instance['view_id'] ) ) { |
|
| 56 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
| 57 | 57 | |
| 58 | 58 | gravityview()->log->debug( 'No View ID has been defined. Not showing the widget.', array( 'data' => $instance ) ); |
| 59 | 59 | |
@@ -61,22 +61,22 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** This filter is documented in wp-includes/default-widgets.php */ |
| 64 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
|
| 64 | + $title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? '' : $instance[ 'title' ], $instance, $this->id_base ); |
|
| 65 | 65 | |
| 66 | - echo $args['before_widget']; |
|
| 66 | + echo $args[ 'before_widget' ]; |
|
| 67 | 67 | |
| 68 | 68 | if ( $title ) { |
| 69 | - echo $args['before_title'] . $title . $args['after_title']; |
|
| 69 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // @todo Add to the widget configuration form |
| 73 | - $instance['search_layout'] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
| 73 | + $instance[ 'search_layout' ] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
| 74 | 74 | |
| 75 | - $instance['context'] = 'wp_widget'; |
|
| 75 | + $instance[ 'context' ] = 'wp_widget'; |
|
| 76 | 76 | |
| 77 | 77 | // form |
| 78 | - $instance['form_id'] = GVCommon::get_meta_form_id( $instance['view_id'] ); |
|
| 79 | - $instance['form'] = GVCommon::get_form( $instance['form_id'] ); |
|
| 78 | + $instance[ 'form_id' ] = GVCommon::get_meta_form_id( $instance[ 'view_id' ] ); |
|
| 79 | + $instance[ 'form' ] = GVCommon::get_form( $instance[ 'form_id' ] ); |
|
| 80 | 80 | |
| 81 | 81 | // We don't want to overwrite existing context, etc. |
| 82 | 82 | $previous_view = GravityView_View::getInstance(); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | new GravityView_View( $previous_view ); |
| 94 | 94 | |
| 95 | - echo $args['after_widget']; |
|
| 95 | + echo $args[ 'after_widget' ]; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,27 +102,27 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $instance = $old_instance; |
| 104 | 104 | |
| 105 | - if( $this->is_preview() ) { |
|
| 105 | + if ( $this->is_preview() ) { |
|
| 106 | 106 | //Oh! Sorry but still not fully compatible with customizer |
| 107 | 107 | return $instance; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() ); |
|
| 110 | + $new_instance = wp_parse_args( (array)$new_instance, self::get_defaults() ); |
|
| 111 | 111 | |
| 112 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 113 | - $instance['view_id'] = absint( $new_instance['view_id'] ); |
|
| 114 | - $instance['search_fields'] = $new_instance['search_fields']; |
|
| 115 | - $instance['post_id'] = $new_instance['post_id']; |
|
| 116 | - $instance['search_clear'] = $new_instance['search_clear']; |
|
| 117 | - $instance['search_mode'] = $new_instance['search_mode']; |
|
| 112 | + $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); |
|
| 113 | + $instance[ 'view_id' ] = absint( $new_instance[ 'view_id' ] ); |
|
| 114 | + $instance[ 'search_fields' ] = $new_instance[ 'search_fields' ]; |
|
| 115 | + $instance[ 'post_id' ] = $new_instance[ 'post_id' ]; |
|
| 116 | + $instance[ 'search_clear' ] = $new_instance[ 'search_clear' ]; |
|
| 117 | + $instance[ 'search_mode' ] = $new_instance[ 'search_mode' ]; |
|
| 118 | 118 | |
| 119 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'], true ); |
|
| 119 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ], true ); |
|
| 120 | 120 | |
| 121 | 121 | //check if post_id is a valid post with embedded View |
| 122 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 122 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
| 123 | 123 | |
| 124 | 124 | // Share that the widget isn't brand new |
| 125 | - $instance['updated'] = 1; |
|
| 125 | + $instance[ 'updated' ] = 1; |
|
| 126 | 126 | |
| 127 | 127 | return $instance; |
| 128 | 128 | } |
@@ -133,28 +133,28 @@ discard block |
||
| 133 | 133 | public function form( $instance ) { |
| 134 | 134 | |
| 135 | 135 | // @todo Make compatible with Customizer |
| 136 | - if( $this->is_preview() ) { |
|
| 136 | + if ( $this->is_preview() ) { |
|
| 137 | 137 | |
| 138 | - $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="'.admin_url('widgets.php').'">', '</a>' ); |
|
| 138 | + $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="' . admin_url( 'widgets.php' ) . '">', '</a>' ); |
|
| 139 | 139 | |
| 140 | 140 | echo wpautop( GravityView_Admin::get_floaty() . $warning ); |
| 141 | 141 | |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $instance = wp_parse_args( (array) $instance, self::get_defaults() ); |
|
| 145 | + $instance = wp_parse_args( (array)$instance, self::get_defaults() ); |
|
| 146 | 146 | |
| 147 | - $title = $instance['title']; |
|
| 148 | - $view_id = $instance['view_id']; |
|
| 149 | - $post_id = $instance['post_id']; |
|
| 150 | - $search_fields = $instance['search_fields']; |
|
| 151 | - $search_clear = $instance['search_clear']; |
|
| 152 | - $search_mode = $instance['search_mode']; |
|
| 147 | + $title = $instance[ 'title' ]; |
|
| 148 | + $view_id = $instance[ 'view_id' ]; |
|
| 149 | + $post_id = $instance[ 'post_id' ]; |
|
| 150 | + $search_fields = $instance[ 'search_fields' ]; |
|
| 151 | + $search_clear = $instance[ 'search_clear' ]; |
|
| 152 | + $search_mode = $instance[ 'search_mode' ]; |
|
| 153 | 153 | |
| 154 | 154 | $views = GVCommon::get_all_views(); |
| 155 | 155 | |
| 156 | 156 | // If there are no views set up yet, we get outta here. |
| 157 | - if( empty( $views ) ) { ?> |
|
| 157 | + if ( empty( $views ) ) { ?> |
|
| 158 | 158 | <div id="select_gravityview_view"> |
| 159 | 159 | <div class="wrap"><?php echo GravityView_Admin::no_views_text(); ?></div> |
| 160 | 160 | </div> |
@@ -162,17 +162,17 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | ?> |
| 164 | 164 | |
| 165 | - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'gravityview'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
| 165 | + <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'gravityview' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
| 166 | 166 | |
| 167 | 167 | <?php |
| 168 | 168 | /** |
| 169 | 169 | * Display errors generated for invalid embed IDs |
| 170 | 170 | * @see GravityView_View_Data::is_valid_embed_id |
| 171 | 171 | */ |
| 172 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
| 172 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
| 173 | 173 | ?> |
| 174 | 174 | <div class="error inline hide-on-view-change"> |
| 175 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
| 175 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
| 176 | 176 | </div> |
| 177 | 177 | <?php |
| 178 | 178 | unset ( $error ); |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | <p> |
| 183 | 183 | <label for="gravityview_view_id"><?php _e( 'View:', 'gravityview' ); ?></label> |
| 184 | - <select id="gravityview_view_id" name="<?php echo $this->get_field_name('view_id'); ?>" class="widefat"> |
|
| 184 | + <select id="gravityview_view_id" name="<?php echo $this->get_field_name( 'view_id' ); ?>" class="widefat"> |
|
| 185 | 185 | <option value=""><?php esc_html_e( '— Select a View —', 'gravityview' ); ?></option> |
| 186 | 186 | <?php |
| 187 | - foreach( $views as $view_option ) { |
|
| 188 | - $title = empty( $view_option->post_title ) ? __('(no title)', 'gravityview') : $view_option->post_title; |
|
| 189 | - echo '<option value="'. $view_option->ID .'" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>'. esc_html( sprintf('%s #%d', $title, $view_option->ID ) ) .'</option>'; |
|
| 187 | + foreach ( $views as $view_option ) { |
|
| 188 | + $title = empty( $view_option->post_title ) ? __( '(no title)', 'gravityview' ) : $view_option->post_title; |
|
| 189 | + echo '<option value="' . $view_option->ID . '" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>' . esc_html( sprintf( '%s #%d', $title, $view_option->ID ) ) . '</option>'; |
|
| 190 | 190 | } |
| 191 | 191 | ?> |
| 192 | 192 | </select> |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | * Display errors generated for invalid embed IDs |
| 199 | 199 | * @see GravityView_View_Data::is_valid_embed_id |
| 200 | 200 | */ |
| 201 | - if( !empty( $instance['error_post_id'] ) ) { |
|
| 201 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
| 202 | 202 | ?> |
| 203 | 203 | <div class="error inline"> |
| 204 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
| 204 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
| 205 | 205 | </div> |
| 206 | 206 | <?php |
| 207 | 207 | unset ( $error ); |
@@ -209,40 +209,40 @@ discard block |
||
| 209 | 209 | ?> |
| 210 | 210 | |
| 211 | 211 | <p> |
| 212 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
| 213 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" /> |
|
| 212 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
| 213 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" /> |
|
| 214 | 214 | <span class="howto"><?php |
| 215 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
| 216 | - echo ' '.gravityview_get_link('https://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 215 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
| 216 | + echo ' ' . gravityview_get_link( 'https://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 217 | 217 | ?></span> |
| 218 | 218 | </p> |
| 219 | 219 | |
| 220 | 220 | <p> |
| 221 | - <label for="<?php echo $this->get_field_id('search_clear'); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
| 222 | - <input name="<?php echo $this->get_field_name('search_clear'); ?>" type="hidden" value="0"> |
|
| 223 | - <input id="<?php echo $this->get_field_id('search_clear'); ?>" name="<?php echo $this->get_field_name('search_clear'); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
| 221 | + <label for="<?php echo $this->get_field_id( 'search_clear' ); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
| 222 | + <input name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="hidden" value="0"> |
|
| 223 | + <input id="<?php echo $this->get_field_id( 'search_clear' ); ?>" name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
| 224 | 224 | </p> |
| 225 | 225 | |
| 226 | 226 | <p> |
| 227 | 227 | <label><?php esc_html_e( 'Search Mode', 'gravityview' ); ?>:</label> |
| 228 | - <label for="<?php echo $this->get_field_id('search_mode'); ?>_any"> |
|
| 229 | - <input id="<?php echo $this->get_field_id('search_mode'); ?>_any" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>> |
|
| 228 | + <label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_any"> |
|
| 229 | + <input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_any" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="any" <?php checked( $search_mode, 'any', true ); ?>> |
|
| 230 | 230 | <?php esc_html_e( 'Match Any Fields', 'gravityview' ); ?> |
| 231 | 231 | </label> |
| 232 | - <label for="<?php echo $this->get_field_id('search_mode'); ?>_all"> |
|
| 233 | - <input id="<?php echo $this->get_field_id('search_mode'); ?>_all" name="<?php echo $this->get_field_name('search_mode'); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>> |
|
| 232 | + <label for="<?php echo $this->get_field_id( 'search_mode' ); ?>_all"> |
|
| 233 | + <input id="<?php echo $this->get_field_id( 'search_mode' ); ?>_all" name="<?php echo $this->get_field_name( 'search_mode' ); ?>" type="radio" class="radio" value="all" <?php checked( $search_mode, 'all', true ); ?>> |
|
| 234 | 234 | <?php esc_html_e( 'Match All Fields', 'gravityview' ); ?> |
| 235 | 235 | </label> |
| 236 | - <span class="howto"><?php esc_html_e('Should search results match all search fields, or any?', 'gravityview' ); ?></span |
|
| 236 | + <span class="howto"><?php esc_html_e( 'Should search results match all search fields, or any?', 'gravityview' ); ?></span |
|
| 237 | 237 | </p> |
| 238 | 238 | |
| 239 | 239 | <hr /> |
| 240 | 240 | |
| 241 | 241 | <?php // @todo: move style to CSS ?> |
| 242 | 242 | <div style="margin-bottom: 1em;"> |
| 243 | - <label class="screen-reader-text" for="<?php echo $this->get_field_id('search_fields'); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
| 244 | - <div class="gv-widget-search-fields" title="<?php esc_html_e('Search Fields', 'gravityview'); ?>"> |
|
| 245 | - <input id="<?php echo $this->get_field_id('search_fields'); ?>" name="<?php echo $this->get_field_name('search_fields'); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
| 243 | + <label class="screen-reader-text" for="<?php echo $this->get_field_id( 'search_fields' ); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
| 244 | + <div class="gv-widget-search-fields" title="<?php esc_html_e( 'Search Fields', 'gravityview' ); ?>"> |
|
| 245 | + <input id="<?php echo $this->get_field_id( 'search_fields' ); ?>" name="<?php echo $this->get_field_name( 'search_fields' ); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
| 246 | 246 | </div> |
| 247 | 247 | |
| 248 | 248 | </div> |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Don't exit if we're running test suite. |
| 37 | 37 | * @since 1.15 |
| 38 | 38 | */ |
| 39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 39 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 40 | 40 | return $mixed; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function check_ajax_nonce() { |
| 53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
| 53 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxviews' ) ) { |
|
| 54 | 54 | $this->_exit( false ); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | //check nonce |
| 68 | 68 | $this->check_ajax_nonce(); |
| 69 | 69 | |
| 70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
| 70 | + $context = isset( $_POST[ 'context' ] ) ? esc_attr( $_POST[ 'context' ] ) : 'directory'; |
|
| 71 | 71 | |
| 72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
| 73 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
| 73 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 74 | + do_action( 'gravityview_render_available_fields', (int)$_POST[ 'form_id' ], $context ); |
|
| 75 | 75 | $this->_exit(); |
| 76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
| 77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 76 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 77 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 78 | 78 | |
| 79 | 79 | /** @see GravityView_Admin_Views::render_available_fields */ |
| 80 | 80 | do_action( 'gravityview_render_available_fields', $form, $context ); |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | function get_active_areas() { |
| 97 | 97 | $this->check_ajax_nonce(); |
| 98 | 98 | |
| 99 | - if( empty( $_POST['template_id'] ) ) { |
|
| 99 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 100 | 100 | $this->_exit( false ); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | ob_start(); |
| 104 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 105 | - $response['directory'] = ob_get_clean(); |
|
| 104 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true ); |
|
| 105 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 106 | 106 | |
| 107 | 107 | ob_start(); |
| 108 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 109 | - $response['single'] = ob_get_clean(); |
|
| 108 | + do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true ); |
|
| 109 | + $response[ 'single' ] = ob_get_clean(); |
|
| 110 | 110 | |
| 111 | 111 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 112 | 112 | |
@@ -121,20 +121,20 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $this->check_ajax_nonce(); |
| 123 | 123 | |
| 124 | - if( empty( $_POST['template_id'] ) ) { |
|
| 124 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 125 | 125 | $this->_exit( false ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // get the fields xml config file for this specific preset |
| 129 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 129 | + $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] ); |
|
| 130 | 130 | // import fields |
| 131 | - if( !empty( $preset_fields_path ) ) { |
|
| 131 | + if ( ! empty( $preset_fields_path ) ) { |
|
| 132 | 132 | $presets = $this->import_fields( $preset_fields_path ); |
| 133 | 133 | } else { |
| 134 | 134 | $presets = array( 'widgets' => array(), 'fields' => array() ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 137 | + $template_id = esc_attr( $_POST[ 'template_id' ] ); |
|
| 138 | 138 | |
| 139 | 139 | // template areas |
| 140 | 140 | $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
@@ -144,20 +144,20 @@ discard block |
||
| 144 | 144 | $default_widget_areas = GravityView_Widget::get_default_widget_areas(); |
| 145 | 145 | |
| 146 | 146 | ob_start(); |
| 147 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 148 | - $response['header'] = ob_get_clean(); |
|
| 147 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 148 | + $response[ 'header' ] = ob_get_clean(); |
|
| 149 | 149 | |
| 150 | 150 | ob_start(); |
| 151 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 152 | - $response['footer'] = ob_get_clean(); |
|
| 151 | + do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] ); |
|
| 152 | + $response[ 'footer' ] = ob_get_clean(); |
|
| 153 | 153 | |
| 154 | 154 | ob_start(); |
| 155 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 156 | - $response['directory'] = ob_get_clean(); |
|
| 155 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] ); |
|
| 156 | + $response[ 'directory' ] = ob_get_clean(); |
|
| 157 | 157 | |
| 158 | 158 | ob_start(); |
| 159 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 160 | - $response['single'] = ob_get_clean(); |
|
| 159 | + do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] ); |
|
| 160 | + $response[ 'single' ] = ob_get_clean(); |
|
| 161 | 161 | |
| 162 | 162 | $response = array_map( 'gravityview_strip_whitespace', $response ); |
| 163 | 163 | |
@@ -175,26 +175,26 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $this->check_ajax_nonce(); |
| 177 | 177 | |
| 178 | - if( empty( $_POST['template_id'] ) ) { |
|
| 178 | + if ( empty( $_POST[ 'template_id' ] ) ) { |
|
| 179 | 179 | gravityview()->log->error( 'Cannot create preset form; the template_id is empty.' ); |
| 180 | 180 | $this->_exit( false ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // get the xml for this specific template_id |
| 184 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 184 | + $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] ); |
|
| 185 | 185 | |
| 186 | 186 | // import form |
| 187 | 187 | $form = $this->import_form( $preset_form_xml_path ); |
| 188 | 188 | |
| 189 | 189 | // get the form ID |
| 190 | - if( false === $form ) { |
|
| 190 | + if ( false === $form ) { |
|
| 191 | 191 | // send error to user |
| 192 | - gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int) $_POST['template_id'] ) ); |
|
| 192 | + gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int)$_POST[ 'template_id' ] ) ); |
|
| 193 | 193 | |
| 194 | 194 | $this->_exit( false ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 197 | + $this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' ); |
|
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | gravityview()->log->debug( '[import_form] Import Preset Form. (File) {path}', array( 'path' => $xml_or_json_path ) ); |
| 210 | 210 | |
| 211 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 211 | + if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) { |
|
| 212 | 212 | gravityview()->log->error( 'Class GFExport or file not found. file: {path}', array( 'path' => $xml_or_json_path ) ); |
| 213 | 213 | return false; |
| 214 | 214 | } |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | gravityview()->log->debug( '[import_form] Importing form (Result) {count}', array( 'count' => $count ) ); |
| 221 | 221 | gravityview()->log->debug( '[import_form] Importing form (Form) ', array( 'data' => $forms ) ); |
| 222 | 222 | |
| 223 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 223 | + if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) { |
|
| 224 | 224 | gravityview()->log->error( 'Form Import Failed!' ); |
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // import success - return form id |
| 229 | - return $forms[0]; |
|
| 229 | + return $forms[ 0 ]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | function get_field_options() { |
| 241 | 241 | $this->check_ajax_nonce(); |
| 242 | 242 | |
| 243 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 243 | + if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) { |
|
| 244 | 244 | gravityview()->log->error( 'Required fields were not set in the $_POST request. ' ); |
| 245 | 245 | $this->_exit( false ); |
| 246 | 246 | } |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | $_post = array_map( 'esc_attr', $_post ); |
| 253 | 253 | |
| 254 | 254 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 255 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 256 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 255 | + $input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL; |
|
| 256 | + $context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL; |
|
| 257 | 257 | |
| 258 | - $form_id = empty( $_post['form_id'] ) ? null : $_post['form_id']; |
|
| 259 | - $response = GravityView_Render_Settings::render_field_options( $form_id, $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
| 258 | + $form_id = empty( $_post[ 'form_id' ] ) ? null : $_post[ 'form_id' ]; |
|
| 259 | + $response = GravityView_Render_Settings::render_field_options( $form_id, $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context ); |
|
| 260 | 260 | |
| 261 | 261 | $response = gravityview_strip_whitespace( $response ); |
| 262 | 262 | |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | $form = ''; |
| 278 | 278 | |
| 279 | 279 | // if form id is set, use it, else, get form from preset |
| 280 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 280 | + if ( ! empty( $_POST[ 'form_id' ] ) ) { |
|
| 281 | 281 | |
| 282 | - $form = (int) $_POST['form_id']; |
|
| 282 | + $form = (int)$_POST[ 'form_id' ]; |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | // get form from preset |
| 286 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 286 | + elseif ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
| 287 | 287 | |
| 288 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 288 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 289 | 289 | |
| 290 | 290 | } |
| 291 | 291 | |
@@ -301,27 +301,27 @@ discard block |
||
| 301 | 301 | * @param string $template_id Preset template |
| 302 | 302 | * |
| 303 | 303 | */ |
| 304 | - static function pre_get_form_fields( $template_id = '') { |
|
| 304 | + static function pre_get_form_fields( $template_id = '' ) { |
|
| 305 | 305 | |
| 306 | - if( empty( $template_id ) ) { |
|
| 306 | + if ( empty( $template_id ) ) { |
|
| 307 | 307 | gravityview()->log->error( 'Template ID not set.' ); |
| 308 | 308 | return false; |
| 309 | 309 | } else { |
| 310 | 310 | $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
| 311 | - if( !file_exists( $form_file ) ) { |
|
| 311 | + if ( ! file_exists( $form_file ) ) { |
|
| 312 | 312 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. File not found. file: {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 313 | 313 | return false; |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Load xml parser (from GravityForms) |
| 318 | - if( class_exists( 'GFCommon' ) ) { |
|
| 318 | + if ( class_exists( 'GFCommon' ) ) { |
|
| 319 | 319 | $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
| 320 | 320 | } else { |
| 321 | 321 | $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if( file_exists( $xml_parser ) ) { |
|
| 324 | + if ( file_exists( $xml_parser ) ) { |
|
| 325 | 325 | require_once( $xml_parser ); |
| 326 | 326 | } else { |
| 327 | 327 | gravityview()->log->debug( ' - Gravity Forms XML Parser not found {path}.', array( 'path' => $xml_parser ) ); |
@@ -332,32 +332,32 @@ discard block |
||
| 332 | 332 | $xmlstr = file_get_contents( $form_file ); |
| 333 | 333 | |
| 334 | 334 | $options = array( |
| 335 | - "page" => array("unserialize_as_array" => true), |
|
| 336 | - "form"=> array("unserialize_as_array" => true), |
|
| 337 | - "field"=> array("unserialize_as_array" => true), |
|
| 338 | - "rule"=> array("unserialize_as_array" => true), |
|
| 339 | - "choice"=> array("unserialize_as_array" => true), |
|
| 340 | - "input"=> array("unserialize_as_array" => true), |
|
| 341 | - "routing_item"=> array("unserialize_as_array" => true), |
|
| 342 | - "creditCard"=> array("unserialize_as_array" => true), |
|
| 343 | - "routin"=> array("unserialize_as_array" => true), |
|
| 344 | - "confirmation" => array("unserialize_as_array" => true), |
|
| 345 | - "notification" => array("unserialize_as_array" => true) |
|
| 335 | + "page" => array( "unserialize_as_array" => true ), |
|
| 336 | + "form"=> array( "unserialize_as_array" => true ), |
|
| 337 | + "field"=> array( "unserialize_as_array" => true ), |
|
| 338 | + "rule"=> array( "unserialize_as_array" => true ), |
|
| 339 | + "choice"=> array( "unserialize_as_array" => true ), |
|
| 340 | + "input"=> array( "unserialize_as_array" => true ), |
|
| 341 | + "routing_item"=> array( "unserialize_as_array" => true ), |
|
| 342 | + "creditCard"=> array( "unserialize_as_array" => true ), |
|
| 343 | + "routin"=> array( "unserialize_as_array" => true ), |
|
| 344 | + "confirmation" => array( "unserialize_as_array" => true ), |
|
| 345 | + "notification" => array( "unserialize_as_array" => true ) |
|
| 346 | 346 | ); |
| 347 | 347 | |
| 348 | - $xml = new RGXML($options); |
|
| 349 | - $forms = $xml->unserialize($xmlstr); |
|
| 348 | + $xml = new RGXML( $options ); |
|
| 349 | + $forms = $xml->unserialize( $xmlstr ); |
|
| 350 | 350 | |
| 351 | - if( !$forms ) { |
|
| 351 | + if ( ! $forms ) { |
|
| 352 | 352 | gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) ); |
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 357 | - $form = $forms[0]; |
|
| 356 | + if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) { |
|
| 357 | + $form = $forms[ 0 ]; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if( empty( $form ) ) { |
|
| 360 | + if ( empty( $form ) ) { |
|
| 361 | 361 | gravityview()->log->error( '$form not set.', array( 'data' => $forms ) ); |
| 362 | 362 | return false; |
| 363 | 363 | } |
@@ -376,38 +376,38 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | function import_fields( $file ) { |
| 378 | 378 | |
| 379 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 379 | + if ( empty( $file ) || ! file_exists( $file ) ) { |
|
| 380 | 380 | gravityview()->log->error( 'Importing Preset Fields. File not found. (File) {path}', array( 'path' => $file ) ); |
| 381 | 381 | return false; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if( !class_exists('WXR_Parser') ) { |
|
| 384 | + if ( ! class_exists( 'WXR_Parser' ) ) { |
|
| 385 | 385 | include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | $parser = new WXR_Parser(); |
| 389 | 389 | $presets = $parser->parse( $file ); |
| 390 | 390 | |
| 391 | - if(is_wp_error( $presets )) { |
|
| 391 | + if ( is_wp_error( $presets ) ) { |
|
| 392 | 392 | gravityview()->log->error( 'Importing Preset Fields failed. Threw WP_Error.', array( 'data' => $presets ) ); |
| 393 | 393 | return false; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 396 | + if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) { |
|
| 397 | 397 | gravityview()->log->error( 'Importing Preset Fields failed. Meta not found in file. {path}', array( 'path' => $file ) ); |
| 398 | 398 | return false; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets['posts'][0]['postmeta'] ) ); |
|
| 401 | + gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ); |
|
| 402 | 402 | |
| 403 | 403 | $fields = $widgets = array(); |
| 404 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 405 | - switch ($meta['key']) { |
|
| 404 | + foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) { |
|
| 405 | + switch ( $meta[ 'key' ] ) { |
|
| 406 | 406 | case '_gravityview_directory_fields': |
| 407 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 407 | + $fields = maybe_unserialize( $meta[ 'value' ] ); |
|
| 408 | 408 | break; |
| 409 | 409 | case '_gravityview_directory_widgets': |
| 410 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 410 | + $widgets = maybe_unserialize( $meta[ 'value' ] ); |
|
| 411 | 411 | break; |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | * @param mixed $field_id Field ID or Field array |
| 334 | 334 | * @return string field type |
| 335 | 335 | */ |
| 336 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
| 337 | - return GVCommon::get_field_type( $form, $field_id ); |
|
| 336 | +function gravityview_get_field_type( $form = null, $field_id = '' ) { |
|
| 337 | + return GVCommon::get_field_type( $form, $field_id ); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | * @return string HTML of the output. Empty string if $view_id is empty. |
| 348 | 348 | */ |
| 349 | 349 | function get_gravityview( $view_id = '', $atts = array() ) { |
| 350 | - if( !empty( $view_id ) ) { |
|
| 351 | - $atts['id'] = $view_id; |
|
| 350 | + if ( ! empty( $view_id ) ) { |
|
| 351 | + $atts[ 'id' ] = $view_id; |
|
| 352 | 352 | $args = wp_parse_args( $atts, \GV\View_Settings::defaults() ); |
| 353 | 353 | $GravityView_frontend = GravityView_frontend::getInstance(); |
| 354 | 354 | $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
@@ -391,19 +391,19 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
| 393 | 393 | |
| 394 | - if( class_exists('GFFormsModel') && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 394 | + if ( class_exists( 'GFFormsModel' ) && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 395 | 395 | |
| 396 | 396 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
| 397 | - foreach( $form_fields as $form_field ) { |
|
| 397 | + foreach ( $form_fields as $form_field ) { |
|
| 398 | 398 | $field_id = $form_field->id; |
| 399 | - foreach( $view_fields as $zone ) { |
|
| 399 | + foreach ( $view_fields as $zone ) { |
|
| 400 | 400 | |
| 401 | 401 | // ACF compatibility; ACF-added fields aren't arrays |
| 402 | 402 | if ( ! is_array( $zone ) ) { continue; } |
| 403 | 403 | |
| 404 | - foreach( $zone as $field ) { |
|
| 404 | + foreach ( $zone as $field ) { |
|
| 405 | 405 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
| 406 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
| 406 | + if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) { |
|
| 407 | 407 | return true; |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | // If there's an overriding CSS file in the current template folder, use it. |
| 33 | 33 | $template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file; |
| 34 | 34 | |
| 35 | - if( file_exists( $template_css_path ) ) { |
|
| 35 | + if ( file_exists( $template_css_path ) ) { |
|
| 36 | 36 | $path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file; |
| 37 | 37 | gravityview()->log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => esc_attr( $css_file ) ) ); |
| 38 | 38 | } else { |
| 39 | 39 | // Default: use GravityView CSS file |
| 40 | 40 | |
| 41 | 41 | // If no path is provided, assume default plugin templates CSS folder |
| 42 | - if( '' === $dir_path ) { |
|
| 42 | + if ( '' === $dir_path ) { |
|
| 43 | 43 | $dir_path = GRAVITYVIEW_DIR . 'templates/css/'; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | // plugins_url() expects a path to a file, not directory. We append a file to be stripped. |
| 47 | - $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
| 47 | + $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | return $path; |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $parsed_permalink = parse_url( get_permalink( $id ) ); |
| 84 | 84 | |
| 85 | - $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; |
|
| 85 | + $permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false; |
|
| 86 | 86 | |
| 87 | - if( empty( $permalink_args ) ) { |
|
| 87 | + if ( empty( $permalink_args ) ) { |
|
| 88 | 88 | return array(); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
| 110 | 110 | |
| 111 | 111 | $output = ''; |
| 112 | - if( is_array( $current ) ) { |
|
| 113 | - if( in_array( $value, $current ) ) { |
|
| 112 | + if ( is_array( $current ) ) { |
|
| 113 | + if ( in_array( $value, $current ) ) { |
|
| 114 | 114 | $output = __checked_selected_helper( true, true, false, $type ); |
| 115 | 115 | } |
| 116 | 116 | } else { |
| 117 | 117 | $output = __checked_selected_helper( $value, $current, false, $type ); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if( $echo ) { |
|
| 120 | + if ( $echo ) { |
|
| 121 | 121 | echo $output; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
| 128 | -if( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
| 128 | +if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that. |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | function gravityview_strip_whitespace( $string ) { |
| 173 | 173 | $string = normalize_whitespace( $string ); |
| 174 | - return preg_replace('/[\r\n\t ]+/', ' ', $string ); |
|
| 174 | + return preg_replace( '/[\r\n\t ]+/', ' ', $string ); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @return string Included file contents |
| 186 | 186 | */ |
| 187 | 187 | function gravityview_ob_include( $file_path, $object = NULL ) { |
| 188 | - if( ! file_exists( $file_path ) ) { |
|
| 188 | + if ( ! file_exists( $file_path ) ) { |
|
| 189 | 189 | gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); |
| 190 | 190 | return ''; |
| 191 | 191 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $width = $height * 0.7586206897; |
| 205 | 205 | |
| 206 | - if( function_exists('is_rtl') && is_rtl() ) { |
|
| 206 | + if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
| 207 | 207 | $style = 'margin:10px 10px 10px 0;'; |
| 208 | 208 | $class = 'alignright'; |
| 209 | 209 | } else { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $class = 'alignleft'; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - return '<img src="'.plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="'.$class.'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />'; |
|
| 214 | + return '<img src="' . plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) . '" class="' . $class . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />'; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | function gravityview_number_format( $number, $decimals = '' ) { |
| 235 | 235 | global $wp_locale; |
| 236 | 236 | |
| 237 | - if( '' === $decimals ) { |
|
| 237 | + if ( '' === $decimals ) { |
|
| 238 | 238 | |
| 239 | - $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; |
|
| 239 | + $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.'; |
|
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | 242 | * Calculate the position of the decimal point in the number |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $parts = parse_url( $value ); |
| 266 | 266 | |
| 267 | 267 | // No domain? Strange...show the original text. |
| 268 | - if( empty( $parts['host'] ) ) { |
|
| 268 | + if ( empty( $parts[ 'host' ] ) ) { |
|
| 269 | 269 | return $value; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -278,16 +278,16 @@ discard block |
||
| 278 | 278 | * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n |
| 279 | 279 | * If true: `http://example.com => example.com` |
| 280 | 280 | */ |
| 281 | - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { |
|
| 281 | + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { |
|
| 282 | 282 | |
| 283 | - if( isset( $parts['scheme'] ) ) { |
|
| 284 | - $return .= $parts['scheme']; |
|
| 283 | + if ( isset( $parts[ 'scheme' ] ) ) { |
|
| 284 | + $return .= $parts[ 'scheme' ]; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // The domain, which may contain a subdomain |
| 290 | - $domain = $parts['host']; |
|
| 290 | + $domain = $parts[ 'host' ]; |
|
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | 293 | * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n |
| 296 | 296 | * If true: `www.example.com => example.com` |
| 297 | 297 | */ |
| 298 | - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); |
|
| 298 | + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); |
|
| 299 | 299 | |
| 300 | - if( $strip_www ) { |
|
| 301 | - $domain = str_replace('www.', '', $domain ); |
|
| 300 | + if ( $strip_www ) { |
|
| 301 | + $domain = str_replace( 'www.', '', $domain ); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -308,11 +308,11 @@ discard block |
||
| 308 | 308 | * If true: `http://demo.example.com => example.com` \n |
| 309 | 309 | * If false: `http://demo.example.com => demo.example.com` |
| 310 | 310 | */ |
| 311 | - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); |
|
| 311 | + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); |
|
| 312 | 312 | |
| 313 | - if( $strip_subdomains ) { |
|
| 313 | + if ( $strip_subdomains ) { |
|
| 314 | 314 | |
| 315 | - $domain = _gravityview_strip_subdomain( $parts['host'] ); |
|
| 315 | + $domain = _gravityview_strip_subdomain( $parts[ 'host' ] ); |
|
| 316 | 316 | |
| 317 | 317 | } |
| 318 | 318 | |
@@ -326,12 +326,12 @@ discard block |
||
| 326 | 326 | * If true: `http://example.com/sub/directory/page.html => example.com` \n |
| 327 | 327 | * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` |
| 328 | 328 | */ |
| 329 | - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); |
|
| 329 | + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); |
|
| 330 | 330 | |
| 331 | - if( empty( $root_only ) ) { |
|
| 331 | + if ( empty( $root_only ) ) { |
|
| 332 | 332 | |
| 333 | - if( isset( $parts['path'] ) ) { |
|
| 334 | - $return .= $parts['path']; |
|
| 333 | + if ( isset( $parts[ 'path' ] ) ) { |
|
| 334 | + $return .= $parts[ 'path' ]; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n |
| 342 | 342 | * If true: `http://example.com/?query=example => example.com` |
| 343 | 343 | */ |
| 344 | - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); |
|
| 344 | + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); |
|
| 345 | 345 | |
| 346 | - if( empty( $strip_query_string ) ) { |
|
| 346 | + if ( empty( $strip_query_string ) ) { |
|
| 347 | 347 | |
| 348 | - if( isset( $parts['query'] ) ) { |
|
| 349 | - $return .= '?'.$parts['query']; |
|
| 348 | + if ( isset( $parts[ 'query' ] ) ) { |
|
| 349 | + $return .= '?' . $parts[ 'query' ]; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { |
| 365 | 365 | |
| 366 | - if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
| 367 | - return $matches['domain']; |
|
| 366 | + if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
| 367 | + return $matches[ 'domain' ]; |
|
| 368 | 368 | } else { |
| 369 | 369 | return $string_maybe_has_subdomain; |
| 370 | 370 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | if ( in_array( $value, array( 'yes', 'true' ), true ) ) { |
| 435 | 435 | $value = true; |
| 436 | - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
| 436 | + } else if ( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
| 437 | 437 | $value = false; |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -462,19 +462,19 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { |
| 464 | 464 | |
| 465 | - if( ! is_string( $value ) ) { |
|
| 465 | + if ( ! is_string( $value ) ) { |
|
| 466 | 466 | return $value; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | $decoded = json_decode( $value ); |
| 470 | 470 | |
| 471 | 471 | // There was a JSON error (PHP 5.3+) |
| 472 | - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { |
|
| 472 | + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
| 473 | 473 | return $value; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | // It wasn't JSON (PHP < 5.3 fallback) |
| 477 | - if( is_null( $decoded ) ) { |
|
| 477 | + if ( is_null( $decoded ) ) { |
|
| 478 | 478 | return $value; |
| 479 | 479 | } |
| 480 | 480 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | // Use the original function, if exists. |
| 499 | 499 | // Requires WP 4.4+ |
| 500 | - if( function_exists( 'map_deep') ) { |
|
| 500 | + if ( function_exists( 'map_deep' ) ) { |
|
| 501 | 501 | return map_deep( $value, $callback ); |
| 502 | 502 | } |
| 503 | 503 | |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | $exploded = explode( '.', "{$field_id}" ); |
| 564 | 564 | |
| 565 | - return isset( $exploded[1] ) ? intval( $exploded[1] ) : false; |
|
| 565 | + return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false; |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -603,13 +603,13 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | $args = apply_filters( 'gravityview_get_terms_choices_args', $args ); |
| 605 | 605 | |
| 606 | - $terms = get_terms( $args['taxonomy'], $args ); |
|
| 606 | + $terms = get_terms( $args[ 'taxonomy' ], $args ); |
|
| 607 | 607 | |
| 608 | 608 | $choices = array(); |
| 609 | 609 | |
| 610 | 610 | if ( is_array( $terms ) ) { |
| 611 | 611 | foreach ( $terms as $term_id => $term_name ) { |
| 612 | - $choices[] = array( |
|
| 612 | + $choices[ ] = array( |
|
| 613 | 613 | 'text' => $term_name, |
| 614 | 614 | 'value' => $term_id |
| 615 | 615 | ); |
@@ -633,21 +633,21 @@ discard block |
||
| 633 | 633 | function _gravityview_process_posted_fields() { |
| 634 | 634 | $fields = array(); |
| 635 | 635 | |
| 636 | - if( !empty( $_POST['gv_fields'] ) ) { |
|
| 637 | - if ( ! is_array( $_POST['gv_fields'] ) ) { |
|
| 636 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
| 637 | + if ( ! is_array( $_POST[ 'gv_fields' ] ) ) { |
|
| 638 | 638 | |
| 639 | 639 | // We are not using parse_str() due to max_input_vars limitation with large View configurations |
| 640 | 640 | $fields_holder = array(); |
| 641 | - GVCommon::gv_parse_str( $_POST['gv_fields'], $fields_holder ); |
|
| 641 | + GVCommon::gv_parse_str( $_POST[ 'gv_fields' ], $fields_holder ); |
|
| 642 | 642 | |
| 643 | - if ( isset( $fields_holder['fields'] ) ) { |
|
| 644 | - $fields = $fields_holder['fields']; |
|
| 643 | + if ( isset( $fields_holder[ 'fields' ] ) ) { |
|
| 644 | + $fields = $fields_holder[ 'fields' ]; |
|
| 645 | 645 | } else { |
| 646 | 646 | gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | } else { |
| 650 | - $fields = $_POST['gv_fields']; |
|
| 650 | + $fields = $_POST[ 'gv_fields' ]; |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $disapproved_result = $wpdb->query( $wpdb->prepare( $sql, GravityView_Entry_Approval_Status::DISAPPROVED, '0' ) ); |
| 74 | 74 | |
| 75 | - if( false === $approved_result || false === $disapproved_result ) { |
|
| 75 | + if ( false === $approved_result || false === $disapproved_result ) { |
|
| 76 | 76 | gravityview()->log->error( 'There was an error processing the query. {error}', array( 'error' => $wpdb->last_error ) ); |
| 77 | 77 | } else { |
| 78 | 78 | // All done: Meta values are migrated |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $redux_settings = $this->get_redux_settings(); |
| 106 | 106 | |
| 107 | 107 | // No need to process |
| 108 | - if( false === $redux_settings ) { |
|
| 108 | + if ( false === $redux_settings ) { |
|
| 109 | 109 | return; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if( empty( $redux_settings['license_key_status'] ) ) { |
|
| 112 | + if ( empty( $redux_settings[ 'license_key_status' ] ) ) { |
|
| 113 | 113 | $redux_settings = $this->get_redux_license_status( $redux_settings ); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | gravityview()->settings->update( $updated_settings ); |
| 124 | 124 | |
| 125 | 125 | // And now remove the previous option, so this is a one-time thing. |
| 126 | - delete_option('gravityview_settings'); |
|
| 127 | - delete_option('gravityview_settings-transients'); |
|
| 126 | + delete_option( 'gravityview_settings' ); |
|
| 127 | + delete_option( 'gravityview_settings-transients' ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | $license_call = \GV\License_Handler::get()->license_call( $data ); |
| 149 | 149 | |
| 150 | - if( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
| 151 | - $redux_settings['license_key_status'] = $license_call->license; |
|
| 152 | - $redux_settings['license_key_response'] = json_encode( $license_call ); |
|
| 150 | + if ( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
| 151 | + $redux_settings[ 'license_key_status' ] = $license_call->license; |
|
| 152 | + $redux_settings[ 'license_key_response' ] = json_encode( $license_call ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return $redux_settings; |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | function get_redux_settings() { |
| 164 | 164 | |
| 165 | 165 | // Previous settings set by Redux |
| 166 | - $redux_option = get_option('gravityview_settings'); |
|
| 166 | + $redux_option = get_option( 'gravityview_settings' ); |
|
| 167 | 167 | |
| 168 | 168 | // No Redux settings? Don't proceed. |
| 169 | - if( false === $redux_option ) { |
|
| 169 | + if ( false === $redux_option ) { |
|
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | if ( $license_array = \GV\Utils::get( $redux_option, 'license' ) ) { |
| 180 | 180 | |
| 181 | - $redux_settings['license_key'] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
| 181 | + $redux_settings[ 'license_key' ] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
| 182 | 182 | |
| 183 | - $redux_last_changed_values = get_option('gravityview_settings-transients'); |
|
| 183 | + $redux_last_changed_values = get_option( 'gravityview_settings-transients' ); |
|
| 184 | 184 | |
| 185 | 185 | // This contains the last response for license validation |
| 186 | - if( !empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
| 186 | + if ( ! empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
| 187 | 187 | |
| 188 | 188 | $saved_license = \GV\Utils::get( $saved_values, 'license' ); |
| 189 | 189 | |
| 190 | 190 | // Only use the last-saved values if they are for the same license |
| 191 | - if( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
| 192 | - $redux_settings['license_key_status'] = \GV\Utils::get( $saved_license, 'status' ); |
|
| 193 | - $redux_settings['license_key_response'] = \GV\Utils::get( $saved_license, 'response' ); |
|
| 191 | + if ( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
| 192 | + $redux_settings[ 'license_key_status' ] = \GV\Utils::get( $saved_license, 'status' ); |
|
| 193 | + $redux_settings[ 'license_key_response' ] = \GV\Utils::get( $saved_license, 'response' ); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | /** ---- Migrate from old search widget to new search widget ---- */ |
| 203 | 203 | function update_search_on_views() { |
| 204 | 204 | |
| 205 | - if( !class_exists('GravityView_Widget_Search') ) { |
|
| 206 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' ); |
|
| 205 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
| 206 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/search-widget/class-search-widget.php' ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Loop through all the views |
@@ -215,20 +215,20 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $views = get_posts( $query_args ); |
| 217 | 217 | |
| 218 | - foreach( $views as $view ) { |
|
| 218 | + foreach ( $views as $view ) { |
|
| 219 | 219 | |
| 220 | 220 | $widgets = gravityview_get_directory_widgets( $view->ID ); |
| 221 | 221 | $search_fields = null; |
| 222 | 222 | |
| 223 | - if( empty( $widgets ) || !is_array( $widgets ) ) { continue; } |
|
| 223 | + if ( empty( $widgets ) || ! is_array( $widgets ) ) { continue; } |
|
| 224 | 224 | |
| 225 | 225 | gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Loading View ID: {view_id}', array( 'view_id' => $view->ID ) ); |
| 226 | 226 | |
| 227 | - foreach( $widgets as $area => $ws ) { |
|
| 228 | - foreach( $ws as $k => $widget ) { |
|
| 229 | - if( $widget['id'] !== 'search_bar' ) { continue; } |
|
| 227 | + foreach ( $widgets as $area => $ws ) { |
|
| 228 | + foreach ( $ws as $k => $widget ) { |
|
| 229 | + if ( $widget[ 'id' ] !== 'search_bar' ) { continue; } |
|
| 230 | 230 | |
| 231 | - if( is_null( $search_fields ) ) { |
|
| 231 | + if ( is_null( $search_fields ) ) { |
|
| 232 | 232 | $search_fields = $this->get_search_fields( $view->ID ); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -236,24 +236,24 @@ discard block |
||
| 236 | 236 | // [search_free] => 1 |
| 237 | 237 | // [search_date] => 1 |
| 238 | 238 | $search_generic = array(); |
| 239 | - if( !empty( $widget['search_free'] ) ) { |
|
| 240 | - $search_generic[] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
| 239 | + if ( ! empty( $widget[ 'search_free' ] ) ) { |
|
| 240 | + $search_generic[ ] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
| 241 | 241 | } |
| 242 | - if( !empty( $widget['search_date'] ) ) { |
|
| 243 | - $search_generic[] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
| 242 | + if ( ! empty( $widget[ 'search_date' ] ) ) { |
|
| 243 | + $search_generic[ ] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $search_config = array_merge( $search_generic, $search_fields ); |
| 247 | 247 | |
| 248 | 248 | // don't throw '[]' when json_encode an empty array |
| 249 | - if( empty( $search_config ) ) { |
|
| 249 | + if ( empty( $search_config ) ) { |
|
| 250 | 250 | $search_config = ''; |
| 251 | 251 | } else { |
| 252 | 252 | $search_config = json_encode( $search_config ); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $widgets[ $area ][ $k ]['search_fields'] = $search_config; |
|
| 256 | - $widgets[ $area ][ $k ]['search_layout'] = 'horizontal'; |
|
| 255 | + $widgets[ $area ][ $k ][ 'search_fields' ] = $search_config; |
|
| 256 | + $widgets[ $area ][ $k ][ 'search_layout' ] = 'horizontal'; |
|
| 257 | 257 | |
| 258 | 258 | gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Updated Widget: ', array( 'data' => $widgets[ $area ][ $k ] ) ); |
| 259 | 259 | } |
@@ -281,26 +281,26 @@ discard block |
||
| 281 | 281 | // check view fields' settings |
| 282 | 282 | $fields = gravityview_get_directory_fields( $view_id, false ); |
| 283 | 283 | |
| 284 | - if( !empty( $fields ) && is_array( $fields ) ) { |
|
| 284 | + if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
| 285 | 285 | |
| 286 | - foreach( $fields as $t => $fs ) { |
|
| 286 | + foreach ( $fields as $t => $fs ) { |
|
| 287 | 287 | |
| 288 | - foreach( $fs as $k => $field ) { |
|
| 288 | + foreach ( $fs as $k => $field ) { |
|
| 289 | 289 | // is field a search_filter ? |
| 290 | - if( empty( $field['search_filter'] ) ) { continue; } |
|
| 290 | + if ( empty( $field[ 'search_filter' ] ) ) { continue; } |
|
| 291 | 291 | |
| 292 | 292 | // get field type & calculate the input type (by default) |
| 293 | - $form_field = gravityview_get_field( $form, $field['id'] ); |
|
| 293 | + $form_field = gravityview_get_field( $form, $field[ 'id' ] ); |
|
| 294 | 294 | |
| 295 | - if( empty( $form_field['type'] ) ) { |
|
| 295 | + if ( empty( $form_field[ 'type' ] ) ) { |
|
| 296 | 296 | continue; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | // depending on the field type assign a group of possible search field types |
| 300 | - $type = GravityView_Widget_Search::get_search_input_types( $field['id'], $form_field['type'] ); |
|
| 300 | + $type = GravityView_Widget_Search::get_search_input_types( $field[ 'id' ], $form_field[ 'type' ] ); |
|
| 301 | 301 | |
| 302 | 302 | // add field to config |
| 303 | - $search_fields[] = array( 'field' => $field['id'], 'input' => $type ); |
|
| 303 | + $search_fields[ ] = array( 'field' => $field[ 'id' ], 'input' => $type ); |
|
| 304 | 304 | |
| 305 | 305 | } |
| 306 | 306 | } |