function announcer($id) { static $note = array(); $options = get_option('announcer_data'); $id = intval($id); if ($id <= 0) { return; } $opts = $options[$id]; if (!isset($opts) || empty($opts)) { return; } $loc = ancr_location_check($opts['location']); $date = ancr_date_check($opts); $pos = $opts['position']; $filter = current_filter(); $posflag = 0; if ($pos == 'above-content' && $filter == 'loop_start' && is_main_query()) { $posflag = 1; } elseif ($pos != 'above-content' && $pos != 'manual' && $filter == 'wp_footer') { $posflag = 1; } elseif ($filter == '') { $posflag = 1; } if (isset($note[$id]) && $note[$id] == 1) { $added = 1; } else { $added = 0; } if ($opts['status'] == 'yes' && $loc && $added == 0 && $posflag && $date) { // close button if ($opts['closebt'] == 'yes') { $closebt = "\n" . '<span class="announcer-closebt">x</span>' . "\n"; } else { $closebt = ''; } // box style if ($opts['style'] == 'custom') { $class = $opts['customclass']; } else { $class = 'announcer-' . $opts['style']; $brclr = $opts['borderclr'] ? "border-color:" . $opts['borderclr'] . ';' : ''; $bgclr = $opts['bgclr'] ? "background-color:" . $opts['bgclr'] . ';' : ''; $txclr = $opts['textclr'] ? "color:" . $opts['textclr'] . ';' : ''; $style = ' style="' . $brclr . $bgclr . $txclr . '"'; } $class = 'announcer-' . $opts['position'] . ' ' . $class; if (strpos($opts['position'], 'top') !== false) { $class .= ' announcer-topbar'; } elseif (strpos($opts['position'], 'bottom') !== false) { $class .= ' announcer-bottombar'; } // Effect $effdur = (int) $opts['effectduration'] * 1000; $effect = ' data-effect="' . $opts['effect'] . '" data-effdur="' . $effdur . '"'; // Position $position = ' data-pos="' . $opts['position'] . '"'; $this_blog_id = get_current_blog_id(); if ($this_blog_id != 1) { // Main output echo "<!-- Start Announcement - Announcer plugin -->\n"; echo '<div class="announcer ' . $class . '"' . $style . $effect . $position . ' data-id="' . $id . '">' . $closebt . '<div class="announcer-content">' . $opts['content'] . '</div>'; echo "</div>\n"; echo "<!-- End Announcement - Announcer plugin -->\n"; } // Note that it has been diplayed $note[$id] = 1; } }
<?php $options = get_option('announcer_data'); $att = array(); $ancr_id = ''; if ($params['id'] !== false) { if (isset($options[$params['id']])) { $ancr_id = intval($params['id']); $att = $options[$ancr_id]; $date = ancr_date_check($att); if ($att['status'] == 'yes' && $date) { $status = array('green', __('Active', 'announcer')); } else { $status = array('red', __(' Inactive', 'announcer')); } $title = __('Edit Announcement: ', 'announcer') . $ancr_id . '<div class="ancr-single-info"><span class="ancr-single-status ' . $status[0] . '">' . $status[1] . '</span> <a class="button delete-btn" href="' . wp_nonce_url(ANCR_ADMIN . '&action=delete&id=' . $ancr_id, 'ancr-delete') . '">' . __('Delete', 'announcer') . '</a></div>'; } else { echo '<div class="updated below-h2 error"><p>Announcement does not exist !!! </p></div>'; $title = __("Create an Announcement", 'announcer'); } } else { $title = __("Create an Announcement", 'announcer'); } $defaults = ancr_default_data(); $att = array_merge($defaults, $att); ?> <form method="post" id="ancr-single-form"> <table class="widefat ancr-table"> <tbody>
<th width="20%">Name</th> <th>Announcement</th> <th width="10%"><center>Status<center></th> </tr> </thead> <tbody> <?php $i = 0; foreach ($options as $key => $value) { if (intval($key) > 0) { $content = strip_tags($value['content']); $name = '<a href="' . ANCR_ADMIN . '&action=edit&id=' . $key . '">' . strip_tags($value['name']) . '</a>'; $alternate = $i % 2 == 0 ? 'class="alternate"' : ''; $date = ancr_date_check($value); if ($value['status'] == 'yes' && $date) { $status = array('green', __('Active', 'announcer')); } else { $status = array('red', __(' Inactive', 'announcer')); } if (empty($value['fromdate'])) { $fdate = '(not set)'; } else { $fdate = $value['fromdate']; } if (empty($value['todate'])) { $tdate = '(not set)'; } else { $tdate = $value['todate']; }