String locator - Version 2.1.2

Version Description

  • Fix for max execution times some times being interpreted as strings and failing when you it should be able to run indefinitely
  • Fix for regex being enabled when you return to the search results, but you hadn't performed a regex search
  • Resolved some code issues with functions being called improperly (future proofing)
Download this release

Release Info

Developer Clorith
Plugin Icon 128x128 String locator
Version 2.1.2
Comparing to
See all releases

Code changes from version 2.1.1 to 2.1.2

Files changed (4) hide show
  1. changelog.txt +18 -0
  2. options.php +54 -54
  3. readme.txt +6 -19
  4. string-locator.php +25 -19
changelog.txt CHANGED
@@ -1,3 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  = 1.9.1 =
2
  * Fixes a regression relating to support for older versions of PHP introduced in 1.9.0
3
 
1
+ = 2.0.3 =
2
+ * Added support for HHVM
3
+ * Improved inline documentation
4
+
5
+ = 2.0.2 =
6
+ * Fixed max memory indicators on hosts that do not use shorthands
7
+
8
+ = 2.0.1 =
9
+ * Fixed a bug where heavy sites would not run searches due to incorrect memory consumption calculations
10
+ * Fixed a visual bug when warnings are displayed
11
+ * Added error feedback if high execution times or memory consumption is detected before a search is started
12
+
13
+ = 2.0.0 =
14
+ * Performance enhancement, now also detects memory consumption to avoid exceeding memory limits
15
+ * Fixed a warning incorrectly being shown saying files cannot be read
16
+ * Better feedback during the search process
17
+ * Fixed a longstanding bug with searching single file plugins
18
+
19
  = 1.9.1 =
20
  * Fixes a regression relating to support for older versions of PHP introduced in 1.9.0
21
 
options.php CHANGED
@@ -1,73 +1,73 @@
1
  <?php
2
- $this_url = admin_url( ( is_multisite() ? 'network/admin.php' : 'tools.php' ) . '?page=string-locator' );
3
 
4
- $search_string = '';
5
- $search_location = '';
6
- $search_regex = false;
7
 
8
- if ( isset( $_POST['string-locator-string'] ) ) {
9
- $search_string = $_POST['string-locator-string'];
10
- }
11
- if ( isset( $_POST['string-locator-search'] ) ) {
12
- $search_location = $_POST['string-locator-search'];
13
- }
14
 
15
- if ( isset( $_GET['restore'] ) ) {
16
- $restore = unserialize( get_option( 'string-locator-search-overview' ) );
17
 
18
- $search_string = $restore->search;
19
- $search_location = $restore->directory;
20
- $search_regex = $restore->regex;
21
- }
22
  ?>
23
  <div class="wrap">
24
- <h2>
25
- <?php _e( 'String Locator', 'string-locator' ); ?>
26
- </h2>
27
 
28
- <form action="<?php echo esc_url( $this_url ); ?>" method="post" id="string-locator-search-form">
29
- <label for="string-locator-search"><?php _e( 'Search through', 'string-locator' ); ?></label>
30
- <select name="string-locator-search" id="string-locator-search">
31
- <optgroup label="<?php _e( 'Core', 'string-locator' ); ?>">
32
- <option value="core"><?php _e( 'The whole WordPress directory', 'string-locator' ); ?></option>
33
- <option value="wp-content"><?php _e( 'Everything under wp-content', 'string-locator' ); ?></option>
34
- </optgroup>
35
- <optgroup label="<?php _e( 'Themes', 'string-locator' ); ?>">
36
- <?php echo String_Locator::get_themes_options( $search_location ); ?>
37
- </optgroup>
38
- <optgroup label="<?php _e( 'Plugins', 'string-locator' ); ?>">
39
- <?php echo String_Locator::get_plugins_options( $search_location ); ?>
40
- </optgroup>
41
- </select>
42
 
43
- <label for="string-locator-string"><?php _e( 'Search string', 'string-locator' ); ?></label>
44
- <input type="text" name="string-locator-string" id="string-locator-string" value="<?php echo esc_attr( $search_string ); ?>" />
45
 
46
- <label><input type="checkbox" name="string-locator-regex" id="string-locator-regex"<?php echo ( $search_regex ? ' checked="checked"' : '' ); ?>'> RegEx search</label>
47
 
