@@ -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 | } |
@@ -41,7 +41,6 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @see GVCommon::get_forms() |
| 43 | 43 | * @access public |
| 44 | - * @param mixed $form_id |
|
| 45 | 44 | * @return array Empty array if GFAPI isn't available or no forms. Otherwise, associative array with id, title keys |
| 46 | 45 | */ |
| 47 | 46 | function gravityview_get_forms() { |
@@ -53,7 +52,7 @@ discard block |
||
| 53 | 52 | * |
| 54 | 53 | * @see GVCommon::get_form_fields() |
| 55 | 54 | * @access public |
| 56 | - * @param string|array $form_id (default: '') or $form object |
|
| 55 | + * @param string|array $form (default: '') or $form object |
|
| 57 | 56 | * @return array |
| 58 | 57 | */ |
| 59 | 58 | function gravityview_get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
@@ -91,6 +90,7 @@ discard block |
||
| 91 | 90 | * @param int|array $form_ids The ID of the form or an array IDs of the Forms. Zero for all forms. |
| 92 | 91 | * @param mixed $passed_criteria (default: null) |
| 93 | 92 | * @param mixed &$total (default: null) |
| 93 | + * @param integer $total |
|
| 94 | 94 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
| 95 | 95 | */ |
| 96 | 96 | function gravityview_get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
@@ -103,7 +103,6 @@ discard block |
||
| 103 | 103 | * 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()` |
| 104 | 104 | * |
| 105 | 105 | * @access public |
| 106 | - * @param mixed $entry_id |
|
| 107 | 106 | * @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. |
| 108 | 107 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true {@since 1.14} |
| 109 | 108 | * @return array|boolean |
@@ -190,7 +189,6 @@ discard block |
||
| 190 | 189 | * |
| 191 | 190 | * @see GravityView_Template::template_id |
| 192 | 191 | * |
| 193 | - * @param int $view_id The ID of the View to get the layout of |
|
| 194 | 192 | * |
| 195 | 193 | * @return string GravityView_Template::template_id value. Empty string if not. |
| 196 | 194 | */ |
@@ -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 | |
@@ -123,7 +123,7 @@ |
||
| 123 | 123 | * |
| 124 | 124 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
| 125 | 125 | * |
| 126 | - * @since 1.17 |
|
| 126 | + * @since 1.17 |
|
| 127 | 127 | * |
| 128 | 128 | * @see process_delete_notes |
| 129 | 129 | * |
@@ -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 | */ |
@@ -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 | |
@@ -100,23 +100,23 @@ discard block |
||
| 100 | 100 | public function enqueue_scripts() { |
| 101 | 101 | global $wp_actions; |
| 102 | 102 | |
| 103 | - if( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
| 103 | + if ( ! wp_script_is( 'gravityview-notes', 'enqueued' ) ) { |
|
| 104 | 104 | wp_enqueue_style( 'gravityview-notes' ); |
| 105 | 105 | wp_enqueue_script( 'gravityview-notes' ); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
| 108 | + if ( ! wp_script_is( 'gravityview-notes', 'done' ) ) { |
|
| 109 | 109 | |
| 110 | 110 | $strings = self::strings(); |
| 111 | 111 | |
| 112 | 112 | wp_localize_script( 'gravityview-notes', 'GVNotes', array( |
| 113 | 113 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 114 | 114 | 'text' => array( |
| 115 | - 'processing' => $strings['processing'], |
|
| 116 | - 'delete_confirm' => $strings['delete-confirm'], |
|
| 117 | - 'note_added' => $strings['added-note'], |
|
| 118 | - 'error_invalid' => $strings['error-invalid'], |
|
| 119 | - 'error_empty_note' => $strings['error-empty-note'], |
|
| 115 | + 'processing' => $strings[ 'processing' ], |
|
| 116 | + 'delete_confirm' => $strings[ 'delete-confirm' ], |
|
| 117 | + 'note_added' => $strings[ 'added-note' ], |
|
| 118 | + 'error_invalid' => $strings[ 'error-invalid' ], |
|
| 119 | + 'error_empty_note' => $strings[ 'error-empty-note' ], |
|
| 120 | 120 | ), |
| 121 | 121 | ) ); |
| 122 | 122 | } |
@@ -133,22 +133,22 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | function maybe_add_note() { |
| 135 | 135 | |
| 136 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 136 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 137 | 137 | do_action( 'gravityview_log_error', __METHOD__ . ': The user isnt allowed to add entry notes.' ); |
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if( 'gv_note_add' === rgpost('action') ) { |
|
| 141 | + if ( 'gv_note_add' === rgpost( 'action' ) ) { |
|
| 142 | 142 | |
| 143 | 143 | $post = wp_unslash( $_POST ); |
| 144 | 144 | |
| 145 | - if( $this->doing_ajax ) { |
|
| 146 | - parse_str( $post['data'], $data ); |
|
| 145 | + if ( $this->doing_ajax ) { |
|
| 146 | + parse_str( $post[ 'data' ], $data ); |
|
| 147 | 147 | } else { |
| 148 | 148 | $data = $post; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $this->process_add_note( (array) $data ); |
|
| 151 | + $this->process_add_note( (array)$data ); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
@@ -175,23 +175,23 @@ discard block |
||
| 175 | 175 | $error = false; |
| 176 | 176 | $success = false; |
| 177 | 177 | |
| 178 | - if( empty( $data['entry-slug'] ) ) { |
|
| 178 | + if ( empty( $data[ 'entry-slug' ] ) ) { |
|
| 179 | 179 | |
| 180 | - $error = self::strings('error-invalid'); |
|
| 180 | + $error = self::strings( 'error-invalid' ); |
|
| 181 | 181 | do_action( 'gravityview_log_error', __METHOD__ . ': The note is missing an Entry ID.' ); |
| 182 | 182 | |
| 183 | 183 | } else { |
| 184 | 184 | |
| 185 | - $valid = wp_verify_nonce( $data['gv_note_add'], 'gv_note_add_' . $data['entry-slug'] ); |
|
| 185 | + $valid = wp_verify_nonce( $data[ 'gv_note_add' ], 'gv_note_add_' . $data[ 'entry-slug' ] ); |
|
| 186 | 186 | |
| 187 | 187 | $has_cap = GVCommon::has_cap( 'gravityview_add_entry_notes' ); |
| 188 | 188 | |
| 189 | - if( ! $has_cap ) { |
|
| 189 | + if ( ! $has_cap ) { |
|
| 190 | 190 | $error = self::strings( 'error-cap-add' ); |
| 191 | 191 | do_action( 'gravityview_log_error', __METHOD__ . ': Adding a note failed: the user does not have the "gravityview_add_entry_notes" capability.' ); |
| 192 | 192 | } elseif ( $valid ) { |
| 193 | 193 | |
| 194 | - $entry = gravityview_get_entry( $data['entry-slug'], true, false ); |
|
| 194 | + $entry = gravityview_get_entry( $data[ 'entry-slug' ], true, false ); |
|
| 195 | 195 | |
| 196 | 196 | $added = $this->add_note( $entry, $data ); |
| 197 | 197 | |
@@ -209,22 +209,22 @@ discard block |
||
| 209 | 209 | $this->maybe_send_entry_notes( $note, $entry, $data ); |
| 210 | 210 | |
| 211 | 211 | if ( $note ) { |
| 212 | - $success = self::display_note( $note, ! empty( $data['show-delete'] ) ); |
|
| 213 | - do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact('note', 'data') ); |
|
| 212 | + $success = self::display_note( $note, ! empty( $data[ 'show-delete' ] ) ); |
|
| 213 | + do_action( 'gravityview_log_debug', __METHOD__ . ': The note was successfully created', compact( 'note', 'data' ) ); |
|
| 214 | 214 | } else { |
| 215 | - $error = self::strings('error-add-note'); |
|
| 216 | - do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact('note', 'data') ); |
|
| 215 | + $error = self::strings( 'error-add-note' ); |
|
| 216 | + do_action( 'gravityview_log_error', __METHOD__ . ': The note was not successfully created', compact( 'note', 'data' ) ); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | } else { |
| 220 | - $error = self::strings('error-invalid'); |
|
| 220 | + $error = self::strings( 'error-invalid' ); |
|
| 221 | 221 | do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed; the note was not created' ); |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
| 226 | - if( $this->doing_ajax ) { |
|
| 227 | - if( $success ) { |
|
| 226 | + if ( $this->doing_ajax ) { |
|
| 227 | + if ( $success ) { |
|
| 228 | 228 | wp_send_json_success( array( 'html' => $success ) ); |
| 229 | 229 | } else { |
| 230 | 230 | $error = $error ? $error : self::strings( 'error-invalid' ); |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | return; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if ( isset( $_POST['action'] ) && 'gv_delete_notes' === $_POST['action'] ) { |
|
| 253 | + if ( isset( $_POST[ 'action' ] ) && 'gv_delete_notes' === $_POST[ 'action' ] ) { |
|
| 254 | 254 | |
| 255 | 255 | $post = wp_unslash( $_POST ); |
| 256 | 256 | if ( $this->doing_ajax ) { |
| 257 | - parse_str( $post['data'], $data ); |
|
| 257 | + parse_str( $post[ 'data' ], $data ); |
|
| 258 | 258 | } else { |
| 259 | 259 | $data = $post; |
| 260 | 260 | } |
@@ -285,18 +285,18 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | function process_delete_notes( $data ) { |
| 287 | 287 | |
| 288 | - $valid = wp_verify_nonce( $data['gv_delete_notes'], 'gv_delete_notes_' . $data['entry-slug'] ); |
|
| 288 | + $valid = wp_verify_nonce( $data[ 'gv_delete_notes' ], 'gv_delete_notes_' . $data[ 'entry-slug' ] ); |
|
| 289 | 289 | $has_cap = GVCommon::has_cap( 'gravityview_delete_entry_notes' ); |
| 290 | 290 | $success = false; |
| 291 | 291 | |
| 292 | 292 | if ( $valid && $has_cap ) { |
| 293 | - GravityView_Entry_Notes::delete_notes( $data['note'] ); |
|
| 293 | + GravityView_Entry_Notes::delete_notes( $data[ 'note' ] ); |
|
| 294 | 294 | $success = true; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if( $this->doing_ajax ) { |
|
| 297 | + if ( $this->doing_ajax ) { |
|
| 298 | 298 | |
| 299 | - if( $success ) { |
|
| 299 | + if ( $success ) { |
|
| 300 | 300 | wp_send_json_success(); |
| 301 | 301 | } else { |
| 302 | 302 | if ( ! $valid ) { |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 331 | 331 | |
| 332 | - unset( $field_options['show_as_link'] ); |
|
| 332 | + unset( $field_options[ 'show_as_link' ] ); |
|
| 333 | 333 | |
| 334 | 334 | $notes_options = array( |
| 335 | 335 | 'notes' => array( |
| 336 | 336 | 'type' => 'checkboxes', |
| 337 | - 'label' => __('Note Settings', 'gravityview'), |
|
| 338 | - '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>' ), |
|
| 337 | + 'label' => __( 'Note Settings', 'gravityview' ), |
|
| 338 | + '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>' ), |
|
| 339 | 339 | 'options' => array( |
| 340 | 340 | 'view' => array( |
| 341 | 341 | 'label' => __( 'Display notes?', 'gravityview' ), |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | 'processing' => __( 'Processing…', 'gravityview' ), |
| 388 | 388 | 'other-email' => __( 'Other email address', 'gravityview' ), |
| 389 | 389 | 'email-label' => __( 'Email address', 'gravityview' ), |
| 390 | - 'email-placeholder' => _x('[email protected]', 'Example email address used as a placeholder', 'gravityview'), |
|
| 390 | + 'email-placeholder' => _x( '[email protected]', 'Example email address used as a placeholder', 'gravityview' ), |
|
| 391 | 391 | 'subject-label' => __( 'Subject', 'gravityview' ), |
| 392 | 392 | 'subject' => __( 'Email subject', 'gravityview' ), |
| 393 | 393 | 'default-email-subject' => __( 'New entry note', 'gravityview' ), |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | $strings = gv_map_deep( apply_filters( 'gravityview/field/notes/strings', $strings ), 'esc_html' ); |
| 408 | 408 | |
| 409 | - if( $key ) { |
|
| 409 | + if ( $key ) { |
|
| 410 | 410 | return isset( $strings[ $key ] ) ? $strings[ $key ] : ''; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | static public function display_note( $note, $show_delete = false ) { |
| 427 | 427 | |
| 428 | - if( ! is_object( $note ) ) { |
|
| 428 | + if ( ! is_object( $note ) ) { |
|
| 429 | 429 | return ''; |
| 430 | 430 | } |
| 431 | 431 | |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | $note_row = ob_get_clean(); |
| 467 | 467 | |
| 468 | 468 | $replacements = array( |
| 469 | - '{note_id}' => $note_content['note_id'], |
|
| 469 | + '{note_id}' => $note_content[ 'note_id' ], |
|
| 470 | 470 | '{row_class}' => 'gv-note', |
| 471 | 471 | '{note_detail}' => $note_detail_html |
| 472 | 472 | ); |
@@ -498,13 +498,13 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | $user_data = get_userdata( $current_user->ID ); |
| 500 | 500 | |
| 501 | - $note_content = trim( $data['gv-note-content'] ); |
|
| 501 | + $note_content = trim( $data[ 'gv-note-content' ] ); |
|
| 502 | 502 | |
| 503 | - if( empty( $note_content ) ) { |
|
| 503 | + if ( empty( $note_content ) ) { |
|
| 504 | 504 | return new WP_Error( 'gv-add-note-empty', __( 'The note is empty.', 'gravityview' ) ); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $return = GravityView_Entry_Notes::add_note( $entry['id'], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
| 507 | + $return = GravityView_Entry_Notes::add_note( $entry[ 'id' ], $user_data->ID, $user_data->display_name, $note_content, 'gravityview/field/notes' ); |
|
| 508 | 508 | |
| 509 | 509 | return $return; |
| 510 | 510 | } |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | */ |
| 521 | 521 | public static function get_add_note_part() { |
| 522 | 522 | |
| 523 | - if( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 523 | + if ( ! GVCommon::has_cap( 'gravityview_add_entry_notes' ) ) { |
|
| 524 | 524 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to add entry notes ("gravityview_add_entry_notes").' ); |
| 525 | 525 | return ''; |
| 526 | 526 | } |
@@ -533,19 +533,19 @@ discard block |
||
| 533 | 533 | |
| 534 | 534 | $visibility_settings = $gravityview_view->getCurrentFieldSetting( 'notes' ); |
| 535 | 535 | $entry = $gravityview_view->getCurrentEntry(); |
| 536 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
| 536 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
| 537 | 537 | $nonce_field = wp_nonce_field( 'gv_note_add_' . $entry_slug, 'gv_note_add', false, false ); |
| 538 | 538 | |
| 539 | 539 | // Only generate the dropdown if the field settings allow it |
| 540 | 540 | $email_fields = ''; |
| 541 | - if( ! empty( $visibility_settings['email'] ) ) { |
|
| 541 | + if ( ! empty( $visibility_settings[ 'email' ] ) ) { |
|
| 542 | 542 | $email_fields = self::get_note_email_fields( $entry_slug ); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $add_note_html = str_replace( '{entry_slug}', $entry_slug, $add_note_html ); |
| 546 | 546 | $add_note_html = str_replace( '{nonce_field}', $nonce_field, $add_note_html ); |
| 547 | - $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings['delete'] ), $add_note_html ); |
|
| 548 | - $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
| 547 | + $add_note_html = str_replace( '{show_delete}', intval( $visibility_settings[ 'delete' ] ), $add_note_html ); |
|
| 548 | + $add_note_html = str_replace( '{email_fields}', $email_fields, $add_note_html ); |
|
| 549 | 549 | |
| 550 | 550 | return $add_note_html; |
| 551 | 551 | } |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | $note_emails = array(); |
| 570 | 570 | |
| 571 | 571 | foreach ( $email_fields as $email_field ) { |
| 572 | - if ( ! empty( $entry["{$email_field->id}"] ) && is_email( $entry["{$email_field->id}"] ) ) { |
|
| 573 | - $note_emails[] = $entry["{$email_field->id}"]; |
|
| 572 | + if ( ! empty( $entry[ "{$email_field->id}" ] ) && is_email( $entry[ "{$email_field->id}" ] ) ) { |
|
| 573 | + $note_emails[ ] = $entry[ "{$email_field->id}" ]; |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | */ |
| 583 | 583 | $note_emails = apply_filters( 'gravityview/field/notes/emails', $note_emails, $entry ); |
| 584 | 584 | |
| 585 | - return (array) $note_emails; |
|
| 585 | + return (array)$note_emails; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | private static function get_note_email_fields( $entry_slug = '' ) { |
| 600 | 600 | |
| 601 | - if( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 601 | + if ( ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 602 | 602 | do_action( 'gravityview_log_error', __METHOD__ . ': User does not have permission to email entry notes ("gravityview_email_entry_notes").' ); |
| 603 | 603 | return ''; |
| 604 | 604 | } |
@@ -620,27 +620,27 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | if ( ! empty( $note_emails ) || $include_custom ) { ?> |
| 622 | 622 | <div class="gv-note-email-container"> |
| 623 | - <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings['also-email']; ?></label> |
|
| 623 | + <label for="gv-note-email-to-<?php echo $entry_slug_esc; ?>" class="screen-reader-text"><?php echo $strings[ 'also-email' ]; ?></label> |
|
| 624 | 624 | <select class="gv-note-email-to" name="gv-note-to" id="gv-note-email-to-<?php echo $entry_slug_esc; ?>"> |
| 625 | - <option value=""><?php echo $strings['also-email']; ?></option> |
|
| 625 | + <option value=""><?php echo $strings[ 'also-email' ]; ?></option> |
|
| 626 | 626 | <?php foreach ( $note_emails as $email ) { |
| 627 | 627 | ?> |
| 628 | 628 | <option value="<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></option> |
| 629 | 629 | <?php } |
| 630 | - if( $include_custom ) { ?> |
|
| 631 | - <option value="custom"><?php echo self::strings('other-email'); ?></option> |
|
| 630 | + if ( $include_custom ) { ?> |
|
| 631 | + <option value="custom"><?php echo self::strings( 'other-email' ); ?></option> |
|
| 632 | 632 | <?php } ?> |
| 633 | 633 | </select> |
| 634 | 634 | <fieldset class="gv-note-to-container"> |
| 635 | - <?php if( $include_custom ) { ?> |
|
| 635 | + <?php if ( $include_custom ) { ?> |
|
| 636 | 636 | <div class='gv-note-to-custom-container'> |
| 637 | - <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings['email-label']; ?></label> |
|
| 638 | - <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="" /> |
|
| 637 | + <label for="gv-note-email-to-custom-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'email-label' ]; ?></label> |
|
| 638 | + <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="" /> |
|
| 639 | 639 | </div> |
| 640 | 640 | <?php } ?> |
| 641 | 641 | <div class='gv-note-subject-container'> |
| 642 | - <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings['subject-label']; ?></label> |
|
| 643 | - <input type="text" name="gv-note-subject" placeholder="<?php echo $strings['subject']; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 642 | + <label for="gv-note-subject-<?php echo $entry_slug_esc; ?>"><?php echo $strings[ 'subject-label' ]; ?></label> |
|
| 643 | + <input type="text" name="gv-note-subject" placeholder="<?php echo $strings[ 'subject' ]; ?>" id="gv-note-subject-<?php echo $entry_slug_esc; ?>" value="" /> |
|
| 644 | 644 | </div> |
| 645 | 645 | </fieldset> |
| 646 | 646 | </div> |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | */ |
| 664 | 664 | private function maybe_send_entry_notes( $note = false, $entry, $data ) { |
| 665 | 665 | |
| 666 | - if( ! $note || ! GVCommon::has_cap('gravityview_email_entry_notes') ) { |
|
| 666 | + if ( ! $note || ! GVCommon::has_cap( 'gravityview_email_entry_notes' ) ) { |
|
| 667 | 667 | do_action( 'gravityview_log_debug', __METHOD__ . ': User doesnt have "gravityview_email_entry_notes" cap, or $note is empty', $note ); |
| 668 | 668 | return; |
| 669 | 669 | } |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | do_action( 'gravityview_log_debug', __METHOD__ . ': $data', $data ); |
| 672 | 672 | |
| 673 | 673 | //emailing notes if configured |
| 674 | - if ( ! empty( $data['gv-note-to'] ) ) { |
|
| 674 | + if ( ! empty( $data[ 'gv-note-to' ] ) ) { |
|
| 675 | 675 | |
| 676 | 676 | $default_data = array( |
| 677 | 677 | 'gv-note-to' => '', |
@@ -680,11 +680,11 @@ discard block |
||
| 680 | 680 | 'gv-note-content' => '', |
| 681 | 681 | ); |
| 682 | 682 | |
| 683 | - $current_user = wp_get_current_user(); |
|
| 683 | + $current_user = wp_get_current_user(); |
|
| 684 | 684 | $email_data = wp_parse_args( $data, $default_data ); |
| 685 | 685 | |
| 686 | - $from = $current_user->user_email; |
|
| 687 | - $to = $email_data['gv-note-to']; |
|
| 686 | + $from = $current_user->user_email; |
|
| 687 | + $to = $email_data[ 'gv-note-to' ]; |
|
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | 690 | * Documented in get_note_email_fields |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | */ |
| 693 | 693 | $include_custom = apply_filters( 'gravityview/field/notes/custom-email', true ); |
| 694 | 694 | |
| 695 | - if( 'custom' === $to && $include_custom ) { |
|
| 696 | - $to = $email_data['gv-note-to-custom']; |
|
| 695 | + if ( 'custom' === $to && $include_custom ) { |
|
| 696 | + $to = $email_data[ 'gv-note-to-custom' ]; |
|
| 697 | 697 | do_action( 'gravityview_log_debug', __METHOD__ . ': Sending note to a custom email address: ' . $to ); |
| 698 | 698 | } |
| 699 | 699 | |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | $bcc = false; |
| 706 | 706 | $reply_to = $from; |
| 707 | - $subject = trim( $email_data['gv-note-subject'] ); |
|
| 707 | + $subject = trim( $email_data[ 'gv-note-subject' ] ); |
|
| 708 | 708 | |
| 709 | 709 | // We use empty() here because GF uses empty to check against, too. `0` isn't a valid subject to GF |
| 710 | 710 | $subject = empty( $subject ) ? self::strings( 'default-email-subject' ) : $subject; |
| 711 | - $message = $email_data['gv-note-content']; |
|
| 712 | - $from_name = $current_user->display_name; |
|
| 711 | + $message = $email_data[ 'gv-note-content' ]; |
|
| 712 | + $from_name = $current_user->display_name; |
|
| 713 | 713 | $message_format = 'html'; |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | GVCommon::send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, '', $entry, false ); |
| 726 | 726 | |
| 727 | - $form = isset( $entry['form_id'] ) ? GFAPI::get_form( $entry['form_id'] ) : array(); |
|
| 727 | + $form = isset( $entry[ 'form_id' ] ) ? GFAPI::get_form( $entry[ 'form_id' ] ) : array(); |
|
| 728 | 728 | |
| 729 | 729 | /** |
| 730 | 730 | * @see https://www.gravityhelp.com/documentation/article/10146-2/ It's here for compatibility with Gravity Forms |
@@ -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 |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | * @return string |
| 22 | 22 | */ |
| 23 | 23 | function get_field_desc() { |
| 24 | - return !empty( $this->field['desc'] ) ? $this->field['desc'] : ''; |
|
| 24 | + return ! empty( $this->field[ 'desc' ] ) ? $this->field[ 'desc' ] : ''; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | } |