PluginProbe
Translation with DeepL API / 1.0
Translation with DeepL API v1.0
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 +99 -119 1.7.51.0 View file →
@@ -1,119 +1,99 @@
1 -<?php
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: 1.7.5.1
6 - * Plugin Slug: wpdeepl
7 - * Author: Fluenx
8 - * Author URI: https://www.fluenx.com/
9 - * Requires at least: 4.0.0
10 - * Tested up to: 6.1
11 - * Text Domain: wpdeepl
12 - * Domain Path: /languages
13 - */
14 -
15 -if( !function_exists( 'is_admin' ) || !is_admin() )
16 - return;
17 -
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.
23 -defined( 'WPDEEPL_URL' ) or define( 'WPDEEPL_URL', plugins_url( '', __FILE__ ) );
24 -$plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
25 -defined( 'WPDEEPL_VERSION' ) or define( 'WPDEEPL_VERSION', $plugin_data['Version'] );
26 -
27 -defined( 'WPDEEPL_DEBUG' ) or define( 'WPDEEPL_DEBUG', 0 );
28 -
29 -$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 );
33 -
34 -// obs 20210422 v1.7 defined( 'DEEPL_API_URL' ) or define( 'DEEPL_API_URL', 'https://api.deepl.com/v2/' );
35 -
36 -function zebench_wpdeepl_paths( $paths = array() ) {
37 - $paths['deepl_settings'] = array(
38 - 'files' => WPDEEPL_FILES
39 - );
40 - return $paths;
41 -}
42 -
43 -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' );
48 -
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' );
52 -
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' );
56 -
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');
63 - }
64 -} catch ( Exception $e ) {
65 - if( current_user_can( 'manage_options' ) ) {
66 - print_r( $e );
67 - die( __( 'Error loading WPDeepL','wpdeepl' ) );
68 - }
69 -}
70 -
71 -
72 -//global $DeepLForWordPress; $DeepLForWordPress = new DeepLForWordPress();
73 -function deepl_is_plugin_fully_configured() {
74 - $WP_Error = new WP_Error();
75 -
76 - if( count( $WP_Error->get_error_messages() ) ) {
77 - return $WP_Error;
78 - }
79 - return true;
80 -}
81 -
82 -if( !function_exists( 'plouf' ) ) {
83 - function plouf( $e, $txt = '' ) {
84 - if( $txt != '' ) echo "<br />\n$txt";
85 - echo '<pre>';
86 - print_r( $e );
87 - echo '</pre>';
88 - }
89 -}
90 -
91 -add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wpdeepl_plugin_action_links' );
92 -function wpdeepl_plugin_action_links( $links ) {
93 - $links = array_merge(
94 - array(
95 - '<a href="' . esc_url( admin_url( '/options-general.php?page=deepl_settings' ) ) . '">' . __( 'Settings', 'wpdeepl' ) . '</a>'
96 - ),
97 - $links
98 - );
99 - return $links;
100 -}
101 -
102 -register_activation_hook( __FILE__, 'deepl_plugin_activate' );
103 -function deepl_plugin_activate() {
104 - deepl_install_plugin();
105 -}
106 -
107 -register_deactivation_hook( __FILE__, 'deepl_plugin_deactivate' );
108 -function deepl_plugin_deactivate() {
109 -}
110 -
111 -
112 -add_action( 'init', 'deepl_init' );
113 -function deepl_init() {
114 - if( !is_admin() ) {
115 - return;
116 - }
117 -
118 - load_plugin_textdomain( 'wpdeepl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
119 -}
1 +<?php
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: 1.0
6 + * Plugin Slug: wpdeepl
7 + * Author: Fluenx
8 + * Author URI: https://www.fluenx.com/
9 + * Requires at least: 4.0.0
10 + * Tested up to: 5.0.3
11 + * Text Domain: wpdeepl
12 + * Domain Path: /languages
13 + */
14 +
15 +if( !function_exists( 'is_admin' ) || !is_admin() )
16 + return;
17 +
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.
23 +defined( 'WPDEEPL_URL' ) or define( 'WPDEEPL_URL', plugins_url( '', __FILE__ ) );
24 +$plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
25 +defined( 'WPDEEPL_VERSION' ) or define( 'WPDEEPL_VERSION', $plugin_data['Version'] );
26 +
27 +$wp_upload_dir = wp_upload_dir();
28 +defined( 'WPDEEPL_FILES' ) or define( 'WPDEEPL_FILES', trailingslashit( $wp_upload_dir['basedir'] ) . 'wpdeepl' );
29 +defined( 'WPDEEPL_FILES_URL' ) or define( 'WPDEEPL_FILES_URL', trailingslashit( $wp_upload_dir['baseurl'] ) . 'wpdeepl' );
30 +if( !is_dir( WPDEEPL_FILES ) ) mkdir( WPDEEPL_FILES );
31 +
32 +defined( 'DEEPL_API_URL' ) or define( 'DEEPL_API_URL', 'https://api.deepl.com/v2/' );
33 +
34 +try {
35 + if( is_admin() ) {
36 + require_once( trailingslashit( WPDEEPL_PATH ) . 'deepl-configuration.class.php' );
37 + require_once( trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-functions.php' );
38 + require_once( trailingslashit( WPDEEPL_PATH ) . 'includes/deepl-plugin-install.php' );
39 +
40 + require_once( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-admin-hooks.php' );
41 + require_once( trailingslashit( WPDEEPL_PATH ) . 'admin/deepl-metabox.php' );
42 +
43 + require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/abstract-wc-settings-api.php' );
44 + require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings.class.php' );
45 + require_once( trailingslashit( WPDEEPL_PATH ) . 'settings/wp-improved-settings-wpdeepl.class.php' );
46 +
47 + require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deepl-data.class.php' );
48 + require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi.class.php' );
49 + require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-translate.class.php' );
50 + require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-usage.class.php' );
51 + require_once( trailingslashit( WPDEEPL_PATH ) . 'client/deeplapi-functions.php' );
52 + }
53 +} catch ( Exception $e ) {
54 + if( current_user_can( 'manage_options' ) ) {
55 + print_r( $e );
56 + die( __( 'Error loading WPDeepL','wpdeepl' ) );
57 + }
58 +}
59 +
60 +//global $DeepLForWordPress; $DeepLForWordPress = new DeepLForWordPress();
61 +function deepl_is_plugin_fully_configured() {
62 + $WP_Error = new WP_Error();
63 +
64 + if( count( $WP_Error->get_error_messages() ) ) {
65 + return $WP_Error;
66 + }
67 + return true;
68 +}
69 +
70 +if( !function_exists( 'plouf' ) ) {
71 + function plouf( $e, $txt = '' ) {
72 + if( $txt != '' ) echo "<br />\n$txt";
73 + echo '<pre>';
74 + print_r( $e );
75 + echo '</pre>';
76 + }
77 +}
78 +
79 +add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wpdeepl_plugin_action_links' );
80 +function wpdeepl_plugin_action_links( $links ) {
81 + $links = array_merge(
82 + array(
83 + '<a href="' . esc_url( admin_url( '/options-general.php?page=deepl_settings' ) ) . '">' . __( 'Settings', 'wpdeepl' ) . '</a>'
84 + ),
85 + $links
86 + );
87 + return $links;
88 +}
89 +
90 +add_action( 'init', 'deepl_load_language' );
91 +function deepl_load_language() {
92 + if( !is_admin() ) {
93 + return;
94 + }
95 +
96 + load_plugin_textdomain( 'wpdeepl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
97 +}
98 +
99 +