partially fixes dev_interface. Must remove Vue components to fix
This commit is contained in:
parent
fb046a998f
commit
4e474d1665
|
@ -40,6 +40,7 @@ class Admin {
|
||||||
|
|
||||||
function load_admin_page() {
|
function load_admin_page() {
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 );
|
||||||
}
|
}
|
||||||
|
|
||||||
function login_styles_reset( $style ) {
|
function login_styles_reset( $style ) {
|
||||||
|
@ -91,16 +92,22 @@ class Admin {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_body_class( $classes ) {
|
function add_admin_js() {
|
||||||
global $pagenow;
|
global $TAINACAN_BASE_URL;
|
||||||
if ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] == $this->menu_slug ) {
|
|
||||||
$classes .= ' tainacan-admin-page';
|
wp_enqueue_script( 'tainacan-user-admin', $TAINACAN_BASE_URL . '/assets/user_admin-components.js', [], null, true );
|
||||||
}
|
|
||||||
|
$settings = $this->get_admin_js_localization_params();
|
||||||
|
|
||||||
|
wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings );
|
||||||
|
|
||||||
|
|
||||||
return $classes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function admin_page() {
|
/**
|
||||||
|
* Also used by DevInterface
|
||||||
|
*/
|
||||||
|
function get_admin_js_localization_params() {
|
||||||
global $TAINACAN_BASE_URL;
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
|
||||||
|
@ -109,11 +116,6 @@ class Admin {
|
||||||
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
|
||||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
|
||||||
|
|
||||||
// TODO move it to a separate file and start the Vue project
|
|
||||||
echo "<div id='tainacan-admin-app'></div>";
|
|
||||||
//wp_enqueue_script( 'tainacan-dev-admin', $TAINACAN_BASE_URL . '/assets/dev_admin-components.js', [] , null, true);
|
|
||||||
wp_enqueue_script( 'tainacan-user-admin', $TAINACAN_BASE_URL . '/assets/user_admin-components.js', [], null, true );
|
|
||||||
|
|
||||||
$tainacan_admin_i18n = require( 'tainacan-admin-i18n.php' );
|
$tainacan_admin_i18n = require( 'tainacan-admin-i18n.php' );
|
||||||
|
|
||||||
$entities_labels = [
|
$entities_labels = [
|
||||||
|
@ -175,8 +177,24 @@ class Admin {
|
||||||
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
|
||||||
wp_localize_script( 'tainacan-user-admin', 'tainacan_plugin', $settings );
|
}
|
||||||
|
|
||||||
|
function admin_body_class( $classes ) {
|
||||||
|
global $pagenow;
|
||||||
|
if ( $pagenow == 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] == $this->menu_slug ) {
|
||||||
|
$classes .= ' tainacan-admin-page';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function admin_page() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
// TODO move it to a separate file and start the Vue project
|
||||||
|
echo "<div id='tainacan-admin-app'></div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,10 @@ class DevInterface {
|
||||||
'components' => $components
|
'components' => $components
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$tainacan_settings = \Tainacan\Admin::getInstance()->get_admin_js_localization_params();
|
||||||
|
|
||||||
|
$settings = array_merge($settings, $tainacan_settings);
|
||||||
|
|
||||||
wp_enqueue_script( 'tainacan-dev-admin', $TAINACAN_BASE_URL . '/assets/dev_admin-components.js', [] , null, true);
|
wp_enqueue_script( 'tainacan-dev-admin', $TAINACAN_BASE_URL . '/assets/dev_admin-components.js', [] , null, true);
|
||||||
wp_localize_script( 'tainacan-dev-admin', 'tainacan_plugin', $settings );
|
wp_localize_script( 'tainacan-dev-admin', 'tainacan_plugin', $settings );
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,10 @@ require_once(CLASSES_DIR . 'tainacan-creator.php');
|
||||||
require_once(API_DIR . 'tainacan-rest-creator.php');
|
require_once(API_DIR . 'tainacan-rest-creator.php');
|
||||||
|
|
||||||
require_once('dev-interface/class-tainacan-dev-interface.php');
|
require_once('dev-interface/class-tainacan-dev-interface.php');
|
||||||
$Tainacan_Dev_interface = \Tainacan\DevInterface\DevInterface::getInstance();
|
if ( tnc_enable_dev_wp_interface() ) {
|
||||||
|
$Tainacan_Dev_interface = \Tainacan\DevInterface\DevInterface::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function tnc_enable_dev_wp_interface() {
|
function tnc_enable_dev_wp_interface() {
|
||||||
return defined('TNC_ENABLE_DEV_WP_INTERFACE') && true === TNC_ENABLE_DEV_WP_INTERFACE ? true : false;
|
return defined('TNC_ENABLE_DEV_WP_INTERFACE') && true === TNC_ENABLE_DEV_WP_INTERFACE ? true : false;
|
||||||
|
|
Loading…
Reference in New Issue