48
- <p>
49
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Search', 'string-locator' ); ?>">
50
- <a href="<?php echo esc_url( $this_url . '&restore=true' ); ?>" class="button button-primary"><?php _e( 'Restore last search', 'string-locator' ); ?></a>
51
- </p>
52
- </form>
53
 
54
  <div class="notices"></div>
55
 
56
- <div class="string-locator-feedback hide">
57
- <progress id="string-locator-search-progress" max="100"></progress>
58
- <span id="string-locator-feedback-text"><?php esc_html_e( 'Preparing search&hellip;', 'string-locator' ); ?></span>
59
- </div>
60
 
61
  <div class="table-wrapper">
62
- <?php
63
- if ( isset( $_GET['restore'] ) ) {
64
- $items = maybe_unserialize( get_option( 'string-locator-search-history', array() ) );
65
 
66
- echo String_Locator::prepare_full_table( $items, array( 'restore' ) );
67
- }
68
- else {
69
- echo String_Locator::prepare_full_table( array() );
70
- }
71
- ?>
72
  </div>
73
  </div>
1
  <?php
2
+ $this_url = admin_url( ( is_multisite() ? 'network/admin.php' : 'tools.php' ) . '?page=string-locator' );
3
 
4
+ $search_string = '';
5
+ $search_location = '';
6
+ $search_regex = false;
7
 
8
+ if ( isset( $_POST['string-locator-string'] ) ) {
9
+ $search_string = $_POST['string-locator-string'];
10
+ }
11
+ if ( isset( $_POST['string-locator-search'] ) ) {
12
+ $search_location = $_POST['string-locator-search'];
13
+ }
14
 
15
+ if ( isset( $_GET['restore'] ) ) {
16
+ $restore = unserialize( get_option( 'string-locator-search-overview' ) );
17
 
18
+ $search_string = $restore->search;
19
+ $search_location = $restore->directory;
20
+ $search_regex = String_Locator::absbool( $restore->regex );
21
+ }
22
  ?>
23
  <div class="wrap">
24
+ <h2>
25
+ <?php _e( 'String Locator', 'string-locator' ); ?>
26
+ </h2>
27
 
28
+ <form action="<?php echo esc_url( $this_url ); ?>" method="post" id="string-locator-search-form">
29
+ <label for="string-locator-search"><?php _e( 'Search through', 'string-locator' ); ?></label>
30
+ <select name="string-locator-search" id="string-locator-search">
31
+ <optgroup label="<?php _e( 'Core', 'string-locator' ); ?>">
32
+ <option value="core"><?php _e( 'The whole WordPress directory', 'string-locator' ); ?></option>
33
+ <option value="wp-content"><?php _e( 'Everything under wp-content', 'string-locator' ); ?></option>
34
+ </optgroup>
35
+ <optgroup label="<?php _e( 'Themes', 'string-locator' ); ?>">
36
+ <?php echo String_Locator::get_themes_options( $search_location ); ?>
37
+ </optgroup>
38
+ <optgroup label="<?php _e( 'Plugins', 'string-locator' ); ?>">
39
+ <?php echo String_Locator::get_plugins_options( $search_location ); ?>
40
+ </optgroup>
41
+ </select>
42
 
43
+ <label for="string-locator-string"><?php _e( 'Search string', 'string-locator' ); ?></label>
44
+ <input type="text" name="string-locator-string" id="string-locator-string" value="<?php echo esc_attr( $search_string ); ?>" />
45
 
46
+ <label><input type="checkbox" name="string-locator-regex" id="string-locator-regex"<?php echo ( $search_regex ? ' checked="checked"' : '' ); ?>'> RegEx search</label>
47
 
48
+ <p>
49
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Search', 'string-locator' ); ?>">
50
+ <a href="<?php echo esc_url( $this_url . '&restore=true' ); ?>" class="button button-primary"><?php _e( 'Restore last search', 'string-locator' ); ?></a>
51
+ </p>
52
+ </form>
53
 
54
  <div class="notices"></div>
55
 
56
+ <div class="string-locator-feedback hide">
57
+ <progress id="string-locator-search-progress" max="100"></progress>
58
+ <span id="string-locator-feedback-text"><?php esc_html_e( 'Preparing search&hellip;', 'string-locator' ); ?></span>
59
+ </div>
60
 
61
  <div class="table-wrapper">
