PluginProbe
Embed Privacy / 1.11.2
Embed Privacy v1.11.2
1.14.0 1.13.0 trunk 0.1 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.10 1.10.2 1.10.3 1.10.4 1.10.5 1.10.6 1.10.7 1.10.8 1.10.9 1.11.0 1.11.1 1.11.2 All 68 releases
embed-privacy / inc / admin / class-user-interface.php

class-user-interface.php in Embed Privacy 1.11.2, at inc/admin/class-user-interface.php

90 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace epiphyt\Embed_Privacy\admin;
3
4 use WP_Screen;
5
6 /**
7 * Admin user interface functionality.
8 *
9 * @author Epiphyt
10 * @license GPL2
11 * @package epiphyt\Embed_Privacy
12 * @since 1.10.0
13 */
14 final class User_Interface {
15 /**
16 * Initialize functions.
17 */
18 public static function init() {
19 \add_action( 'admin_enqueue_scripts', [ self::class, 'enqueue_assets' ] );
20 \add_filter( 'plugin_row_meta', [ self::class, 'add_meta_link' ], 10, 2 );
21 }
22
23 /**
24 * Add plugin meta links.
25 *
26 * @param array $input Registered links.
27 * @param string $file Current plugin file.
28 * @return array Merged links
29 */
30 public static function add_meta_link( $input, $file ) {
31 // bail on other plugins
32 if ( $file !== \plugin_basename( \EPI_EMBED_PRIVACY_BASE ) ) {
33 return $input;
34 }
35
36 return \array_merge(
37 $input,
38 [
39 '<a href="https://epiph.yt/en/embed-privacy/documentation/?version=' . \rawurlencode( \EMBED_PRIVACY_VERSION ) . '" target="_blank" rel="noopener noreferrer">' . \esc_html__( 'Documentation', 'embed-privacy' ) . '</a>',
40 ]
41 );
42 }
43
44 /**
45 * Enqueue admin assets.
46 *
47 * @param string $hook The current hook
48 */
49 public static function enqueue_assets( $hook ) {
50 $screen = \get_current_screen();
51 $suffix = \defined( 'WP_DEBUG' ) && \WP_DEBUG || \defined( 'SCRIPT_DEBUG' ) && \SCRIPT_DEBUG ? '' : '.min';
52
53 if ( ! $screen instanceof WP_Screen ) {
54 return;
55 }
56
57 if ( ( $hook === 'post.php' && $hook === 'post-new.php' ) || $screen->id === 'epi_embed' ) {
58 $script_path = \EPI_EMBED_PRIVACY_BASE . 'assets/js/admin/image-upload' . $suffix . '.js';
59 $script_url = \EPI_EMBED_PRIVACY_URL . 'assets/js/admin/image-upload' . $suffix . '.js';
60
61 \wp_enqueue_script( 'embed-privacy-admin-image-upload', $script_url, [ 'jquery' ], (string) \filemtime( $script_path ), true );
62
63 $style_path = \EPI_EMBED_PRIVACY_BASE . 'assets/style/embed-privacy-admin' . $suffix . '.css';
64 $style_url = \EPI_EMBED_PRIVACY_URL . 'assets/style/embed-privacy-admin' . $suffix . '.css';
65
66 \wp_enqueue_style( 'embed-privacy-admin-style', $style_url, [], (string) \filemtime( $style_path ) );
67 }
68
69 if ( $screen->id === 'settings_page_embed_privacy' ) {
70 $script_path = \EPI_EMBED_PRIVACY_BASE . 'assets/js/admin/clipboard' . $suffix . '.js';
71 $script_url = \EPI_EMBED_PRIVACY_URL . 'assets/js/admin/clipboard' . $suffix . '.js';
72
73 \wp_enqueue_script( 'embed-privacy-admin-clipboard', $script_url, [], (string) \filemtime( $script_path ), true );
74 \wp_localize_script(
75 'embed-privacy-admin-clipboard',
76 'embedPrivacyAdminSettings',
77 [
78 'supportDataCopiedToClipboardFailure' => \__( 'Support data could not be copied to clipboard!', 'embed-privacy' ),
79 'supportDataCopiedToClipboardSuccess' => \__( 'Support data copied to clipboard!', 'embed-privacy' ),
80 ]
81 );
82
83 $style_path = \EPI_EMBED_PRIVACY_BASE . 'assets/style/settings' . $suffix . '.css';
84 $style_url = \EPI_EMBED_PRIVACY_URL . 'assets/style/settings' . $suffix . '.css';
85
86 \wp_enqueue_style( 'embed-privacy-admin-settings', $style_url, [], (string) \filemtime( $style_path ) );
87 }
88 }
89 }
90