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 / scripts.php

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

86 lines 2.1 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\Admin_Utils;
6 use ISC\Helpers;
7
8 /**
9 * Add the admin menu items für Image Sources features
10 */
11 class Image_Sources_Admin_Scripts {
12 /**
13 * Constructor
14 */
15 public function __construct() {
16 add_action( 'admin_enqueue_scripts', [ $this, 'add_admin_scripts' ] );
17 add_action( 'admin_print_scripts', [ $this, 'admin_head_scripts' ] );
18 }
19
20 /**
21 * Add scripts to ISC-related pages
22 */
23 public function add_admin_scripts() {
24 $screen = get_current_screen();
25
26 if ( ! isset( $screen->id ) ) {
27 return;
28 }
29
30 if ( $screen->id === 'media_page_isc-sources' ) {
31 Helpers::enqueue_script( 'isc_sources_script', 'admin/assets/js/sources.js' );
32 }
33
34 // check if we are on the media library page with list view
35 if ( Admin_Utils::is_media_library_list_view_page() ) {
36 return;
37 }
38
39 if ( in_array( $screen->id, [ 'upload', 'widgets', 'customize' ], true ) ) {
40 Helpers::enqueue_script( 'isc_attachment_compat', 'admin/assets/js/wp.media.view.AttachmentCompat.js', [ 'media-upload' ] );
41 }
42 }
43
44 /**
45 * Display scripts in <head></head> section of admin page. Useful for creating js variables in the js global namespace.
46 */
47 public function admin_head_scripts() {
48 global $pagenow;
49 $screen = get_current_screen();
50 // texts in JavaScript on sources page
51 if ( 'upload.php' === $pagenow && isset( $_GET['page'] ) && 'isc-sources' === $_GET['page'] ) {
52 ?>
53 <script>
54 isc_data = {
55 confirm_message: '<?php esc_html_e( 'Are you sure?', 'image-source-control-isc' ); ?>',
56 baseurl: '<?php echo esc_url( ISCBASEURL ); ?>'
57 };
58 </script>
59 <?php
60 }
61 // add style to media edit pages
62 if ( isset( $screen->id ) && $screen->id === 'attachment' ) {
63 // Meta field in media view
64 ?>
65 <style>
66 .compat-attachment-fields input[type="text"] {
67 width: 100%;
68 }
69
70 .compat-attachment-fields th {
71 vertical-align: top;
72 }
73 </style>
74 <?php
75 }
76 // add to any backend pages
77 ?>
78 <style>
79 .compat-attachment-fields .isc-get-pro {
80 font-weight: bold;
81 color: #F70;
82 }
83 </style>
84 <?php
85 }
86 }