Changeset 3335141
- Timestamp:
- 07/28/2025 06:32:59 AM (8 months ago)
- Location:
- language-switcher/trunk
- Files:
-
- 5 edited
-
includes/class-language-switcher-settings.php (modified) (1 diff)
-
includes/class-language-switcher.php (modified) (15 diffs)
-
includes/lib/class-language-switcher-admin-api.php (modified) (3 diffs)
-
language-switcher.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
language-switcher/trunk/includes/class-language-switcher-settings.php
r3165172 r3335141 377 377 'author_link' => 'https://code.recuweb.com/about-us/?utm_source='.$domain.'&utm_medium=referral&utm_campaign='.$campaign, 378 378 ), 379 ' rew-bulk-editor' => array(379 'bulk-task-editor' => array( 380 380 381 381 'title' => 'Bulk Task Editor', 382 382 'addon_link' => 'https://code.recuweb.com/get/bulk-task-editor/?utm_source='.$domain.'&utm_medium=referral&utm_campaign='.$campaign, 383 'addon_name' => ' rew-bulk-editor',383 'addon_name' => 'bulk-task-editor', 384 384 'logo_url' => 'https://d3ddkiw8cptmcg.cloudfront.net/c/u/3a09f4cf991c32bd735fa06db67889e5/2024/07/21103352/content-bulk-editor-2-300x300.png', 385 385 'description' => 'Accelerate your content management workflow for post types, taxonomies, users, and imported data, all without overloading your server.', -
language-switcher/trunk/includes/class-language-switcher.php
r3211770 r3335141 180 180 181 181 add_action('admin_init', array($this, 'init_backend')); 182 182 183 183 add_action('init', array($this, 'init_language')); 184 184 … … 320 320 public function normalize_url($url,$current_url) { 321 321 322 $proto = ( is_ssl() ? 'https://' : 'http://' ); 323 324 if( $url[0] == '/' ){ 325 326 $url = home_url( $url ); 327 } 328 else{ 329 330 $u = parse_url($url); 331 332 if( empty($u['host']) ){ 333 334 $url = $current_url . '/' . $url; 335 } 336 elseif( empty($u['scheme']) ){ 337 338 $url = $proto . $url; 339 } 340 } 341 322 if( is_string($url) && !empty($url) ){ 323 324 $proto = ( is_ssl() ? 'https://' : 'http://' ); 325 326 if( $url[0] == '/' ){ 327 328 $url = home_url( $url ); 329 } 330 else{ 331 332 $u = parse_url($url); 333 334 if( empty($u['host']) ){ 335 336 $url = $current_url . '/' . $url; 337 } 338 elseif( empty($u['scheme']) ){ 339 340 $url = $proto . $url; 341 } 342 } 343 } 344 342 345 return $url; 343 346 } … … 406 409 } 407 410 } 408 409 if( empty($language['urls'][$language['main']]) ){410 411 412 if( !empty($language['main']) ){ 413 411 414 $language['urls'][$language['main']] = apply_filters('lsw_sanitize_link',get_permalink($post_id)); 412 415 } … … 491 494 public function get_default_language($skip_cookie=false){ 492 495 493 if( ! $skip_cookie && !empty($_COOKIE[$this->_prefix . 'd']) ){496 if( !is_admin() && !$skip_cookie && !empty($_COOKIE[$this->_prefix . 'd']) ){ 494 497 495 498 $default_lang = sanitize_text_field($_COOKIE[$this->_prefix . 'd']); … … 529 532 530 533 if( is_singular() && !is_front_page() ){ 531 534 532 535 if( !$language = $this->get_post_language( get_queried_object_id() )){ 533 536 … … 973 976 974 977 //add language in post types 975 978 979 add_action( 'add_meta_boxes', function(){ 980 981 foreach( $this->get_active_post_types() as $post_type ){ 982 983 $this->admin->add_meta_box ( 984 985 'language_switcher', 986 __( 'Languages', 'language-switcher' ), 987 array($post_type), 988 'side', 989 'default' 990 ); 991 } 992 }); 993 976 994 if( $post_types = $this->get_active_post_types() ){ 977 995 978 996 foreach( $post_types as $post_type ){ 979 997 980 add_action( 'add_meta_boxes', function(){ 981 982 foreach( $this->get_active_post_types() as $post_type ){ 983 984 $this->admin->add_meta_box ( 985 986 'language_switcher', 987 __( 'Languages', 'language-switcher' ), 988 array($post_type), 989 'side', 990 'default' 991 ); 992 } 993 }); 994 995 add_filter( $post_type . '_custom_fields', array( $this, get_post_type_object( $post_type )->public ? 'add_post_type_language_switcher_with_url' : 'add_post_type_language_switcher_without_url' )); 996 997 add_action( 'save_post_' . $post_type, array( $this, 'save_language_post_type' ), 10, 3 ); 998 999 add_filter( 'manage_'.$post_type.'_posts_columns', array( $this, 'set_language_post_type_columns' ) ); 1000 1001 add_action( 'manage_'.$post_type.'_posts_custom_column' , array( $this, 'get_language_post_type_column' ), 10, 2 ); 1002 } 1003 1004 add_filter( 'pre_get_posts', array( $this, 'query_admin_language_post_type') ); 1005 } 998 add_filter($post_type . '_custom_fields', array( $this, get_post_type_object( $post_type )->public ? 'add_post_type_language_switcher_with_url' : 'add_post_type_language_switcher_without_url' )); 999 1000 add_filter('manage_'.$post_type.'_posts_columns', array( $this, 'set_language_post_type_columns' ) ); 1001 1002 add_action('manage_'.$post_type.'_posts_custom_column' , array( $this, 'get_language_post_type_column' ), 10, 2 ); 1003 } 1004 } 1005 1006 add_action('save_post', array( $this, 'save_language_post_type' ), 10, 3 ); 1007 1008 add_filter('pre_get_posts', array( $this, 'query_admin_language_post_type') ); 1006 1009 } 1007 1010 elseif( in_array( basename($_SERVER['SCRIPT_FILENAME']), array('term.php','edit-tags.php') ) ){ … … 1460 1463 $language_switcher = $this->sanitize_language_switcher($_REQUEST['language_switcher']); 1461 1464 1462 update_term_meta($term_id,'language_switcher',$language_switcher);1463 1464 1465 if( !empty($language_switcher['main']) ){ 1465 1466 1466 update_term_meta($term_id,$this->_base . 'main_language',$language_switcher['main']); 1467 } 1467 $main_lang = $language_switcher['main']; 1468 1469 $language_switcher['urls'][$main_lang] = apply_filters('lsw_sanitize_link',get_term_link($term_id)); 1470 1471 update_term_meta($term_id,$this->_base . 'main_language',$main_lang); 1472 } 1473 1474 update_term_meta($term_id,'language_switcher',$language_switcher); 1468 1475 } 1469 1476 … … 1476 1483 1477 1484 $language_switcher = $this->sanitize_language_switcher($_REQUEST['language_switcher']); 1478 1485 1486 if( !empty($language_switcher['main']) ){ 1487 1488 $main_lang = $language_switcher['main']; 1489 1490 $language_switcher['urls'][$main_lang] = apply_filters('lsw_sanitize_link',get_permalink($post_id)); 1491 1492 update_post_meta($post_id,$this->_base . 'main_language',$main_lang); 1493 1494 } 1495 1479 1496 update_post_meta($post_id,$this->_base . 'language_switcher',$language_switcher); 1480 1481 if( !empty($language_switcher['main']) ){1482 1483 update_post_meta($post_id,$this->_base . 'main_language',$language_switcher['main']);1484 }1485 1486 1497 } 1487 1498 … … 1517 1528 } 1518 1529 1519 public function get_language_urls($languages ){1530 public function get_language_urls($languages,$is_shortcode=false){ 1520 1531 1521 1532 $urls = array(); … … 1527 1538 $language = $this->get_current_language(); 1528 1539 1529 foreach( $active_languages as $iso){1540 foreach( $active_languages as $iso ){ 1530 1541 1531 1542 if( !empty($languages[$iso]) ){ … … 1539 1550 elseif( $language['main'] != $iso ){ 1540 1551 1541 if( !empty($default_urls[$iso]) ){ 1542 1543 $urls[$iso]['url'] = $default_urls[$iso]; 1544 } 1545 else{ 1552 if( !$is_shortcode ){ 1546 1553 1547 $urls[$iso]['url'] = add_query_arg( array('lang' => $iso), $this->get_current_url() ); 1548 } 1554 if( !empty($default_urls[$iso]) ){ 1555 1556 $urls[$iso]['url'] = $default_urls[$iso]; 1557 } 1558 else{ 1559 1560 $urls[$iso]['url'] = add_query_arg( array('lang' => $iso), $this->get_current_url() ); 1561 } 1562 } 1563 else{ 1564 1565 $urls[$iso]['url'] = false; 1566 } 1549 1567 } 1550 1568 else{ … … 1565 1583 $icon = ( !empty($atts['icon']) ? $atts['icon'] : '' ); 1566 1584 1567 return $this->get_language_switcher( $display, $show, $icon );1568 } 1569 1570 public function get_language_switcher( $display = 'button', $show = 'title_option', $icon = '' ){1585 return $this->get_language_switcher( $display, $show, $icon, true ); 1586 } 1587 1588 public function get_language_switcher( $display = 'button', $show = 'title_option', $icon = '', $is_shortcode = false ){ 1571 1589 1572 1590 // get languages … … 1576 1594 // get language urls 1577 1595 1578 $urls = $this->get_language_urls($languages );1596 $urls = $this->get_language_urls($languages, $is_shortcode); 1579 1597 1580 1598 // current language … … 1621 1639 foreach( $urls as $iso => $data ){ 1622 1640 1623 $switcher .= '<li'.( $language['main'] == $iso ? ' class="lsw-active"' : '' ).'>'; 1624 1625 $switcher .= '<a onclick="setLang(\''.$iso.'\');" href="'.esc_url($data['url']).'">'.$data['language'].'</a>'; 1626 1627 $switcher .= '</li>'; 1641 if( !empty($data['url']) ){ 1642 1643 $switcher .= '<li'.( $language['main'] == $iso ? ' class="lsw-active"' : '' ).'>'; 1644 1645 $switcher .= '<a onclick="setLang(\''.$iso.'\');" href="'.esc_url($data['url']).'">'.$data['language'].'</a>'; 1646 1647 $switcher .= '</li>'; 1648 } 1628 1649 } 1629 1650 … … 1661 1682 1662 1683 foreach( $urls as $iso => $data ){ 1663 1664 $html .= '<li'.( $language['main'] == $iso ? ' class="lsw-active"' : '' ).'>'; 1665 1666 $html .= '<a onclick="setLang(\''.$iso.'\');" href="' . esc_url($data['url']) . '">' . $data['language'] . '</a>'; 1667 1668 $html .= '</li>'; 1684 1685 if( !empty($data['url']) ){ 1686 1687 $html .= '<li'.( $language['main'] == $iso ? ' class="lsw-active"' : '' ).'>'; 1688 1689 $html .= '<a onclick="setLang(\''.$iso.'\');" href="' . esc_url($data['url']) . '">' . $data['language'] . '</a>'; 1690 1691 $html .= '</li>'; 1692 } 1669 1693 } 1670 1694 -
language-switcher/trunk/includes/lib/class-language-switcher-admin-api.php
r3149222 r3335141 191 191 192 192 $default = $this->parent->get_code_by_locale( get_site_option('WPLANG') ); 193 193 194 194 foreach ( $field['options'] as $k => $v ) { 195 195 196 196 $checked = false; 197 197 198 if ( in_array( $k, (array) $data ) ) {198 if ( in_array( $k, (array) $data ) || $k == $default ) { 199 199 200 200 $checked = true; … … 293 293 294 294 $html .= '<div style="margin-bottom:2px;width:90%;display: inline-block;">' . $language['full'] . '</div>'; 295 295 296 296 $html .= '<input style="width:90%;margin-left:25px;" id="' . esc_attr( $field['id'] ) . '_url_' . $iso . '" type="text" name="' . esc_attr( $option_name ) . '[urls]['.$iso.']" placeholder="http://" value="' . $value . '"'.( $data['main'] == $iso ? ' disabled="disabled"' : '' ).'/>' . "\n"; 297 297 … … 592 592 */ 593 593 public function save_meta_boxes ( $post_id = 0 ) { 594 594 595 595 if( !$post_id || isset($_POST['_inline_edit']) || isset($_GET['bulk_edit']) ) return; 596 596 -
language-switcher/trunk/language-switcher.php
r3211770 r3335141 4 4 * Plugin URI: https://code.recuweb.com/download/language-switcher/ 5 5 * Description: Add a Language Switcher to Post Types and Taxonomies 6 * Version: 3.8. 16 * Version: 3.8.6 7 7 * Author: Rafasashi 8 8 * Author URI: https://code.recuweb.com/about-us/ 9 9 * Requires at least: 4.6 10 * Tested up to: 6. 610 * Tested up to: 6.8 11 11 * Tags: language switcher, languages, internationalisation, internationalization, language 12 12 * -
language-switcher/trunk/readme.txt
r3211770 r3335141 4 4 Donate link: https://code.recuweb.com/get/language-switcher-everywhere/ 5 5 Requires at least: 4.6 6 Tested up to: 6. 67 Stable tag: 3.8. 16 Tested up to: 6.8 7 Stable tag: 3.8.6 8 8 License: GPLv3 9 9 License URI: https://code.recuweb.com/product-licenses/
Note: See TracChangeset
for help on using the changeset viewer.