TranslatePress – Translate Multilingual sites - Version 1.4.6

Version Description

  • Fixed a js compatibility error with mootools.js
  • Modified how the license page works and added plugin notifications
  • Allow compatibility fix for Translation Editor on certain environments
  • Fixed Safari bug with links when WooCommerce active
Download this release

Release Info

Developer madalin.ungureanu
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 1.4.6
Comparing to
See all releases

Code changes from version 1.4.5 to 1.4.6

assets/css/trp-back-end-style.css CHANGED
@@ -141,4 +141,15 @@ input.trp-translation-published{
141
142
.trp-settings-delimiter-border {
143
border-top: 1px solid #d9d9d9;
144
}
141
142
.trp-settings-delimiter-border {
143
border-top: 1px solid #d9d9d9;
144
+ }
145
+
146
+ /* License Page */
147
+ .trp-active-license{
148
+ line-height: 29px;
149
+ color: #008000;
150
+ }
151
+
152
+ .trp-invalid-license{
153
+ line-height: 29px;
154
+ color:#ca4a1f;
155
}
assets/js/trp-editor-script.js CHANGED
@@ -1527,83 +1527,82 @@ jQuery( function() {
1527
1528
/* handle gettext texts */
1529
var gettext_dictionaries = null;
1530
- jQuery(function(){
1531
- /* initial load and populate the dropdown with gettext strings */
1532
- function trp_initialize_gettext() {
1533
- /* get the gettext texts ids from the page and pass them to a ajax call to construct the dictonaries */
1534
- var gettext_strings = jQuery( '#trp-preview-iframe').contents().find( '[data-trpgettextoriginal]' );
1535
- gettext_string_ids = [];
1536
- gettext_strings.each( function(){
1537
- gettext_string_ids.push( jQuery(this).attr('data-trpgettextoriginal'));
1538
- });
1539
1540
- jQuery.ajax({
1541
- url: trp_ajax_url,
1542
- type: 'post',
1543
- dataType: 'json',
1544
- data: {
1545
- action: 'trp_gettext_get_translations',
1546
- security: trp_localized_text['gettextgettranslationsnonce'],
1547
- language: trp_language,
1548
- gettext_string_ids: JSON.stringify( gettext_string_ids )
1549
- },
1550
- success: function (response) {
1551
- gettext_dictionaries = response;
1552
- trp_lister = new TRP_Lister( gettext_dictionaries[trp_language] );
1553
- trp_lister.add_gettext_strings();
1554
- jQuery( '#trp-string-saved-ajax-loader' ).css('display', 'none');
1555
- },
1556
- error: function(errorThrown){
1557
- console.log( 'TranslatePress AJAX Request Error' );
1558
- jQuery( '#trp-string-saved-ajax-loader' ).css('display', 'none');
1559
- }
1560
1561
- });
1562
1563
- /* handle clicking the edit icon on gettext strings */
1564
- trp_lister = new TRP_Lister( [] );
1565
- jQuery(jQuery( '#trp-preview-iframe').contents()).on( 'mouseenter', '[data-trpgettextoriginal]', function(){
1566
- if( gettext_dictionaries == null )
1567
- return;//the strings haven't been loaded so don't do nothing yet
1568
1569
- gettext_string = this;
1570
1571
- if ( ! trpEditor.edit_translation_button ){
1572
- trpEditor.edit_translation_button = jQuery( trp_action_button_html );
1573
- }
1574
- trpEditor.edit_translation_button.children( ).removeClass( 'trp-active-icon' );
1575
- trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
1576
1577
- if ( jQuery(this).attr( 'type' ) == 'submit' || jQuery(this).attr( 'type' ) == 'button' || jQuery(this).attr('type') == 'search' || jQuery(this).attr('placeholder') || jQuery(this).attr('alt')) {
1578
- if( jQuery(this).parent('trp-wrap').length == 0 )
1579
- jQuery(this).wrap('<trp-wrap class="trpgettext-wrap"></trp-wrap>');
1580
- jQuery(this).parent().prepend(trpEditor.edit_translation_button);
1581
- }
1582
- else {
1583
- jQuery(this).prepend(trpEditor.edit_translation_button);
1584
- }
1585
- trpEditor.make_sure_pencil_icon_is_inside_view ( jQuery(this)[0] );
1586
- trpEditor.edit_translation_button.off( 'click' );
1587
- trpEditor.edit_translation_button.on( 'click', function(e){
1588
- // remove highlighting of possibly highlighted new translation block
1589
- trpEditor.preview_iframe.contents().find('.trp-highlight.trp-create-translation-block').removeClass('trp-highlight trp-create-translation-block');
1590
- e.preventDefault();
1591
- e.stopPropagation();
1592
- trp_lister.set_texts_select_to_gettext( jQuery(gettext_string) );
1593
- });
1594
- jQuery( this ).addClass( 'trp-highlight' );
1595
1596
});
1597
1598
- jQuery(jQuery( '#trp-preview-iframe').contents()).on( 'mouseleave', '[data-trpgettextoriginal]', function(){
1599
- jQuery( this ).removeClass( 'trp-highlight' );
1600
- });
1601
1602
1603
1604
- }
1605
- //trp_initialize_gettext();
1606
- //jQuery( "#trp-preview-iframe" ).load(function(){
1607
jQuery( "#trp-preview-iframe" ).load( trp_initialize_gettext );
1608
jQuery( "#trp-preview-iframe" ).on( 'trp_page_loaded', trp_initialize_gettext );
1609
1527
1528
/* handle gettext texts */
1529
var gettext_dictionaries = null;
1530
1531
+ /* initial load and populate the dropdown with gettext strings */
1532
+ function trp_initialize_gettext() {
1533
+ /* get the gettext texts ids from the page and pass them to a ajax call to construct the dictonaries */
1534
+ var gettext_strings = jQuery( '#trp-preview-iframe').contents().find( '[data-trpgettextoriginal]' );
1535
+ gettext_string_ids = [];
1536
+ gettext_strings.each( function(){
1537
+ gettext_string_ids.push( jQuery(this).attr('data-trpgettextoriginal'));
1538
+ });
1539
1540
+ jQuery.ajax({
1541
+ url: trp_ajax_url,
1542
+ type: 'post',
1543
+ dataType: 'json',
1544
+ data: {
1545
+ action: 'trp_gettext_get_translations',
1546
+ security: trp_localized_text['gettextgettranslationsnonce'],
1547
+ language: trp_language,
1548
+ gettext_string_ids: JSON.stringify( gettext_string_ids )
1549
+ },
1550
+ success: function (response) {
1551
+ gettext_dictionaries = response;
1552
+ trp_lister = new TRP_Lister( gettext_dictionaries[trp_language] );
1553
+ trp_lister.add_gettext_strings();
1554
+ jQuery( '#trp-string-saved-ajax-loader' ).css('display', 'none');
1555
+ },
1556
+ error: function(errorThrown){
1557
+ console.log( 'TranslatePress AJAX Request Error' );
1558
+ jQuery( '#trp-string-saved-ajax-loader' ).css('display', 'none');
1559
+ }
1560
1561
+ });
1562
1563
+ /* handle clicking the edit icon on gettext strings */
1564
+ trp_lister = new TRP_Lister( [] );
1565
+ jQuery(jQuery( '#trp-preview-iframe').contents()).on( 'mouseenter', '[data-trpgettextoriginal]', function(){
1566
+ if( gettext_dictionaries == null )
1567
+ return;//the strings haven't been loaded so don't do nothing yet
1568
1569
+ gettext_string = this;
1570
1571
+ if ( ! trpEditor.edit_translation_button ){
1572
+ trpEditor.edit_translation_button = jQuery( trp_action_button_html );
1573
+ }
1574
+ trpEditor.edit_translation_button.children( ).removeClass( 'trp-active-icon' );
1575
+ trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
1576
1577
+ if ( jQuery(this).attr( 'type' ) == 'submit' || jQuery(this).attr( 'type' ) == 'button' || jQuery(this).attr('type') == 'search' || jQuery(this).attr('placeholder') || jQuery(this).attr('alt')) {
1578
+ if( jQuery(this).parent('trp-wrap').length == 0 )
1579
+ jQuery(this).wrap('<trp-wrap class="trpgettext-wrap"></trp-wrap>');
1580
+ jQuery(this).parent().prepend(trpEditor.edit_translation_button);
1581
+ }
1582
+ else {
1583
+ jQuery(this).prepend(trpEditor.edit_translation_button);
1584
+ }
1585
+ trpEditor.make_sure_pencil_icon_is_inside_view ( jQuery(this)[0] );
1586
+ trpEditor.edit_translation_button.off( 'click' );
1587
+ trpEditor.edit_translation_button.on( 'click', function(e){
1588
+ // remove highlighting of possibly highlighted new translation block
1589
+ trpEditor.preview_iframe.contents().find('.trp-highlight.trp-create-translation-block').removeClass('trp-highlight trp-create-translation-block');
1590
+ e.preventDefault();
1591
+ e.stopPropagation();
1592
+ trp_lister.set_texts_select_to_gettext( jQuery(gettext_string) );
1593
});
1594
+ jQuery( this ).addClass( 'trp-highlight' );
1595
1596
+ });
1597
+
1598
+ jQuery(jQuery( '#trp-preview-iframe').contents()).on( 'mouseleave', '[data-trpgettextoriginal]', function(){
1599
+ jQuery( this ).removeClass( 'trp-highlight' );
1600
+ });
1601
1602
+ }
1603
1604
+ jQuery(function(){
1605
1606
jQuery( "#trp-preview-iframe" ).load( trp_initialize_gettext );
1607
jQuery( "#trp-preview-iframe" ).on( 'trp_page_loaded', trp_initialize_gettext );
1608
assets/js/trp-frontend-compatibility.js CHANGED
@@ -2,7 +2,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
2
function trpClearWooCartFragments(){
3
4
// clear WooCommerce cart fragments when switching language
5
- var trp_language_switcher_urls = document.querySelectorAll(".trp-language-switcher-container a:not(.trp-ls-disabled-language");
6
7
for (i = 0; i < trp_language_switcher_urls.length; i++) {
8
trp_language_switcher_urls[i].addEventListener("click", function(){
2
function trpClearWooCartFragments(){
3
4
// clear WooCommerce cart fragments when switching language
5
+ var trp_language_switcher_urls = document.querySelectorAll(".trp-language-switcher-container a:not(.trp-ls-disabled-language)");
6
7
for (i = 0; i < trp_language_switcher_urls.length; i++) {
8
trp_language_switcher_urls[i].addEventListener("click", function(){
assets/js/trp-translate-dom-changes.js CHANGED
@@ -74,7 +74,7 @@ function TRP_Translator(){
74
this.update_strings = function( response, strings_to_query ) {
75
if ( response != null && response[language_to_query] != null ){
76
var dictionary = {};
77
- for ( var j in strings_to_query ) {
78
var queried_string = strings_to_query[j];
79
var translation_found = false;
80
var initial_value = queried_string.original;
@@ -119,7 +119,7 @@ function TRP_Translator(){
119
}
120
}
121
}else{
122
- for ( var j in strings_to_query ) {
123
strings_to_query[j].node.textContent = strings_to_query[j].original;
124
}
125
}
74
this.update_strings = function( response, strings_to_query ) {
75
if ( response != null && response[language_to_query] != null ){
76
var dictionary = {};
77
+ for (var j = 0 ; j < strings_to_query.length; j++){
78
var queried_string = strings_to_query[j];
79
var translation_found = false;
80
var initial_value = queried_string.original;
119
}
120
}
121
}else{
122
+ for (var j = 0 ; j < strings_to_query.length; j++){
123
strings_to_query[j].node.textContent = strings_to_query[j].original;
124
}
125
}
class-translate-press.php CHANGED
@@ -18,6 +18,9 @@ class TRP_Translate_Press{
18
protected $languages;
19
protected $slug_manager;
20
protected $upgrade;
21
public static $translate_press = null;
22
23
/**
@@ -41,12 +44,13 @@ class TRP_Translate_Press{
41
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
42
define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
43
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
44
- define( 'TRP_PLUGIN_VERSION', '1.4.5' );
45
46
wp_cache_add_non_persistent_groups(array('trp'));
47
48
$this->load_dependencies();
49
$this->initialize_components();
50
$this->define_admin_hooks();
51
$this->define_frontend_hooks();
52
}
@@ -99,6 +103,36 @@ class TRP_Translate_Press{
99
$this->translation_manager = new TRP_Translation_Manager( $this->settings->get_settings() );
100
$this->notifications = new TRP_Trigger_Plugin_Notifications();
101
$this->upgrade = new TRP_Upgrade( $this->settings->get_settings() );
102
}
103
104
/**
@@ -137,6 +171,21 @@ class TRP_Translate_Press{
137
$this->loader->add_action( 'admin_enqueue_scripts', $this->upgrade, 'enqueue_update_script', 10, 1 );
138
$this->loader->add_action( 'wp_ajax_trp_update_database', $this->upgrade, 'trp_update_database' );
139
140
}
141
142
/**
18
protected $languages;
19
protected $slug_manager;
20
protected $upgrade;
21
+ protected $plugin_updater;
22
+ protected $license_page;
23
+ public $active_pro_addons = array();
24
public static $translate_press = null;
25
26
/**
44
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
45
define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
46
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
47
+ define( 'TRP_PLUGIN_VERSION', '1.4.6' );
48
49
wp_cache_add_non_persistent_groups(array('trp'));
50
51
$this->load_dependencies();
52
$this->initialize_components();
53
+ $this->get_active_pro_addons();
54
$this->define_admin_hooks();
55
$this->define_frontend_hooks();
56
}
103
$this->translation_manager = new TRP_Translation_Manager( $this->settings->get_settings() );
104
$this->notifications = new TRP_Trigger_Plugin_Notifications();
105
$this->upgrade = new TRP_Upgrade( $this->settings->get_settings() );
106
+ $this->plugin_updater = new TRP_Plugin_Updater();
107
+ $this->license_page = new TRP_LICENSE_PAGE();
108
+ }
109
+
110
+ /**
111
+ * We use this function to detect if we have any addons that require a license
112
+ */
113
+ public function get_active_pro_addons(){
114
+
115
+ //don't do nothing in frontend
116
+ if( !is_admin() )
117
+ return;
118
+
119
+ // the names of your product should match the download names in EDD exactly
120
+ $trp_all_pro_addons = array(
121
+ "tp-add-on-automatic-language-detection" => "Automatic User Language Detection",
122
+ "tp-add-on-browse-as-other-roles" => "Browse as other Role",
123
+ "tp-add-on-extra-languages" => "Multiple Languages",
124
+ "tp-add-on-navigation-based-on-language" => "Navigation Based on Language",
125
+ "tp-add-on-seo-pack" => "SEO Pack",
126
+ "tp-add-on-translator-accounts" => "Translator Accounts",
127
+ );
128
+ $active_plugins = get_option('active_plugins');
129
+ foreach ( $trp_all_pro_addons as $trp_pro_addon_folder => $trp_pro_addon_name ){
130
+ foreach( $active_plugins as $active_plugin ){
131
+ if( strpos( $active_plugin, $trp_pro_addon_folder.'/' ) === 0 ){
132
+ $this->active_pro_addons[$trp_pro_addon_folder] = $trp_pro_addon_name;
133
+ }
134
+ }
135
+ }
136
}
137
138
/**
171
$this->loader->add_action( 'admin_enqueue_scripts', $this->upgrade, 'enqueue_update_script', 10, 1 );
172
$this->loader->add_action( 'wp_ajax_trp_update_database', $this->upgrade, 'trp_update_database' );
173
174
+ /* add hooks for license operations */
175
+ if( !empty( $this->active_pro_addons ) ) {
176
+ $this->loader->add_action('admin_init', $this->plugin_updater, 'activate_license');
177
+ $this->loader->add_filter('pre_set_site_transient_update_plugins', $this->plugin_updater, 'check_license');
178
+ $this->loader->add_action('admin_init', $this->plugin_updater, 'deactivate_license');
179
+ $this->loader->add_action('admin_notices', $this->plugin_updater, 'admin_activation_notices');
180
+ }
181
+
182
+ /* add license page */
183
+ global $trp_license_page;//this global was used in the addons, so we need to use it here also so we don't initialize the license page multiple times (backward compatibility)
184
+ if( !isset( $trp_license_page ) ) {
185
+ $trp_license_page = $this->license_page;
186
+ $this->loader->add_action('admin_menu', $this->license_page, 'license_menu');
187
+ }
188
+
189
}
190
191
/**
includes/class-edd-sl-plugin-updater.php ADDED
@@ -0,0 +1,790 @@
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Allows plugins to use their own update API.
8
+ *
9
+ * @author Easy Digital Downloads
10
+ * @version 1.6.13
11
+ */
12
+ class TRP_EDD_SL_Plugin_Updater {
13
+
14
+ private $api_url = '';
15
+ private $api_data = array();
16
+ private $name = '';
17
+ private $slug = '';
18
+ private $version = '';
19
+ private $wp_override = false;
20
+ private $cache_key = '';
21
+
22
+ /**
23
+ * Class constructor.
24
+ *
25
+ * @uses plugin_basename()
26
+ * @uses hook()
27
+ *
28
+ * @param string $_api_url The URL pointing to the custom API endpoint.
29
+ * @param string $_plugin_file Path to the plugin file.
30
+ * @param array $_api_data Optional data to send with API calls.
31
+ */
32
+ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+
34
+ global $edd_plugin_data;
35
+
36
+ $this->api_url = trailingslashit( $_api_url );
37
+ $this->api_data = $_api_data;
38
+ $this->name = plugin_basename( $_plugin_file );
39
+ $this->slug = basename( $_plugin_file, '.php' );
40
+ $this->version = $_api_data['version'];
41
+ $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
42
+ $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
43
+ $this->cache_key = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
44
+
45
+ $edd_plugin_data[ $this->slug ] = $this->api_data;
46
+
47
+ // Set up hooks.
48
+ $this->init();
49
+
50
+ }
51
+
52
+ /**
53
+ * Set up WordPress filters to hook into WP's update process.
54
+ *
55
+ * @uses add_filter()
56
+ *
57
+ * @return void
58
+ */
59
+ public function init() {
60
+
61
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
62
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
63
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
64
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
65
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
66
+
67
+ }
68
+
69
+ /**
70
+ * Check for Updates at the defined API endpoint and modify the update array.
71
+ *
72
+ * This function dives into the update API just when WordPress creates its update array,
73
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
74
+ * It is reassembled from parts of the native WordPress plugin update code.
75
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
76
+ *
77
+ * @uses api_request()
78
+ *
79
+ * @param array $_transient_data Update array build by WordPress.
80
+ * @return array Modified update array with custom plugin data.
81
+ */
82
+ public function check_update( $_transient_data ) {
83
+
84
+ global $pagenow;
85
+
86
+ if ( ! is_object( $_transient_data ) ) {
87
+ $_transient_data = new stdClass;
88
+ }
89
+
90
+ if ( 'plugins.php' == $pagenow && is_multisite() ) {
91
+ return $_transient_data;
92
+ }
93
+
94
+ if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
95
+ return $_transient_data;
96
+ }
97
+
98
+ $version_info = $this->get_cached_version_info();
99
+
100
+ if ( false === $version_info ) {
101
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
102
+
103
+ $this->set_version_info_cache( $version_info );
104
+
105
+ }
106
+
107
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
108
+
109
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
110
+
111
+ $_transient_data->response[ $this->name ] = $version_info;
112
+
113
+ }
114
+
115
+ $_transient_data->last_checked = current_time( 'timestamp' );
116
+ $_transient_data->checked[ $this->name ] = $this->version;
117
+
118
+ }
119
+
120
+ return $_transient_data;
121
+ }
122
+
123
+ /**
124
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
125
+ *
126
+ * @param string $file
127
+ * @param array $plugin
128
+ */
129
+ public function show_update_notification( $file, $plugin ) {
130
+
131
+ if ( is_network_admin() ) {
132
+ return;
133
+ }
134
+
135
+ if( ! current_user_can( 'update_plugins' ) ) {
136
+ return;
137
+ }
138
+
139
+ if( ! is_multisite() ) {
140
+ return;
141
+ }
142
+
143
+ if ( $this->name != $file ) {
144
+ return;
145
+ }
146
+
147
+ // Remove our filter on the site transient
148
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
149
+
150
+ $update_cache = get_site_transient( 'update_plugins' );
151
+
152
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
153
+
154
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
155
+
156
+ $version_info = $this->get_cached_version_info();
157
+
158
+ if ( false === $version_info ) {
159
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
160
+
161
+ $this->set_version_info_cache( $version_info );
162
+ }
163
+
164
+ if ( ! is_object( $version_info ) ) {
165
+ return;
166
+ }
167
+
168
+ if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
169
+
170
+ $update_cache->response[ $this->name ] = $version_info;
171
+
172
+ }
173
+
174
+ $update_cache->last_checked = current_time( 'timestamp' );
175
+ $update_cache->checked[ $this->name ] = $this->version;
176
+
177
+ set_site_transient( 'update_plugins', $update_cache );
178
+
179
+ } else {
180
+
181
+ $version_info = $update_cache->response[ $this->name ];
182
+
183
+ }
184
+
185
+ // Restore our filter
186
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
187
+
188
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
189
+
190
+ // build a plugin list row, with update notification
191
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
192
+ # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
193
+ echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
194
+ echo '<td colspan="3" class="plugin-update colspanchange">';
195
+ echo '<div class="update-message notice inline notice-warning notice-alt">';
196
+
197
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
198
+
199
+ if ( empty( $version_info->download_link ) ) {
200
+ printf(
201
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
202
+ esc_html( $version_info->name ),
203
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
204
+ esc_html( $version_info->new_version ),
205
+ '</a>'
206
+ );
207
+ } else {
208
+ printf(
209
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
210
+ esc_html( $version_info->name ),
211
+ '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
212
+ esc_html( $version_info->new_version ),
213
+ '</a>',
214
+ '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
215
+ '</a>'
216
+ );
217
+ }
218
+
219
+ do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
220
+
221
+ echo '</div></td></tr>';
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Updates information on the "View version x.x details" page with custom data.
227
+ *
228
+ * @uses api_request()
229
+ *
230
+ * @param mixed $_data
231
+ * @param string $_action
232
+ * @param object $_args
233
+ * @return object $_data
234
+ */
235
+ public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
236
+
237
+ if ( $_action != 'plugin_information' ) {
238
+
239
+ return $_data;
240
+
241
+ }
242
+
243
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
244
+
245
+ return $_data;
246
+
247
+ }
248
+
249
+ $to_send = array(
250
+ 'slug' => $this->slug,
251
+ 'is_ssl' => is_ssl(),
252
+ 'fields' => array(
253
+ 'banners' => array(),
254
+ 'reviews' => false
255
+ )
256
+ );
257
+
258
+ $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
259
+
260
+ // Get the transient where we store the api request for this plugin for 24 hours
261
+ $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
262
+
263
+ //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
264
+ if ( empty( $edd_api_request_transient ) ) {
265
+
266
+ $api_response = $this->api_request( 'plugin_information', $to_send );
267
+
268
+ // Expires in 3 hours
269
+ $this->set_version_info_cache( $api_response, $cache_key );
270
+
271
+ if ( false !== $api_response ) {
272
+ $_data = $api_response;
273
+ }
274
+
275
+ } else {
276
+ $_data = $edd_api_request_transient;
277
+ }
278
+
279
+ // Convert sections into an associative array, since we're getting an object, but Core expects an array.
280
+ if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
281
+ $new_sections = array();
282
+ foreach ( $_data->sections as $key => $value ) {
283
+ $new_sections[ $key ] = $value;
284
+ }
285
+
286
+ $_data->sections = $new_sections;
287
+ }
288
+
289
+ // Convert banners into an associative array, since we're getting an object, but Core expects an array.
290
+ if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
291
+ $new_banners = array();
292
+ foreach ( $_data->banners as $key => $value ) {
293
+ $new_banners[ $key ] = $value;
294
+ }
295
+
296
+ $_data->banners = $new_banners;
297
+ }
298
+
299
+ return $_data;
300
+ }
301
+
302
+ /**
303
+ * Disable SSL verification in order to prevent download update failures
304
+ *
305
+ * @param array $args
306
+ * @param string $url
307
+ * @return object $array
308
+ */
309
+ public function http_request_args( $args, $url ) {
310
+
311
+ $verify_ssl = $this->verify_ssl();
312
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
313
+ $args['sslverify'] = $verify_ssl;
314
+ }
315
+ return $args;
316
+
317
+ }
318
+
319
+ /**
320
+ * Calls the API and, if successfull, returns the object delivered by the API.
321
+ *
322
+ * @uses get_bloginfo()
323
+ * @uses wp_remote_post()
324
+ * @uses is_wp_error()
325
+ *
326
+ * @param string $_action The requested action.
327
+ * @param array $_data Parameters for the API action.
328
+ * @return false|object
329
+ */
330
+ private function api_request( $_action, $_data ) {
331
+
332
+ global $wp_version;
333
+
334
+ $data = array_merge( $this->api_data, $_data );
335
+
336
+ if ( $data['slug'] != $this->slug ) {
337
+ return;
338
+ }
339
+
340
+ if( $this->api_url == trailingslashit (home_url() ) ) {
341
+ return false; // Don't allow a plugin to ping itself
342
+ }
343
+
344
+ $api_params = array(
345
+ 'edd_action' => 'get_version',
346
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
347
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
348
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
349
+ 'version' => isset( $data['version'] ) ? $data['version'] : false,
350
+ 'slug' => $data['slug'],
351
+ 'author' => $data['author'],
352
+ 'url' => home_url(),
353
+ 'beta' => ! empty( $data['beta'] ),
354
+ );
355
+
356
+ $verify_ssl = $this->verify_ssl();
357
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
358
+
359
+ if ( ! is_wp_error( $request ) ) {
360
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
361
+ }
362
+
363
+ if ( $request && isset( $request->sections ) ) {
364
+ $request->sections = maybe_unserialize( $request->sections );
365
+ } else {
366
+ $request = false;
367
+ }
368
+
369
+ if ( $request && isset( $request->banners ) ) {
370
+ $request->banners = maybe_unserialize( $request->banners );
371
+ }
372
+
373
+ if( ! empty( $request->sections ) ) {
374
+ foreach( $request->sections as $key => $section ) {
375
+ $request->$key = (array) $section;
376
+ }
377
+ }
378
+
379
+ return $request;
380
+ }
381
+
382
+ public function show_changelog() {
383
+
384
+ global $edd_plugin_data;
385
+
386
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
387
+ return;
388
+ }
389
+
390
+ if( empty( $_REQUEST['plugin'] ) ) {
391
+ return;
392
+ }
393
+
394
+ if( empty( $_REQUEST['slug'] ) ) {
395
+ return;
396
+ }
397
+
398
+ if( ! current_user_can( 'update_plugins' ) ) {
399
+ wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
400
+ }
401
+
402
+ $data = $edd_plugin_data[ $_REQUEST['slug'] ];
403
+ $beta = ! empty( $data['beta'] ) ? true : false;
404
+ $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
405
+ $version_info = $this->get_cached_version_info( $cache_key );
406
+
407
+ if( false === $version_info ) {
408
+
409
+ $api_params = array(
410
+ 'edd_action' => 'get_version',
411
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
412
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
413
+ 'slug' => $_REQUEST['slug'],
414
+ 'author' => $data['author'],
415
+ 'url' => home_url(),
416
+ 'beta' => ! empty( $data['beta'] )
417
+ );
418
+
419
+ $verify_ssl = $this->verify_ssl();
420
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
421
+
422
+ if ( ! is_wp_error( $request ) ) {
423
+ $version_info = json_decode( wp_remote_retrieve_body( $request ) );
424
+ }
425
+
426
+
427
+ if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
428
+ $version_info->sections = maybe_unserialize( $version_info->sections );
429
+ } else {
430
+ $version_info = false;
431
+ }
432
+
433
+ if( ! empty( $version_info ) ) {
434
+ foreach( $version_info->sections as $key => $section ) {
435
+ $version_info->$key = (array) $section;
436
+ }
437
+ }
438
+
439
+ $this->set_version_info_cache( $version_info, $cache_key );
440
+
441
+ }
442
+
443
+ if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
444
+ echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
445
+ }
446
+
447
+ exit;
448
+ }
449
+
450
+ public function get_cached_version_info( $cache_key = '' ) {
451
+
452
+ if( empty( $cache_key ) ) {
453
+ $cache_key = $this->cache_key;
454
+ }
455
+
456
+ $cache = get_option( $cache_key );
457
+
458
+ if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
459
+ return false; // Cache is expired
460
+ }
461
+
462
+ return json_decode( $cache['value'] );
463
+
464
+ }
465
+
466
+ public function set_version_info_cache( $value = '', $cache_key = '' ) {
467
+
468
+ if( empty( $cache_key ) ) {
469
+ $cache_key = $this->cache_key;
470
+ }
471
+
472
+ $data = array(
473
+ 'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
474
+ 'value' => json_encode( $value )
475
+ );
476
+
477
+ update_option( $cache_key, $data );
478
+
479
+ }
480
+
481
+ /**
482
+ * Returns if the SSL of the store should be verified.
483
+ *
484
+ * @since 1.6.13
485
+ * @return bool
486
+ */
487
+ private function verify_ssl() {
488
+ return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
489
+ }
490
+
491
+ }
492
+
493
+
494
+ if( !class_exists('TRP_LICENSE_PAGE') ) {
495
+ class TRP_LICENSE_PAGE
496
+ {
497
+ public function __construct(){
498
+ }
499
+
500
+ public function license_menu()
501
+ {
502
+ add_submenu_page(
503
+ 'TRPHidden',
504
+ 'TranslatePress License',
505
+ 'TRPHidden',
506
+ 'manage_options',
507
+ 'trp_license_key',
508
+ array($this, 'license_page')
509
+ );
510
+ }
511
+
512
+ public function license_page()
513
+ {
514
+ $license = get_option('trp_license_key');
515
+ $status = get_option('trp_license_status');
516
+ $details = get_option('trp_license_details');
517
+ $action = 'options.php';
518
+ ob_start();
519
+ require TRP_PLUGIN_DIR . 'partials/license-settings-page.php';
520
+ echo ob_get_clean();
521
+ }
522
+ }
523
+ }
524
+
525
+ class TRP_Plugin_Updater{
526
+
527
+ private $store_url = "https://translatepress.com";
528
+
529
+ public function __construct(){
530
+ }
531
+
532
+ protected function get_option( $license_key_option ){
533
+ return get_option( $license_key_option );
534
+ }
535
+
536
+ protected function delete_option( $license_key_option ){
537
+ delete_option( $license_key_option );
538
+ }
539
+
540
+ protected function update_option( $license_key_option, $value ){
541
+ update_option( $license_key_option, $value );
542
+ }
543
+
544
+ protected function license_page_url( ){
545
+ return admin_url( 'admin.php?page=trp_license_key' );
546
+ }
547
+
548
+ public function edd_sanitize_license( $new ) {
549
+ $new = sanitize_text_field($new);
550
+ $old = $this->get_option( 'trp_license_key' );
551
+ if( $old && $old != $new ) {
552
+ $this->delete_option( 'trp_license_status' ); // new license has been entered, so must reactivate
553
+ }
554
+ return $new;
555
+ }
556
+
557
+ /**
558
+ * This function is run when wordpress checks for updates ( twice a day I believe )
559
+ * @param $transient_data
560
+ * @return mixed
561
+ */
562
+ public function check_license( $transient_data ){
563
+
564
+ $license = trim( $this->get_option( 'trp_license_key' ) );
565
+ if( $license ) {
566
+ $license_status = trim($this->get_option('trp_license_status'));
567
+
568
+ if ($license_status) { // do this only if the user activated the license on this site
569
+ $license_information_for_all_addons = array();
570
+
571
+ $trp = TRP_Translate_Press::get_trp_instance();
572
+ if (!empty($trp->active_pro_addons)) {
573
+ foreach ($trp->active_pro_addons as $active_pro_addon_name) {
574
+ // data to send in our API request
575
+ $api_params = array(
576
+ 'edd_action' => 'activate_license',//as the license is already activated this does not do anything. We could use check_license action but it gives different results so we can't use it consistently with the result we get from the moment we activate it
577
+ 'license' => $license,
578
+ 'item_name' => urlencode($active_pro_addon_name), // the name of our product in EDD
579
+ 'url' => home_url()
580
+ );
581
+
582
+ // Call the custom API.
583
+ $response = wp_remote_post($this->store_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
584
+
585
+ // make sure the response came back okay
586
+ if (!is_wp_error($response)) {
587
+ $license_data = json_decode(wp_remote_retrieve_body($response));
588
+ if (false === $license_data->success) {
589
+ $license_information_for_all_addons['invalid'][] = $license_data;
590
+ break;//we only need one failure
591
+ } else {
592
+ $license_information_for_all_addons['valid'][] = $license_data;
593
+ }
594
+ }
595
+ }
596
+ }
597
+
598
+ //store the license reponse for each addon in the database
599
+ $this->update_option('trp_license_details', $license_information_for_all_addons);
600
+
601
+ }
602
+ }
603
+
604
+ return $transient_data;
605
+ }
606
+
607
+ public function admin_activation_notices() {
608
+ if ( isset( $_GET['trp_sl_activation'] ) && ! empty( $_GET['message'] ) ) {
609
+
610
+ $message = urldecode( $_GET['message'] );
611
+
612
+ switch( $_GET['trp_sl_activation'] ) {
613
+ case 'false':
614
+ $class ="error";
615
+ break;
616
+ case 'true':
617
+ default:
618
+ $class ="updated";
619
+ break;
620
+ }
621
+
622
+ ?>
623
+ <div class="<?php echo $class; ?>">
624
+ <p><?php echo wp_kses_post( $message ); ?></p>
625
+ </div>
626
+ <?php
627
+ }
628
+ }
629
+
630
+ public function activate_license() {
631
+
632
+ // listen for our activate button to be clicked
633
+ if( isset( $_POST['trp_edd_license_activate'] ) ) {
634
+ // run a quick security check
635
+ if( ! check_admin_referer( 'trp_license_nonce', 'trp_license_nonce' ) )
636
+ return; // get out if we didn't click the Activate button
637
+
638
+ // save the license
639
+ $license = $this->edd_sanitize_license( trim( $_POST['trp_license_key'] ) );
640
+ $this->update_option( 'trp_license_key', $license );
641
+
642
+ $message = array();//we will check the license for each addon and we will sotre the messages in an array
643
+ $license_information_for_all_addons = array();
644
+
645
+ $trp = TRP_Translate_Press::get_trp_instance();
646
+ if( !empty( $trp->active_pro_addons ) ){
647
+ foreach ( $trp->active_pro_addons as $active_pro_addon_name ){
648
+ // data to send in our API request
649
+ $api_params = array(
650
+ 'edd_action' => 'activate_license',
651
+ 'license' => $license,
652
+ 'item_name' => urlencode( $active_pro_addon_name ), // the name of our product in EDD
653
+ 'url' => home_url()
654
+ );
655
+
656
+ // Call the custom API.
657
+ $response = wp_remote_post( $this->store_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
658
+
659
+ // make sure the response came back okay
660
+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
661
+
662
+ $response_error_message = $response->get_error_message();
663
+ $message[] = ( is_wp_error( $response ) && ! empty( $response_error_message ) ) ? $response->get_error_message() : __( 'An error occurred, please try again.', 'translatepress-multilingual' );
664
+
665
+ } else {
666
+
667
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
668
+
669
+ if ( false === $license_data->success ) {
670
+
671
+ switch( $license_data->error ) {
672
+ case 'expired' :
673
+ $message[] = sprintf(
674
+ __( 'Your license key expired on %s.', 'translatepress-multilingual' ),
675
+ date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
676
+ );
677
+ break;
678
+ case 'revoked' :
679
+ $message[] = __( 'Your license key has been disabled.', 'translatepress-multilingual' );
680
+ break;
681
+ case 'missing' :
682
+ $message[] = __( 'Invalid license.', 'translatepress-multilingual' );
683
+ break;
684
+ case 'invalid' :
685
+ case 'site_inactive' :
686
+ $message[] = __( 'Your license is not active for this URL.', 'translatepress-multilingual' );
687
+ break;
688
+ case 'item_name_mismatch' :
689
+ $message[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'translatepress-multilingual' ), $active_pro_addon_name );
690
+ break;
691
+ case 'no_activations_left':
692
+ $message[] = __( 'Your license key has reached its activation limit.', 'translatepress-multilingual' );
693
+ break;
694
+ default :
695
+ $message[] = __( 'An error occurred, please try again.', 'translatepress-multilingual' );
696
+ break;
697
+ }
698
+
699
+ $license_information_for_all_addons['invalid'][] = $license_data;
700
+
701
+ }
702
+ else{
703
+ $license_information_for_all_addons['valid'][] = $license_data;
704
+ }
705
+
706
+ }
707
+ }
708
+ }
709
+
710
+ //store the license reponse for each addon in the database
711
+ $this->update_option( 'trp_license_details', $license_information_for_all_addons );
712
+
713
+
714
+ // Check if anything passed on a message constituting a failure
715
+ if ( ! empty( $message ) ) {
716
+ $message = implode( "<br/>", array_unique($message) );//if we got the same message for multiple addons show just one, and add a br in case we show multiple messages
717
+ $redirect = add_query_arg( array( 'trp_sl_activation' => 'false', 'message' => urlencode( $message ) ), $this->license_page_url() );
718
+
719
+ wp_redirect( $redirect );
720
+ exit();
721
+ }
722
+
723
+ // $license_data->license will be either "valid" or "invalid"
724
+
725
+ $this->update_option( 'trp_license_status', $license_data->license );
726
+ wp_redirect( add_query_arg( array( 'trp_sl_activation' => 'true', 'message' => urlencode( __( 'You have successfully activated your license', 'translatepress-multilingual' ) ) ), $this->license_page_url() ) );
727
+ exit();
728
+ }
729
+ }
730
+
731
+
732
+
733
+ function deactivate_license() {
734
+
735
+ // listen for our activate button to be clicked
736
+ if( isset( $_POST['trp_edd_license_deactivate'] ) ) {
737
+
738
+ // run a quick security check
739
+ if( ! check_admin_referer( 'trp_license_nonce', 'trp_license_nonce' ) )
740
+ return; // get out if we didn't click the Activate button
741
+
742
+ // retrieve the license from the database
743
+ $license = trim( $this->get_option( 'trp_license_key' ) );
744
+
745
+ $trp = TRP_Translate_Press::get_trp_instance();
746
+ if( !empty( $trp->active_pro_addons ) ){
747
+ foreach ( $trp->active_pro_addons as $active_pro_addon_name ){//this loop will actually run just once, as we redirect at the end in all cases
748
+
749
+ // data to send in our API request
750
+ $api_params = array(
751
+ 'edd_action' => 'deactivate_license',
752
+ 'license' => $license,
753
+ 'item_name' => urlencode( $active_pro_addon_name ), // the name of our product in EDD
754
+ 'url' => home_url()
755
+ );
756
+
757
+ // Call the custom API.
758
+ $response = wp_remote_post( $this->store_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
759
+
760
+ // make sure the response came back okay
761
+ if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
762
+
763
+ if ( is_wp_error( $response ) ) {
764
+ $message = $response->get_error_message();
765
+ } else {
766
+ $message = __( 'An error occurred, please try again.', 'translatepress-multilingual' );
767
+ }
768
+
769
+ $redirect = add_query_arg( array( 'trp_sl_activation' => 'false', 'message' => urlencode( $message ) ), $this->license_page_url() );
770
+ wp_redirect( $redirect );
771
+ exit();
772
+ }
773
+
774
+ // decode the license data
775
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
776
+
777
+ // $license_data->license will be either "deactivated" or "failed"
778
+ if( $license_data->license == 'deactivated' ) {
779
+ delete_option( 'trp_license_status' );
780
+ }
781
+
782
+ wp_redirect( $this->license_page_url() );
783
+ exit();
784
+ }
785
+ }
786
+ }
787
+ }
788
+
789
+
790
+ }
includes/class-plugin-notices.php CHANGED
@@ -12,11 +12,13 @@ class TRP_Add_General_Notices{
12
public $notificationClass = '';
13
public $startDate = '';
14
public $endDate = '';
15
16
- function __construct( $notificationId, $notificationMessage, $notificationClass = 'updated' , $startDate = '', $endDate = '' ){
17
$this->notificationId = $notificationId;
18
$this->notificationMessage = $notificationMessage;
19
$this->notificationClass = $notificationClass;
20
21
if( !empty( $startDate ) && time() < strtotime( $startDate ) )
22
return;
@@ -39,7 +41,7 @@ class TRP_Add_General_Notices{
39
40
if ( current_user_can( 'manage_options' ) ){
41
// Check that the user hasn't already clicked to ignore the message
42
- if ( ! get_user_meta($user_id, $this->notificationId.'_dismiss_notification' ) ) {
43
echo $finalMessage = apply_filters($this->notificationId.'_notification_message','<div class="'. $this->notificationClass .'" >'.$this->notificationMessage.'</div>', $this->notificationMessage);
44
}
45
do_action( $this->notificationId.'_notification_displayed', $current_user, $pagenow );
@@ -156,7 +158,7 @@ Class TRP_Plugin_Notifications {
156
*
157
*
158
*/
159
- public function add_notification( $notification_id = '', $notification_message = '', $notification_class = 'update-nag', $count_in_menu = true, $count_in_submenu = array() ) {
160
161
if( empty( $notification_id ) )
162
return;
@@ -166,8 +168,20 @@ Class TRP_Plugin_Notifications {
166
167
global $current_user;
168
169
- if( get_user_meta( $current_user->ID, $notification_id . '_dismiss_notification' ) )
170
- return;
171
172
$this->notifications[$notification_id] = array(
173
'id' => $notification_id,
@@ -178,8 +192,8 @@ Class TRP_Plugin_Notifications {
178
);
179
180
181
- if( $this->is_plugin_page() ) {
182
- new TRP_Add_General_Notices( $notification_id, $notification_message, $notification_class );
183
}
184
185
}
@@ -269,10 +283,10 @@ Class TRP_Plugin_Notifications {
269
270
271
/**
272
- *
273
*
274
*/
275
- protected function is_plugin_page() {
276
if( !empty( $this->pluginPages ) ){
277
foreach ( $this->pluginPages as $pluginPage ){
278
if( ! empty( $_GET['page'] ) && false !== strpos( $_GET['page'], $pluginPage ) )
@@ -316,6 +330,54 @@ class TRP_Trigger_Plugin_Notifications{
316
}
317
318
319
/* this must be unique */
320
$notification_id = 'trp_new_addon_auto_detect_language';
321
12
public $notificationClass = '';
13
public $startDate = '';
14
public $endDate = '';
15
+ public $force_show = false;//this attribute ignores the dismiss notification
16
17
+ function __construct( $notificationId, $notificationMessage, $notificationClass = 'updated' , $startDate = '', $endDate = '', $force_show = false ){
18
$this->notificationId = $notificationId;
19
$this->notificationMessage = $notificationMessage;
20
$this->notificationClass = $notificationClass;
21
+ $this->force_show = $force_show;
22
23
if( !empty( $startDate ) && time() < strtotime( $startDate ) )
24
return;
41
42
if ( current_user_can( 'manage_options' ) ){
43
// Check that the user hasn't already clicked to ignore the message
44
+ if ( ! get_user_meta($user_id, $this->notificationId.'_dismiss_notification' ) || $this->force_show ) {//ignore the dismissal if we have force_show
45
echo $finalMessage = apply_filters($this->notificationId.'_notification_message','<div class="'. $this->notificationClass .'" >'.$this->notificationMessage.'</div>', $this->notificationMessage);
46
}
47
do_action( $this->notificationId.'_notification_displayed', $current_user, $pagenow );
158
*
159
*
160
*/
161
+ public function add_notification( $notification_id = '', $notification_message = '', $notification_class = 'update-nag', $count_in_menu = true, $count_in_submenu = array(), $show_in_all_backend = false ) {
162
163
if( empty( $notification_id ) )
164
return;
168
169
global $current_user;
170
171
+
172
+ /**
173
+ * added a $show_in_all_backend argument in version 1.4.6 that allows some notifications to be displayed on all the pages not just the plugin pages
174
+ * we needed it for license notifications
175
+ */
176
+ $force_show = false;
177
+ if( get_user_meta( $current_user->ID, $notification_id . '_dismiss_notification' ) ) {
178
+ if( !($this->is_plugin_page() && $show_in_all_backend) ){
179
+ return;
180
+ }
181
+ else{
182
+ $force_show = true; //if $show_in_all_backend is true then we ignore the dismiss on plugin pages, but on the rest of the pages it can be dismissed
183
+ }
184
+ }
185
186
$this->notifications[$notification_id] = array(
187
'id' => $notification_id,
192
);
193
194
195
+ if( $this->is_plugin_page() || $show_in_all_backend ) {
196
+ new TRP_Add_General_Notices( $notification_id, $notification_message, $notification_class, '', '', $force_show );
197
}
198
199
}
283
284
285
/**
286
+ * Test if we are an a page that belong to our plugin
287
*
288
*/
289
+ public function is_plugin_page() {
290
if( !empty( $this->pluginPages ) ){
291
foreach ( $this->pluginPages as $pluginPage ){
292
if( ! empty( $_GET['page'] ) && false !== strpos( $_GET['page'], $pluginPage ) )
330
}
331
332
333
+ /* License Notifications */
334
+ $license_details = get_option( 'trp_license_details' );
335
+ if( !empty($license_details) ){
336
+ /* if we have any invalid response for any of the addon show just the error notification and ignore any valid responses */
337
+ if( !empty( $license_details['invalid'] ) ){
338
+
339
+ //take the first addon details (it should be the same for the rest of the invalid ones)
340
+ $license_detail = $license_details['invalid'][0];
341
+
342
+ /* this must be unique */
343
+ $notification_id = 'trp_invalid_license';
344
+ $message = '<p style="padding-right:30px;">';
345
+ if( $license_detail->error == 'missing' )
346
+ $message .= sprintf( __('<p>Your <strong>TranslatePress</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>' , 'translatepress-multilingual' ), "<a href='". admin_url('/admin.php?page=trp_license_key') ."'>", "</a>", "<a href='https://translatepress.com/pricing/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-SN-Purchase' target='_blank' class='button-primary'>", "</a>" );
347
+ elseif($license_detail->error == 'expired')
348
+ $message .= sprintf( __('<p>Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s</p>' , 'translatepress-multilingual' ), "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank'>", "</a>", "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank' class='button-primary'>", "</a>" );
349
+ $message .= '</p>';
350
+
351
+ if( !$notifications->is_plugin_page() ) {
352
+ //make sure to use the trp_dismiss_admin_notification arg
353
+ $message .= '<a style="text-decoration: none;z-index:100;" href="' . add_query_arg(array('trp_dismiss_admin_notification' => $notification_id)) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __('Dismiss this notice.', 'translatepress-multilingual') . '</span></a>';
354
+ }
355
+
356
+ $notifications->add_notification( $notification_id, $message, 'trp-notice notice error is-dismissible', true, array('translate-press'), true);
357
+ }
358
+ elseif( !empty( $license_details['valid'] ) ){
359
+
360
+ //take the first addon details (it should be the same for the rest of the valid ones)
361
+ $license_detail = $license_details['valid'][0];
362
+
363
+ if( isset($license_detail->auto_billing) && !$license_detail->auto_billing ) {//auto_billing was added by us in a filter on translatepress.com
364
+ if ((strtotime($license_detail->expires) - time()) / (60 * 60 * 24) < 30) {
365
+
366
+ /* this must be unique */
367
+ $notification_id = 'trp_will_expire_license';
368
+ $message = '<p style="padding-right:30px;">' . sprintf( __( 'Your <strong>TranslatePress</strong> license will expire on %1$s. Please %2$sRenew Your Licence%3$s to continue receiving access to product downloads, automatic updates and support.', 'translatepress-multilingual'), date_i18n( get_option( 'date_format' ), strtotime( $license_detail->expires, current_time( 'timestamp' ) ) ), '<a href="https://translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal" target="_blank">', '</a>'). '</p>';
369
+
370
+ if (!$notifications->is_plugin_page()) {
371
+ //make sure to use the trp_dismiss_admin_notification arg
372
+ $message .= '<a style="text-decoration: none;z-index:100;" href="' . add_query_arg(array('trp_dismiss_admin_notification' => $notification_id)) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __('Dismiss this notice.', 'translatepress-multilingual') . '</span></a>';
373
+ }
374
+
375
+ $notifications->add_notification($notification_id, $message, 'trp-notice notice notice-info is-dismissible', true, array('translate-press'), true);
376
+ }
377
+ }
378
+ }
379
+ }
380
+
381
/* this must be unique */
382
$notification_id = 'trp_new_addon_auto_detect_language';
383
includes/class-settings.php CHANGED
@@ -392,6 +392,12 @@ class TRP_Settings{
392
)
393
));
394
395
if( class_exists('TRP_LICENSE_PAGE') ) {
396
$tabs[] = array(
397
'name' => __( 'License', 'translatepress-multilingual' ),
@@ -399,11 +405,6 @@ class TRP_Settings{
399
'page' => 'trp_license_key'
400
);
401
}
402
- $tabs[] = array(
403
- 'name' => __( 'Addons', 'translatepress-multilingual' ),
404
- 'url' => admin_url( 'admin.php?page=trp_addons_page' ),
405
- 'page' => 'trp_addons_page'
406
- );
407
408
$active_tab = 'translate-press';
409
if ( isset( $_GET['page'] ) ){
392
)
393
));
394
395
+ $tabs[] = array(
396
+ 'name' => __( 'Addons', 'translatepress-multilingual' ),
397
+ 'url' => admin_url( 'admin.php?page=trp_addons_page' ),
398
+ 'page' => 'trp_addons_page'
399
+ );
400
+
401
if( class_exists('TRP_LICENSE_PAGE') ) {
402
$tabs[] = array(
403
'name' => __( 'License', 'translatepress-multilingual' ),
405
'page' => 'trp_license_key'
406
);
407
}
408
409
$active_tab = 'translate-press';
410
if ( isset( $_GET['page'] ) ){
index.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: TranslatePress - Multilingual
4
Plugin URI: https://translatepress.com/
5
Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
- Version: 1.4.5
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
Text Domain: translatepress-multilingual
@@ -35,4 +35,12 @@ function trp_run_translatepress_hooks(){
35
$trp->run();
36
}
37
/* make sure we execute our plugin before other plugins so the changes we make apply across the board */
38
- add_action( 'plugins_loaded', 'trp_run_translatepress_hooks', 1 );
3
Plugin Name: TranslatePress - Multilingual
4
Plugin URI: https://translatepress.com/
5
Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
+ Version: 1.4.6
7
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
Author URI: https://cozmoslabs.com/
9
Text Domain: translatepress-multilingual
35
$trp->run();
36
}
37
/* make sure we execute our plugin before other plugins so the changes we make apply across the board */
38
+ add_action( 'plugins_loaded', 'trp_run_translatepress_hooks', 1 );
39
+
40
+
41
+ /** License classes includes here
42
+ * Since version 1.4.6
43
+ * It need to be outside of a hook so it load before the classes that are in the addons, that we are trying to phase out
44
+ */
45
+
46
+ require_once plugin_dir_path(__FILE__) . 'includes/class-edd-sl-plugin-updater.php';
languages/translatepress-multilingual.catalog.php CHANGED
@@ -24,8 +24,19 @@
24
<?php __("Choose...", "translatepress-multilingual"); ?>
25
<?php __("Add", "translatepress-multilingual"); ?>
26
<?php __("Select the languages you wish to make your website available in.", "translatepress-multilingual"); ?>
27
<?php __("You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon so TranslatePress can function properly.", "translatepress-multilingual"); ?>
28
<?php __("Dismiss this notice.", "translatepress-multilingual"); ?>
29
<?php __("Redirect users to their preferred language based on their browser language or IP address using our new <a href=\"https://translatepress.com/docs/addons/automatic-user-language-detection/\" >Automatic User Language Detection Add-on</a>.", "translatepress-multilingual"); ?>
30
<?php __("Full Language Names", "translatepress-multilingual"); ?>
31
<?php __("Short Language Names", "translatepress-multilingual"); ?>
@@ -35,8 +46,8 @@
35
<?php __("Current Language", "translatepress-multilingual"); ?>
36
<?php __("General", "translatepress-multilingual"); ?>
37
<?php __("Translate Site", "translatepress-multilingual"); ?>
38
- <?php __("License", "translatepress-multilingual"); ?>
39
<?php __("Addons", "translatepress-multilingual"); ?>
40
<?php __("Settings", "translatepress-multilingual"); ?>
41
<?php __("Pro Features", "translatepress-multilingual"); ?>
42
<?php __("Translate", "translatepress-multilingual"); ?>
@@ -78,6 +89,9 @@
78
<?php __("If the page does not redirect automatically", "translatepress-multilingual"); ?>
79
<?php __("click here", "translatepress-multilingual"); ?>
80
<?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
81
<?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
82
<?php __("To add <strong>more then two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>", "translatepress-multilingual"); ?>
83
<?php __("Not only you are getting extra features and premium support, you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
@@ -152,6 +166,3 @@
152
<?php __("Remove duplicate rows", "translatepress-multilingual"); ?>
153
<?php __("TranslatePress Database Updater", "translatepress-multilingual"); ?>
154
<?php __("Updating TranslatePress tables", "translatepress-multilingual"); ?>
155
- <?php __(" TranslatePress Settings", "translatepress-multilingual"); ?>
156
- <?php __("Translator", "translatepress-multilingual"); ?>
157
- <?php __("Allow this user to translate the website.", "translatepress-multilingual"); ?>
24
<?php __("Choose...", "translatepress-multilingual"); ?>
25
<?php __("Add", "translatepress-multilingual"); ?>
26
<?php __("Select the languages you wish to make your website available in.", "translatepress-multilingual"); ?>
27
+ <?php __("An error occurred, please try again.", "translatepress-multilingual"); ?>
28
+ <?php __("Your license key expired on %s.", "translatepress-multilingual"); ?>
29
+ <?php __("Your license key has been disabled.", "translatepress-multilingual"); ?>
30
+ <?php __("Invalid license.", "translatepress-multilingual"); ?>
31
+ <?php __("Your license is not active for this URL.", "translatepress-multilingual"); ?>
32
+ <?php __("This appears to be an invalid license key for %s.", "translatepress-multilingual"); ?>
33
+ <?php __("Your license key has reached its activation limit.", "translatepress-multilingual"); ?>
34
+ <?php __("You have successfully activated your license", "translatepress-multilingual"); ?>
35
<?php __("You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon so TranslatePress can function properly.", "translatepress-multilingual"); ?>
36
<?php __("Dismiss this notice.", "translatepress-multilingual"); ?>
37
+ <?php __("<p>Your <strong>TranslatePress</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>", "translatepress-multilingual"); ?>
38
+ <?php __("<p>Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s</p>", "translatepress-multilingual"); ?>
39
+ <?php __("Your <strong>TranslatePress</strong> license will expire on %1$s. Please %2$sRenew Your Licence%3$s to continue receiving access to product downloads, automatic updates and support.", "translatepress-multilingual"); ?>
40
<?php __("Redirect users to their preferred language based on their browser language or IP address using our new <a href=\"https://translatepress.com/docs/addons/automatic-user-language-detection/\" >Automatic User Language Detection Add-on</a>.", "translatepress-multilingual"); ?>
41
<?php __("Full Language Names", "translatepress-multilingual"); ?>
42
<?php __("Short Language Names", "translatepress-multilingual"); ?>
46
<?php __("Current Language", "translatepress-multilingual"); ?>
47
<?php __("General", "translatepress-multilingual"); ?>
48
<?php __("Translate Site", "translatepress-multilingual"); ?>
49
<?php __("Addons", "translatepress-multilingual"); ?>
50
+ <?php __("License", "translatepress-multilingual"); ?>
51
<?php __("Settings", "translatepress-multilingual"); ?>
52
<?php __("Pro Features", "translatepress-multilingual"); ?>
53
<?php __("Translate", "translatepress-multilingual"); ?>
89
<?php __("If the page does not redirect automatically", "translatepress-multilingual"); ?>
90
<?php __("click here", "translatepress-multilingual"); ?>
91
<?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
92
+ <?php __("Active on this site", "translatepress-multilingual"); ?>
93
+ <?php __("Your license is invalid", "translatepress-multilingual"); ?>
94
+ <?php __("If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key", "translatepress-multilingual"); ?>
95
<?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
96
<?php __("To add <strong>more then two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>", "translatepress-multilingual"); ?>
97
<?php __("Not only you are getting extra features and premium support, you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
166
<?php __("Remove duplicate rows", "translatepress-multilingual"); ?>
167
<?php __("TranslatePress Database Updater", "translatepress-multilingual"); ?>
168
<?php __("Updating TranslatePress tables", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -17,11 +17,11 @@ msgstr ""
17
msgid "Error! Duplicate Url slug values."
18
msgstr ""
19
20
- #: ../tp-add-on-navigation-based-on-language/class-navigation-based-on-language.php:86
21
msgid "Limit this menu item to the following languages"
22
msgstr ""
23
24
- #: ../tp-add-on-navigation-based-on-language/class-navigation-based-on-language.php:92, ../tp-add-on-extra-languages/partials/language-selector-pro.php:2, ../translatepress/partials/main-settings-language-selector.php:2
25
msgid "All Languages"
26
msgstr ""
27
@@ -49,23 +49,23 @@ msgstr ""
49
msgid "<div class=\"warning\">WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment.</div>"
50
msgstr ""
51
52
- #: partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:4, ../tp-add-on-seo-pack/partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-google-key-settings-page.php:10, ../translatepress/partials/trp-remove-duplicate-rows.php:3, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:4
53
msgid "TranslatePress Settings"
54
msgstr ""
55
56
- #: partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:10, ../tp-add-on-seo-pack/partials/license-settings-page.php:10, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:10
57
msgid "License Key"
58
msgstr ""
59
60
- #: partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:15, ../tp-add-on-seo-pack/partials/license-settings-page.php:15, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:15
61
msgid "Enter your license key."
62
msgstr ""
63
64
- #: partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:22, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:31, ../tp-add-on-seo-pack/partials/license-settings-page.php:22, ../tp-add-on-seo-pack/partials/license-settings-page.php:31, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:31
65
msgid "Activate License"
66
msgstr ""
67
68
- #: partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, ../tp-add-on-navigation-based-on-language/partials/license-settings-page.php:28, ../tp-add-on-seo-pack/partials/license-settings-page.php:28, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:28
69
msgid "Deactivate License"
70
msgstr ""
71
@@ -113,15 +113,59 @@ msgstr ""
113
msgid "Select the languages you wish to make your website available in."
114
msgstr ""
115
116
- #: ../translatepress/includes/class-plugin-notices.php:311
117
msgid "You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon so TranslatePress can function properly."
118
msgstr ""
119
120
- #: ../translatepress/includes/class-plugin-notices.php:313, ../translatepress/includes/class-plugin-notices.php:324
121
msgid "Dismiss this notice."
122
msgstr ""
123
124
- #: ../translatepress/includes/class-plugin-notices.php:322
125
msgid "Redirect users to their preferred language based on their browser language or IP address using our new <a href=\"https://translatepress.com/docs/addons/automatic-user-language-detection/\" >Automatic User Language Detection Add-on</a>."
126
msgstr ""
127
@@ -157,19 +201,19 @@ msgstr ""
157
msgid "Translate Site"
158
msgstr ""
159
160
- #: ../translatepress/includes/class-settings.php:397
161
- msgid "License"
162
msgstr ""
163
164
#: ../translatepress/includes/class-settings.php:403
165
- msgid "Addons"
166
msgstr ""
167
168
- #: ../translatepress/includes/class-settings.php:428, ../translatepress/includes/class-translation-manager.php:649
169
msgid "Settings"
170
msgstr ""
171
172
- #: ../translatepress/includes/class-settings.php:432
173
msgid "Pro Features"
174
msgstr ""
175
@@ -331,6 +375,18 @@ msgstr ""
331
msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
332
msgstr ""
333
334
#: ../translatepress/partials/main-settings-language-selector.php:59
335
msgid "Select the language you wish to make your website available in."
336
msgstr ""
@@ -626,15 +682,3 @@ msgstr ""
626
#: ../translatepress/partials/trp-update-database.php:7
627
msgid "Updating TranslatePress tables"
628
msgstr ""
629
-
630
- #: ../trp-add-on-translator-accounts-add-on/includes/class-translator-accounts.php:119
631
- msgid " TranslatePress Settings"
632
- msgstr ""
633
-
634
- #: ../trp-add-on-translator-accounts-add-on/includes/class-translator-accounts.php:123, ../trp-add-on-translator-accounts-add-on/includes/class-translator-accounts.php:124
635
- msgid "Translator"
636
- msgstr ""
637
-
638
- #: ../trp-add-on-translator-accounts-add-on/includes/class-translator-accounts.php:128
639
- msgid "Allow this user to translate the website."
640
- msgstr ""
17
msgid "Error! Duplicate Url slug values."
18
msgstr ""
19
20
+ #: ../tp-add-on-navigation-based-on-language/class-navigation-based-on-language.php:71
21
msgid "Limit this menu item to the following languages"
22
msgstr ""
23
24
+ #: ../tp-add-on-navigation-based-on-language/class-navigation-based-on-language.php:77, ../tp-add-on-extra-languages/partials/language-selector-pro.php:2, ../translatepress/partials/main-settings-language-selector.php:2
25
msgid "All Languages"
26
msgstr ""
27
49
msgid "<div class=\"warning\">WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment.</div>"
50
msgstr ""
51
52
+ #: partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, ../tp-add-on-seo-pack/partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/license-settings-page.php:8, ../translatepress/partials/license-settings-page.php:46, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-google-key-settings-page.php:10, ../translatepress/partials/trp-remove-duplicate-rows.php:3
53
msgid "TranslatePress Settings"
54
msgstr ""
55
56
+ #: partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, ../tp-add-on-seo-pack/partials/license-settings-page.php:10, ../translatepress/partials/license-settings-page.php:14
57
msgid "License Key"
58
msgstr ""
59
60
+ #: partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, ../tp-add-on-seo-pack/partials/license-settings-page.php:15, ../translatepress/partials/license-settings-page.php:38
61
msgid "Enter your license key."
62
msgstr ""
63
64
+ #: partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, ../tp-add-on-seo-pack/partials/license-settings-page.php:22, ../tp-add-on-seo-pack/partials/license-settings-page.php:31, ../translatepress/partials/license-settings-page.php:32
65
msgid "Activate License"
66
msgstr ""
67
68
+ #: partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, ../tp-add-on-seo-pack/partials/license-settings-page.php:28, ../translatepress/partials/license-settings-page.php:22
69
msgid "Deactivate License"
70
msgstr ""
71
113
msgid "Select the languages you wish to make your website available in."
114
msgstr ""
115
116
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:663, ../translatepress/includes/class-edd-sl-plugin-updater.php:695, ../translatepress/includes/class-edd-sl-plugin-updater.php:766
117
+ msgid "An error occurred, please try again."
118
+ msgstr ""
119
+
120
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:674
121
+ msgid "Your license key expired on %s."
122
+ msgstr ""
123
+
124
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:679
125
+ msgid "Your license key has been disabled."
126
+ msgstr ""
127
+
128
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:682
129
+ msgid "Invalid license."
130
+ msgstr ""
131
+
132
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:686
133
+ msgid "Your license is not active for this URL."
134
+ msgstr ""
135
+
136
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:689
137
+ msgid "This appears to be an invalid license key for %s."
138
+ msgstr ""
139
+
140
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:692
141
+ msgid "Your license key has reached its activation limit."
142
+ msgstr ""
143
+
144
+ #: ../translatepress/includes/class-edd-sl-plugin-updater.php:726
145
+ msgid "You have successfully activated your license"
146
+ msgstr ""
147
+
148
+ #: ../translatepress/includes/class-plugin-notices.php:325
149
msgid "You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon so TranslatePress can function properly."
150
msgstr ""
151
152
+ #: ../translatepress/includes/class-plugin-notices.php:327, ../translatepress/includes/class-plugin-notices.php:353, ../translatepress/includes/class-plugin-notices.php:372, ../translatepress/includes/class-plugin-notices.php:386
153
msgid "Dismiss this notice."
154
msgstr ""
155
156
+ #: ../translatepress/includes/class-plugin-notices.php:346
157
+ msgid "<p>Your <strong>TranslatePress</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>"
158
+ msgstr ""
159
+
160
+ #: ../translatepress/includes/class-plugin-notices.php:348
161
+ msgid "<p>Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s</p>"
162
+ msgstr ""
163
+
164
+ #: ../translatepress/includes/class-plugin-notices.php:368
165
+ msgid "Your <strong>TranslatePress</strong> license will expire on %1$s. Please %2$sRenew Your Licence%3$s to continue receiving access to product downloads, automatic updates and support."
166
+ msgstr ""
167
+
168
+ #: ../translatepress/includes/class-plugin-notices.php:384
169
msgid "Redirect users to their preferred language based on their browser language or IP address using our new <a href=\"https://translatepress.com/docs/addons/automatic-user-language-detection/\" >Automatic User Language Detection Add-on</a>."
170
msgstr ""
171
201
msgid "Translate Site"
202
msgstr ""
203
204
+ #: ../translatepress/includes/class-settings.php:396
205
+ msgid "Addons"
206
msgstr ""
207
208
#: ../translatepress/includes/class-settings.php:403
209
+ msgid "License"
210
msgstr ""
211
212
+ #: ../translatepress/includes/class-settings.php:429, ../translatepress/includes/class-translation-manager.php:649
213
msgid "Settings"
214
msgstr ""
215
216
+ #: ../translatepress/includes/class-settings.php:433
217
msgid "Pro Features"
218
msgstr ""
219
375
msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
376
msgstr ""
377
378
+ #: ../translatepress/partials/license-settings-page.php:25
379
+ msgid "Active on this site"
380
+ msgstr ""
381
+
382
+ #: ../translatepress/partials/license-settings-page.php:27
383
+ msgid "Your license is invalid"
384
+ msgstr ""
385
+
386
+ #: ../translatepress/partials/license-settings-page.php:48
387
+ msgid "If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key"
388
+ msgstr ""
389
+
390
#: ../translatepress/partials/main-settings-language-selector.php:59
391
msgid "Select the language you wish to make your website available in."
392
msgstr ""
682
#: ../translatepress/partials/trp-update-database.php:7
683
msgid "Updating TranslatePress tables"
684
msgstr ""
partials/license-settings-page.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ $trp = TRP_Translate_Press::get_trp_instance();
3
+ if( !empty( $trp->active_pro_addons ) ){//if we have any Advanced or Pro addons active then show the license key activation form
4
+ ?>
5
+ <div id="trp-license-settings" class="wrap">
6
+ <form method="post" action="<?php echo $action; ?>">
7
+ <?php settings_fields( 'trp_license_key' ); ?>
8
+ <h1> <?php _e( 'TranslatePress Settings', 'translatepress-multilingual' );?></h1>
9
+ <?php do_action ( 'trp_settings_navigation_tabs' ); ?>
10
+ <table class="form-table">
11
+ <tbody>
12
+ <tr valign="top">
13
+ <th scope="row" valign="top">
14
+ <?php _e('License Key', 'translatepress-multilingual'); ?>
15
+ </th>
16
+ <td>
17
+ <div>
18
+ <input id="trp_license_key" name="trp_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" />
19
+ <?php wp_nonce_field( 'trp_license_nonce', 'trp_license_nonce' ); ?>
20
+ <?php if( $status !== false && $status == 'valid' ) {
21
+ $button_name = 'trp_edd_license_deactivate';
22
+ $button_value = __('Deactivate License', 'translatepress-multilingual' );
23
+
24
+ if( empty( $details['invalid'] ) )
25
+ echo '<span title="'.__( 'Active on this site', 'translatepress-multilingual' ) .'" class="trp-active-license dashicons dashicons-yes"></span>';
26
+ else
27
+ echo '<span title="'.__( 'Your license is invalid', 'translatepress-multilingual' ) .'" class="trp-invalid-license dashicons dashicons-warning"></span>';
28
+
29
+ }
30
+ else {
31
+ $button_name = 'trp_edd_license_activate';
32
+ $button_value = __('Activate License', 'translatepress-multilingual');
33
+ }
34
+ ?>
35
+ <input type="submit" class="button-secondary" name="<?php echo $button_name; ?>" value="<?php echo $button_value; ?>"/>
36
+ </div>
37
+ <p class="description">
38
+ <?php _e( 'Enter your license key.', 'translatepress-multilingual' ); ?>
39
+ </p>
40
+ </td>
41
+ </tbody>
42
+ </table>
43
+ </form>
44
+ </div>
45
+ <?php } else{ ?>
46
+ <h1> <?php _e( 'TranslatePress Settings', 'translatepress-multilingual' );?></h1>
47
+ <?php do_action ( 'trp_settings_navigation_tabs' ); ?>
48
+ <h4><?php printf( __( 'If you do not have any of the <a href="%s">Advanced or Pro Addons</a> activated you do not need a license key', 'translatepress-multilingual' ), admin_url('/admin.php?page=trp_addons_page') ); ?></h4>
49
+ <?php } ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.com/
4
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
Requires at least: 3.1.0
6
Tested up to: 5.1.1
7
- Stable tag: 1.4.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -125,6 +125,12 @@ For more information please check out [TranslatePress - Multilingual plugin docu
125
6. Menu Language Switcher
126
127
== Changelog ==
128
= 1.4.5 =
129
* Performance improvements
130
* Fixed an issue that was causing empty strings to get inserted in the database
4
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
Requires at least: 3.1.0
6
Tested up to: 5.1.1
7
+ Stable tag: 1.4.6
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
125
6. Menu Language Switcher
126
127
== Changelog ==
128
+ = 1.4.6 =
129
+ * Fixed a js compatibility error with mootools.js
130
+ * Modified how the license page works and added plugin notifications
131
+ * Allow compatibility fix for Translation Editor on certain environments
132
+ * Fixed Safari bug with links when WooCommerce active
133
+
134
= 1.4.5 =
135
* Performance improvements
136
* Fixed an issue that was causing empty strings to get inserted in the database