Plugin Directory

Changeset 1524934


Ignore:
Timestamp:
10/30/2016 07:47:04 PM (9 years ago)
Author:
theode
Message:

wp 4.7 and bugfixes

Location:
no-function-language-widget/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • no-function-language-widget/trunk/no-function-language-widget.php

    r1302872 r1524934  
    55Description: It produces an output of a language changing widget but has no additional features behind it.
    66Author: wp-plugin-dev.com
    7 Version: 1.5
     7Version: 1.6
    88License: CC-BY-SA 4.0
    99License URI: https://creativecommons.org/licenses/by-sa/4.0/
    1010Author URI: http://www.wp-plugin-dev.com/
    1111You are free to use it or modify it for clients, as long as you keep the name wp-plugin-dev.com .
    12 
    1312It is now using https://cdnjs.com/libraries/flag-icon-css Flags
    1413*/
    15 
    16 
    17 
    1814// class no_function_language_widget
    1915add_action( 'widgets_init', create_function( '', 'register_widget( "no_function_language_widget" );' ) );
    2016
    21 
    22 function contains($substring, $string) {
     17function contains($substring, $string)
     18{
    2319    $pos = strpos($string, $substring);
    2420
    25 
    26     if ($pos === false) {
     21    if ($pos === false)
     22    {
    2723        // string needle NOT found in haystack
    2824        return false;
    2925    }
    30     else {
     26    else
     27    {
    3128        // string needle found in haystack
    3229        return true;
    3330
    3431    }
    35 
    3632}
    3733
    3834class no_function_language_widget extends WP_Widget {
    39 
    40     public function __construct() {
     35    public function __construct()
     36    {
    4137        parent::__construct(
    4238            'no_function_language_widget', // Base ID
    43             __('No')." ".__("Function")." ".__("Language")." ".__("Widget"), // Name
     39            __('None')." ".__("Function")." ".__("Language")." ".__("Widget"), // Name
    4440            array( 'description' => __( 'A No Function Language Changer', 'text_domain' ), ) // Args
    4541        );
     
    4743    }
    4844
    49 
    50     public function widget( $args, $instance ) {
    51 
    52 
    53         // https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.5/css/flag-icon.min.css
     45    public function widget( $args, $instance )
     46    {
    5447        wp_enqueue_style( 'flag-icons', "https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.5/css/flag-icon.min.css" );
    5548
     
    6356
    6457        $langbase= $instance['nflw_language_base'];
    65 
    66 
    67 
    6858        echo $before_widget;
    6959
     
    7161            echo $before_title . $title . $after_title;
    7262
    73 
    7463        $lansum=count($nflw_languages);
    7564
    7665        $i=0;
    7766
    78         if ($langbase=="?lang=") {
    79 
    80             while ($i<$lansum ) {
     67        if ($langbase=="?lang=")
     68        {
     69            while ($i<$lansum )
     70            {
    8171                ?><a class="flag-icon flag-icon-<?php echo $nflw_languages[$i];
    8272                ?>" href="?lang=<?php echo $nflw_languages[$i];
     
    8575            }
    8676        }
    87         else {
    88             while ($i<$lansum ) {
    89 
     77        else
     78        {
     79            while ($i<$lansum )
     80            {
    9081                $this_wp = ''.get_bloginfo('wpurl').'';
    9182
     
    9788                $j=0;
    9889
    99                 while ($j<$lansum) {
     90                while ($j<$lansum)
     91                {
    10092                    $this_url_lang=''.$this_wp.'/'.$nflw_languages[$j].'/';
    10193
    102 
    103                     if ($this_url_lang==$this_url) {$language_set=true;
    104                     }
    105                     else {$language_set=false;
    106                     }
    107 
     94                    if ($this_url_lang==$this_url)
     95                        {$language_set=true;
     96                    }
     97                    else
     98                        {$language_set=false;
     99                    }
    108100                    $current_language = "/".$nflw_languages[$j]."/";
    109101
    110                     if (contains($current_language, $this_url)) {$language_set=true;
    111                     }
    112                     else {$language_set=false;
    113                     }
    114 
    115                     if ($language_set==true) {$choozen_language_URL=="";
     102                    if (contains($current_language, $this_url))
     103                        {$language_set=true;
     104                    }
     105                    else
     106                        {$language_set=false;
     107                    }
     108                    if ($language_set==true)
     109                        {$choozen_language_URL=="";
    116110
    117111                        $this_post = str_replace($this_url_lang , "", $this_url);
    118112
    119 
    120113                        $this_post = str_replace($current_language , "", $this_post);
    121114
    122115                    }
    123                     else {}
     116                    else
     117                        {}
    124118                    $j++;
    125119
    126120                }
    127                 if ($nflw_languages[$i]==$nflw_languages[0]) {
     121                if ($nflw_languages[$i]==$nflw_languages[0])
     122                {
    128123                    $choozen_language_URL=''.get_bloginfo('wpurl').'/';
    129124
    130125                    //default language hack
    131126                }
    132                 else {
    133 
     127                else
     128                {
    134129                    // If you want it directly to the current site uncomment $this_post
    135130                    $choozen_language_URL=''.get_bloginfo('wpurl').'/'.$nflw_languages[$i];
     
    139134                $language_set=false;
    140135
    141 
    142136                ?><a  class="flag-icon flag-icon-<?php echo $nflw_languages[$i];
    143137                ?>" href="<?php echo $choozen_language_URL ?>"> </a> <?php
    144138                $i++;
    145139            }
    146 
    147140        }
    148141        //echo ' -> your url '.$this_post.'';
    149142        echo $after_widget;
    150143
    151 
    152     }
    153 
    154     public function update( $new_instance, $old_instance ) {
     144    }
     145
     146    public function update( $new_instance, $old_instance )
     147    {
    155148        $instance = array();
    156149
     
    165158    }
    166159
    167 
    168     public function form( $instance ) {
    169         if ( isset( $instance[ 'title' ] )) {
     160    public function form( $instance )
     161    {
     162        if ( isset( $instance[ 'title' ] ))
     163        {
    170164            $title = __($instance[ 'title' ]);
    171165
     
    175169
    176170        }
    177         else {
     171        else
     172        {
    178173            $title = __( 'New title', 'text_domain' );
    179174
     
    208203        <input  id="<?php echo $this->get_field_id( 'nflw_language_base' );
    209204        ?>" name="<?php echo $this->get_field_name( 'nflw_language_base' );
    210         ?>" type="radio" value="/" <?php if ($nflw_language_base=="/") {echo ' checked';
     205        ?>" type="radio" value="/" <?php if ($nflw_language_base=="/")
     206            {echo ' checked';
    211207        }?>/> /de <br>
    212208        <input id="<?php echo $this->get_field_id( 'nflw_language_base' );
    213209        ?>" name="<?php echo $this->get_field_name( 'nflw_language_base' );
    214         ?>" type="radio" value="?lang=" <?php if ($nflw_language_base=="?lang=") {echo ' checked';
     210        ?>" type="radio" value="?lang=" <?php if ($nflw_language_base=="?lang=")
     211            {echo ' checked';
    215212        }?>/> ?lang=de
    216213        </p>
     
    218215    }
    219216
    220 } 
     217}
    221218
    222219?>
  • no-function-language-widget/trunk/readme.txt

    r1302872 r1524934  
    44Tags: language, multilingual, widget, flags
    55Requires at least: 3.0
    6 Tested up to: 4.4
    7 Stable tag: 1.5
     6Tested up to: 4.7
     7Stable tag: 1.6
    88License: CC-BY-SA 4.0
    99License URI: https://creativecommons.org/licenses/by-sa/4.0/
Note: See TracChangeset for help on using the changeset viewer.