PluginProbe
Translation with DeepL API / 2.4.5
Translation with DeepL API v2.4.5
trunk 0.1.20180323 1.0 1.2.5.1 1.5.2.5 1.7.5 2.4.3.12 2.4.3.9 2.4.5
← All changes | wpdeepl.php +70 -40 1.7.52.4.5 View file →
@@ -1,38 +1,49 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: DeepL for WordPress : translation plugin
4 4 * Description: Get DeepL translation magic right inside your WordPress editor (with a paid DeepL Pro account)
5 - * Version: 1.7.5.1
5 + * Version: 2.4.5
6 6 * Plugin Slug: wpdeepl
7 7 * Author: Fluenx
8 8 * Author URI: https://www.fluenx.com/
9 9 * Requires at least: 4.0.0
10 - * Tested up to: 6.1
10 + * Tested up to: 6.7.1
11 + * Stable tag: 2.4.5
11 12 * Text Domain: wpdeepl
12 13 * Domain Path: /languages
13 14 */
14 15
15 -if( !function_exists( 'is_admin' ) || !is_admin() )
16 +//return;
17 +
18 +
19 +$allow_front_end = get_option('wpdeepl_allow_front_end');
20 +
21 +if( $allow_front_end != 'yes' ) {
22 + if ( !function_exists( 'is_admin' ) || !is_admin() )
16 23 return;
17 24
18 -defined( 'WPDEEPL_FLAVOR' ) or define( 'WPDEEPL_FLAVOR', 'free' );
19 -defined( 'WPDEEPL_NAME' ) or define( 'WPDEEPL_NAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
20 -defined( 'WPDEEPL_SLUG' ) or define( 'WPDEEPL_SLUG', 'wpdeepl' );// plugin slug ( should match above meta: Text Domain ).
21 -defined( 'WPDEEPL_DIR' ) or define( 'WPDEEPL_DIR', dirname( __FILE__ ) ); // our directory.
22 -defined( 'WPDEEPL_PATH' ) or define( 'WPDEEPL_PATH', realpath( __DIR__ ) ); // our directory.
25 +}
26 +
27 +
28 +defined( 'WPDEEPL_FLAVOR' ) or define( 'WPDEEPL_FLAVOR', 'free' );
29 +defined( 'WPDEEPL_NAME' ) or define( 'WPDEEPL_NAME', plugin_basename( __FILE__ ) );
30 +defined( 'WPDEEPL_SLUG' ) or define( 'WPDEEPL_SLUG', 'wpdeepl' );
31 +defined( 'WPDEEPL_DIR' ) or define( 'WPDEEPL_DIR', dirname( __FILE__ ) );
32 +defined( 'WPDEEPL_PATH' ) or define( 'WPDEEPL_PATH', realpath( __DIR__ ) );
23 33 defined( 'WPDEEPL_URL' ) or define( 'WPDEEPL_URL', plugins_url( '', __FILE__ ) );
34 +
24 35 $plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
25 36 defined( 'WPDEEPL_VERSION' ) or define( 'WPDEEPL_VERSION', $plugin_data['Version'] );
26 37
27 -defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', 0 );
38 +defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', false );
28 39
29 40 $wp_upload_dir = wp_upload_dir();
30 -defined( 'WPDEEPL_FILES' ) or define( 'WPDEEPL_FILES', trailingslashit( $wp_upload_dir['basedir'] ) . 'wpdeepl' );
31 -defined( 'WPDEEPL_FILES_URL' ) or define( 'WPDEEPL_FILES_URL', trailingslashit( $wp_upload_dir['baseurl'] ) . 'wpdeepl' );
32 -if( !is_dir( WPDEEPL_FILES ) ) mkdir( WPDEEPL_FILES );
41 +defined( 'WPDEEPL_FILES' ) or define( 'WPDEEPL_FILES', trailingslashit( $wp_upload_dir['basedir'] ) . 'wpdeepl' );
42 +defined( 'WPDEEPL_FILES_URL' ) or define( 'WPDEEPL_FILES_URL', trailingslashit( $wp_upload_dir['baseurl'] ) . 'wpdeepl' );
43 +if ( !is_dir( WPDEEPL_FILES ) ) mkdir( WPDEEPL_FILES );
33 44
34 -// obs 20210422 v1.7 defined( 'DEEPL_API_URL' ) or define( 'DEEPL_API_URL', 'https://api.deepl.com/v2/' );
45 +// obs 20210422 v1.7 defined( 'DEEPL_API_URL' ) or define( 'DEEPL_API_URL', 'https://api.deepl.com/v2/' );
35 46
36 47 function zebench_wpdeepl_paths( $paths = array() ) {
37 48 $paths['deepl_settings'] = array(
38 49 'files' => WPDEEPL_FILES
@@ -40,31 +51,51 @@
40 51 return $paths;
41 52 }
42 53
43 54 try {
44 - if( is_admin() ) {
45 - require_once( trailingslashit( WPDEEPL_PATH ) . 'deepl-configuration.class.php' );
46 - require_once( trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-functions.php' );
47 - require_once( trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-plugin-install.php' );
55 + if ( is_admin() || $allow_front_end == 'yes' ) {
48 56
49 - require_once( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-admin-hooks.php' );
50 - require_once( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-admin-functions.php' );
51 - require_once( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-metabox.php' );
57 +
58 + include_once trailingslashit( WPDEEPL_PATH ) . 'deepl-configuration.class.php';
59 +
60 + include_once trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-functions.php';
61 + include_once trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-plugin-install.php';
62 +
52 63
53 - require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings-api.class.php' );
54 - require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings.class.php' );
55 - require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings-wpdeepl.class.php' );
64 + include_once trailingslashit( WPDEEPL_PATH ) . 'modules/deepl-translate-post.php';
56 65
57 - require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deepl-data.class.php' );
58 - require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi.class.php' );
59 - require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-translate.class.php' );
60 - require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-usage.class.php' );
61 - require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-functions.php' );
62 - add_filter('zebench_plugins_paths', 'zebench_wpdeepl_paths');
66 + include_once trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings-api.class.php';
67 + include_once trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings.class.php';
68 + include_once trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings-wpdeepl.class.php';
69 +
70 + include_once trailingslashit( WPDEEPL_PATH ) . 'client/deepl-data.class.php';
71 + include_once trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-functions.php';
72 + include_once trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi.class.php';
73 + include_once trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-translate.class.php';
74 + include_once trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-usage.class.php';
75 +
76 + if( is_admin() ) {
77 + include_once trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-admin-hooks.php';
78 + include_once trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-admin-functions.php';
79 + include_once trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-metabox.php';
80 + //if( file_exists( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-elementor.php' ) include_once trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-elementor.php';
81 +
82 + }
83 +
84 + add_filter('zebench_plugins_paths', 'zebench_wpdeepl_paths');
85 +
86 + $customisation_file = trailingslashit( WPDEEPL_PATH ) . 'custom-integration.php';
87 + if ( file_exists( $customisation_file ) ) {
88 + include_once $customisation_file;
89 + }
90 + else {
91 +
92 + }
93 +
63 94 }
64 -} catch ( Exception $e ) {
65 - if( current_user_can( 'manage_options' ) ) {
66 - print_r( $e );
95 +} catch ( Exception $exception ) {
96 + if ( current_user_can( 'manage_options' ) ) {
97 + print_r( $exception );
67 98 die( __( 'Error loading WPDeepL','wpdeepl' ) );
68 99 }
69 100 }
70 101
@@ -72,17 +103,17 @@
72 103 //global $DeepLForWordPress; $DeepLForWordPress = new DeepLForWordPress();
73 104 function deepl_is_plugin_fully_configured() {
74 105 $WP_Error = new WP_Error();
75 106
76 - if( count( $WP_Error->get_error_messages() ) ) {
107 + if ( count( $WP_Error->get_error_messages() ) ) {
77 108 return $WP_Error;
78 109 }
79 110 return true;
80 111 }
81 112
82 -if( !function_exists( 'plouf' ) ) {
113 +if ( !function_exists( 'plouf' ) ) {
83 114 function plouf( $e, $txt = '' ) {
84 - if( $txt != '' ) echo "<br />\n$txt";
115 + if ( $txt != '' ) echo "<br />\n$txt";
85 116 echo '<pre>';
86 117 print_r( $e );
87 118 echo '</pre>';
88 119 }
@@ -89,13 +120,13 @@
89 120 }
90 121
91 122 add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wpdeepl_plugin_action_links' );
92 123 function wpdeepl_plugin_action_links( $links ) {
93 - $links = array_merge(
124 + $links = array_merge(
94 125 array(
95 126 '<a href="' . esc_url( admin_url( '/options-general.php?page=deepl_settings' ) ) . '">' . __( 'Settings', 'wpdeepl' ) . '</a>'
96 - ),
97 - $links
127 + ),
128 + $links
98 129 );
99 130 return $links;
100 131 }
101 132
@@ -107,13 +138,12 @@
107 138 register_deactivation_hook( __FILE__, 'deepl_plugin_deactivate' );
108 139 function deepl_plugin_deactivate() {
109 140 }
110 141
111 -
112 142 add_action( 'init', 'deepl_init' );
113 143 function deepl_init() {
114 - if( !is_admin() ) {
144 + if ( !is_admin() ) {
115 145 return;
116 146 }
117 147
118 148 load_plugin_textdomain( 'wpdeepl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
119 149 }