PluginProbe
Image Source Control Lite – Show Image Credits and Captions / trunk
Image Source Control Lite – Show Image Credits and Captions vtrunk
3.12.0 3.11.0 trunk 1.1 1.1.1 1.1.2 1.1.2.1 1.1.3 1.10 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.2 1.2.0.1 1.2.0.2 1.2.0.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.4.1 1.3.5 All 110 releases
image-source-control-isc / includes / image-sources / admin / menu.php

menu.php in Image Source Control Lite – Show Image Credits and Captions trunk, at includes/image-sources/admin/menu.php

108 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ISC\Image_Sources;
4
5 use ISC_Model;
6
7 /**
8 * Add the admin menu items and pages Image Sources features
9 */
10 class Admin_Menu {
11 use \ISC\Options;
12
13 /**
14 * Constructor
15 */
16 public function __construct() {
17 add_action( 'admin_menu', [ $this, 'add_menu_items' ] );
18 }
19
20 /**
21 * Create the menu pages for ISC with access for editors and higher roles
22 */
23 public function add_menu_items() {
24 $options = self::get_options();
25 if ( empty( $options['warning_onesource_missing'] ) ) {
26 $notice_alert = '';
27 } else {
28 $missing_images = get_transient( 'isc-show-missing-sources-warning' );
29 $notice_alert = '&nbsp;<span class="update-plugins count-' . $missing_images . '"><span class="update-count">' . $missing_images . '</span></span>';
30 }
31
32 add_submenu_page(
33 'upload.php',
34 esc_html__( 'Image Source Control', 'image-source-control-isc' ),
35 __( 'Image Sources', 'image-source-control-isc' ) . $notice_alert,
36 'edit_others_posts',
37 'isc-sources',
38 [ $this, 'render_sources_page' ]
39 );
40 }
41
42
43 /**
44 * Missing sources page callback
45 */
46 public function render_sources_page() {
47
48 ?>
49 <div class="wrap metabox-holder">
50 <div id="isc-section-wrapper">
51 <?php
52
53 $attachments = ISC_Model::get_attachments_with_empty_sources();
54 if ( ! empty( $attachments ) ) {
55 ob_start();
56 require_once ISCPATH . '/admin/templates/sources/images-without-sources.php';
57 $this->render_sources_page_section( ob_get_clean(), esc_html__( 'Images without sources', 'image-source-control-isc' ), 'images-without-sources' );
58 } else {
59 ?>
60 <div class="notice notice-success"><p><span class="dashicons dashicons-yes" style="color: #46b450"></span><?php esc_html_e( 'All images found in the frontend have sources assigned.', 'image-source-control-isc' ); ?></p></div>
61 <?php
62 }
63
64 $stats = \ISC\Unused_Images::get_unused_attachment_stats();
65 $attachment_count = $stats['attachment_count'] ?? 0;
66 $files = $stats['files'] ?? 0;
67 $filesize = $stats['filesize'] ?? 0;
68 if ( $files ) {
69 ob_start();
70 require_once ISCPATH . '/admin/templates/sources/unused-attachments.php';
71 $this->render_sources_page_section( ob_get_clean(), esc_html__( 'Unused Images', 'image-source-control-isc' ), 'unused-attachments' );
72 }
73
74 $post_type_image_index = ISC_Model::get_posts_with_image_index();
75 ob_start();
76 require_once ISCPATH . '/admin/templates/sources/post-index.php';
77 $this->render_sources_page_section( ob_get_clean(), esc_html__( 'Post Index', 'image-source-control-isc' ), 'post-index' );
78
79 $storage_model = new \ISC_Storage_Model();
80 $external_images = $storage_model->get_storage_without_wp_images();
81 if ( ! empty( $stored_images ) ) {
82 ob_start();
83 require_once ISCPATH . '/admin/templates/sources/external-images.php';
84 $this->render_sources_page_section( ob_get_clean(), esc_html__( 'Additional images', 'image-source-control-isc' ), 'external-images' );
85 }
86
87 $storage_size = count( $storage_model->get_storage() );
88 ob_start();
89 require_once ISCPATH . '/admin/templates/sources/storage.php';
90 $this->render_sources_page_section( ob_get_clean(), esc_html__( 'Storage', 'image-source-control-isc' ), 'storage' );
91
92 ?>
93 </div>
94 </div>
95 <?php
96 }
97
98 /**
99 * Render sources page sections
100 *
101 * @param string $section section HTML.
102 * @param string $title section title.
103 * @param string $id section id.
104 */
105 public function render_sources_page_section( $section, $title = '', $id = '' ) {
106 include ISCPATH . '/admin/templates/sources/section.php';
107 }
108 }