Plugin Directory

Changeset 3496041


Ignore:
Timestamp:
03/31/2026 10:35:11 PM (10 hours ago)
Author:
marbak
Message:

Update to v1.2.0

Location:
admin-code-search/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin-code-search/trunk/admin-code-search.php

    r3495290 r3496041  
    44 * Plugin URI: https://wordpress.org/plugins/admin-code-search/
    55 * Description: Search code inside active themes and plugins directly from the WordPress admin area.
    6  * Version: 1.1.0
     6 * Version: 1.2.0
    77 * Author: Marko Bakic
    88 * License: GPL v2 or later
     
    1616}
    1717
    18 define( 'ADCOSE_VERSION', '1.1.0' );
     18define( 'ADCOSE_VERSION', '1.2.0' );
    1919define( 'ADCOSE_FILE', __FILE__ );
    2020define( 'ADCOSE_PATH', plugin_dir_path( __FILE__ ) );
  • admin-code-search/trunk/includes/class-adcose-admin-page.php

    r3495290 r3496041  
    3636        echo '<div class="wrap">';
    3737        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>';
    3939
    4040        $this->render_form( $data );
     
    5050                    $data['term'],
    5151                    $data['summary'],
    52                     $data['case_sensitive']
     52                    $data['case_sensitive'],
     53                    $data['match_mode']
    5354                );
    5455            } else {
     
    7172            'scan_plugins'   => true,
    7273            'scan_themes'    => true,
     74            'scan_muplugins' => false,
    7375            'case_sensitive' => false,
     76            'match_mode'     => 'partial',
    7477            'submitted'      => false,
    7578            'error'          => '',
     
    8992        }
    9093
     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
    9199        $data['scan_plugins']   = isset( $_POST['scan_plugins'] );
    92100        $data['scan_themes']    = isset( $_POST['scan_themes'] );
     101        $data['scan_muplugins'] = isset( $_POST['scan_muplugins'] );
    93102        $data['case_sensitive'] = isset( $_POST['case_sensitive'] );
    94103
     
    106115        }
    107116
    108         if ( ! $data['scan_plugins'] && ! $data['scan_themes'] ) {
     117        if ( ! $data['scan_plugins'] && ! $data['scan_themes'] && ! $data['scan_muplugins'] ) {
    109118            $data['error'] = __( 'Select at least one search location.', 'admin-code-search' );
    110119            return $data;
     
    113122        $dirs = array();
    114123
    115         if ( $data['scan_plugins'] && defined( 'WP_PLUGIN_DIR' ) ) {
     124        if ( $data['scan_plugins'] && defined( 'WP_PLUGIN_DIR' ) && is_dir( WP_PLUGIN_DIR ) ) {
    116125            $dirs[] = wp_normalize_path( WP_PLUGIN_DIR );
    117126        }
     
    128137                $dirs[] = $template_dir;
    129138            }
     139        }
     140
     141        if ( $data['scan_muplugins'] && defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
     142            $dirs[] = wp_normalize_path( WPMU_PLUGIN_DIR );
    130143        }
    131144
     
    147160            $extensions,
    148161            $exclude_names,
    149             $data['case_sensitive']
     162            $data['case_sensitive'],
     163            $data['match_mode']
    150164        );
    151165
     
    188202        echo '<td>';
    189203        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>';
    191206        echo '</td>';
    192207        echo '</tr>';
     
    196211        echo '<td>';
    197212        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>';
    198219        echo '</td>';
    199220        echo '</tr>';
     
    217238     * @param array   $summary        Search summary.
    218239     * @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 ) {
    222244        echo '<h2>' . esc_html__( 'Results', 'admin-code-search' ) . '</h2>';
    223245
     
    235257            ? esc_html__( 'Search mode: Case-sensitive.', 'admin-code-search' )
    236258            : 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' );
    237265        echo '</p>';
    238266
  • admin-code-search/trunk/includes/class-adcose-scanner.php

    r3495290 r3496041  
    1515     * @param array   $exclude_names  Excluded path fragments.
    1616     * @param boolean $case_sensitive Whether search is case-sensitive.
     17     * @param string  $match_mode     Match mode: partial or exact.
    1718     * @return array
    1819     */
    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' ) {
    2021        $results = array();
    2122        $summary = array(
     
    6061            foreach ( $iterator as $file_info ) {
    6162                $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 );
    6364            }
    6465        }
     
    8182     * @param array   $summary        Summary array by reference.
    8283     * @param boolean $case_sensitive Whether search is case-sensitive.
     84     * @param string  $match_mode     Match mode: partial or exact.
    8385     * @return void
    8486     */
    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' ) {
    8688        try {
    8789            if ( ! is_readable( $file_path ) ) {
     
    100102            while ( false !== ( $line = fgets( $handle ) ) ) {
    101103                $line_number++;
     104                $line_to_check = rtrim( $line, "\r\n" );
    102105
    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                }
    106118
    107119                if ( $is_match ) {
    108120                    $results[ $file_path ][] = array(
    109121                        'line' => $line_number,
    110                         'text' => rtrim( $line, "\r\n" ),
     122                        'text' => $line_to_check,
    111123                    );
    112124
  • admin-code-search/trunk/readme.txt

    r3495290 r3496041  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.1.0
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Search code inside active themes and plugins directly from the WordPress admin area.
     11Search code across active plugins, themes, and MU plugins directly from the WordPress admin.
    1212
    1313== Description ==
    1414
    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.
     15Admin Code Search is a lightweight developer tool that lets you search code directly from the WordPress admin area — no FTP or terminal access required.
    1616
    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.
     17It scans active plugins, themes, and MU plugins line-by-line and shows matching results with file paths and line numbers.
    1818
    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
     19Designed for quick debugging, code tracing, and locating specific hooks, functions, or strings across a site.
     20
     21A 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
     43Large searches may take longer on sites with many plugins or large codebases. Results are processed in real time.
    2744
    2845= Privacy =
     
    4057
    4158= Who can use this plugin? =
    42 
    4359Only administrators or users with the `manage_options` capability.
    4460
    4561= What files are searched? =
     62The plugin scans active plugin files, the active theme, the parent theme (if different), and MU plugins.
    4663
    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? =
     65Partial 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.
    4966
    5067= Can I search file types other than PHP? =
     68Yes. You can enter comma-separated extensions such as `php,js,css,inc`.
    5169
    52 Yes. You can define custom file extensions (for example: php, js, css, inc).
     70= Will this affect site performance? =
     71Search runs on demand and only when triggered by an admin. On very large sites, searches may take a few seconds.
    5372
    54 = Does this affect site performance? =
     73= Does it search WordPress core files? =
     74No. The plugin is limited to plugins, themes, and MU plugins.
    5575
    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? =
     77Yes. It is read-only and does not modify any files or data.
    6678
    6779== Screenshots ==
     
    7486== Changelog ==
    7587
     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
    7693= 1.1.0 =
    7794* Added case-sensitive search option.
Note: See TracChangeset for help on using the changeset viewer.