62
+ <?php
63
+ if ( isset( $_GET['restore'] ) ) {
64
+ $items = maybe_unserialize( get_option( 'string-locator-search-history', array() ) );
65
 
66
+ echo String_Locator::prepare_full_table( $items, array( 'restore' ) );
67
+ }
68
+ else {
69
+ echo String_Locator::prepare_full_table( array() );
70
+ }
71
+ ?>
72
  </div>
73
  </div>
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://www.paypal.me/clorith
6
  Tags: theme, plugin, text, search, find, editor, syntax, highlight
7
  Requires at least: 3.6
8
  Tested up to: 4.7
9
- Stable tag: 2.1.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -56,6 +56,11 @@ When writing your search string, make sure to wrap your search in forward slashe
56
  3. Smart-Scan has detected an inconsistency in the use of braces
57
 
58
  == Changelog ==
 
 
 
 
 
59
  = 2.1.1 =
60
  * Improved error messages
61
  * Add regex pattern validation before performing a search
@@ -69,24 +74,6 @@ When writing your search string, make sure to wrap your search in forward slashe
69
  * Display file path in the editor to identify which file is being modified
70
  * Add support for RegEx string searches
71
 
72
- = 2.0.3 =
73
- * Added support for HHVM
74
- * Improved inline documentation
75
-
76
- = 2.0.2 =
77
- * Fixed max memory indicators on hosts that do not use shorthands
78
-
79
- = 2.0.1 =
80
- * Fixed a bug where heavy sites would not run searches due to incorrect memory consumption calculations
81
- * Fixed a visual bug when warnings are displayed
82
- * Added error feedback if high execution times or memory consumption is detected before a search is started
83
-
84
- = 2.0.0 =
85
- * Performance enhancement, now also detects memory consumption to avoid exceeding memory limits
86
- * Fixed a warning incorrectly being shown saying files cannot be read
87
- * Better feedback during the search process
88
- * Fixed a longstanding bug with searching single file plugins
89
-
90
 
91
  == Upgrade notice ==
92
 
6
  Tags: theme, plugin, text, search, find, editor, syntax, highlight
7
  Requires at least: 3.6
8
  Tested up to: 4.7
9
+ Stable tag: 2.1.2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
56
  3. Smart-Scan has detected an inconsistency in the use of braces
57
 
58
  == Changelog ==
59
+ = 2.1.2 =
60
+ * Fix for max execution times some times being interpreted as strings and failing when you it should be able to run indefinitely
61
+ * Fix for regex being enabled when you return to the search results, but you hadn't performed a regex search
62
+ * Resolved some code issues with functions being called improperly (future proofing)
63
+
64
  = 2.1.1 =
65
  * Improved error messages
66
  * Add regex pattern validation before performing a search
74
  * Display file path in the editor to identify which file is being modified
75
  * Add support for RegEx string searches
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  == Upgrade notice ==
79
 
string-locator.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: String Locator
4
  * Plugin URI: http://www.clorith.net/wordpress-string-locator/
5
  * Description: Scan through theme and plugin files looking for text strings
6
- * Version: 2.1.1
7
  * Author: Clorith
8
  * Author URI: http://www.clorith.net
9
  * Text Domain: string-locator
@@ -38,7 +38,7 @@ class String_Locator
38
  * @var string $plugin_url The URL to the plugins directory
39
  */
40
  public $string_locator_language = '';
41
- public $version = '2.1.1';
42
  public $notice = array();
43
  public $failed_edit = false;
44
  private $plugin_url = '';
@@ -62,7 +62,7 @@ class String_Locator
62
  $this->path_to_use = ( is_multisite() ? 'network/admin.php' : 'tools.php' );
63
  $this->excerpt_length = apply_filters( 'string_locator_excerpt_length', 25 );
64
 
65
- $this->max_execution_time = ini_get( 'max_execution_time' );
66
  $this->start_execution_timer = microtime( true );
67
 
68
  $this->set_memory_limit();
@@ -131,7 +131,7 @@ class String_Locator
131
  *
132
  * @return string
133
  */
