Changeset 3353793
- Timestamp:
- 09/01/2025 10:12:00 AM (3 months ago)
- Location:
- athemes-blocks/trunk
- Files:
-
- 3 edited
-
athemes-blocks.php (modified) (2 diffs)
-
includes/Admin/PluginDashboard/NotificationsSidebar.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
athemes-blocks/trunk/athemes-blocks.php
r3343697 r3353793 3 3 * Plugin Name: aThemes Blocks 4 4 * Description: aThemes Blocks is a Gutenberg plugin extending the WordPress editor with awesome blocks. 5 * Version: 1.1. 05 * Version: 1.1.1 6 6 * Author: aThemes 7 7 * Author URI: https://athemes.com … … 21 21 use AThemes_Blocks\PluginLoader; 22 22 23 define( 'ATHEMES_BLOCKS_VERSION', '1.1. 0' );23 define( 'ATHEMES_BLOCKS_VERSION', '1.1.1' ); 24 24 define( 'ATHEMES_BLOCKS_FILE', __FILE__ ); 25 25 define( 'ATHEMES_BLOCKS_PATH', plugin_dir_path( ATHEMES_BLOCKS_FILE ) ); -
athemes-blocks/trunk/includes/Admin/PluginDashboard/NotificationsSidebar.php
r3343697 r3353793 53 53 $this->notifications_pro = apply_filters( 'athemes_blocks_notifications_pro', array() ); 54 54 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 } 56 59 57 60 $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'; 58 71 } 59 72 … … 91 104 */ 92 105 public function enqueue_scripts(): void { 106 if ( ! $this->is_plugin_dashboard_page() ) { 107 return; 108 } 109 93 110 wp_enqueue_style( 'athemes-blocks-dashboard-sidebar-notifications', ATHEMES_BLOCKS_URL . 'assets/css/admin/plugin-dashboard/sidebar-notifications.css', array(), ATHEMES_BLOCKS_VERSION ); 94 111 } … … 100 117 */ 101 118 public function add_internal_script(): void { 119 if ( ! $this->is_plugin_dashboard_page() ) { 120 return; 121 } 122 102 123 ?> 103 124 <script> … … 163 184 */ 164 185 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. 165 196 $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 172 212 return $this->notifications; 173 213 } … … 184 224 185 225 $user_id = get_current_user_id(); 186 $user_read_meta = get_user_meta( $user_id, 'at hemes_blocks_dashboard_notifications_latest_read', true );226 $user_read_meta = get_user_meta( $user_id, 'atb_dashboard_notifications_latest_read', true ); 187 227 188 228 $last_notification_date = strtotime( is_string( $this->notifications[0]->post_date ) ? $this->notifications[0]->post_date : '' ); … … 206 246 */ 207 247 public function render(): void { 208 if ( ! $this-> notifications) {248 if ( ! $this->is_plugin_dashboard_page() || empty( $this->notifications ) ) { 209 249 return; 210 250 } -
athemes-blocks/trunk/readme.txt
r3344345 r3353793 4 4 Tested up to: 6.6 5 5 Requires PHP: 5.6 6 Stable tag: 1.1. 06 Stable tag: 1.1.1 7 7 Contributors: aThemes 8 8 License: GPLv2 or later … … 12 12 13 13 == Description == 14 = Essential Gutenberg Blocks Plugin with Powerful Blocks for Faster WordPress Websites – No Coding Required14 == Essential Gutenberg Blocks Plugin with Powerful Blocks for Faster WordPress Websites – No Coding Required 15 15 16 16 Transform 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.