Plugin Directory

Changeset 3833010


Ignore:
Timestamp:
11/29/2026 12:38:59 PM (9 hours ago)
Author:
leadwon
Message:

Release 1.1.5: the full top bar is back

Location:
dealroot
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dealroot/tags/1.1.5/dealroot.php

    r3831796 r3833010  
    44 * Plugin URI:        https://dealroot.net/docs/
    55 * Description:       See where every lead comes from, follow it to a sale, and get notified the moment it arrives.
    6  * Version:           1.1.4
     6 * Version:           1.1.5
    77 * Requires at least: 6.8
    88 * Requires PHP:      7.4
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'DEALROOT_VERSION', '1.1.4' );
     21define( 'DEALROOT_VERSION', '1.1.5' );
    2222define( 'DEALROOT_FILE', __FILE__ );
    2323define( 'DEALROOT_DIR', plugin_dir_path( __FILE__ ) );
  • dealroot/tags/1.1.5/includes/admin/class-admin.php

    r3830572 r3833010  
    112112                add_action( 'admin_menu', array( $this, 'menu' ) );
    113113                // After every plugin changed the menu, before it is shown.
    114                 add_action( 'admin_head', array( Shell::class, 'shorten_menu' ) );
    115114                add_action( 'admin_init', array( new Settings_Page(), 'register_settings' ) );
    116115                add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
  • dealroot/tags/1.1.5/includes/admin/class-shell.php

    r3830572 r3833010  
    2222
    2323        /**
    24          * The Dealroot screens of the admin menu before it was shortened to one item per group.
    25          *
    26          * @var string[]|null
    27          */
    28         private static $menu = null;
    29 
    30         /**
    3124         * Screens in the bar, in their order. Add-ons add theirs with the dealroot_admin_screens filter.
    3225         *
    … …  
    4336                $screens = array(
    4437                        'overview' => array(
    45                                 'group'      => 'overview',
    4638                                'label'      => __( 'Overview', 'dealroot' ),
    4739                                'page'       => Admin::PAGE,
    … …  
    5042                        ),
    5143                        'live'     => array(
    52                                 'group'      => 'leads',
    5344                                'label'      => __( 'Live', 'dealroot' ),
    5445                                'page'       => Live_Page::PAGE,
    … …  
    5849                        ),
    5950                        'leads'    => array(
    60                                 'group'      => 'leads',
    6151                                'label'      => __( 'Leads', 'dealroot' ),
    6252                                'page'       => Admin::LEADS_PAGE,
    … …  
    6656                        ),
    6757                        'ask'      => array(
    68                                 'group'      => 'reports',
    69                                 'label'      => __( 'Ask a question', 'dealroot' ),
     58                                'label'      => __( 'Ask', 'dealroot' ),
    7059                                'page'       => Ask_Page::PAGE,
    7160                                'capability' => Admin::capability(),
    … …  
    7362                        ),
    7463                        'reports'  => array(
    75                                 'group'      => 'reports',
    7664                                'label'      => __( 'Reports', 'dealroot' ),
    7765                                'page'       => Reports_Page::PAGE,
    … …  
    8068                        ),
    8169                        'forms'    => array(
    82                                 'group'      => 'website',
    8370                                'label'      => __( 'Forms', 'dealroot' ),
    8471                                'page'       => Forms_Page::PAGE,
    … …  
    8774                        ),
    8875                        'settings' => array(
    89                                 'group'      => 'settings',
    9076                                'label'      => __( 'Settings', 'dealroot' ),
    9177                                'page'       => Admin::SETTINGS_PAGE,
    … …  
    9581                );
    9682
     83                // Not in the admin menu, so it stays out of the way, but a tab at the end of the bar.
    9784                $screens['features'] = array(
    9885                        'label'      => __( 'All features', 'dealroot' ),
    9986                        'page'       => Features_Page::PAGE,
    100                         'group'      => 'settings',
    10187                        'capability' => 'manage_options',
    10288                        'order'      => 99,
    … …  
    11298
    11399                // A screen that was taken out of the menu, e.g. for a white label, leaves the bar too.
    114                 $menu = null !== self::$menu ? self::$menu : wp_list_pluck( (array) ( $submenu[ Admin::PAGE ] ?? array() ), 2 );
     100                $menu = wp_list_pluck( (array) ( $submenu[ Admin::PAGE ] ?? array() ), 2 );
    115101
    116102                $screens = array_filter(
    … …  
    135121
    136122                return $screens;
    137         }
    138 
    139         /**
    140          * The groups of the bar, in their order: a few words a person looks for, each with its
    141          * screens as tabs below the bar.
    142          *
    143          * @return array<string, string> Group key => label.
    144          */
    145         public static function groups() {
    146                 /**
    147                  * Filters the groups of the bar.
    148                  *
    149                  * @param array<string, string> $groups Group key => label.
    150                  */
    151                 return (array) apply_filters(
    152                         'dealroot_admin_groups',
    153                         array(
    154                                 'overview' => __( 'Overview', 'dealroot' ),
    155                                 'leads'    => __( 'Leads', 'dealroot' ),
    156                                 'reports'  => __( 'Reports', 'dealroot' ),
    157                                 'website'  => __( 'Your website', 'dealroot' ),
    158                                 'ads'      => __( 'Ads', 'dealroot' ),
    159                                 'settings' => __( 'Settings', 'dealroot' ),
    160                         )
    161                 );
    162         }
    163 
    164         /**
    165          * Group of a screen; a screen without one gets its own place in the bar.
    166          *
    167          * @param string $key    Screen key.
    168          * @param array  $screen Screen.
    169          * @return string
    170          */
    171         private static function group_of( $key, array $screen ) {
    172                 return isset( $screen['group'] ) && isset( self::groups()[ $screen['group'] ] ) ? (string) $screen['group'] : (string) $key;
    173         }
    174 
    175         /**
    176          * Shortens the Dealroot part of the admin menu to one item per group, named like the group,
    177          * as in the bar: the other screens are reached by the tabs and stay where they are.
    178          */
    179         public static function shorten_menu() {
    180                 global $submenu;
    181 
    182                 if ( empty( $submenu[ Admin::PAGE ] ) ) {
    183                         return;
    184                 }
    185 
    186                 self::$menu = wp_list_pluck( $submenu[ Admin::PAGE ], 2 );
    187 
    188                 $labels = self::groups();
    189                 $first  = array();
    190                 $others = array();
    191 
    192                 foreach ( self::screens() as $key => $screen ) {
    193                         $group = self::group_of( $key, $screen );
    194 
    195                         if ( ! isset( $first[ $group ] ) ) {
    196                                 $first[ $group ] = $screen['page'];
    197                         } else {
    198                                 $others[] = $screen['page'];
    199                         }
    200                 }
    201 
    202                 $pages = array_flip( $first );
    203                 $page  = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only which item is current.
    204 
    205                 // A screen reached by a tab marks the item of its group as current.
    206                 foreach ( self::screens() as $key => $screen ) {
    207                         if ( $screen['page'] === $page && in_array( $page, $others, true ) ) {
    208                                 $GLOBALS['submenu_file'] = $first[ self::group_of( $key, $screen ) ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Highlights our own item.
    209                         }
    210                 }
    211 
    212                 foreach ( $submenu[ Admin::PAGE ] as $index => $item ) {
    213                         if ( in_array( $item[2], $others, true ) ) {
    214                                 unset( $submenu[ Admin::PAGE ][ $index ] );
    215                         } elseif ( isset( $pages[ $item[2] ], $labels[ $pages[ $item[2] ] ] ) ) {
    216                                 $submenu[ Admin::PAGE ][ $index ][0] = $labels[ $pages[ $item[2] ] ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Only the label of our own item.
    217                         }
    218                 }
    219123        }
    220124
    … …  
    316220                                <span><?php esc_html_e( 'Dealroot', 'dealroot' ); ?></span>
    317221                        </a>
    318                         <?php
    319                         $screens = self::screens();
    320                         $labels  = self::groups();
    321                         $groups  = array();
    322 
    323                         foreach ( $screens as $key => $screen ) {
    324                                 $groups[ self::group_of( $key, $screen ) ][ $key ] = $screen;
    325                         }
    326 
    327                         // The groups in their own order, screens without a group where their first screen is.
    328                         uksort(
    329                                 $groups,
    330                                 static function ( $a, $b ) use ( $labels ) {
    331                                         $order = array_flip( array_keys( $labels ) );
    332 
    333                                         return ( $order[ $a ] ?? 50 ) <=> ( $order[ $b ] ?? 50 );
    334                                 }
    335                         );
    336 
    337                         $active = isset( $screens[ $current ] ) ? self::group_of( $current, $screens[ $current ] ) : '';
    338                         ?>
    339222                        <ul class="dealroot-appbar__screens">
    340                                 <?php foreach ( $groups as $group => $members ) : ?>
    341                                         <?php
    342                                         $first = reset( $members );
    343                                         $count = 0;
    344                                         $live  = null;
    345 
    346                                         foreach ( $members as $member ) {
    347                                                 $count += (int) ( $member['count'] ?? 0 );
    348                                                 $live   = isset( $member['live'] ) ? (int) $member['live'] : $live;
    349                                         }
    350 
    351                                         $label = 1 === count( $members ) && ! isset( $labels[ $group ] ) ? $first['label'] : ( $labels[ $group ] ?? $first['label'] );
    352                                         ?>
     223                                <?php foreach ( self::screens() as $key => $screen ) : ?>
    353224                                        <li>
    354                                                 <a href="<?php echo esc_url( self::url( $first['page'] ) ); ?>"<?php echo $group === $active ? ' class="is-current" aria-current="page"' : ''; ?>>
    355                                                         <?php echo esc_html( $label ); ?>
    356                                                         <?php if ( null !== $live ) : ?>
    357                                                                 <span class="dealroot-appbar__live" data-dealroot-live-count<?php echo $live > 0 ? '' : ' hidden'; ?>><?php echo esc_html( number_format_i18n( $live ) ); ?></span>
     225                                                <a href="<?php echo esc_url( self::url( $screen['page'] ) ); ?>"<?php echo $key === $current ? ' class="is-current" aria-current="page"' : ''; ?>>
     226                                                        <?php echo esc_html( $screen['label'] ); ?>
     227                                                        <?php if ( isset( $screen['live'] ) ) : ?>
     228                                                                <span class="dealroot-appbar__live" data-dealroot-live-count<?php echo $screen['live'] > 0 ? '' : ' hidden'; ?>><?php echo esc_html( number_format_i18n( (int) $screen['live'] ) ); ?></span>
    358229                                                        <?php endif; ?>
    359                                                         <?php if ( $count > 0 ) : ?>
    360                                                                 <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( $count ) ); ?></span>
     230                                                        <?php if ( ! empty( $screen['count'] ) ) : ?>
     231                                                                <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( (int) $screen['count'] ) ); ?></span>
    361232                                                        <?php endif; ?>
    362233                                                </a>
    … …  
    366237                </nav>
    367238                <?php
    368                 $tabs = '' !== $active ? (array) ( $groups[ $active ] ?? array() ) : array();
    369 
    370                 if ( count( $tabs ) > 1 ) :
    371                         ?>
    372                         <nav class="dealroot-subnav" aria-label="<?php echo esc_attr( $labels[ $active ] ?? '' ); ?>">
    373                                 <?php foreach ( $tabs as $key => $screen ) : ?>
    374                                         <a href="<?php echo esc_url( self::url( $screen['page'] ) ); ?>"<?php echo $key === $current ? ' class="is-current" aria-current="page"' : ''; ?>>
    375                                                 <?php echo esc_html( $screen['label'] ); ?>
    376                                                 <?php if ( isset( $screen['live'] ) ) : ?>
    377                                                         <span class="dealroot-appbar__live" data-dealroot-live-count="always"><?php echo esc_html( number_format_i18n( (int) $screen['live'] ) ); ?></span>
    378                                                 <?php endif; ?>
    379                                                 <?php if ( ! empty( $screen['count'] ) ) : ?>
    380                                                         <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( (int) $screen['count'] ) ); ?></span>
    381                                                 <?php endif; ?>
    382                                         </a>
    383                                 <?php endforeach; ?>
    384                         </nav>
    385                         <?php
    386                 endif;
    387 
    388239                if ( 'live' !== $current && Live::enabled() ) {
    389240                        // The number next to "Live" stays current on the other screens too.
    390241                        wp_print_inline_script_tag(
    391242                                sprintf(
    392                                         '(function(){var b=document.querySelectorAll("[data-dealroot-live-count]");if(!b.length||!window.fetch){return;}function u(){if("hidden"===document.visibilityState){return;}var d=new URLSearchParams();d.append("action","dealroot_live_count");d.append("nonce",%1$s);fetch(%2$s,{method:"POST",credentials:"same-origin",body:d}).then(function(r){return r.json();}).then(function(r){if(r&&r.success){b.forEach(function(e){e.textContent=Number(r.data).toLocaleString();e.hidden=0===Number(r.data)&&"always"!==e.getAttribute("data-dealroot-live-count");});}}).catch(function(){});}setInterval(u,15000);document.addEventListener("visibilitychange",u);})();',
     243                                        '(function(){var b=document.querySelector("[data-dealroot-live-count]");if(!b||!window.fetch){return;}function u(){if("hidden"===document.visibilityState){return;}var d=new URLSearchParams();d.append("action","dealroot_live_count");d.append("nonce",%1$s);fetch(%2$s,{method:"POST",credentials:"same-origin",body:d}).then(function(r){return r.json();}).then(function(r){if(r&&r.success){b.textContent=Number(r.data).toLocaleString();b.hidden=0===Number(r.data);}}).catch(function(){});}setInterval(u,15000);document.addEventListener("visibilitychange",u);})();',
    393244                                        wp_json_encode( wp_create_nonce( 'dealroot_live_count' ) ),
    394245                                        wp_json_encode( admin_url( 'admin-ajax.php' ) )
  • dealroot/tags/1.1.5/readme.txt

    r3831796 r3833010  
    55Tested up to: 7.2
    66Requires PHP: 7.4
    7 Stable tag: 1.1.4
     7Stable tag: 1.1.5
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    218218
    219219== Changelog ==
     220
     221= 1.1.5 =
     222* The bar at the top of the Dealroot screens shows every screen again, and the admin menu lists them all, as before 1.1.0. "All features" is the last tab of the bar.
    220223
    221224= 1.1.4 =
  • dealroot/trunk/dealroot.php

    r3831796 r3833010  
    44 * Plugin URI:        https://dealroot.net/docs/
    55 * Description:       See where every lead comes from, follow it to a sale, and get notified the moment it arrives.
    6  * Version:           1.1.4
     6 * Version:           1.1.5
    77 * Requires at least: 6.8
    88 * Requires PHP:      7.4
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'DEALROOT_VERSION', '1.1.4' );
     21define( 'DEALROOT_VERSION', '1.1.5' );
    2222define( 'DEALROOT_FILE', __FILE__ );
    2323define( 'DEALROOT_DIR', plugin_dir_path( __FILE__ ) );
  • dealroot/trunk/includes/admin/class-admin.php

    r3830572 r3833010  
    112112                add_action( 'admin_menu', array( $this, 'menu' ) );
    113113                // After every plugin changed the menu, before it is shown.
    114                 add_action( 'admin_head', array( Shell::class, 'shorten_menu' ) );
    115114                add_action( 'admin_init', array( new Settings_Page(), 'register_settings' ) );
    116115                add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
  • dealroot/trunk/includes/admin/class-shell.php

    r3830572 r3833010  
    2222
    2323        /**
    24          * The Dealroot screens of the admin menu before it was shortened to one item per group.
    25          *
    26          * @var string[]|null
    27          */
    28         private static $menu = null;
    29 
    30         /**
    3124         * Screens in the bar, in their order. Add-ons add theirs with the dealroot_admin_screens filter.
    3225         *
    … …  
    4336                $screens = array(
    4437                        'overview' => array(
    45                                 'group'      => 'overview',
    4638                                'label'      => __( 'Overview', 'dealroot' ),
    4739                                'page'       => Admin::PAGE,
    … …  
    5042                        ),
    5143                        'live'     => array(
    52                                 'group'      => 'leads',
    5344                                'label'      => __( 'Live', 'dealroot' ),
    5445                                'page'       => Live_Page::PAGE,
    … …  
    5849                        ),
    5950                        'leads'    => array(
    60                                 'group'      => 'leads',
    6151                                'label'      => __( 'Leads', 'dealroot' ),
    6252                                'page'       => Admin::LEADS_PAGE,
    … …  
    6656                        ),
    6757                        'ask'      => array(
    68                                 'group'      => 'reports',
    69                                 'label'      => __( 'Ask a question', 'dealroot' ),
     58                                'label'      => __( 'Ask', 'dealroot' ),
    7059                                'page'       => Ask_Page::PAGE,
    7160                                'capability' => Admin::capability(),
    … …  
    7362                        ),
    7463                        'reports'  => array(
    75                                 'group'      => 'reports',
    7664                                'label'      => __( 'Reports', 'dealroot' ),
    7765                                'page'       => Reports_Page::PAGE,
    … …  
    8068                        ),
    8169                        'forms'    => array(
    82                                 'group'      => 'website',
    8370                                'label'      => __( 'Forms', 'dealroot' ),
    8471                                'page'       => Forms_Page::PAGE,
    … …  
    8774                        ),
    8875                        'settings' => array(
    89                                 'group'      => 'settings',
    9076                                'label'      => __( 'Settings', 'dealroot' ),
    9177                                'page'       => Admin::SETTINGS_PAGE,
    … …  
    9581                );
    9682
     83                // Not in the admin menu, so it stays out of the way, but a tab at the end of the bar.
    9784                $screens['features'] = array(
    9885                        'label'      => __( 'All features', 'dealroot' ),
    9986                        'page'       => Features_Page::PAGE,
    100                         'group'      => 'settings',
    10187                        'capability' => 'manage_options',
    10288                        'order'      => 99,
    … …  
    11298
    11399                // A screen that was taken out of the menu, e.g. for a white label, leaves the bar too.
    114                 $menu = null !== self::$menu ? self::$menu : wp_list_pluck( (array) ( $submenu[ Admin::PAGE ] ?? array() ), 2 );
     100                $menu = wp_list_pluck( (array) ( $submenu[ Admin::PAGE ] ?? array() ), 2 );
    115101
    116102                $screens = array_filter(
    … …  
    135121
    136122                return $screens;
    137         }
    138 
    139         /**
    140          * The groups of the bar, in their order: a few words a person looks for, each with its
    141          * screens as tabs below the bar.
    142          *
    143          * @return array<string, string> Group key => label.
    144          */
    145         public static function groups() {
    146                 /**
    147                  * Filters the groups of the bar.
    148                  *
    149                  * @param array<string, string> $groups Group key => label.
    150                  */
    151                 return (array) apply_filters(
    152                         'dealroot_admin_groups',
    153                         array(
    154                                 'overview' => __( 'Overview', 'dealroot' ),
    155                                 'leads'    => __( 'Leads', 'dealroot' ),
    156                                 'reports'  => __( 'Reports', 'dealroot' ),
    157                                 'website'  => __( 'Your website', 'dealroot' ),
    158                                 'ads'      => __( 'Ads', 'dealroot' ),
    159                                 'settings' => __( 'Settings', 'dealroot' ),
    160                         )
    161                 );
    162         }
    163 
    164         /**
    165          * Group of a screen; a screen without one gets its own place in the bar.
    166          *
    167          * @param string $key    Screen key.
    168          * @param array  $screen Screen.
    169          * @return string
    170          */
    171         private static function group_of( $key, array $screen ) {
    172                 return isset( $screen['group'] ) && isset( self::groups()[ $screen['group'] ] ) ? (string) $screen['group'] : (string) $key;
    173         }
    174 
    175         /**
    176          * Shortens the Dealroot part of the admin menu to one item per group, named like the group,
    177          * as in the bar: the other screens are reached by the tabs and stay where they are.
    178          */
    179         public static function shorten_menu() {
    180                 global $submenu;
    181 
    182                 if ( empty( $submenu[ Admin::PAGE ] ) ) {
    183                         return;
    184                 }
    185 
    186                 self::$menu = wp_list_pluck( $submenu[ Admin::PAGE ], 2 );
    187 
    188                 $labels = self::groups();
    189                 $first  = array();
    190                 $others = array();
    191 
    192                 foreach ( self::screens() as $key => $screen ) {
    193                         $group = self::group_of( $key, $screen );
    194 
    195                         if ( ! isset( $first[ $group ] ) ) {
    196                                 $first[ $group ] = $screen['page'];
    197                         } else {
    198                                 $others[] = $screen['page'];
    199                         }
    200                 }
    201 
    202                 $pages = array_flip( $first );
    203                 $page  = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only which item is current.
    204 
    205                 // A screen reached by a tab marks the item of its group as current.
    206                 foreach ( self::screens() as $key => $screen ) {
    207                         if ( $screen['page'] === $page && in_array( $page, $others, true ) ) {
    208                                 $GLOBALS['submenu_file'] = $first[ self::group_of( $key, $screen ) ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Highlights our own item.
    209                         }
    210                 }
    211 
    212                 foreach ( $submenu[ Admin::PAGE ] as $index => $item ) {
    213                         if ( in_array( $item[2], $others, true ) ) {
    214                                 unset( $submenu[ Admin::PAGE ][ $index ] );
    215                         } elseif ( isset( $pages[ $item[2] ], $labels[ $pages[ $item[2] ] ] ) ) {
    216                                 $submenu[ Admin::PAGE ][ $index ][0] = $labels[ $pages[ $item[2] ] ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Only the label of our own item.
    217                         }
    218                 }
    219123        }
    220124
    … …  
    316220                                <span><?php esc_html_e( 'Dealroot', 'dealroot' ); ?></span>
    317221                        </a>
    318                         <?php
    319                         $screens = self::screens();
    320                         $labels  = self::groups();
    321                         $groups  = array();
    322 
    323                         foreach ( $screens as $key => $screen ) {
    324                                 $groups[ self::group_of( $key, $screen ) ][ $key ] = $screen;
    325                         }
    326 
    327                         // The groups in their own order, screens without a group where their first screen is.
    328                         uksort(
    329                                 $groups,
    330                                 static function ( $a, $b ) use ( $labels ) {
    331                                         $order = array_flip( array_keys( $labels ) );
    332 
    333                                         return ( $order[ $a ] ?? 50 ) <=> ( $order[ $b ] ?? 50 );
    334                                 }
    335                         );
    336 
    337                         $active = isset( $screens[ $current ] ) ? self::group_of( $current, $screens[ $current ] ) : '';
    338                         ?>
    339222                        <ul class="dealroot-appbar__screens">
    340                                 <?php foreach ( $groups as $group => $members ) : ?>
    341                                         <?php
    342                                         $first = reset( $members );
    343                                         $count = 0;
    344                                         $live  = null;
    345 
    346                                         foreach ( $members as $member ) {
    347                                                 $count += (int) ( $member['count'] ?? 0 );
    348                                                 $live   = isset( $member['live'] ) ? (int) $member['live'] : $live;
    349                                         }
    350 
    351                                         $label = 1 === count( $members ) && ! isset( $labels[ $group ] ) ? $first['label'] : ( $labels[ $group ] ?? $first['label'] );
    352                                         ?>
     223                                <?php foreach ( self::screens() as $key => $screen ) : ?>
    353224                                        <li>
    354                                                 <a href="<?php echo esc_url( self::url( $first['page'] ) ); ?>"<?php echo $group === $active ? ' class="is-current" aria-current="page"' : ''; ?>>
    355                                                         <?php echo esc_html( $label ); ?>
    356                                                         <?php if ( null !== $live ) : ?>
    357                                                                 <span class="dealroot-appbar__live" data-dealroot-live-count<?php echo $live > 0 ? '' : ' hidden'; ?>><?php echo esc_html( number_format_i18n( $live ) ); ?></span>
     225                                                <a href="<?php echo esc_url( self::url( $screen['page'] ) ); ?>"<?php echo $key === $current ? ' class="is-current" aria-current="page"' : ''; ?>>
     226                                                        <?php echo esc_html( $screen['label'] ); ?>
     227                                                        <?php if ( isset( $screen['live'] ) ) : ?>
     228                                                                <span class="dealroot-appbar__live" data-dealroot-live-count<?php echo $screen['live'] > 0 ? '' : ' hidden'; ?>><?php echo esc_html( number_format_i18n( (int) $screen['live'] ) ); ?></span>
    358229                                                        <?php endif; ?>
    359                                                         <?php if ( $count > 0 ) : ?>
    360                                                                 <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( $count ) ); ?></span>
     230                                                        <?php if ( ! empty( $screen['count'] ) ) : ?>
     231                                                                <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( (int) $screen['count'] ) ); ?></span>
    361232                                                        <?php endif; ?>
    362233                                                </a>
    … …  
    366237                </nav>
    367238                <?php
    368                 $tabs = '' !== $active ? (array) ( $groups[ $active ] ?? array() ) : array();
    369 
    370                 if ( count( $tabs ) > 1 ) :
    371                         ?>
    372                         <nav class="dealroot-subnav" aria-label="<?php echo esc_attr( $labels[ $active ] ?? '' ); ?>">
    373                                 <?php foreach ( $tabs as $key => $screen ) : ?>
    374                                         <a href="<?php echo esc_url( self::url( $screen['page'] ) ); ?>"<?php echo $key === $current ? ' class="is-current" aria-current="page"' : ''; ?>>
    375                                                 <?php echo esc_html( $screen['label'] ); ?>
    376                                                 <?php if ( isset( $screen['live'] ) ) : ?>
    377                                                         <span class="dealroot-appbar__live" data-dealroot-live-count="always"><?php echo esc_html( number_format_i18n( (int) $screen['live'] ) ); ?></span>
    378                                                 <?php endif; ?>
    379                                                 <?php if ( ! empty( $screen['count'] ) ) : ?>
    380                                                         <span class="dealroot-appbar__count"><?php echo esc_html( number_format_i18n( (int) $screen['count'] ) ); ?></span>
    381                                                 <?php endif; ?>
    382                                         </a>
    383                                 <?php endforeach; ?>
    384                         </nav>
    385                         <?php
    386                 endif;
    387 
    388239                if ( 'live' !== $current && Live::enabled() ) {
    389240                        // The number next to "Live" stays current on the other screens too.
    390241                        wp_print_inline_script_tag(
    391242                                sprintf(
    392                                         '(function(){var b=document.querySelectorAll("[data-dealroot-live-count]");if(!b.length||!window.fetch){return;}function u(){if("hidden"===document.visibilityState){return;}var d=new URLSearchParams();d.append("action","dealroot_live_count");d.append("nonce",%1$s);fetch(%2$s,{method:"POST",credentials:"same-origin",body:d}).then(function(r){return r.json();}).then(function(r){if(r&&r.success){b.forEach(function(e){e.textContent=Number(r.data).toLocaleString();e.hidden=0===Number(r.data)&&"always"!==e.getAttribute("data-dealroot-live-count");});}}).catch(function(){});}setInterval(u,15000);document.addEventListener("visibilitychange",u);})();',
     243                                        '(function(){var b=document.querySelector("[data-dealroot-live-count]");if(!b||!window.fetch){return;}function u(){if("hidden"===document.visibilityState){return;}var d=new URLSearchParams();d.append("action","dealroot_live_count");d.append("nonce",%1$s);fetch(%2$s,{method:"POST",credentials:"same-origin",body:d}).then(function(r){return r.json();}).then(function(r){if(r&&r.success){b.textContent=Number(r.data).toLocaleString();b.hidden=0===Number(r.data);}}).catch(function(){});}setInterval(u,15000);document.addEventListener("visibilitychange",u);})();',
    393244                                        wp_json_encode( wp_create_nonce( 'dealroot_live_count' ) ),
    394245                                        wp_json_encode( admin_url( 'admin-ajax.php' ) )
  • dealroot/trunk/readme.txt

    r3831796 r3833010  
    55Tested up to: 7.2
    66Requires PHP: 7.4
    7 Stable tag: 1.1.4
     7Stable tag: 1.1.5
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    218218
    219219== Changelog ==
     220
     221= 1.1.5 =
     222* The bar at the top of the Dealroot screens shows every screen again, and the admin menu lists them all, as before 1.1.0. "All features" is the last tab of the bar.
    220223
    221224= 1.1.4 =
Note: See TracChangeset for help on using the changeset viewer.