PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.2.8
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.2.8
0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 All 32 releases
code-engine / classes / admin.php

admin.php in Code Engine – PHP Snippets, AI Functions & Automation for WordPress 0.2.8, at classes/admin.php

69 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class Meow_MWCODE_Admin extends MeowCommon_Admin {
3
4 public $core;
5
6 public function __construct( $core ) {
7 $this->core = $core;
8
9 parent::__construct( MWCODE_PREFIX, MWCODE_ENTRY, MWCODE_DOMAIN, class_exists( 'MeowPro_MWCODE_Core' ) );
10 if ( is_admin() ) {
11 add_action( 'admin_menu', array( $this, 'app_menu' ) );
12
13 // Load the scripts only if they are needed by the current screen
14 $page = isset( $_GET["page"] ) ? sanitize_text_field( $_GET["page"] ) : null;
15 $is_mwcode_screen = in_array( $page, [ 'mwcode_settings' ] );
16 $is_meowapps_dashboard = $page === 'meowapps-main-menu';
17 if ( $is_meowapps_dashboard || $is_mwcode_screen ) {
18 add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
19 }
20 }
21 }
22
23 function admin_enqueue_scripts() {
24
25 // Load the scripts
26 $physical_file = MWCODE_PATH . '/app/index.js';
27 $cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MWCODE_VERSION;
28 wp_register_script( 'mwcode_snippet_vault-vendor', MWCODE_URL . 'app/vendor.js',
29 ['wp-element', 'wp-i18n'], $cache_buster
30 );
31 wp_register_script( 'mwcode_snippet_vault', MWCODE_URL . 'app/index.js',
32 ['mwcode_snippet_vault-vendor', 'wp-i18n'], $cache_buster
33 );
34 wp_set_script_translations( 'mwcode_snippet_vault', 'code-engine' );
35 wp_enqueue_script('mwcode_snippet_vault' );
36
37 // Load the fonts
38 wp_register_style( 'meow-neko-ui-lato-font', '//fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900&display=swap');
39 wp_enqueue_style( 'meow-neko-ui-lato-font' );
40
41 // Localize and options
42 wp_localize_script( 'mwcode_snippet_vault', 'mwcode_snippet_vault', [
43 'api_url' => rest_url( 'code-engine/v1' ),
44 'rest_url' => rest_url(),
45 'plugin_url' => MWCODE_URL,
46 'prefix' => MWCODE_PREFIX,
47 'domain' => MWCODE_DOMAIN,
48 'is_pro' => class_exists( 'MeowPro_MWCODE_Core' ),
49 'is_registered' => !!$this->is_registered(),
50 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
51 'options' => $this->core->get_all_options(),
52 ] );
53 }
54
55 function is_registered() {
56 return apply_filters( MWCODE_PREFIX . '_meowapps_is_registered', false, MWCODE_PREFIX );
57 }
58
59 function app_menu() {
60 add_submenu_page( 'meowapps-main-menu', 'Code Engine', 'Code Engine', 'manage_options',
61 'mwcode_settings', array( $this, 'admin_settings' ) );
62 }
63
64 function admin_settings() {
65 echo '<div id="mwcode-admin-settings"></div>';
66 }
67 }
68
69 ?>