Changeset 3155289
- Timestamp:
- 09/20/2024 04:06:55 PM (18 months ago)
- Location:
- topic
- Files:
-
- 29 added
- 2 edited
-
tags/1.0.29 (added)
-
tags/1.0.29/api (added)
-
tags/1.0.29/api/usetopicapi.php (added)
-
tags/1.0.29/assets (added)
-
tags/1.0.29/assets/banner-1544x500.png (added)
-
tags/1.0.29/assets/banner-772x250.png (added)
-
tags/1.0.29/assets/icon-128x128.png (added)
-
tags/1.0.29/assets/icon-256x256.png (added)
-
tags/1.0.29/assets/icon.svg (added)
-
tags/1.0.29/assets/screenshot-1.png (added)
-
tags/1.0.29/assets/screenshot-2.png (added)
-
tags/1.0.29/build (added)
-
tags/1.0.29/build/index-classic.4c8966e0.asset.php (added)
-
tags/1.0.29/build/index-classic.ca720ed5.js (added)
-
tags/1.0.29/build/index-classic.css (added)
-
tags/1.0.29/build/index.c118109a.asset.php (added)
-
tags/1.0.29/build/index.c94eadac.js (added)
-
tags/1.0.29/build/index.css (added)
-
tags/1.0.29/classic-editor (added)
-
tags/1.0.29/classic-editor/classic.css (added)
-
tags/1.0.29/classic-editor/fonts (added)
-
tags/1.0.29/classic-editor/fonts/Times.woff (added)
-
tags/1.0.29/classic-editor/fonts/Verdana.woff (added)
-
tags/1.0.29/index.php (added)
-
tags/1.0.29/readme.txt (added)
-
trunk/build/index-classic.4c8966e0.asset.php (added)
-
trunk/build/index-classic.ca720ed5.js (added)
-
trunk/build/index.c118109a.asset.php (added)
-
trunk/build/index.c94eadac.js (added)
-
trunk/index.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
topic/trunk/index.php
r3153093 r3155289 7 7 * License: GPL v2 or later 8 8 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 9 * Version: 1.0.2 89 * Version: 1.0.29 10 10 */ 11 11 if( ! defined( 'ABSPATH') ) { … … 39 39 } 40 40 41 /** 42 * Function to find the file path for index.[hash].js or index-classic.[hash].js 43 * @param string $filePattern - The file pattern to search for (e.g., 'index' or 'index-classic') 44 * @param string $directory - The directory where the build files are located 45 * @return string|null - Returns the full file path or null if not found 46 */ 47 public function getHashedFilePath($filePattern, $directory = 'build') { 48 // Get the full path to the plugin directory 49 $plugin_dir = plugin_dir_path(__FILE__); 50 $full_directory_path = $plugin_dir . $directory; 51 52 if (!is_dir($full_directory_path)) { 53 return null; 54 } 55 56 // Define the regex pattern to match files like index.[hash].js or index-classic.[hash].js 57 $pattern = sprintf('/^%s\.[a-f0-9]{8}\.js$/', preg_quote($filePattern, '/')); 58 59 // Scan the directory for files 60 $files = scandir($full_directory_path); 61 62 // Iterate through the files to find a match 63 foreach ($files as $file) { 64 if (preg_match($pattern, $file)) { 65 // Return the relative path of the matched file 66 return $directory . '/' . $file; 67 } 68 } 69 70 // If no match was found, return null 71 return null; 72 } 73 41 74 public function topic_enqueue_assets() { 42 wp_enqueue_script( 43 'topic-gutenberg-sidebar', 44 plugins_url( 'build/index.js', __FILE__ ), 45 array( 'wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element' ) 46 ); 47 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(), 'all'); 75 $index_file_path = $this->getHashedFilePath('index'); 76 if ($index_file_path === null) { 77 $index_file_path = 'build/index.js'; 78 } 79 wp_enqueue_script( 80 'topic-gutenberg-sidebar', 81 plugins_url( $index_file_path, __FILE__ ), 82 array( 'wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element' ), 83 null 84 ); 85 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), 'all'); 48 86 } 49 87 50 88 public function topic_enqueue_assets_classic() { 89 $index_file_path = $this->getHashedFilePath('index-classic'); 90 if ($index_file_path === null) { 91 $index_file_path = 'build/index-classic.js'; 92 } 51 93 wp_enqueue_script( 52 94 'topic-gutenberg-sidebar-classic', 53 plugins_url( 'build/index-classic.js', __FILE__ ), array('wp-plugins'), time(), true95 plugins_url( $index_file_path , __FILE__ ), array('wp-plugins'), null 54 96 ); 55 wp_enqueue_style('topic-classic-sidebar', plugins_url( 'classic-editor/classic.css', __FILE__ ), array(), time(),'all');56 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), time(),'all');97 wp_enqueue_style('topic-classic-sidebar', plugins_url( 'classic-editor/classic.css', __FILE__ ), array(), 'all'); 98 wp_enqueue_style('topic-sidebar-global', plugins_url( 'build/index.css', __FILE__ ), array(), 'all'); 57 99 } 58 100 -
topic/trunk/readme.txt
r3153093 r3155289 84 84 85 85 == Changelog == 86 = 1.0.29 = 87 Release Date: SEP 25, 2024 88 Cache Busting Mechanism 89 86 90 = 1.0.28 = 87 91 Release Date: SEP 12, 2024
Note: See TracChangeset
for help on using the changeset viewer.