PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.6.4
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.6.4
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
← All changes | admin/admin.php +157 -35 1.2.02.6.4 View file →
@@ -21,8 +21,63 @@
21 21 */
22 22 class AYG_Admin {
23 23
24 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 strings settings
34 + if ( false == get_option( 'ayg_strings_settings' ) ) {
35 + $gallery_settings = get_option( 'ayg_gallery_settings' );
36 +
37 + $strings_settings = array(
38 + 'more_button_label' => ! empty( $gallery_settings['more_button_label'] ) ? $gallery_settings['more_button_label'] : $defaults['ayg_strings_settings']['more_button_label'],
39 + 'previous_button_label' => ! empty( $gallery_settings['previous_button_label'] ) ? $gallery_settings['previous_button_label'] : $defaults['ayg_strings_settings']['previous_button_label'],
40 + 'next_button_label' => ! empty( $gallery_settings['next_button_label'] ) ? $gallery_settings['next_button_label'] : $defaults['ayg_strings_settings']['next_button_label'],
41 + 'show_more_label' => $defaults['ayg_strings_settings']['show_more_label'],
42 + 'show_less_label' => $defaults['ayg_strings_settings']['show_less_label'],
43 + );
44 +
45 + add_option( 'ayg_strings_settings', $strings_settings );
46 + }
47 +
48 + // Update the player settings
49 + $player_settings = get_option( 'ayg_player_settings' );
50 +
51 + if ( ! array_key_exists( 'player_type', $player_settings ) ) {
52 + $player_settings['player_type'] = $defaults['ayg_player_settings']['player_type'];
53 + $player_settings['player_color'] = $defaults['ayg_player_settings']['player_color'];
54 +
55 + update_option( 'ayg_player_settings', $player_settings );
56 + }
57 +
58 + // Insert the livestream settings
59 + if ( false == get_option( 'ayg_livestream_settings' ) ) {
60 + add_option( 'ayg_livestream_settings', $defaults['ayg_livestream_settings'] );
61 + }
62 +
63 + // Insert the privacy settings
64 + if ( false == get_option( 'ayg_privacy_settings' ) ) {
65 + add_option( 'ayg_privacy_settings', $defaults['ayg_privacy_settings'] );
66 + }
67 +
68 + // Create custom database tables
69 + ayg_db_create_custom_tables();
70 +
71 + // Delete the plugin cache
72 + ayg_delete_cache();
73 +
74 + // Update the plugin version
75 + update_option( 'ayg_version', AYG_VERSION );
76 + }
77 + }
78 +
79 + /**
25 80 * Enqueue styles for the admin area.
26 81 *
27 82 * @since 1.0.0
28 83 */
@@ -29,10 +84,18 @@
29 84 public function enqueue_styles() {
30 85 wp_enqueue_style( 'wp-color-picker' );
31 86
32 87 wp_enqueue_style(
88 + AYG_SLUG . '-magnific-popup',
89 + AYG_URL . 'vendor/magnific-popup/magnific-popup.css',
90 + array(),
91 + '1.2.0',
92 + 'all'
93 + );
94 +
95 + wp_enqueue_style(
33 96 AYG_SLUG . '-admin',
34 - AYG_URL . 'admin/assets/css/admin.css',
97 + AYG_URL . 'admin/assets/css/admin.min.css',
35 98 array(),
36 99 AYG_VERSION,
37 100 'all'
38 101 );
@@ -47,10 +110,18 @@
47 110 wp_enqueue_media();
48 111 wp_enqueue_script( 'wp-color-picker' );
49 112
50 113 wp_enqueue_script(
114 + AYG_SLUG . '-magnific-popup',
115 + AYG_URL . 'vendor/magnific-popup/magnific-popup.min.js',
116 + array( 'jquery' ),
117 + '1.2.0',
118 + array( 'strategy' => 'defer' )
119 + );
120 +
121 + wp_enqueue_script(
51 122 AYG_SLUG . '-admin',
52 - AYG_URL . 'admin/assets/js/admin.js',
123 + AYG_URL . 'admin/assets/js/admin.min.js',
53 124 array( 'jquery' ),
54 125 AYG_VERSION,
55 126 false
56 127 );
@@ -58,17 +129,19 @@
58 129 wp_localize_script(
59 130 AYG_SLUG . '-admin',
60 131 'ayg_admin',
61 132 array(
62 - 'i18n' => array(
63 - 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
64 - )
133 + 'ajax_nonce' => wp_create_nonce( 'ayg_ajax_nonce' ),
134 + 'i18n' => array(
135 + 'invalid_api_key' => __( 'Invalid API Key', 'automatic-youtube-gallery' ),
136 + 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
137 + )
65 138 )
66 139 );
67 140 }
68 141
69 142 /**
70 - * Add settings page link on the plugins menu.
143 + * Add dashboard page link on the plugins menu.
71 144 *
72 145 * @since 1.0.0
73 146 * @param array $links An array of plugin action links.
74 147 * @return string $links Array of filtered plugin action links.
@@ -73,52 +146,101 @@
73 146 * @param array $links An array of plugin action links.
74 147 * @return string $links Array of filtered plugin action links.
75 148 */
76 149 public function plugin_action_links( $links ) {
77 - $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=automatic-youtube-gallery' ), __( 'Settings', 'automatic-youtube-gallery' ) );
78 - array_unshift( $links, $settings_link );
150 + $dashboard_link = sprintf(
151 + '<a href="%s">%s</a>',
152 + admin_url( 'admin.php?page=automatic-youtube-gallery' ),
153 + __( 'Build Gallery', 'automatic-youtube-gallery' )
154 + );
79 155
156 + array_unshift( $links, $dashboard_link );
157 +
80 158 return $links;
81 159 }
82 160
83 161 /**
84 - * Display admin notice.
162 + * Add "Dashboard" menu.
85 163 *
86 - * @since 1.0.0
164 + * @since 1.3.0
87 165 */
88 - public function admin_notice() {
89 - $screen = get_current_screen();
166 + public function admin_menu() {
167 + add_menu_page(
168 + __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
169 + __( 'YouTube Gallery', 'automatic-youtube-gallery' ),
170 + 'manage_options',
171 + 'automatic-youtube-gallery',
172 + array( $this, 'display_dashboard_content' ),
173 + 'dashicons-video-alt3',
174 + 10
175 + );
90 176
91 - $post_type = $screen->post_type;
92 - if ( 'post' == $post_type || 'page' == $post_type ) {
93 - return;
94 - }
177 + add_submenu_page(
178 + 'automatic-youtube-gallery',
179 + __( 'Dashboard', 'automatic-youtube-gallery' ),
180 + __( 'Dashboard', 'automatic-youtube-gallery' ),
181 + 'manage_options',
182 + 'automatic-youtube-gallery',
183 + array( $this, 'display_dashboard_content' )
184 + );
185 + }
186 +
187 + /**
188 + * Display dashboard content.
189 + *
190 + * @since 1.3.0
191 + */
192 + public function display_dashboard_content() {
193 + $general_settings = get_option( 'ayg_general_settings' );
194 +
195 + $tabs = array(
196 + 'dashboard' => __( 'Build Gallery', 'automatic-youtube-gallery' )
197 + );
95 198
96 - if ( false == get_option( 'ayg_admin_notice_dismissed' ) ) : ?>
97 - <div id="ayg-admin-notice" class="notice notice-info is-dismissible" data-security="<?php echo wp_create_nonce( 'ayg_admin_notice_nonce' ); ?>">
199 + $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
200 +
201 + require_once AYG_DIR . 'admin/templates/dashboard.php';
202 + }
203 +
204 + /**
205 + * Prints admin screen notices.
206 + *
207 + * @since 2.0.0
208 + */
209 + public function admin_notices() {
210 + $general_settings = get_option( 'ayg_general_settings' );
211 +
212 + if ( isset( $general_settings['development_mode'] ) && ! empty( $general_settings['development_mode'] ) ) {
213 + ?>
214 + <div class="notice notice-info">
98 215 <p>
99 - <span class="dashicons-before dashicons-video-alt3"></span> <strong><?php _e( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ); ?></strong>:
100 - <a href="https://plugins360.com/automatic-youtube-gallery/documentation/" target="_blank"><?php _e( 'Getting Started', 'automatic-youtube-gallery' ); ?></a>
101 - <span class="ayg-admin-notice-separator"> | </span>
102 - <a href="<?php echo admin_url( 'admin.php?page=automatic-youtube-gallery-contact' ); ?>"><?php _e( 'Contact Us', 'automatic-youtube-gallery' ); ?></a>
103 - <?php if ( ayg_fs()->is_not_paying() ) : ?>
104 - <span class="ayg-admin-notice-separator"> | </span>
105 - <a href="<?php echo ayg_fs()->get_upgrade_url(); ?>" class="ayg-admin-notice-link-premium"><?php _e( 'Upgrade Pro', 'automatic-youtube-gallery' ); ?></a>
106 - <?php endif; ?>
107 - </p>
108 - </div>
109 - <?php endif;
216 + <?php
217 + printf(
218 + __( '<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' ),
219 + esc_url( admin_url( 'admin.php?page=automatic-youtube-gallery-settings' ) )
220 + );
221 + ?>
222 + </p>
223 + </div>
224 + <?php
225 + }
110 226 }
111 227
112 228 /**
113 - * Dismiss admin notice.
229 + * Save API Key.
114 230 *
115 - * @since 1.0.0
231 + * @since 1.3.0
116 232 */
117 - public function ajax_callback_dismiss_admin_notice() {
118 - check_ajax_referer( 'ayg_admin_notice_nonce', 'security' );
233 + public function ajax_callback_save_api_key() {
234 + check_ajax_referer( 'ayg_ajax_nonce', 'security' );
119 235
120 - add_option( 'ayg_admin_notice_dismissed', 1 );
236 + if ( current_user_can( 'manage_options' ) ) {
237 + $general_settings = get_option( 'ayg_general_settings' );
238 + $general_settings['api_key'] = sanitize_text_field( $_POST['api_key'] );
239 +
240 + update_option( 'ayg_general_settings', $general_settings );
241 + }
242 +
121 243 wp_die();
122 - }
244 + }
123 245
124 246 }