Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.3.40 #274

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.39
PLUGIN_VERSION: 1.3.40
WP_PROJECT_TYPE: plugin
WP_VERSION: latest
WP_MULTISITE: 0
Expand Down
23 changes: 19 additions & 4 deletions includes/lib/transifex-live-integration-hreflang.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private function generate_languages_hreflang( $raw_url, $languages,
$language_map, $hreflang_map
) {
Plugin_Debug::logTrace();
$source = $this->settings['source_language'];
$url_map = Transifex_Live_Integration_Common::generate_language_url_map( $raw_url, $this->tokenized_url, $language_map );
$ret = [ ];
foreach ($languages as $language) {
Expand All @@ -106,10 +107,11 @@ private function generate_languages_hreflang( $raw_url, $languages,
$protocol = Transifex_Live_Integration_Util::get_http_requested_protocol();
$href_link_parts[0] = $protocol;
$arr['href'] = implode(':', $href_link_parts);
} else {
$arr['href'] = $url_map[$language];
} else {
$arr['href'] = $url_map[$language];
}
$arr['hreflang'] = $hreflang_map[$language];
$arr['is_source'] = ($language === $source);
array_push( $ret, $arr );
}
return $ret;
Expand All @@ -134,10 +136,23 @@ public function render_hreflang() {
$unslashed_source_url = $site_url . $source_url_path;
$source_url = rtrim( $unslashed_source_url, '/' ) . '/';
$hreflang_out = '';
$hreflangs = $this->generate_languages_hreflang( $source_url_path, $this->languages, $this->language_map, $this->hreflang_map );
$source_hreflang = '';

foreach ($hreflangs as $hreflang) {
if ($hreflang['is_source']) {
$source_hreflang = $hreflang['hreflang'];
break;
}
}
// If source_hreflang is not found,
// use the source language as default
if (empty($source_hreflang)) {
$source_hreflang = $source;
}
$hreflang_out .= <<<SOURCE
<link rel="alternate" href="$source_url" hreflang="$source"/>\n
<link rel="alternate" href="$source_url" hreflang="$source_hreflang"/>\n
SOURCE;
$hreflangs = $this->generate_languages_hreflang( $source_url_path, $this->languages, $this->language_map, $this->hreflang_map );
foreach ($hreflangs as $hreflang) {
$href_attr = $hreflang['href'];
$hreflang_attr = $hreflang['hreflang'];
Expand Down
68 changes: 32 additions & 36 deletions javascript/transifex-live-integration-settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,56 +71,53 @@ function build_cdn_manifest_url(apikey) {
return "https://cdn.transifex.com/" + apikey + "/latest/manifest.jsonp";
}




function transifex_live_integration_convert(l) {
var r = {"type": "div",
function transifex_live_integration_convert(data) {
var result = {"type": "div",
"id": "transifex-languages"};
var t = l['translation'];
var k = l['source'];
var h = [];
var translation = data['translation'];
var source = data['source'];
var html = [];
transifex_languages = [];
language_lookup = [];
language_map = [];
hreflang_map = [];
var arr = {};
var arrr = {};
var arrrr = {};

h.push(transifex_live_integration_mapper(k));
transifex_languages.push(k['code']);
arr['tx_name'] = k['tx_name'];
arr['code'] = k['code'];
language_lookup.push(arr);
arrr[k['code']] = k['code'];
arrrr[k['code']] = k['code'].toLowerCase().replace('_', '-');
var language_data = {};
var language = {};
var hreflang = {};

html.push(transifex_live_integration_mapper(source));
transifex_languages.push(source['code']);
language_data['tx_name'] = source['tx_name'];
language_data['code'] = source['code'];
language_lookup.push(language_data);
language[source['code']] = source['code'];
hreflang[source['code']] = source['code'].toLowerCase().replace('_', '-');

jQuery.each(
t, function (i, o) {
h.push(transifex_live_integration_mapper(o));
translation, function (i, o) {
html.push(transifex_live_integration_mapper(o));
transifex_languages.push(o['code']);
var arr = {};
arr['tx_name'] = o['tx_name'];
arr['code'] = o['code'];
language_lookup.push(arr);
arrr[o['code']] = o['code'];
arrrr[o['code']] = o['code'].toLowerCase().replace('_', '-');
var language_data = {};
language_data['tx_name'] = o['tx_name'];
language_data['code'] = o['code'];
language_lookup.push(language_data);
language[o['code']] = o['code'];
hreflang[o['code']] = o['code'].toLowerCase().replace('_', '-');
}
);
language_map.push(arrr);
hreflang_map.push(arrrr);
language_map.push(language);
hreflang_map.push(hreflang);
var s = {
caption: 'Source:' + l['source']['tx_name'],
caption: 'Source:' + source['tx_name'],
name: "transifex-integration-live-source-language",
id: "transifex-integration-live-[source-language]",
type: "text",
value: l['source']['code']
value: source['code']
};
source_language = l['source']['code'];
r['source'] = s;
r['html'] = h;
return r;
source_language = source['code'];
result['source'] = s;
result['html'] = html;
return result;
}


Expand Down Expand Up @@ -206,7 +203,6 @@ function addTransifexLanguages(obj) {
}
);


} else {
var tlslm = JSON.parse(jQuery('#transifex_live_settings_language_map').val());
var tlshm = JSON.parse(jQuery('#transifex_live_settings_hreflang_map').val());
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.40 =
Fix hrefland in source alternate tag

= 1.3.39 =
Add subdirectory rewrite rules for archive pages of custom post types

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.39
Stable tag: 1.3.40
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.40 =
Fix hrefland in source alternate tag

= 1.3.39 =
Add subdirectory rewrite rules for archive pages of custom post types

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.39
* @version 1.3.40
*
* @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.39
* Version: 1.3.40
* 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.39';
$version = '1.3.40';

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