| 1 |
<?php |
| 2 |
|
| 3 |
class Meow_MGL_Admin extends MeowKit_MGL_Admin { |
| 4 |
|
| 5 |
private $core; |
| 6 |
|
| 7 |
public function __construct($core) { |
| 8 |
parent::__construct( MGL_PREFIX, MGL_ENTRY, MGL_DOMAIN, class_exists( 'MeowPro_MGL_Core' ) ); |
| 9 |
$this->core = $core; |
| 10 |
add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| 11 |
$blocks_enabled = function_exists( 'register_block_type' ); |
| 12 |
if ( $blocks_enabled ) { |
| 13 |
add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); |
| 14 |
} |
| 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). |
| 19 |
$captions_enabled = get_option( 'mgl_captions_enabled' ); |
| 20 |
$this->core->update_options( array_merge( |
| 21 |
$options, |
| 22 |
[ 'captions' => $captions_enabled ? 'hover-only' : false ] |
| 23 |
) ); |
| 24 |
delete_option( 'mgl_captions_enabled' ); |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
public function mgl_settings() { |
| 29 |
echo '<div id="mgl-admin-settings"></div>'; |
| 30 |
} |
| 31 |
|
| 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 |
) ); |
| 38 |
} |
| 39 |
|
| 40 |
function app_menu() { |
| 41 |
add_submenu_page( 'meowapps-main-menu', __( 'Gallery', MGL_DOMAIN ), __( 'Gallery', MGL_DOMAIN ), |
| 42 |
'manage_options', 'mgl_settings', array( $this, 'mgl_settings' ) |
| 43 |
); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
?> |
| 48 |
|