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

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