first commit

This commit is contained in:
2023-09-12 21:41:04 +02:00
commit 3361a7f053
13284 changed files with 2116755 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?php
/**
* @author OnTheGo Systems
*/
class WPML_Custom_XML_Factory {
public function create_resources( WPML_WP_API $wpml_wp_api ) {
return new WPML_Custom_XML_UI_Resources( $wpml_wp_api );
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* @author OnTheGo Systems
*/
class WPML_Custom_XML_UI_Hooks {
/** @var WPML_Custom_XML_UI_Resources */
private $resources;
public function __construct( WPML_Custom_XML_UI_Resources $resources ) {
$this->resources = $resources;
}
public function init() {
add_filter( 'wpml_tm_tab_items', array( $this, 'add_items' ) );
add_action( 'admin_enqueue_scripts', array( $this->resources, 'admin_enqueue_scripts' ) );
}
public function add_items( $tab_items ) {
$tab_items['custom-xml-config']['caption'] = __( 'Custom XML Configuration', 'wpml-translation-management' );
$tab_items['custom-xml-config']['callback'] = array( $this, 'build_content' );
$tab_items['custom-xml-config']['current_user_can'] = 'manage_options';
return $tab_items;
}
public function build_content() {
echo '<div id="wpml-tm-custom-xml-content" class="wpml-tm-custom-xml js-wpml-tm-custom-xml"></div>';
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* @author OnTheGo Systems
*/
class WPML_Custom_XML_UI_Resources {
private $wpml_wp_api;
/**
* @var string
*/
private $wpml_core_url;
function __construct( WPML_WP_API $wpml_wp_api) {
$this->wpml_wp_api = $wpml_wp_api;
$this->wpml_core_url = $this->wpml_wp_api->constant( 'ICL_PLUGIN_URL' );
}
function admin_enqueue_scripts() {
if ( $this->wpml_wp_api->is_tm_page( 'custom-xml-config', 'settings' ) ) {
$core_version = $this->wpml_wp_api->constant( 'ICL_SITEPRESS_VERSION' );
$siteUrl = get_rest_url();
wp_register_script( 'wpml-custom-xml-config', $this->wpml_core_url . '/dist/js/xmlConfigEditor/app.js', [], $core_version );
wp_localize_script(
'wpml-custom-xml-config',
'wpmlCustomXML',
[
'restNonce' => wp_create_nonce( 'wp_rest' ),
'endpoint' => $siteUrl . 'wpml/v1/custom-xml-config',
]
);
wp_register_style( 'wpml-custom-xml-config', $this->wpml_core_url . '/dist/css/xmlConfigEditor/styles.css', [], $core_version );
wp_enqueue_style( 'wpml-custom-xml-config' );
wp_enqueue_script( 'wpml-custom-xml-config' );
}
}
}