PluginProbe
Translation with DeepL API / trunk
Translation with DeepL API vtrunk
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 +50 -37 2.4.3.12trunk View file →
@@ -1,15 +1,14 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: DeepL for WordPress : translation plugin
4 - * Description: Get DeepL translation magic right inside your WordPress editor (with a paid DeepL Pro account)
5 - * Version: 2.4.3.12
3 + * Plugin Name: Translation with DeepL API
4 + * Description: Get DeepL translation magic right inside your WordPress editor (with a paid DeepL Pro account). This plugin is not affiliated with DeepL SE.
5 + * Version: 2.6.2
6 6 * Plugin Slug: wpdeepl
7 7 * Author: Fluenx
8 8 * Author URI: https://www.fluenx.com/
9 - * Requires at least: 4.0.0
10 - * Tested up to: 6.6.1
11 - * Stable tag: 2.4.3.12
9 + * License: GPLv2 or later
10 + * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 11 * Text Domain: wpdeepl
13 12 * Domain Path: /languages
14 13 */
15 14
@@ -14,19 +13,19 @@
14 13 */
15 14
16 15 //return;
17 16
17 +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18 18
19 -$allow_front_end = get_option('wpdeepl_allow_front_end');
20 -
21 -if( $allow_front_end != 'yes' ) {
19 +// exit early
20 +$wpdeepl_allow_front_end = filter_var( get_option('wpdeepl_allow_front_end'), FILTER_VALIDATE_BOOLEAN );
21 +if( ! $wpdeepl_allow_front_end ) {
22 22 if ( !function_exists( 'is_admin' ) || !is_admin() )
23 23 return;
24 -
25 24 }
26 25
27 -
28 -defined( 'WPDEEPL_FLAVOR' ) or define( 'WPDEEPL_FLAVOR', 'free' );
26 +//defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', false ); // Uncomment AND set to true to force debug mode
27 +defined( 'WPDEEPL_FLAVOR' ) or define( 'WPDEEPL_FLAVOR', 'free' );
29 28 defined( 'WPDEEPL_NAME' ) or define( 'WPDEEPL_NAME', plugin_basename( __FILE__ ) );
30 29 defined( 'WPDEEPL_SLUG' ) or define( 'WPDEEPL_SLUG', 'wpdeepl' );
31 30 defined( 'WPDEEPL_DIR' ) or define( 'WPDEEPL_DIR', dirname( __FILE__ ) );
32 31 defined( 'WPDEEPL_PATH' ) or define( 'WPDEEPL_PATH', realpath( __DIR__ ) );
@@ -31,21 +30,18 @@
31 30 defined( 'WPDEEPL_DIR' ) or define( 'WPDEEPL_DIR', dirname( __FILE__ ) );
32 31 defined( 'WPDEEPL_PATH' ) or define( 'WPDEEPL_PATH', realpath( __DIR__ ) );
33 32 defined( 'WPDEEPL_URL' ) or define( 'WPDEEPL_URL', plugins_url( '', __FILE__ ) );
34 33
35 -$plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
36 -defined( 'WPDEEPL_VERSION' ) or define( 'WPDEEPL_VERSION', $plugin_data['Version'] );
34 +$wpdeepl_plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
35 +defined( 'WPDEEPL_VERSION' ) or define( 'WPDEEPL_VERSION', $wpdeepl_plugin_data['Version'] );
37 36
38 -defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', 0 );
37 +defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', false );
39 38
40 -$wp_upload_dir = wp_upload_dir();
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 );
39 +$wpdeepl_upload_dir = wp_upload_dir();
40 +defined( 'WPDEEPL_FILES' ) or define( 'WPDEEPL_FILES', trailingslashit( $wpdeepl_upload_dir['basedir'] ) . 'wpdeepl' );
41 +defined( 'WPDEEPL_FILES_URL' ) or define( 'WPDEEPL_FILES_URL', trailingslashit( $wpdeepl_upload_dir['baseurl'] ) . 'wpdeepl' );
44 42
45 -// obs 20210422 v1.7 defined( 'DEEPL_API_URL' ) or define( 'DEEPL_API_URL', 'https://api.deepl.com/v2/' );
46 -
47 -function zebench_wpdeepl_paths( $paths = array() ) {
43 +function wpdeepl_paths( $paths = array() ) {
48 44 $paths['deepl_settings'] = array(
49 45 'files' => WPDEEPL_FILES
50 46 );
51 47 return $paths;
@@ -51,9 +47,9 @@
51 47 return $paths;
52 48 }
53 49
54 50 try {
55 - if ( is_admin() || $allow_front_end == 'yes' ) {
51 + if ( is_admin() || $wpdeepl_allow_front_end ) {
56 52
57 53
58 54 include_once trailingslashit( WPDEEPL_PATH ) . 'deepl-configuration.class.php';
59 55
@@ -80,21 +76,33 @@
80 76 //if( file_exists( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-elementor.php' ) include_once trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-elementor.php';
81 77
82 78 }
83 79
84 - add_filter('zebench_plugins_paths', 'zebench_wpdeepl_paths');
80 + add_filter('zebench_plugins_paths', 'wpdeepl_paths');
85 81
86 - $customisation_file = trailingslashit( WPDEEPL_PATH ) . 'custom-integration.php';
87 - if ( file_exists( $customisation_file ) ) {
88 - include_once $customisation_file;
82 + $wpdeepl_customisation_file = trailingslashit( WPDEEPL_PATH ) . 'custom-integration.php';
83 + //echo "\n file $wpdeepl_customisation_file / exists ? " . file_exists( $wpdeepl_customisation_file );
84 + if ( file_exists( $wpdeepl_customisation_file ) ) {
85 + include_once $wpdeepl_customisation_file;
89 86 }
87 + else {
88 +
89 + }
90 90
91 91 }
92 92 } catch ( Exception $exception ) {
93 93 if ( current_user_can( 'manage_options' ) ) {
94 - print_r( $exception );
95 - die( __( 'Error loading WPDeepL','wpdeepl' ) );
94 + // En mode debug seulement, logger les erreurs
95 + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
96 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Debug mode only
97 + error_log( 'WPDeepL Fatal Error: ' . $exception->getMessage() . ' in ' . $exception->getFile() . ' on line ' . $exception->getLine() );
98 + }
99 + wp_die(
100 + esc_html__( 'Error loading WPDeepL', 'wpdeepl' ),
101 + array( 'response' => 500 )
102 + );
96 103 }
104 + return;
97 105 }
98 106
99 107
100 108 //global $DeepLForWordPress; $DeepLForWordPress = new DeepLForWordPress();
@@ -106,14 +114,21 @@
106 114 }
107 115 return true;
108 116 }
109 117
110 -if ( !function_exists( 'plouf' ) ) {
111 - function plouf( $e, $txt = '' ) {
112 - if ( $txt != '' ) echo "<br />\n$txt";
113 - echo '<pre>';
114 - print_r( $e );
115 - echo '</pre>';
118 +if ( !function_exists( 'wpdeepl_debug_display' ) ) {
119 + function wpdeepl_debug_display( $e, $txt = '' ) {
120 +
121 + // En mode debug seulement
122 + if ( 1 == 1 ) {
123 + if ( $txt != '' ) echo esc_html( "<br />\n$txt" );
124 + ?>
125 + <pre><?php
126 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r -- Debug mode seulement
127 + print_r( $e );
128 + ?>
129 + </pre><?php
130 + }
116 131 }
117 132 }
118 133
119 134 add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wpdeepl_plugin_action_links' );
@@ -140,7 +155,5 @@
140 155 function deepl_init() {
141 156 if ( !is_admin() ) {
142 157 return;
143 158 }
144 -
145 - load_plugin_textdomain( 'wpdeepl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
146 159 }