| @@ -27,13 +27,35 @@ | ||
| 27 | 27 | * @since 1.6.4 |
| 28 | 28 | */ |
| 29 | 29 | public function insert_missing_options() { |
| 30 | 30 | if ( AYG_VERSION !== get_option( 'ayg_version' ) ) { |
| 31 | - $defaults = ayg_get_default_settings(); | |
| 31 | + $defaults = ayg_get_default_settings(); | |
| 32 | 32 | |
| 33 | - // Update the plugin version | |
| 34 | - update_option( 'ayg_version', AYG_VERSION ); | |
| 33 | + // Insert the strings settings | |
| 34 | + if ( false == get_option( 'ayg_strings_settings' ) ) { | |
| 35 | + $gallery_settings = get_option( 'ayg_gallery_settings' ); | |
| 35 | 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 | + | |
| 36 | 58 | // Insert the livestream settings |
| 37 | 59 | if ( false == get_option( 'ayg_livestream_settings' ) ) { |
| 38 | 60 | add_option( 'ayg_livestream_settings', $defaults['ayg_livestream_settings'] ); |
| 39 | 61 | } |
| @@ -41,8 +63,17 @@ | ||
| 41 | 63 | // Insert the privacy settings |
| 42 | 64 | if ( false == get_option( 'ayg_privacy_settings' ) ) { |
| 43 | 65 | add_option( 'ayg_privacy_settings', $defaults['ayg_privacy_settings'] ); |
| 44 | 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 ); | |
| 45 | 76 | } |
| 46 | 77 | } |
| 47 | 78 | |
| 48 | 79 | /** |
| @@ -53,10 +84,18 @@ | ||
| 53 | 84 | public function enqueue_styles() { |
| 54 | 85 | wp_enqueue_style( 'wp-color-picker' ); |
| 55 | 86 | |
| 56 | 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( | |
| 57 | 96 | AYG_SLUG . '-admin', |
| 58 | - AYG_URL . 'admin/assets/css/admin.css', | |
| 97 | + AYG_URL . 'admin/assets/css/admin.min.css', | |
| 59 | 98 | array(), |
| 60 | 99 | AYG_VERSION, |
| 61 | 100 | 'all' |
| 62 | 101 | ); |
| @@ -71,10 +110,18 @@ | ||
| 71 | 110 | wp_enqueue_media(); |
| 72 | 111 | wp_enqueue_script( 'wp-color-picker' ); |
| 73 | 112 | |
| 74 | 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( | |
| 75 | 122 | AYG_SLUG . '-admin', |
| 76 | - AYG_URL . 'admin/assets/js/admin.js', | |
| 123 | + AYG_URL . 'admin/assets/js/admin.min.js', | |
| 77 | 124 | array( 'jquery' ), |
| 78 | 125 | AYG_VERSION, |
| 79 | 126 | false |
| 80 | 127 | ); |
| @@ -185,12 +232,14 @@ | ||
| 185 | 232 | */ |
| 186 | 233 | public function ajax_callback_save_api_key() { |
| 187 | 234 | check_ajax_referer( 'ayg_ajax_nonce', 'security' ); |
| 188 | 235 | |
| 189 | - $general_settings = get_option( 'ayg_general_settings' ); | |
| 190 | - $general_settings['api_key'] = sanitize_text_field( $_POST['api_key'] ); | |
| 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'] ); | |
| 191 | 239 | |
| 192 | - update_option( 'ayg_general_settings', $general_settings ); | |
| 240 | + update_option( 'ayg_general_settings', $general_settings ); | |
| 241 | + } | |
| 193 | 242 | |
| 194 | 243 | wp_die(); |
| 195 | 244 | } |
| 196 | 245 | |