PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.8
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.8
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 +118 -35 1.2.02.3.8 View file →
@@ -21,8 +21,40 @@
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 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 + /**
25 57 * Enqueue styles for the admin area.
26 58 *
27 59 * @since 1.0.0
28 60 */
@@ -30,9 +62,9 @@
30 62 wp_enqueue_style( 'wp-color-picker' );
31 63
32 64 wp_enqueue_style(
33 65 AYG_SLUG . '-admin',
34 - AYG_URL . 'admin/assets/css/admin.css',
66 + AYG_URL . 'admin/assets/css/admin.min.css',
35 67 array(),
36 68 AYG_VERSION,
37 69 'all'
38 70 );
@@ -48,9 +80,9 @@
48 80 wp_enqueue_script( 'wp-color-picker' );
49 81
50 82 wp_enqueue_script(
51 83 AYG_SLUG . '-admin',
52 - AYG_URL . 'admin/assets/js/admin.js',
84 + AYG_URL . 'admin/assets/js/admin.min.js',
53 85 array( 'jquery' ),
54 86 AYG_VERSION,
55 87 false
56 88 );
@@ -58,17 +90,19 @@
58 90 wp_localize_script(
59 91 AYG_SLUG . '-admin',
60 92 'ayg_admin',
61 93 array(
62 - 'i18n' => array(
63 - 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
64 - )
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 + )
65 99 )
66 100 );
67 101 }
68 102
69 103 /**
70 - * Add settings page link on the plugins menu.
104 + * Add dashboard page link on the plugins menu.
71 105 *
72 106 * @since 1.0.0
73 107 * @param array $links An array of plugin action links.
74 108 * @return string $links Array of filtered plugin action links.
@@ -73,52 +107,101 @@
73 107 * @param array $links An array of plugin action links.
74 108 * @return string $links Array of filtered plugin action links.
75 109 */
76 110 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 );
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 + );
79 116
117 + array_unshift( $links, $dashboard_link );
118 +
80 119 return $links;
81 120 }
82 121
83 122 /**
84 - * Display admin notice.
123 + * Add "Dashboard" menu.
85 124 *
86 - * @since 1.0.0
125 + * @since 1.3.0
87 126 */
88 - public function admin_notice() {
89 - $screen = get_current_screen();
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 + );
90 137
91 - $post_type = $screen->post_type;
92 - if ( 'post' == $post_type || 'page' == $post_type ) {
93 - return;
94 - }
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 + );
95 159
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' ); ?>">
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">
98 176 <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;
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 + }
110 187 }
111 188
112 189 /**
113 - * Dismiss admin notice.
190 + * Save API Key.
114 191 *
115 - * @since 1.0.0
192 + * @since 1.3.0
116 193 */
117 - public function ajax_callback_dismiss_admin_notice() {
118 - check_ajax_referer( 'ayg_admin_notice_nonce', 'security' );
194 + public function ajax_callback_save_api_key() {
195 + check_ajax_referer( 'ayg_ajax_nonce', 'security' );
119 196
120 - add_option( 'ayg_admin_notice_dismissed', 1 );
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 +
121 204 wp_die();
122 - }
205 + }
123 206
124 207 }