Skip to content

Commit

Permalink
Merge pull request #280 from transifex/devel
Browse files Browse the repository at this point in the history
Release 1.3.42
  • Loading branch information
svaloumas authored Jun 21, 2024
2 parents 430d0b7 + 9679026 commit 7ba0035
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

env:
PLUGIN_VERSION: 1.3.41
PLUGIN_VERSION: 1.3.42
WP_PROJECT_TYPE: plugin
WP_VERSION: latest
WP_MULTISITE: 0
Expand Down
7 changes: 6 additions & 1 deletion includes/admin/transifex-live-integration-admin-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@
</td>
</tr>
<tr>
<td style="padding-right:0px">
<td style="padding-right:0px; padding-bottom: 1px;">
<input name="transifex_live_settings[translate_urls]" type="checkbox" id="transifex_live_settings_translate_urls" value="1" <?php echo $checked_translate_urls ?>><?php _e( 'Make images and links translatable' ); ?>&nbsp;<a target="_blank" href="<?php echo $settings['urls']['translate_urls']; ?>"><b><?php _e( 'Learn more' ) ?></b></a>.
</td>
</tr>
<tr>
<td style="padding-right:0px">
<input name="transifex_live_settings[canonical_urls]" type="checkbox" id="transifex_live_settings_canonical_urls" value="1" <?php echo $checked_canonical_urls ?>><?php _e( 'Disable rendering canonical URLs' ); ?>.
</td>
</tr>
<tr>
<td>
<label for="transifex_live_settings_url_options">
Expand Down
9 changes: 9 additions & 0 deletions includes/admin/transifex-live-integration-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ static function options_page() {
checked( $settings['translate_urls'], 1 );
$checked_translate_urls = ob_get_clean();

ob_start();
checked( $settings['canonical_urls'], 1 );
$checked_canonical_urls = ob_get_clean();

ob_start();
checked( $settings['rewrite_option_all'], 1 );
$checked_rewrite_option_all = ob_get_clean();
Expand Down Expand Up @@ -212,9 +216,13 @@ static public function update_settings( $settings ) {
$transifex_languages = json_decode( stripslashes( $settings['transifex_live_settings']['transifex_languages'] ), true );

$is_subdirectory_install = false;
$disable_canonical_urls = false;
if ( isset($settings['transifex_live_settings']['is_subdirectory_install'])) {
$is_subdirectory_install = $settings['transifex_live_settings']['is_subdirectory_install'];
}
if ( isset($settings['transifex_live_settings']['disable_canonical_urls'])) {
$disable_canonical_urls = $settings['transifex_live_settings']['disable_canonical_urls'];
}
$site_url = (new Transifex_Live_Integration_WP_Services($settings['transifex_live_settings']))->get_site_url();
$tokenized_url = Transifex_Live_Integration_Admin_Util::generate_tokenized_url( $site_url, $settings['transifex_live_settings']['url_options'] );
$settings['transifex_live_settings']['tokenized_url'] = $tokenized_url;
Expand Down Expand Up @@ -255,6 +263,7 @@ static public function update_settings( $settings ) {
$settings['transifex_live_settings']['rewrite_pattern'] = $rewrite_pattern;
$settings['transifex_live_settings']['languages_regex'] = $languages_regex;
$settings['transifex_live_settings']['languages'] = $languages;
$settings['transifex_live_settings']['disable_canonical_urls'] = $disable_canonical_urls;
if ( isset( $settings['transifex_live_settings'] ) ) {
update_option( 'transifex_live_settings', $settings['transifex_live_settings'] );
}
Expand Down
14 changes: 14 additions & 0 deletions includes/lib/transifex-live-integration-hreflang.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function render_hreflang() {
return false;
}
global $wp;
$disable_canonical_urls = $this->settings['canonical_urls'];
$lang = get_query_var( 'lang' );
$url_path = add_query_arg( array(), $wp->request );
$source_url_path = (substr( $url_path, 0, strlen( $lang ) ) === $lang) ? substr( $url_path, strlen( $lang ), strlen( $url_path ) ) : $url_path;
Expand Down Expand Up @@ -164,6 +165,19 @@ public function render_hreflang() {
$hreflang_out .= <<<XDEFAULT
<link rel="alternate" href="$source_url" hreflang="x-default"/>\n
XDEFAULT;
if (!$disable_canonical_urls) {
$canonical_url = home_url('/');
foreach ($hreflangs as $hreflang) {
if (!empty($url_path) && strpos($hreflang['href'], $url_path) !== false) {
$canonical_url = $hreflang['href'];
break;
} else {}
}

$hreflang_out .= <<<CANONICAL
<link rel="canonical" href="$canonical_url"/>\n
CANONICAL;
}
echo $hreflang_out;
return true;
}
Expand Down
1 change: 1 addition & 0 deletions includes/transifex-live-integration-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static function settings() {
// Wordpress is installed in a subdirectory like www.mydomain.com/cms but the site is accessible from www.mydomain.com
'is_subdirectory_install' => 0,
'translate_urls' => false,
'canonical_urls' => false,
'previous_api_key' => null,
'raw_transifex_languages' => null,
'transifex_languages' => null,
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Ex. $updated_content = apply_filters('tx_link', $original_content);
* It is also recommended to use [widgets](https://codex.wordpress.org/Widgets_API) in your theme instead of custom code, since this allows you to make your integration more future proof against incompatibilities with 3rd party modules.

== Changelog ==
= 1.3.42 =
Toggle canonical URLs

= 1.3.41 =
Remove source subdirectory hreflang

Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: txmatthew, ThemeBoy, brooksx
Tags: transifex, localize, localization, multilingual, international, SEO
Requires at least: 3.5.2
Tested up to: 6.5.3
Stable tag: 1.3.41
Stable tag: 1.3.42
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -78,6 +78,9 @@ Ex. $updated_content = apply_filters('tx_link', $original_content);
It is also recommended to use [widgets](https://codex.wordpress.org/Widgets_API) in your theme instead of custom code, since this allows you to make your integration more future proof against incompatibilities with 3rd party modules.

== Changelog ==
= 1.3.42 =
Toggle canonical URLs

= 1.3.41 =
Remove source subdirectory hreflang

Expand Down
6 changes: 3 additions & 3 deletions transifex-live-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*
* @link https://help.transifex.com/en/articles/6261241-wordpress
* @package TransifexLiveIntegration
* @version 1.3.41
* @version 1.3.42
*
* @wordpress-plugin
* Plugin Name: International SEO by Transifex
* Plugin URI: https://help.transifex.com/en/articles/6261241-wordpress
* Description: Translate your WordPress powered website using Transifex.
* Version: 1.3.41
* Version: 1.3.42
* License: GNU General Public License
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: transifex-live-integration
Expand Down Expand Up @@ -75,7 +75,7 @@
}

define( 'LANG_PARAM', 'lang' );
$version = '1.3.41';
$version = '1.3.42';

require_once( dirname( __FILE__ ) . '/transifex-live-integration-main.php' );
Transifex_Live_Integration::do_plugin( is_admin(), $version );

0 comments on commit 7ba0035

Please sign in to comment.