| 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 |
* @subpackage Automatic_YouTube_Gallery/admin |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly |
| 14 |
if ( ! defined( 'WPINC' ) ) { |
| 15 |
die; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* AYG_Admin class. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
*/ |
| 23 |
class AYG_Admin { |
| 24 |
|
| 25 |
/** |
| 26 |
* Enqueue styles for the admin area. |
| 27 |
* |
| 28 |
* @since 1.0.0 |
| 29 |
*/ |
| 30 |
public function enqueue_styles() { |
| 31 |
|
| 32 |
wp_enqueue_style( 'wp-color-picker' ); |
| 33 |
|
| 34 |
wp_enqueue_style( |
| 35 |
AYG_SLUG . '-admin', |
| 36 |
AYG_URL . 'admin/assets/css/admin.css', |
| 37 |
array(), |
| 38 |
AYG_VERSION, |
| 39 |
'all' |
| 40 |
); |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Enqueue scripts for the admin area. |
| 46 |
* |
| 47 |
* @since 1.0.0 |
| 48 |
*/ |
| 49 |
public function enqueue_scripts() { |
| 50 |
|
| 51 |
wp_enqueue_media(); |
| 52 |
wp_enqueue_script( 'wp-color-picker' ); |
| 53 |
|
| 54 |
wp_enqueue_script( |
| 55 |
AYG_SLUG . '-admin', |
| 56 |
AYG_URL . 'admin/assets/js/admin.js', |
| 57 |
array( 'jquery' ), |
| 58 |
AYG_VERSION, |
| 59 |
false |
| 60 |
); |
| 61 |
|
| 62 |
wp_localize_script( |
| 63 |
AYG_SLUG . '-admin', |
| 64 |
'ayg_admin', |
| 65 |
array( |
| 66 |
'i18n' => array( |
| 67 |
'cleared' => __( 'Cleared', 'automatic-youtube-gallery' ) |
| 68 |
) |
| 69 |
) |
| 70 |
); |
| 71 |
|
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Add settings page link on the plugins menu. |
| 76 |
* |
| 77 |
* @since 1.0.0 |
| 78 |
* @param array $links An array of plugin action links. |
| 79 |
* @return string $links Array of filtered plugin action links. |
| 80 |
*/ |
| 81 |
public function plugin_action_links( $links ) { |
| 82 |
|
| 83 |
$settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=automatic-youtube-gallery' ), __( 'Settings', 'automatic-youtube-gallery' ) ); |
| 84 |
array_unshift( $links, $settings_link ); |
| 85 |
|
| 86 |
return $links; |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Display admin notice. |
| 92 |
* |
| 93 |
* @since 1.0.0 |
| 94 |
*/ |
| 95 |
public function admin_notice() { |
| 96 |
|
| 97 |
$screen = get_current_screen(); |
| 98 |
|
| 99 |
$post_type = $screen->post_type; |
| 100 |
if ( 'post' == $post_type || 'page' == $post_type ) { |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 104 |
if ( false == get_option( 'ayg_admin_notice_dismissed' ) ) : ?> |
| 105 |
<div id="ayg-admin-notice" class="notice notice-info is-dismissible" data-security="<?php echo wp_create_nonce( 'ayg_admin_notice_nonce' ); ?>"> |
| 106 |
<p> |
| 107 |
<span class="dashicons-before dashicons-video-alt3"></span> <strong><?php _e( 'Automatic YouTube Gallery', 'automatic-youtube-gallery' ); ?></strong>: |
| 108 |
<a href="https://plugins360.com/automatic-youtube-gallery/documentation/" target="_blank"><?php _e( 'Getting Started', 'automatic-youtube-gallery' ); ?></a> |
| 109 |
<span class="ayg-admin-notice-separator"> | </span> |
| 110 |
<a href="<?php echo admin_url( 'admin.php?page=automatic-youtube-gallery-contact' ); ?>"><?php _e( 'Contact Us', 'automatic-youtube-gallery' ); ?></a> |
| 111 |
<?php if ( ayg_fs()->is_not_paying() ) : ?> |
| 112 |
<span class="ayg-admin-notice-separator"> | </span> |
| 113 |
<a href="<?php echo ayg_fs()->get_upgrade_url(); ?>" class="ayg-admin-notice-link-premium"><?php _e( 'Upgrade Pro', 'automatic-youtube-gallery' ); ?></a> |
| 114 |
<?php endif; ?> |
| 115 |
</p> |
| 116 |
</div> |
| 117 |
<?php endif; |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* Dismiss admin notice. |
| 123 |
* |
| 124 |
* @since 1.0.0 |
| 125 |
*/ |
| 126 |
public function ajax_callback_dismiss_admin_notice() { |
| 127 |
|
| 128 |
check_ajax_referer( 'ayg_admin_notice_nonce', 'security' ); |
| 129 |
|
| 130 |
add_option( 'ayg_admin_notice_dismissed', 1 ); |
| 131 |
wp_die(); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
} |
| 136 |
|