Shortcodes.php
951 Bytes
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
<?php
namespace AC\Column\Post;
use AC\Column;
/**
* Display used shortcodes
* @since 2.3.5
*/
class Shortcodes extends Column {
public function __construct() {
$this->set_type( 'column-shortcode' );
$this->set_label( __( 'Shortcodes', 'codepress-admin-columns' ) );
}
public function get_value( $post_id ) {
$shortcodes = $this->get_raw_value( $post_id );
if ( ! $shortcodes ) {
return $this->get_empty_char();
}
$display = [];
foreach ( $shortcodes as $sc => $count ) {
$string = '[' . $sc . ']';
if ( $count > 1 ) {
$string .= ac_helper()->html->rounded( $count );
}
$display[ $sc ] = '<span class="ac-spacing">' . $string . '</span>';
}
return implode( ' ', $display );
}
public function get_raw_value( $post_id ) {
global $shortcode_tags;
if ( ! $shortcode_tags ) {
return false;
}
return ac_helper()->string->get_shortcodes( get_post_field( 'post_content', $post_id ) );
}
}