Plugin Directory

Changeset 3397926


Ignore:
Timestamp:
11/18/2025 10:15:56 AM (5 months ago)
Author:
Alobaidi
Message:

Adds visual admin notifications to the plugin menu.

Location:
video-popup/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • video-popup/trunk/includes/class-admin.php

    r3397512 r3397926  
    7171        add_action('admin_init', array($this, 'register_settings_fields'));
    7272        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_script'));
     73        add_action('admin_head', array($this, 'admin_notify'));
    7374    }
    7475
     
    9394                update_option($this->get_const('settings_key') . '_first_use', 'used');
    9495            }
     96        }
     97
     98        if ( !get_option($this->get_const('settings_key') . '_admin_notify') ) {
     99            update_option($this->get_const('settings_key') . '_admin_notify', 'shown');
    95100        }
    96101
     
    135140            array($this, 'render_page')
    136141        );
     142    }
     143
     144    /**
     145     * Adds visual admin notifications to the plugin menu
     146     * when the admin_notify option is not enabled.
     147     */
     148    public function admin_notify() {
     149        if ( !get_option($this->get_const('settings_key') . '_admin_notify') ) {
     150            ?>
     151                <style>
     152                    li.toplevel_page_video_popup > a.toplevel_page_video_popup{
     153                        background-color: #409b1a !important;
     154                        font-weight: 500 !important;
     155                    }
     156                </style>
     157                <script>
     158                    document.addEventListener('DOMContentLoaded', function () {
     159                        const vpMainMenuLabel = document.querySelector(
     160                            'li.toplevel_page_video_popup > a.toplevel_page_video_popup .wp-menu-name'
     161                        );
     162
     163                        const vpSubmenuFirstItem = document.querySelector(
     164                            'li.toplevel_page_video_popup .wp-submenu li.wp-first-item > a'
     165                        );
     166
     167                        if (vpMainMenuLabel) {
     168                            const vpBadgeMain = document.createElement('span');
     169                            vpBadgeMain.className = 'update-plugins count-1';
     170                            vpBadgeMain.innerHTML = '<span class="plugin-count">1</span>';
     171                            vpMainMenuLabel.append(' ', vpBadgeMain);
     172                        }
     173
     174                        if (vpSubmenuFirstItem) {
     175                            const vpBadgeSub = document.createElement('span');
     176                            vpBadgeSub.className = 'update-plugins count-1';
     177                            vpBadgeSub.innerHTML = '<span class="plugin-count">1</span>';
     178                            vpSubmenuFirstItem.append(' ', vpBadgeSub);
     179                        }
     180                    });
     181                </script>
     182            <?php
     183        }
    137184    }
    138185
  • video-popup/trunk/includes/class-onpageload.php

    r3397512 r3397926  
    108108                update_option($this->get_const('settings_key') . '_first_use', 'used');
    109109            }
     110        }
     111
     112        if ( !get_option($this->get_const('settings_key') . '_admin_notify') ) {
     113            update_option($this->get_const('settings_key') . '_admin_notify', 'shown');
    110114        }
    111115
  • video-popup/trunk/includes/class-shortcode-reference-page.php

    r3397512 r3397926  
    8787        if ( isset($_GET['page']) && $_GET['page'] != $this->get_const('plugin_id') . '_shortcode' ) {
    8888            return;
     89        }
     90
     91        if ( !get_option($this->get_const('settings_key') . '_admin_notify') ) {
     92            update_option($this->get_const('settings_key') . '_admin_notify', 'shown');
    8993        }
    9094
  • video-popup/trunk/uninstall.php

    r3397512 r3397926  
    66delete_option('video_popup_settings_onpage_load');
    77delete_option('video_popup_settings_first_use');
     8delete_option('video_popup_settings_admin_notify');
Note: See TracChangeset for help on using the changeset viewer.