| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* |
| 5 |
* @link https://pampa.dev |
| 6 |
* @since 1.0.0 |
| 7 |
* @package Auto_Translate |
| 8 |
* |
| 9 |
* @wordpress-plugin |
| 10 |
* Plugin Name: Automatic Translator with Google Translate |
| 11 |
* Description: Translate your WordPress site with a polished Google Translate language switcher for instant visitor translation. |
| 12 |
* Version: 2.2.0 |
| 13 |
* Requires at least: 6.5 |
| 14 |
* Requires PHP: 7.4 |
| 15 |
* Author: Pampa Dev |
| 16 |
* Author URI: https://pampa.dev |
| 17 |
* License: GPL-2.0+ |
| 18 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 19 |
* Text Domain: auto-translate |
| 20 |
* Domain Path: /languages |
| 21 |
*/ |
| 22 |
|
| 23 |
// If this file is called directly, abort. |
| 24 |
if ( ! defined( 'WPINC' ) ) { |
| 25 |
die; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Currently plugin version. |
| 30 |
*/ |
| 31 |
define( 'AUTO_TRANSLATE_VERSION', '2.2.0' ); |
| 32 |
|
| 33 |
/** |
| 34 |
* Initialize the plugin tracker. |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
function wpat_appsero_init_tracker_auto_translate() { |
| 39 |
|
| 40 |
if ( ! class_exists( 'WpatAppsero\\Client' ) ) { |
| 41 |
require_once __DIR__ . '/appsero/src/Client.php'; |
| 42 |
} |
| 43 |
|
| 44 |
if ( ! class_exists( 'Auto_Translate_Lifecycle' ) ) { |
| 45 |
require_once __DIR__ . '/includes/class-auto-translate-lifecycle.php'; |
| 46 |
} |
| 47 |
|
| 48 |
if ( ! class_exists( 'Auto_Translate_Config' ) ) { |
| 49 |
require_once __DIR__ . '/includes/class-auto-translate-config.php'; |
| 50 |
} |
| 51 |
|
| 52 |
$client = new WpatAppsero\Client( |
| 53 |
'f2a83449-c6d2-49f9-8e57-8dbc99eaa136', |
| 54 |
'Automatic Translator with Google Translate', |
| 55 |
__FILE__ |
| 56 |
); |
| 57 |
|
| 58 |
// Active insights. |
| 59 |
$client->insights() |
| 60 |
->add_extra( array( 'Auto_Translate_Lifecycle', 'get_appsero_metadata' ) ) |
| 61 |
->init(); |
| 62 |
} |
| 63 |
|
| 64 |
wpat_appsero_init_tracker_auto_translate(); |
| 65 |
|
| 66 |
/** |
| 67 |
* The code that runs during plugin activation. |
| 68 |
* This action is documented in includes/class-auto-translate-activator.php |
| 69 |
*/ |
| 70 |
function wpat_activate_auto_translate() { |
| 71 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-auto-translate-activator.php'; |
| 72 |
Auto_Translate_Activator::activate(); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* The code that runs during plugin deactivation. |
| 77 |
* This action is documented in includes/class-auto-translate-deactivator.php |
| 78 |
*/ |
| 79 |
function wpat_deactivate_auto_translate() { |
| 80 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-auto-translate-deactivator.php'; |
| 81 |
Auto_Translate_Deactivator::deactivate(); |
| 82 |
} |
| 83 |
|
| 84 |
register_activation_hook( __FILE__, 'wpat_activate_auto_translate' ); |
| 85 |
register_deactivation_hook( __FILE__, 'wpat_deactivate_auto_translate' ); |
| 86 |
|
| 87 |
/** |
| 88 |
* The core plugin class that is used to define internationalization, |
| 89 |
* admin-specific hooks, and public-facing site hooks. |
| 90 |
*/ |
| 91 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-auto-translate.php'; |
| 92 |
|
| 93 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-auto-translate-config.php'; |
| 94 |
|
| 95 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-auto-translate-languages.php'; |
| 96 |
|
| 97 |
/** |
| 98 |
* Load language/country config after init so translation functions are not called too early. |
| 99 |
* |
| 100 |
* @since 1.6.0 |
| 101 |
*/ |
| 102 |
function wpat_auto_translate_load_config() { |
| 103 |
static $config_loaded = false; |
| 104 |
global $wpat_supported_languages; |
| 105 |
global $wpat_widget_types; |
| 106 |
global $wpat_languages_countries; |
| 107 |
|
| 108 |
if ( $config_loaded ) { |
| 109 |
return; |
| 110 |
} |
| 111 |
|
| 112 |
require plugin_dir_path( __FILE__ ) . 'includes/config.php'; |
| 113 |
$config_loaded = true; |
| 114 |
} |
| 115 |
|
| 116 |
add_action( 'init', 'wpat_auto_translate_load_config', 0 ); |
| 117 |
|
| 118 |
|
| 119 |
/** |
| 120 |
* Begins execution of the plugin. |
| 121 |
* |
| 122 |
* Since everything within the plugin is registered via hooks, |
| 123 |
* then kicking off the plugin from this point in the file does |
| 124 |
* not affect the page life cycle. |
| 125 |
* |
| 126 |
* @since 1.0.0 |
| 127 |
*/ |
| 128 |
function wpat_run_auto_translate() { |
| 129 |
|
| 130 |
$plugin = new Auto_Translate(); |
| 131 |
$plugin->run(); |
| 132 |
|
| 133 |
} |
| 134 |
wpat_run_auto_translate(); |
| 135 |
|