PluginProbe
Image Hub – Free Images from Unsplash, Pixabay, Pexels, Openverse & Giphy / trunk
Image Hub – Free Images from Unsplash, Pixabay, Pexels, Openverse & Giphy vtrunk
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 trunk, at inc/src/Admin.php

88 lines 2.4 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 add_filter( 'plugin_row_meta', array($this, 'onUdatePluginBuild'), 10, 4 );
25 }
26
27 public function onUdatePluginBuild($plugin_meta, $plugin_file) {
28 $plugins_dir = trailingslashit(
29 wp_normalize_path( WP_CONTENT_DIR . '/plugins/' )
30 );
31 $image_hub_file = str_replace(
32 $plugins_dir,
33 '',
34 wp_normalize_path( IMAGE_HUB_ENTRY_FILE )
35 );
36 if ( $plugin_file === $image_hub_file ) {
37 $plugin_meta[0] =
38 "{$plugin_meta[0]} (build: " . IMAGE_HUB_BUILD_NUMBER . ')';
39 }
40
41 return $plugin_meta;
42 }
43 public function image_hub_add_admin_media_page() {
44 add_media_page(
45 'Image Hub',
46 'Image Hub',
47 'manage_options',
48 'image-hub-media-tab',
49 array($this, 'image_hub_admin_media_page_content')
50 );
51 }
52
53 public function image_hub_admin_media_page_content() {
54 ?>
55 <div class="wrap">
56 <div id="image-hub-root"></div>
57 </div>
58 <?php
59 }
60
61 public function image_hub_enqueue_admin_assets($hook) {
62 if ('media_page_image-hub-media-tab' !== $hook) {
63 return;
64 }
65
66 wp_enqueue_style(
67 'image-hub-style',
68 IMAGE_HUB_ROOT_URL . '/assets/css/index.css',
69 array(),
70 Utils::get_version()
71 );
72
73 Utils::enque_image_hub_script('admin', true);
74
75 wp_enqueue_style('wp-components');
76 wp_localize_script('image-hub-admin', 'image_hub_settings', $this->settings);
77
78 Utils::localize_props('image-hub-admin');
79
80 wp_set_script_translations('image-hub-admin', 'image-hub');
81 }
82
83 public function image_hub_remove_footer_admin() {
84
85 return __('Image Hub – Discover and download beautiful images from free sources with ease.','image-hub');
86 }
87 }
88