Plugin Directory

Changeset 2816182


Ignore:
Timestamp:
11/10/2022 06:29:24 PM (3 years ago)
Author:
renderlogic
Message:

Implemented Sticky Footer feature option

  • Allows instance of the alert to be attached to the bottom left of screen.
  • Truncating stays persistent on page refreshes.
  • Click on the alert to expand to full information.
Location:
super-simple-site-alert/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • super-simple-site-alert/trunk/README.txt

    r2791424 r2816182  
    55Requires at least: 5.7
    66Tested up to: 5.9
    7 Stable tag: 1.2
     7Stable tag: 1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • super-simple-site-alert/trunk/admin/partials/site-alert-admin-manage.php

    r2728652 r2816182  
    4444    $option_all_sites = isset($_POST['allsites']) ? intval($_POST['allsites']) : '';
    4545    $option_is_static = isset($_POST['isstatic']) ? intval($_POST['isstatic']) : '';
     46    $option_is_sticky_footer = isset($_POST['isstickyfooter']) ? intval($_POST['isstickyfooter']) : '';
    4647    $option_is_popup = isset($_POST['ispopup']) ? intval($_POST['ispopup']) : '';
    4748    $publish_date = isset($_POST['publish-date']) ? sanitize_text_field($_POST['publish-date']) : '';
     
    9697                add_post_meta($post_id, 'exclude_by_group', $exclude_by_group);
    9798                add_post_meta($post_id, 'isstatic', $option_is_static);
     99                add_post_meta($post_id, 'isstickyfooter', $option_is_sticky_footer);
    98100                add_post_meta($post_id, 'ispopup', $option_is_popup);
    99101                add_post_meta($post_id, 'publish-date', $publish_date);
     
    119121                update_post_meta($post_id, 'exclude_by_group', $exclude_by_group);
    120122                update_post_meta($post_id, 'isstatic', $option_is_static);
     123                update_post_meta($post_id, 'isstickyfooter', $option_is_sticky_footer);
    121124                update_post_meta($post_id, 'ispopup', $option_is_popup);
    122125                update_post_meta($post_id, 'publish-date', $publish_date);
     
    147150    $exclude_by_group = get_post_meta($post_id, 'exclude_by_group', true);
    148151    $option_is_static = get_post_meta($post_id, 'isstatic', true);
     152    $option_is_sticky_footer = get_post_meta($post_id, 'isstickyfooter', true);
    149153    $option_is_popup = get_post_meta($post_id, 'ispopup', true);
    150154    $publish_date = get_post_meta($post_id, 'publish-date', true);
     
    307311                        </div>
    308312                        <div>
     313                            <input type="checkbox" name="isstickyfooter" value="1" <?PHP print $option_is_sticky_footer == 1 ? "checked" : "";?>> Sticky Footer
     314                        </div>
     315                        <div>
    309316                            <input type="checkbox" name="ispopup" value="1" <?PHP print $option_is_popup == 1 ? "checked" : "";?>> Pop-Up
    310317                            <?PHP if($action == "edit"){?><a href="javascript: void(0)" class="reset-popup small" data-id="<?PHP print esc_attr($post_id);?>">[Reset suppressed window]</a><?PHP } ?>
  • super-simple-site-alert/trunk/public/class-site-alert-public.php

    r2728652 r2816182  
    6161    public function show_alert() {
    6262        //suppress the alert from showing up in Elementor editor
     63        require_once plugin_dir_path(__DIR__) . '/includes/utilities.php';
    6364        if ( class_exists('Elementor\Plugin') ) {
    6465            if ( \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
  • super-simple-site-alert/trunk/public/css/site-alert-public.css

    r2728652 r2816182  
    5555}
    5656
     57.site-alert.sticky-footer {
     58    position: fixed;
     59    bottom: 10px;
     60    left: 10px;
     61    padding: 10px 20px;
     62    width: initial;
     63    height: 50px;
     64    font-size: initial;
     65    margin: 0;
     66    display: flex;
     67    overflow: hidden;
     68    max-width: 50%;
     69    z-index: 999;
     70}
     71
     72.site-alert.sticky-footer.expand {
     73    height: initial;
     74    z-index: 9999;
     75}
     76
     77.site-alert.sticky-footer.truncate {
     78    padding: 0 !important;
     79    z-index: 999;
     80}
     81
     82.site-alert.sticky-footer.truncate i.sa-closed {
     83    padding: 20px;
     84    display: flex;
     85    align-items: center;
     86    justify-content: center;
     87}
     88
     89.site-alert.sticky-footer.truncate::before,
     90.site-alert.sticky-footer.truncate .site-alert-content,
     91.site-alert.sticky-footer i.sa-closed {
     92    display: none;
     93}
     94
     95.site-alert.sticky-footer i.sa-close {
     96    position: absolute;
     97    top: 0;
     98    right: 0;
     99    opacity: 0.2;
     100}
     101
     102.site-alert.sticky-footer i.sa-close:hover {
     103    opacity: 0.5;
     104}
     105
     106.site-alert.sticky-footer .site-alert-content .short-length {
     107    display: block;
     108}
     109
     110.site-alert.sticky-footer.expand .site-alert-content .short-length {
     111    display: none;
     112}
     113
     114.site-alert.sticky-footer.expand .site-alert-content .full-length {
     115    display: block;
     116}
     117
     118.site-alert.sticky-footer .site-alert-content .full-length {
     119    display: none;
     120}
     121
    57122.site-alert.ispopup {
    58123    width: 100%;
  • super-simple-site-alert/trunk/public/partials/site-alert-public-display.php

    r2728698 r2816182  
    8383            $excluded_sites = explode(',', get_post_meta($post_id, 'exclude', true));
    8484            $option_is_static = get_post_meta($post_id, 'isstatic', true) == 1 ? 'isstatic' : '';
     85            $option_is_sticky_footer = get_post_meta($post_id, 'isstickyfooter', true) == 1 ? 'isstickyfooter' : '';
    8586            $option_is_popup = get_post_meta($post_id, 'ispopup', true) == 1 ? 'ispopup' : '';
    8687            $publish_date = get_post_meta($post_id, 'publish-date', true);
     
    9596</div>
    9697<?PHP
    97 }
     98                    }
    9899                    if($option_is_popup){
    99100?>
     
    113114            </div>
    114115        </div>
     116    </div>
     117</div>
     118<?PHP
     119                    }
     120                    if($option_is_sticky_footer){
     121?>
     122<div class="site-alert sticky-footer <?PHP print esc_attr($priority_class);?>" style="border-color: <?PHP print esc_attr($priority_color_border);?>; background: <?PHP print esc_attr($priority_color_bg);?>; color: <?PHP print esc_attr($priority_color_text);?>" data-id="<?PHP print esc_attr($post_id);?>">
     123    <i class="sa-closed dashicons dashicons-warning" alt="Alert Notification" title="Alert Notification"></i>
     124    <div class="site-alert-content">
     125        <i class="sa-close dashicons dashicons-no"></i>
     126        <?PHP
     127            $full_message = wp_kses_post($message);
     128            $length = 50;
     129            $short_message = sssa_truncate_html($full_message, $length)."...";
     130        ?>
     131        <div class="short-length"><?PHP print $short_message;?></div>
     132        <div class="full-length"><?PHP print $full_message;?></div>
    115133    </div>
    116134</div>
     
    154172         });
    155173       }
     174
     175       handleStickyFooterAlert();
    156176    });
    157177
     
    192212    }
    193213
     214    //handle sticky footer
     215    function handleStickyFooterAlert() {
     216        $('.site-alert.sticky-footer').each(function(i, e){
     217            var alert = $(e);
     218            var id = alert.data('id');
     219            var storageId = sssa_getHost() + "___" + id;
     220            if(storage.getItem(storageId)){
     221                //if alert is set as 'do not show' by the browser
     222                alert.addClass('truncate');
     223            }
     224
     225            var offset = 5;
     226            var height = alert.outerHeight();
     227            var pos = 10 + (height * i) + (i * 5);
     228            alert.css('bottom', pos);
     229
     230            //while is open
     231            alert.find('i.sa-close').on('click', function(e){
     232                e.stopPropagation();
     233                alert.addClass('truncate');
     234                alert.removeClass('expand');
     235                storage.setItem(storageId, Date.now());
     236            });
     237
     238            alert.on('click', function(){
     239                if(!alert.hasClass('truncate')) {
     240                    if(!alert.hasClass('expand')) {
     241                        $('.site-alert.sticky-footer').removeClass('expand');
     242                        alert.addClass('expand');
     243                        alert.removeClass('truncate');
     244                    }else{
     245                        alert.addClass('truncate');
     246                        alert.removeClass('expand');
     247                    }
     248                }else{
     249                    alert.addClass('expand');
     250                    alert.removeClass('truncate');
     251                    storage.removeItem(storageId);
     252                }
     253            });
     254        });
     255    }
     256
    194257    function siteAlertCheckDom(e, name, insertion){
    195258       var _tag = $(name);
  • super-simple-site-alert/trunk/site-alert.php

    r2791424 r2816182  
    1313 * Plugin URI:
    1414 * Description:       Broadcast simple, important alerts across your multisite network. Also great for single sites.
    15  * Version:           1.2
     15 * Version:           1.3
    1616 * Requires at least: 5.7
    1717 * Requires PHP:            7.3
     
    3232 * Rename this for your plugin and update it as you release new versions.
    3333 */
    34 define( 'SITE_ALERT_VERSION', '1.2' );
     34define( 'SITE_ALERT_VERSION', '1.3' );
    3535
    3636/**
Note: See TracChangeset for help on using the changeset viewer.