PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 2.2.44
Gallery : FooGallery v2.2.44
3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / admin / class-columns.php
foogallery / includes / admin Last commit date
class-admin-notices.php 3 years ago class-admin.php 3 years ago class-attachment-fields.php 3 years ago class-columns.php 3 years ago class-demo-content.php 3 years ago class-extensions.php 3 years ago class-gallery-attachment-modal.php 3 years ago class-gallery-datasources.php 3 years ago class-gallery-editor.php 3 years ago class-gallery-metabox-fields.php 3 years ago class-gallery-metabox-items.php 3 years ago class-gallery-metabox-settings-helper.php 3 years ago class-gallery-metabox-settings.php 3 years ago class-gallery-metaboxes.php 3 years ago class-menu.php 3 years ago class-pro-promotion.php 3 years ago class-settings.php 3 years ago class-silent-installer-skin.php 3 years ago demo-content-galleries.php 3 years ago demo-content-images.php 3 years ago index.php 3 years ago view-extensions.php 3 years ago view-help-demos.php 3 years ago view-help-getting-started.php 3 years ago view-help-pro.php 3 years ago view-help.php 3 years ago view-system-info.php 3 years ago
class-columns.php
113 lines
1 <?php
2 /*
3 * FooGallery Admin Columns class
4 */
5
6 if ( ! class_exists( 'FooGallery_Admin_Columns' ) ) {
7
8 class FooGallery_Admin_Columns {
9
10 private $include_clipboard_script = false;
11 private $_foogallery = false;
12
13 public function __construct() {
14 add_filter( 'manage_edit-' . FOOGALLERY_CPT_GALLERY . '_columns', array( $this, 'gallery_custom_columns' ) );
15 add_action( 'manage_posts_custom_column', array( $this, 'gallery_custom_column_content' ) );
16 add_action( 'admin_footer', array( $this, 'include_clipboard_script' ) );
17 }
18
19 public function gallery_custom_columns( $columns ) {
20 return array_slice( $columns, 0, 1, true ) +
21 array( 'icon' => '' ) +
22 array_slice( $columns, 1, null, true ) +
23 array(
24 FOOGALLERY_CPT_GALLERY . '_template' => __( 'Template', 'foogallery' ),
25 FOOGALLERY_CPT_GALLERY . '_count' => __( 'Media', 'foogallery' ),
26 FOOGALLERY_CPT_GALLERY . '_shortcode' => __( 'Shortcode', 'foogallery' ),
27 FOOGALLERY_CPT_GALLERY . '_usage' => __( 'Usage', 'foogallery' ),
28 );
29 }
30
31 private function get_local_gallery( $post ) {
32 if ( false === $this->_foogallery ) {
33 $this->_foogallery = FooGallery::get( $post );
34 } else if ( $this->_foogallery->ID !== $post->ID) {
35 $this->_foogallery = FooGallery::get( $post );
36 }
37
38 return $this->_foogallery;
39 }
40
41 public function gallery_custom_column_content( $column ) {
42 global $post;
43
44 switch ( $column ) {
45 case FOOGALLERY_CPT_GALLERY . '_template':
46 $gallery = $this->get_local_gallery( $post );
47 echo $gallery->gallery_template_name();
48 break;
49 case FOOGALLERY_CPT_GALLERY . '_count':
50 $gallery = $this->get_local_gallery( $post );
51 echo $gallery->image_count();
52 break;
53 case FOOGALLERY_CPT_GALLERY . '_shortcode':
54 $gallery = $this->get_local_gallery( $post );
55 $shortcode = $gallery->shortcode();
56
57 echo '<input type="text" readonly="readonly" size="' . strlen( $shortcode ) . '" value="' . esc_attr( $shortcode ) . '" class="foogallery-shortcode" />';
58
59 $this->include_clipboard_script = true;
60
61 break;
62 case 'icon':
63 $gallery = $this->get_local_gallery( $post );
64 $html_img = foogallery_find_featured_attachment_thumbnail_html( $gallery, array(
65 'width' => 60,
66 'height' => 60,
67 'force_use_original_thumb' => true
68 ) );
69 if ( $html_img ) {
70 echo $html_img;
71 }
72 break;
73 case FOOGALLERY_CPT_GALLERY . '_usage':
74 $gallery = $this->get_local_gallery( $post );
75 $posts = $gallery->find_usages();
76 if ( $posts && count( $posts ) > 0 ) {
77 echo '<ul class="ul-disc">';
78 foreach ( $posts as $post ) {
79 echo edit_post_link( $post->post_title, '<li>', '</li>', $post->ID );
80 }
81 echo '</ul>';
82 } else {
83 _e( 'Not used!', 'foogallery' );
84 }
85 break;
86 }
87 }
88
89 public function include_clipboard_script() {
90 if ( $this->include_clipboard_script ) { ?>
91 <script>
92 jQuery(function($) {
93 $('.foogallery-shortcode').on('click', function () {
94 try {
95 //select the contents
96 this.select();
97 //copy the selection
98 document.execCommand('copy');
99 //show the copied message
100 $('.foogallery-shortcode-message').remove();
101 $(this).after('<p class="foogallery-shortcode-message"><?php _e( 'Shortcode copied to clipboard :)','foogallery' ); ?></p>');
102 } catch(err) {
103 console.log('Oops, unable to copy!');
104 }
105 });
106 });
107 </script>
108 <?php
109 }
110 }
111 }
112 }
113