Plugin Directory

Changeset 3335141


Ignore:
Timestamp:
07/28/2025 06:32:59 AM (8 months ago)
Author:
rafasashi
Message:

3.8.6

Location:
language-switcher/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • language-switcher/trunk/includes/class-language-switcher-settings.php

    r3165172 r3335141  
    377377                'author_link'   => 'https://code.recuweb.com/about-us/?utm_source='.$domain.'&utm_medium=referral&utm_campaign='.$campaign,
    378378            ),
    379             'rew-bulk-editor'   => array(
     379            'bulk-task-editor'  => array(
    380380           
    381381                'title'         => 'Bulk Task Editor',
    382382                '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',
    384384                'logo_url'      => 'https://d3ddkiw8cptmcg.cloudfront.net/c/u/3a09f4cf991c32bd735fa06db67889e5/2024/07/21103352/content-bulk-editor-2-300x300.png',
    385385                '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  
    180180       
    181181        add_action('admin_init', array($this, 'init_backend'));
    182            
     182           
    183183        add_action('init', array($this, 'init_language'));
    184184       
     
    320320    public function normalize_url($url,$current_url) {
    321321       
    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       
    342345        return $url;
    343346    }
     
    406409            }           
    407410        }
    408        
    409         if( empty($language['urls'][$language['main']]) ){
    410        
     411
     412        if( !empty($language['main']) ){
     413           
    411414            $language['urls'][$language['main']] = apply_filters('lsw_sanitize_link',get_permalink($post_id));
    412415        }
     
    491494    public function get_default_language($skip_cookie=false){
    492495       
    493         if( !$skip_cookie && !empty($_COOKIE[$this->_prefix . 'd']) ){
     496        if( !is_admin() && !$skip_cookie && !empty($_COOKIE[$this->_prefix . 'd']) ){
    494497           
    495498            $default_lang = sanitize_text_field($_COOKIE[$this->_prefix . 'd']);
     
    529532           
    530533            if( is_singular() && !is_front_page() ){
    531                  
     534               
    532535                if( !$language = $this->get_post_language( get_queried_object_id() )){
    533536                   
     
    973976
    974977            //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           
    976994            if( $post_types = $this->get_active_post_types() ){
    977995               
    978996                foreach( $post_types as $post_type ){
    979997                   
    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') );
    10061009        }       
    10071010        elseif( in_array( basename($_SERVER['SCRIPT_FILENAME']), array('term.php','edit-tags.php') ) ){
     
    14601463            $language_switcher = $this->sanitize_language_switcher($_REQUEST['language_switcher']);
    14611464           
    1462             update_term_meta($term_id,'language_switcher',$language_switcher);
    1463 
    14641465            if( !empty($language_switcher['main']) ){
    14651466           
    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);
    14681475        }
    14691476       
     
    14761483           
    14771484            $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           
    14791496            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            
    14861497        }
    14871498       
     
    15171528    }
    15181529   
    1519     public function get_language_urls($languages){
     1530    public function get_language_urls($languages,$is_shortcode=false){
    15201531       
    15211532        $urls = array();
     
    15271538            $language = $this->get_current_language();
    15281539           
    1529             foreach($active_languages as $iso){
     1540            foreach( $active_languages as $iso ){
    15301541               
    15311542                if( !empty($languages[$iso]) ){
     
    15391550                    elseif( $language['main'] != $iso ){
    15401551                       
    1541                         if( !empty($default_urls[$iso]) ){
    1542                        
    1543                             $urls[$iso]['url'] = $default_urls[$iso];
    1544                         }
    1545                         else{
     1552                        if( !$is_shortcode ){
    15461553                           
    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                        }
    15491567                    }
    15501568                    else{
     
    15651583        $icon       = ( !empty($atts['icon']) ? $atts['icon'] : '' );
    15661584       
    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 ){
    15711589       
    15721590        // get languages
     
    15761594        // get language urls
    15771595       
    1578         $urls = $this->get_language_urls($languages);
     1596        $urls = $this->get_language_urls($languages, $is_shortcode);
    15791597       
    15801598        // current language
     
    16211639                    foreach( $urls as $iso => $data ){
    16221640                       
    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                        }
    16281649                    }
    16291650                   
     
    16611682               
    16621683                    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                        }
    16691693                    }
    16701694                   
  • language-switcher/trunk/includes/lib/class-language-switcher-admin-api.php

    r3149222 r3335141  
    191191               
    192192                $default = $this->parent->get_code_by_locale( get_site_option('WPLANG') );
    193                
     193
    194194                foreach ( $field['options'] as $k => $v ) {
    195195
    196196                    $checked = false;
    197197
    198                     if ( in_array( $k, (array) $data ) ) {
     198                    if ( in_array( $k, (array) $data ) || $k == $default ) {
    199199                       
    200200                        $checked = true;
     
    293293                                   
    294294                                    $html .= '<div style="margin-bottom:2px;width:90%;display: inline-block;">' . $language['full'] . '</div>';
    295 
     295                                   
    296296                                    $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";
    297297
     
    592592     */
    593593    public function save_meta_boxes ( $post_id = 0 ) {
    594 
     594       
    595595        if( !$post_id || isset($_POST['_inline_edit']) || isset($_GET['bulk_edit']) ) return;
    596596
  • language-switcher/trunk/language-switcher.php

    r3211770 r3335141  
    44 * Plugin URI: https://code.recuweb.com/download/language-switcher/
    55 * Description: Add a Language Switcher to Post Types and Taxonomies
    6  * Version: 3.8.1
     6 * Version: 3.8.6
    77 * Author: Rafasashi
    88 * Author URI: https://code.recuweb.com/about-us/
    99 * Requires at least: 4.6
    10  * Tested up to: 6.6
     10 * Tested up to: 6.8
    1111 * Tags: language switcher, languages, internationalisation, internationalization, language
    1212 *
  • language-switcher/trunk/readme.txt

    r3211770 r3335141  
    44Donate link: https://code.recuweb.com/get/language-switcher-everywhere/
    55Requires at least: 4.6
    6 Tested up to: 6.6
    7 Stable tag: 3.8.1
     6Tested up to: 6.8
     7Stable tag: 3.8.6
    88License: GPLv3
    99License URI: https://code.recuweb.com/product-licenses/
Note: See TracChangeset for help on using the changeset viewer.