Plugin Directory

Changeset 3493744


Ignore:
Timestamp:
03/29/2026 08:38:49 AM (3 days ago)
Author:
amitbiswas06
Message:

Release version 1.1.0: Admin new responses indicator + highlighting

Location:
plugiva-pulse
Files:
11 edited
10 copied

Legend:

Unmodified
Added
Removed
  • plugiva-pulse/tags/1.1.0/admin/class-admin.php

    r3464907 r3493744  
    1515        Pulses_Page::init();
    1616        Responses_Page::init();
     17
     18        // @since 1.1.0
     19        add_action( 'admin_menu', [ __CLASS__, 'maybe_add_responses_bubble' ], 99 );
     20        add_action( 'admin_head', [ __CLASS__, 'add_admin_styles' ] );
    1721    }
     22
     23    /**
     24     * Maybe add responses bubble to admin menu.
     25     *
     26     * @return void
     27     * @since 1.1.0
     28     */
     29    public static function maybe_add_responses_bubble(): void {
     30
     31        // Get last seen (or fallback to now)
     32        $last_seen = get_option( 'ppls_last_seen_responses', '' );
     33
     34        if ( empty( $last_seen ) ) {
     35            // $last_seen = current_time( 'mysql' );
     36            $last_seen = '2000-01-01 00:00:00';
     37        }
     38
     39        // Get new responses count
     40        $count = \Plugiva\Pulse\Pulses::get_new_responses_count( $last_seen );
     41
     42        if ( $count <= 0 ) {
     43            return;
     44        }
     45
     46        global $menu;
     47
     48        foreach ( $menu as $key => $item ) {
     49
     50            if ( isset( $item[2] ) && $item[2] === 'ppls-pulses' ) {
     51
     52                $menu[$key][0] .= ' <span class="update-plugins count-' . esc_attr( $count ) . '">
     53                    <span class="plugin-count">' . esc_html( $count ) . '</span>
     54                </span>';
     55
     56                break;
     57            }
     58        }
     59    }
     60
     61    /**
     62     * Add admin styles.
     63     *
     64     * @return void
     65     * @since 1.1.0
     66     */
     67    public static function add_admin_styles(): void {
     68        ?>
     69        <style>
     70            .wp-list-table.responses > tbody > tr.ppls-row-new {
     71                background-color: #fff8e5;
     72            }
     73        </style>
     74        <?php
     75    }
     76
    1877}
  • plugiva-pulse/tags/1.1.0/admin/class-responses-page.php

    r3464907 r3493744  
    3131        $table = new Responses_Table();
    3232        $table->prepare_items();
     33
     34        // Mark responses as seen AFTER rendering logic.
     35        // @since 1.1.0
     36        update_option( 'ppls_last_seen_responses', current_time( 'mysql' ) );
    3337
    3438        require PPLS_PATH . 'admin/views/responses-page.php';
  • plugiva-pulse/tags/1.1.0/admin/class-responses-table.php

    r3464907 r3493744  
    2121     */
    2222    private const TABLE = 'ppls_responses';
     23
     24    /**
     25     * Last seen datetime.
     26     *
     27     * @var string
     28     * @since 1.1.0
     29     */
     30    protected $last_seen;
    2331
    2432    /**
     
    3341            ]
    3442        );
     43
     44        // update the responses seen option
     45        // @since 1.1.0
     46        $this->last_seen = get_option( 'ppls_last_seen_responses', '' );
     47
     48        if ( empty( $this->last_seen ) ) {
     49            $this->last_seen = current_time( 'mysql' );
     50        }
     51    }
     52
     53    /**
     54     * Render a single row.
     55     *
     56     * @param array $item
     57     * @return void
     58     * @since 1.1.0
     59     */
     60    public function single_row( $item ) {
     61
     62        $created_at = $item['created_at'] ?? '';
     63
     64        $is_new = ( ! empty( $created_at ) && $created_at > $this->last_seen );
     65
     66        $class = $is_new ? 'ppls-row-new' : '';
     67
     68        echo '<tr class="' . esc_attr( $class ) . '">';
     69        $this->single_row_columns( $item );
     70        echo '</tr>';
    3571    }
    3672
  • plugiva-pulse/tags/1.1.0/includes/class-pulses.php

    r3464907 r3493744  
    1515
    1616    const OPTION_KEY = 'ppls_pulses';
     17
     18    /**
     19     * Get count of new responses since last seen datetime.
     20     *
     21     * @param string $last_seen MySQL datetime string.
     22     * @return int
     23     * @since 1.1.0
     24     */
     25    public static function get_new_responses_count( string $last_seen ): int {
     26        global $wpdb;
     27
     28        $table = $wpdb->prefix . 'ppls_responses';
     29
     30        return (int) $wpdb->get_var(
     31            $wpdb->prepare(
     32                "SELECT COUNT(*) FROM {$table} WHERE created_at > %s",
     33                $last_seen
     34            )
     35        );
     36    }
     37
    1738
    1839    /**
  • plugiva-pulse/tags/1.1.0/plugiva-pulse.php

    r3464907 r3493744  
    33 * Plugin Name: Plugiva Pulse
    44 * Description: Create lightweight feedback forms and quick polls with yes/no, emoji, and text responses inside WordPress.
    5  * Version:     1.0.0
     5 * Version:     1.1.0
    66 * Author:      Plugiva
    77 * Author URI:  https://plugiva.com
     
    1616}
    1717
    18 define( 'PPLS_VERSION', '1.0.0' );
     18define( 'PPLS_VERSION', '1.1.0' );
    1919define( 'PPLS_PATH', plugin_dir_path( __FILE__ ) );
    2020define( 'PPLS_URL', plugin_dir_url( __FILE__ ) );
  • plugiva-pulse/tags/1.1.0/readme.txt

    r3464907 r3493744  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2626* Admin responses table with pagination
    2727* Bulk delete responses
     28* See new responses instantly with admin notification bubble
    2829* CSV export of collected responses
    2930* Clean uninstall (optional data removal)
     
    7980== Changelog ==
    8081
     82= 1.1.0 =
     83* New: Admin "New Responses" bubble in menu
     84* New: Highlight new responses in admin table
     85* Improved: Better visibility of incoming feedback
     86
    8187= 1.0.0 =
    8288* Initial release
  • plugiva-pulse/tags/1.1.0/uninstall.php

    r3464907 r3493744  
    2828delete_option( 'ppls_pulses' );
    2929delete_option( 'ppls_cleanup_on_uninstall' );
     30// @since 1.1.0
     31delete_option( 'ppls_last_seen_responses' );
  • plugiva-pulse/trunk/admin/class-admin.php

    r3464907 r3493744  
    1515        Pulses_Page::init();
    1616        Responses_Page::init();
     17
     18        // @since 1.1.0
     19        add_action( 'admin_menu', [ __CLASS__, 'maybe_add_responses_bubble' ], 99 );
     20        add_action( 'admin_head', [ __CLASS__, 'add_admin_styles' ] );
    1721    }
     22
     23    /**
     24     * Maybe add responses bubble to admin menu.
     25     *
     26     * @return void
     27     * @since 1.1.0
     28     */
     29    public static function maybe_add_responses_bubble(): void {
     30
     31        // Get last seen (or fallback to now)
     32        $last_seen = get_option( 'ppls_last_seen_responses', '' );
     33
     34        if ( empty( $last_seen ) ) {
     35            // $last_seen = current_time( 'mysql' );
     36            $last_seen = '2000-01-01 00:00:00';
     37        }
     38
     39        // Get new responses count
     40        $count = \Plugiva\Pulse\Pulses::get_new_responses_count( $last_seen );
     41
     42        if ( $count <= 0 ) {
     43            return;
     44        }
     45
     46        global $menu;
     47
     48        foreach ( $menu as $key => $item ) {
     49
     50            if ( isset( $item[2] ) && $item[2] === 'ppls-pulses' ) {
     51
     52                $menu[$key][0] .= ' <span class="update-plugins count-' . esc_attr( $count ) . '">
     53                    <span class="plugin-count">' . esc_html( $count ) . '</span>
     54                </span>';
     55
     56                break;
     57            }
     58        }
     59    }
     60
     61    /**
     62     * Add admin styles.
     63     *
     64     * @return void
     65     * @since 1.1.0
     66     */
     67    public static function add_admin_styles(): void {
     68        ?>
     69        <style>
     70            .wp-list-table.responses > tbody > tr.ppls-row-new {
     71                background-color: #fff8e5;
     72            }
     73        </style>
     74        <?php
     75    }
     76
    1877}
  • plugiva-pulse/trunk/admin/class-responses-page.php

    r3464907 r3493744  
    3131        $table = new Responses_Table();
    3232        $table->prepare_items();
     33
     34        // Mark responses as seen AFTER rendering logic.
     35        // @since 1.1.0
     36        update_option( 'ppls_last_seen_responses', current_time( 'mysql' ) );
    3337
    3438        require PPLS_PATH . 'admin/views/responses-page.php';
  • plugiva-pulse/trunk/admin/class-responses-table.php

    r3464907 r3493744  
    2121     */
    2222    private const TABLE = 'ppls_responses';
     23
     24    /**
     25     * Last seen datetime.
     26     *
     27     * @var string
     28     * @since 1.1.0
     29     */
     30    protected $last_seen;
    2331
    2432    /**
     
    3341            ]
    3442        );
     43
     44        // update the responses seen option
     45        // @since 1.1.0
     46        $this->last_seen = get_option( 'ppls_last_seen_responses', '' );
     47
     48        if ( empty( $this->last_seen ) ) {
     49            $this->last_seen = current_time( 'mysql' );
     50        }
     51    }
     52
     53    /**
     54     * Render a single row.
     55     *
     56     * @param array $item
     57     * @return void
     58     * @since 1.1.0
     59     */
     60    public function single_row( $item ) {
     61
     62        $created_at = $item['created_at'] ?? '';
     63
     64        $is_new = ( ! empty( $created_at ) && $created_at > $this->last_seen );
     65
     66        $class = $is_new ? 'ppls-row-new' : '';
     67
     68        echo '<tr class="' . esc_attr( $class ) . '">';
     69        $this->single_row_columns( $item );
     70        echo '</tr>';
    3571    }
    3672
  • plugiva-pulse/trunk/includes/class-pulses.php

    r3464907 r3493744  
    1515
    1616    const OPTION_KEY = 'ppls_pulses';
     17
     18    /**
     19     * Get count of new responses since last seen datetime.
     20     *
     21     * @param string $last_seen MySQL datetime string.
     22     * @return int
     23     * @since 1.1.0
     24     */
     25    public static function get_new_responses_count( string $last_seen ): int {
     26        global $wpdb;
     27
     28        $table = $wpdb->prefix . 'ppls_responses';
     29
     30        return (int) $wpdb->get_var(
     31            $wpdb->prepare(
     32                "SELECT COUNT(*) FROM {$table} WHERE created_at > %s",
     33                $last_seen
     34            )
     35        );
     36    }
     37
    1738
    1839    /**
  • plugiva-pulse/trunk/plugiva-pulse.php

    r3464907 r3493744  
    33 * Plugin Name: Plugiva Pulse
    44 * Description: Create lightweight feedback forms and quick polls with yes/no, emoji, and text responses inside WordPress.
    5  * Version:     1.0.0
     5 * Version:     1.1.0
    66 * Author:      Plugiva
    77 * Author URI:  https://plugiva.com
     
    1616}
    1717
    18 define( 'PPLS_VERSION', '1.0.0' );
     18define( 'PPLS_VERSION', '1.1.0' );
    1919define( 'PPLS_PATH', plugin_dir_path( __FILE__ ) );
    2020define( 'PPLS_URL', plugin_dir_url( __FILE__ ) );
  • plugiva-pulse/trunk/readme.txt

    r3464907 r3493744  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2626* Admin responses table with pagination
    2727* Bulk delete responses
     28* See new responses instantly with admin notification bubble
    2829* CSV export of collected responses
    2930* Clean uninstall (optional data removal)
     
    7980== Changelog ==
    8081
     82= 1.1.0 =
     83* New: Admin "New Responses" bubble in menu
     84* New: Highlight new responses in admin table
     85* Improved: Better visibility of incoming feedback
     86
    8187= 1.0.0 =
    8288* Initial release
  • plugiva-pulse/trunk/uninstall.php

    r3464907 r3493744  
    2828delete_option( 'ppls_pulses' );
    2929delete_option( 'ppls_cleanup_on_uninstall' );
     30// @since 1.1.0
     31delete_option( 'ppls_last_seen_responses' );
Note: See TracChangeset for help on using the changeset viewer.