PluginProbe
Image Hub – Free Images from Unsplash, Pixabay, Pexels, Openverse & Giphy / 1.0.8
Image Hub – Free Images from Unsplash, Pixabay, Pexels, Openverse & Giphy v1.0.8
1.2.0 trunk 1.0.11 1.0.8 1.0.9 1.1.0
image-hub / inc / src / Admin.php

Admin.php in Image Hub – Free Images from Unsplash, Pixabay, Pexels, Openverse & Giphy 1.0.8, at inc/src/Admin.php

70 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageHub;
4
5 use ImageHub\Utils;
6
7 class Admin {
8
9 protected $settings;
10
11 public function __construct($settings) {
12 $this->settings = $settings;
13
14 add_action('admin_menu', array($this, 'image_hub_add_admin_media_page'));
15 add_action('admin_enqueue_scripts', array($this, 'image_hub_enqueue_admin_assets'));
16
17 add_action('current_screen', function () {
18 $screen = get_current_screen();
19 if ($screen && str_contains((string)$screen->id, 'image-hub')) {
20 add_filter('admin_footer_text', array($this, 'image_hub_remove_footer_admin'));
21 }
22 });
23 }
24
25 public function image_hub_add_admin_media_page() {
26 add_media_page(
27 'Image Hub',
28 'Image Hub',
29 'manage_options',
30 'image-hub-media-tab',
31 array($this, 'image_hub_admin_media_page_content')
32 );
33 }
34
35 public function image_hub_admin_media_page_content() {
36 ?>
37 <div class="wrap">
38 <div id="image-hub-root"></div>
39 </div>
40 <?php
41 }
42
43 public function image_hub_enqueue_admin_assets($hook) {
44 if ('media_page_image-hub-media-tab' !== $hook) {
45 return;
46 }
47
48 wp_enqueue_style(
49 'image-hub-style',
50 IMAGE_HUB_ROOT_URL . '/assets/css/index.css',
51 array(),
52 Utils::get_version()
53 );
54
55 Utils::enque_image_hub_script('admin', true);
56
57 wp_enqueue_style('wp-components');
58 wp_localize_script('image-hub-admin', 'image_hub_settings', $this->settings);
59
60 Utils::localize_props('image-hub-admin');
61
62 wp_set_script_translations('image-hub-admin', 'image-hub');
63 }
64
65 public function image_hub_remove_footer_admin() {
66
67 return __('Image Hub – Discover and download beautiful images from free sources with ease.','image-hub');
68 }
69 }
70