PluginProbe
Meow Gallery / 5.5.5
Meow Gallery v5.5.5
5.5.5 5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 All 157 releases
← All changes | classes/admin.php +20 -40 4.2.25.5.5 View file →
@@ -1,18 +1,27 @@
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 - public function __construct() {
5 + private $core;
6 +
7 + public function __construct($core) {
6 8 parent::__construct( MGL_PREFIX, MGL_ENTRY, MGL_DOMAIN, class_exists( 'MeowPro_MGL_Core' ) );
9 + $this->core = $core;
7 10 add_action( 'admin_menu', array( $this, 'app_menu' ) );
8 11 $blocks_enabled = function_exists( 'register_block_type' );
9 12 if ( $blocks_enabled ) {
10 - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
13 + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
11 14 }
12 - if ( get_option( 'mgl_captions', 'notset' ) === 'notset' ) {
15 + $options = $this->core->get_all_options();
16 + if ( ( $options['captions'] ?? 'notset' ) === 'notset' ) {
17 + // MEOMO: mgl_captions_enabled option is used only here. Also, it deletes soon after being used.
18 + // So we keep this option what it is (not migrated to the mgl_options).
13 19 $captions_enabled = get_option( 'mgl_captions_enabled' );
14 - update_option( 'mgl_captions', $captions_enabled ? 'hover-only' : false );
20 + $this->core->update_options( array_merge(
21 + $options,
22 + [ 'captions' => $captions_enabled ? 'hover-only' : false ]
23 + ) );
15 24 delete_option( 'mgl_captions_enabled' );
16 25 }
17 26 }
18 27
@@ -19,43 +28,14 @@
19 28 public function mgl_settings() {
20 29 echo '<div id="mgl-admin-settings"></div>';
21 30 }
22 31
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( 'jquery' ), $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' );
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 + ) );
58 38 }
59 39
60 40 function app_menu() {
61 41 add_submenu_page( 'meowapps-main-menu', __( 'Gallery', MGL_DOMAIN ), __( 'Gallery', MGL_DOMAIN ),