| @@ -3,12 +3,8 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmFormsListHelper extends FrmListHelper { |
| 7 | - | |
| 8 | - /** | |
| 9 | - * @var string | |
| 10 | - */ | |
| 11 | 7 | public $status = ''; |
| 12 | 8 | |
| 13 | 9 | public $total_items = 0; |
| 14 | 10 | |
| @@ -49,11 +45,8 @@ | ||
| 49 | 45 | 'param' => 'order', |
| 50 | 46 | 'default' => 'ASC', |
| 51 | 47 | ) |
| 52 | 48 | ); |
| 53 | - | |
| 54 | - FrmAppController::apply_saved_sort_preference( $orderby, $order ); | |
| 55 | - | |
| 56 | 49 | $start = self::get_param( |
| 57 | 50 | array( |
| 58 | 51 | 'param' => 'start', |
| 59 | 52 | 'default' => ( $page - 1 ) * $per_page, |
| @@ -86,13 +79,11 @@ | ||
| 86 | 79 | 'param' => 's', |
| 87 | 80 | 'sanitize' => 'sanitize_text_field', |
| 88 | 81 | ) |
| 89 | 82 | ); |
| 90 | - | |
| 91 | 83 | if ( $s != '' ) { |
| 92 | 84 | preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
| 93 | 85 | $search_terms = array_map( 'trim', $matches[0] ); |
| 94 | - | |
| 95 | 86 | foreach ( $search_terms as $term ) { |
| 96 | 87 | $s_query[] = array( |
| 97 | 88 | 'or' => true, |
| 98 | 89 | 'name LIKE' => $term, |
| @@ -156,10 +147,8 @@ | ||
| 156 | 147 | return $actions; |
| 157 | 148 | } |
| 158 | 149 | |
| 159 | 150 | /** |
| 160 | - * @param string $which | |
| 161 | - * | |
| 162 | 151 | * @return void |
| 163 | 152 | */ |
| 164 | 153 | public function extra_tablenav( $which ) { |
| 165 | 154 | if ( 'top' !== $which ) { |
| @@ -220,9 +209,8 @@ | ||
| 220 | 209 | } |
| 221 | 210 | |
| 222 | 211 | /** |
| 223 | 212 | * @param string $which |
| 224 | - * | |
| 225 | 213 | * @return void |
| 226 | 214 | */ |
| 227 | 215 | public function pagination( $which ) { |
| 228 | 216 | global $mode; |
| @@ -236,9 +224,8 @@ | ||
| 236 | 224 | |
| 237 | 225 | /** |
| 238 | 226 | * @param stdClass $item |
| 239 | 227 | * @param string $style |
| 240 | - * | |
| 241 | 228 | * @return string |
| 242 | 229 | */ |
| 243 | 230 | public function single_row( $item, $style = '' ) { |
| 244 | 231 | global $frm_vars, $mode; |
| @@ -255,9 +242,9 @@ | ||
| 255 | 242 | $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; |
| 256 | 243 | $checkbox_label_text = sprintf( |
| 257 | 244 | // translators: Form title |
| 258 | 245 | __( 'Select %s', 'formidable' ), |
| 259 | - ! empty( $item->name ) ? $item->name : FrmFormsHelper::get_no_title_text() | |
| 246 | + ! empty( $item->name ) ? $item->name : __( '(no title)', 'formidable' ) | |
| 260 | 247 | ); |
| 261 | 248 | |
| 262 | 249 | $checkbox .= '<label for="cb-item-action-' . absint( $item->id ) . '"><span class="screen-reader-text">' . esc_html( $checkbox_label_text ) . '</span></label>'; |
| 263 | 250 | |
| @@ -265,9 +252,8 @@ | ||
| 265 | 252 | |
| 266 | 253 | list( $columns, $hidden ) = $this->get_column_info(); |
| 267 | 254 | |
| 268 | 255 | $format = 'Y/m/d'; |
| 269 | - | |
| 270 | 256 | if ( 'list' !== $mode ) { |
| 271 | 257 | $format .= ' \<\b\r \/\> g:i:s a'; |
| 272 | 258 | } |
| 273 | 259 | |
| @@ -274,9 +260,8 @@ | ||
| 274 | 260 | foreach ( $columns as $column_name => $column_display_name ) { |
| 275 | 261 | $class = $column_name . ' column-' . $column_name . ( 'name' === $column_name ? ' post-title page-title column-title' : '' ); |
| 276 | 262 | |
| 277 | 263 | $style = ''; |
| 278 | - | |
| 279 | 264 | if ( in_array( $column_name, $hidden, true ) ) { |
| 280 | 265 | $class .= ' frm_hidden'; |
| 281 | 266 | } |
| 282 | 267 | |
| @@ -344,15 +329,13 @@ | ||
| 344 | 329 | * |
| 345 | 330 | * @since 6.0 |
| 346 | 331 | * |
| 347 | 332 | * @param stdClass $form |
| 348 | - * | |
| 349 | 333 | * @return string |
| 350 | 334 | */ |
| 351 | 335 | protected function column_shortcode( $form ) { |
| 352 | 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>'; |
| 353 | 337 | $val .= $this->column_style( $form ); |
| 354 | - $val .= $this->column_views( $form ); | |
| 355 | 338 | $val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) ); |
| 356 | 339 | // Remove the space hard coded in Landing pages. |
| 357 | 340 | $val = str_replace( ' ', '', $val ); |
| 358 | 341 | $val = '<div>' . $val . '</div>'; |
| @@ -364,13 +347,12 @@ | ||
| 364 | 347 | * |
| 365 | 348 | * @since 6.0 |
| 366 | 349 | * |
| 367 | 350 | * @param stdClass $form |
| 368 | - * | |
| 369 | 351 | * @return string |
| 370 | 352 | */ |
| 371 | 353 | protected function column_style( $form ) { |
| 372 | - $style_setting = $form->options['custom_style'] ?? ''; | |
| 354 | + $style_setting = isset( $form->options['custom_style'] ) ? $form->options['custom_style'] : ''; | |
| 373 | 355 | $frm_settings = FrmAppHelper::get_settings(); |
| 374 | 356 | |
| 375 | 357 | if ( $style_setting === '0' || 'none' === $frm_settings->load_style ) { |
| 376 | 358 | // Don't show a link if styling is off. |
| @@ -377,9 +359,8 @@ | ||
| 377 | 359 | return ''; |
| 378 | 360 | } |
| 379 | 361 | |
| 380 | 362 | $style = FrmStylesController::get_form_style( $form ); |
| 381 | - | |
| 382 | 363 | if ( ! $style ) { |
| 383 | 364 | // Do a second pass to avoid null values. |
| 384 | 365 | $frm_style = new FrmStyle( 'default' ); |
| 385 | 366 | $style = $frm_style->get_one(); |
| @@ -389,29 +370,8 @@ | ||
| 389 | 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>'; |
| 390 | 371 | } |
| 391 | 372 | |
| 392 | 373 | /** |
| 393 | - * Generate the HTML for the form Views page. | |
| 394 | - * | |
| 395 | - * @since 6.19 | |
| 396 | - * | |
| 397 | - * @param stdClass $form Form object. | |
| 398 | - * | |
| 399 | - * @return string | |
| 400 | - */ | |
| 401 | - protected function column_views( $form ) { | |
| 402 | - $attributes = array( | |
| 403 | - 'href' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $form->id ) . '&show_nav=1' ), | |
| 404 | - 'title' => __( 'Link to list of all views for this form.', 'formidable' ), | |
| 405 | - 'target' => '_blank', | |
| 406 | - ); | |
| 407 | - | |
| 408 | - return '<a ' . FrmAppHelper::array_to_html_params( $attributes ) . '> | |
| 409 | - ' . FrmAppHelper::icon_by_class( 'frmfont frm_eye_icon', array( 'echo' => false ) ) . | |
| 410 | - '</a>'; | |
| 411 | - } | |
| 412 | - | |
| 413 | - /** | |
| 414 | 374 | * @param array $actions |
| 415 | 375 | * @param object $item |
| 416 | 376 | * @param string $edit_link |
| 417 | 377 | * |
| @@ -418,9 +378,8 @@ | ||
| 418 | 378 | * @return void |
| 419 | 379 | */ |
| 420 | 380 | private function get_actions( &$actions, $item, $edit_link ) { |
| 421 | 381 | $new_actions = FrmFormsHelper::get_action_links( $item->id, $item ); |
| 422 | - | |
| 423 | 382 | foreach ( $new_actions as $link => $action ) { |
| 424 | 383 | $new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' ); |
| 425 | 384 | } |
| 426 | 385 | |
| @@ -447,21 +406,17 @@ | ||
| 447 | 406 | * @return string |
| 448 | 407 | */ |
| 449 | 408 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
| 450 | 409 | $form_name = $item->name; |
| 451 | - | |
| 452 | - if ( is_null( $form_name ) || trim( $form_name ) === '' ) { | |
| 453 | - $form_name = FrmFormsHelper::get_no_title_text(); | |
| 410 | + if ( trim( $form_name ) == '' ) { | |
| 411 | + $form_name = __( '(no title)', 'formidable' ); | |
| 454 | 412 | } |
| 455 | - | |
| 456 | 413 | $form_name = FrmAppHelper::kses( $form_name ); |
| 457 | - | |
| 458 | 414 | if ( 'excerpt' != $mode ) { |
| 459 | 415 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
| 460 | 416 | } |
| 461 | 417 | |
| 462 | 418 | $val = '<strong>'; |
| 463 | - | |
| 464 | 419 | if ( 'trash' === $this->status ) { |
| 465 | 420 | $val .= $form_name; |
| 466 | 421 | } else { |
| 467 | 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> '; |
| @@ -494,10 +449,9 @@ | ||
| 494 | 449 | * @return void |
| 495 | 450 | */ |
| 496 | 451 | private function add_form_description( $item, &$val ) { |
| 497 | 452 | global $mode; |
| 498 | - | |
| 499 | - if ( 'excerpt' === $mode && ! is_null( $item->description ) ) { | |
| 453 | + if ( 'excerpt' === $mode ) { | |
| 500 | 454 | $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
| 501 | 455 | } |
| 502 | 456 | } |
| 503 | 457 | |