Plugin Directory

Changeset 3353793


Ignore:
Timestamp:
09/01/2025 10:12:00 AM (3 months ago)
Author:
athemes
Message:

v1.1.1

Location:
athemes-blocks/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • athemes-blocks/trunk/athemes-blocks.php

    r3343697 r3353793  
    33 * Plugin Name:       aThemes Blocks
    44 * Description:       aThemes Blocks is a Gutenberg plugin extending the WordPress editor with awesome blocks.
    5  * Version:           1.1.0
     5 * Version:           1.1.1
    66 * Author:            aThemes
    77 * Author URI:        https://athemes.com
     
    2121use AThemes_Blocks\PluginLoader;
    2222
    23 define( 'ATHEMES_BLOCKS_VERSION', '1.1.0' );
     23define( 'ATHEMES_BLOCKS_VERSION', '1.1.1' );
    2424define( 'ATHEMES_BLOCKS_FILE', __FILE__ );
    2525define( 'ATHEMES_BLOCKS_PATH', plugin_dir_path( ATHEMES_BLOCKS_FILE ) );
  • athemes-blocks/trunk/includes/Admin/PluginDashboard/NotificationsSidebar.php

    r3343697 r3353793  
    5353        $this->notifications_pro = apply_filters( 'athemes_blocks_notifications_pro', array() );
    5454       
    55         $this->fetch_notifications();
     55        // Only fetch notifications if we're on the plugin dashboard page.
     56        if ( $this->is_plugin_dashboard_page() ) {
     57            $this->fetch_notifications();
     58        }
    5659
    5760        $this->init_hooks();
     61    }
     62
     63    /**
     64     * Check if current screen is the aThemes Blocks plugin dashboard.
     65     *
     66     * @return bool
     67     */
     68    private function is_plugin_dashboard_page(): bool {
     69        global $pagenow;
     70        return $pagenow === 'admin.php' && isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) === 'at-blocks';
    5871    }
    5972
     
    91104     */
    92105    public function enqueue_scripts(): void {
     106        if ( ! $this->is_plugin_dashboard_page() ) {
     107            return;
     108        }
     109       
    93110        wp_enqueue_style( 'athemes-blocks-dashboard-sidebar-notifications', ATHEMES_BLOCKS_URL . 'assets/css/admin/plugin-dashboard/sidebar-notifications.css', array(), ATHEMES_BLOCKS_VERSION );
    94111    }
     
    100117     */
    101118    public function add_internal_script(): void {
     119        if ( ! $this->is_plugin_dashboard_page() ) {
     120            return;
     121        }
     122       
    102123        ?>
    103124        <script>
     
    163184     */
    164185    private function fetch_notifications(): array {
     186        $cache_key = 'athemes_blocks_notifications';
     187       
     188        // Try to get cached notifications first.
     189        $cached_notifications = get_transient( $cache_key );
     190        if ( $cached_notifications !== false && is_array( $cached_notifications ) ) {
     191            $this->notifications = $cached_notifications;
     192            return $this->notifications;
     193        }
     194
     195        // Fetch fresh notifications.
    165196        $response = wp_remote_get( 'https://athemes.com/wp-json/wp/v2/notifications?theme=7112&per_page=3' );
    166         $this->notifications = ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ? json_decode( wp_remote_retrieve_body( $response ) ) : false;
    167 
    168         if ( ! $this->notifications ) {
    169             return array();
    170         }
    171 
     197       
     198        if ( ! is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) === 200 ) {
     199            $decoded_response = json_decode( wp_remote_retrieve_body( $response ) );
     200            $this->notifications = is_array( $decoded_response ) ? $decoded_response : array();
     201        } else {
     202            $this->notifications = array();
     203        }
     204
     205        // Cache the result for 1 hour if successful, 15 minutes if empty to prevent repeated failed requests.
     206        if ( ! empty( $this->notifications ) ) {
     207            set_transient( $cache_key, $this->notifications, HOUR_IN_SECONDS );
     208        } else {
     209            set_transient( $cache_key, array(), 15 * MINUTE_IN_SECONDS );
     210        }
     211       
    172212        return $this->notifications;
    173213    }
     
    184224       
    185225        $user_id                     = get_current_user_id();
    186         $user_read_meta              = get_user_meta( $user_id, 'athemes_blocks_dashboard_notifications_latest_read', true );
     226        $user_read_meta              = get_user_meta( $user_id, 'atb_dashboard_notifications_latest_read', true );
    187227
    188228        $last_notification_date      = strtotime( is_string( $this->notifications[0]->post_date ) ? $this->notifications[0]->post_date : '' );
     
    206246     */
    207247    public function render(): void {
    208         if ( ! $this->notifications ) {
     248        if ( ! $this->is_plugin_dashboard_page() || empty( $this->notifications ) ) {
    209249            return;
    210250        }
  • athemes-blocks/trunk/readme.txt

    r3344345 r3353793  
    44Tested up to: 6.6
    55Requires PHP: 5.6
    6 Stable tag: 1.1.0
     6Stable tag: 1.1.1
    77Contributors: aThemes
    88License: GPLv2 or later
     
    1212
    1313== Description ==
    14 = Essential Gutenberg Blocks Plugin with Powerful Blocks for Faster WordPress Websites – No Coding Required
     14== Essential Gutenberg Blocks Plugin with Powerful Blocks for Faster WordPress Websites – No Coding Required
    1515
    1616Transform your WordPress block editor experience with aThemes Gutenberg Blocks, featuring essential blocks designed for speed, performance, and professional results. Whether you're building with [Sydney](https://athemes.com/theme/sydney/), [Botiga](https://athemes.com/theme/botiga/), or any WordPress theme, our blocks help you create beautiful websites that load fast and convert better.
Note: See TracChangeset for help on using the changeset viewer.