1. В файле "../inc/shortcodes/links_list.php" перейти на 179 строку, рядом с ней найти такой код:
< ul class ="links_list<?php if (!empty($align)) echo ' links_list-align-'.$align; ?><?php echo esc_attr( $css_class ); ?> ">
Сразу после нее, с новой строки, вставить этот код:
<?php if ($ align == 'right ' ){
if (get_option ('lang_widget ' ) == 1 ){
$ languages = icl_get_languages ('skip_missing=0&orderby=code ' );
echo '<li><div class="woocommerce-currency-switcher-form"><div id="lang_widget" class="dd-container"> ' ;
if (!empty ($ languages )){
foreach ($ languages as $ l ){
if ($ l ['active ' ]) echo '<div class="dd-select"><a class="dd-selected"> ' ;
if (!$ l ['active ' ]) echo '<li><a class="dd-option" href=" ' .$ l ['url ' ].'"> ' ;
if ($ l ['country_flag_url ' ]) echo '<img class="dd-option-image dd-image-left" src=" ' .$ l ['country_flag_url ' ].'" height="12" alt=" ' .$ l ['language_code ' ].'" width="18" /> ' ;
echo ($ l ['active ' ] ? '<label class="dd-selected-text"> ' : '<label class="dd-option-text"> ' ) . icl_disp_language ($ l ['translated_name ' ]) . '</label> ' ;
if (!$ l ['active ' ]) echo '</a></li> ' ;
if ($ l ['active ' ]) echo '</a></div><ul class="dd-options"> ' ;
}
}
echo '</ul></div></div></li> ' ;
}
if (get_option ('curr_widget ' ) == 1 ) echo '<li> ' . do_shortcode ('[woocs] ' ) . '</li> ' ;
}?>
2. В конец файла "../style.css" добавить эти стили:
.links_list , .dd-selected-image , .dd-image-right , .dd-option-description , .dd-selected-description , .dd-pointer , footer .woocommerce-currency-switcher-form , footer .custom_li_lang {
display : none;
}
.dd-select {
background : none !important ;
border : none !important ;
}
.dd-options {
margin : 0 !important ;
width : max-content !important ;
}
.dd-options li {
margin : 0 !important ;
display : block;
}
.dd-option-text {
line-height : initial !important ;
display : table-row;
cursor : pointer;
}
.dd-selected-text , .dd-option-selected {
color : # 373d54 !important ;
font-weight : 500 !important ;
cursor : pointer;
}
.woocommerce-currency-switcher-form .dd-selected {
padding : 0 !important ;
margin-top : -8px !important ;
}
.dd-container : after {
color : inherit;
font-size : 12px ;
font-family : Dashicons;
content : '\f347' ;
line-height : 1 ;
position : absolute;
top : 55% ;
right : -12px ;
margin : -6px 0 0 0 ;
vertical-align : middle;
display : inline-block;
-webkit-transform : rotate (0 );
-moz-transform : rotate (0 );
-ms-transform : rotate (0 );
transform : rotate (0 );
}
# lang_widget img {
margin-top : 2px ;
}
3. В конец файла "../functions.php" добавить этот код:
function theme_settings_page () {
?> <div class="wrap">
<h1>Пользовательские настройки</h1>
<form method="post" action="options.php"><?php
settings_fields ("widgets-section " );
do_settings_sections ("my-custom-options " );
submit_button ();
?> </form>
</div><?php
}
function add_theme_menu_item () {
add_menu_page ("Доп. параметры " , "Доп. параметры " , "manage_options " , "custom-settings-panel " , "theme_settings_page " , null , 59 );
}
add_action ("admin_menu " , "add_theme_menu_item " );
function display_widgets_element () { ?>
<fieldset>
<label for="lang_widget">
<input name="lang_widget" type="checkbox" id="lang_widget" value="1" <?php checked (1 , get_option ('lang_widget ' ), true ); ?> />
Отображать виджет смены языка
</label>
</fieldset>
<fieldset>
<label for="curr_widget">
<input name="curr_widget" type="checkbox" id="curr_widget" value="1" <?php checked (1 , get_option ('curr_widget ' ), true ); ?> />
Отображать виджет валют
</label>
</fieldset><?php
}
function display_theme_panel_fields (){
add_settings_section ("widgets-section " , "Кастомные настройки " , null , "my-custom-options " );
add_settings_field ("widgets " , "Виджеты " , "display_widgets_element " , "my-custom-options " , "widgets-section " );
register_setting ("widgets-section " , "curr_widget " );
register_setting ("widgets-section " , "lang_widget " );
}
add_action ("admin_init " , "display_theme_panel_fields " );
4. В конец файла "../js/main.js" вставить следующий код:
jQuery ( document ) . ready ( function ( $ ) {
$ ( '.links_list' ) . show ( ) ;
$ ( "#lang_widget .dd-selected" ) . click ( function ( e ) {
$ ( '#lang_widget .dd-options' ) . slideToggle ( 'fast' ) ;
} ) ;
jQuery ( document ) . mouseup ( function ( e ) {
if ( ! $ ( '#lang_widget' ) . find ( '*' ) . is ( e . target ) ) $ ( '#lang_widget .dd-options' ) . slideUp ( 'fast' ) ;
} ) ;
} ) ;