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
wpdeepl / wpdeeplpro / wpdeeplpro.php

wpdeeplpro.php in Translation with DeepL API 2.4.5, at wpdeeplpro/wpdeeplpro.php

142 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: DeepL for WordPress : translation plugin PRO
4 * Description: Get DeepL translation magic right inside your WordPress editor (with a paid DeepL Pro account)
5 * Version: 2.6.1
6 * Plugin Slug: wpdeeplpro
7 * Author: Fluenx
8 * Author URI: https://www.fluenx.com/
9 * Requires at least: 5.0
10 * Tested up to: 6.4
11 * Text Domain: wpdeeplpro
12 * Domain Path: /languages
13 */
14
15 //return;
16 defined( 'WPDEEPLPRO_NAME' ) or define( 'WPDEEPLPRO_NAME', plugin_basename( __FILE__ ) ); // plugin name as known by WP.
17 defined( 'WPDEEPLPRO_DIR' ) or define( 'WPDEEPLPRO_DIR', dirname( __FILE__ ) ); // our directory.
18 defined( 'WPDEEPLPRO_PATH' ) or define( 'WPDEEPLPRO_PATH', realpath( __DIR__ ) ); // our directory.
19 defined( 'WPDEEPLPRO_URL' ) or define( 'WPDEEPLPRO_URL', plugins_url( '', __FILE__ ) );
20 $plugin_data = get_file_data( __FILE__, array( 'Version' => 'Version' ), false );
21 defined( 'WPDEEPLPRO_VERSION' ) or define( 'WPDEEPLPRO_VERSION', $plugin_data['Version'] );
22
23 defined('WPDEEPLPRO_DEBUG') or define('WPDEEPLPRO_DEBUG', false );
24
25 try {
26 include_once trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php';
27 if(
28 ( is_admin() || get_option('wpdeepl_allow_front_end') == 'yes' )
29 &&
30 is_plugin_active( 'wpdeepl/wpdeepl.php' ) ) {
31
32 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'keypress-api-client.php';
33 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'keypress-wpdeeplpro.php';
34 global $KeyPressWPDeepLPro;
35 $KeyPressWPDeepLPro = new KeyPressWPDeepLPro();
36
37 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'deeplpro-configuration.class.php' ;
38
39 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'admin/deeplpro-admin-hooks.php' ;
40
41 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-plugin-install.php' ;
42 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-functions.php' ;
43 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-polylang.php' ;
44 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-duplicate-post.php' ;
45 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-acf.php' ;
46
47
48
49 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-post-translation.php' ;
50 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-comments.php';
51 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-bulk-actions.php' ;
52
53
54 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'client/deeplapi-glossary.class.php';
55 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'client/deeplapi-glossary-functions.php';
56
57
58
59
60 }
61 } catch ( Exception $e ) {
62 if( current_user_can( 'manage_options' ) ) {
63 print_r( $e );
64 die( __( 'Error loading WPDeepL', 'wpdeepl' ) );
65 }
66 }
67
68 add_action( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'deeplpro_plugin_action_links' );
69 function deeplpro_plugin_action_links( $links ) {
70 $links = array_merge(
71 array(
72 '<a href="' . esc_url( admin_url( '/options-general.php?page=deepl_settings&tab=pro' ) ) . '">' . __( 'Settings', 'wpdeepl' ) . '</a>'
73 ),
74 $links
75 );
76 return $links;
77 }
78
79 register_activation_hook( __FILE__, 'deeplpro_plugin_activate' );
80 function deeplpro_plugin_activate() {
81 if( !function_exists('deeplpro_install_plugin' ) )
82 include_once trailingslashit( WPDEEPLPRO_PATH ) . 'includes/deeplpro-plugin-install.php' ;
83 deeplpro_install_plugin();
84 deeplpro_maybe_activate_wpdeepl();
85 }
86
87 register_deactivation_hook( __FILE__, 'deeplpro_plugin_deactivate' );
88 function deeplpro_plugin_deactivate() {
89 }
90
91
92 add_action( 'plugins_loaded', 'deeplpro_init', 45 );
93 function deeplpro_init() {
94 if( !defined( 'WPDEEPL_FILES' ) ) {
95 return;
96 }
97
98 if( !is_admin() ) {
99 return;
100 }
101
102 load_plugin_textdomain( 'wpdeepl', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
103 }
104
105 add_action('admin_notices', 'deeplpro_admin_notices' );
106 function deeplpro_admin_notices() {
107 include_once trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php';
108 if ( ! is_plugin_active( 'wpdeepl/wpdeepl.php' ) and current_user_can( 'activate_plugins' ) ) {
109
110
111 echo '<div class="notice notice-error is-dismissible">
112 <p>';
113 printf(
114 __('WPDeepL Pro extension needs the <a target="_blank" href="%s">WPDeepL plugin</a> installed and activated to run. Please install or activate', 'wpdeepl' ),
115 'https://fr.wordpress.org/plugins/wpdeepl/'
116 );
117 echo '</p>
118 </div>';
119 }
120 }
121
122 add_action('after_plugin_row_wpdeeplpro/wpdeeplpro.php', 'deeplpro_missing_main_plugin', 10, 3);
123 function deeplpro_missing_main_plugin($plugin_file, $plugin_data, $plugin_status){
124 include_once trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php';
125 if ( ! is_plugin_active( 'wpdeepl/wpdeepl.php' ) and current_user_can( 'activate_plugins' ) ) {
126 $slug = dirname($plugin_file);
127
128 $wp_list_table = _get_list_table('WP_Plugins_List_Table');
129 ?>
130 <tr class="plugin-update-tr" id="<?php echo $slug; ?>-missing-main"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="plugin-error colspanchange">
131 <div class="notice inline notice-error">
132 <p><?php
133 printf(
134 __('WPDeepL Pro extension needs the <a target="_blank" href="%s">WPDeepL plugin</a> installed and activated to run. Please install or activate', 'wpdeepl' ),
135 'https://fr.wordpress.org/plugins/wpdeepl/'
136 );
137 ?></p>
138 </div>
139 </tr>
140 <?php
141 }
142 }