@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 20 | 20 | |
| 21 | - if( 'edit' === $context ) { |
|
| 21 | + if ( 'edit' === $context ) { |
|
| 22 | 22 | return $field_options; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'quiz_show_explanation' => array( |
| 27 | 27 | 'type' => 'checkbox', |
| 28 | 28 | 'label' => __( 'Show Answer Explanation?', 'gravityview' ), |
| 29 | - 'desc' => __('If the field has an answer explanation, show it?', 'gravityview'), |
|
| 29 | + 'desc' => __( 'If the field has an answer explanation, show it?', 'gravityview' ), |
|
| 30 | 30 | 'value' => false, |
| 31 | 31 | 'merge_tags' => false, |
| 32 | 32 | ), |
@@ -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,30 +53,30 @@ 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 | - do_action('gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class($this)), $instance ); |
|
| 58 | + do_action( 'gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class( $this ) ), $instance ); |
|
| 59 | 59 | |
| 60 | 60 | return; |
| 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( $new_instance['post_id'], $instance['view_id'] ); |
|
| 119 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $new_instance[ 'post_id' ], $instance[ 'view_id' ] ); |
|
| 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_Post_Types::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('http://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( 'http://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> |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param mixed $field_id Field ID or Field array |
| 290 | 290 | * @return string field type |
| 291 | 291 | */ |
| 292 | -function gravityview_get_field_type( $form = null , $field_id = '' ) { |
|
| 293 | - return GVCommon::get_field_type( $form, $field_id ); |
|
| 292 | +function gravityview_get_field_type( $form = null, $field_id = '' ) { |
|
| 293 | + return GVCommon::get_field_type( $form, $field_id ); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -303,8 +303,8 @@ discard block |
||
| 303 | 303 | * @return string HTML of the output. Empty string if $view_id is empty. |
| 304 | 304 | */ |
| 305 | 305 | function get_gravityview( $view_id = '', $atts = array() ) { |
| 306 | - if( !empty( $view_id ) ) { |
|
| 307 | - $atts['id'] = $view_id; |
|
| 306 | + if ( ! empty( $view_id ) ) { |
|
| 307 | + $atts[ 'id' ] = $view_id; |
|
| 308 | 308 | $args = wp_parse_args( $atts, GravityView_View_Data::get_default_args() ); |
| 309 | 309 | $GravityView_frontend = GravityView_frontend::getInstance(); |
| 310 | 310 | $GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) ); |
@@ -347,19 +347,19 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) { |
| 349 | 349 | |
| 350 | - if( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 350 | + if ( $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) { |
|
| 351 | 351 | |
| 352 | 352 | /** @var GF_Field_Radio|GF_Field_Checkbox $form_field */ |
| 353 | - foreach( $form_fields as $form_field ) { |
|
| 353 | + foreach ( $form_fields as $form_field ) { |
|
| 354 | 354 | $field_id = $form_field->id; |
| 355 | - foreach( $view_fields as $zone ) { |
|
| 355 | + foreach ( $view_fields as $zone ) { |
|
| 356 | 356 | |
| 357 | 357 | // ACF compatibility; ACF-added fields aren't arrays |
| 358 | 358 | if ( ! is_array( $zone ) ) { continue; } |
| 359 | 359 | |
| 360 | - foreach( $zone as $field ) { |
|
| 360 | + foreach ( $zone as $field ) { |
|
| 361 | 361 | // If it's an input, not the parent and the parent ID matches a checkbox or radio |
| 362 | - if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) { |
|
| 362 | + if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) { |
|
| 363 | 363 | return true; |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @see GVCommon::get_form_fields() |
| 58 | 58 | * @access public |
| 59 | - * @param string|array $form_id (default: '') or $form object |
|
| 59 | + * @param string|array $form (default: '') or $form object |
|
| 60 | 60 | * @return array |
| 61 | 61 | */ |
| 62 | 62 | function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
@@ -94,6 +94,7 @@ discard block |
||
| 94 | 94 | * @param int|array $form_ids The ID of the form or an array IDs of the Forms. Zero for all forms. |
| 95 | 95 | * @param mixed $passed_criteria (default: null) |
| 96 | 96 | * @param mixed &$total (default: null) |
| 97 | + * @param integer $total |
|
| 97 | 98 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
| 98 | 99 | */ |
| 99 | 100 | function gravityview_get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
@@ -106,7 +107,6 @@ discard block |
||
| 106 | 107 | * Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching `gravityview_unique_id` meta. The `$entry_slug` is fetched by getting the current query var set by `is_single_entry()` |
| 107 | 108 | * |
| 108 | 109 | * @access public |
| 109 | - * @param mixed $entry_id |
|
| 110 | 110 | * @param boolean $force_allow_ids Force the get_entry() method to allow passed entry IDs, even if the `gravityview_custom_entry_slug_allow_id` filter returns false. |
| 111 | 111 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true {@since 1.14} |
| 112 | 112 | * @return array|boolean |
@@ -193,7 +193,6 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @see GravityView_Template::template_id |
| 195 | 195 | * |
| 196 | - * @param int $view_id The ID of the View to get the layout of |
|
| 197 | 196 | * |
| 198 | 197 | * @return string GravityView_Template::template_id value. Empty string if not. |
| 199 | 198 | */ |
@@ -41,9 +41,9 @@ |
||
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | 43 | private function fix_posted_fields() { |
| 44 | - if( is_admin() && isset( $_POST['action'] ) && isset( $_POST['post_type'] ) ) { |
|
| 45 | - if( 'editpost' === $_POST['action'] && 'gravityview' === $_POST['post_type'] ) { |
|
| 46 | - $_POST['fields'] = _gravityview_process_posted_fields(); |
|
| 44 | + if ( is_admin() && isset( $_POST[ 'action' ] ) && isset( $_POST[ 'post_type' ] ) ) { |
|
| 45 | + if ( 'editpost' === $_POST[ 'action' ] && 'gravityview' === $_POST[ 'post_type' ] ) { |
|
| 46 | + $_POST[ 'fields' ] = _gravityview_process_posted_fields(); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -40,11 +40,11 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $field_options['link_phone'] = array( |
| 43 | - 'type' => 'checkbox', |
|
| 44 | - 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
| 45 | - 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
| 46 | - 'value' => true, |
|
| 47 | - ); |
|
| 43 | + 'type' => 'checkbox', |
|
| 44 | + 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
| 45 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
| 46 | + 'value' => true, |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | 49 | return $field_options; |
| 50 | 50 | } |
@@ -35,14 +35,14 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 37 | 37 | |
| 38 | - if( 'edit' === $context ) { |
|
| 38 | + if ( 'edit' === $context ) { |
|
| 39 | 39 | return $field_options; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $field_options['link_phone'] = array( |
|
| 42 | + $field_options[ 'link_phone' ] = array( |
|
| 43 | 43 | 'type' => 'checkbox', |
| 44 | 44 | 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
| 45 | - 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
| 45 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview' ), |
|
| 46 | 46 | 'value' => true, |
| 47 | 47 | ); |
| 48 | 48 | |
@@ -220,6 +220,9 @@ |
||
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | + /** |
|
| 224 | + * @param string $key |
|
| 225 | + */ |
|
| 223 | 226 | public function getCurrentFieldSetting( $key ) { |
| 224 | 227 | $settings = $this->getCurrentField('field_settings'); |
| 225 | 228 | |
@@ -329,34 +329,34 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | - * Get the fields for a specific context |
|
| 333 | - * |
|
| 334 | - * @since 1.19.2 |
|
| 335 | - * |
|
| 332 | + * Get the fields for a specific context |
|
| 333 | + * |
|
| 334 | + * @since 1.19.2 |
|
| 335 | + * |
|
| 336 | 336 | * @param string $context [Optional] "directory", "single", or "edit" |
| 337 | 337 | * |
| 338 | 338 | * @return array Array of GravityView field layout configurations |
| 339 | 339 | */ |
| 340 | 340 | public function getContextFields( $context = '' ) { |
| 341 | 341 | |
| 342 | - if( '' === $context ) { |
|
| 343 | - $context = $this->getContext(); |
|
| 344 | - } |
|
| 342 | + if( '' === $context ) { |
|
| 343 | + $context = $this->getContext(); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | $fields = $this->getFields(); |
| 347 | 347 | |
| 348 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 348 | + foreach ( (array) $fields as $key => $context_fields ) { |
|
| 349 | 349 | |
| 350 | - // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 351 | - $matches = explode( '_', $key ); |
|
| 350 | + // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
|
| 351 | + $matches = explode( '_', $key ); |
|
| 352 | 352 | |
| 353 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 354 | - return $context_fields; |
|
| 355 | - } |
|
| 356 | - } |
|
| 353 | + if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 354 | + return $context_fields; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | return array(); |
| 359 | - } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * @param array $fields |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | public function getPaging() { |
| 451 | 451 | |
| 452 | - $default_params = array( |
|
| 453 | - 'offset' => 0, |
|
| 454 | - 'page_size' => 20, |
|
| 455 | - ); |
|
| 452 | + $default_params = array( |
|
| 453 | + 'offset' => 0, |
|
| 454 | + 'page_size' => 20, |
|
| 455 | + ); |
|
| 456 | 456 | |
| 457 | 457 | return wp_parse_args( $this->paging, $default_params ); |
| 458 | 458 | } |
@@ -509,10 +509,10 @@ discard block |
||
| 509 | 509 | public function getSorting() { |
| 510 | 510 | |
| 511 | 511 | $defaults_params = array( |
| 512 | - 'sort_field' => 'date_created', |
|
| 513 | - 'sort_direction' => 'ASC', |
|
| 514 | - 'is_numeric' => false, |
|
| 515 | - ); |
|
| 512 | + 'sort_field' => 'date_created', |
|
| 513 | + 'sort_direction' => 'ASC', |
|
| 514 | + 'is_numeric' => false, |
|
| 515 | + ); |
|
| 516 | 516 | |
| 517 | 517 | return wp_parse_args( $this->sorting, $defaults_params ); |
| 518 | 518 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 19 | +if ( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
| 20 | 20 | require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | 'atts' => NULL, |
| 158 | 158 | ) ); |
| 159 | 159 | |
| 160 | - foreach ($atts as $key => $value) { |
|
| 161 | - if( is_null( $value ) ) { |
|
| 160 | + foreach ( $atts as $key => $value ) { |
|
| 161 | + if ( is_null( $value ) ) { |
|
| 162 | 162 | continue; |
| 163 | 163 | } |
| 164 | 164 | $this->{$key} = $value; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | static function getInstance( $passed_post = NULL ) { |
| 191 | 191 | |
| 192 | - if( empty( self::$instance ) ) { |
|
| 192 | + if ( empty( self::$instance ) ) { |
|
| 193 | 193 | self::$instance = new self( $passed_post ); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | public function getCurrentField( $key = NULL ) { |
| 204 | 204 | |
| 205 | - if( !empty( $key ) ) { |
|
| 206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 205 | + if ( ! empty( $key ) ) { |
|
| 206 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
| 207 | 207 | return $this->_current_field[ $key ]; |
| 208 | 208 | } |
| 209 | 209 | return NULL; |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | |
| 215 | 215 | public function setCurrentFieldSetting( $key, $value ) { |
| 216 | 216 | |
| 217 | - if( !empty( $this->_current_field ) ) { |
|
| 218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 217 | + if ( ! empty( $this->_current_field ) ) { |
|
| 218 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | public function getCurrentFieldSetting( $key ) { |
| 224 | - $settings = $this->getCurrentField('field_settings'); |
|
| 224 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
| 225 | 225 | |
| 226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 226 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
| 227 | 227 | return $settings[ $key ]; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -254,8 +254,8 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | public function getAtts( $key = NULL ) { |
| 256 | 256 | |
| 257 | - if( !empty( $key ) ) { |
|
| 258 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 257 | + if ( ! empty( $key ) ) { |
|
| 258 | + if ( isset( $this->atts[ $key ] ) ) { |
|
| 259 | 259 | return $this->atts[ $key ]; |
| 260 | 260 | } |
| 261 | 261 | return NULL; |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | |
| 322 | 322 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
| 323 | 323 | |
| 324 | - if( $fields && !empty( $key ) ) { |
|
| 324 | + if ( $fields && ! empty( $key ) ) { |
|
| 325 | 325 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
| 326 | 326 | } |
| 327 | 327 | |
@@ -339,18 +339,18 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | public function getContextFields( $context = '' ) { |
| 341 | 341 | |
| 342 | - if( '' === $context ) { |
|
| 342 | + if ( '' === $context ) { |
|
| 343 | 343 | $context = $this->getContext(); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $fields = $this->getFields(); |
| 347 | 347 | |
| 348 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 348 | + foreach ( (array)$fields as $key => $context_fields ) { |
|
| 349 | 349 | |
| 350 | 350 | // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
| 351 | 351 | $matches = explode( '_', $key ); |
| 352 | 352 | |
| 353 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 353 | + if ( isset( $matches[ 0 ] ) && $matches[ 0 ] === $context ) { |
|
| 354 | 354 | return $context_fields; |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | public function getField( $key ) { |
| 373 | 373 | |
| 374 | - if( !empty( $key ) ) { |
|
| 375 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 374 | + if ( ! empty( $key ) ) { |
|
| 375 | + if ( isset( $this->fields[ $key ] ) ) { |
|
| 376 | 376 | return $this->fields[ $key ]; |
| 377 | 377 | } |
| 378 | 378 | } |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | public function getPaginationCounts() { |
| 479 | 479 | |
| 480 | 480 | $paging = $this->getPaging(); |
| 481 | - $offset = $paging['offset']; |
|
| 482 | - $page_size = $paging['page_size']; |
|
| 481 | + $offset = $paging[ 'offset' ]; |
|
| 482 | + $page_size = $paging[ 'page_size' ]; |
|
| 483 | 483 | $total = $this->getTotalEntries(); |
| 484 | 484 | |
| 485 | 485 | if ( empty( $total ) ) { |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | */ |
| 501 | 501 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
| 502 | 502 | |
| 503 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 503 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -591,16 +591,16 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function getCurrentEntry() { |
| 593 | 593 | |
| 594 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 594 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
| 595 | 595 | $entries = $this->getEntries(); |
| 596 | - $entry = $entries[0]; |
|
| 596 | + $entry = $entries[ 0 ]; |
|
| 597 | 597 | } else { |
| 598 | 598 | $entry = $this->_current_entry; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 602 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 603 | - $entry = $this->_current_field['entry']; |
|
| 602 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
| 603 | + $entry = $this->_current_field[ 'entry' ]; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | return $entry; |
@@ -637,8 +637,8 @@ discard block |
||
| 637 | 637 | */ |
| 638 | 638 | public function renderZone( $zone = '', $atts = array(), $echo = true ) { |
| 639 | 639 | |
| 640 | - if( empty( $zone ) ) { |
|
| 641 | - do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
|
| 640 | + if ( empty( $zone ) ) { |
|
| 641 | + do_action( 'gravityview_log_error', 'GravityView_View[renderZone] No zone defined.' ); |
|
| 642 | 642 | return NULL; |
| 643 | 643 | } |
| 644 | 644 | |
@@ -647,37 +647,37 @@ discard block |
||
| 647 | 647 | 'context' => $this->getContext(), |
| 648 | 648 | 'entry' => $this->getCurrentEntry(), |
| 649 | 649 | 'form' => $this->getForm(), |
| 650 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
| 650 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
| 651 | 651 | ); |
| 652 | 652 | |
| 653 | 653 | $final_atts = wp_parse_args( $atts, $defaults ); |
| 654 | 654 | |
| 655 | 655 | $output = ''; |
| 656 | 656 | |
| 657 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
| 657 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
| 658 | 658 | |
| 659 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 659 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
| 660 | 660 | |
| 661 | 661 | // Backward compatibility |
| 662 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
| 662 | + if ( 'table' === $this->getTemplatePartSlug() ) { |
|
| 663 | 663 | /** |
| 664 | 664 | * @filter `gravityview_table_cells` Modify the fields displayed in a table |
| 665 | 665 | * @param array $fields |
| 666 | 666 | * @param GravityView_View $this |
| 667 | 667 | */ |
| 668 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 668 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - if( empty( $fields ) ) { |
|
| 671 | + if ( empty( $fields ) ) { |
|
| 672 | 672 | |
| 673 | - do_action('gravityview_log_error', 'GravityView_View[renderZone] Empty View configuration for this context.', $fields ); |
|
| 673 | + do_action( 'gravityview_log_error', 'GravityView_View[renderZone] Empty View configuration for this context.', $fields ); |
|
| 674 | 674 | |
| 675 | 675 | return NULL; |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | $field_output = ''; |
| 679 | 679 | foreach ( $fields as $field ) { |
| 680 | - $final_atts['field'] = $field; |
|
| 680 | + $final_atts[ 'field' ] = $field; |
|
| 681 | 681 | |
| 682 | 682 | $field_output .= gravityview_field_output( $final_atts ); |
| 683 | 683 | } |
@@ -688,21 +688,21 @@ discard block |
||
| 688 | 688 | * @since 1.7.6 |
| 689 | 689 | * @param boolean $hide_empty_zone Default: false |
| 690 | 690 | */ |
| 691 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 691 | + if ( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
| 692 | 692 | return NULL; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 696 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 695 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 696 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | $output .= $field_output; |
| 700 | 700 | |
| 701 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 701 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 702 | 702 | $output .= '</div>'; |
| 703 | 703 | } |
| 704 | 704 | |
| 705 | - if( $echo ) { |
|
| 705 | + if ( $echo ) { |
|
| 706 | 706 | echo $output; |
| 707 | 707 | } |
| 708 | 708 | |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | */ |
| 721 | 721 | function locate_template( $template_names, $load = false, $require_once = true ) { |
| 722 | 722 | |
| 723 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 723 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 724 | 724 | |
| 725 | 725 | $located = $this->located_templates[ $template_names ]; |
| 726 | 726 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | // Set $load to always false so we handle it here. |
| 730 | 730 | $located = parent::locate_template( $template_names, false, $require_once ); |
| 731 | 731 | |
| 732 | - if( is_string( $template_names ) ) { |
|
| 732 | + if ( is_string( $template_names ) ) { |
|
| 733 | 733 | $this->located_templates[ $template_names ] = $located; |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | * @return mixed|null The stored data. |
| 748 | 748 | */ |
| 749 | 749 | public function __get( $name ) { |
| 750 | - if( isset( $this->{$name} ) ) { |
|
| 750 | + if ( isset( $this->{$name} ) ) { |
|
| 751 | 751 | return $this->{$name}; |
| 752 | 752 | } else { |
| 753 | 753 | return NULL; |
@@ -776,15 +776,15 @@ discard block |
||
| 776 | 776 | $additional = array(); |
| 777 | 777 | |
| 778 | 778 | // form-19-table-body.php |
| 779 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 779 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 780 | 780 | |
| 781 | 781 | // view-3-table-body.php |
| 782 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 782 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
| 783 | 783 | |
| 784 | - if( $this->getPostId() ) { |
|
| 784 | + if ( $this->getPostId() ) { |
|
| 785 | 785 | |
| 786 | 786 | // page-19-table-body.php |
| 787 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 787 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | // Combine with existing table-body.php and table.php |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | |
| 807 | 807 | do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
| 808 | 808 | |
| 809 | - if( !empty( $template_file) ) { |
|
| 809 | + if ( ! empty( $template_file ) ) { |
|
| 810 | 810 | |
| 811 | 811 | if ( $require_once ) { |
| 812 | 812 | require_once( $template_file ); |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | */ |
| 824 | 824 | public function render_widget_hooks( $view_id ) { |
| 825 | 825 | |
| 826 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 826 | + if ( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
| 827 | 827 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
| 828 | 828 | return; |
| 829 | 829 | } |
@@ -831,9 +831,9 @@ discard block |
||
| 831 | 831 | $view_data = gravityview_get_current_view_data( $view_id ); |
| 832 | 832 | |
| 833 | 833 | // get View widget configuration |
| 834 | - $widgets = (array)$view_data['widgets']; |
|
| 834 | + $widgets = (array)$view_data[ 'widgets' ]; |
|
| 835 | 835 | |
| 836 | - switch( current_filter() ) { |
|
| 836 | + switch ( current_filter() ) { |
|
| 837 | 837 | default: |
| 838 | 838 | case 'gravityview_before': |
| 839 | 839 | $zone = 'header'; |
@@ -847,9 +847,9 @@ discard block |
||
| 847 | 847 | * Filter widgets not in the current zone |
| 848 | 848 | * @since 1.16 |
| 849 | 849 | */ |
| 850 | - foreach( $widgets as $key => $widget ) { |
|
| 850 | + foreach ( $widgets as $key => $widget ) { |
|
| 851 | 851 | // The widget isn't in the current zone |
| 852 | - if( false === strpos( $key, $zone ) ) { |
|
| 852 | + if ( false === strpos( $key, $zone ) ) { |
|
| 853 | 853 | unset( $widgets[ $key ] ); |
| 854 | 854 | } |
| 855 | 855 | } |
@@ -864,8 +864,8 @@ discard block |
||
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | // Prevent being called twice |
| 867 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
| 868 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
| 867 | + if ( did_action( $zone . '_' . $view_id . '_widgets' ) ) { |
|
| 868 | + do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets' ) ); |
|
| 869 | 869 | return; |
| 870 | 870 | } |
| 871 | 871 | |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | |
| 877 | 877 | $default_css_class = 'gv-grid gv-widgets-' . $zone; |
| 878 | 878 | |
| 879 | - if( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
| 879 | + if ( 0 === GravityView_View::getInstance()->getTotalEntries() ) { |
|
| 880 | 880 | $default_css_class .= ' gv-widgets-no-results'; |
| 881 | 881 | } |
| 882 | 882 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @param string $zone Current widget zone, either `header` or `footer` |
| 888 | 888 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
| 889 | 889 | */ |
| 890 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets ); |
|
| 890 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets ); |
|
| 891 | 891 | |
| 892 | 892 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 893 | 893 | |
@@ -895,17 +895,17 @@ discard block |
||
| 895 | 895 | ?> |
| 896 | 896 | <div class="<?php echo $css_class; ?>"> |
| 897 | 897 | <?php |
| 898 | - foreach( $rows as $row ) { |
|
| 899 | - foreach( $row as $col => $areas ) { |
|
| 900 | - $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
|
| 898 | + foreach ( $rows as $row ) { |
|
| 899 | + foreach ( $row as $col => $areas ) { |
|
| 900 | + $column = ( $col == '2-2' ) ? '1-2 gv-right' : $col . ' gv-left'; |
|
| 901 | 901 | ?> |
| 902 | 902 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
| 903 | 903 | <?php |
| 904 | - if( !empty( $areas ) ) { |
|
| 905 | - foreach( $areas as $area ) { |
|
| 906 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 907 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
| 908 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
| 904 | + if ( ! empty( $areas ) ) { |
|
| 905 | + foreach ( $areas as $area ) { |
|
| 906 | + if ( ! empty( $widgets[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
| 907 | + foreach ( $widgets[ $zone . '_' . $area[ 'areaid' ] ] as $widget ) { |
|
| 908 | + do_action( "gravityview_render_widget_{$widget[ 'id' ]}", $widget ); |
|
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | } |
@@ -921,8 +921,8 @@ discard block |
||
| 921 | 921 | * Prevent widgets from being called twice. |
| 922 | 922 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
| 923 | 923 | */ |
| 924 | - if( did_action( 'wp_head' ) ) { |
|
| 925 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
| 924 | + if ( did_action( 'wp_head' ) ) { |
|
| 925 | + do_action( $zone . '_' . $view_id . '_widgets' ); |
|
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | 928 | |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @param array $file_paths List of template paths ordered |
| 318 | 318 | * |
| 319 | - * @return array File paths with `./` and `./partials/` paths added |
|
| 319 | + * @return string[] File paths with `./` and `./partials/` paths added |
|
| 320 | 320 | */ |
| 321 | 321 | public function add_template_path( $file_paths ) { |
| 322 | 322 | |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * @param array $entry |
| 486 | 486 | * @param array $data Note details array |
| 487 | 487 | * |
| 488 | - * @return int|WP_Error |
|
| 488 | + * @return integer |
|
| 489 | 489 | */ |
| 490 | 490 | private function add_note( $entry, $data ) { |
| 491 | 491 | global $current_user, $wpdb; |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | * |
| 585 | 585 | * @since 1.17 |
| 586 | 586 | * |
| 587 | - * @param int|string $entry_slug Current entry unique ID |
|
| 587 | + * @param string $entry_slug Current entry unique ID |
|
| 588 | 588 | * |
| 589 | 589 | * @return string HTML output |
| 590 | 590 | */ |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
| 270 | 270 | * |
| 271 | - * @since 1.17 |
|
| 271 | + * @since 1.17 |
|
| 272 | 272 | * |
| 273 | 273 | * @see process_delete_notes |
| 274 | 274 | * |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | 'subject-label' => __( 'Subject', 'gravityview' ), |
| 422 | 422 | 'subject' => __( 'Email subject', 'gravityview' ), |
| 423 | 423 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
| 424 | - 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 424 | + 'email-footer' => __( 'This note was sent from {url}', 'gravityview' ), |
|
| 425 | 425 | 'also-email' => __( 'Also email this note to', 'gravityview' ), |
| 426 | 426 | 'error-add-note' => __( 'There was an error adding the note.', 'gravityview' ), |
| 427 | 427 | 'error-invalid' => __( 'The request was invalid. Refresh the page and try again.', 'gravityview' ), |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | 'gv-note-to-custom' => '', |
| 711 | 711 | 'gv-note-subject' => '', |
| 712 | 712 | 'gv-note-content' => '', |
| 713 | - 'current-url' => '', |
|
| 713 | + 'current-url' => '', |
|
| 714 | 714 | ); |
| 715 | 715 | |
| 716 | 716 | $current_user = wp_get_current_user(); |
@@ -762,9 +762,9 @@ discard block |
||
| 762 | 762 | $message .= $this->get_email_footer( $email_footer, $is_html, $email_data ); |
| 763 | 763 | |
| 764 | 764 | /** |
| 765 | - * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 765 | + * @filter `gravityview/field/notes/wpautop_email` Should the message content have paragraphs added automatically, if using HTML message format |
|
| 766 | 766 | * @since 1.18 |
| 767 | - * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 767 | + * @param bool $wpautop_email True: Apply wpautop() to the email message if using; False: Leave as entered (Default: true) |
|
| 768 | 768 | */ |
| 769 | 769 | $wpautop_email = apply_filters( 'gravityview/field/notes/wpautop_email', true ); |
| 770 | 770 | |
@@ -784,12 +784,12 @@ discard block |
||
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | /** |
| 787 | - * Get the footer for Entry Note emails |
|
| 788 | - * |
|
| 789 | - * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 790 | - * |
|
| 791 | - * @since 1.18 |
|
| 792 | - * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 787 | + * Get the footer for Entry Note emails |
|
| 788 | + * |
|
| 789 | + * `{url}` is replaced by the URL of the page where the note form was embedded |
|
| 790 | + * |
|
| 791 | + * @since 1.18 |
|
| 792 | + * @see GravityView_Field_Notes::strings The default value of $message_footer is set here, with the key 'email-footer' |
|
| 793 | 793 | * |
| 794 | 794 | * @param string $email_footer The message footer value |
| 795 | 795 | * @param bool $is_html True: Email is being sent as HTML; False: sent as text |
@@ -798,10 +798,10 @@ discard block |
||
| 798 | 798 | */ |
| 799 | 799 | private function get_email_footer( $email_footer = '', $is_html = true, $email_data = array() ) { |
| 800 | 800 | |
| 801 | - $output = ''; |
|
| 801 | + $output = ''; |
|
| 802 | 802 | |
| 803 | 803 | if( ! empty( $email_footer ) ) { |
| 804 | - $url = rgar( $email_data, 'current-url' ); |
|
| 804 | + $url = rgar( $email_data, 'current-url' ); |
|
| 805 | 805 | $url = html_entity_decode( $url ); |
| 806 | 806 | $url = site_url( $url ); |
| 807 | 807 | |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | add_shortcode( 'gv_note_add', array( 'GravityView_Field_Notes', 'get_add_note_part' ) ); |
| 65 | 65 | |
| 66 | - add_action( 'wp', array( $this, 'maybe_delete_notes'), 1000 ); |
|
| 67 | - add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
| 68 | - add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes') ); |
|
| 66 | + add_action( 'wp', array( $this, 'maybe_delete_notes' ), 1000 ); |
|
| 67 | + add_action( 'wp_ajax_nopriv_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
| 68 | + add_action( 'wp_ajax_gv_delete_notes', array( $this, 'maybe_delete_notes' ) ); |
|
| 69 | 69 | |
| 70 | - add_action( 'wp', array( $this, 'maybe_add_note'), 1000 ); |
|
| 71 | - add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note') ); |
|
| 72 | - add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note') ); |
|
| 70 | + add_action( 'wp', array( $this, 'maybe_add_note' ), 1000 ); |
|
| 71 | + add_action( 'wp_ajax_nopriv_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
| 72 | + add_action( 'wp_ajax_gv_note_add', array( $this, 'maybe_add_note' ) ); |
|
| 73 | 73 | |
| 74 | 74 | // add template path to check for field |
| 75 | 75 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
| 76 | 76 | |
| 77 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 77 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 78 | 78 | add_action( 'gravityview/field/notes/scripts', array( $this, 'enqueue_scripts' ) ); |
| 79 | 79 | |
| 80 | 80 | add_filter( 'gravityview_entry_default_fields', array( $this, 'add_entry_default_field' ), 10, 3 ); |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function add_entry_default_field( $entry_default_fields, $form, $zone ) { |
| 98 | 98 | |
| 99 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
| 100 | - $entry_default_fields['notes'] = array( |
|
| 99 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
| 100 | + $entry_default_fields[ 'notes' ] = array( |
|
| 101 | 101 | 'label' => __( 'Entry Notes', 'gravityview' ), |
| 102 | 102 | 'type' => 'notes', |
| 103 | 103 | 'desc' => __( 'Display, add, and delete notes for an entry.', 'gravityview' ), |
@@ -130,23 +130,23 @@ discard block |
||
| 130 | 130 | public function enqueue_scripts() { |
| 131 | 131 | global $wp_actions; |
| 132 | 132 | |
| 133 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
| 133 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
| 134 | 134 | wp_enqueue_style( 'gravityview-notes' ); |
| 135 | 135 | wp_enqueue_script( 'gravityview-notes' ); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
| 138 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
| 139 | 139 | |
| 140 | 140 | $strings = self::strings(); |
| 141 | 141 | |
| 142 | 142 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
| 143 | 143 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 144 | 144 | 'text' => array( |
| 145 | - 'processing' => $strings['processing'], |
|
| 146 | - 'delete_confirm' => $strings['delete-confirm'], |
|
| 147 | - 'note_added' => $strings['added-note'], |
|
| 148 | - 'error_invalid' => $strings['error-invalid'], |
|
| 149 | - 'error_empty_note' => $strings['error-empty-note'], |
|
| 145 | + 'processing' => $strings[ 'processing' ], |
|
| 146 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
| 147 | + 'note_added' => $strings[ 'added-note' ], |
|
| 148 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
| 149 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
| 150 | 150 | ), |
| 151 | 151 | ) ); |
| 152 | 152 | } |
@@ -163,22 +163,22 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function maybe_add_note() { |
| 165 | 165 | |
| 166 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 166 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 167 | 167 | do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
| 168 | 168 | return; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if( 'gv_note_add' === rgpost('action') ) { |
|
| 171 | + if ( 'gv_note_add' === rgpost( 'action' ) ) { |
|
| 172 | 172 | |
| 173 | 173 | $post = wp_unslash( $_POST ); |
| 174 | 174 | |
| 175 | - if( $this->doing_ajax ) { |
|
| 176 | - parse_str( $post['data'], $data ); |
|
| 175 | + if ( $this->doing_ajax ) { |
|
| 176 | + parse_str( $post[ 'data' ], $data ); |
|
| 177 | 177 | } else { |
| 178 | 178 | $data = $post; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $this->process_add_note( (array) $data ); |
|
| 181 | + $this->process_add_note( (array)$data ); |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
@@ -205,23 +205,23 @@ discard block |
||
| 205 | 205 | $error = false; |
| 206 | 206 | $success = false; |
| 207 | 207 | |
| 208 | - if( empty( $data['entry-slug'] ) ) { |
|
| 208 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
| 209 | 209 | |
| 210 | - $error = self::strings('error-invalid'); |
|
| 210 | + $error = self::strings( 'error-invalid' ); |
|
| 211 | 211 | do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' ); |
| 212 | 212 | |
| 213 | 213 | } else { |
| 214 | 214 | |
| 215 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
| 215 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
| 216 | 216 | |
| 217 | 217 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
| 218 | 218 | |
| 219 | - if( ! $has_cap ) { |
|
| 219 | + if ( ! $has_cap ) { |
|
| 220 | 220 | $error = self::strings( 'error-cap-add' ); |
| 221 | 221 | do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
| 222 | 222 | } elseif ( $valid ) { |
| 223 | 223 | |
| 224 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
| 224 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
| 225 | 225 | |
| 226 | 226 | $added = $this->add_note( $entry, $data ); |
| 227 | 227 | |
@@ -239,22 +239,22 @@ discard block |
||
| 239 | 239 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
| 240 | 240 | |
| 241 | 241 | if ( $note ) { |
| 242 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
| 243 | - do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') ); |
|
| 242 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
| 243 | + do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) ); |
|
| 244 | 244 | } else { |
| 245 | - $error = self::strings('error-add-note'); |
|
| 246 | - do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') ); |
|
| 245 | + $error = self::strings( 'error-add-note' ); |
|
| 246 | + do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) ); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } else { |
| 250 | - $error = self::strings('error-invalid'); |
|
| 250 | + $error = self::strings( 'error-invalid' ); |
|
| 251 | 251 | do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' ); |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - if( $this->doing_ajax ) { |
|
| 257 | - if( $success ) { |
|
| 256 | + if ( $this->doing_ajax ) { |
|
| 257 | + if ( $success ) { |
|
| 258 | 258 | wp_send_json_success( array( 'html' => $success ) ); |
| 259 | 259 | } else { |
| 260 | 260 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -280,11 +280,11 @@ discard block |
||
| 280 | 280 | return; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
| 283 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
| 284 | 284 | |
| 285 | 285 | $post = wp_unslash( $_POST ); |
| 286 | 286 | if ( $this->doing_ajax ) { |
| 287 | - parse_str( $post['data'], $data ); |
|
| 287 | + parse_str( $post[ 'data' ], $data ); |
|
| 288 | 288 | } else { |
| 289 | 289 | $data = $post; |
| 290 | 290 | } |
@@ -315,18 +315,18 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | function process_delete_notes( $data ) { |
| 317 | 317 | |
| 318 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
| 318 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
| 319 | 319 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
| 320 | 320 | $success = false; |
| 321 | 321 | |
| 322 | 322 | if ( $valid && $has_cap ) { |
| 323 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
| 323 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
| 324 | 324 | $success = true; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if( $this->doing_ajax ) { |
|
| 327 | + if ( $this->doing_ajax ) { |
|
| 328 | 328 | |
| 329 | - if( $success ) { |
|
| 329 | + if ( $success ) { |
|
| 330 | 330 | wp_send_json_success(); |
| 331 | 331 | } else { |
| 332 | 332 | if ( ! $valid ) { |
@@ -359,13 +359,13 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 361 | 361 | |
| 362 | - unset( $field_options['show_as_link'] ); |
|
| 362 | + unset( $field_options[ 'show_as_link' ] ); |
|
| 363 | 363 | |
| 364 | 364 | $notes_options = array( |
| 365 | 365 | 'notes' => array( |
| 366 | 366 | 'type' => 'checkboxes', |
| 367 | - 'label' => __('Note Settings', 'gravityview'), |
|
| 368 | - 'desc' => sprintf( _x('Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
| 367 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
| 368 | + 'desc' => sprintf( _x( 'Only users with specific capabilities will be able to view, add and delete notes. %sRead more%s.', '%s is opening and closing HTML link', 'gravityview' ), '<a href="https://docs.gravityview.co/article/311-gravityview-capabilities">', '</a>' ), |
|
| 369 | 369 | 'options' => array( |
| 370 | 370 | 'view' => array( |
| 371 | 371 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | 'processing' => __( 'Processing…', 'gravityview' ), |
| 418 | 418 | 'other-email' => __( 'Other email address', 'gravityview' ), |
| 419 | 419 | 'email-label' => __( 'Email address', 'gravityview' ), |
| 420 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
| 420 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
| 421 | 421 | 'subject-label' => __( 'Subject', 'gravityview' ), |
| 422 | 422 | 'subject' => __( 'Email subject', 'gravityview' ), |
| 423 | 423 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
| 439 | 439 | |
| 440 | - if( $key ) { |
|
| 440 | + if ( $key ) { |
|
| 441 | 441 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | static public function display_note( $note, $show_delete = false ) { |
| 458 | 458 | |
| 459 | - if( ! is_object( $note ) ) { |
|
| 459 | + if ( ! is_object( $note ) ) { |
|
| 460 | 460 | return ''; |
| 461 | 461 | } |
| 462 | 462 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | $note_row = ob_get_clean(); |
| 498 | 498 | |
| 499 | 499 | $replacements = array( |
| 500 | - '{note_id}' => $note_content['note_id'], |
|
| 500 | + '{note_id}' => $note_content[ 'note_id' ], |
|
| 501 | 501 | '{row_class}' => 'gv-note', |
| 502 | 502 | '{note_detail}' => $note_detail_html |
| 503 | 503 | ); |
@@ -529,13 +529,13 @@ discard block |
||
| 529 | 529 | |
| 530 | 530 | $user_data = get_userdata( $current_user->ID ); |
| 531 | 531 | |
| 532 | - $note_content = trim( $data['gv-note-content'] ); |
|
| 532 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
| 533 | 533 | |
| 534 | - if( empty( $note_content ) ) { |
|
| 534 | + if ( empty( $note_content ) ) { |
|
| 535 | 535 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
| 538 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
| 539 | 539 | |
| 540 | 540 | return $return; |
| 541 | 541 | } |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | */ |
| 552 | 552 | public static function get_add_note_part() { |
| 553 | 553 | |
| 554 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 554 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 555 | 555 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
| 556 | 556 | return ''; |
| 557 | 557 | } |
@@ -564,19 +564,19 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
| 566 | 566 | $entry = $gravityview_view->getCurrentEntry(); |
| 567 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 567 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 568 | 568 | $nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false ); |
| 569 | 569 | |
| 570 | 570 | // Only generate the dropdown if the field settings allow it |
| 571 | 571 | $email_fields = ''; |
| 572 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
| 572 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
| 573 | 573 | $email_fields = self::get_note_email_fields( $entry_slug ); |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
| 577 | 577 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
| 578 | - $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html ); |
|
| 579 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
| 578 | + $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
| 579 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
| 580 | 580 | $add_note_html = str_replace( '{url}', esc_url_raw( add_query_arg( array() ) ), $add_note_html ); |
| 581 | 581 | |
| 582 | 582 | return $add_note_html; |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | $note_emails = array(); |
| 602 | 602 | |
| 603 | 603 | foreach ( $email_fields as $email_field ) { |
| 604 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
| 605 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
| 604 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
| 605 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
| 616 | 616 | |
| 617 | - return (array) $note_emails; |
|
| 617 | + return (array)$note_emails; |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | */ |
| 631 | 631 | private static function get_note_email_fields( $entry_slug = '' ) { |
| 632 | 632 | |
| 633 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 633 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 634 | 634 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
| 635 | 635 | return ''; |
| 636 | 636 | } |
@@ -652,27 +652,27 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
| 654 | 654 | <div class="gv-note-email-container"> |
| 655 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
| 655 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
| 656 | 656 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
| 657 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
| 657 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
| 658 | 658 | <?php foreach ( $note_emails as $email ) { |
| 659 | 659 | ?> |
| 660 | 660 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
| 661 | 661 | <?php } |
| 662 | - if( $include_custom ) { ?> |
|
| 663 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
| 662 | + if ( $include_custom ) { ?> |
|
| 663 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
| 664 | 664 | <?php } ?> |
| 665 | 665 | </select> |
| 666 | 666 | <fieldset class="gv-note-to-container"> |
| 667 | - <?php if( $include_custom ) { ?> |
|
| 667 | + <?php if ( $include_custom ) { ?> |
|
| 668 | 668 | <div class='gv-note-to-custom-container'> |
| 669 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
| 670 | - <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings['email-placeholder']; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 669 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
| 670 | + <input type="text" name="gv-note-to-custom" placeholder="<?php echo $strings[ 'email-placeholder' ]; ?>" id="gv-note-to-custom-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 671 | 671 | </div> |
| 672 | 672 | <?php } ?> |
| 673 | 673 | <div class='gv-note-subject-container'> |
| 674 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
| 675 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 674 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
| 675 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 676 | 676 | </div> |
| 677 | 677 | </fieldset> |
| 678 | 678 | </div> |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
| 697 | 697 | |
| 698 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
| 698 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 699 | 699 | do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note ); |
| 700 | 700 | return; |
| 701 | 701 | } |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data ); |
| 704 | 704 | |
| 705 | 705 | //emailing notes if configured |
| 706 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
| 706 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
| 707 | 707 | |
| 708 | 708 | $default_data = array( |
| 709 | 709 | 'gv-note-to' => '', |
@@ -713,11 +713,11 @@ discard block |
||
| 713 | 713 | 'current-url' => '', |
| 714 | 714 | ); |
| 715 | 715 | |
| 716 | - $current_user = wp_get_current_user(); |
|
| 716 | + $current_user = wp_get_current_user(); |
|
| 717 | 717 | $email_data = wp_parse_args( $data, $default_data ); |
| 718 | 718 | |
| 719 | - $from = $current_user->user_email; |
|
| 720 | - $to = $email_data['gv-note-to']; |
|
| 719 | + $from = $current_user->user_email; |
|
| 720 | + $to = $email_data[ 'gv-note-to' ]; |
|
| 721 | 721 | |
| 722 | 722 | /** |
| 723 | 723 | * Documented in get_note_email_fields |
@@ -725,8 +725,8 @@ discard block |
||
| 725 | 725 | */ |
| 726 | 726 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
| 727 | 727 | |
| 728 | - if( 'custom' === $to && $include_custom ) { |
|
| 729 | - $to = $email_data['gv-note-to-custom']; |
|
| 728 | + if ( 'custom' === $to && $include_custom ) { |
|
| 729 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
| 730 | 730 | do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to ); |
| 731 | 731 | } |
| 732 | 732 | |
@@ -737,13 +737,13 @@ discard block |
||
| 737 | 737 | |
| 738 | 738 | $bcc = false; |
| 739 | 739 | $reply_to = $from; |
| 740 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
| 740 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
| 741 | 741 | |
| 742 | 742 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
| 743 | 743 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
| 744 | - $message = $email_data['gv-note-content']; |
|
| 744 | + $message = $email_data[ 'gv-note-content' ]; |
|
| 745 | 745 | $email_footer = self::strings( 'email-footer' ); |
| 746 | - $from_name = $current_user->display_name; |
|
| 746 | + $from_name = $current_user->display_name; |
|
| 747 | 747 | $message_format = 'html'; |
| 748 | 748 | |
| 749 | 749 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | |
| 775 | 775 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
| 776 | 776 | |
| 777 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
| 777 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
| 778 | 778 | |
| 779 | 779 | /** |
| 780 | 780 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | $output = ''; |
| 802 | 802 | |
| 803 | - if( ! empty( $email_footer ) ) { |
|
| 803 | + if ( ! empty( $email_footer ) ) { |
|
| 804 | 804 | $url = rgar( $email_data, 'current-url' ); |
| 805 | 805 | $url = html_entity_decode( $url ); |
| 806 | 806 | $url = site_url( $url ); |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | // Make sure the keys are all set |
| 68 | 68 | $note = wp_parse_args( $note, $default_note ); |
| 69 | 69 | |
| 70 | - GFFormsModel::add_note( intval( $note['lead_id'] ), intval( $note['user_id'] ), esc_attr( $note['user_name'] ), $note['note'], esc_attr( $note['note_type'] ) ); |
|
| 70 | + GFFormsModel::add_note( intval( $note[ 'lead_id' ] ), intval( $note[ 'user_id' ] ), esc_attr( $note[ 'user_name' ] ), $note[ 'note' ], esc_attr( $note[ 'note_type' ] ) ); |
|
| 71 | 71 | |
| 72 | 72 | // If last_error is empty string, there was no error. |
| 73 | - if( empty( $wpdb->last_error ) ) { |
|
| 73 | + if ( empty( $wpdb->last_error ) ) { |
|
| 74 | 74 | $return = $wpdb->insert_id; |
| 75 | 75 | } else { |
| 76 | 76 | $return = new WP_Error( 'gravityview-add-note', $wpdb->last_error ); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public static function delete_notes( $note_ids = array() ) { |
| 98 | 98 | |
| 99 | - if( !is_array( $note_ids ) ) { |
|
| 99 | + if ( ! is_array( $note_ids ) ) { |
|
| 100 | 100 | |
| 101 | 101 | do_action( 'gravityview_log_error', __METHOD__ . ' - Note IDs not an array. Not processing delete request.', $note_ids ); |
| 102 | 102 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | ) |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - return $results ? $results[0] : false; |
|
| 154 | + return $results ? $results[ 0 ] : false; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | public static function filter_avatar( $avatar = '', $note ) { |
| 166 | 166 | |
| 167 | - if( 'gravityview' === $note->note_type && -1 === (int)$note->user_id ) { |
|
| 168 | - $avatar = sprintf( '<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw( plugins_url( 'assets/images/floaty-avatar.png', GRAVITYVIEW_FILE ) ) ); |
|
| 167 | + if ( 'gravityview' === $note->note_type && -1 === (int)$note->user_id ) { |
|
| 168 | + $avatar = sprintf( '<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw( plugins_url( 'assets/images/floaty-avatar.png', GRAVITYVIEW_FILE ) ) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $avatar; |
@@ -21,10 +21,10 @@ |
||
| 21 | 21 | {email_fields} |
| 22 | 22 | |
| 23 | 23 | <div class="gv-note-content-container"> |
| 24 | - <label for="gv-note-content-{entry_slug}" class="screen-reader-text"><?php echo GravityView_Field_Notes::strings('content-label'); ?></label> |
|
| 24 | + <label for="gv-note-content-{entry_slug}" class="screen-reader-text"><?php echo GravityView_Field_Notes::strings( 'content-label' ); ?></label> |
|
| 25 | 25 | <textarea name="gv-note-content" id="gv-note-content-{entry_slug}"></textarea> |
| 26 | 26 | </div> |
| 27 | 27 | |
| 28 | - <button type="submit" class="button gv-add-note-submit"><?php echo GravityView_Field_Notes::strings('add-note'); ?></button> |
|
| 28 | + <button type="submit" class="button gv-add-note-submit"><?php echo GravityView_Field_Notes::strings( 'add-note' ); ?></button> |
|
| 29 | 29 | </div> |
| 30 | 30 | </form> |
| 31 | 31 | \ No newline at end of file |