| @@ -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 |
| @@ -40,8 +45,11 @@ | ||
| 40 | 45 | 'param' => 'order', |
| 41 | 46 | 'default' => 'ASC', |
| 42 | 47 | ) |
| 43 | 48 | ); |
| 49 | + | |
| 50 | + FrmAppController::apply_saved_sort_preference( $orderby, $order ); | |
| 51 | + | |
| 44 | 52 | $start = self::get_param( |
| 45 | 53 | array( |
| 46 | 54 | 'param' => 'start', |
| 47 | 55 | 'default' => ( $page - 1 ) * $per_page, |
| @@ -77,9 +85,9 @@ | ||
| 77 | 85 | ); |
| 78 | 86 | if ( $s != '' ) { |
| 79 | 87 | preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
| 80 | 88 | $search_terms = array_map( 'trim', $matches[0] ); |
| 81 | - foreach ( (array) $search_terms as $term ) { | |
| 89 | + foreach ( $search_terms as $term ) { | |
| 82 | 90 | $s_query[] = array( |
| 83 | 91 | 'or' => true, |
| 84 | 92 | 'name LIKE' => $term, |
| 85 | 93 | 'description LIKE' => $term, |
| @@ -90,10 +98,10 @@ | ||
| 90 | 98 | unset( $term ); |
| 91 | 99 | } |
| 92 | 100 | } |
| 93 | 101 | |
| 94 | - $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); | |
| 95 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); | |
| 102 | + $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); | |
| 103 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); | |
| 96 | 104 | $this->total_items = $total_items; |
| 97 | 105 | |
| 98 | 106 | $this->set_pagination_args( |
| 99 | 107 | array( |
| @@ -124,9 +132,9 @@ | ||
| 124 | 132 | |
| 125 | 133 | public function get_bulk_actions() { |
| 126 | 134 | $actions = array(); |
| 127 | 135 | |
| 128 | - if ( 'trash' == $this->status ) { | |
| 136 | + if ( 'trash' === $this->status ) { | |
| 129 | 137 | if ( current_user_can( 'frm_edit_forms' ) ) { |
| 130 | 138 | $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
| 131 | 139 | } |
| 132 | 140 | |
| @@ -145,13 +153,13 @@ | ||
| 145 | 153 | /** |
| 146 | 154 | * @return void |
| 147 | 155 | */ |
| 148 | 156 | public function extra_tablenav( $which ) { |
| 149 | - if ( 'top' != $which ) { | |
| 157 | + if ( 'top' !== $which ) { | |
| 150 | 158 | return; |
| 151 | 159 | } |
| 152 | 160 | |
| 153 | - if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { | |
| 161 | + if ( 'trash' === $this->status && current_user_can( 'frm_delete_forms' ) ) { | |
| 154 | 162 | ?> |
| 155 | 163 | <div class="alignleft actions frm_visible_overflow"> |
| 156 | 164 | <?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?> |
| 157 | 165 | </div> |
| @@ -158,10 +166,12 @@ | ||
| 158 | 166 | <?php |
| 159 | 167 | } |
| 160 | 168 | } |
| 161 | 169 | |
| 170 | + /** | |
| 171 | + * @return array | |
| 172 | + */ | |
| 162 | 173 | public function get_views() { |
| 163 | - | |
| 164 | 174 | $statuses = array( |
| 165 | 175 | 'published' => __( 'My Forms', 'formidable' ), |
| 166 | 176 | 'draft' => __( 'Drafts', 'formidable' ), |
| 167 | 177 | 'trash' => __( 'Trash', 'formidable' ), |
| @@ -201,8 +211,9 @@ | ||
| 201 | 211 | return $links; |
| 202 | 212 | } |
| 203 | 213 | |
| 204 | 214 | /** |
| 215 | + * @param string $which | |
| 205 | 216 | * @return void |
| 206 | 217 | */ |
| 207 | 218 | public function pagination( $which ) { |
| 208 | 219 | global $mode; |
| @@ -230,24 +241,31 @@ | ||
| 230 | 241 | |
| 231 | 242 | $action_links = $this->row_actions( $actions ); |
| 232 | 243 | |
| 233 | 244 | // 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 ) . '" />'; | |
| 245 | + $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; | |
| 246 | + $checkbox_label_text = sprintf( | |
| 247 | + // translators: Form title | |
| 248 | + __( 'Select %s', 'formidable' ), | |
| 249 | + ! empty( $item->name ) ? $item->name : FrmFormsHelper::get_no_title_text() | |
| 250 | + ); | |
| 235 | 251 | |
| 252 | + $checkbox .= '<label for="cb-item-action-' . absint( $item->id ) . '"><span class="screen-reader-text">' . esc_html( $checkbox_label_text ) . '</span></label>'; | |
| 253 | + | |
| 236 | 254 | $r = '<tr id="item-action-' . absint( $item->id ) . '"' . $style . '>'; |
| 237 | 255 | |
| 238 | 256 | list( $columns, $hidden ) = $this->get_column_info(); |
| 239 | 257 | |
| 240 | 258 | $format = 'Y/m/d'; |
| 241 | - if ( 'list' != $mode ) { | |
| 259 | + if ( 'list' !== $mode ) { | |
| 242 | 260 | $format .= ' \<\b\r \/\> g:i:s a'; |
| 243 | 261 | } |
| 244 | 262 | |
| 245 | 263 | foreach ( $columns as $column_name => $column_display_name ) { |
| 246 | - $class = $column_name . ' column-' . $column_name . ( 'name' == $column_name ? ' post-title page-title column-title' : '' ); | |
| 264 | + $class = $column_name . ' column-' . $column_name . ( 'name' === $column_name ? ' post-title page-title column-title' : '' ); | |
| 247 | 265 | |
| 248 | 266 | $style = ''; |
| 249 | - if ( in_array( $column_name, $hidden ) ) { | |
| 267 | + if ( in_array( $column_name, $hidden, true ) ) { | |
| 250 | 268 | $class .= ' frm_hidden'; |
| 251 | 269 | } |
| 252 | 270 | |
| 253 | 271 | if ( $column_name === 'name' ) { |
| @@ -266,9 +284,9 @@ | ||
| 266 | 284 | case 'form_key': |
| 267 | 285 | $val = $item->{$column_name}; |
| 268 | 286 | break; |
| 269 | 287 | case 'name': |
| 270 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); | |
| 288 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); | |
| 271 | 289 | $val .= $action_links; |
| 272 | 290 | break; |
| 273 | 291 | case 'created_at': |
| 274 | 292 | $date = gmdate( $format, strtotime( $item->created_at ) ); |
| @@ -293,9 +311,9 @@ | ||
| 293 | 311 | if ( method_exists( $this, 'column_' . $column_name ) ) { |
| 294 | 312 | $val = call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 295 | 313 | } |
| 296 | 314 | break; |
| 297 | - } | |
| 315 | + }//end switch | |
| 298 | 316 | |
| 299 | 317 | if ( isset( $val ) ) { |
| 300 | 318 | $r .= "<td $attributes>"; |
| 301 | 319 | $r .= $val; |
| @@ -301,9 +319,9 @@ | ||
| 301 | 319 | $r .= $val; |
| 302 | 320 | $r .= '</td>'; |
| 303 | 321 | } |
| 304 | 322 | unset( $val ); |
| 305 | - } | |
| 323 | + }//end foreach | |
| 306 | 324 | $r .= '</tr>'; |
| 307 | 325 | |
| 308 | 326 | return $r; |
| 309 | 327 | } |
| @@ -317,13 +335,15 @@ | ||
| 317 | 335 | * @param stdClass $form |
| 318 | 336 | * @return string |
| 319 | 337 | */ |
| 320 | 338 | 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>'; | |
| 339 | + $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 | 340 | $val .= $this->column_style( $form ); |
| 341 | + $val .= $this->column_views( $form ); | |
| 323 | 342 | $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>'; | |
| 343 | + // Remove the space hard coded in Landing pages. | |
| 344 | + $val = str_replace( ' ', '', $val ); | |
| 345 | + $val = '<div>' . $val . '</div>'; | |
| 326 | 346 | return $val; |
| 327 | 347 | } |
| 328 | 348 | |
| 329 | 349 | /** |
| @@ -354,11 +374,31 @@ | ||
| 354 | 374 | 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 | 375 | } |
| 356 | 376 | |
| 357 | 377 | /** |
| 378 | + * Generate the HTML for the form Views page. | |
| 379 | + * | |
| 380 | + * @since 6.19 | |
| 381 | + * | |
| 382 | + * @param stdClass $form Form object. | |
| 383 | + * @return string | |
| 384 | + */ | |
| 385 | + protected function column_views( $form ) { | |
| 386 | + $attributes = array( | |
| 387 | + 'href' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $form->id ) . '&show_nav=1' ), | |
| 388 | + 'title' => __( 'View Form', 'formidable' ), | |
| 389 | + 'target' => '_blank', | |
| 390 | + ); | |
| 391 | + | |
| 392 | + return '<a ' . FrmAppHelper::array_to_html_params( $attributes ) . '> | |
| 393 | + ' . FrmAppHelper::icon_by_class( 'frmfont frm_eye_icon', array( 'echo' => false ) ) . | |
| 394 | + '</a>'; | |
| 395 | + } | |
| 396 | + | |
| 397 | + /** | |
| 398 | + * @param array $actions | |
| 399 | + * @param object $item | |
| 358 | 400 | * @param string $edit_link |
| 359 | - * @param array $actions | |
| 360 | - * @param stdClass $item | |
| 361 | 401 | * |
| 362 | 402 | * @return void |
| 363 | 403 | */ |
| 364 | 404 | private function get_actions( &$actions, $item, $edit_link ) { |
| @@ -366,11 +406,10 @@ | ||
| 366 | 406 | foreach ( $new_actions as $link => $action ) { |
| 367 | 407 | $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' ); |
| 368 | 408 | } |
| 369 | 409 | |
| 370 | - if ( 'trash' == $this->status ) { | |
| 410 | + if ( 'trash' === $this->status ) { | |
| 371 | 411 | $actions = $new_actions; |
| 372 | - | |
| 373 | 412 | return; |
| 374 | 413 | } |
| 375 | 414 | |
| 376 | 415 | if ( current_user_can( 'frm_edit_forms' ) ) { |
| @@ -382,17 +421,19 @@ | ||
| 382 | 421 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>'; |
| 383 | 422 | } |
| 384 | 423 | |
| 385 | 424 | /** |
| 425 | + * @param object $item | |
| 426 | + * @param array $actions | |
| 386 | 427 | * @param string $edit_link |
| 387 | - * @param stdClass $item | |
| 428 | + * @param string $mode | |
| 388 | 429 | * |
| 389 | 430 | * @return string |
| 390 | 431 | */ |
| 391 | 432 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 392 | 433 | $form_name = $item->name; |
| 393 | - if ( trim( $form_name ) == '' ) { | |
| 394 | - $form_name = __( '(no title)', 'formidable' ); | |
| 434 | + if ( is_null( $form_name ) || trim( $form_name ) == '' ) { | |
| 435 | + $form_name = FrmFormsHelper::get_no_title_text(); | |
| 395 | 436 | } |
| 396 | 437 | $form_name = FrmAppHelper::kses( $form_name ); |
| 397 | 438 | if ( 'excerpt' != $mode ) { |
| 398 | 439 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| @@ -398,9 +439,9 @@ | ||
| 398 | 439 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 399 | 440 | } |
| 400 | 441 | |
| 401 | 442 | $val = '<strong>'; |
| 402 | - if ( 'trash' == $this->status ) { | |
| 443 | + if ( 'trash' === $this->status ) { | |
| 403 | 444 | $val .= $form_name; |
| 404 | 445 | } else { |
| 405 | 446 | $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 | 447 | } |
| @@ -413,19 +454,21 @@ | ||
| 413 | 454 | return $val; |
| 414 | 455 | } |
| 415 | 456 | |
| 416 | 457 | /** |
| 458 | + * @param object $item | |
| 417 | 459 | * @param string $val |
| 418 | 460 | * |
| 419 | 461 | * @return void |
| 420 | 462 | */ |
| 421 | 463 | private function add_draft_label( $item, &$val ) { |
| 422 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { | |
| 423 | - $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; | |
| 464 | + if ( 'draft' === $item->status && 'draft' != $this->status ) { | |
| 465 | + $val .= ' - <span class="post-state">' . esc_html__( 'Draft', 'formidable' ) . '</span>'; | |
| 424 | 466 | } |
| 425 | 467 | } |
| 426 | 468 | |
| 427 | 469 | /** |
| 470 | + * @param object $item | |
| 428 | 471 | * @param string $val |
| 429 | 472 | * |
| 430 | 473 | * @return void |
| 431 | 474 | */ |
| @@ -430,9 +473,9 @@ | ||
| 430 | 473 | * @return void |
| 431 | 474 | */ |
| 432 | 475 | private function add_form_description( $item, &$val ) { |
| 433 | 476 | global $mode; |
| 434 | - if ( 'excerpt' == $mode ) { | |
| 477 | + if ( 'excerpt' === $mode && ! is_null( $item->description ) ) { | |
| 435 | 478 | $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
| 436 | 479 | } |
| 437 | 480 | } |
| 438 | 481 | |