PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.0.0
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.0.0
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 2.0.0, at admin/admin.php

198 lines 4.6 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 * Insert missing plugin options.
26 *
27 * @since 1.6.4
28 */
29 public function insert_missing_options() {
30 if ( AYG_VERSION !== get_option( 'ayg_version' ) ) {
31 $defaults = ayg_get_default_settings();
32
33 // Update the plugin version
34 update_option( 'ayg_version', AYG_VERSION );
35
36 // Insert the livestream settings
37 if ( false == get_option( 'ayg_livestream_settings' ) ) {
38 add_option( 'ayg_livestream_settings', $defaults['ayg_livestream_settings'] );
39 }
40
41 // Insert the privacy settings
42 if ( false == get_option( 'ayg_privacy_settings' ) ) {
43 add_option( 'ayg_privacy_settings', $defaults['ayg_privacy_settings'] );
44 }
45 }
46 }
47
48 /**
49 * Enqueue styles for the admin area.
50 *
51 * @since 1.0.0
52 */
53 public function enqueue_styles() {
54 wp_enqueue_style( 'wp-color-picker' );
55
56 wp_enqueue_style(
57 AYG_SLUG . '-admin',
58 AYG_URL . 'admin/assets/css/admin.css',
59 array(),
60 AYG_VERSION,
61 'all'
62 );
63 }
64
65 /**
66 * Enqueue scripts for the admin area.
67 *
68 * @since 1.0.0
69 */
70 public function enqueue_scripts() {
71 wp_enqueue_media();
72 wp_enqueue_script( 'wp-color-picker' );
73
74 wp_enqueue_script(
75 AYG_SLUG . '-admin',
76 AYG_URL . 'admin/assets/js/admin.js',
77 array( 'jquery' ),
78 AYG_VERSION,
79 false
80 );
81
82 wp_localize_script(
83 AYG_SLUG . '-admin',
84 'ayg_admin',
85 array(
86 'ajax_nonce' => wp_create_nonce( 'ayg_ajax_nonce' ),
87 'i18n' => array(
88 'invalid_api_key' => __( 'Invalid API Key', 'automatic-youtube-gallery' ),
89 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
90 )
91 )
92 );
93 }
94
95 /**
96 * Add dashboard page link on the plugins menu.
97 *
98 * @since 1.0.0
99 * @param array $links An array of plugin action links.
100 * @return string $links Array of filtered plugin action links.
101 */
102 public function plugin_action_links( $links ) {
103 $dashboard_link = sprintf(
104 '<a href="%s">%s</a>',
105 admin_url( 'admin.php?page=automatic-youtube-gallery' ),
106 __( 'Build Gallery', 'automatic-youtube-gallery' )
107 );
108
109 array_unshift( $links, $dashboard_link );
110
111 return $links;
112 }
113
114 /**
115 * Add "Dashboard" menu.
116 *
117 * @since 1.3.0
118 */
119 public function admin_menu() {
120 add_menu_page(
121 __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
122 __( 'YouTube Gallery', 'automatic-youtube-gallery' ),
123 'manage_options',
124 'automatic-youtube-gallery',
125 array( $this, 'display_dashboard_content' ),
126 'dashicons-video-alt3',
127 10
128 );
129
130 add_submenu_page(
131 'automatic-youtube-gallery',
132 __( 'Dashboard', 'automatic-youtube-gallery' ),
133 __( 'Dashboard', 'automatic-youtube-gallery' ),
134 'manage_options',
135 'automatic-youtube-gallery',
136 array( $this, 'display_dashboard_content' )
137 );
138 }
139
140 /**
141 * Display dashboard content.
142 *
143 * @since 1.3.0
144 */
145 public function display_dashboard_content() {
146 $general_settings = get_option( 'ayg_general_settings' );
147
148 $tabs = array(
149 'dashboard' => __( 'Build Gallery', 'automatic-youtube-gallery' )
150 );
151
152 $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
153
154 require_once AYG_DIR . 'admin/templates/dashboard.php';
155 }
156
157 /**
158 * Prints admin screen notices.
159 *
160 * @since 2.0.0
161 */
162 public function admin_notices() {
163 $general_settings = get_option( 'ayg_general_settings' );
164
165 if ( isset( $general_settings['development_mode'] ) && ! empty( $general_settings['development_mode'] ) ) {
166 ?>
167 <div class="notice notice-info">
168 <p>
169 <?php
170 printf(
171 __( '<strong>Automatic YouTube Gallery:</strong> You have <a href="%s">development mode</a> enabled. We do not cache API results in this mode. While this is ok when you are testing the plugin, we strongly recommend disabling this option when your site goes live.', 'automatic-youtube-gallery' ),
172 esc_url( admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) )
173 );
174 ?>
175 </p>
176 </div>
177 <?php
178 }
179 }
180
181 /**
182 * Save API Key.
183 *
184 * @since 1.3.0
185 */
186 public function ajax_callback_save_api_key() {
187 check_ajax_referer( 'ayg_ajax_nonce', 'security' );
188
189 $general_settings = get_option( 'ayg_general_settings' );
190 $general_settings['api_key'] = sanitize_text_field( $_POST['api_key'] );
191
192 update_option( 'ayg_general_settings', $general_settings );
193
194 wp_die();
195 }
196
197 }
198