Table.php
1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace ACA\YoastSeo\Service;
use AC\ListScreen;
use AC\Registerable;
class Table implements Registerable {
public function register(): void
{
add_action( 'ac/admin_footer', [ $this, 'fix_yoast_heading_tooltips' ] );
add_action( 'ac/table/list_screen', [ $this, 'remove_link_column_on_ajax' ] );
}
/**
* @param ListScreen $list_screen
*/
public function remove_link_column_on_ajax( $list_screen ) {
/**
* Quickfix for Yoast SEO Link column, that gives an error on the/our Ajax call
* We unset this column on our Ajax Request so
*/
add_filter( $list_screen->get_heading_hookname(), function ( $headings ) {
if ( filter_input( INPUT_POST, 'ac_action' ) && is_array( $headings ) ) {
$headings = $this->replace_key_maintain_order( $headings, 'wpseo-links', 'wpseo-links_empty' );
$headings = $this->replace_key_maintain_order( $headings, 'wpseo-linked', 'wpseo-linked_empty' );
}
return $headings;
}, 201 );
}
/**
* Replace key & Maintain Order
*
* @param array $array
* @param string $oldkey
* @param string $newkey
*
* @return array
*/
private function replace_key_maintain_order( array $array, $oldkey, $newkey ) {
if ( array_key_exists( $oldkey, $array ) ) {
$keys = array_keys( $array );
$keys[ array_search( $oldkey, $keys ) ] = $newkey;
return array_combine( $keys, $array );
}
return $array;
}
public function fix_yoast_heading_tooltips() {
?>
<style>
.wp-list-table th > a.yoast-tooltip::before,
.wp-list-table th > a.yoast-tooltip::after {
display: none !important;
}
</style>
<?php
}
}