134
- function get_themes_options( $current = null ) {
135
  $options = sprintf(
136
  '<option value="%s" %s>&mdash; %s &mdash;</option>',
137
  't--',
@@ -163,7 +163,7 @@ class String_Locator
163
  *
164
  * @return string
165
  */
166
- function get_plugins_options( $current = null ) {
167
  $options = sprintf(
168
  '<option value="%s" %s>&mdash; %s &mdash;</option>',
169
  'p--',
@@ -276,6 +276,22 @@ class String_Locator
276
  return false;
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /**
280
  * Search an individual file supplied via AJAX
281
  *
@@ -337,17 +353,7 @@ class String_Locator
337
 
338
  $is_regex = false;
339
  if ( isset( $scan_data->regex ) ) {
340
- if ( is_bool( $scan_data->regex ) ) {
341
- $is_regex = $scan_data->regex;
342
- }
343
- else {
344
- if ( 'false' == $scan_data->regex ) {
345
- $is_regex = false;
346
- }
347
- else {
348
- $is_regex = true;
349
- }
350
- }
351
  }
352
 
353
  if ( $is_regex ) {
@@ -444,7 +450,7 @@ class String_Locator
444
  *
445
  * @return string
446
  */
447
- function prepare_table_row( $item ) {
448
  if ( ! is_object( $item ) ) {
449
  $item = (object) $item;
450
  }
@@ -470,7 +476,7 @@ class String_Locator
470
  *
471
  * @return string
472
  */
473
- function prepare_full_table( $items, $table_class = array() ) {
474
  $table_class = array_merge( $table_class, array(
475
  'wp-list-table',
476
  'widefat',
@@ -492,7 +498,7 @@ class String_Locator
492
 
493
  $table_rows = array();
494
  foreach( $items AS $item ) {
495
- $table_rows[] = $this->prepare_table_row( $item );
496
  }
497
 
498
  $table = sprintf(
3
  * Plugin Name: String Locator
4
  * Plugin URI: http://www.clorith.net/wordpress-string-locator/
5
  * Description: Scan through theme and plugin files looking for text strings
6
+ * Version: 2.1.2
7
  * Author: Clorith
8
  * Author URI: http://www.clorith.net
9
  * Text Domain: string-locator
38
  * @var string $plugin_url The URL to the plugins directory
39
  */
40
  public $string_locator_language = '';
41
+ public $version = '2.1.2';
42
  public $notice = array();
43
  public $failed_edit = false;
44
  private $plugin_url = '';
62
  $this->path_to_use = ( is_multisite() ? 'network/admin.php' : 'tools.php' );
63
  $this->excerpt_length = apply_filters( 'string_locator_excerpt_length', 25 );
64
 
65
+ $this->max_execution_time = absint( ini_get( 'max_execution_time' ) );
66
  $this->start_execution_timer = microtime( true );
67
 
68
  $this->set_memory_limit();
131
  *
132
  * @return string
133
  */
134
+ public static function get_themes_options( $current = null ) {
135
  $options = sprintf(
136
  '<option value="%s" %s>&mdash; %s &mdash;</option>',
137
  't--',
163
  *
164
  * @return string
165
  */
166
+ public static function get_plugins_options( $current = null ) {
167
  $options = sprintf(
168
  '<option value="%s" %s>&mdash; %s &mdash;</option>',
169
  'p--',
276
  return false;
277
  }
278
 
279
+ public static function absbool( $value ) {
280
+ if ( is_bool( $value ) ) {
281
+ $bool = $value;
282
+ }
283
+ else {
284
+ if ( 'false' == $value ) {
285
+ $bool = false;
286
+ }
287
+ else {
288
+ $bool = true;
289
+ }
290
+ }
291
+
292
+ return $bool;
293
+ }
294
+
295
  /**
296
  * Search an individual file supplied via AJAX
297
  *
353
 
354
  $is_regex = false;
355
  if ( isset( $scan_data->regex ) ) {
356
+ $is_regex = $this->absbool( $scan_data->regex );
 
 
 
 
 
 
 
 
 
 
357
  }
358
 
359
  if ( $is_regex ) {
450
  *
451
  * @return string
452
  */
453
+ public static function prepare_table_row( $item ) {
454
  if ( ! is_object( $item ) ) {
455
  $item = (object) $item;
456
  }
476
  *
477
  * @return string
478
  */
479
+ public static function prepare_full_table( $items, $table_class = array() ) {
480
  $table_class = array_merge( $table_class, array(
481
  'wp-list-table',
482
  'widefat',
498
 
499
  $table_rows = array();
500
  foreach( $items AS $item ) {
501
+ $table_rows[] = self::prepare_table_row( $item );
502
  }
503
 
504
  $table = sprintf(