Skip to content

Commit

Permalink
Rename QTX_LANG_CODE_FORMAT
Browse files Browse the repository at this point in the history
  • Loading branch information
herrvigg committed Sep 5, 2020
1 parent db99ff3 commit 38a6892
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion admin/qtx_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function qtranxf_add_admin_footer_js() {
$config['hide_lsb_copy_content'] = true;
}

$config['lang_code_format'] = QTX_LANG_CODE;
$config['lang_code_format'] = QTX_LANG_CODE_FORMAT;

// Last chance to customize Java script variable qTranslateConfig
$config = apply_filters( 'qtranslate_admin_page_config', $config );
Expand Down
4 changes: 2 additions & 2 deletions admin/qtx_admin_options_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function qtranxf_editConfig() {
if ( $_POST['language_name'] == '' ) {
$errors[] = __( 'The Language must have a name!', 'qtranslate' );
}
if ( ! preg_match( '/^' . QTX_LANG_CODE . '$/', $lang ) ) {
if ( ! preg_match( '/^' . QTX_LANG_CODE_FORMAT . '$/', $lang ) ) {
$errors[] = __( 'Invalid language code!', 'qtranslate' );
}
$langs = array();
Expand Down Expand Up @@ -195,7 +195,7 @@ function qtranxf_editConfig() {
}
} elseif ( isset( $_GET['edit'] ) ) {
$lang = sanitize_text_field( $_GET['edit'] );
if ( ! preg_match( '/^' . QTX_LANG_CODE . '$/', $lang ) ) {
if ( ! preg_match( '/^' . QTX_LANG_CODE_FORMAT . '$/', $lang ) ) {
$errors[] = __( 'Invalid language code!', 'qtranslate' );
}
$original_lang = $lang;
Expand Down
4 changes: 2 additions & 2 deletions admin/qtx_admin_utils_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function qtranxf_convert_to_b( $text ) {
$text = '';
$lang = false;
$lang_closed = true;
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;

foreach ( $blocks as $block ) {
if ( preg_match( "#^<!--:($lang_code)-->$#ism", $block, $matches ) ) {
Expand Down Expand Up @@ -430,7 +430,7 @@ function qtranxf_extract_languages( $text, $lang2keep ) {
$s = '';
$current_language = false;
$eol = false;
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;

foreach ( $blocks as $block ) {
// detect c-tags
Expand Down
2 changes: 1 addition & 1 deletion modules/wp-seo/qwpseo-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/*
function qwpseo_set_encoding_s($value){
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
if(is_string($value)){
$value = preg_replace('/<!--:($lang_code)-->/ism', '{:$1}', $value);
Expand Down
2 changes: 1 addition & 1 deletion modules/wp-seo/qwpseo-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function qwpseo_xmlsitemaps_config() {
* @since 1.1
*/
function qwpseo_encode_swirly( $value ) {
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
$value = preg_replace( '#\[:($lang_code|)]#i', '{:$1}', $value );

return $value;
Expand Down
10 changes: 5 additions & 5 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function qtranxf_parse_language_info( &$url_info, $link = false ) {
return false; // url is not from this WP installation
}

$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
$doredirect = false;

// parse URL lang
Expand Down Expand Up @@ -911,7 +911,7 @@ function qtranxf_url_del_language( &$urlinfo ) {
switch ( $url_mode ) {
case QTX_URL_PATH:
// might already have language information
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
if ( ! empty( $urlinfo['wp-path'] ) && preg_match( "!^/($lang_code)(/|$)!i", $urlinfo['wp-path'], $match ) ) {
if ( qtranxf_isEnabled( $match[1] ) ) {
// found language information, remove it
Expand Down Expand Up @@ -1156,7 +1156,7 @@ function qtranxf_convertURLs( $url, $lang = '', $forceadmin = false, $showDefaul
* @since 3.3.6 swirly bracket encoding added
*/
function qtranxf_get_language_blocks( $text ) {
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
$split_regex = "#(<!--:$lang_code-->|<!--:-->|\[:$lang_code\]|\[:\]|\{:$lang_code\}|\{:\})#ism";

return preg_split( $split_regex, $text, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
Expand All @@ -1180,7 +1180,7 @@ function qtranxf_split_blocks( $blocks, &$found = array() ) {
}

$current_language = false;
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;

foreach ( $blocks as $block ) {
// detect c-tags
Expand Down Expand Up @@ -1233,7 +1233,7 @@ function qtranxf_split_blocks( $blocks, &$found = array() ) {
function qtranxf_split_languages( $blocks ) {
$result = array();
$current_language = false;
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;

foreach ( $blocks as $block ) {
// detect c-tags
Expand Down
2 changes: 1 addition & 1 deletion qtranslate_frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function qtranxf_convertBlogInfoURL( $url, $what ) {
* Moved here from qtranslate_hooks.php and modified.
*/
function qtranxf_pagenum_link( $url ) {
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;
$url_fixed = preg_replace( "#\?lang=$lang_code/#i", '/', $url ); //kind of ugly fix for function get_pagenum_link in /wp-includes/link-template.php. Maybe we should cancel filter 'bloginfo_url' instead?
return qtranxf_convertURL( $url_fixed );
Expand Down
2 changes: 1 addition & 1 deletion qtranslate_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
// #1 language ISO 639-1 and 639-2: 2 or 3 alpha
// #2 script ISO 15924: 4 Alpha
// #3 region ISO 3166-2: 2 ALPHA or 3 digits
define( 'QTX_LANG_CODE', '[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2}|-\d{3})?');
define( 'QTX_LANG_CODE_FORMAT', '[a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2}|-\d{3})?');


global $q_config;
Expand Down
2 changes: 1 addition & 1 deletion qtranslate_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function qtranxf_external_host( $host ) {
}

function qtranxf_isMultilingual( $str ) {
$lang_code = QTX_LANG_CODE;
$lang_code = QTX_LANG_CODE_FORMAT;

return preg_match( "/<!--:$lang_code-->|\[:$lang_code]|{:$lang_code}/im", $str );
}
Expand Down

0 comments on commit 38a6892

Please sign in to comment.