| 1 |
<?php |
| 2 |
|
| 3 |
class Meow_MGL_Admin extends MeowCommon_Admin { |
| 4 |
|
| 5 |
public function __construct() { |
| 6 |
parent::__construct( MGL_PREFIX, MGL_ENTRY, MGL_DOMAIN, class_exists( 'MeowPro_MGL_Core' ) ); |
| 7 |
add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| 8 |
$blocks_enabled = function_exists( 'register_block_type' ); |
| 9 |
if ( $blocks_enabled ) { |
| 10 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| 11 |
} |
| 12 |
if ( get_option( 'mgl_captions', 'notset' ) === 'notset' ) { |
| 13 |
$captions_enabled = get_option( 'mgl_captions_enabled' ); |
| 14 |
update_option( 'mgl_captions', $captions_enabled ? 'hover-only' : false ); |
| 15 |
delete_option( 'mgl_captions_enabled' ); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
public function mgl_settings() { |
| 20 |
echo '<div id="mgl-admin-settings"></div>'; |
| 21 |
} |
| 22 |
|
| 23 |
function enqueue_scripts() { |
| 24 |
|
| 25 |
// Javascript for gallery |
| 26 |
$physical_file = MGL_PATH . '/app/galleries.js'; |
| 27 |
$cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MGL_VERSION; |
| 28 |
wp_register_script( 'mgl-gallery-js', plugins_url( '/app/galleries.js', __DIR__ ), |
| 29 |
array(), $cache_buster, false ); |
| 30 |
|
| 31 |
// Load the "admin" scripts |
| 32 |
$physical_file = MGL_PATH . '/app/admin.js'; |
| 33 |
$cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MGL_VERSION; |
| 34 |
wp_register_script( 'mgl-admin-js', MGL_URL . '/app/admin.js', |
| 35 |
array( 'mgl-gallery-js', 'wp-editor', 'wp-i18n', 'wp-element' ), $cache_buster ); |
| 36 |
register_block_type( 'meow-gallery/gallery', array( 'editor_script' => 'mgl-admin-js' )); |
| 37 |
|
| 38 |
// Load the fonts |
| 39 |
wp_register_style( 'meow-neko-ui-lato-font', '//fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900&display=swap'); |
| 40 |
wp_enqueue_style( 'meow-neko-ui-lato-font' ); |
| 41 |
|
| 42 |
// Localize and options |
| 43 |
global $wplr; |
| 44 |
wp_localize_script( 'mgl-admin-js', 'mgl_meow_gallery', array_merge( [ |
| 45 |
//'api_nonce' => wp_create_nonce( 'mfrh_media_file_renamer' ), |
| 46 |
'api_url' => get_rest_url( null, '/meow-gallery/v1/' ), |
| 47 |
'rest_url' => get_rest_url(), |
| 48 |
'plugin_url' => MGL_URL, |
| 49 |
'prefix' => MGL_PREFIX, |
| 50 |
'domain' => MGL_DOMAIN, |
| 51 |
'is_pro' => class_exists( 'MeowPro_MGL_Core' ), |
| 52 |
'is_registered' => !!$this->is_registered(), |
| 53 |
'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
| 54 |
'wplr_collections' => $wplr ? $wplr->read_collections_recursively() : [], |
| 55 |
] ) ); |
| 56 |
|
| 57 |
wp_enqueue_script( 'mgl-admin-js' ); |
| 58 |
} |
| 59 |
|
| 60 |
function app_menu() { |
| 61 |
add_submenu_page( 'meowapps-main-menu', __( 'Gallery', MGL_DOMAIN ), __( 'Gallery', MGL_DOMAIN ), |
| 62 |
'manage_options', 'mgl_settings', array( $this, 'mgl_settings' ) |
| 63 |
); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
?> |
| 68 |
|