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

164 lines 3.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 }
42
43 /**
44 * Enqueue styles for the admin area.
45 *
46 * @since 1.0.0
47 */
48 public function enqueue_styles() {
49 wp_enqueue_style( 'wp-color-picker' );
50
51 wp_enqueue_style(
52 AYG_SLUG . '-admin',
53 AYG_URL . 'admin/assets/css/admin.css',
54 array(),
55 AYG_VERSION,
56 'all'
57 );
58 }
59
60 /**
61 * Enqueue scripts for the admin area.
62 *
63 * @since 1.0.0
64 */
65 public function enqueue_scripts() {
66 wp_enqueue_media();
67 wp_enqueue_script( 'wp-color-picker' );
68
69 wp_enqueue_script(
70 AYG_SLUG . '-admin',
71 AYG_URL . 'admin/assets/js/admin.js',
72 array( 'jquery' ),
73 AYG_VERSION,
74 false
75 );
76
77 wp_localize_script(
78 AYG_SLUG . '-admin',
79 'ayg_admin',
80 array(
81 'i18n' => array(
82 'invalid_api_key' => __( 'Invalid API Key', 'automatic-youtube-gallery' ),
83 'cleared' => __( 'Cleared', 'automatic-youtube-gallery' )
84 ),
85 'ajax_nonce' => wp_create_nonce( 'ayg_admin_ajax_nonce' )
86 )
87 );
88 }
89
90 /**
91 * Add dashboard page link on the plugins menu.
92 *
93 * @since 1.0.0
94 * @param array $links An array of plugin action links.
95 * @return string $links Array of filtered plugin action links.
96 */
97 public function plugin_action_links( $links ) {
98 $dashboard_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=automatic-youtube-gallery' ), __( 'Build Gallery', 'automatic-youtube-gallery' ) );
99 array_unshift( $links, $dashboard_link );
100
101 return $links;
102 }
103
104 /**
105 * Add "Dashboard" menu.
106 *
107 * @since 1.3.0
108 */
109 public function admin_menu() {
110 add_menu_page(
111 __( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ),
112 __( 'YouTube Gallery', 'automatic-youtube-gallery' ),
113 'manage_options',
114 'automatic-youtube-gallery',
115 array( $this, 'display_dashboard_content' ),
116 'dashicons-video-alt3',
117 10
118 );
119
120 add_submenu_page(
121 'automatic-youtube-gallery',
122 __( 'Dashboard', 'automatic-youtube-gallery' ),
123 __( 'Dashboard', 'automatic-youtube-gallery' ),
124 'manage_options',
125 'automatic-youtube-gallery',
126 array( $this, 'display_dashboard_content' )
127 );
128 }
129
130 /**
131 * Display dashboard content.
132 *
133 * @since 1.3.0
134 */
135 public function display_dashboard_content() {
136 $general_settings = get_option( 'ayg_general_settings', array() );
137
138 $tabs = array(
139 'dashboard' => __( 'Build Gallery', 'automatic-youtube-gallery' )
140 );
141
142 $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'dashboard';
143
144 require_once AYG_DIR . 'admin/templates/dashboard.php';
145 }
146
147 /**
148 * Save API Key.
149 *
150 * @since 1.3.0
151 */
152 public function ajax_callback_save_api_key() {
153 check_ajax_referer( 'ayg_admin_ajax_nonce', 'security' );
154
155 $general_settings = get_option( 'ayg_general_settings', array() );
156 $general_settings['api_key'] = sanitize_text_field( $_POST['api_key'] );
157
158 update_option( 'ayg_general_settings', $general_settings );
159
160 wp_die();
161 }
162
163 }
164