Changeset 1866057
- Timestamp:
- 04/29/2018 04:32:04 PM (8 years ago)
- Location:
- salah-widget
- Files:
-
- 5 edited
-
assets/save_widget.png (modified) (previous)
-
assets/screenshot-2.png (modified) (previous)
-
assets/upload_csv.png (modified) (previous)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/salah-widget.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
salah-widget/trunk/readme.txt
r1865866 r1866057 15 15 The widget shows the prayer/fasting time on your website using the local WordPress timezone and the provided salah.csv file (see installation description). 16 16 17 Front-end language support for: 18 - English 19 - German 20 - Bosnian 21 17 22 == Installation == 18 23 … … 26 31 8. Enter the name of your city in the Salah Widget settings 27 32 9. Choose a Theme 33 10. Select the front-end language 28 34 10. [Save](https://plugins.svn.wordpress.org/salah-widget/assets/save_widget.png) your Salah Widget settings 29 35 … … 44 50 = 1.1 = 45 51 * Stable version. 46 * Support for german language.52 * Added front-end language selection for: english, german, bosnian -
salah-widget/trunk/salah-widget.php
r1865866 r1866057 32 32 $defaults = array( 33 33 'salah_city' => $timezone, 34 'select' => 'Classic' 34 'select_theme' => 'Classic', 35 'select_language' => 'English' 35 36 ); 36 37 … … 38 39 $date_time->setTimezone(new DateTimeZone($timezone)); 39 40 40 $current_date = $date_time->format('d') . "." . $date_time->format('m') . ".". $date_time->format('Y');41 $current_time = $date_time->format('H') . ":" . $date_time->format('i') . ":". $date_time->format('s');42 $display_date_time = '<br><b>' . $current_date . " - ". $current_time . '</b><br>' . '(' . __('Please ensure that the displayed date and time are same with your local/city date and time, if not change the Timezone in your WordPress settings') . ' !)';41 $current_date = $date_time->format('d') . '.' . $date_time->format('m') . '.' . $date_time->format('Y'); 42 $current_time = $date_time->format('H') . ':' . $date_time->format('i') . ':' . $date_time->format('s'); 43 $display_date_time = '<br><b>' . $current_date . ' - ' . $current_time . '</b><br>' . '(' . __('Please ensure that the displayed date and time are same with your local/city date and time, if not change the Timezone in your WordPress settings') . ' !)'; 43 44 44 45 ?> … … 47 48 48 49 ?> 49 <label for= "<?php echo $this->get_field_id('salah_city'); ?>"><?php _e('Add');50 <label for='<?php echo $this->get_field_id('salah_city'); ?>'><?php _e('Add'); 50 51 echo ' <b>salah.csv</b> '; 51 52 _e('document'); … … 62 63 63 64 <p> 64 <label for= "<?php echo $this->get_field_id('salah_city'); ?>"><?php _e('Enter Location');65 <label for='<?php echo $this->get_field_id('salah_city'); ?>'><?php _e('Enter Location'); 65 66 echo ':'; ?></label> 66 <label for= "<?php echo esc_attr($this->get_field_id('salah_city')); ?>"></label>67 <input class= "widefat" id="<?php echo esc_attr($this->get_field_id('salah_city')); ?>"68 name= "<?php echo esc_attr($this->get_field_name('salah_city')); ?>" type="text"69 value= "<?php echo esc_attr($salah_city); ?>"/>67 <label for='<?php echo esc_attr($this->get_field_id('salah_city')); ?>'></label> 68 <input class='widefat' id='<?php echo esc_attr($this->get_field_id('salah_city')); ?>' 69 name='<?php echo esc_attr($this->get_field_name('salah_city')); ?>' type='text' 70 value='<?php echo esc_attr($salah_city); ?>'/> 70 71 </p> 71 72 72 73 <p> 73 <label for= "<?php echo $this->get_field_id('select'); ?>"><?php _e('Select Theme');74 <label for='<?php echo $this->get_field_id('select_theme'); ?>'><?php _e('Select Theme'); 74 75 echo ':'; ?></label> 75 <select name= "<?php echo $this->get_field_name('select'); ?>"76 id= "<?php echo $this->get_field_id('select'); ?>"class="widefat">76 <select name='<?php echo $this->get_field_name('select_theme'); ?>' 77 id='<?php echo $this->get_field_id('select_theme'); ?>' class="widefat"> 77 78 <?php 78 79 // Your options array … … 87 88 // Loop through options and add each one to the select dropdown 88 89 foreach ($options as $key => $name) { 89 echo '<option value="' . esc_attr($key) . '" id="' . esc_attr($key) . '" ' . selected($select , $key, false) . '>' . $name . '</option>';90 echo '<option value="' . esc_attr($key) . '" id="' . esc_attr($key) . '" ' . selected($select_theme, $key, false) . '>' . $name . '</option>'; 90 91 91 92 } ?> … … 93 94 </p> 94 95 96 <p> 97 <label for='<?php echo $this->get_field_id('select_language'); ?>'><?php _e('Select Frontend Language'); 98 echo ':'; ?></label> 99 <select name='<?php echo $this->get_field_name('select_language'); ?>' 100 id='<?php echo $this->get_field_id('select_language'); ?>' class="widefat"> 101 <?php 102 // Your options array 103 $options = array( 104 'en_language' => __('English'), 105 'de_language' => __('German'), 106 'bs_language' => __('Bosnian') 107 ); 108 109 // Loop through options and add each one to the select dropdown 110 foreach ($options as $key => $name) { 111 echo '<option value="' . esc_attr($key) . '" id="' . esc_attr($key) . '" ' . selected($select_language, $key, false) . '>' . $name . '</option>'; 112 113 } ?> 114 </select> 115 </p> 116 95 117 <?php 96 118 } … … 100 122 $instance = $old_instance; 101 123 $instance['salah_city'] = isset($new_instance['salah_city']) ? wp_strip_all_tags($new_instance['salah_city']) : ''; 102 $instance['select'] = isset($new_instance['select']) ? wp_strip_all_tags($new_instance['select']) : ''; 124 $instance['select_theme'] = isset($new_instance['select_theme']) ? wp_strip_all_tags($new_instance['select_theme']) : ''; 125 $instance['select_language'] = isset($new_instance['select_language']) ? wp_strip_all_tags($new_instance['select_language']) : ''; 103 126 return $instance; 104 127 } … … 107 130 public function widget($args, $instance) 108 131 { 132 global $en_language; 133 global $de_language; 134 global $bs_language; 135 109 136 extract($args); 110 137 111 138 $salah_city = !empty($instance['salah_city']) ? apply_filters('widget_title', $instance['salah_city']) : 'Europe/Vienna'; 112 $salah_theme = !empty($instance['select']) ? $instance['select'] : 'classicTable'; 139 $salah_theme = !empty($instance['select_theme']) ? $instance['select_theme'] : 'classicTable'; 140 $salah_language = !empty($instance['select_language']) ? $instance['select_language'] : 'en_language'; 141 113 142 $file_id = get_option('salah'); 114 143 $file = get_attached_file($file_id); … … 118 147 $current_date = date('d') . '/' . date('m') . '/' . date('Y'); 119 148 $csv_data = file_get_contents($file); 120 $csv_data = iconv( "windows-1250", "utf-8", $csv_data);149 $csv_data = iconv('windows-1250', 'utf-8', $csv_data); 121 150 122 151 $lines = explode("\n", $csv_data); // split data by new lines … … 134 163 } 135 164 } else { 136 $date = "Error";137 $fajr = "Error";138 $sunrise = "Error";139 $dhuhr = "Error";140 $asr = "Error";141 $maghrib = "Error";142 $isha = "Error";165 $date = 'Error'; 166 $fajr = 'Error'; 167 $sunrise = 'Error'; 168 $dhuhr = 'Error'; 169 $asr = 'Error'; 170 $maghrib = 'Error'; 171 $isha = 'Error'; 143 172 } 173 174 $selected_language = null; 175 176 switch ($salah_language) { 177 case 'en_language': 178 $selected_language = $en_language; 179 break; 180 case 'de_language': 181 $selected_language = $de_language; 182 break; 183 case 'bs_language': 184 $selected_language = $bs_language; 185 break; 186 } 187 144 188 145 189 echo $before_widget; … … 147 191 echo '<thead>'; 148 192 echo '<tr>'; 149 echo '<th colspan="4">' . __('Salah time for '). $salah_city . '<br>' . $date . '</th>';193 echo '<th colspan="4">' . $selected_language['Salah time for '] . $salah_city . '<br>' . $date . '</th>'; 150 194 echo '</tr>'; 151 195 echo '</thead>'; 152 196 echo '<tbody>'; 153 197 echo '<tr>'; 154 echo '<td>' . __('Fajr'). '</td>';198 echo '<td>' . $selected_language['Fajr'] . '</td>'; 155 199 echo '<td>' . $fajr . '</td>'; 156 echo '<td>' . __('Asr'). '</td>';200 echo '<td>' .$selected_language['Asr'] . '</td>'; 157 201 echo '<td>' . $asr . '</td>'; 158 202 echo '</tr>'; 159 203 echo '<tr>'; 160 echo '<td>' . __('Sunrise'). '</td>';204 echo '<td>' . $selected_language['Sunrise'] . '</td>'; 161 205 echo '<td>' . $sunrise . '</td>'; 162 echo '<td>' . __('Maghrib'). '</td>';206 echo '<td>' . $selected_language['Maghrib'] . '</td>'; 163 207 echo '<td >' . $maghrib . '</td>'; 164 208 echo '</tr>'; 165 209 echo '<tr>'; 166 echo '<td>' . __('Dhuhr'). '</td>';210 echo '<td>' . $selected_language['Dhuhr'] . '</td>'; 167 211 echo '<td>' . $dhuhr . '</td>'; 168 echo '<td>' . __('Isha'). '</td>';212 echo '<td>' . $selected_language['Isha'] . '</td>'; 169 213 echo '<td>' . $isha . '</td>'; 170 214 echo '</tr>'; … … 175 219 } 176 220 221 $en_language = [ 222 'Salah time for ' => 'Salah time for ', 223 'Fajr' => 'Fajr', 224 'Asr' => 'Asr', 225 'Sunrise' => 'Sunrise', 226 'Maghrib' => 'Maghrib', 227 'Dhuhr' => 'Dhuhr', 228 'Isha' => 'Isha' 229 ]; 230 231 $de_language = [ 232 'Salah time for ' => 'Gebetszeiten für ', 233 'Fajr' => 'Morgengebet', 234 'Asr' => 'Nachmittagsgebet', 235 'Sunrise' => 'Sonnenaufgang', 236 'Maghrib' => 'Abendgebet', 237 'Dhuhr' => 'Mittagsgebet', 238 'Isha' => 'Nachtgebet' 239 ]; 240 241 $bs_language = [ 242 'Salah time for ' => 'Vaktija za ', 243 'Fajr' => 'Vaktija za', 244 'Asr' => 'Ikindija', 245 'Sunrise' => 'Izlazak sunca', 246 'Maghrib' => 'Akšam', 247 'Dhuhr' => 'Podne', 248 'Isha' => 'Jacija' 249 ]; 250 177 251 function register_salah_widget() 178 252 {
Note: See TracChangeset
for help on using the changeset viewer.