PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 1.6.2
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v1.6.2
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
automatic-youtube-gallery / admin / admin.php

admin.php in Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels 1.6.2, at admin/admin.php

145 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link https://plugins360.com
7 * @since 1.0.0
8 *
9 * @package Automatic_YouTube_Gallery
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 /**
18 * AYG_Admin class.
19 *
20 * @since 1.0.0
21 */
22 class AYG_Admin {
23
24 /**
25 * Enqueue styles for the admin area.
26 *
27 * @since 1.0.0
28 */
29 public function enqueue_styles() {
30 wp_enqueue_style( 'wp-color-picker' );
31
32 wp_enqueue_style(
33 AYG_SLUG . '-admin',
34 AYG_URL . 'admin/assets/css/admin.css',
35 array(),
36 AYG_VERSION,
37 'all'
38 );
39 }
40
41 /**
42 * Enqueue scripts for the admin area.
43 *
44 * @since 1.0.0
45 */
46 public function enqueue_scripts() {
47 wp_enqueue_media();
48 wp_enqueue_script( 'wp-color-picker' );
49
50 wp_enqueue_script(
51 AYG_SLUG . '-admin',
52 AYG_URL . 'admin/assets/js/admin.js',
53 array( 'jquery' ),
54 AYG_VERSION,
55 false
56 );
57
58 wp_localize_script(
59 AYG_SLUG . '-admin',
60 'ayg_admin',
61 array(
62 'i18n' => array(
63 'invalid_api_key' => __( 'Invalid API Key', 'automatic-youtube-gallery' ),
64 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
65 ),
66 'ajax_nonce' => wp_create_nonce( 'ayg_admin_ajax_nonce' )
67 )
68 );
69 }
70
71 /**
72 * Add dashboard page link on the plugins menu.
73 *
74 * @since 1.0.0
75 * @param array $links An array of plugin action links.
76 * @return string $links Array of filtered plugin action links.
77 */
78 public function plugin_action_links( $links ) {
79 $dashboard_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=automatic-youtube-gallery' ), __( 'Build Gallery', 'automatic-youtube-gallery' ) );
80 array_unshift( $links, $dashboard_link );
81
82 return $links;
83 }
84
85 /**
86 * Add "Dashboard" menu.
87 *
88 * @since 1.3.0
89 */
90 public function admin_menu() {
91 add_menu_page(
92 __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
93 __( 'YouTube Gallery', 'automatic-youtube-gallery' ),
94 'manage_options',
95 'automatic-youtube-gallery',
96 array( $this, 'display_dashboard_content' ),
97 'dashicons-video-alt3',
98 10
99 );
100
101 add_submenu_page(
102 'automatic-youtube-gallery',
103 __( 'Dashboard', 'automatic-youtube-gallery' ),
104 __( 'Dashboard', 'automatic-youtube-gallery' ),
105 'manage_options',
106 'automatic-youtube-gallery',
107 array( $this, 'display_dashboard_content' )
108 );
109 }
110
111 /**
112 * Display dashboard content.
113 *
114 * @since 1.3.0
115 */
116 public function display_dashboard_content() {
117 $general_settings = get_option( 'ayg_general_settings', array() );
118
119 $tabs = array(
120 'dashboard' => __( 'Build Gallery', 'automatic-youtube-gallery' )
121 );
122
123 $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
124
125 require_once AYG_DIR . 'admin/templates/dashboard.php';
126 }
127
128 /**
129 * Save API Key.
130 *
131 * @since 1.3.0
132 */
133 public function ajax_callback_save_api_key() {
134 check_ajax_referer( 'ayg_admin_ajax_nonce', 'security' );
135
136 $general_settings = get_option( 'ayg_general_settings', array() );
137 $general_settings['api_key'] = sanitize_text_field( $_POST['api_key'] );
138
139 update_option( 'ayg_general_settings', $general_settings );
140
141 wp_die();
142 }
143
144 }
145