parsers
5 years ago
admin.php
4 years ago
core.php
4 years ago
engine.php
4 years ago
init.php
4 years ago
parsers.php
5 years ago
rest.php
4 years ago
support.php
4 years ago
ui.php
5 years ago
admin.php
101 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_WPMC_Admin extends MeowCommon_Admin { |
| 4 | |
| 5 | public function __construct( $allow_setup ) { |
| 6 | parent::__construct( WPMC_PREFIX, WPMC_ENTRY, WPMC_DOMAIN, class_exists( 'MeowPro_WPMC_Core' ) ); |
| 7 | if ( $allow_setup ) { |
| 8 | add_action( 'admin_menu', array( $this, 'app_menu' ) ); |
| 9 | } |
| 10 | |
| 11 | // Load the scripts only if they are needed by the current screen |
| 12 | $page = isset( $_GET["page"] ) ? $_GET["page"] : null; |
| 13 | $is_wpmc_screen = in_array( $page, [ 'wpmc_dashboard', 'wpmc_settings' ] ); |
| 14 | $is_meowapps_dashboard = $page === 'meowapps-main-menu'; |
| 15 | if ( $is_meowapps_dashboard || $is_wpmc_screen ) { |
| 16 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | function admin_enqueue_scripts() { |
| 21 | |
| 22 | // Load the scripts |
| 23 | $physical_file = WPMC_PATH . '/app/index.js'; |
| 24 | $cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : WPMC_VERSION; |
| 25 | wp_register_script( 'wpmc_media_cleaner-vendor', WPMC_URL . 'app/vendor.js', |
| 26 | ['wp-element', 'wp-i18n'], $cache_buster |
| 27 | ); |
| 28 | wp_register_script( 'wpmc_media_cleaner', WPMC_URL . 'app/index.js', |
| 29 | ['wpmc_media_cleaner-vendor', 'wp-i18n'], $cache_buster |
| 30 | ); |
| 31 | if ( function_exists( 'wp_set_script_translations' ) ) { |
| 32 | wp_set_script_translations( 'wpmc_media_cleaner', 'media-cleaner' ); |
| 33 | } |
| 34 | wp_enqueue_script('wpmc_media_cleaner' ); |
| 35 | |
| 36 | // Load the fonts |
| 37 | wp_register_style( 'meow-neko-ui-lato-font', '//fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900&display=swap'); |
| 38 | wp_enqueue_style( 'meow-neko-ui-lato-font' ); |
| 39 | |
| 40 | // Localize and options |
| 41 | wp_localize_script( 'wpmc_media_cleaner', 'wpmc_media_cleaner', array_merge( [ |
| 42 | 'api_url' => rest_url( 'media-cleaner/v1' ), |
| 43 | 'rest_url' => rest_url(), |
| 44 | 'plugin_url' => WPMC_URL, |
| 45 | 'prefix' => WPMC_PREFIX, |
| 46 | 'domain' => WPMC_DOMAIN, |
| 47 | 'is_pro' => class_exists( 'MeowPro_WPMC_Core' ), |
| 48 | 'is_registered' => !!$this->is_registered(), |
| 49 | 'rest_nonce' => wp_create_nonce( 'wp_rest' ) |
| 50 | ], $this->get_all_options() ) ); |
| 51 | } |
| 52 | |
| 53 | function app_menu() { |
| 54 | add_submenu_page( 'meowapps-main-menu', 'Cleaner', 'Cleaner', 'read', 'wpmc_settings', |
| 55 | array( $this, 'admin_settings' ) |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | public function admin_settings() { |
| 60 | echo '<div id="wpmc-admin-settings"></div>'; |
| 61 | } |
| 62 | |
| 63 | function list_options() { |
| 64 | return array( |
| 65 | 'wpmc_method' => 'media', |
| 66 | 'wpmc_content' => true, |
| 67 | 'wpmc_filesystem_content' => false, |
| 68 | 'wpmc_media_library' => true, |
| 69 | 'wpmc_live_content' => false, |
| 70 | 'wpmc_debuglogs' => false, |
| 71 | 'wpmc_images_only' => false, |
| 72 | 'wpmc_attach_is_use' => false, |
| 73 | 'wpmc_thumbnails_only' => false, |
| 74 | 'wpmc_dirs_filter' => '', |
| 75 | 'wpmc_files_filter' => '', |
| 76 | 'wpmc_hide_thumbnails' => false, |
| 77 | 'wpmc_hide_warning' => false, |
| 78 | 'wpmc_medias_buffer' => 100, |
| 79 | 'wpmc_posts_buffer' => 5, |
| 80 | 'wpmc_analysis_buffer' => 100, |
| 81 | 'wpmc_file_op_buffer' => 20, |
| 82 | 'wpmc_delay' => 100, |
| 83 | 'wpmc_shortcodes_disabled' => false, |
| 84 | 'wpmc_posts_per_page' => 10, |
| 85 | 'wpmc_clean_uninstall' => false, |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | function get_all_options() { |
| 90 | $options = $this->list_options(); |
| 91 | $current_options = array(); |
| 92 | foreach ( $options as $option => $default ) { |
| 93 | $current_options[$option] = get_option( $option, $default ); |
| 94 | } |
| 95 | return $current_options; |
| 96 | } |
| 97 | |
| 98 | } |
| 99 | |
| 100 | ?> |
| 101 |