| @@ -1,9 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Meow_MGL_Admin extends MeowCommon_Admin { | |
| 3 | +class Meow_MGL_Admin extends MeowKit_MGL_Admin { | |
| 4 | 4 | |
| 5 | 5 | private $core; |
| 6 | + | |
| 6 | 7 | public function __construct($core) { |
| 7 | 8 | parent::__construct( MGL_PREFIX, MGL_ENTRY, MGL_DOMAIN, class_exists( 'MeowPro_MGL_Core' ) ); |
| 8 | 9 | $this->core = $core; |
| 9 | 10 | add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| @@ -8,9 +9,9 @@ | ||
| 8 | 9 | $this->core = $core; |
| 9 | 10 | add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| 10 | 11 | $blocks_enabled = function_exists( 'register_block_type' ); |
| 11 | 12 | if ( $blocks_enabled ) { |
| 12 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
| 13 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); | |
| 13 | 14 | } |
| 14 | 15 | $options = $this->core->get_all_options(); |
| 15 | 16 | if ( ( $options['captions'] ?? 'notset' ) === 'notset' ) { |
| 16 | 17 | // MEOMO: mgl_captions_enabled option is used only here. Also, it deletes soon after being used. |
| @@ -27,44 +28,14 @@ | ||
| 27 | 28 | public function mgl_settings() { |
| 28 | 29 | echo '<div id="mgl-admin-settings"></div>'; |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - function enqueue_scripts() { | |
| 32 | - | |
| 33 | - // Javascript for gallery | |
| 34 | - $physical_file = MGL_PATH . '/app/galleries.js'; | |
| 35 | - $cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MGL_VERSION; | |
| 36 | - wp_register_script( 'mgl-gallery-js', plugins_url( '/app/galleries.js', __DIR__ ), | |
| 37 | - array(), $cache_buster, false ); | |
| 38 | - | |
| 39 | - // Load the "admin" scripts | |
| 40 | - $physical_file = MGL_PATH . '/app/admin.js'; | |
| 41 | - $cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MGL_VERSION; | |
| 42 | - wp_register_script( 'mgl-admin-js', MGL_URL . '/app/admin.js', | |
| 43 | - array( 'mgl-gallery-js', 'wp-editor', 'wp-i18n', 'wp-element' ), $cache_buster ); | |
| 44 | - register_block_type( 'meow-gallery/gallery', array( 'editor_script' => 'mgl-admin-js' )); | |
| 45 | - | |
| 46 | - // Load the fonts | |
| 47 | - wp_register_style( 'meow-neko-ui-lato-font', '//fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900&display=swap'); | |
| 48 | - wp_enqueue_style( 'meow-neko-ui-lato-font' ); | |
| 49 | - | |
| 50 | - // Localize and options | |
| 51 | - global $wplr; | |
| 52 | - wp_localize_script( 'mgl-admin-js', 'mgl_meow_gallery', [ | |
| 53 | - //'api_nonce' => wp_create_nonce( 'mfrh_media_file_renamer' ), | |
| 54 | - 'api_url' => get_rest_url( null, '/meow-gallery/v1/' ), | |
| 55 | - 'rest_url' => get_rest_url(), | |
| 56 | - 'plugin_url' => MGL_URL, | |
| 57 | - 'prefix' => MGL_PREFIX, | |
| 58 | - 'domain' => MGL_DOMAIN, | |
| 59 | - 'is_pro' => class_exists( 'MeowPro_MGL_Core' ), | |
| 60 | - 'is_registered' => !!$this->is_registered(), | |
| 61 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), | |
| 62 | - 'wplr_collections' => $wplr ? $wplr->read_collections_recursively() : [], | |
| 63 | - 'options' => $this->core->get_all_options(), | |
| 64 | - ] ); | |
| 65 | - | |
| 66 | - wp_enqueue_script( 'mgl-admin-js' ); | |
| 32 | + // The scripts and styles are all handled by Meow_MGL_Run; the block only needs to point at | |
| 33 | + // the admin bundle it registers. | |
| 34 | + function register_block() { | |
| 35 | + register_block_type( 'meow-gallery/gallery', array( | |
| 36 | + 'editor_script' => Meow_MGL_Run::ADMIN_SCRIPT_HANDLE, | |
| 37 | + ) ); | |
| 67 | 38 | } |
| 68 | 39 | |
| 69 | 40 | function app_menu() { |
| 70 | 41 | add_submenu_page( 'meowapps-main-menu', __( 'Gallery', MGL_DOMAIN ), __( 'Gallery', MGL_DOMAIN ), |