| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Jock On Air Now |
| 4 |
Plugin URI: https://gandenterprisesinc.com |
| 5 |
Description: JOAN allows you to create, manage and display your station's programming schedule quite easily. After install use the widget to display the current show/Jock on air, display full station schedule by inserting the included shortcode into posts or pages. Create a new page, name it schedule or whatever you like place the schedule shortcode on it, add to your menu to display your full schedule. |
| 6 |
Author: G & D Enterprises, Inc. |
| 7 |
Version: 5.6 |
| 8 |
Author URI: https://www.gandenterprisesinc.com |
| 9 |
|
| 10 |
*/ |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit("Sorry, you are not allowed to access this page directly."); |
| 14 |
} |
| 15 |
|
| 16 |
/* Set constant for plugin directory */ |
| 17 |
define( 'SS3_URL', WP_PLUGIN_URL.'/joan' ); |
| 18 |
|
| 19 |
$joan_db_version = "3.1.1"; |
| 20 |
|
| 21 |
if (!isset($wpdb)) |
| 22 |
$wpdb = $GLOBALS['wpdb']; |
| 23 |
|
| 24 |
$joanTable = $wpdb->prefix . "WPJoan"; |
| 25 |
|
| 26 |
$tz = get_option('timezone_string'); |
| 27 |
date_default_timezone_set($tz); |
| 28 |
|
| 29 |
//Installation |
| 30 |
function joan_install() { |
| 31 |
|
| 32 |
global $wpdb; |
| 33 |
global $joan_db_version; |
| 34 |
global $joanTable; |
| 35 |
|
| 36 |
$joanTable = $wpdb->prefix . "WPJoan"; |
| 37 |
|
| 38 |
if($wpdb->get_var("show tables like '$joanTable'") != $joanTable) { |
| 39 |
|
| 40 |
$sql = "CREATE TABLE " . $joanTable . " ( |
| 41 |
id int(9) NOT NULL AUTO_INCREMENT, |
| 42 |
dayOfTheWeek text NOT NULL, |
| 43 |
startTime int(11) NOT NULL, |
| 44 |
endTime int(11) NOT NULL, |
| 45 |
startClock text not null, |
| 46 |
endClock text not null, |
| 47 |
showName text NOT NULL, |
| 48 |
linkURL text NOT null, |
| 49 |
imageURL text not null, |
| 50 |
UNIQUE KEY id (id) |
| 51 |
);"; |
| 52 |
|
| 53 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 54 |
dbDelta($sql); |
| 55 |
|
| 56 |
add_option("joan_db_version", $joan_db_version); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
register_activation_hook(__FILE__,'joan_install'); |
| 61 |
/* uninstall function */ |
| 62 |
function joan_uninstall(){ |
| 63 |
global $wpdb; |
| 64 |
$joanTable = $wpdb->prefix . "WPJoan"; |
| 65 |
delete_option("joan_db_version"); |
| 66 |
$sql = "DROP TABLE IF EXISTS $joanTable"; |
| 67 |
$wpdb->query($sql); |
| 68 |
} |
| 69 |
register_uninstall_hook( __FILE__, 'joan_uninstall' ); |
| 70 |
//Register and create the Widget |
| 71 |
|
| 72 |
class JoanWidget extends WP_Widget { |
| 73 |
|
| 74 |
/** |
| 75 |
* Declares the JoanWidget class. |
| 76 |
* |
| 77 |
*/ |
| 78 |
function __construct(){ |
| 79 |
$widget_ops = array('classname' => 'joan_widget', 'description' => __( "Display your schedule with style.") ); |
| 80 |
$control_ops = array('width' => 300, 'height' => 300); |
| 81 |
parent::__construct( 'Joan', __( 'Joan', 'joan' ), $widget_ops, $control_ops ); |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Displays the Widget |
| 86 |
* |
| 87 |
*/ |
| 88 |
function widget($args, $instance){ |
| 89 |
|
| 90 |
extract($args); |
| 91 |
$title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title']); |
| 92 |
|
| 93 |
# Before the widget |
| 94 |
echo $before_widget; |
| 95 |
|
| 96 |
# The title |
| 97 |
if ( $title ){ |
| 98 |
echo $before_title . $title . $after_title; |
| 99 |
} |
| 100 |
# Make the Joan widget |
| 101 |
echo showme_joan(); |
| 102 |
|
| 103 |
# After the widget |
| 104 |
echo $after_widget; |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* Saves the widgets settings. |
| 109 |
* |
| 110 |
*/ |
| 111 |
function update($new_instance, $old_instance){ |
| 112 |
$instance = $old_instance; |
| 113 |
$instance['title'] = strip_tags(stripslashes($new_instance['title'])); |
| 114 |
$instance['lineOne'] = strip_tags(stripslashes($new_instance['lineOne'])); |
| 115 |
$instance['lineTwo'] = strip_tags(stripslashes($new_instance['lineTwo'])); |
| 116 |
|
| 117 |
return $instance; |
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Creates the edit form for the widget. |
| 122 |
* |
| 123 |
*/ |
| 124 |
function form($instance){ |
| 125 |
//Defaults |
| 126 |
$instance = wp_parse_args( (array) $instance, array('title'=>'On Air Now') ); |
| 127 |
|
| 128 |
$title = htmlspecialchars($instance['title']); |
| 129 |
|
| 130 |
# Output the options |
| 131 |
echo '<p style="text-align:right;"><label for="' . $this->get_field_name('title') . '">' . __('Title:') . ' <input style="width: 250px;" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" /></label></p>'; |
| 132 |
} |
| 133 |
} //End of widget |
| 134 |
|
| 135 |
|
| 136 |
function JoanInit() { |
| 137 |
register_widget('JoanWidget'); |
| 138 |
} |
| 139 |
add_action('widgets_init', 'JoanInit'); |
| 140 |
|
| 141 |
function joan_default_options(){ |
| 142 |
//==== OPTIONS ==== |
| 143 |
add_option('joan_upcoming', 'yes'); |
| 144 |
add_option('joan_use_images', 'yes'); |
| 145 |
add_option('joan_shutitdown', 'no'); |
| 146 |
add_option('off_air_message', 'We are currently off the air.'); |
| 147 |
add_option('joan_css', ''); |
| 148 |
add_option('joan_shutitdown', 'no'); |
| 149 |
} |
| 150 |
register_activation_hook(__FILE__,'joan_default_options'); |
| 151 |
function elementor_joan_widget(){ |
| 152 |
|
| 153 |
class Elementor_Joan_Widget extends \Elementor\Widget_Base { |
| 154 |
|
| 155 |
/** |
| 156 |
* Get widget name. |
| 157 |
* |
| 158 |
* Retrieve oEmbed widget name. |
| 159 |
* |
| 160 |
* @since 1.0.0 |
| 161 |
* @access public |
| 162 |
* |
| 163 |
* @return string Widget name. |
| 164 |
*/ |
| 165 |
public function get_name() { |
| 166 |
return 'joan'; |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* Get widget title. |
| 171 |
* |
| 172 |
* Retrieve oEmbed widget title. |
| 173 |
* |
| 174 |
* @since 1.0.0 |
| 175 |
* @access public |
| 176 |
* |
| 177 |
* @return string Widget title. |
| 178 |
*/ |
| 179 |
public function get_title() { |
| 180 |
return __( 'Joke On Air Widget', 'joan' ); |
| 181 |
} |
| 182 |
|
| 183 |
/** |
| 184 |
* Get widget icon. |
| 185 |
* |
| 186 |
* Retrieve oEmbed widget icon. |
| 187 |
* |
| 188 |
* @since 1.0.0 |
| 189 |
* @access public |
| 190 |
* |
| 191 |
* @return string Widget icon. |
| 192 |
*/ |
| 193 |
public function get_icon() { |
| 194 |
return 'fa fa-bars'; |
| 195 |
} |
| 196 |
|
| 197 |
/** |
| 198 |
* Get widget categories. |
| 199 |
* |
| 200 |
* Retrieve the list of categories the oEmbed widget belongs to. |
| 201 |
* |
| 202 |
* @since 1.0.0 |
| 203 |
* @access public |
| 204 |
* |
| 205 |
* @return array Widget categories. |
| 206 |
*/ |
| 207 |
public function get_categories() { |
| 208 |
return [ 'general' ]; |
| 209 |
} |
| 210 |
|
| 211 |
/** |
| 212 |
* Register oEmbed widget controls. |
| 213 |
* |
| 214 |
* Adds different input fields to allow the user to change and customize the widget settings. |
| 215 |
* |
| 216 |
* @since 1.0.0 |
| 217 |
* @access protected |
| 218 |
*/ |
| 219 |
protected function _register_controls() { |
| 220 |
|
| 221 |
$this->start_controls_section( |
| 222 |
'content_section', |
| 223 |
[ |
| 224 |
'label' => __( 'Content', 'plugin-name' ), |
| 225 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 226 |
] |
| 227 |
); |
| 228 |
|
| 229 |
$this->add_control( |
| 230 |
'title', |
| 231 |
[ |
| 232 |
'label' => __( 'Title of the widget', 'joan' ), |
| 233 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 234 |
'input_type' => 'text', |
| 235 |
'placeholder' => __( 'On Air Now', 'joan' ), |
| 236 |
] |
| 237 |
); |
| 238 |
$this->add_control( |
| 239 |
'heading', |
| 240 |
[ |
| 241 |
'label' => __( 'Heading', 'plugin-name' ), |
| 242 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 243 |
'options' => [ |
| 244 |
'H1' => __( 'H1', 'plugin-name' ), |
| 245 |
'H2' => __( 'H2', 'plugin-name' ), |
| 246 |
'H3' => __( 'H3', 'plugin-name' ), |
| 247 |
'H4' => __( 'H4', 'plugin-name' ), |
| 248 |
'H5' => __( 'H5', 'plugin-name' ), |
| 249 |
'H6' => __( 'H6', 'plugin-name' ), |
| 250 |
|
| 251 |
], |
| 252 |
'default' => 'H1', |
| 253 |
] |
| 254 |
); |
| 255 |
$this->add_control( |
| 256 |
'text_align', |
| 257 |
[ |
| 258 |
'label' => __( 'Alignment', 'plugin-domain' ), |
| 259 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 260 |
'options' => [ |
| 261 |
'left' => [ |
| 262 |
'title' => __( 'Left', 'plugin-domain' ), |
| 263 |
'icon' => 'fa fa-align-left', |
| 264 |
], |
| 265 |
'center' => [ |
| 266 |
'title' => __( 'Center', 'plugin-domain' ), |
| 267 |
'icon' => 'fa fa-align-center', |
| 268 |
], |
| 269 |
'right' => [ |
| 270 |
'title' => __( 'Right', 'plugin-domain' ), |
| 271 |
'icon' => 'fa fa-align-right', |
| 272 |
], |
| 273 |
], |
| 274 |
'default' => 'center', |
| 275 |
'toggle' => true, |
| 276 |
] |
| 277 |
); |
| 278 |
$this->end_controls_section(); |
| 279 |
|
| 280 |
} |
| 281 |
|
| 282 |
/** |
| 283 |
* Render oEmbed widget output on the frontend. |
| 284 |
* |
| 285 |
* Written in PHP and used to generate the final HTML. |
| 286 |
* |
| 287 |
* @since 1.0.0 |
| 288 |
* @access protected |
| 289 |
*/ |
| 290 |
protected function render() { |
| 291 |
|
| 292 |
$settings = $this->get_settings_for_display(); |
| 293 |
|
| 294 |
$title = htmlspecialchars( $settings['title'] ); |
| 295 |
$heading = $settings['heading']; |
| 296 |
$title = !empty($title) ? $title : 'On Air Now'; |
| 297 |
$startHeading = sprintf("<%s>",$heading); |
| 298 |
$endHeading = sprintf("</%s>",$heading); |
| 299 |
$text_align = $settings['text_align']; |
| 300 |
|
| 301 |
|
| 302 |
# Before the widget |
| 303 |
echo sprintf('<div class="text-%s">',$text_align); |
| 304 |
|
| 305 |
# The title |
| 306 |
|
| 307 |
echo $startHeading. $title . $endHeading; |
| 308 |
# Make the Joan widget |
| 309 |
echo showme_joan(); |
| 310 |
|
| 311 |
# After the widget |
| 312 |
echo '</div>'; |
| 313 |
|
| 314 |
} |
| 315 |
|
| 316 |
} |
| 317 |
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor_Joan_Widget() ); |
| 318 |
} |
| 319 |
|
| 320 |
add_action( 'elementor/widgets/widgets_registered','elementor_joan_widget' ); |
| 321 |
//add_action( 'elementor/frontend/after_enqueue_styles', 'widget_styles' ); |
| 322 |
add_action( 'elementor/frontend/after_register_scripts', 'joan_header_scripts' ); |
| 323 |
|
| 324 |
//==== SHORTCODES ==== |
| 325 |
|
| 326 |
function joan_schedule_handler($atts, $content=null, $code=""){ |
| 327 |
|
| 328 |
if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb']; |
| 329 |
global $wpdb; |
| 330 |
global $joanTable; |
| 331 |
|
| 332 |
//Get the current schedule, divided into days |
| 333 |
$daysOfTheWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); |
| 334 |
|
| 335 |
$schedule = array(); |
| 336 |
|
| 337 |
$output = ''; |
| 338 |
|
| 339 |
foreach ($daysOfTheWeek as $day) { |
| 340 |
if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb']; |
| 341 |
//Add this day's shows HTML to the $output array |
| 342 |
$showsForThisDay = $wpdb->get_results( $wpdb->prepare ( "SELECT * FROM $joanTable WHERE dayOfTheWeek = %s ORDER BY startTime", $day )); |
| 343 |
|
| 344 |
//Check to make sure this day has shows before saving the header |
| 345 |
if ($showsForThisDay){ |
| 346 |
$output .= '<h2>'.$day.'</h2>'; |
| 347 |
$output .= '<ul class="joan-schedule">'; |
| 348 |
foreach ($showsForThisDay as $show){ |
| 349 |
$showName = $show->showName; |
| 350 |
$startClock = $show->startClock; |
| 351 |
$endClock = $show->endClock; |
| 352 |
$linkURL = $show->linkURL; |
| 353 |
$imageURL = $show->imageURL; |
| 354 |
|
| 355 |
if ($linkURL){ |
| 356 |
$showName = '<a href="'.$linkURL.'">'.$showName.'</a>'; |
| 357 |
} |
| 358 |
|
| 359 |
$output .= '<li><strong>'.$startClock.'</strong> - <strong>'.$endClock.'</strong>: '.$showName.'</li>'; |
| 360 |
|
| 361 |
} |
| 362 |
$output .= '</ul>'; |
| 363 |
} |
| 364 |
} |
| 365 |
return $output; |
| 366 |
} |
| 367 |
|
| 368 |
add_shortcode('joan-schedule', 'joan_schedule_handler'); |
| 369 |
|
| 370 |
//Daily schedule |
| 371 |
function joan_schedule_today($atts, $content=null, $code=""){ |
| 372 |
|
| 373 |
global $wpdb; |
| 374 |
global $joanTable; |
| 375 |
|
| 376 |
//Get the current schedule, divided into days |
| 377 |
$daysOfTheWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); |
| 378 |
|
| 379 |
$today = date('l'); |
| 380 |
|
| 381 |
$schedule = array(); |
| 382 |
|
| 383 |
$output = ''; |
| 384 |
|
| 385 |
foreach ($daysOfTheWeek as $day) { |
| 386 |
//Add this day's shows HTML to the $output array |
| 387 |
$showsForThisDay = $wpdb->get_results( $wpdb->prepare ( "SELECT * FROM $joanTable WHERE dayOfTheWeek = %s ORDER BY startTime", $day )); |
| 388 |
|
| 389 |
if ($day == $today) { |
| 390 |
|
| 391 |
//Check to make sure this day has shows before saving the header |
| 392 |
if ($showsForThisDay){ |
| 393 |
$output .= '<h2 class="widget-title">Today - '.$today.'</h2>'; |
| 394 |
$output .= '<ul class="joan-schedule">'; |
| 395 |
foreach ($showsForThisDay as $show){ |
| 396 |
$showName = $show->showName; |
| 397 |
$startClock = $show->startClock; |
| 398 |
$endClock = $show->endClock; |
| 399 |
$linkURL = $show->linkURL; |
| 400 |
if ($linkURL){ |
| 401 |
$showName = '<a href="'.$linkURL.'">'.$showName.'</a>'; |
| 402 |
} |
| 403 |
$output .= '<li><span class="show-time">'.$startClock./*' - '.$endClock.*/':</span> <span class="show-name">'.$showName.'</span></li>'; |
| 404 |
} |
| 405 |
$output .= '</ul>'; |
| 406 |
} |
| 407 |
} |
| 408 |
} |
| 409 |
return $output; |
| 410 |
} |
| 411 |
|
| 412 |
add_shortcode('schedule-today', 'joan_schedule_today'); |
| 413 |
|
| 414 |
//End daily schedule |
| 415 |
|
| 416 |
function showme_joan(){ |
| 417 |
|
| 418 |
$output = '<style>'.get_option('joan_css', '').'</style>'; |
| 419 |
$output .= '<div class="joan-now-playing"></div>'; |
| 420 |
return $output; |
| 421 |
|
| 422 |
} |
| 423 |
|
| 424 |
add_shortcode('joan-now-playing', 'showme_joan'); |
| 425 |
|
| 426 |
function joan_init(){ |
| 427 |
add_action('admin_menu', 'joan_plugin_menu'); |
| 428 |
} |
| 429 |
add_action( 'init', 'joan_init'); |
| 430 |
|
| 431 |
function joan_image_upload_scripts() { |
| 432 |
wp_enqueue_script('media-upload'); |
| 433 |
wp_enqueue_script('thickbox'); |
| 434 |
wp_enqueue_script('my-upload'); |
| 435 |
} |
| 436 |
|
| 437 |
function joan_image_upload_styles() { |
| 438 |
wp_enqueue_style('thickbox'); |
| 439 |
} |
| 440 |
|
| 441 |
if (isset($_GET['page']) && $_GET['page'] == 'joan_settings') { |
| 442 |
add_action('admin_print_scripts', 'joan_image_upload_scripts'); |
| 443 |
add_action('admin_print_styles', 'joan_image_upload_styles'); |
| 444 |
} |
| 445 |
|
| 446 |
//==== ADMIN OPTIONS AND SCHEDULE PAGE ==== |
| 447 |
|
| 448 |
function joan_plugin_menu() { |
| 449 |
global $pagenow; |
| 450 |
// Add a new submenu under Options: |
| 451 |
add_menu_page('JOAN', 'Jock On Air Now', 'activate_plugins', 'joan_settings', 'joan_options_page'); |
| 452 |
|
| 453 |
// Modified by PHP Stack |
| 454 |
if ($pagenow == 'admin.php' && isset($_GET['page'])) { |
| 455 |
if ($_GET['page'] == 'joan_settings') { |
| 456 |
wp_enqueue_style( "joan-admin", plugins_url('admin.css', __FILE__) ); |
| 457 |
wp_enqueue_script( "joan-admin", plugins_url('admin.js', __FILE__), array('jquery'), '1.0.0', true ); |
| 458 |
} |
| 459 |
} |
| 460 |
} |
| 461 |
|
| 462 |
function joan_options_page(){ |
| 463 |
if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb']; |
| 464 |
global $wpdb; |
| 465 |
global $joanTable; |
| 466 |
//Check to see if the user is upgrading from an old Joan database |
| 467 |
|
| 468 |
if (isset($_POST['upgrade-database'])){ |
| 469 |
if (check_admin_referer('upgrade_joan_database', 'upgrade_joan_database_field')){ |
| 470 |
|
| 471 |
if ($wpdb->get_var("show tables like '$joanTable'") != $joanTable){ |
| 472 |
$sql = "CREATE TABLE " . $joanTable . " ( |
| 473 |
id int(9) NOT NULL AUTO_INCREMENT, |
| 474 |
dayOfTheWeek text NOT NULL, |
| 475 |
startTime int(11) NOT NULL, |
| 476 |
endTime int(11) NOT NULL, |
| 477 |
startClock text not null, |
| 478 |
endClock text not null, |
| 479 |
showName text NOT NULL, |
| 480 |
linkURL text NOT null, |
| 481 |
imageURL text not null, |
| 482 |
UNIQUE KEY id (id) |
| 483 |
);"; |
| 484 |
|
| 485 |
$wpdb->query($sql); |
| 486 |
} |
| 487 |
|
| 488 |
$joanOldTable = $wpdb->prefix.'joan'; |
| 489 |
|
| 490 |
$oldJoanShows = $wpdb->get_results($wpdb->prepare("SELECT id, showstart, showend, showname, linkUrl, imageUrl FROM $joanOldTable WHERE id != %d", -1)); |
| 491 |
if ($oldJoanShows){ |
| 492 |
foreach ($oldJoanShows as $show){ |
| 493 |
$showname = $show->showname; |
| 494 |
$startTime = $show->showstart; |
| 495 |
$endTime = $show->showend; |
| 496 |
$startDay = date('l', $startTime); |
| 497 |
$startClock = date('g:i a', ($startTime)); |
| 498 |
$endClock = date('g:i a', ($endTime)); |
| 499 |
$linkURL = $show->linkUrl; |
| 500 |
if ($linkURL == 'No link specified.'){ |
| 501 |
$linkURL = ''; |
| 502 |
} |
| 503 |
$imageURL = $show->imageUrl; |
| 504 |
|
| 505 |
//Insert the new show into the New Joan Databse |
| 506 |
$wpdb->query( $wpdb->prepare("INSERT INTO $joanTable (dayOfTheWeek, startTime,endTime,startClock, endClock, showName, imageURL, linkURL) VALUES (%s, %d, %d , %s, %s, %s, %s, %s)", $startDay, $startTime, $endTime, $startClock, $endClock, $showname, $imageURL, $linkURL ) ); |
| 507 |
} |
| 508 |
} |
| 509 |
} |
| 510 |
//Remove the old Joan table if the new table has been created |
| 511 |
if($wpdb->get_var("show tables like '$joanTable'") == $joanTable) { |
| 512 |
$wpdb->query("DROP TABLE $joanOldTable"); |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
// echo '<script type="text/javascript" src="'.SS3_URL.'/admin.js" ></script>'; |
| 517 |
|
| 518 |
?> |
| 519 |
<div class="wrap"> |
| 520 |
<div class="joan-message-window">Message goes here.</div> |
| 521 |
<h1>Jock On Air Now</h1> |
| 522 |
<p><em>Let your listeners know when their favorite jock/show is on.</em><br /><small>by <a href='http://www.gandenterprisesinc.com' target='_blank'>G & D Enterprises, Inc.</a></small></p> |
| 523 |
|
| 524 |
<style> |
| 525 |
.pcb { |
| 526 |
width:100%; |
| 527 |
height:423px; |
| 528 |
border:none; |
| 529 |
border-collapse:collapse; |
| 530 |
padding:0px; |
| 531 |
} |
| 532 |
.pcb th { |
| 533 |
align:top; |
| 534 |
border:none; |
| 535 |
padding:0px; |
| 536 |
} |
| 537 |
.pcb td { |
| 538 |
align:top; |
| 539 |
border:none; |
| 540 |
padding:0px; |
| 541 |
} |
| 542 |
</style> |
| 543 |
<table class="pcb"> |
| 544 |
<tbody> |
| 545 |
<tr> |
| 546 |
<td align="top" width="100%"><a href="https://myradiohut.com" target="_blank"><img src="https://apps.myradiohut.com/web/images/joan_lite/rhut-banner1.png"></a> |
| 547 |
<td align="top" width="423"><p><a href="https://vouscast.com" target="_blank"><img src="https://apps.myradiohut.com/web/images/joan_lite/vouscast_banner2.png"></a></p></td> |
| 548 |
</tr> |
| 549 |
</tbody> |
| 550 |
</table> |
| 551 |
|
| 552 |
|
| 553 |
<?php |
| 554 |
//Check to see if Joan 2.0 is installed |
| 555 |
$table_name = $wpdb->prefix . "joan"; |
| 556 |
if($wpdb->get_var("show tables like '$table_name'") == $table_name) { |
| 557 |
?> |
| 558 |
<div class="error"> |
| 559 |
<form method="post" action=""> |
| 560 |
<p><strong>Previous version of Joan detected.</strong> Be sure to backup your database before performing this upgrade. <input type="submit" class="button-primary" value="Upgrade my Joan Database" /></p> |
| 561 |
<input type="hidden" name="upgrade-database" value=' ' /> |
| 562 |
<?php wp_nonce_field('upgrade_joan_database', 'upgrade_joan_database_field'); ?> |
| 563 |
</form> |
| 564 |
</div> |
| 565 |
<?php |
| 566 |
} |
| 567 |
|
| 568 |
?> |
| 569 |
|
| 570 |
<input type="hidden" class="script-src" readonly="readonly" value="<?= $_SERVER['PHP_SELF']; ?>?page=joan_settings" /> |
| 571 |
<?php wp_nonce_field('delete_joan_entry', 'delete_entries_nonce_field'); ?> |
| 572 |
|
| 573 |
<ul class="tab-navigation"> |
| 574 |
<li class="joan-scheudle"><img src="https://apps.myradiohut.com/web/images/joan_lite/button_schedule.png"></li> |
| 575 |
<li class="joan-options"><img src="https://apps.myradiohut.com/web/images/joan_lite/button_options.png"></li> |
| 576 |
<li class="shut-it-down"><img src="https://apps.myradiohut.com/web/images/joan_lite/button_on-off.png"></li> |
| 577 |
<li class="joan-pre"><img src="https://apps.myradiohut.com/web/images/joan_lite/button_get-premium.png"></li> |
| 578 |
</ul> |
| 579 |
|
| 580 |
<div class="joan-tabs"> |
| 581 |
|
| 582 |
<div class="tab-container" id="joan-schedule"> |
| 583 |
|
| 584 |
<hr> |
| 585 |
|
| 586 |
<h2>Schedule: Add New Shows To Schedule or Edit Existing Show Schedule</h2> |
| 587 |
|
| 588 |
|
| 589 |
<div class="add-new-entry"> |
| 590 |
|
| 591 |
<form id="add-joan-entry" method="post" action="<?php echo get_admin_url()?>admin-ajax.php"> |
| 592 |
<input type='hidden' name='action' value='show-time-curd' /> |
| 593 |
<div class="set-joan-show-deets"> |
| 594 |
<div class="show-time-container"> |
| 595 |
<h3>Show Start</h3> |
| 596 |
<label for="start"> |
| 597 |
<select class="startDay" name="sday"> |
| 598 |
<option value="Sunday">Sunday</option> |
| 599 |
<option value="Monday">Monday</option> |
| 600 |
<option value="Tuesday">Tuesday</option> |
| 601 |
<option value="Wednesday">Wednesday</option> |
| 602 |
<option value="Thursday">Thursday</option> |
| 603 |
<option value="Friday">Friday</option> |
| 604 |
<option value="Saturday">Saturday</option> |
| 605 |
</select> |
| 606 |
</label> |
| 607 |
|
| 608 |
<label for="starttime"> |
| 609 |
<input id="starttime" class="text" name="startTime" size="5" maxlength="5" type="text" value="00:00" /></label> |
| 610 |
</div> |
| 611 |
|
| 612 |
<div class="show-time-container"> |
| 613 |
<h3>Show End</h3> |
| 614 |
<label for="endday"> |
| 615 |
<select class="endDay" name="eday"> |
| 616 |
<option value="Sunday">Sunday</option> |
| 617 |
<option value="Monday">Monday</option> |
| 618 |
<option value="Tuesday">Tuesday</option> |
| 619 |
<option value="Wednesday">Wednesday</option> |
| 620 |
<option value="Thursday">Thursday</option> |
| 621 |
<option value="Friday">Friday</option> |
| 622 |
<option value="Saturday">Saturday</option> |
| 623 |
</select> |
| 624 |
</label> |
| 625 |
|
| 626 |
<label for="endtime"> |
| 627 |
<input id="endtime" class="text" name="endTime" size="5" maxlength="5" type="text" value="00:00" /></label> |
| 628 |
</div> |
| 629 |
<div class="clr"></div> |
| 630 |
<p><strong>Set WP clock to 24 hour time format (01:00 = 1 AM, 13:00 = 1 PM)</strong></p> |
| 631 |
<p>Important, set your <a href="/wp-admin/options-general.php">timezone <strong>to a city</strong></a> which matches your local time.(Do NOT Use UTC)<br/> |
| 632 |
<small><em>Current timezone: <?php if (get_option('timezone_string') == '') { echo '<strong style="color:red;">Set your <a href="options-general.php">timezone</a> city now.</strong></em></small></p>'; } else { echo get_option('timezone_string'); ?></em></small></p> |
| 633 |
|
| 634 |
</div> |
| 635 |
|
| 636 |
<div class="set-joan-show-deets"> |
| 637 |
<label for="showname"><h3>Show Details</h3></label> |
| 638 |
<p>Name: <br/> |
| 639 |
<input id="showname" type="text" name="showname" class="show-detail" /> |
| 640 |
</p> |
| 641 |
|
| 642 |
<p>Link URL (optional):<br /> |
| 643 |
<label for="linkUrl"> |
| 644 |
|
| 645 |
<input type="text" name="linkUrl" placeholder="No URL specified." class="show-detail" /> |
| 646 |
|
| 647 |
</p> |
| 648 |
|
| 649 |
<p id="primary-image"></p> |
| 650 |
<p><input class="image-url" type="hidden" name="imageUrl" data-target-field-name="new show" value=""/></p> |
| 651 |
<p><input type="button" class="upload-image button" data-target-field="new show" value="Upload Image" /></p> |
| 652 |
<img src="" style="display:none;" data-target-field-name="new show" /> |
| 653 |
<p><a id="remove-primary-image" href="#"><small>Remove Image</small></a></p> |
| 654 |
|
| 655 |
|
| 656 |
<input type="submit" class="button-primary" style="cursor: pointer;" value="Add Show" /> |
| 657 |
<input type="hidden" name="crud-action" value="create" /> |
| 658 |
<?php wp_nonce_field('add_joan_entry', 'joan_nonce_field'); ?> |
| 659 |
|
| 660 |
<?php } ?> |
| 661 |
|
| 662 |
</div> |
| 663 |
</form> |
| 664 |
|
| 665 |
|
| 666 |
<div class="clr"></div> |
| 667 |
|
| 668 |
</div> |
| 669 |
|
| 670 |
<h3>Current Schedule</h3> |
| 671 |
|
| 672 |
<p>Edit Schedule: <a href="#" class="display-toggle full-display">Expand</a> | <a href="#" class="display-toggle simple-display">Retract</a></p> |
| 673 |
|
| 674 |
<form method="post" action="<?php echo get_admin_url()?>admin-ajax.php" class="joan-update-shows"> |
| 675 |
<input type='hidden' name='action' value='show-time-curd' /> |
| 676 |
<div class="joan-schedule loading"> |
| 677 |
<div class="sunday-container"><h2>Sunday</h2></div><!-- end this day of the week --> |
| 678 |
<div class="monday-container"><h2>Monday</h2></div><!-- end this day of the week --> |
| 679 |
<div class="tuesday-container"><h2>Tuesday</h2></div><!-- end this day of the week --> |
| 680 |
<div class="wednesday-container"><h2>Wednesday</h2></div><!-- end this day of the week --> |
| 681 |
<div class="thursday-container"><h2>Thursday</h2></div><!-- end this day of the week --> |
| 682 |
<div class="friday-container"><h2>Friday</h2></div><!-- end this day of the week --> |
| 683 |
<div class="saturday-container"><h2>Saturday</h2></div><!-- end this day of the week --> |
| 684 |
</div> |
| 685 |
<input type="hidden" name="crud-action" value="update" /> |
| 686 |
<?php wp_nonce_field('save_joan_entries', 'joan_entries_nonce_field'); ?> |
| 687 |
|
| 688 |
</form> |
| 689 |
|
| 690 |
<p>Edit Schedule: <a href="#" class="display-toggle full-display">Expand</a> | <a href="#" class="display-toggle simple-display">Retract</a></p> |
| 691 |
|
| 692 |
|
| 693 |
</div> |
| 694 |
|
| 695 |
<div class="tab-container" id="joan-options"> |
| 696 |
<form method="post" action=""> |
| 697 |
|
| 698 |
<hr> |
| 699 |
|
| 700 |
<h2>Select Options Below</h2> |
| 701 |
|
| 702 |
<?php |
| 703 |
|
| 704 |
//Save posted options |
| 705 |
|
| 706 |
if (isset($_POST['joan_options'])){ |
| 707 |
|
| 708 |
update_option('joan_upcoming', $_POST['joan_options']['showUpcoming']); |
| 709 |
update_option('joan_use_images', $_POST['joan_options']['imagesOn']); |
| 710 |
update_option('off_air_message', htmlentities(stripslashes($_POST['joan_options']['offAirMessage']))); |
| 711 |
update_option('joan_css', htmlentities(stripslashes($_POST['joan_options']['joanCSS']))); |
| 712 |
|
| 713 |
} |
| 714 |
if (isset($_POST['shut-it-down'])) { |
| 715 |
|
| 716 |
update_option('joan_shutitdown', $_POST['shut-it-down']); |
| 717 |
} |
| 718 |
|
| 719 |
//Set options variables |
| 720 |
$showUpcoming = get_option('joan_upcoming'); |
| 721 |
$imagesOn = get_option('joan_use_images'); |
| 722 |
$shutItDown = get_option('joan_shutitdown'); |
| 723 |
$offAirMessage = get_option('off_air_message'); |
| 724 |
$joanCSS = get_option('joan_css'); |
| 725 |
//$shutItDown = get_option('joan_shutitdown'); |
| 726 |
|
| 727 |
?> |
| 728 |
|
| 729 |
<h3>Display Images</h3> |
| 730 |
<form id="option" method="post" action=""> |
| 731 |
<p>Show accompanying images with joans?</p> |
| 732 |
<label><input type="radio"<?php if($imagesOn == 'yes') { ?> checked="checked"<?php } ?> name="joan_options[imagesOn]" value="yes" /> : Yes</label><br/> |
| 733 |
<label><input type="radio"<?php if($imagesOn == 'no') { ?> checked="checked"<?php } ?> name="joan_options[imagesOn]" value="no" /> : No</label><br/> |
| 734 |
|
| 735 |
|
| 736 |
<h3>Upcoming Timeslot</h3> |
| 737 |
|
| 738 |
<p>Show the name/time of the next timeslot?</p> |
| 739 |
<label><input type="radio"<?php if($showUpcoming == 'yes') { ?> checked="checked"<?php } ?> name="joan_options[showUpcoming]" value="yes" /> : Yes</label><br/> |
| 740 |
<label><input type="radio"<?php if($showUpcoming == 'no') { ?> checked="checked"<?php } ?> name="joan_options[showUpcoming]" value="no" /> : No</label><br/> |
| 741 |
|
| 742 |
|
| 743 |
<h3>Custom Message</h3> |
| 744 |
<label>Message:<br /><input type="text" id="off-air-message" value="<?= $offAirMessage; ?>" name="joan_options[offAirMessage]" size="40" /></label> |
| 745 |
|
| 746 |
|
| 747 |
<p class="submit"> |
| 748 |
<input type="submit" class="button-primary" value="Save Changes" /> |
| 749 |
</p> |
| 750 |
|
| 751 |
<h2>Display Shortcodes</h2> |
| 752 |
|
| 753 |
<h3>[joan-schedule]</h3> |
| 754 |
<p>Display a list of the times and names of your events, broken down weekly, example:</p> |
| 755 |
<div style="margin-left:30px;"> |
| 756 |
<h4>Mondays</h4> |
| 757 |
<ul> |
| 758 |
<li><strong>5:00 am - 10:00 am</strong> - Morning Ride</li> |
| 759 |
<li><strong>10:00 am - 12:00 pm</strong> - The Vibe with MarkD</li> |
| 760 |
</ul> |
| 761 |
<h4>Saturdays</h4> |
| 762 |
<ul> |
| 763 |
<li><strong>10:00 am - 1:00 am</strong> - Drive Time</li> |
| 764 |
<li><strong>1:00 pm - 4:00 pm</strong> - Kool Jamz</li> |
| 765 |
</ul> |
| 766 |
</div> |
| 767 |
<h3>[joan-now-playing]</h3> |
| 768 |
<p>Display the Current Show/jock widget.</p> |
| 769 |
<h3>[schedule-today]</h3> |
| 770 |
<p>Automatically display your schedule for each day of the week.</p> |
| 771 |
|
| 772 |
<div class="clr"></div> |
| 773 |
|
| 774 |
|
| 775 |
</div> |
| 776 |
|
| 777 |
<div class="tab-container" id="joan-shut-it-down"> |
| 778 |
|
| 779 |
<hr> |
| 780 |
|
| 781 |
<h2>Suspend schedule</h2> |
| 782 |
|
| 783 |
<form method="post" action=""> |
| 784 |
<p>You can temporarily take down your schedule for any reason, during schedule updates, public holidays or station off-air periods etc.</p> |
| 785 |
<label><input type="radio"<?php checked($shutItDown,'yes',true); ?> name="shut-it-down" value="yes" /> : Schedule Off</label><br/> |
| 786 |
<label><input type="radio"<?php checked($shutItDown,'no',true); ?> name="shut-it-down" value="no" /> : Schedule On (Default)</label><br/> |
| 787 |
|
| 788 |
<p class="submit"> |
| 789 |
<input type="submit" class="button-primary" value="Save changes" /> |
| 790 |
</p> |
| 791 |
</form> |
| 792 |
|
| 793 |
|
| 794 |
</div> |
| 795 |
<div class="tab-container" id="joan-pre"> |
| 796 |
|
| 797 |
<style> |
| 798 |
.pca { |
| 799 |
width:100%; |
| 800 |
height:423px; |
| 801 |
border:none; |
| 802 |
border-collapse:collapse; |
| 803 |
padding:0px; |
| 804 |
} |
| 805 |
.pca th { |
| 806 |
align:top; |
| 807 |
border:none; |
| 808 |
padding:0px; |
| 809 |
} |
| 810 |
.pca td { |
| 811 |
align:top; |
| 812 |
border:none; |
| 813 |
padding:0px; |
| 814 |
} |
| 815 |
</style> |
| 816 |
<table class="pca"> |
| 817 |
<tbody> |
| 818 |
<tr> |
| 819 |
<p></p><td align="top" width="100%"><h2>Introducing JOAN Premium, follow the link below to get started with JOAN Premium.</h2> |
| 820 |
<h1>Get Joan Premium</h1> |
| 821 |
<p>*Priority Support</p> |
| 822 |
<p>*Autmatically updates JOAN database (Your data is not altered in anyway)</p> |
| 823 |
<p>*Schedule Import/Export</p> |
| 824 |
<p>*Added option to display public schedule in 24h-military time</p> |
| 825 |
<p>*Localization Ready</p> |
| 826 |
<p>*Multi-site support</p> |
| 827 |
<p>*Easily "duplicate" show schedules (Recurring shows)</p> |
| 828 |
<p>*update show status</p> |
| 829 |
<p>*Hide current or next show/jock</p> |
| 830 |
<p>*Edit existing show time</p> |
| 831 |
<p>*Open show URLs in a new tab</p> |
| 832 |
<p><a href="https://gandenterprisesinc.com/pricing/" target="_blank"><h2>GET JOAN PREMIUM</h2></a></p> |
| 833 |
<p><img src="https://caribbeanbusinesslinkup.com/samples/featured_img.jpg"></p></td> |
| 834 |
<td align="top" width="423"><p><a href="https://musidek.com" target="_blank"><img src="https://caribbeanbusinesslinkup.com/samples/Mp3MF_logp.png"></a></p></td> |
| 835 |
</tr> |
| 836 |
</tbody> |
| 837 |
</table> |
| 838 |
|
| 839 |
</div> |
| 840 |
|
| 841 |
</div><!-- end the joan tabs --> |
| 842 |
|
| 843 |
</div> |
| 844 |
|
| 845 |
<?php |
| 846 |
|
| 847 |
} |
| 848 |
|
| 849 |
function joan_header_scripts(){ |
| 850 |
|
| 851 |
|
| 852 |
echo '<script>crudScriptURL = "'.get_admin_url().'admin-ajax.php"</script>'; |
| 853 |
wp_enqueue_script( "joan-front", plugins_url('joan.js', __FILE__), array(), '1.0.0', true ); |
| 854 |
} |
| 855 |
|
| 856 |
add_action("wp_head","joan_header_scripts"); |
| 857 |
|
| 858 |
|
| 859 |
function _handle_form_action(){ |
| 860 |
|
| 861 |
include( plugin_dir_path( __FILE__ ) . 'crud.php' ); |
| 862 |
|
| 863 |
die(); // this is required to return a proper result |
| 864 |
} |
| 865 |
add_action('wp_ajax_show-time-curd', '_handle_form_action'); |
| 866 |
add_action('wp_ajax_nopriv_show-time-curd', '_handle_form_action'); |