@@ -376,6 +376,79 @@ public function search_box( $text, $input_id ) {
376
376
<?php
377
377
}
378
378
379
+ /**
380
+ * Generates views links.
381
+ *
382
+ * @since 6.1.0
383
+ *
384
+ * @param array $link_data {
385
+ * An array of link data.
386
+ *
387
+ * @type string $url The link URL.
388
+ * @type string $label The link label.
389
+ * @type bool $current Optional. Whether this is the currently selected view.
390
+ * }
391
+ * @return array An array of link markup. Keys match the `$link_data` input array.
392
+ */
393
+ protected function get_views_links ( $ link_data = array () ) {
394
+ if ( ! is_array ( $ link_data ) ) {
395
+ _doing_it_wrong (
396
+ __METHOD__ ,
397
+ sprintf (
398
+ /* translators: %s: The $link_data argument. */
399
+ __ ( 'The %s argument must be an array. ' ),
400
+ '<code>$link_data</code> '
401
+ ),
402
+ '6.1.0 '
403
+ );
404
+
405
+ return array ( '' );
406
+ }
407
+
408
+ $ views_links = array ();
409
+
410
+ foreach ( $ link_data as $ view => $ link ) {
411
+ if ( empty ( $ link ['url ' ] ) || ! is_string ( $ link ['url ' ] ) || '' === trim ( $ link ['url ' ] ) ) {
412
+ _doing_it_wrong (
413
+ __METHOD__ ,
414
+ sprintf (
415
+ /* translators: %1$s: The argument name. %2$s: The view name. */
416
+ __ ( 'The %1$s argument must be a non-empty string for %2$s. ' ),
417
+ '<code>url</code> ' ,
418
+ '<code> ' . esc_html ( $ view ) . '</code> '
419
+ ),
420
+ '6.1.0 '
421
+ );
422
+
423
+ continue ;
424
+ }
425
+
426
+ if ( empty ( $ link ['label ' ] ) || ! is_string ( $ link ['label ' ] ) || '' === trim ( $ link ['label ' ] ) ) {
427
+ _doing_it_wrong (
428
+ __METHOD__ ,
429
+ sprintf (
430
+ /* translators: %1$s: The argument name. %2$s: The view name. */
431
+ __ ( 'The %1$s argument must be a non-empty string for %2$s. ' ),
432
+ '<code>label</code> ' ,
433
+ '<code> ' . esc_html ( $ view ) . '</code> '
434
+ ),
435
+ '6.1.0 '
436
+ );
437
+
438
+ continue ;
439
+ }
440
+
441
+ $ views_links [ $ view ] = sprintf (
442
+ '<a href="%s"%s>%s</a> ' ,
443
+ esc_url ( $ link ['url ' ] ),
444
+ isset ( $ link ['current ' ] ) && true === $ link ['current ' ] ? ' class="current" aria-current="page" ' : '' ,
445
+ $ link ['label ' ]
446
+ );
447
+ }
448
+
449
+ return $ views_links ;
450
+ }
451
+
379
452
/**
380
453
* Gets the list of views available on this table.
381
454
*
@@ -1513,78 +1586,6 @@ public function ajax_response() {
1513
1586
die ( wp_json_encode ( $ response ) );
1514
1587
}
1515
1588
1516
- /**
1517
- * Generates views links.
1518
- *
1519
- * @since 6.1.0
1520
- *
1521
- * @param array $link_data {
1522
- * An array of link data.
1523
- *
1524
- * @type string $url The link URL.
1525
- * @type string $label The link label.
1526
- * @type bool $current Optional. Whether this is the currently selected view.
1527
- * }
1528
- * @return array An array of link markup. Keys match the $link_data input array.
1529
- */
1530
- protected function get_views_links ( $ link_data = array () ) {
1531
- if ( ! is_array ( $ link_data ) ) {
1532
- _doing_it_wrong (
1533
- __METHOD__ ,
1534
- sprintf (
1535
- /* translators: %s: The $link_data argument. */
1536
- __ ( 'The %s argument must be an array. ' ),
1537
- '<code>$link_data</code> '
1538
- ),
1539
- '6.1.0 '
1540
- );
1541
-
1542
- return array ( '' );
1543
- }
1544
-
1545
- $ views_links = array ();
1546
- foreach ( $ link_data as $ view => $ link ) {
1547
- if ( empty ( $ link ['url ' ] ) || ! is_string ( $ link ['url ' ] ) || '' === trim ( $ link ['url ' ] ) ) {
1548
- _doing_it_wrong (
1549
- __METHOD__ ,
1550
- sprintf (
1551
- /* translators: %1$s: The argument name. %2$s: The view name. */
1552
- __ ( 'The %1$s argument must be a non-empty string for %2$s. ' ),
1553
- '<code>url</code> ' ,
1554
- '<code> ' . esc_html ( $ view ) . '</code> '
1555
- ),
1556
- '6.1.0 '
1557
- );
1558
-
1559
- continue ;
1560
- }
1561
-
1562
- if ( empty ( $ link ['label ' ] ) || ! is_string ( $ link ['label ' ] ) || '' === trim ( $ link ['label ' ] ) ) {
1563
- _doing_it_wrong (
1564
- __METHOD__ ,
1565
- sprintf (
1566
- /* translators: %1$s: The argument name. %2$s: The view name. */
1567
- __ ( 'The %1$s argument must be a non-empty string for %2$s. ' ),
1568
- '<code>label</code> ' ,
1569
- '<code> ' . esc_html ( $ view ) . '</code> '
1570
- ),
1571
- '6.1.0 '
1572
- );
1573
-
1574
- continue ;
1575
- }
1576
-
1577
- $ views_links [ $ view ] = sprintf (
1578
- '<a href="%s"%s>%s</a> ' ,
1579
- esc_url ( $ link ['url ' ] ),
1580
- isset ( $ link ['current ' ] ) && true === $ link ['current ' ] ? ' class="current" aria-current="page" ' : '' ,
1581
- $ link ['label ' ]
1582
- );
1583
- }
1584
-
1585
- return $ views_links ;
1586
- }
1587
-
1588
1589
/**
1589
1590
* Sends required variables to JavaScript land.
1590
1591
*
0 commit comments