css
3 years ago
font
3 years ago
images
3 years ago
js
3 years ago
admin.php
3 years ago
edit.php
3 years ago
form.php
3 years ago
insert.php
3 years ago
manage.php
3 years ago
settings.php
3 years ago
tools.php
3 years ago
manage.php
70 lines
| 1 | <?php |
| 2 | if( ! defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | class SC_Admin_Manage{ |
| 5 | |
| 6 | public static function init(){ |
| 7 | |
| 8 | add_filter( 'manage_' . SC_POST_TYPE . '_posts_columns', array( __CLASS__, 'column_head' ) ); |
| 9 | |
| 10 | add_action( 'manage_' . SC_POST_TYPE . '_posts_custom_column', array( __CLASS__, 'column_content' ), 10, 2 ); |
| 11 | |
| 12 | add_filter( 'edit_posts_per_page', array( __CLASS__, 'per_page_count' ), 10, 2 ); |
| 13 | |
| 14 | } |
| 15 | |
| 16 | public static function column_head( $columns ){ |
| 17 | |
| 18 | unset( $columns[ 'views' ] ); |
| 19 | |
| 20 | $new_columns = array(); |
| 21 | |
| 22 | foreach( $columns as $id => $val ){ |
| 23 | if( $id == 'taxonomy-sc_tag' ){ |
| 24 | $new_columns[ 'shortcode' ] = __( 'Shortcode', 'shortcoder'); |
| 25 | $new_columns[ 'desc' ] = __( 'Description', 'shortcoder'); |
| 26 | } |
| 27 | $new_columns[$id] = $val; |
| 28 | } |
| 29 | |
| 30 | return $new_columns; |
| 31 | |
| 32 | } |
| 33 | |
| 34 | public static function column_content( $column, $post_id ){ |
| 35 | |
| 36 | $general_settings = Shortcoder::get_settings(); |
| 37 | |
| 38 | if( $column == 'shortcode' ){ |
| 39 | $sc_tag = Shortcoder::get_sc_tag( $post_id ); |
| 40 | echo '<span class="sc_copy_list_wrap"><input type="text" class="widefat sc_copy_text" readonly value="' . esc_attr( $sc_tag ) . '" /><a href="#" class="sc_copy_list" title="' . esc_attr__( 'Copy', 'shortcoder' ) . '"><span class="dashicons dashicons-clipboard"></span></a></span>'; |
| 41 | if( $general_settings[ 'list_content' ] != 'no' ){ |
| 42 | $sc_post = get_post( $post_id ); |
| 43 | $sc_content = trim( $sc_post->post_content ); |
| 44 | if( !empty( $sc_content ) ){ |
| 45 | $content_size = intval( $general_settings[ 'list_content' ] ); |
| 46 | $sc_content = substr( $sc_content, 0, $content_size ? $content_size : 100 ); |
| 47 | echo '<pre class="sc_content_list">' . esc_html( trim( $sc_content ) ) . '...</pre>'; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if( $column == 'desc' ){ |
| 53 | $sc_settings = Shortcoder::get_sc_settings( $post_id ); |
| 54 | echo esc_html( $sc_settings[ '_sc_description' ] ); |
| 55 | } |
| 56 | |
| 57 | } |
| 58 | |
| 59 | public static function per_page_count( $count, $post_type ){ |
| 60 | if( $post_type == SC_POST_TYPE && $count == 20 ){ |
| 61 | return 500; |
| 62 | } |
| 63 | return $count; |
| 64 | } |
| 65 | |
| 66 | } |
| 67 | |
| 68 | SC_Admin_Manage::init(); |
| 69 | |
| 70 | ?> |