| @@ -11,8 +11,13 @@ | ||
| 11 | 11 | public function __construct( $args ) { |
| 12 | 12 | $this->status = self::get_param( array( 'param' => 'form_type' ) ); |
| 13 | 13 | |
| 14 | 14 | parent::__construct( $args ); |
| 15 | + $this->screen->set_screen_reader_content( | |
| 16 | + array( | |
| 17 | + 'heading_list' => esc_html__( 'Forms list', 'formidable' ), | |
| 18 | + ) | |
| 19 | + ); | |
| 15 | 20 | } |
| 16 | 21 | |
| 17 | 22 | /** |
| 18 | 23 | * @return void |
| @@ -77,9 +82,9 @@ | ||
| 77 | 82 | ); |
| 78 | 83 | if ( $s != '' ) { |
| 79 | 84 | preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
| 80 | 85 | $search_terms = array_map( 'trim', $matches[0] ); |
| 81 | - foreach ( (array) $search_terms as $term ) { | |
| 86 | + foreach ( $search_terms as $term ) { | |
| 82 | 87 | $s_query[] = array( |
| 83 | 88 | 'or' => true, |
| 84 | 89 | 'name LIKE' => $term, |
| 85 | 90 | 'description LIKE' => $term, |
| @@ -90,10 +95,10 @@ | ||
| 90 | 95 | unset( $term ); |
| 91 | 96 | } |
| 92 | 97 | } |
| 93 | 98 | |
| 94 | - $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); | |
| 95 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); | |
| 99 | + $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); | |
| 100 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); | |
| 96 | 101 | $this->total_items = $total_items; |
| 97 | 102 | |
| 98 | 103 | $this->set_pagination_args( |
| 99 | 104 | array( |
| @@ -124,9 +129,9 @@ | ||
| 124 | 129 | |
| 125 | 130 | public function get_bulk_actions() { |
| 126 | 131 | $actions = array(); |
| 127 | 132 | |
| 128 | - if ( 'trash' == $this->status ) { | |
| 133 | + if ( 'trash' === $this->status ) { | |
| 129 | 134 | if ( current_user_can( 'frm_edit_forms' ) ) { |
| 130 | 135 | $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
| 131 | 136 | } |
| 132 | 137 | |
| @@ -145,13 +150,13 @@ | ||
| 145 | 150 | /** |
| 146 | 151 | * @return void |
| 147 | 152 | */ |
| 148 | 153 | public function extra_tablenav( $which ) { |
| 149 | - if ( 'top' != $which ) { | |
| 154 | + if ( 'top' !== $which ) { | |
| 150 | 155 | return; |
| 151 | 156 | } |
| 152 | 157 | |
| 153 | - if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { | |
| 158 | + if ( 'trash' === $this->status && current_user_can( 'frm_delete_forms' ) ) { | |
| 154 | 159 | ?> |
| 155 | 160 | <div class="alignleft actions frm_visible_overflow"> |
| 156 | 161 | <?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?> |
| 157 | 162 | </div> |
| @@ -158,10 +163,12 @@ | ||
| 158 | 163 | <?php |
| 159 | 164 | } |
| 160 | 165 | } |
| 161 | 166 | |
| 167 | + /** | |
| 168 | + * @return array | |
| 169 | + */ | |
| 162 | 170 | public function get_views() { |
| 163 | - | |
| 164 | 171 | $statuses = array( |
| 165 | 172 | 'published' => __( 'My Forms', 'formidable' ), |
| 166 | 173 | 'draft' => __( 'Drafts', 'formidable' ), |
| 167 | 174 | 'trash' => __( 'Trash', 'formidable' ), |
| @@ -201,8 +208,9 @@ | ||
| 201 | 208 | return $links; |
| 202 | 209 | } |
| 203 | 210 | |
| 204 | 211 | /** |
| 212 | + * @param string $which | |
| 205 | 213 | * @return void |
| 206 | 214 | */ |
| 207 | 215 | public function pagination( $which ) { |
| 208 | 216 | global $mode; |
| @@ -230,24 +238,31 @@ | ||
| 230 | 238 | |
| 231 | 239 | $action_links = $this->row_actions( $actions ); |
| 232 | 240 | |
| 233 | 241 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
| 234 | - $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; | |
| 242 | + $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; | |
| 243 | + $checkbox_label_text = sprintf( | |
| 244 | + // translators: Form title | |
| 245 | + __( 'Select %s', 'formidable' ), | |
| 246 | + ! empty( $item->name ) ? $item->name : FrmFormsHelper::get_no_title_text() | |
| 247 | + ); | |
| 235 | 248 | |
| 249 | + $checkbox .= '<label for="cb-item-action-' . absint( $item->id ) . '"><span class="screen-reader-text">' . esc_html( $checkbox_label_text ) . '</span></label>'; | |
| 250 | + | |
| 236 | 251 | $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>'; |
| 237 | 252 | |
| 238 | 253 | list( $columns, $hidden ) = $this->get_column_info(); |
| 239 | 254 | |
| 240 | 255 | $format = 'Y/m/d'; |
| 241 | - if ( 'list' != $mode ) { | |
| 256 | + if ( 'list' !== $mode ) { | |
| 242 | 257 | $format .= ' \<\b\r \/\> g:i:s a'; |
| 243 | 258 | } |
| 244 | 259 | |
| 245 | 260 | foreach ( $columns as $column_name => $column_display_name ) { |
| 246 | - $class = $column_name . ' column-' . $column_name . ( 'name' == $column_name ? ' post-title page-title column-title' : '' ); | |
| 261 | + $class = $column_name . ' column-' . $column_name . ( 'name' === $column_name ? ' post-title page-title column-title' : '' ); | |
| 247 | 262 | |
| 248 | 263 | $style = ''; |
| 249 | - if ( in_array( $column_name, $hidden ) ) { | |
| 264 | + if ( in_array( $column_name, $hidden, true ) ) { | |
| 250 | 265 | $class .= ' frm_hidden'; |
| 251 | 266 | } |
| 252 | 267 | |
| 253 | 268 | if ( $column_name === 'name' ) { |
| @@ -266,9 +281,9 @@ | ||
| 266 | 281 | case 'form_key': |
| 267 | 282 | $val = $item->{$column_name}; |
| 268 | 283 | break; |
| 269 | 284 | case 'name': |
| 270 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); | |
| 285 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); | |
| 271 | 286 | $val .= $action_links; |
| 272 | 287 | break; |
| 273 | 288 | case 'created_at': |
| 274 | 289 | $date = gmdate( $format, strtotime( $item->created_at ) ); |
| @@ -293,9 +308,9 @@ | ||
| 293 | 308 | if ( method_exists( $this, 'column_' . $column_name ) ) { |
| 294 | 309 | $val = call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 295 | 310 | } |
| 296 | 311 | break; |
| 297 | - } | |
| 312 | + }//end switch | |
| 298 | 313 | |
| 299 | 314 | if ( isset( $val ) ) { |
| 300 | 315 | $r .= "<td $attributes>"; |
| 301 | 316 | $r .= $val; |
| @@ -301,9 +316,9 @@ | ||
| 301 | 316 | $r .= $val; |
| 302 | 317 | $r .= '</td>'; |
| 303 | 318 | } |
| 304 | 319 | unset( $val ); |
| 305 | - } | |
| 320 | + }//end foreach | |
| 306 | 321 | $r .= '</tr>'; |
| 307 | 322 | |
| 308 | 323 | return $r; |
| 309 | 324 | } |
| @@ -317,13 +332,14 @@ | ||
| 317 | 332 | * @param stdClass $form |
| 318 | 333 | * @return string |
| 319 | 334 | */ |
| 320 | 335 | protected function column_shortcode( $form ) { |
| 321 | - $val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_html__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>'; | |
| 336 | + $val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_attr__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>'; | |
| 322 | 337 | $val .= $this->column_style( $form ); |
| 323 | 338 | $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) ); |
| 324 | - $val = str_replace( ' ', '', $val ); // Remove the space hard coded in Landing pages. | |
| 325 | - $val = '<div>' . $val . '</div>'; | |
| 339 | + // Remove the space hard coded in Landing pages. | |
| 340 | + $val = str_replace( ' ', '', $val ); | |
| 341 | + $val = '<div>' . $val . '</div>'; | |
| 326 | 342 | return $val; |
| 327 | 343 | } |
| 328 | 344 | |
| 329 | 345 | /** |
| @@ -354,11 +370,11 @@ | ||
| 354 | 370 | return '<a href="' . esc_url( $href ) . '" title="' . esc_attr( $style->post_title ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_pallet_icon', array( 'echo' => false ) ) . '</a>'; |
| 355 | 371 | } |
| 356 | 372 | |
| 357 | 373 | /** |
| 374 | + * @param array $actions | |
| 375 | + * @param object $item | |
| 358 | 376 | * @param string $edit_link |
| 359 | - * @param array $actions | |
| 360 | - * @param stdClass $item | |
| 361 | 377 | * |
| 362 | 378 | * @return void |
| 363 | 379 | */ |
| 364 | 380 | private function get_actions( &$actions, $item, $edit_link ) { |
| @@ -366,11 +382,10 @@ | ||
| 366 | 382 | foreach ( $new_actions as $link => $action ) { |
| 367 | 383 | $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' ); |
| 368 | 384 | } |
| 369 | 385 | |
| 370 | - if ( 'trash' == $this->status ) { | |
| 386 | + if ( 'trash' === $this->status ) { | |
| 371 | 387 | $actions = $new_actions; |
| 372 | - | |
| 373 | 388 | return; |
| 374 | 389 | } |
| 375 | 390 | |
| 376 | 391 | if ( current_user_can( 'frm_edit_forms' ) ) { |
| @@ -382,10 +397,12 @@ | ||
| 382 | 397 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>'; |
| 383 | 398 | } |
| 384 | 399 | |
| 385 | 400 | /** |
| 401 | + * @param object $item | |
| 402 | + * @param array $actions | |
| 386 | 403 | * @param string $edit_link |
| 387 | - * @param stdClass $item | |
| 404 | + * @param string $mode | |
| 388 | 405 | * |
| 389 | 406 | * @return string |
| 390 | 407 | */ |
| 391 | 408 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| @@ -390,9 +407,9 @@ | ||
| 390 | 407 | */ |
| 391 | 408 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 392 | 409 | $form_name = $item->name; |
| 393 | 410 | if ( trim( $form_name ) == '' ) { |
| 394 | - $form_name = __( '(no title)', 'formidable' ); | |
| 411 | + $form_name = FrmFormsHelper::get_no_title_text(); | |
| 395 | 412 | } |
| 396 | 413 | $form_name = FrmAppHelper::kses( $form_name ); |
| 397 | 414 | if ( 'excerpt' != $mode ) { |
| 398 | 415 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| @@ -398,9 +415,9 @@ | ||
| 398 | 415 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 399 | 416 | } |
| 400 | 417 | |
| 401 | 418 | $val = '<strong>'; |
| 402 | - if ( 'trash' == $this->status ) { | |
| 419 | + if ( 'trash' === $this->status ) { | |
| 403 | 420 | $val .= $form_name; |
| 404 | 421 | } else { |
| 405 | 422 | $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; |
| 406 | 423 | } |
| @@ -413,19 +430,21 @@ | ||
| 413 | 430 | return $val; |
| 414 | 431 | } |
| 415 | 432 | |
| 416 | 433 | /** |
| 434 | + * @param object $item | |
| 417 | 435 | * @param string $val |
| 418 | 436 | * |
| 419 | 437 | * @return void |
| 420 | 438 | */ |
| 421 | 439 | private function add_draft_label( $item, &$val ) { |
| 422 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { | |
| 423 | - $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; | |
| 440 | + if ( 'draft' === $item->status && 'draft' != $this->status ) { | |
| 441 | + $val .= ' - <span class="post-state">' . esc_html__( 'Draft', 'formidable' ) . '</span>'; | |
| 424 | 442 | } |
| 425 | 443 | } |
| 426 | 444 | |
| 427 | 445 | /** |
| 446 | + * @param object $item | |
| 428 | 447 | * @param string $val |
| 429 | 448 | * |
| 430 | 449 | * @return void |
| 431 | 450 | */ |
| @@ -430,9 +449,9 @@ | ||
| 430 | 449 | * @return void |
| 431 | 450 | */ |
| 432 | 451 | private function add_form_description( $item, &$val ) { |
| 433 | 452 | global $mode; |
| 434 | - if ( 'excerpt' == $mode ) { | |
| 453 | + if ( 'excerpt' === $mode ) { | |
| 435 | 454 | $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
| 436 | 455 | } |
| 437 | 456 | } |
| 438 | 457 | |