PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.10.0
Translate and Go multilingual – Automatic AI translation – wpLingua v2.10.0
2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 All 111 releases
wplingua / inc / assets.php

assets.php in Translate and Go multilingual – Automatic AI translation – wpLingua 2.10.0, at inc/assets.php

131 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8
9 /**
10 * Register asset for wpLingua in front (CSS, JS)
11 *
12 * @return void
13 */
14 function wplng_register_assets() {
15
16 if ( is_admin() ) {
17 return;
18 }
19
20 /**
21 * Enqueue jQuery
22 */
23
24 wp_enqueue_script( 'jquery' );
25
26 /**
27 * Enqueue wpLingua JS script
28 */
29
30 wp_enqueue_script(
31 'wplingua-script',
32 plugins_url() . '/wplingua/assets/js/front.js',
33 array( 'jquery' ),
34 WPLNG_PLUGIN_VERSION
35 );
36
37 /**
38 * Enqueue wpLingua CSS style
39 */
40
41 wp_enqueue_style(
42 'wplingua',
43 plugins_url() . '/wplingua/assets/css/front.css',
44 array(),
45 WPLNG_PLUGIN_VERSION
46 );
47
48 /**
49 * Add inline style for wpLingua custom CSS
50 */
51
52 if ( empty( $_GET['wplng-mode'] )
53 || 'list' !== $_GET['wplng-mode']
54 ) {
55
56 $custom_css = get_option( 'wplng_custom_css' );
57
58 if ( ! empty( $custom_css )
59 && is_string( $custom_css )
60 ) {
61 $custom_css = wp_strip_all_tags( $custom_css );
62 wp_add_inline_style( 'wplingua', $custom_css );
63 }
64 }
65
66 if ( ! empty( $_GET['wplng-mode'] )
67 && empty( $_GET['wplng-load'] )
68 && (
69 'editor' === $_GET['wplng-mode']
70 || 'list' === $_GET['wplng-mode']
71 )
72 ) {
73
74 wp_enqueue_script(
75 'wplingua-translation',
76 plugins_url() . '/wplingua/assets/js/admin/edit-translation.js',
77 array( 'jquery' ),
78 WPLNG_PLUGIN_VERSION
79 );
80
81 wp_localize_script(
82 'wplingua-translation',
83 'wplngI18nTranslation',
84 array(
85 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
86 'currentLanguage' => wplng_get_language_current_id(),
87 'message' => array(
88 'exitPage' => esc_html__(
89 'You are about to leave the page without saving your changes. They will be lost if you continue. Would you like to leave the page anyway?',
90 'wplingua'
91 ),
92 'exitEditorModal' => esc_html__(
93 'You are about to exit without saving your changes. They will be lost if you continue. Would you like to leave anyway?',
94 'wplingua'
95 ),
96 'buttonSave' => esc_html__( 'Save', 'wplingua' ),
97 'buttonSaveInProgress' => esc_html__( 'Save in progress...', 'wplingua' ),
98 ),
99 )
100 );
101
102 }
103 }
104
105
106 /**
107 * Print the on page scrip
108 *
109 * @return void
110 */
111 function wplng_on_page_script() {
112
113 if ( ! empty( $_GET['wplng-load'] ) ) {
114 return;
115 }
116
117 $script = file_get_contents( WPLNG_PLUGIN_PATH . '/assets/js/on-page.js' );
118
119 if ( empty( $script ) ) {
120 return;
121 }
122
123 $script = str_replace(
124 array( '[admin-ajax-php]', '//# sourceMappingURL=on-page.js.map' ),
125 array( admin_url( 'admin-ajax.php' ), '' ),
126 $script
127 );
128
129 echo '<script id="wplingua-js-on-page">' . rtrim( $script ) . '</script>';
130 }
131