initial
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
+1194
File diff suppressed because it is too large
Load Diff
+230
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/*
|
||||
WPFront Notification Bar Plugin
|
||||
Copyright (C) 2013, WPFront.com
|
||||
Website: wpfront.com
|
||||
Contact: syam@wpfront.com
|
||||
|
||||
WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
|
||||
June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
|
||||
St, Fifth Floor, Boston, MA 02110, USA
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace WPFront\Notification_Bar;
|
||||
|
||||
if (!defined('ABSPATH')) exit();
|
||||
|
||||
if (!class_exists('\WPFront\Notification_Bar\WPFront_Notification_Bar_Custom_Css_Template')) {
|
||||
|
||||
class WPFront_Notification_Bar_Custom_CSS_Template {
|
||||
|
||||
protected $controller;
|
||||
protected $options;
|
||||
|
||||
public function write($controller, $force = false) {
|
||||
$this->controller = $controller;
|
||||
$this->options = $controller->get_options();
|
||||
|
||||
$enabled = $this->options->enabled;
|
||||
$preview = $this->options->preview_mode;
|
||||
|
||||
if ($preview || $enabled || $force) {
|
||||
$this->wpfront_notification_bar_css();
|
||||
$this->div_wpfront_message_css();
|
||||
$this->a_wpfront_button_css();
|
||||
$this->open_button_css();
|
||||
$this->table_css();
|
||||
$this->div_wpfront_close_css();
|
||||
$this->div_wpfront_close_hover_css();
|
||||
$this->display_on_devices();
|
||||
$this->hide_small_window();
|
||||
$this->custom_css();
|
||||
}
|
||||
}
|
||||
|
||||
protected function wpfront_notification_bar_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar$id_suffix, #wpfront-notification-bar-editor";
|
||||
?>
|
||||
{
|
||||
background: <?php echo $this->options->bar_from_color; ?>;
|
||||
background: -moz-linear-gradient(top, <?php echo $this->options->bar_from_color; ?> 0%, <?php echo $this->options->bar_to_color; ?> 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->bar_from_color; ?>), color-stop(100%,<?php echo $this->options->bar_to_color; ?>));
|
||||
background: -webkit-linear-gradient(top, <?php echo $this->options->bar_from_color; ?> 0%,<?php echo $this->options->bar_to_color; ?> 100%);
|
||||
background: -o-linear-gradient(top, <?php echo $this->options->bar_from_color; ?> 0%,<?php echo $this->options->bar_to_color; ?> 100%);
|
||||
background: -ms-linear-gradient(top, <?php echo $this->options->bar_from_color; ?> 0%,<?php echo $this->options->bar_to_color; ?> 100%);
|
||||
background: linear-gradient(to bottom, <?php echo $this->options->bar_from_color; ?> 0%, <?php echo $this->options->bar_to_color; ?> 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->bar_from_color; ?>', endColorstr='<?php echo $this->options->bar_to_color; ?>',GradientType=0 );
|
||||
background-repeat: no-repeat;
|
||||
<?php if ($this->options->set_full_width_message) {
|
||||
?>
|
||||
flex-direction: column;
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function table_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar-table$id_suffix, .wpfront-notification-bar tbody, .wpfront-notification-bar tr";
|
||||
?>
|
||||
{
|
||||
<?php if ($this->options->set_full_width_message) { ?>
|
||||
width: 100%
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function div_wpfront_message_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar$id_suffix div.wpfront-message, #wpfront-notification-bar-editor.wpfront-message";
|
||||
?>
|
||||
{
|
||||
color: <?php echo $this->options->message_color; ?>;
|
||||
<?php if ($this->options->set_full_width_message) {
|
||||
?>
|
||||
width: 100%
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function a_wpfront_button_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar$id_suffix a.wpfront-button, #wpfront-notification-bar-editor a.wpfront-button";
|
||||
?>
|
||||
{
|
||||
background: <?php echo $this->options->button_from_color; ?>;
|
||||
background: -moz-linear-gradient(top, <?php echo $this->options->button_from_color; ?> 0%, <?php echo $this->options->button_to_color; ?> 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->button_from_color; ?>), color-stop(100%,<?php echo $this->options->button_to_color; ?>));
|
||||
background: -webkit-linear-gradient(top, <?php echo $this->options->button_from_color; ?> 0%,<?php echo $this->options->button_to_color; ?> 100%);
|
||||
background: -o-linear-gradient(top, <?php echo $this->options->button_from_color; ?> 0%,<?php echo $this->options->button_to_color; ?> 100%);
|
||||
background: -ms-linear-gradient(top, <?php echo $this->options->button_from_color; ?> 0%,<?php echo $this->options->button_to_color; ?> 100%);
|
||||
background: linear-gradient(to bottom, <?php echo $this->options->button_from_color; ?> 0%, <?php echo $this->options->button_to_color; ?> 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->button_from_color; ?>', endColorstr='<?php echo $this->options->button_to_color; ?>',GradientType=0 );
|
||||
|
||||
background-repeat: no-repeat;
|
||||
color: <?php echo $this->options->button_text_color; ?>;
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function open_button_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar-open-button$id_suffix";
|
||||
?>
|
||||
{
|
||||
background-color: <?php echo $this->options->open_button_color; ?>;
|
||||
right: <?php echo 10 + $this->options->reopen_button_offset; ?>px;
|
||||
<?php
|
||||
if (!empty($this->options->reopen_button_image_url)) {
|
||||
echo "background-image: url({$this->options->reopen_button_image_url});";
|
||||
}
|
||||
?>
|
||||
}
|
||||
<?php
|
||||
if (empty($this->options->reopen_button_image_url)) {
|
||||
$url_top = plugins_url('images/arrow_down.png', $this->controller->get_plugin_file());
|
||||
$url_bottom = plugins_url('images/arrow_up.png', $this->controller->get_plugin_file());
|
||||
echo "#wpfront-notification-bar-open-button$id_suffix.top";
|
||||
?>
|
||||
{
|
||||
background-image: url(<?php echo $url_top; ?>);
|
||||
}
|
||||
|
||||
<?php
|
||||
echo "#wpfront-notification-bar-open-button$id_suffix.bottom";
|
||||
?>
|
||||
{
|
||||
background-image: url(<?php echo $url_bottom; ?>);
|
||||
}
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
protected function div_wpfront_close_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar$id_suffix div.wpfront-close";
|
||||
?>
|
||||
{
|
||||
border: 1px solid <?php echo $this->options->close_button_color; ?>;
|
||||
background-color: <?php echo $this->options->close_button_color; ?>;
|
||||
color: <?php echo $this->options->close_button_color_x; ?>;
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function div_wpfront_close_hover_css() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "#wpfront-notification-bar$id_suffix div.wpfront-close:hover";
|
||||
?>
|
||||
{
|
||||
border: 1px solid <?php echo $this->options->close_button_color_hover; ?>;
|
||||
background-color: <?php echo $this->options->close_button_color_hover; ?>;
|
||||
}
|
||||
<?php
|
||||
}
|
||||
|
||||
protected function display_on_devices() {
|
||||
switch ($this->options->hide_small_device) {
|
||||
case 'small':
|
||||
$this->display_on_small_device();
|
||||
break;
|
||||
|
||||
case 'large':
|
||||
$this->display_on_large_device();
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->display_on_all_device();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function display_on_all_device() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo " #wpfront-notification-bar-spacer$id_suffix { display:block; }";
|
||||
}
|
||||
|
||||
protected function display_on_small_device() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo " #wpfront-notification-bar-spacer$id_suffix { display:none; }@media screen and (max-device-width:{$this->options->small_device_width}px) { #wpfront-notification-bar-spacer$id_suffix { display:block; } }";
|
||||
}
|
||||
|
||||
protected function display_on_large_device() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "@media screen and (max-device-width: {$this->options->small_device_width}px) { #wpfront-notification-bar-spacer$id_suffix { display:none; } }";
|
||||
}
|
||||
|
||||
protected function hide_small_window() {
|
||||
if ($this->options->hide_small_window) {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
echo "@media screen and (max-width: {$this->options->small_window_width}px) { #wpfront-notification-bar-spacer$id_suffix { display:none; } }";
|
||||
}
|
||||
}
|
||||
|
||||
protected function custom_css() {
|
||||
echo wp_strip_all_tags($this->options->custom_css, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/*
|
||||
WPFront Notification Bar Plugin
|
||||
Copyright (C) 2013, WPFront.com
|
||||
Website: wpfront.com
|
||||
Contact: syam@wpfront.com
|
||||
|
||||
WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
|
||||
June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
|
||||
St, Fifth Floor, Boston, MA 02110, USA
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace WPFront\Notification_Bar;
|
||||
|
||||
if (!defined('ABSPATH')) exit();
|
||||
|
||||
if (!class_exists('\WPFront\Notification_Bar\WPFront_Notification_Bar_Template')) {
|
||||
|
||||
/**
|
||||
* Template for WPFront Notification Bar
|
||||
*
|
||||
* @author Syam Mohan <syam@wpfront.com>
|
||||
* @copyright 2013 WPFront.com
|
||||
*/
|
||||
class WPFront_Notification_Bar_Template {
|
||||
|
||||
protected $controller;
|
||||
protected $options;
|
||||
|
||||
public function __construct($options, $controller) {
|
||||
$this->options = $options;
|
||||
$this->controller = $controller;
|
||||
}
|
||||
|
||||
public function write() {
|
||||
$this->dynamic_css();
|
||||
$this->display_button_js_script();
|
||||
$this->display_bar();
|
||||
}
|
||||
|
||||
protected function dynamic_css() {
|
||||
if (!$this->options->dynamic_css_use_url) {
|
||||
?>
|
||||
<style type="text/css">
|
||||
<?php
|
||||
$template = new WPFront_Notification_Bar_Custom_CSS_Template();
|
||||
$template->write($this->controller);
|
||||
?>
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
protected function display_button_js_script() {
|
||||
if ($this->options->display_button && $this->options->button_action == 2) {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
$id_suffix = str_replace('-', "", $id_suffix);
|
||||
$js = preg_replace('/<\/script\b[^>]*>/i', '', $this->options->button_action_javascript);
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function wpfront_notification_bar_button_action_script<?php echo $id_suffix ?>() {
|
||||
try {
|
||||
<?php echo $js; ?>
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
protected function check_empty_id($id) {
|
||||
if (!empty($id)) {
|
||||
return '-' . $id;
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns bar CSS classes;
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ElseExpression)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_bar_css_classes() {
|
||||
$bar_css = 'wpfront-notification-bar wpfront-fixed';
|
||||
|
||||
if($this->options->fixed_position) {
|
||||
$bar_css .= ' wpfront-fixed-position';
|
||||
}
|
||||
|
||||
if($this->controller->display_on_page_load()) {
|
||||
$bar_css .= ' load';
|
||||
}
|
||||
|
||||
if($this->options->position == 1) {
|
||||
$bar_css .= ' top';
|
||||
} else {
|
||||
$bar_css .= ' bottom';
|
||||
}
|
||||
|
||||
if($this->options->display_shadow) {
|
||||
if($this->options->position == 1) {
|
||||
$bar_css .= ' wpfront-bottom-shadow';
|
||||
} else {
|
||||
$bar_css .= ' wpfront-top-shadow';
|
||||
}
|
||||
}
|
||||
|
||||
if($this->controller->has_keep_closed_set()) {
|
||||
$bar_css .= ' keep-closed';
|
||||
}
|
||||
|
||||
if($this->controller->has_max_views_reached()) {
|
||||
$bar_css .= ' max-views-reached';
|
||||
}
|
||||
|
||||
$bar_css .= ' ' . $this->options->custom_class;
|
||||
|
||||
return $bar_css;
|
||||
}
|
||||
|
||||
protected function display_bar() {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
$bar_css = $this->get_bar_css_classes();
|
||||
?>
|
||||
<div id="wpfront-notification-bar-spacer<?php echo $id_suffix; ?>" class="wpfront-notification-bar-spacer <?php echo $this->options->fixed_position ? ' wpfront-fixed-position' : ''; ?> <?php echo $this->controller->display_on_page_load() ? ' ' : 'hidden'; ?>">
|
||||
<div id="wpfront-notification-bar-open-button<?php echo $id_suffix; ?>" aria-label="reopen" role="button" class="wpfront-notification-bar-open-button hidden <?php echo $this->options->position == 1 ? 'top wpfront-bottom-shadow' : 'bottom wpfront-top-shadow'; ?>"></div>
|
||||
<div id="wpfront-notification-bar<?php echo $id_suffix; ?>" class="<?php echo esc_attr($bar_css); ?>">
|
||||
<?php if ($this->options->close_button) { ?>
|
||||
<div aria-label="close" class="wpfront-close">X</div>
|
||||
<?php } if (empty($this->controller->get_message_text())) {
|
||||
?> <?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$table_present = apply_filters('wpfront_notification_bar_use_table_html', true);
|
||||
if (!empty($this->options->display_button) || !empty($this->controller->get_message_text())) {
|
||||
if ($table_present == true) {
|
||||
?>
|
||||
<table id="wpfront-notification-bar-table<?php echo $id_suffix; ?>" border="0" cellspacing="0" cellpadding="0" role="presentation">
|
||||
<tr>
|
||||
<td>
|
||||
<?php } ?>
|
||||
<div class="wpfront-message wpfront-div">
|
||||
<?php echo __($this->controller->get_message_text(true), $this->controller->get_lang_domain()); ?>
|
||||
</div>
|
||||
<?php
|
||||
if ($this->options->display_button) {
|
||||
?>
|
||||
<div class="wpfront-div">
|
||||
<?php
|
||||
$button_text = $this->controller->get_button_text(true);
|
||||
?>
|
||||
<?php
|
||||
if ($this->options->button_action == 1) {
|
||||
$rel = array();
|
||||
|
||||
if ($this->options->button_action_url_nofollow) {
|
||||
$rel[] = 'nofollow';
|
||||
}
|
||||
|
||||
if ($this->options->button_action_url_noreferrer) {
|
||||
$rel[] = 'noreferrer';
|
||||
}
|
||||
|
||||
if ($this->options->button_action_new_tab && $this->options->button_action_url_noopener) {
|
||||
$rel[] = 'noopener';
|
||||
}
|
||||
|
||||
$rel = implode(' ', $rel);
|
||||
?>
|
||||
<a class="wpfront-button" href="<?php echo __($this->options->button_action_url, $this->controller->get_lang_domain()); ?>" target="<?php echo $this->options->button_action_new_tab ? '_blank' : '_self'; ?>" <?php echo empty($rel) ? '' : "rel=\"$rel\""; ?>><?php echo __($button_text, $this->controller->get_lang_domain()); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ($this->options->button_action == 2) {
|
||||
$id_suffix = $this->controller->get_html_id_suffix();
|
||||
$id_suffix = str_replace('-', "", $id_suffix);
|
||||
?>
|
||||
<a class="wpfront-button" onclick="javascript:wpfront_notification_bar_button_action_script<?php echo $id_suffix ?>();"><?php echo __($button_text, $this->controller->get_lang_domain()); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if ($table_present == true) {
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user