Actions.php
9 years ago
Attachment.php
9 years ago
AttachmentCount.php
9 years ago
Author.php
9 years ago
AuthorName.php
9 years ago
BeforeMoreTag.php
9 years ago
Categories.php
9 years ago
CommentCount.php
9 years ago
CommentStatus.php
9 years ago
Comments.php
9 years ago
Content.php
9 years ago
Date.php
9 years ago
DatePublished.php
9 years ago
Depth.php
9 years ago
EstimatedReadingTime.php
9 years ago
Excerpt.php
9 years ago
FeaturedImage.php
9 years ago
Formats.php
9 years ago
ID.php
9 years ago
LastModifiedAuthor.php
9 years ago
Modified.php
9 years ago
Order.php
9 years ago
PageTemplate.php
9 years ago
Parent.php
9 years ago
Path.php
9 years ago
Permalink.php
9 years ago
PingStatus.php
9 years ago
Roles.php
9 years ago
Shortcodes.php
9 years ago
Shortlink.php
9 years ago
Slug.php
9 years ago
Status.php
9 years ago
Sticky.php
9 years ago
Tags.php
9 years ago
Taxonomy.php
9 years ago
Title.php
9 years ago
TitleRaw.php
9 years ago
WordCount.php
9 years ago
Shortcodes.php
62 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Display used shortcodes |
| 9 | * |
| 10 | * @since 2.3.5 |
| 11 | */ |
| 12 | class AC_Column_Post_Shortcodes extends AC_Column { |
| 13 | |
| 14 | public function __construct() { |
| 15 | $this->set_type( 'column-shortcode' ); |
| 16 | $this->set_label( __( 'Shortcodes', 'codepress-admin-columns' ) ); |
| 17 | } |
| 18 | |
| 19 | public function get_value( $post_id ) { |
| 20 | if ( ! ( $shortcodes = $this->get_raw_value( $post_id ) ) ) { |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | $display = array(); |
| 25 | foreach ( $shortcodes as $sc => $count ) { |
| 26 | $string = '[' . $sc . ']'; |
| 27 | |
| 28 | if ( $count > 1 ) { |
| 29 | $string .= ac_helper()->html->rounded( $count ); |
| 30 | } |
| 31 | |
| 32 | $display[ $sc ] = '<span class="ac-spacing">' . $string . '</span>'; |
| 33 | } |
| 34 | |
| 35 | return implode( ' ', $display ); |
| 36 | } |
| 37 | |
| 38 | public function get_raw_value( $post_id ) { |
| 39 | global $shortcode_tags; |
| 40 | |
| 41 | if ( ! $shortcode_tags ) { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | $content = get_post_field( 'post_content', $post_id ); |
| 46 | |
| 47 | $shortcodes = array(); |
| 48 | |
| 49 | $_shortcodes = array_keys( $shortcode_tags ); |
| 50 | asort( $_shortcodes ); |
| 51 | |
| 52 | foreach ( $_shortcodes as $sc ) { |
| 53 | if ( $count = substr_count( $content, '[' . $sc ) ) { |
| 54 | $shortcodes[ $sc ] = $count; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | return $shortcodes; |
| 59 | } |
| 60 | |
| 61 | } |
| 62 |