Plugin Directory

Changeset 3412263


Ignore:
Timestamp:
12/05/2025 02:22:41 PM (4 months ago)
Author:
autoglot
Message:

Small improvements

Location:
autoglot
Files:
62 added
8 edited

Legend:

Unmodified
Added
Removed
  • autoglot/trunk/admin/autoglot_admin.php

    r3409735 r3412263  
    11731173                    'supplemental' => __('Show language names in native languages, English, as ISO code, or combination.', 'autoglot'),
    11741174                    'type' => 'select',
    1175                     'options' => $this->language_name_options,
     1175                    'options' => $this->autoglot->options->get_language_name_options(),
    11761176                    'default' => array(autoglot_consts::LANGUAGE_NAME_TYPES[0]),
    11771177                    'sanitize_callback' => array($this, 'sanitize_language_names'),
  • autoglot/trunk/autoglot.php

    r3409735 r3412263  
    44Plugin URI: https://autoglot.com/download/
    55Description: Fully automatic SEO-friendly plugin for multilingual WordPress translation. Translate your website and boost your traffic in minutes! No coding, no subscription, no recurring payments, no hurdles!
    6 Version: 2.9.0
     6Version: 2.9.1
    77Text Domain: autoglot
    88Author: Autoglot WordPress Team
     
    8888        /** we need permalinks for Autoglot to function */
    8989        public $using_permalinks = false;
    90        
     90
    9191        /** shown moderation message? */
    9292        public $shown_moderation = false;
     
    178178                }
    179179                if($this->options->floatbox_enable){
    180                     add_action('wp_footer', array($this, 'add_autoglot_floatbox')); // add float box with language switcher popup
     180                    add_action('wp_footer', array($this, 'add_autoglot_floatbox')); // add float box for language switcher
     181                    add_action('wp_footer', array($this, 'add_autoglot_language_switcher_popup')); // add language switcher popup
     182                }elseif($this->autoglot_database->check_meta_key_exists("_autoglot_menu_item")){
     183                    add_action('wp_footer', array($this, 'add_autoglot_language_switcher_popup')); // add language switcher popup for menu
    181184                }
    182185                add_action('wp_print_styles', array(&$this, 'add_autoglot_css'));
     
    380383            }
    381384        }
    382        
    383         /**
    384          * Adds floating box with language switcher popup
     385
     386        /**
     387         * Adds floating box
    385388         */
    386389        function add_autoglot_floatbox() {
    387             if (is_404() || is_search() || !$this->options->floatbox_enable || (defined('REST_REQUEST') && REST_REQUEST)) {
     390            if (/*is_404() || is_search() || */!$this->options->floatbox_enable || (defined('REST_REQUEST') && REST_REQUEST)) {
    388391                return;
    389392            }
     
    435438                }
    436439                echo '</a></div>';
    437                
     440            }
     441        }
     442
     443        /**
     444         * Adds language switcher popup
     445         */
     446        function add_autoglot_language_switcher_popup() {
     447
     448            if ($this->added_switcher_box/* || is_404() || is_search()*/ || (defined('REST_REQUEST') && REST_REQUEST)) {
     449                return;
     450            }
     451
     452            if(count($this->options->active_languages) && (!$this->options->translation_adminonly || $this->options->translation_adminonly && current_user_can('manage_options'))){
     453
    438454                echo '                <div id="boxes" class="'.esc_attr(AUTOGLOT_NOTRANSLATE_LANGUAGESWITCHER).'">
    439455                <div id="ag_languageswitcher" class="ag_window" style="text-align:left">';
     
    457473            }
    458474        }
    459        
     475
    460476        /**
    461477         * Use autoglot CSS
  • autoglot/trunk/front/css/autoglot.css

    r3409735 r3412263  
    1515}
    1616
     17.ag_notranslateswitcher_menu ul {
     18    overflow-y: scroll;
     19    max-height: 400px;
     20    scrollbar-width: thin;
     21    scrollbar-color: #CCC transparent;
     22}
     23
    1724#ag_mask {
    1825  position:absolute;
     
    99106.cssflag_small {
    100107    display: inline-block;
    101     width:23px !important;
    102     height:15px !important;
     108    width: 23px !important;
     109    height: 15px !important;
    103110    margin: 1px 2px !important;
    104111    background-image: url('../img/smallflags_sprites.png');
     
    106113
    107114.cssflag_menu {
    108     margin-right: 5px !important;
    109     vertical-align: text-top;
     115    margin-right: 8px !important;
     116    vertical-align: middle;
    110117}
    111118.cssflag-ad {
  • autoglot/trunk/readme.txt

    r3409735 r3412263  
    55Tested up to: 6.9
    66Requires PHP: 7.0
    7 Stable tag: 2.9.0
     7Stable tag: 2.9.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    319319== Upgrade Notice ==
    320320
    321 = 2.9.0 =
    322 Added language switcher to menu
     321= 2.9.1 =
     322Improved language switcher шт menu
    323323
    324324= 2.8.3 =
     
    361361== Changelog ==
    362362
     363= 2.9.1 (05/12/2025) =
     364* Added a selector for the language switcher type in the menu: native dropdown or popup window
     365* The native dropdown displays child menu items as a regular menu
     366* The popup window opens a language switcher popup, similar to a floating box
     367* If there are more than 15 active languages, the dropdown menu becomes scrollable
     368* The language switcher now appears on 404 and search pages and links to the translated home pages
     369
     370
    363371= 2.9.0 (03/12/2025) =
    364372**Autoglot Introduces Language Switcher in Menu!**
    365373
    366374* Added Autoglot Language Switcher option to built-in WordPress menus
    367 * Users can add as many language switchers to different menus as they want
    368 * Each language switcher in menu can be customized and display flags, language names, or both
    369 * Type of language names can also be customized: native name, English name, ISO code, or a combination
    370 * When displaying plugin health status, Autoglot will also check if language switcher is enabled in menu
     375* Users can add multiple language switchers to different menus
     376* Each language switcher can be customized to display flags, language names, or both
     377* The type of language name can also be customized: native name, English name, ISO code, or a combination
     378* When showing plugin health status, Autoglot now also checks if a language switcher is enabled in the menu
    371379* Note: currently, only traditional themes support built-in WordPress menus
    372 * Moved a few constants from admin to a separate file to make the re-usable
     380* Moved several constants from admin to a separate file to make them reusable
    373381* Confirmed compatibility with WordPress 6.9
    374382
  • autoglot/trunk/utils/autoglot_constants.php

    r3409735 r3412263  
    250250            );
    251251
     252    const LANGUAGE_SWITCHER_MENU_TYPES = array(
     253                'languagedropdown',//default
     254                'languagepopup',
     255            );
     256
    252257    const INLINE_TAGS_EDITOR = array("b", "i", "small", "cite", "code", "em", "strong", "a", "br", "span", "sub", "sup", "h1", "h2", "h3", "h4", "h5", "h6");
    253258   
     
    256261
    257262//Define for autoglot plugin version
    258 define('AUTOGLOT_PLUGIN_VER', '2.9.0');
     263define('AUTOGLOT_PLUGIN_VER', '2.9.1');
    259264
    260265//Define for autoglot plugin name
  • autoglot/trunk/utils/autoglot_menu.php

    r3409735 r3412263  
    9494
    9595            $options = array();
     96            if(isset($_POST['autoglot-menu-meta-menu-type'][$menu_item_db_id]))$options['menu_type'] = $_POST['autoglot-menu-meta-menu-type'][$menu_item_db_id];
    9697            if(isset($_POST['autoglot-menu-meta-type'][$menu_item_db_id]))$options['switcher_type'] = $_POST['autoglot-menu-meta-type'][$menu_item_db_id];
    9798            if(isset($_POST['autoglot-menu-meta-language-names'][$menu_item_db_id])) $options['language_names'] = $_POST['autoglot-menu-meta-language-names'][$menu_item_db_id];
     
    111112        ?>
    112113        <div class="field-autoglot_menu_meta description-wide" style="margin: 15px 0;">
    113             <p class="description description-wide"><strong><?php _e( "Autoglot Language Switcher Settings", 'autoglot' ); ?></strong></p>
     114            <p class="description description-wide"><strong><?php esc_html_e( "Autoglot Language Switcher Settings", 'autoglot' ); ?></strong></p>
    114115   
    115116            <input type="hidden" name="autoglot-menu-meta[<?php echo $item_id ;?>]" value="<?php echo $item_id ;?>" />
    116117
     118            <p class="field-menu-type description description-wide">
     119                <label for="autoglot-menu-meta-menu-type-for-<?php echo $item_id ;?>">
     120                <?php esc_html_e( 'Type of Menu', 'autoglot'); ?></label>
     121                <select class="widefat" id="autoglot-menu-meta-menu-type-for-<?php echo $item_id ;?>" name="autoglot-menu-meta-menu-type[<?php echo $item_id ;?>]"><?php
     122                foreach ($this->autoglot->options->get_language_switcher_menu() as $lname_key => $lname_text) {
     123                    $selected = ($safe_autoglot_menu_meta['menu_type'] == $lname_key) ? 'selected' : '';
     124                    echo '<option value="' . esc_attr($lname_key) . '" ' . $selected . '>' . esc_html($lname_text) . '</option>';
     125                }
     126                ?>
     127                </select>
     128                <em><?php esc_html_e( '* Popup window uses the type of switcher from Autoglot Settings', 'autoglot'); ?></em>
     129            </p>
     130
    117131            <p class="field-show-flag description description-wide">
    118132                <label for="autoglot-menu-meta-type-for-<?php echo $item_id ;?>">
    119                 <?php _e( 'Type of Switcher', 'autoglot'); ?></label>
     133                <?php esc_html_e( 'Type of Switcher', 'autoglot'); ?></label>
    120134                <select class="widefat" id="autoglot-menu-meta-type-for-<?php echo $item_id ;?>" name="autoglot-menu-meta-type[<?php echo $item_id ;?>]"><?php
    121135                foreach ($this->autoglot->options->get_language_switcher_options() as $l_key => $l_text) {
     
    125139                ?>
    126140                </select>
    127                 <em><?php _e( '* Please note, some WP themes may fail to display flags properly', 'autoglot'); ?></em>
     141                <em><?php esc_html_e( '* Please note, some WP themes may fail to display flags properly', 'autoglot'); ?></em>
    128142            </p>
    129143
    130144            <p class="field-language-names description description-wide">
    131145                <label for="autoglot-menu-meta-language-names-for-<?php echo $item_id ;?>">
    132                 <?php _e( 'How to Display Language Names', 'autoglot'); ?></label>
     146                <?php esc_html_e( 'How to Display Language Names', 'autoglot'); ?></label>
    133147                <select class="widefat" id="autoglot-menu-meta-language-names-for-<?php echo $item_id ;?>" name="autoglot-menu-meta-language-names[<?php echo $item_id ;?>]"><?php
    134148                foreach ($this->autoglot->options->get_language_name_options() as $lname_key => $lname_text) {
     
    160174            foreach ($items as $item) {
    161175                if ($autoglot_menu_meta = get_post_meta($item->ID, '_autoglot_menu_item', true)) {
     176                    if (is_404() || is_search() || (defined('REST_REQUEST') && REST_REQUEST)) {
     177                        $current_url = $this->autoglot->homeURL;
     178                    }
     179
    162180                    $safe_autoglot_menu_meta = $this->autoglot->options->validate_menu_meta($autoglot_menu_meta);
    163181
     
    193211
    194212
    195                     foreach ($this->autoglot->options->active_languages as $lcode) if($lcode!=$lang) {
    196                         $language_item = clone $item;
    197                         $language_item->ID = $item->ID . '_' . $lcode;
    198 
    199                         $item_title = $item_flag = $add_item_flag = "";
    200                         $addsmallcss = "";
    201                         switch($safe_autoglot_menu_meta["switcher_type"]){
    202                             case "languageflagslist":
    203                             case "smallflagslist":
    204                                 $addsmallcss = "_small";
    205                             case "flagslist":
    206                                 $lang_flag = isset($this->autoglot->options->language_flags[$lcode])?$this->autoglot->options->language_flags[$lcode]:autoglot_utils::get_language_flag($lcode);
    207                                 $item_flag = '<span class="cssflag_menu cssflag'.$addsmallcss.' cssflag-'.esc_attr($lang_flag.$addsmallcss).'"></span>';
    208                             break;
    209                             default:
    210                             break;
     213                    if($safe_autoglot_menu_meta["menu_type"] == "languagedropdown") {
     214                        foreach ($this->autoglot->options->active_languages as $lcode) if($lcode!=$lang) {
     215                            $language_item = clone $item;
     216                            $language_item->ID = $item->ID . '_' . $lcode;
     217   
     218                            $item_title = $item_flag = $add_item_flag = "";
     219                            $addsmallcss = "";
     220                            switch($safe_autoglot_menu_meta["switcher_type"]){
     221                                case "languageflagslist":
     222                                case "smallflagslist":
     223                                    $addsmallcss = "_small";
     224                                case "flagslist":
     225                                    $lang_flag = isset($this->autoglot->options->language_flags[$lcode])?$this->autoglot->options->language_flags[$lcode]:autoglot_utils::get_language_flag($lcode);
     226                                    $item_flag = '<span class="cssflag_menu cssflag'.$addsmallcss.' cssflag-'.esc_attr($lang_flag.$addsmallcss).'"></span>';
     227                                break;
     228                                default:
     229                                break;
     230                            }
     231                            switch($safe_autoglot_menu_meta["switcher_type"]){
     232                                case "smallflagslist":
     233                                case "flagslist":
     234                                    $item_title = $item_flag;
     235                                break;
     236                                case "languageflagslist":
     237                                    $add_item_flag = $item_flag;
     238                                default:
     239                                    $item_title = $add_item_flag.esc_html(autoglot_utils::get_full_name($lcode,$safe_autoglot_menu_meta["language_names"]));
     240                                break;
     241                            }
     242                           
     243                            $language_item->title = $item_title;
     244                            //$language_item->attr_title = esc_html(autoglot_utils::get_full_name($lcode, "iso"));
     245                            // Build language menu URL
     246                            if ($lcode == $this->autoglot->options->default_language) {
     247                                $language_item->url = $current_url;
     248                            } else {
     249                                if ($this->autoglot->options->translate_urls) {
     250                                    $language_item->url = autoglot_utils::add_language_to_url($this->autoglot->translate_url($current_url, $lcode), $this->autoglot->homeURL, $lcode);
     251                                } else {
     252                                    $language_item->url = autoglot_utils::add_language_to_url($current_url, $this->autoglot->homeURL, $lcode);
     253                                }
     254                            }
     255                            $language_item->lang = $lcode;
     256                            $language_item->menu_item_parent = $item->ID;
     257                            $language_item->menu_order = $menu_order++;
     258                            $language_item->db_id = 0;
     259                            $updated_items[] = $language_item;
    211260                        }
    212                         switch($safe_autoglot_menu_meta["switcher_type"]){
    213                             case "smallflagslist":
    214                             case "flagslist":
    215                                 $item_title = $item_flag;
    216                             break;
    217                             case "languageflagslist":
    218                                 $add_item_flag = $item_flag;
    219                             default:
    220                                 $item_title = $add_item_flag.esc_html(autoglot_utils::get_full_name($lcode,$safe_autoglot_menu_meta["language_names"]));
    221                             break;
    222                         }
    223                        
    224                         $language_item->title = $item_title;
    225                         //$language_item->attr_title = esc_html(autoglot_utils::get_full_name($lcode, "iso"));
    226                         // Build language menu URL
    227                         if ($lcode == $this->autoglot->options->default_language) {
    228                             $language_item->url = $current_url;
    229                         } else {
    230                             if ($this->autoglot->options->translate_urls) {
    231                                 $language_item->url = autoglot_utils::add_language_to_url($this->autoglot->translate_url($current_url, $lcode), $this->autoglot->homeURL, $lcode);
    232                             } else {
    233                                 $language_item->url = autoglot_utils::add_language_to_url($current_url, $this->autoglot->homeURL, $lcode);
    234                             }
    235                         }
    236                         $language_item->lang = $lcode;
    237                         $language_item->menu_item_parent = $item->ID;
    238                         $language_item->menu_order = $menu_order++;
    239                         $language_item->db_id = 0;
    240                         $updated_items[] = $language_item;
    241                     }
     261                    }/* elseif($safe_autoglot_menu_meta["menu_type"] == "languagepopup") {
     262                        $this->autoglot->add_autoglot_language_switcher_popup();
     263                    }*/
     264
    242265                    $item->classes[] = AUTOGLOT_NOTRANSLATE_LANGUAGESWITCHER;
     266                    if(count($this->autoglot->options->active_languages)>15) $item->classes[] = AUTOGLOT_NOTRANSLATE_LANGUAGESWITCHER."_menu";
    243267                    $updated_items[] = $item;
    244268                } else {
     
    258282        if (get_post_meta($item->ID, '_autoglot_menu_item', true) || get_post_meta($item->menu_item_parent, '_autoglot_menu_item', true)) {
    259283            $attrs['data-type'] = 'languageswitcher';
     284        }
     285        if (($autoglot_menu_meta = get_post_meta($item->ID, '_autoglot_menu_item', true)) && !get_post_meta($item->menu_item_parent, '_autoglot_menu_item', true)) {
     286            $safe_autoglot_menu_meta = $this->autoglot->options->validate_menu_meta($autoglot_menu_meta);
     287            if($safe_autoglot_menu_meta["menu_type"] == "languagepopup"){
     288                $attrs['name'] = 'ag_modal';
     289                $attrs['box'] = 'ag_languageswitcher';
     290            }
    260291        }
    261292        return $attrs;
  • autoglot/trunk/utils/autoglot_options.php

    r3409735 r3412263  
    5353    private $language_switcher_positions;
    5454    private $language_name_options;
     55    private $language_switcher_menu;
    5556
    5657    private function validate_checkbox($option, $default1 = 1, $max_value = 1){
     
    6667       
    6768        $validated_menu_meta = array();
    68         $default_options = array( 'switcher_type' => $this->popup_switcher, 'language_names' => $this->language_names ); // Default values
     69        $default_options = array( 'menu_type' => "languagedropdown"/*TODO: array_key_first PHP 7 >= 7.3*/, 'switcher_type' => $this->popup_switcher, 'language_names' => $this->language_names ); // Default values
     70       
     71        if(isset($autoglot_menu_meta["menu_type"]) && in_array($autoglot_menu_meta["menu_type"], autoglot_consts::LANGUAGE_SWITCHER_MENU_TYPES, true)){
     72            $validated_menu_meta["menu_type"] = $autoglot_menu_meta["menu_type"];
     73        } else {
     74            $validated_menu_meta["menu_type"] = $default_options["menu_type"];
     75        }
    6976       
    7077        if(isset($autoglot_menu_meta["switcher_type"]) && in_array($autoglot_menu_meta["switcher_type"], autoglot_consts::LANGUAGE_SWITCHER_TYPES, true)){
     
    210217        );
    211218
     219        $this->language_switcher_menu = array(
     220            'languagedropdown' => __( 'Dropdown Menu', 'autoglot' ),
     221            'languagepopup'      => __( 'Language Switcher Popup', 'autoglot' ),
     222        );
     223
    212224        $this->language_switcher_options = array(
    213225            'languagelist'      => __( 'Language Names', 'autoglot' ),
     
    239251    }
    240252
     253    public function get_language_switcher_menu(): array {
     254        return $this->language_switcher_menu;
     255    }
     256
    241257    public function get_language_switcher_options(): array {
    242258        return $this->language_switcher_options;
  • autoglot/trunk/utils/autoglot_widget.php

    r3344116 r3412263  
    158158                $flagimage = "";
    159159
    160                 $current_url = is_404()?$this->autoglot->homeURL:$this->autoglot->get_original_url(home_url( add_query_arg( array(), $wp->request ) ),$this->autoglot->homeURL,$this->autoglot->langURL, 0);
     160                $current_url = (is_404()||is_search())?$this->autoglot->homeURL:$this->autoglot->get_original_url(home_url( add_query_arg( array(), $wp->request ) ),$this->autoglot->homeURL,$this->autoglot->langURL, 0);
    161161                $current_link = $current_url;//str_replace($this->autoglot->homeURL, "", $current_url);
    162162                $widget_translate_urls = $this->autoglot->options->translate_urls;
Note: See TracChangeset for help on using the changeset viewer.