WordPress.org

Plugin Directory

Changeset 519890


Ignore:
Timestamp:
03/16/12 15:51:04 (2 years ago)
Author:
MZAWeb
Message:

Added correct localization management for weekdays

Location:
business-hours-plugin/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • business-hours-plugin/trunk/widget.php

    r517200 r519890  
    4242 
    4343 
    44             $day = strtolower( $workinghours->get_day_using_timezone() ); 
    45             $open = $workinghours->settings->get_setting($day,"open"); 
    46             $close = $workinghours->settings->get_setting($day,"close"); 
    47             $working = $workinghours->settings->get_setting($day,"working"); 
     44            $day = $workinghours->get_day_using_timezone() ; 
     45 
     46            $id = key($day); 
     47            $name = $day[$id]; 
     48 
     49            $open = $workinghours->settings->get_setting($id,"open"); 
     50            $close = $workinghours->settings->get_setting($id,"close"); 
     51            $working = $workinghours->settings->get_setting($id,"working"); 
    4852 
    4953            echo $before_widget; 
     
    5963 
    6064            if ($instance['template_today'] != ""){ 
    61                 $today = str_replace("{{Day}}", ucwords($day), $instance['template_today']); 
     65                $today = str_replace("{{Day}}", $name, $instance['template_today']); 
    6266                $template = $today.$template; 
    6367            } 
  • business-hours-plugin/trunk/working-hours.class.php

    r517201 r519890  
    1414        if ( $content ) { 
    1515 
    16             $day     = strtolower( $this->get_day_using_timezone() ); 
    17             $open    = $this->settings->get_setting( $day, "open" ); 
    18             $close   = $this->settings->get_setting( $day, "close" ); 
    19             $working = $this->settings->get_setting( $day, "working" ); 
     16            $day = $this->get_day_using_timezone(); 
     17 
     18            $id   = key( $day ); 
     19 
     20            $open    = $this->settings->get_setting( $id, "open" ); 
     21            $close   = $this->settings->get_setting( $id, "close" ); 
     22            $working = $this->settings->get_setting( $id, "working" ); 
    2023 
    2124            if ( $working == "true" ) { 
     
    4447            wp_enqueue_style( 'BusinessHoursStyle' ); 
    4548 
    46             wp_register_script('BusinessHoursScript', plugins_url('script.js', __FILE__), array('jquery')); 
    47             wp_enqueue_script('BusinessHoursScript'); 
     49            wp_register_script( 'BusinessHoursScript', plugins_url( 'script.js', __FILE__ ), array( 'jquery' ) ); 
     50            wp_enqueue_script( 'BusinessHoursScript' ); 
    4851        } 
    4952        return $this->get_table( $collapsible ); 
     
    5558        $offset    = $offset * 60 * 60; 
    5659        $timestamp = time() + $offset; 
    57         return gmdate( 'l', $timestamp ); 
     60        $arr = array( strtolower( gmdate( 'l', $timestamp ) )  => ucwords( date_i18n( 'l', $timestamp ) ) ); 
     61        return $arr; 
     62    } 
     63 
     64    private function _get_week_days() { 
     65 
     66        $timestamp = strtotime( 'next Sunday' ); 
     67        $days      = array(); 
     68        for ( $i = 0; $i < 7; $i++ ) { 
     69 
     70            $days[] = array( strtolower( gmdate( 'l', $timestamp ) )  => ucwords( date_i18n( 'l', $timestamp ) ) ); 
     71            $timestamp = strtotime( '+1 day', $timestamp ); 
     72        } 
     73 
     74        return $days; 
    5875    } 
    5976 
     
    6986 
    7087        if ( $collapsible_link ) { 
    71             $ret .= '<a class="business_hours_collapsible_handler" href="#">' . __("[Show all days]", "business-hours") . '</a>'; 
     88            $ret .= '<a class="business_hours_collapsible_handler" href="#">' . __( "[Show all days]", "business-hours" ) . '</a>'; 
    7289            $ret .= '<div class="business_hours_collapsible">'; 
    7390        } 
    7491 
    7592 
    76         $timestamp = strtotime( 'next Sunday' ); 
    77         $days      = array(); 
    78         for ( $i = 0; $i < 7; $i++ ) { 
    79             $days[]    = strftime( '%A', $timestamp ); 
    80             $timestamp = strtotime( '+1 day', $timestamp ); 
    81         } 
     93        $days = $this->_get_week_days(); 
    8294 
    8395        $ret .= "<table width='100%'>"; 
    8496        $ret .= "<tr><th>" . __( "Day", "business-hours" ) . "</th><th  class='business_hours_table_heading'>" . __( "Open", "business-hours" ) . "</th><th  class='business_hours_table_heading'>" . __( "Close", "business-hours" ) . "</th></tr>"; 
    8597        foreach ( $days as $day ) { 
    86             $day     = strtolower( $day ); 
    87             $open    = $workinghours->settings->get_setting( $day, "open" ); 
    88             $close   = $workinghours->settings->get_setting( $day, "close" ); 
    89             $working = $workinghours->settings->get_setting( $day, "working" ); 
     98 
     99            $id = key($day); 
     100            $name = $day[$id]; 
     101 
     102            $open    = $workinghours->settings->get_setting( $id, "open" ); 
     103            $close   = $workinghours->settings->get_setting( $id, "close" ); 
     104            $working = $workinghours->settings->get_setting( $id, "working" ); 
    90105 
    91106            $ret .= "<tr>"; 
    92             $ret .= "<td class='business_hours_table_day'>" . ucwords( $day ) . "</td>"; 
     107            $ret .= "<td class='business_hours_table_day'>" . ucwords( $name ) . "</td>"; 
    93108            if ( $working == "true" ) { 
    94109                $ret .= "<td class='business_hours_table_open'>" . ucwords( $open ) . "</td>"; 
    95110                $ret .= "<td class='business_hours_table_close'>" . ucwords( $close ) . "</td>"; 
    96111            } else { 
    97                 $ret .= "<td class='business_hours_table_closed' colspan='2' align='center'>" . __("Closed", "business-hours" ) ."</td>"; 
     112                $ret .= "<td class='business_hours_table_closed' colspan='2' align='center'>" . __( "Closed", "business-hours" ) . "</td>"; 
    98113            } 
    99114 
     
    112127    private function register_settings() { 
    113128 
    114         $timestamp = strtotime( 'next Sunday' ); 
    115         $days      = array(); 
    116         for ( $i = 0; $i < 7; $i++ ) { 
    117             $days[]    = strftime( '%A', $timestamp ); 
    118             $timestamp = strtotime( '+1 day', $timestamp ); 
    119         } 
     129        $days     = $this->_get_week_days(); 
    120130        $sections = array(); 
    121131 
    122132        foreach ( $days as $day ) { 
    123  
    124             $sections[strtolower( $day )] = array( "title"  =>  $day, "business-hours", 
    125                                                    "fields" => array( "working" => array( "title"   => sprintf( __("Is it open on %s?","business-hours") , $day), 
     133            $id = key($day); 
     134            $name = $day[$id]; 
     135            $sections[$id] = array( "title"  => $name, "business-hours", 
     136                                                   "fields" => array( "working" => array( "title"   => sprintf( __( "Is it open on %s?", "business-hours" ), $name ), 
    126137                                                                                          "type"    => "checkbox", 
    127138                                                                                          "options" => array( "true" => "" ) ), 
     
    140151 
    141152        $sections["support"] = array( "title"  => __( "Support", "business-hours" ), 
    142                                       "fields" => array( "mzaweb" => array( "title" => __("Bugs? Questions? Suggestions?", "business-hours" ), 
     153                                      "fields" => array( "mzaweb" => array( "title" => __( "Bugs? Questions? Suggestions?", "business-hours" ), 
    143154                                                                            "type"  => "support", 
    144155                                                                            "email" => "support@mzaweb.com" ) ) ); 
Note: See TracChangeset for help on using the changeset viewer.