Changeset 3496041
- Timestamp:
- 03/31/2026 10:35:11 PM (10 hours ago)
- Location:
- admin-code-search/trunk
- Files:
-
- 4 edited
-
admin-code-search.php (modified) (2 diffs)
-
includes/class-adcose-admin-page.php (modified) (12 diffs)
-
includes/class-adcose-scanner.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-code-search/trunk/admin-code-search.php
r3495290 r3496041 4 4 * Plugin URI: https://wordpress.org/plugins/admin-code-search/ 5 5 * Description: Search code inside active themes and plugins directly from the WordPress admin area. 6 * Version: 1. 1.06 * Version: 1.2.0 7 7 * Author: Marko Bakic 8 8 * License: GPL v2 or later … … 16 16 } 17 17 18 define( 'ADCOSE_VERSION', '1. 1.0' );18 define( 'ADCOSE_VERSION', '1.2.0' ); 19 19 define( 'ADCOSE_FILE', __FILE__ ); 20 20 define( 'ADCOSE_PATH', plugin_dir_path( __FILE__ ) ); -
admin-code-search/trunk/includes/class-adcose-admin-page.php
r3495290 r3496041 36 36 echo '<div class="wrap">'; 37 37 echo '<h1>' . esc_html__( 'Code Search', 'admin-code-search' ) . '</h1>'; 38 echo '<p>' . esc_html__( 'Search code inside active themes and plugins directly from the WordPress admin area.', 'admin-code-search' ) . '</p>';38 echo '<p>' . esc_html__( 'Search code inside active themes, MU plugins, and plugins directly from the WordPress admin area.', 'admin-code-search' ) . '</p>'; 39 39 40 40 $this->render_form( $data ); … … 50 50 $data['term'], 51 51 $data['summary'], 52 $data['case_sensitive'] 52 $data['case_sensitive'], 53 $data['match_mode'] 53 54 ); 54 55 } else { … … 71 72 'scan_plugins' => true, 72 73 'scan_themes' => true, 74 'scan_muplugins' => false, 73 75 'case_sensitive' => false, 76 'match_mode' => 'partial', 74 77 'submitted' => false, 75 78 'error' => '', … … 89 92 } 90 93 94 if ( isset( $_POST['match_mode'] ) ) { 95 $match_mode = sanitize_text_field( wp_unslash( $_POST['match_mode'] ) ); 96 $data['match_mode'] = in_array( $match_mode, array( 'partial', 'exact' ), true ) ? $match_mode : 'partial'; 97 } 98 91 99 $data['scan_plugins'] = isset( $_POST['scan_plugins'] ); 92 100 $data['scan_themes'] = isset( $_POST['scan_themes'] ); 101 $data['scan_muplugins'] = isset( $_POST['scan_muplugins'] ); 93 102 $data['case_sensitive'] = isset( $_POST['case_sensitive'] ); 94 103 … … 106 115 } 107 116 108 if ( ! $data['scan_plugins'] && ! $data['scan_themes'] ) {117 if ( ! $data['scan_plugins'] && ! $data['scan_themes'] && ! $data['scan_muplugins'] ) { 109 118 $data['error'] = __( 'Select at least one search location.', 'admin-code-search' ); 110 119 return $data; … … 113 122 $dirs = array(); 114 123 115 if ( $data['scan_plugins'] && defined( 'WP_PLUGIN_DIR' ) ) {124 if ( $data['scan_plugins'] && defined( 'WP_PLUGIN_DIR' ) && is_dir( WP_PLUGIN_DIR ) ) { 116 125 $dirs[] = wp_normalize_path( WP_PLUGIN_DIR ); 117 126 } … … 128 137 $dirs[] = $template_dir; 129 138 } 139 } 140 141 if ( $data['scan_muplugins'] && defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) { 142 $dirs[] = wp_normalize_path( WPMU_PLUGIN_DIR ); 130 143 } 131 144 … … 147 160 $extensions, 148 161 $exclude_names, 149 $data['case_sensitive'] 162 $data['case_sensitive'], 163 $data['match_mode'] 150 164 ); 151 165 … … 188 202 echo '<td>'; 189 203 echo '<label><input type="checkbox" name="scan_plugins" value="1" ' . checked( $data['scan_plugins'], true, false ) . '> ' . esc_html__( 'Plugins', 'admin-code-search' ) . '</label><br>'; 190 echo '<label><input type="checkbox" name="scan_themes" value="1" ' . checked( $data['scan_themes'], true, false ) . '> ' . esc_html__( 'Themes', 'admin-code-search' ) . '</label>'; 204 echo '<label><input type="checkbox" name="scan_themes" value="1" ' . checked( $data['scan_themes'], true, false ) . '> ' . esc_html__( 'Themes', 'admin-code-search' ) . '</label><br>'; 205 echo '<label><input type="checkbox" name="scan_muplugins" value="1" ' . checked( $data['scan_muplugins'], true, false ) . '> ' . esc_html__( 'MU Plugins', 'admin-code-search' ) . '</label>'; 191 206 echo '</td>'; 192 207 echo '</tr>'; … … 196 211 echo '<td>'; 197 212 echo '<label><input type="checkbox" name="case_sensitive" value="1" ' . checked( $data['case_sensitive'], true, false ) . '> ' . esc_html__( 'Case-sensitive search', 'admin-code-search' ) . '</label>'; 213 214 echo '<p style="margin-top:10px;">'; 215 echo '<strong>' . esc_html__( 'Match mode', 'admin-code-search' ) . '</strong><br>'; 216 echo '<label><input type="radio" name="match_mode" value="partial" ' . checked( $data['match_mode'], 'partial', false ) . '> ' . esc_html__( 'Partial match', 'admin-code-search' ) . '</label><br>'; 217 echo '<label><input type="radio" name="match_mode" value="exact" ' . checked( $data['match_mode'], 'exact', false ) . '> ' . esc_html__( 'Exact line match', 'admin-code-search' ) . '</label>'; 218 echo '</p>'; 198 219 echo '</td>'; 199 220 echo '</tr>'; … … 217 238 * @param array $summary Search summary. 218 239 * @param boolean $case_sensitive Whether search is case-sensitive. 219 * @return void 220 */ 221 private function render_results( $results, $term, $summary, $case_sensitive ) { 240 * @param string $match_mode Match mode. 241 * @return void 242 */ 243 private function render_results( $results, $term, $summary, $case_sensitive, $match_mode ) { 222 244 echo '<h2>' . esc_html__( 'Results', 'admin-code-search' ) . '</h2>'; 223 245 … … 235 257 ? esc_html__( 'Search mode: Case-sensitive.', 'admin-code-search' ) 236 258 : esc_html__( 'Search mode: Case-insensitive.', 'admin-code-search' ); 259 echo '</p>'; 260 261 echo '<p class="description">'; 262 echo 'exact' === $match_mode 263 ? esc_html__( 'Match mode: Exact line match.', 'admin-code-search' ) 264 : esc_html__( 'Match mode: Partial match.', 'admin-code-search' ); 237 265 echo '</p>'; 238 266 -
admin-code-search/trunk/includes/class-adcose-scanner.php
r3495290 r3496041 15 15 * @param array $exclude_names Excluded path fragments. 16 16 * @param boolean $case_sensitive Whether search is case-sensitive. 17 * @param string $match_mode Match mode: partial or exact. 17 18 * @return array 18 19 */ 19 public function scan( $dirs, $term, $extensions, $exclude_names, $case_sensitive = false ) {20 public function scan( $dirs, $term, $extensions, $exclude_names, $case_sensitive = false, $match_mode = 'partial' ) { 20 21 $results = array(); 21 22 $summary = array( … … 60 61 foreach ( $iterator as $file_info ) { 61 62 $file_path = $file_info->getPathname(); 62 $this->scan_file( $file_path, $term, $results, $summary, $case_sensitive );63 $this->scan_file( $file_path, $term, $results, $summary, $case_sensitive, $match_mode ); 63 64 } 64 65 } … … 81 82 * @param array $summary Summary array by reference. 82 83 * @param boolean $case_sensitive Whether search is case-sensitive. 84 * @param string $match_mode Match mode: partial or exact. 83 85 * @return void 84 86 */ 85 private function scan_file( $file_path, $term, &$results, &$summary, $case_sensitive = false ) {87 private function scan_file( $file_path, $term, &$results, &$summary, $case_sensitive = false, $match_mode = 'partial' ) { 86 88 try { 87 89 if ( ! is_readable( $file_path ) ) { … … 100 102 while ( false !== ( $line = fgets( $handle ) ) ) { 101 103 $line_number++; 104 $line_to_check = rtrim( $line, "\r\n" ); 102 105 103 $is_match = $case_sensitive 104 ? false !== strpos( $line, $term ) 105 : false !== stripos( $line, $term ); 106 if ( 'exact' === $match_mode ) { 107 $left = trim( $line_to_check ); 108 $right = trim( $term ); 109 110 $is_match = $case_sensitive 111 ? $left === $right 112 : strtolower( $left ) === strtolower( $right ); 113 } else { 114 $is_match = $case_sensitive 115 ? false !== strpos( $line_to_check, $term ) 116 : false !== stripos( $line_to_check, $term ); 117 } 106 118 107 119 if ( $is_match ) { 108 120 $results[ $file_path ][] = array( 109 121 'line' => $line_number, 110 'text' => rtrim( $line, "\r\n" ),122 'text' => $line_to_check, 111 123 ); 112 124 -
admin-code-search/trunk/readme.txt
r3495290 r3496041 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 1.07 Stable tag: 1.2.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Search code inside active themes and plugins directly from the WordPress admin area.11 Search code across active plugins, themes, and MU plugins directly from the WordPress admin. 12 12 13 13 == Description == 14 14 15 Admin Code Search is a lightweight developer utility that lets you search code inside active themes and plugins directly from the WordPress admin. Designed for developers who need quick insight into code without leaving wp-admin.15 Admin Code Search is a lightweight developer tool that lets you search code directly from the WordPress admin area — no FTP or terminal access required. 16 16 17 Useful when you need to quickly locate a function, hook, class, or string without leaving the dashboard or accessing files via FTP or IDE.17 It scans active plugins, themes, and MU plugins line-by-line and shows matching results with file paths and line numbers. 18 18 19 Features: 20 - Admin-only access 21 - Search across active plugins 22 - Search active theme (including parent theme) 23 - Support for custom file extensions 24 - Line-by-line results 25 - Highlighted matches 26 - Clean, readable results table 19 Designed for quick debugging, code tracing, and locating specific hooks, functions, or strings across a site. 20 21 A simple, fast code search tool for developers working inside WordPress. 22 23 == Features == 24 25 - Search inside active plugins, themes, and MU plugins 26 - Case-sensitive or case-insensitive search 27 - Partial match or exact line match 28 - Custom file extensions (e.g. php, js, css) 29 - Line-by-line scanning for better performance on large codebases 30 - Displays file path, line number, and highlighted match 31 - Excludes common heavy directories (vendor, node_modules, uploads, cache, .git, .svn) 32 - Admin-only access for security 33 34 == Typical Use Cases == 35 36 - Locate where a function or hook is defined 37 - Find all occurrences of a specific string 38 - Debug custom integrations or third-party plugins 39 - Quickly explore unfamiliar codebases without leaving wp-admin 40 41 == Notes == 42 43 Large searches may take longer on sites with many plugins or large codebases. Results are processed in real time. 27 44 28 45 = Privacy = … … 40 57 41 58 = Who can use this plugin? = 42 43 59 Only administrators or users with the `manage_options` capability. 44 60 45 61 = What files are searched? = 62 The plugin scans active plugin files, the active theme, the parent theme (if different), and MU plugins. 46 63 47 The plugin searches files in active plugins, the active theme, and the parent theme (if used). 48 Inactive plugins and themes are not included.64 = What is the difference between partial match and exact line match? = 65 Partial match finds the search term anywhere within a line. Exact line match only returns results where the entire trimmed line exactly matches the search term. 49 66 50 67 = Can I search file types other than PHP? = 68 Yes. You can enter comma-separated extensions such as `php,js,css,inc`. 51 69 52 Yes. You can define custom file extensions (for example: php, js, css, inc). 70 = Will this affect site performance? = 71 Search runs on demand and only when triggered by an admin. On very large sites, searches may take a few seconds. 53 72 54 = Does this affect site performance? = 73 = Does it search WordPress core files? = 74 No. The plugin is limited to plugins, themes, and MU plugins. 55 75 56 Search runs only when you perform it manually in the admin. 57 It does not run in the background or affect frontend performance. 58 59 = Does this plugin modify any files? = 60 61 No. The plugin is read-only and does not change any files. 62 63 = Is any data sent outside my site? = 64 65 No. All searches are performed locally on your server. 76 = Is this plugin safe to use on production sites? = 77 Yes. It is read-only and does not modify any files or data. 66 78 67 79 == Screenshots == … … 74 86 == Changelog == 75 87 88 = 1.2.0 = 89 * Added partial match and exact line match options. 90 * Added MU Plugins scanning option. 91 * Improved search controls for better precision. 92 76 93 = 1.1.0 = 77 94 * Added case-sensitive search option.
Note: See TracChangeset
for help on using the changeset viewer.