| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Salat Times |
| 4 |
Plugin URI: https://imran.link/ |
| 5 |
Description: Salat (Namaz) timetable for any location around the world, based on a variety of calculation methods currently used in muslim communities. |
| 6 |
Author: M.A. IMRAN |
| 7 |
Version: 3.7 |
| 8 |
Author URI: https://facebook.com/imran2w |
| 9 |
*/ |
| 10 |
|
| 11 |
/* |
| 12 |
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or ( at your option) any later version. |
| 13 |
|
| 14 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 17 |
Online: http://www.gnu.org/licenses/gpl.txt |
| 18 |
*/ |
| 19 |
|
| 20 |
// Bismillah... |
| 21 |
|
| 22 |
defined( 'ABSPATH' )or die( 'Stop! You can not do this!' ); |
| 23 |
|
| 24 |
include_once( 'PrayTime.php' ); |
| 25 |
|
| 26 |
if ( !class_exists( 'uCal' ) ) { |
| 27 |
include_once( 'uCal.php' ); |
| 28 |
} |
| 29 |
|
| 30 |
function st_en2bn( $str ) { |
| 31 |
$enMonth = array( |
| 32 |
'lm1' => 'January', |
| 33 |
'lm2' => 'February', |
| 34 |
'lm3' => 'March', |
| 35 |
'lm4' => 'April', |
| 36 |
'lm5' => 'May', |
| 37 |
'lm6' => 'June', |
| 38 |
'lm7' => 'July', |
| 39 |
'lm8' => 'August', |
| 40 |
'lm9' => 'September', |
| 41 |
'lm10' => 'October', |
| 42 |
'lm11' => 'November', |
| 43 |
'lm12' => 'December', |
| 44 |
|
| 45 |
'hm1' => 'Muharram', |
| 46 |
'hm2' => 'Safar', |
| 47 |
'hm3' => 'Rabi-Al-Awaal', |
| 48 |
'hm4' => 'Rabi-Al-Thani', |
| 49 |
'hm5' => 'Jumada-Al-Awaal', |
| 50 |
'hm6' => 'Jumada-Al-Thani', |
| 51 |
'hm7' => 'Rajab', |
| 52 |
'hm8' => 'Shaaban', |
| 53 |
'hm9' => 'Ramadan', |
| 54 |
'hm10' => 'Shawwal', |
| 55 |
'hm11' => 'Dhu al-Qidah', |
| 56 |
'hm12' => 'Dhu al-Hijjah' |
| 57 |
); |
| 58 |
$enWeeks = array( |
| 59 |
'ld1' => 'Saturday', |
| 60 |
'ld2' => 'Sunday', |
| 61 |
'ld3' => 'Monday', |
| 62 |
'ld4' => 'Tuesday', |
| 63 |
'ld5' => 'Wednesday', |
| 64 |
'ld6' => 'Thursday', |
| 65 |
'ld7' => 'Friday' |
| 66 |
); |
| 67 |
$bnMonth = array( |
| 68 |
'lm1' => 'জানুয়ারি', |
| 69 |
'lm2' => 'ফেব্রুয়ারি', |
| 70 |
'lm3' => 'মার্চ', |
| 71 |
'lm4' => 'এপ্রিল', |
| 72 |
'lm5' => 'মে', |
| 73 |
'lm6' => 'জুন', |
| 74 |
'lm7' => 'জুলাই', |
| 75 |
'lm8' => 'আগস্ট', |
| 76 |
'lm9' => 'সেপ্টেম্বর', |
| 77 |
'lm10' => '� |
| 78 |
ক্টোবর', |
| 79 |
'lm11' => 'নভেম্বর', |
| 80 |
'lm12' => 'ডিসেম্বর', |
| 81 |
|
| 82 |
'hm1' => 'মুহাররম', |
| 83 |
'hm2' => 'সফর', |
| 84 |
'hm3' => 'রবিউল-আউয়াল', |
| 85 |
'hm4' => 'রবিউস-সানি', |
| 86 |
'hm5' => 'জমাদিউল-আউয়াল', |
| 87 |
'hm6' => 'জমাদিউস-সানি', |
| 88 |
'hm7' => 'রজব', |
| 89 |
'hm8' => 'শাবান', |
| 90 |
'hm9' => 'রামাযান', |
| 91 |
'hm10' => 'শাওয়াল', |
| 92 |
'hm11' => 'জিলক্বদ', |
| 93 |
'hm12' => 'জিলহজ্জ' |
| 94 |
); |
| 95 |
$bnWeeks = array( |
| 96 |
'ld1' => 'শনিবার', |
| 97 |
'ld2' => 'রবিবার', |
| 98 |
'ld3' => 'সোমবার', |
| 99 |
'ld4' => 'মঙ্গলবার', |
| 100 |
'ld5' => 'বুধবার', |
| 101 |
'ld6' => 'বৃহস্পতিবার', |
| 102 |
'ld7' => 'শুক্রবার' |
| 103 |
); |
| 104 |
|
| 105 |
$mergeA1 = array_merge( $enMonth, $enWeeks ); |
| 106 |
$mergeA2 = array_merge( $bnMonth, $bnWeeks ); |
| 107 |
|
| 108 |
array_push( $mergeA1, 'AM', 'PM', 'st', 'th', 'nd', 'rd', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ); |
| 109 |
array_push( $mergeA2, '', '', '', '', '', '', '০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯' ); |
| 110 |
|
| 111 |
return str_ireplace( $mergeA1, $mergeA2, $str ); |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
function daily_salat_times() { |
| 116 |
|
| 117 |
$defaults = array( |
| 118 |
'lat_long_tz' => '23.7 90.4 6', |
| 119 |
'lat' => '23.7', |
| 120 |
'long' => '90.4', |
| 121 |
'custom_loc' => '0', |
| 122 |
'calc_method' => '1', |
| 123 |
'asr_method' => '0', |
| 124 |
'highlats' => '0', |
| 125 |
'time_format' => '1', |
| 126 |
'time_zone' => '6', |
| 127 |
'daylight' => '0', |
| 128 |
'wgt_title1' => 'Salat Times', |
| 129 |
'location' => 'Dhaka, Bangladesh', |
| 130 |
'show_date' => '1', |
| 131 |
'show_hdate' => '0', |
| 132 |
'hijri_adjust' => '-0', |
| 133 |
'dir' => 'inherit', |
| 134 |
'width' => '100%', |
| 135 |
'halign' => 'center', |
| 136 |
'talign' => 'center', |
| 137 |
'walign' => 'left', |
| 138 |
'scheme' => '#4189dd #ffffff #4472C4 #ffffff #B4C6E7 #D9E2F3 #000000', |
| 139 |
'custom' => 'Salat-Time-Fajr-Sunrise-Zuhr-Asr-Magrib-Isha-Begins-Jamah', |
| 140 |
'lang' => 'en', |
| 141 |
'timetable' => '0' |
| 142 |
); |
| 143 |
|
| 144 |
$st_options = get_option( "st_options" ); |
| 145 |
if ( !is_array( $st_options ) ) { |
| 146 |
$st_options = $defaults; |
| 147 |
} else { |
| 148 |
foreach ( $defaults as $key => $value ) { |
| 149 |
if ( !array_key_exists( $key, $st_options ) ) { |
| 150 |
$st_options[ $key ] = $value; |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
$d = new uCal; |
| 156 |
$hoffset = esc_html($st_options[ 'hijri_adjust' ]) * 60 * 60; |
| 157 |
|
| 158 |
$stdate = ''; |
| 159 |
$sthdate = ''; |
| 160 |
|
| 161 |
if ( $st_options[ 'lang' ] == 'bn' ) { |
| 162 |
if ( $st_options[ 'show_date' ] == '1' ) { |
| 163 |
$stdate = '<br/>' . st_en2bn( wp_date( "l, jS F, Y") ); |
| 164 |
} |
| 165 |
if ( $st_options[ 'show_hdate' ] == '1' ) { |
| 166 |
$sthdate = '<br/>' . st_en2bn( $d->date( "jS F, Y", current_time('timestamp') + $hoffset ) ); |
| 167 |
} |
| 168 |
} else { |
| 169 |
if ( $st_options[ 'show_date' ] == '1' ) { |
| 170 |
$stdate = '<br/>'.wp_date( "l, jS F, Y"); |
| 171 |
} |
| 172 |
if ( $st_options[ 'show_hdate' ] == '1' ) { |
| 173 |
$sthdate = '<br/>' . $d->date( "jS F, Y", current_time('timestamp') + $hoffset ); |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
ob_start(); // begin output buffering |
| 178 |
|
| 179 |
if ( !$st_options[ 'timetable' ] == '1' ) { // Automatic Timetable |
| 180 |
|
| 181 |
$latitude = 23.7; |
| 182 |
$longitude = 90.4; |
| 183 |
$time_zone = 6; |
| 184 |
|
| 185 |
$highLatsMethod = '0'; |
| 186 |
if(isset($st_options[ 'highlats' ])) { |
| 187 |
$highLatsMethod = esc_html($st_options['highlats']); |
| 188 |
} |
| 189 |
|
| 190 |
$prayTime = new PrayTime(); |
| 191 |
$prayTime->setCalcMethod( $st_options[ 'calc_method' ] ); |
| 192 |
$prayTime->setAsrMethod( $st_options[ 'asr_method' ] ); |
| 193 |
$prayTime->setTimeFormat( $st_options[ 'time_format' ] ); |
| 194 |
$prayTime->setHighLatsMethod($highLatsMethod); |
| 195 |
|
| 196 |
$location = explode( " ", esc_html($st_options[ 'lat_long_tz' ]) ); |
| 197 |
|
| 198 |
if ( $st_options[ 'custom_loc' ] == '0' ) { |
| 199 |
$latitude = $location[ 0 ]; |
| 200 |
$longitude = $location[ 1 ]; |
| 201 |
$time_zone = $location[ 2 ] + esc_html($st_options[ 'daylight' ]); |
| 202 |
} else { |
| 203 |
$latitude = $st_options[ 'lat' ]; |
| 204 |
$longitude = $st_options[ 'long' ]; |
| 205 |
$time_zone = $st_options[ 'time_zone' ] + esc_html($st_options[ 'daylight' ]); |
| 206 |
} |
| 207 |
|
| 208 |
$color = explode( " ", $st_options[ 'scheme' ] ); |
| 209 |
|
| 210 |
if ( $st_options[ 'lang' ] == "en" ) { |
| 211 |
$cl = explode( "-", "Salat-Time-Fajr-Sunrise-Zuhr-Asr-Magrib-Isha-Begins-Jamah" ); |
| 212 |
} else { |
| 213 |
$cl = explode( "-", esc_html($st_options[ 'custom' ]) ); |
| 214 |
} |
| 215 |
|
| 216 |
if ( $st_options[ 'lang' ] == "bn" ) { |
| 217 |
$times = st_en2bn( $prayTime->getPrayerTimes( time(), $latitude, $longitude, $time_zone ) ); |
| 218 |
print( '<table class="st_table" style="font-family: \'Noto Serif Bengali\'; direction: ' . $st_options[ 'dir' ] . '; width: ' . $st_options[ 'width' ] . ';"> |
| 219 |
<tr><td colspan="2" style="text-align: ' . $st_options[ 'halign' ] . '; background-color: ' . $color[ 0 ] . '; color: ' . $color[ 1 ] . ';">' . $st_options[ 'location' ] . $stdate . $sthdate . '</td></tr> |
| 220 |
<tr style="background-color: ' . $color[ 2 ] . '; color: ' . $color[ 3 ] . ';"><th style="text-align: ' . $st_options[ 'talign' ] . ';">ওয়াক্ত</th><th style="text-align: ' . $st_options[ 'talign' ] . ';">সময়</th></tr> |
| 221 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">সুবহে সাদিক</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">ভোর ' . $times[ 0 ] . '</td></tr>' . ' |
| 222 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">সূর্যোদয়</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">ভোর ' . $times[ 1 ] . '</td></tr> |
| 223 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">যোহর</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">দুপুর ' . $times[ 2 ] . '</td></tr> |
| 224 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">আছর</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">বিকাল ' . $times[ 3 ] . '</td></tr> |
| 225 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">মাগরিব</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">সন্ধ্যা ' . $times[ 5 ] . '</td></tr> |
| 226 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">এশা</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;"> রাত ' . $times[ 6 ] . '</td></tr> |
| 227 |
</table>' ); |
| 228 |
} else { |
| 229 |
$times = $prayTime->getPrayerTimes( time(), $latitude, $longitude, $time_zone ); |
| 230 |
print( '<table class="st_table" style="direction: ' . $st_options[ 'dir' ] . '; width: ' . $st_options[ 'width' ] . ';"> |
| 231 |
<tr><td colspan="2" style="text-align: ' . $st_options[ 'halign' ] . '; background-color: ' . $color[ 0 ] . '; color: ' . $color[ 1 ] . ';">' . $st_options[ 'location' ] . $stdate . $sthdate . '</td></tr> |
| 232 |
<tr style="background-color: ' . $color[ 2 ] . '; color: ' . $color[ 3 ] . ';"><th style="text-align: ' . $st_options[ 'talign' ] . ';">' . $cl[ 0 ] . '</th><th style="text-align: ' . $st_options[ 'talign' ] . ';">' . $cl[ 1 ] . '</th></tr> |
| 233 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 2 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 0 ] . '</td></tr>' . ' |
| 234 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 3 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 1 ] . '</td></tr> |
| 235 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 4 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 2 ] . '</td></tr> |
| 236 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 5 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 3 ] . '</td></tr> |
| 237 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 6 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 5 ] . '</td></tr> |
| 238 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $cl[ 7 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . $times[ 6 ] . '</td></tr> |
| 239 |
</table>' ); |
| 240 |
} |
| 241 |
} else { // Manual Timetable |
| 242 |
|
| 243 |
$time_zone = $st_options[ 'time_zone' ]; |
| 244 |
$offset = $time_zone * 60 * 60; |
| 245 |
|
| 246 |
$dir = WP_CONTENT_DIR . '/plugin_data/salat-times/'; |
| 247 |
$file = $dir . 'manual_time.data'; |
| 248 |
$lines = file( $file ); //file in to an array |
| 249 |
|
| 250 |
$lineN = gmdate( "z", time() + $offset ); |
| 251 |
|
| 252 |
$color = explode( " ", $st_options[ 'scheme' ] ); |
| 253 |
|
| 254 |
if ( $st_options[ 'lang' ] == "en" ) { |
| 255 |
$cl = explode( "-", "Salat-Time-Fajr-Sunrise-Zuhr-Asr-Magrib-Isha-Begins-Jamah" ); |
| 256 |
} else { |
| 257 |
$cl = explode( "-", esc_html($st_options['custom']) ); |
| 258 |
} |
| 259 |
|
| 260 |
if(isset($lines[ $lineN ])) { |
| 261 |
if ( $st_options[ 'lang' ] == "bn" ) { |
| 262 |
$times = explode( "--", st_en2bn( str_ireplace( ['AM', 'PM'], ['', ''], $lines[ $lineN ] ) ) ); |
| 263 |
print( '<table class="st_table" style="font-family: \'Noto Serif Bengali\'; direction: ' . $st_options[ 'dir' ] . '; width: ' . $st_options[ 'width' ] . ';"> |
| 264 |
<tr><td colspan="3" style="text-align: ' . $st_options[ 'halign' ] . '; background-color: ' . $color[ 0 ] . '; color: ' . $color[ 1 ] . ';">' . $st_options[ 'location' ] . $stdate . $sthdate . '</td></tr> |
| 265 |
|
| 266 |
<tr style="background-color: ' . $color[ 2 ] . '; color: ' . $color[ 3 ] . ';"><td style="text-align: ' . $st_options[ 'talign' ] . ';">ওয়াক্ত</td><td style="text-align: ' . $st_options[ 'talign' ] . ';">শুরু</td><td style="text-align: ' . $st_options[ 'talign' ] . ';">জামা’আত</td></tr> |
| 267 |
|
| 268 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">ফযর</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 1 ]) . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 6 ]) . '</td></tr>' . ' |
| 269 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">সূর্যোদয়</td><td colspan="2" style="text-align: center;">' . trim($times[ 11 ]) . '</td></tr> |
| 270 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">যোহর</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 2 ]) . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 7 ]) . '</td></tr> |
| 271 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">আছর</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 3 ]) . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 8 ]) . '</td></tr> |
| 272 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">মাগরিব</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 4 ]) . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 9 ]) . '</td></tr> |
| 273 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . ';">এশা</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 5 ]) . '</td><td style="text-align: ' . $st_options[ 'walign' ] . ';">' . trim($times[ 10 ]) . '</td></tr> |
| 274 |
</table>' ); |
| 275 |
} else { |
| 276 |
$times = explode( "--", $lines[ $lineN ] ); |
| 277 |
print( '<table class="st_table" style="direction: ' . $st_options[ 'dir' ] . '; width: ' . $st_options[ 'width' ] . ';"> |
| 278 |
<tr><td colspan="3" style="text-align: ' . $st_options[ 'halign' ] . '; background-color: ' . $color[ 0 ] . '; color: ' . $color[ 1 ] . ';">' . $st_options[ 'location' ] . $stdate . $sthdate . '</td></tr> |
| 279 |
|
| 280 |
<tr style="background-color: ' . $color[ 2 ] . '; color: ' . $color[ 3 ] . ';"><th style="text-align: ' . $st_options[ 'talign' ] . ';">' . $cl[ 0 ] . '</th><th style="text-align: ' . $st_options[ 'talign' ] . ';">' . $cl[ 8 ] . '</th><th style="text-align: ' . $st_options[ 'talign' ] . ';">' . $cl[ 9 ] . '</th></tr> |
| 281 |
|
| 282 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 2 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 1 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 6 ] . '</td></tr>' . ' |
| 283 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 3 ] . '</td><td colspan="2" style="text-align: center; padding-left: 10px;">' . $times[ 11 ] . '</td></tr> |
| 284 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 4 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 2 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 7 ] . '</td></tr> |
| 285 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 5 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 3 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 8 ] . '</td></tr> |
| 286 |
<tr style="background-color: ' . $color[ 4 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 6 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 4 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 9 ] . '</td></tr> |
| 287 |
<tr style="background-color: ' . $color[ 5 ] . '; color: ' . $color[ 6 ] . ';"><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $cl[ 7 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 5 ] . '</td><td style="text-align: ' . $st_options[ 'walign' ] . '; padding-left: 10px;">' . $times[ 10 ] . '</td></tr> |
| 288 |
</table>' ); |
| 289 |
} |
| 290 |
} else { |
| 291 |
echo '<p style="color: red;">No timetable found for today! Please fill in the full year time for this date in the manual timetable file.</p>'; |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
$output = ob_get_contents(); // end output buffering |
| 296 |
ob_end_clean(); // grab the buffer contents and empty the buffer |
| 297 |
return $output; |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
function widget_daily_salat( $args ) { |
| 302 |
extract( $args ); |
| 303 |
$st_options = get_option( "st_options" ); |
| 304 |
if ( !is_array( $st_options ) ) { |
| 305 |
$st_options = array( 'wgt_title1' => 'Salat Times' ); |
| 306 |
} |
| 307 |
echo $before_widget; |
| 308 |
echo $before_title . esc_html($st_options[ 'wgt_title1' ]) . $after_title; |
| 309 |
?> |
| 310 |
<ul> |
| 311 |
<?php echo daily_salat_times(); ?> |
| 312 |
</ul> |
| 313 |
<?php |
| 314 |
echo $after_widget; |
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
function widget_daily_salat_control() { |
| 319 |
$st_options = get_option( "st_options" ); |
| 320 |
if ( !is_array( $st_options ) ) { |
| 321 |
$st_options = array( |
| 322 |
'wgt_title1' => 'Salat Times', |
| 323 |
'location' => 'Dhaka, Bangladesh' |
| 324 |
); |
| 325 |
} |
| 326 |
?> |
| 327 |
|
| 328 |
<p> |
| 329 |
<table width="100%"> |
| 330 |
<tr> |
| 331 |
<td>Widget Title:</td> |
| 332 |
<td> |
| 333 |
<span style="color: green;"> |
| 334 |
<?php echo esc_html($st_options['wgt_title1']); ?> |
| 335 |
</span> |
| 336 |
</td> |
| 337 |
</tr> |
| 338 |
<tr> |
| 339 |
<td>Location Name:</td> |
| 340 |
<td> |
| 341 |
<span style="color: green;"> |
| 342 |
<?php echo esc_html($st_options['location']); ?> |
| 343 |
</span> |
| 344 |
</td> |
| 345 |
</tr> |
| 346 |
</table> |
| 347 |
</p> |
| 348 |
<p><span style="color: gray;">Go to: Settings > <a href="<?php admin_url(); ?>options-general.php?page=salat_times">Salat Times</a> to change options.</span></p> |
| 349 |
<?php |
| 350 |
} |
| 351 |
|
| 352 |
// ========== Action Links ================= |
| 353 |
|
| 354 |
function st_action_links( $links ) { |
| 355 |
$links[] = '<a href="' . get_admin_url( null, 'options-general.php?page=salat_times' ) . '">Settings</a>'; |
| 356 |
return $links; |
| 357 |
} |
| 358 |
|
| 359 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'st_action_links' ); |
| 360 |
|
| 361 |
// ========== Enqueue Styles ================= |
| 362 |
|
| 363 |
function st_enqueue_styles() { |
| 364 |
wp_enqueue_style( 'salat-times-styles', plugins_url( 'styles.css', __FILE__ ), array(), '3.6' ); |
| 365 |
} |
| 366 |
|
| 367 |
add_action( 'wp_enqueue_scripts', 'st_enqueue_styles' ); |
| 368 |
add_action( 'admin_enqueue_scripts', 'st_enqueue_styles' ); |
| 369 |
|
| 370 |
// ===================== |
| 371 |
|
| 372 |
add_shortcode( 'daily_salat_times', 'daily_salat_times' ); |
| 373 |
wp_register_sidebar_widget( 'daily_salat_times', 'Daily Salat Times', 'widget_daily_salat', array( 'description' => __( 'Displays daily salat/namaz timetable for given location.' ) ) ); |
| 374 |
wp_register_widget_control( 'daily_salat_times', 'Daily Salat Times', 'widget_daily_salat_control' ); |
| 375 |
|
| 376 |
if ( is_admin() ) |
| 377 |
include 'salat_times_admin.php'; |
| 378 |
?> |