WP htaccess Control - Version 3.5

Version Description

Download this release

Release Info

Developer antonioandra.de
Plugin Icon wp plugin WP htaccess Control
Version 3.5
Comparing to
See all releases

Code changes from version 3.4.5 to 3.5

admin-ui-includes/advanced-archives.php CHANGED
@@ -1,42 +1,48 @@
1
- <?php global $WPhtc;?>
2
  <!-- Advanced Archives -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Advanced Archives', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <?php foreach (get_taxonomies('', 'objects') as $taxonomy) {
12
- if (!$taxonomy->rewrite) {
13
- continue;
14
- }
15
- ?>
16
- <tr valign="top">
17
- <th scope="row" style="width:18%;"><?php _e('Create', 'wp-htaccess-control');
18
- echo " " . $taxonomy->labels->name . " ";
19
- _e('Archives', 'wp-htaccess-control'); ?></th>
20
- <td>
21
- <input type="checkbox"
22
- name="WPhtc_create_archive[<?php echo $taxonomy->name; ?>]" <?php if ($WPhtc->get_data('create_archive', $taxonomy->name)) {
23
- echo "checked=checked";
24
- } ?> />
25
- </td>
26
- <td valign="middle">
27
- <p class="description"><?php _e('If active, taxonomy-based archives will be accessible:', 'wp-htaccess-control'); ?></p>
28
 
29
- <p class="description"><code><?php bloginfo('url') ?>/<?php echo $taxonomy->name; ?>
30
- _base/<?php echo $taxonomy->name; ?>_term/2010</code></p>
 
 
31
 
32
- <p class="description"><code><?php bloginfo('url') ?>/<?php echo $taxonomy->name; ?>
33
- _base/<?php echo $taxonomy->name; ?>_term/2010/12</code></p>
 
 
34
 
35
- <p class="description"><?php _e("This will also work if you've removed the", 'wp-htaccess-control'); ?> <?php echo $taxonomy->labels->name; ?> <?php _e("base.", 'wp-htaccess-control'); ?></p>
36
- </td>
37
- </tr>
38
- <?php
39
- }
40
- ?>
41
- </table>
 
 
42
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Advanced Archives -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Advanced Archives', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <?php foreach ( get_taxonomies( '', 'objects' ) as $taxonomy ) {
12
+ if ( ! $taxonomy->rewrite ) {
13
+ continue;
14
+ }
15
+ ?>
16
+ <tr valign="top">
17
+ <th scope="row" style="width:18%;"><?php _e( 'Create', 'wp-htaccess-control' );
18
+ echo " " . $taxonomy->labels->name . " ";
19
+ _e( 'Archives', 'wp-htaccess-control' ); ?></th>
20
+ <td>
21
+ <input type="checkbox"
22
+ name="WPhtc_create_archive[<?php echo $taxonomy->name; ?>]" <?php if ( $WPhtc->get_data( 'create_archive', $taxonomy->name ) ) {
23
+ echo "checked=checked";
24
+ } ?> />
25
+ </td>
26
+ <td valign="middle">
27
+ <p class="description"><?php _e( 'If active, taxonomy-based archives will be accessible:', 'wp-htaccess-control' ); ?></p>
28
 
29
+ <p class="description">
30
+ <code><?php bloginfo( 'url' ) ?>/<?php echo $taxonomy->name . "_base"; ?>
31
+ /<?php echo $taxonomy->name; ?>_term/2010</code>
32
+ </p>
33
 
34
+ <p class="description">
35
+ <code><?php bloginfo( 'url' ) ?>/<?php echo $taxonomy->name . "_base"; ?>
36
+ /<?php echo $taxonomy->name; ?>_term/2010/12</code>
37
+ </p>
38
 
39
+ <p class="description"><?php _e( "This will also work if you've removed the", 'wp-htaccess-control' ); ?>
40
+ <?php echo $taxonomy->labels->name; ?>
41
+ <?php _e( "base.", 'wp-htaccess-control' ); ?></p>
42
+ </td>
43
+ </tr>
44
+ <?php
45
+ }
46
+ ?>
47
+ </table>
48
  </div>
admin-ui-includes/custom-author-permalink.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php global $WPhtc;?>
2
  <!-- Custom Author Permalink -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Custom Author Permalink', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e('Author Base', 'wp-htaccess-control'); ?></th>
13
- <td>
14
- <input type="text" name="WPhtc_cap" value="<?php echo $WPhtc->get_data('cap'); ?>"/>
15
 
16
- <p><code><?php bloginfo('url') ?>
17
- /<em><?php _e('(your-base)', 'wp-htaccess-control'); ?></em>/admin</code></p>
18
- </td>
19
- <td valign="middle">
20
- <p class="description"><?php _e('Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control'); ?></p>
21
 
22
- <p class="description"><?php _e('If set, the author base will be used as shown next to the form field.', 'wp-htaccess-control'); ?></p>
23
 
24
- <p class="description"><?php _e('If you do not want to use a custom Author Permalink base just leave the field empty.', 'wp-htaccess-control'); ?></p>
25
- </td>
26
- </tr>
27
- <?php if (class_exists('GoogleSitemapGeneratorLoader')) { ?>
28
- <tr valign="top">
29
- <th>Google XML Sitemap</th>
30
- <td>
31
- <input type="checkbox" name="WPhtc_sm_enabled"
32
- value="true" <?php if ($WPhtc->get_data('sm_enabled')) {
33
- echo "checked";
34
- } ?>/> <?php _e('Apply Custom Author Permalink on Generated Sitemap', 'wp-htaccess-control'); ?>
35
- </td>
36
- <td valign="middle">
37
- <p class="description"><?php _e('Leave "Include author pages" unchecked on Google XML Sitemap options page if using this.', 'wp-htaccess-control'); ?></p>
38
 
39
- <p class="description"><?php _e('However, if you want to adjust the "Priority" or "Change frequency" you should do so on the <a href="options-general.php?page=google-sitemap-generator/sitemap.php">Google XML Sitemap options page</a>.', 'wp-htaccess-control'); ?></p>
40
- </td>
41
- </tr>
42
- <?php } ?>
43
- </table>
44
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Custom Author Permalink -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Custom Author Permalink', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( 'Author Base', 'wp-htaccess-control' ); ?></th>
13
+ <td>
14
+ <input type="text" name="WPhtc_cap" value="<?php echo $WPhtc->get_data( 'cap' ); ?>"/>
15
 
16
+ <p><code><?php bloginfo( 'url' ) ?>
17
+ /<em><?php _e( '(your-base)', 'wp-htaccess-control' ); ?></em>/admin</code></p>
18
+ </td>
19
+ <td valign="middle">
20
+ <p class="description"><?php _e( 'Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control' ); ?></p>
21
 
22
+ <p class="description"><?php _e( 'If set, the author base will be used as shown next to the form field.', 'wp-htaccess-control' ); ?></p>
23
 
24
+ <p class="description"><?php _e( 'If you do not want to use a custom Author Permalink base just leave the field empty.', 'wp-htaccess-control' ); ?></p>
25
+ </td>
26
+ </tr>
27
+ <?php if ( class_exists( 'GoogleSitemapGeneratorLoader' ) ) { ?>
28
+ <tr valign="top">
29
+ <th>Google XML Sitemap</th>
30
+ <td>
31
+ <input type="checkbox" name="WPhtc_sm_enabled"
32
+ value="true" <?php if ( $WPhtc->get_data( 'sm_enabled' ) ) {
33
+ echo "checked";
34
+ } ?>/> <?php _e( 'Apply Custom Author Permalink on Generated Sitemap', 'wp-htaccess-control' ); ?>
35
+ </td>
36
+ <td valign="middle">
37
+ <p class="description"><?php _e( 'Leave "Include author pages" unchecked on Google XML Sitemap options page if using this.', 'wp-htaccess-control' ); ?></p>
38
 
39
+ <p class="description"><?php _e( 'However, if you want to adjust the "Priority" or "Change frequency" you should do so on the <a href="options-general.php?page=google-sitemap-generator/sitemap.php">Google XML Sitemap options page</a>.', 'wp-htaccess-control' ); ?></p>
40
+ </td>
41
+ </tr>
42
+ <?php } ?>
43
+ </table>
44
  </div>
admin-ui-includes/custom-htaccess.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php global $WPhtc;?>
2
  <!-- Custom htaccess -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Custom htaccess', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <td>
13
  <textarea name="WPhtc_hta" style="width:100%;"
14
- rows="7"><?php echo stripslashes($WPhtc->get_data('hta')); ?></textarea>
15
- </td>
16
- <td style="width:50%;">
17
- <p class="description"><?php _e('This rules will be printed before any WordPress rules.', 'wp-htaccess-control'); ?></p>
18
 
19
- <p class="description"><?php _e('Please double check them before saving as a mistake could make your site inaccessible.', 'wp-htaccess-control'); ?></p>
20
- <ul class="description">
21
- <li><a href="http://www.google.com/search?q=htaccess+tutorial"
22
- title="Search for htaccess tutorials"><img width="16px" src="http://google.com/favicon.ico"
23
- alt="google favicon"> htaccess tutorial</a></li>
24
- <li><a href="http://httpd.apache.org/docs/current/howto/htaccess.html"
25
- title="Read about htaccess at apache.org"><img width="16px"
26
- src="http://apache.org/favicon.ico"
27
- alt="apache favicon"> htaccess</a></li>
28
- <li><a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html"
29
- title="Read about mod_rewrite at apache.org"><img width="16px"
30
- src="http://apache.org/favicon.ico"
31
- alt="apache favicon"> mod_rewrite</a></li>
32
- </ul>
33
- </td>
34
- </tr>
35
- </table>
36
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Custom htaccess -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Custom htaccess', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <td>
13
  <textarea name="WPhtc_hta" style="width:100%;"
14
+ rows="7"><?php echo stripslashes( $WPhtc->get_data( 'hta' ) ); ?></textarea>
15
+ </td>
16
+ <td style="width:50%;">
17
+ <p class="description"><?php _e( 'This rules will be printed before any WordPress rules.', 'wp-htaccess-control' ); ?></p>
18
 
19
+ <p class="description"><?php _e( 'Please double check them before saving as a mistake could make your site inaccessible.', 'wp-htaccess-control' ); ?></p>
20
+ <ul class="description">
21
+ <li><a href="http://www.google.com/search?q=htaccess+tutorial"
22
+ title="Search for htaccess tutorials"><img width="16px" src="http://google.com/favicon.ico"
23
+ alt="google favicon"> htaccess tutorial</a></li>
24
+ <li><a href="http://httpd.apache.org/docs/current/howto/htaccess.html"
25
+ title="Read about htaccess at apache.org"><img width="16px"
26
+ src="http://apache.org/favicon.ico"
27
+ alt="apache favicon"> htaccess</a></li>
28
+ <li><a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html"
29
+ title="Read about mod_rewrite at apache.org"><img width="16px"
30
+ src="http://apache.org/favicon.ico"
31
+ alt="apache favicon"> mod_rewrite</a></li>
32
+ </ul>
33
+ </td>
34
+ </tr>
35
+ </table>
36
  </div>
admin-ui-includes/custom-pagination-permalink.php CHANGED
@@ -1,28 +1,29 @@
1
- <?php global $WPhtc;?>
2
  <!-- Custom Pagination Permalink -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Custom Pagination Permalink', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e('Page Base', 'wp-htaccess-control'); ?></th>
13
- <td>
14
- <input type="text" name="WPhtc_cpp" value="<?php echo $WPhtc->get_data('cpp'); ?>"/>
15
 
16
- <p><code><?php bloginfo('url') ?>/<em><?php _e('(your-base)', 'wp-htaccess-control'); ?></em>/2</code>
17
- </p>
18
- </td>
19
- <td valign="middle">
20
- <p class="description"><?php _e('Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control'); ?></p>
 
21
 
22
- <p class="description"><?php _e('If set, the page base will be used as shown next to the form field in every post listing (category, tag, archive, etc).', 'wp-htaccess-control'); ?></p>
23
 
24
- <p class="description"><?php _e('If you do not want to use a custom Pagination Permalink base just leave the field empty.', 'wp-htaccess-control'); ?></p>
25
- </td>
26
- </tr>
27
- </table>
28
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Custom Pagination Permalink -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Custom Pagination Permalink', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( 'Page Base', 'wp-htaccess-control' ); ?></th>
13
+ <td>
14
+ <input type="text" name="WPhtc_cpp" value="<?php echo $WPhtc->get_data( 'cpp' ); ?>"/>
15
 
16
+ <p><code><?php bloginfo( 'url' ) ?>
17
+ /<em><?php _e( '(your-base)', 'wp-htaccess-control' ); ?></em>/2</code>
18
+ </p>
19
+ </td>
20
+ <td valign="middle">
21
+ <p class="description"><?php _e( 'Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control' ); ?></p>
22
 
23
+ <p class="description"><?php _e( 'If set, the page base will be used as shown next to the form field in every post listing (category, tag, archive, etc).', 'wp-htaccess-control' ); ?></p>
24
 
25
+ <p class="description"><?php _e( 'If you do not want to use a custom Pagination Permalink base just leave the field empty.', 'wp-htaccess-control' ); ?></p>
26
+ </td>
27
+ </tr>
28
+ </table>
29
  </div>
admin-ui-includes/custom-search-permalink.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php global $WPhtc;?>
2
  <!-- Custom Search Permalink -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Custom Search Permalink', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e('Search Base', 'wp-htaccess-control'); ?></th>
13
- <td>
14
- <input type="text" name="WPhtc_custom_search_permalink"
15
- value="<?php echo $WPhtc->get_data('custom_search_permalink'); ?>"/>
16
 
17
- <p><code><?php bloginfo('url') ?>/<em><?php _e('(your-base)', 'wp-htaccess-control'); ?></em>/search-term</code>
18
- </p>
19
- </td>
20
- <td valign="middle">
21
- <p class="description"><?php _e('Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control'); ?></p>
22
 
23
- <p class="description"><?php _e('If set, the search base will always be used instead of "?s=search-term".', 'wp-htaccess-control'); ?></p>
24
 
25
- <p class="description"><?php _e('If you do not want to use a custom Search Permalink base just leave the field empty.', 'wp-htaccess-control'); ?></p>
26
- </td>
27
- </tr>
28
- </table>
29
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Custom Search Permalink -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Custom Search Permalink', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( 'Search Base', 'wp-htaccess-control' ); ?></th>
13
+ <td>
14
+ <input type="text" name="WPhtc_custom_search_permalink"
15
+ value="<?php echo $WPhtc->get_data( 'custom_search_permalink' ); ?>"/>
16
 
17
+ <p><code><?php bloginfo( 'url' ) ?>/<em><?php _e( '(your-base)', 'wp-htaccess-control' ); ?></em>/search-term</code>
18
+ </p>
19
+ </td>
20
+ <td valign="middle">
21
+ <p class="description"><?php _e( 'Permalink settings must be set and not Default (/?p=123).', 'wp-htaccess-control' ); ?></p>
22
 
23
+ <p class="description"><?php _e( 'If set, the search base will always be used instead of "?s=search-term".', 'wp-htaccess-control' ); ?></p>
24
 
25
+ <p class="description"><?php _e( 'If you do not want to use a custom Search Permalink base just leave the field empty.', 'wp-htaccess-control' ); ?></p>
26
+ </td>
27
+ </tr>
28
+ </table>
29
  </div>
admin-ui-includes/htaccess-suggestions.php CHANGED
@@ -1,176 +1,176 @@
1
- <?php global $WPhtc;?>
2
  <!-- htaccess Suggestions -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('htaccess Suggestions', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e('ServerSignature', 'wp-htaccess-control'); ?></th>
13
- <td style="width:3%;" valign="middle">
14
- <input type="checkbox" name="WPhtc_disable_serversignature"
15
- value="true" <?php if ($WPhtc->get_data('disable_serversignature')) {
16
- echo "checked";
17
- } ?>/>
18
- </td>
19
- <td valign="middle">
20
- <p class="description"><?php _e('Disable the ServerSignature on server generated error pages.', 'wp-htaccess-control'); ?></p>
21
- </td>
22
- </tr>
23
- <tr valign="top">
24
- <th scope="row"><?php _e('Indexes', 'wp-htaccess-control'); ?></th>
25
- <td style="width:3%;" valign="middle">
26
- <input type="checkbox" name="WPhtc_disable_indexes"
27
- value="true" <?php if ($WPhtc->get_data('disable_indexes')) {
28
- echo "checked";
29
- } ?>/>
30
- </td>
31
- <td valign="middle">
32
- <p class="description"><?php _e('Disable directory browsing.', 'wp-htaccess-control'); ?></p>
33
- </td>
34
- </tr>
35
- <tr valign="top">
36
- <th scope="row"><?php _e('Protect wp-config.php file', 'wp-htaccess-control'); ?></th>
37
- <td style="width:3%;" valign="middle">
38
- <input type="checkbox" name="WPhtc_protect_wp_config"
39
- value="true" <?php if ($WPhtc->get_data('protect_wp_config')) {
40
- echo "checked";
41
- } ?>/></td>
42
- <td valign="middle">
43
- <p class="description"><?php _e('Deny access to wp-config.php file.', 'wp-htaccess-control'); ?></p>
44
- </td>
45
- </tr>
46
- <tr valign="top">
47
- <th scope="row"><?php _e('Protect htaccess file', 'wp-htaccess-control'); ?></th>
48
- <td style="width:3%;" valign="middle">
49
- <input type="checkbox" name="WPhtc_protect_htaccess"
50
- value="true" <?php if ($WPhtc->get_data('protect_htaccess')) {
51
- echo "checked";
52
- } ?>/></td>
53
- <td valign="middle">
54
- <p class="description"><?php _e('Deny access to .htaccess file.', 'wp-htaccess-control'); ?></p>
55
- </td>
56
- </tr>
57
- <tr valign="top">
58
- <th scope="row"><?php _e('Protect comments.php', 'wp-htaccess-control'); ?></th>
59
- <td style="width:3%;" valign="middle">
60
- <input type="checkbox" name="WPhtc_protect_comments"
61
- value="true" <?php if ($WPhtc->get_data('protect_comments')) {
62
- echo "checked";
63
- } ?>/></td>
64
- <td valign="middle">
65
- <p class="description"><?php _e('Deny comment posting to no referrer requests. This will avoid spam bots coming from nowhere.', 'wp-htaccess-control'); ?></p>
66
- </td>
67
- </tr>
68
- <tr valign="top">
69
- <th scope="row"><?php _e('mod_gzip', 'wp-htaccess-control'); ?></th>
70
- <td style="width:3%;" valign="middle">
71
- <input type="checkbox" name="WPhtc_gzip" value="true" <?php if ($WPhtc->get_data('gzip')) {
72
- echo "checked";
73
- } ?>/>
74
- </td>
75
- <td valign="middle">
76
- <p class="description"><?php _e('Use mod_gzip if available.', 'wp-htaccess-control'); ?></p>
77
- </td>
78
- </tr>
79
- <tr valign="top">
80
- <th scope="row"><?php _e('mod_deflate', 'wp-htaccess-control'); ?></th>
81
- <td style="width:3%;" valign="middle">
82
- <input type="checkbox" name="WPhtc_deflate" value="true" <?php if ($WPhtc->get_data('deflate')) {
83
- echo "checked";
84
- } ?>/>
85
- </td>
86
- <td valign="middle">
87
- <p class="description"><?php _e('Use mod_deflate if available.', 'wp-htaccess-control'); ?></p>
88
- </td>
89
- </tr>
90
- <tr valign="top">
91
- <th scope="row"><?php _e('Limit Upload Size', 'wp-htaccess-control'); ?></th>
92
- <td style="width:3%;" valign="middle">
93
- <input type="text" name="WPhtc_up_limit" value="<?php echo $WPhtc->get_data('up_limit'); ?>"/>
94
- </td>
95
- <td valign="middle">
96
- <p class="description"><?php _e('If set, this value in MB will be used as limit to file uploads.', 'wp-htaccess-control'); ?></p>
97
- </td>
98
- </tr>
99
- <tr valign="top">
100
- <th scope="row"><?php _e('Admin Email', 'wp-htaccess-control'); ?></th>
101
- <td style="width:3%;">
102
- <input type="text" name="WPhtc_admin_email" value="<?php echo $WPhtc->get_data('admin_email') ?>"/>
103
- </td>
104
- <td valign="middle">
105
- <p class="description"><?php _e('If set, this will be used as the admin email on server generated error pages.', 'wp-htaccess-control'); ?></p>
106
- </td>
107
- </tr>
108
- <tr valign="top">
109
- <th scope="row"><?php _e('Disable image hotlinking', 'wp-htaccess-control'); ?></th>
110
- <td style="width:3%;">
111
- <input type="text" name="WPhtc_disable_hotlink"
112
- value="<?php echo $WPhtc->get_data('disable_hotlink'); ?>"/>
113
- </td>
114
- <td valign="middle">
115
- <p class="description"><?php _e('If set, this url will be used as redirection to hotlinked images (you should be using an image url here). If you prefer no output on hotlinked images use "_".', 'wp-htaccess-control'); ?></p>
116
- </td>
117
- </tr>
118
- <tr valign="top">
119
- <th scope="row"><?php _e('Disable file hotlinking extensions', 'wp-htaccess-control'); ?></th>
120
- <td style="width:3%;">
121
- <input type="text" name="WPhtc_disable_file_hotlink_ext"
122
- value="<?php echo $WPhtc->get_data('disable_file_hotlink_ext') ?>"/>
123
- </td>
124
- <td valign="middle">
125
- <p class="description"><?php _e('If set, this file extensions will not be hotlinkable.', 'wp-htaccess-control'); ?></p>
126
 
127
- <p class="description"><?php _e('Separate different extensions with a white-space, ie: "pdf doc zip".', 'wp-htaccess-control'); ?></p>
128
- </td>
129
- </tr>
130
- <tr valign="top">
131
- <th scope="row"><?php _e('File hotlinking redirection', 'wp-htaccess-control'); ?></th>
132
- <td style="width:3%;">
133
- <input type="text" name="WPhtc_disable_file_hotlink_redir"
134
- value="<?php echo $WPhtc->get_data('disable_file_hotlink_redir') ?>"/>
135
- </td>
136
- <td valign="middle">
137
- <p class="description"><?php _e('If set, this url will be used as redirection for hotlinked files.', 'wp-htaccess-control'); ?></p>
138
- </td>
139
- </tr>
140
- <tr valign="top">
141
- <th scope="row"><?php _e('500 error', 'wp-htaccess-control'); ?></th>
142
- <td style="width:3%;" valign="middle">
143
- <input type="text" name="WPhtc_redirect_500" value="<?php echo $WPhtc->get_data('redirect_500'); ?>"/>
144
- </td>
145
- <td valign="middle">
146
- <p class="description"><?php _e('If set, this path will be used as page to 500 errors (example: /error.php).', 'wp-htaccess-control'); ?></p>
147
- </td>
148
- </tr>
149
- <tr valign="top">
150
- <th scope="row"><?php _e('403 error', 'wp-htaccess-control'); ?></th>
151
- <td style="width:3%;" valign="middle">
152
- <input type="text" name="WPhtc_redirect_403" value="<?php echo $WPhtc->get_data('redirect_403'); ?>"/>
153
- </td>
154
- <td valign="middle">
155
- <p class="description"><?php _e('If set, this path will be used as page to 403 errors (example: /error.php).', 'wp-htaccess-control'); ?></p>
156
- </td>
157
- </tr>
158
- <tr valign="top">
159
- <th scope="row" valign="middle"><?php _e('Canonical Url', 'wp-htaccess-control'); ?></th>
160
- <td style="width:3%;" valign="middle">
161
- <select name="WPhtc_canon">
162
- <option value=""></option>
163
- <option value="www" <?php if ($WPhtc->get_data('canon') == 'www') {
164
- echo "selected";
165
- } ?>><?php _e('Force WWW', 'wp-htaccess-control'); ?></option>
166
- <option value="simple" <?php if ($WPhtc->get_data('canon') == 'simple') {
167
- echo "selected";
168
- } ?>><?php _e('Force non-WWW', 'wp-htaccess-control'); ?></option>
169
- </select>
170
- </td>
171
- <td valign="middle">
172
- <p class="description"><?php _e('This will force canonization. This will be done by simply modifying the wordpress "site url" and "home" options (not htaccess).', 'wp-htaccess-control'); ?></p>
173
- </td>
174
- </tr>
175
- </table>
176
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- htaccess Suggestions -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'htaccess Suggestions', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( 'ServerSignature', 'wp-htaccess-control' ); ?></th>
13
+ <td style="width:3%;" valign="middle">
14
+ <input type="checkbox" name="WPhtc_disable_serversignature"
15
+ value="true" <?php if ( $WPhtc->get_data( 'disable_serversignature' ) ) {
16
+ echo "checked";
17
+ } ?>/>
18
+ </td>
19
+ <td valign="middle">
20
+ <p class="description"><?php _e( 'Disable the ServerSignature on server generated error pages.', 'wp-htaccess-control' ); ?></p>
21
+ </td>
22
+ </tr>
23
+ <tr valign="top">
24
+ <th scope="row"><?php _e( 'Indexes', 'wp-htaccess-control' ); ?></th>
25
+ <td style="width:3%;" valign="middle">
26
+ <input type="checkbox" name="WPhtc_disable_indexes"
27
+ value="true" <?php if ( $WPhtc->get_data( 'disable_indexes' ) ) {
28
+ echo "checked";
29
+ } ?>/>
30
+ </td>
31
+ <td valign="middle">
32
+ <p class="description"><?php _e( 'Disable directory browsing.', 'wp-htaccess-control' ); ?></p>
33
+ </td>
34
+ </tr>
35
+ <tr valign="top">
36
+ <th scope="row"><?php _e( 'Protect wp-config.php file', 'wp-htaccess-control' ); ?></th>
37
+ <td style="width:3%;" valign="middle">
38
+ <input type="checkbox" name="WPhtc_protect_wp_config"
39
+ value="true" <?php if ( $WPhtc->get_data( 'protect_wp_config' ) ) {
40
+ echo "checked";
41
+ } ?>/></td>
42
+ <td valign="middle">
43
+ <p class="description"><?php _e( 'Deny access to wp-config.php file.', 'wp-htaccess-control' ); ?></p>
44
+ </td>
45
+ </tr>
46
+ <tr valign="top">
47
+ <th scope="row"><?php _e( 'Protect htaccess file', 'wp-htaccess-control' ); ?></th>
48
+ <td style="width:3%;" valign="middle">
49
+ <input type="checkbox" name="WPhtc_protect_htaccess"
50
+ value="true" <?php if ( $WPhtc->get_data( 'protect_htaccess' ) ) {
51
+ echo "checked";
52
+ } ?>/></td>
53
+ <td valign="middle">
54
+ <p class="description"><?php _e( 'Deny access to .htaccess file.', 'wp-htaccess-control' ); ?></p>
55
+ </td>
56
+ </tr>
57
+ <tr valign="top">
58
+ <th scope="row"><?php _e( 'Protect comments.php', 'wp-htaccess-control' ); ?></th>
59
+ <td style="width:3%;" valign="middle">
60
+ <input type="checkbox" name="WPhtc_protect_comments"
61
+ value="true" <?php if ( $WPhtc->get_data( 'protect_comments' ) ) {
62
+ echo "checked";
63
+ } ?>/></td>
64
+ <td valign="middle">
65
+ <p class="description"><?php _e( 'Deny comment posting to no referrer requests. This will avoid spam bots coming from nowhere.', 'wp-htaccess-control' ); ?></p>
66
+ </td>
67
+ </tr>
68
+ <tr valign="top">
69
+ <th scope="row"><?php _e( 'mod_gzip', 'wp-htaccess-control' ); ?></th>
70
+ <td style="width:3%;" valign="middle">
71
+ <input type="checkbox" name="WPhtc_gzip" value="true" <?php if ( $WPhtc->get_data( 'gzip' ) ) {
72
+ echo "checked";
73
+ } ?>/>
74
+ </td>
75
+ <td valign="middle">
76
+ <p class="description"><?php _e( 'Use mod_gzip if available.', 'wp-htaccess-control' ); ?></p>
77
+ </td>
78
+ </tr>
79
+ <tr valign="top">
80
+ <th scope="row"><?php _e( 'mod_deflate', 'wp-htaccess-control' ); ?></th>
81
+ <td style="width:3%;" valign="middle">
82
+ <input type="checkbox" name="WPhtc_deflate" value="true" <?php if ( $WPhtc->get_data( 'deflate' ) ) {
83
+ echo "checked";
84
+ } ?>/>
85
+ </td>
86
+ <td valign="middle">
87
+ <p class="description"><?php _e( 'Use mod_deflate if available.', 'wp-htaccess-control' ); ?></p>
88
+ </td>
89
+ </tr>
90
+ <tr valign="top">
91
+ <th scope="row"><?php _e( 'Limit Upload Size', 'wp-htaccess-control' ); ?></th>
92
+ <td style="width:3%;" valign="middle">
93
+ <input type="text" name="WPhtc_up_limit" value="<?php echo $WPhtc->get_data( 'up_limit' ); ?>"/>
94
+ </td>
95
+ <td valign="middle">
96
+ <p class="description"><?php _e( 'If set, this value in MB will be used as limit to file uploads.', 'wp-htaccess-control' ); ?></p>
97
+ </td>
98
+ </tr>
99
+ <tr valign="top">
100
+ <th scope="row"><?php _e( 'Admin Email', 'wp-htaccess-control' ); ?></th>
101
+ <td style="width:3%;">
102
+ <input type="text" name="WPhtc_admin_email" value="<?php echo $WPhtc->get_data( 'admin_email' ) ?>"/>
103
+ </td>
104
+ <td valign="middle">
105
+ <p class="description"><?php _e( 'If set, this will be used as the admin email on server generated error pages.', 'wp-htaccess-control' ); ?></p>
106
+ </td>
107
+ </tr>
108
+ <tr valign="top">
109
+ <th scope="row"><?php _e( 'Disable image hotlinking', 'wp-htaccess-control' ); ?></th>
110
+ <td style="width:3%;">
111
+ <input type="text" name="WPhtc_disable_hotlink"
112
+ value="<?php echo $WPhtc->get_data( 'disable_hotlink' ); ?>"/>
113
+ </td>
114
+ <td valign="middle">
115
+ <p class="description"><?php _e( 'If set, this url will be used as redirection to hotlinked images (you should be using an image url here). If you prefer no output on hotlinked images use "_".', 'wp-htaccess-control' ); ?></p>
116
+ </td>
117
+ </tr>
118
+ <tr valign="top">
119
+ <th scope="row"><?php _e( 'Disable file hotlinking extensions', 'wp-htaccess-control' ); ?></th>
120
+ <td style="width:3%;">
121
+ <input type="text" name="WPhtc_disable_file_hotlink_ext"
122
+ value="<?php echo $WPhtc->get_data( 'disable_file_hotlink_ext' ) ?>"/>
123
+ </td>
124
+ <td valign="middle">
125
+ <p class="description"><?php _e( 'If set, this file extensions will not be hotlinkable.', 'wp-htaccess-control' ); ?></p>
126
 
127
+ <p class="description"><?php _e( 'Separate different extensions with a white-space, ie: "pdf doc zip".', 'wp-htaccess-control' ); ?></p>
128
+ </td>
129
+ </tr>
130
+ <tr valign="top">
131
+ <th scope="row"><?php _e( 'File hotlinking redirection', 'wp-htaccess-control' ); ?></th>
132
+ <td style="width:3%;">
133
+ <input type="text" name="WPhtc_disable_file_hotlink_redir"
134
+ value="<?php echo $WPhtc->get_data( 'disable_file_hotlink_redir' ) ?>"/>
135
+ </td>
136
+ <td valign="middle">
137
+ <p class="description"><?php _e( 'If set, this url will be used as redirection for hotlinked files.', 'wp-htaccess-control' ); ?></p>
138
+ </td>
139
+ </tr>
140
+ <tr valign="top">
141
+ <th scope="row"><?php _e( '500 error', 'wp-htaccess-control' ); ?></th>
142
+ <td style="width:3%;" valign="middle">
143
+ <input type="text" name="WPhtc_redirect_500" value="<?php echo $WPhtc->get_data( 'redirect_500' ); ?>"/>
144
+ </td>
145
+ <td valign="middle">
146
+ <p class="description"><?php _e( 'If set, this path will be used as page to 500 errors (example: /error.php).', 'wp-htaccess-control' ); ?></p>
147
+ </td>
148
+ </tr>
149
+ <tr valign="top">
150
+ <th scope="row"><?php _e( '403 error', 'wp-htaccess-control' ); ?></th>
151
+ <td style="width:3%;" valign="middle">
152
+ <input type="text" name="WPhtc_redirect_403" value="<?php echo $WPhtc->get_data( 'redirect_403' ); ?>"/>
153
+ </td>
154
+ <td valign="middle">
155
+ <p class="description"><?php _e( 'If set, this path will be used as page to 403 errors (example: /error.php).', 'wp-htaccess-control' ); ?></p>
156
+ </td>
157
+ </tr>
158
+ <tr valign="top">
159
+ <th scope="row" valign="middle"><?php _e( 'Canonical Url', 'wp-htaccess-control' ); ?></th>
160
+ <td style="width:3%;" valign="middle">
161
+ <select name="WPhtc_canon">
162
+ <option value=""></option>
163
+ <option value="www" <?php if ( $WPhtc->get_data( 'canon' ) == 'www' ) {
164
+ echo "selected";
165
+ } ?>><?php _e( 'Force WWW', 'wp-htaccess-control' ); ?></option>
166
+ <option value="simple" <?php if ( $WPhtc->get_data( 'canon' ) == 'simple' ) {
167
+ echo "selected";
168
+ } ?>><?php _e( 'Force non-WWW', 'wp-htaccess-control' ); ?></option>
169
+ </select>
170
+ </td>
171
+ <td valign="middle">
172
+ <p class="description"><?php _e( 'This will force canonization. This will be done by simply modifying the wordpress "site url" and "home" options (not htaccess).', 'wp-htaccess-control' ); ?></p>
173
+ </td>
174
+ </tr>
175
+ </table>
176
  </div>
admin-ui-includes/login-control.php CHANGED
@@ -1,69 +1,69 @@
1
- <?php global $WPhtc;?>
2
  <!-- Login Control -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Login Control', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"></th>
13
- <td valign="middle" colspan="2">
14
- <p class="description"><?php _e('The options below concern wp-login.php. You\'ll be able to redirect all traffic away from that page and set some allowed IPs.', 'wp-htaccess-control'); ?></p>
15
 
16
- <p class="description"><?php _e('BEWARE: once disabled you won\'t be able to login through that form in any way, except for the listed IPs.', 'wp-htaccess-control'); ?></p>
17
 
18
- <p class="description"><?php _e('If everything goes wrong directly edit your .htaccess file and delete the relevant part somewhere at the top.', 'wp-htaccess-control'); ?></p>
19
- </td>
20
- </tr>
21
- <tr valign="top">
22
- <th scope="row" style="width:18%;"><?php _e('Disable wp-login.php', 'wp-htaccess-control'); ?></th>
23
- <td>
24
- <input type="checkbox" name="WPhtc_login_disabled"
25
- value="true" <?php if ($WPhtc->get_data('login_disabled')) {
26
- echo "checked";
27
- } ?>/>
28
- </td>
29
- <td valign="middle">
30
- <p class="description"><?php _e('This is the main switch. Make sure you know what you\'re doing.', 'wp-htaccess-control'); ?></p>
31
- </td>
32
- </tr>
33
- <tr valign="top">
34
- <th scope="row" style="width:18%;"><?php _e('Redirect', 'wp-htaccess-control'); ?></th>
35
- <td valign="middle">
36
- <input type="text" name="WPhtc_login_redirection"
37
- value="<?php echo $WPhtc->get_data('login_redirection') ?>"/>
38
- </td>
39
- <td valign="middle">
40
- <p class="description"><?php _e('This will be used as redirection url. You might use something like "member-login" to redirect people to "http://yoursite.com/member-login/". If empty the home page will be served as redirection.', 'wp-htaccess-control'); ?></p>
41
- </td>
42
- </tr>
43
- <tr valign="top">
44
- <th scope="row" style="width:18%;"><?php _e('Allowed IPs', 'wp-htaccess-control'); ?></th>
45
- <td>
46
- <textarea name="WPhtc_login_ips"><?php if ($WPhtc->get_data('login_ips')) {
47
- echo implode($WPhtc->get_data('login_ips'), "\n");
48
- } ?></textarea>
49
- </td>
50
- <td valign="middle">
51
- <p class="description"><?php _e('List of IPs allowed to access wp-login.php.', 'wp-htaccess-control'); ?></p>
52
 
53
- <p class="description"><?php _e('Make sure you are have a static IP when using this.'); ?></p>
54
- </td>
55
- </tr>
56
- <tr valign="top">
57
- <th scope="row" style="width:18%;"><?php _e('Half-mode', 'wp-htaccess-control'); ?></th>
58
- <td>
59
- <input type="checkbox" name="WPhtc_login_half_mode"
60
- value="true" <?php if ($WPhtc->get_data('login_half_mode')) {
61
- echo "checked";
62
- } ?>/>
63
- </td>
64
- <td valign="middle">
65
- <p class="description"><?php _e('(BETA) If set, this will still allow access to POST (login) requests, logout and to the password recovery form. I don\'t think this is very useful at the moment (login error messages will still show up on wp-login.php) but may be helpful for AJAX use.', 'wp-htaccess-control'); ?></p>
66
- </td>
67
- </tr>
68
- </table>
69
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Login Control -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Login Control', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"></th>
13
+ <td valign="middle" colspan="2">
14
+ <p class="description"><?php _e( 'The options below concern wp-login.php. You\'ll be able to redirect all traffic away from that page and set some allowed IPs.', 'wp-htaccess-control' ); ?></p>
15
 
16
+ <p class="description"><?php _e( 'BEWARE: once disabled you won\'t be able to login through that form in any way, except for the listed IPs.', 'wp-htaccess-control' ); ?></p>
17
 
18
+ <p class="description"><?php _e( 'If everything goes wrong directly edit your .htaccess file and delete the relevant part somewhere at the top.', 'wp-htaccess-control' ); ?></p>
19
+ </td>
20
+ </tr>
21
+ <tr valign="top">
22
+ <th scope="row" style="width:18%;"><?php _e( 'Disable wp-login.php', 'wp-htaccess-control' ); ?></th>
23
+ <td>
24
+ <input type="checkbox" name="WPhtc_login_disabled"
25
+ value="true" <?php if ( $WPhtc->get_data( 'login_disabled' ) ) {
26
+ echo "checked";
27
+ } ?>/>
28
+ </td>
29
+ <td valign="middle">
30
+ <p class="description"><?php _e( 'This is the main switch. Make sure you know what you\'re doing.', 'wp-htaccess-control' ); ?></p>
31
+ </td>
32
+ </tr>
33
+ <tr valign="top">
34
+ <th scope="row" style="width:18%;"><?php _e( 'Redirect', 'wp-htaccess-control' ); ?></th>
35
+ <td valign="middle">
36
+ <input type="text" name="WPhtc_login_redirection"
37
+ value="<?php echo $WPhtc->get_data( 'login_redirection' ) ?>"/>
38
+ </td>
39
+ <td valign="middle">
40
+ <p class="description"><?php _e( 'This will be used as redirection url. You might use something like "member-login" to redirect people to "http://yoursite.com/member-login/". If empty the home page will be served as redirection.', 'wp-htaccess-control' ); ?></p>
41
+ </td>
42
+ </tr>
43
+ <tr valign="top">
44
+ <th scope="row" style="width:18%;"><?php _e( 'Allowed IPs', 'wp-htaccess-control' ); ?></th>
45
+ <td>
46
+ <textarea name="WPhtc_login_ips"><?php if ( $WPhtc->get_data( 'login_ips' ) ) {
47
+ echo implode( $WPhtc->get_data( 'login_ips' ), "\n" );
48
+ } ?></textarea>
49
+ </td>
50
+ <td valign="middle">
51
+ <p class="description"><?php _e( 'List of IPs allowed to access wp-login.php.', 'wp-htaccess-control' ); ?></p>
52
 
53
+ <p class="description"><?php _e( 'Make sure you are have a static IP when using this.' ); ?></p>
54
+ </td>
55
+ </tr>
56
+ <tr valign="top">
57
+ <th scope="row" style="width:18%;"><?php _e( 'Half-mode', 'wp-htaccess-control' ); ?></th>
58
+ <td>
59
+ <input type="checkbox" name="WPhtc_login_half_mode"
60
+ value="true" <?php if ( $WPhtc->get_data( 'login_half_mode' ) ) {
61
+ echo "checked";
62
+ } ?>/>
63
+ </td>
64
+ <td valign="middle">
65
+ <p class="description"><?php _e( '(BETA) If set, this will still allow access to POST (login) requests, logout and to the password recovery form. I don\'t think this is very useful at the moment (login error messages will still show up on wp-login.php) but may be helpful for AJAX use.', 'wp-htaccess-control' ); ?></p>
66
+ </td>
67
+ </tr>
68
+ </table>
69
  </div>
admin-ui-includes/maintenance-mode.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php global $WPhtc;?>
2
  <!-- Maintenance Mode -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Maintenance Mode', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e('Maintenance Active', 'wp-htaccess-control'); ?></th>
13
- <td valign="middle">
14
- <input type="checkbox" name="WPhtc_maintenance_active"
15
- value="true" <?php if ($WPhtc->get_data('maintenance_active')) {
16
- echo "checked";
17
- } ?>/>
18
- </td>
19
- <td valign="middle">
20
- <p class="description"><?php _e('Toggles Maintenance Mode.', 'wp-htaccess-control'); ?></p>
21
- </td>
22
- </tr>
23
- <tr valign="top">
24
- <th scope="row" style="width:18%;"><?php _e('Allowed IPs', 'wp-htaccess-control'); ?></th>
25
- <td>
26
- <textarea name="WPhtc_maintenance_ips"><?php if ($WPhtc->get_data('maintenance_ips')) {
27
- echo implode($WPhtc->get_data('maintenance_ips'), "\n");
28
- } ?></textarea>
29
- </td>
30
- <td valign="middle">
31
- <p class="description"><?php _e('List of allowed IPs.', 'wp-htaccess-control'); ?></p>
32
 
33
- <p class="description"><?php _e('All the IPs not listed will view the 403 error page or be redirected to a page set below.', 'wp-htaccess-control'); ?></p>
34
- </td>
35
- </tr>
36
- <tr valign="top">
37
- <th scope="row" style="width:18%;"><?php _e('Redirection', 'wp-htaccess-control'); ?></th>
38
- <td>
39
- <input type="text" name="WPhtc_maintenance_redirection"
40
- value="<?php echo $WPhtc->get_data('maintenance_redirection') ?>"/>
41
- </td>
42
- <td valign="middle">
43
- <p class="description"><?php _e('If set, this will be used as redirection for disallowed IPs. This could be an external url or a document on your server (local paths begin with a trailing slash)', 'wp-htaccess-control'); ?></p>
44
- </td>
45
- </tr>
46
- </table>
47
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Maintenance Mode -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Maintenance Mode', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( 'Maintenance Active', 'wp-htaccess-control' ); ?></th>
13
+ <td valign="middle">
14
+ <input type="checkbox" name="WPhtc_maintenance_active"
15
+ value="true" <?php if ( $WPhtc->get_data( 'maintenance_active' ) ) {
16
+ echo "checked";
17
+ } ?>/>
18
+ </td>
19
+ <td valign="middle">
20
+ <p class="description"><?php _e( 'Toggles Maintenance Mode.', 'wp-htaccess-control' ); ?></p>
21
+ </td>
22
+ </tr>
23
+ <tr valign="top">
24
+ <th scope="row" style="width:18%;"><?php _e( 'Allowed IPs', 'wp-htaccess-control' ); ?></th>
25
+ <td>
26
+ <textarea name="WPhtc_maintenance_ips"><?php if ( $WPhtc->get_data( 'maintenance_ips' ) ) {
27
+ echo implode( $WPhtc->get_data( 'maintenance_ips' ), "\n" );
28
+ } ?></textarea>
29
+ </td>
30
+ <td valign="middle">
31
+ <p class="description"><?php _e( 'List of allowed IPs.', 'wp-htaccess-control' ); ?></p>
32
 
33
+ <p class="description"><?php _e( 'All the IPs not listed will view the 403 error page or be redirected to a page set below.', 'wp-htaccess-control' ); ?></p>
34
+ </td>
35
+ </tr>
36
+ <tr valign="top">
37
+ <th scope="row" style="width:18%;"><?php _e( 'Redirection', 'wp-htaccess-control' ); ?></th>
38
+ <td>
39
+ <input type="text" name="WPhtc_maintenance_redirection"
40
+ value="<?php echo $WPhtc->get_data( 'maintenance_redirection' ) ?>"/>
41
+ </td>
42
+ <td valign="middle">
43
+ <p class="description"><?php _e( 'If set, this will be used as redirection for disallowed IPs. This could be an external url or a document on your server (local paths begin with a trailing slash)', 'wp-htaccess-control' ); ?></p>
44
+ </td>
45
+ </tr>
46
+ </table>
47
  </div>
admin-ui-includes/more-rewrite.php CHANGED
@@ -1,33 +1,35 @@
1
- <?php global $WPhtc;?>
2
  <!-- More Rewrite Settings -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('More Rewrite Settings', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <th scope="row" style="width:18%;"><?php _e("Remove hierarchy", 'wp-htaccess-control'); ?></th>
13
- <td style="width:3%;" valign="middle">
14
- <input type="checkbox" name="WPhtc_remove_hierarchy"
15
- value="true" <?php if ($WPhtc->get_data('remove_hierarchy')) {
16
- echo "checked";
17
- } ?>/>
18
- </td>
19
- <td valign="middle">
20
- <p class="description"><?php _e("Remove hierarchy from taxonomy permalinks (this might be interesting when removing the category base).", 'wp-htaccess-control'); ?></p>
21
- </td>
22
- </tr>
23
- <!--<tr valign="top">
24
- <th scope="row" style="width:18%;"><?php _e(".html suffix", 'wp-htaccess-control'); ?></th>
25
  <td style="width:3%;" valign="middle">
26
- <input type="checkbox" name="WPhtc_suffix_html" value="true" <?php if($WPhtc->get_data('suffix_html')){ echo "checked";}?>/>
 
 
27
  </td>
28
  <td valign="middle">
29
- <p class="description"><?php _e("Add '.html' at the end of taxonomy permalinks.", 'wp-htaccess-control'); ?></p>
30
  </td>
31
  </tr>-->
32
- </table>
33
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- More Rewrite Settings -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'More Rewrite Settings', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <th scope="row" style="width:18%;"><?php _e( "Remove hierarchy", 'wp-htaccess-control' ); ?></th>
13
+ <td style="width:3%;" valign="middle">
14
+ <input type="checkbox" name="WPhtc_remove_hierarchy"
15
+ value="true" <?php if ( $WPhtc->get_data( 'remove_hierarchy' ) ) {
16
+ echo "checked";
17
+ } ?>/>
18
+ </td>
19
+ <td valign="middle">
20
+ <p class="description"><?php _e( "Remove hierarchy from taxonomy permalinks (this might be interesting when removing the category base).", 'wp-htaccess-control' ); ?></p>
21
+ </td>
22
+ </tr>
23
+ <!--<tr valign="top">
24
+ <th scope="row" style="width:18%;"><?php _e( ".html suffix", 'wp-htaccess-control' ); ?></th>
25
  <td style="width:3%;" valign="middle">
26
+ <input type="checkbox" name="WPhtc_suffix_html" value="true" <?php if ( $WPhtc->get_data( 'suffix_html' ) ) {
27
+ echo "checked";
28
+ } ?>/>
29
  </td>
30
  <td valign="middle">
31
+ <p class="description"><?php _e( "Add '.html' at the end of taxonomy permalinks.", 'wp-htaccess-control' ); ?></p>
32
  </td>
33
  </tr>-->
34
+ </table>
35
  </div>
admin-ui-includes/remove-bases.php CHANGED
@@ -1,63 +1,64 @@
1
- <?php global $WPhtc;?>
2
  <!-- Remove Taxonomies and Author Base -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Remove Taxonomies and Author Base', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <!-- Remove Author Base -->
12
- <tr valign="top">
13
- <th scope="row" style="width:18%;"><?php _e('Remove Author Base', 'wp-htaccess-control'); ?></th>
14
- <td>
15
- <input type="checkbox"
16
- name="WPhtc_remove_author_base" <?php if ($WPhtc->get_data('remove_author_base')) {
17
- echo "checked=checked";
18
- } ?> />
19
- </td>
20
- <td valign="middle">
21
- <p class="description"><?php _e('If active, the author base will be removed from permalinks:'); ?></p>
22
 
23
- <p class="description"><code><?php bloginfo('url') ?>
24
- /<?php _e('the-author', 'wp-htaccess-control'); ?></code></p>
25
 
26
- <p class="description">
27
- <strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the category base on a situation where a category slug is the same as a user nicename.'); ?>
28
- </p>
29
- </td>
30
- </tr>
31
- <!-- Remove Taxonomies Base -->
32
- <?php foreach (get_taxonomies('', 'objects') as $taxonomy) {
33
- if (!$taxonomy->rewrite) {
34
- continue;
35
- }
36
- ?>
37
- <tr valign="top">
38
- <th scope="row" style="width:18%;"><?php _e('Remove', 'wp-htaccess-control');
39
- echo " " . $taxonomy->labels->name . " ";
40
- _e('Base', 'wp-htaccess-control'); ?></th>
41
- <td>
42
- <input type="checkbox"
43
- name="WPhtc_remove_base[<?php echo $taxonomy->name; ?>]" <?php if ($WPhtc->get_data('remove_taxonomy_base', $taxonomy->name)) {
44
- echo "checked=checked";
45
- } ?> />
46
- </td>
47
- <td valign="middle">
48
- <p class="description"><?php _e('If active, the');
49
- echo " " . $taxonomy->labels->name . " ";
50
- _e('base will be removed from permalinks:'); ?></p>
51
 
52
- <p class="description"><code><?php bloginfo('url') ?>/<?php echo $taxonomy->name; ?>_term</code></p>
 
53
 
54
- <p class="description">
55
- <strong><?php _e('Beware:'); ?></strong> <?php _e('This could conflict with the removal of the other permalink bases on a situation where a term slug is the same.'); ?>
56
- </p>
57
- </td>
58
- </tr>
59
- <?php
60
- }
61
- ?>
62
- </table>
63
  </div>
1
+ <?php global $WPhtc; ?>
2
  <!-- Remove Taxonomies and Author Base -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Remove Taxonomies and Author Base', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <!-- Remove Author Base -->
12
+ <tr valign="top">
13
+ <th scope="row" style="width:18%;"><?php _e( 'Remove Author Base', 'wp-htaccess-control' ); ?></th>
14
+ <td>
15
+ <input type="checkbox"
16
+ name="WPhtc_remove_author_base" <?php if ( $WPhtc->get_data( 'remove_author_base' ) ) {
17
+ echo "checked=checked";
18
+ } ?> />
19
+ </td>
20
+ <td valign="middle">
21
+ <p class="description"><?php _e( 'If active, the author base will be removed from permalinks:' ); ?></p>
22
 
23
+ <p class="description"><code><?php bloginfo( 'url' ) ?>
24
+ /<?php _e( 'the-author', 'wp-htaccess-control' ); ?></code></p>
25
 
26
+ <p class="description">
27
+ <strong><?php _e( 'Beware:' ); ?></strong> <?php _e( 'This could conflict with the removal of the category base on a situation where a category slug is the same as a user nicename.' ); ?>
28
+ </p>
29
+ </td>
30
+ </tr>
31
+ <!-- Remove Taxonomies Base -->
32
+ <?php foreach ( get_taxonomies( '', 'objects' ) as $taxonomy ) {
33
+ if ( ! $taxonomy->rewrite ) {
34
+ continue;
35
+ }
36
+ ?>
37
+ <tr valign="top">
38
+ <th scope="row" style="width:18%;"><?php _e( 'Remove', 'wp-htaccess-control' );
39
+ echo " " . $taxonomy->labels->name . " ";
40
+ _e( 'Base', 'wp-htaccess-control' ); ?></th>
41
+ <td>
42
+ <input type="checkbox"
43
+ name="WPhtc_remove_base[<?php echo $taxonomy->name; ?>]" <?php if ( $WPhtc->get_data( 'remove_taxonomy_base', $taxonomy->name ) ) {
44
+ echo "checked=checked";
45
+ } ?> />
46
+ </td>
47
+ <td valign="middle">
48
+ <p class="description"><?php _e( 'If active, the' );
49
+ echo " " . $taxonomy->labels->name . " ";
50
+ _e( 'base will be removed from permalinks:' ); ?></p>
51
 
52
+ <p class="description"><code><?php bloginfo( 'url' ) ?>/<?php echo $taxonomy->name; ?>_term</code>
53
+ </p>
54
 
55
+ <p class="description">
56
+ <strong><?php _e( 'Beware:' ); ?></strong> <?php _e( 'This could conflict with the removal of the other permalink bases on a situation where a term slug is the same.' ); ?>
57
+ </p>
58
+ </td>
59
+ </tr>
60
+ <?php
61
+ }
62
+ ?>
63
+ </table>
64
  </div>
admin-ui-includes/replace-htaccess.php CHANGED
@@ -1,37 +1,37 @@
1
  <?php global $WPhtc; ?>
2
  <!-- Replace WordPress htaccess -->
3
  <div class="wphtc-section">
4
- <div class="wphtc-section-title stuffbox">
5
- <div title="Click to toggle" class="handlediv"
6
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
- <br></div>
8
- <h3><?php _e('Replace WordPress htaccess', 'wp-htaccess-control'); ?></h3>
9
- </div>
10
- <table class="form-table wphtc-inputs">
11
- <tr valign="top">
12
- <td>
13
  <textarea name="WPhtc_wp_hta" style="width:100%;"
14
- rows="7" <?php if ($WPhtc->get_data('jim_morgan_hta')) {
15
- echo "readonly='true' class='readonly'";
16
- } ?>><?php echo stripslashes($WPhtc->get_data('wp_hta')); ?></textarea>
17
 
18
- <p class="description"><?php _e('Leave empty for default.', 'wp-htaccess-control'); ?></p>
19
- </td>
20
- <td style="width:50%;">
21
- <p class="description"><?php _e('This rules will be printed instead of WordPress rules.', 'wp-htaccess-control'); ?></p>
22
 
23
- <p class="description"><?php _e('Please double check them before saving as a mistake could make your site inaccessible.', 'wp-htaccess-control'); ?></p>
24
 
25
- <p class="description"><?php _e('Original rules:', 'wp-htaccess-control'); ?></p>
26
 
27
- <p class="description">
28
- <code><?php echo nl2br(htmlspecialchars(substr($WPhtc->get_data('htaccess_original'), 0, -1))); ?></code>
29
- </p>
30
- </td>
31
- </tr>
32
- <tr>
33
- <td colspan="2">
34
- <p><?php _e("For instance, <strong><a href='http://www.webmasterworld.com/apache/4053973.htm'>Jim Morgan's wordpress htaccess</a></strong> has been reported to \"speed up your WP mod_rewrite code by a factor of more than two\".", 'wp-htaccess-control'); ?></p>
35
 
36
  <pre>RewriteEngine on
37
  # Unless you have set a different RewriteBase preceding this point,
@@ -50,8 +50,8 @@ RewriteRule ^(.*)$ - [S=1]
50
  # else rewrite the request to WP
51
  RewriteRule . /index.php [L]
52
  </pre>
53
- <p><?php _e("Please note, if your WordPress install is in a subdirectory, you'll have to adjust the first RewriteBase and the last RewriteRule accordingly <br/>(ie: <code>RewriteBase /SUBDIRECTORY/</code> and <code>RewriteRule . /SUBDIRECTORY/index.php [L]</code>)", 'wp-htaccess-control'); ?></p>
54
- </td>
55
- </tr>
56
- </table>
57
  </div>
1
  <?php global $WPhtc; ?>
2
  <!-- Replace WordPress htaccess -->
3
  <div class="wphtc-section">
4
+ <div class="wphtc-section-title stuffbox">
5
+ <div title="Click to toggle" class="handlediv"
6
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
7
+ <br></div>
8
+ <h3><?php _e( 'Replace WordPress htaccess', 'wp-htaccess-control' ); ?></h3>
9
+ </div>
10
+ <table class="form-table wphtc-inputs">
11
+ <tr valign="top">
12
+ <td>
13
  <textarea name="WPhtc_wp_hta" style="width:100%;"
14
+ rows="7" <?php if ( $WPhtc->get_data( 'jim_morgan_hta' ) ) {
15
+ echo "readonly='true' class='readonly'";
16
+ } ?>><?php echo stripslashes( $WPhtc->get_data( 'wp_hta' ) ); ?></textarea>
17
 
18
+ <p class="description"><?php _e( 'Leave empty for default.', 'wp-htaccess-control' ); ?></p>
19
+ </td>
20
+ <td style="width:50%;">
21
+ <p class="description"><?php _e( 'This rules will be printed instead of WordPress rules.', 'wp-htaccess-control' ); ?></p>
22
 
23
+ <p class="description"><?php _e( 'Please double check them before saving as a mistake could make your site inaccessible.', 'wp-htaccess-control' ); ?></p>
24
 
25
+ <p class="description"><?php _e( 'Original rules:', 'wp-htaccess-control' ); ?></p>
26
 
27
+ <p class="description">
28
+ <code><?php echo nl2br( htmlspecialchars( substr( $WPhtc->get_data( 'htaccess_original' ), 0, - 1 ) ) ); ?></code>
29
+ </p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td colspan="2">
34
+ <p><?php _e( "For instance, <strong><a href='http://www.webmasterworld.com/apache/4053973.htm'>Jim Morgan's wordpress htaccess</a></strong> has been reported to \"speed up your WP mod_rewrite code by a factor of more than two\".", 'wp-htaccess-control' ); ?></p>
35
 
36
  <pre>RewriteEngine on
37
  # Unless you have set a different RewriteBase preceding this point,
50
  # else rewrite the request to WP
51
  RewriteRule . /index.php [L]
52
  </pre>
53
+ <p><?php _e( "Please note, if your WordPress install is in a subdirectory, you'll have to adjust the first RewriteBase and the last RewriteRule accordingly <br/>(ie: <code>RewriteBase /SUBDIRECTORY/</code> and <code>RewriteRule . /SUBDIRECTORY/index.php [L]</code>)", 'wp-htaccess-control' ); ?></p>
54
+ </td>
55
+ </tr>
56
+ </table>
57
  </div>
admin-ui-includes/sidebar.php CHANGED
@@ -1,36 +1,39 @@
1
  <?php
2
  global $WPhtc;
3
  $plugin_path = $WPhtc->plugin_path;
4
- $plugin_url = $WPhtc->plugin_url;
5
  ?>
6
 
7
  <div id="wphtc-sidebar">
8
- <div class="wphtc-section">
9
- <div class="wphtc-section-title stuffbox">
10
- <!--<div title="Click to toggle" class="handlediv" style="background:url('<?php bloginfo("wpurl")?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent"><br></div>-->
11
- <h3><?php _e('About this Plugin', 'wp-htaccess-control'); ?></h3>
12
- </div>
13
- <div class="wphtc-inputs">
14
- <ul>
15
- <li><a href="http://antonioandra.de/wp-htaccess-control"><img width="16" height="16"
16
- src="<?php echo $plugin_url ?>/images/antonioandra.de_favicon.png">
17
- Plugin Homepage</a></li>
18
- <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"><img
19
- src="<?php echo $plugin_url ?>/images/favicon.ico"> Plugin at WordPress.org </a></li>
20
- <li>
21
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest"><img
22
- width="16" height="16" src="<?php echo $plugin_url ?>/images/pp_favicon_x.ico"> Donate with
23
- Paypal</a></li>
24
- </ul>
25
- </div>
26
- </div>
27
- <div class="wphtc-section">
28
- <div class="wphtc-section-title stuffbox">
29
- <h3><?php _e('Latest donations', 'wp-htaccess-control'); ?></h3>
30
- </div>
31
- <div class="wphtc-inputs">
32
- <iframe width="100%" src="http://antonioandra.de/wp-htaccess-control-donations"></iframe>
33
- </div>
34
- </div>
35
- <p id="foot">WP htaccess Control <?php _e('by', 'wp-htaccess-control'); ?> António Andrade</p>
 
 
 
36
  </div>
1
  <?php
2
  global $WPhtc;
3
  $plugin_path = $WPhtc->plugin_path;
4
+ $plugin_url = $WPhtc->plugin_url;
5
  ?>
6
 
7
  <div id="wphtc-sidebar">
8
+ <div class="wphtc-section">
9
+ <div class="wphtc-section-title stuffbox">
10
+ <!--<div title="Click to toggle" class="handlediv" style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent"><br></div>-->
11
+ <h3><?php _e( 'About this Plugin', 'wp-htaccess-control' ); ?></h3>
12
+ </div>
13
+ <div class="wphtc-inputs">
14
+ <ul>
15
+ <li><a href="http://antonioandra.de/"><img width="16" height="16"
16
+ src="<?php echo $plugin_url ?>/images/antonioandra.de_favicon.png">
17
+ Author Homepage</a></li>
18
+ <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"><img
19
+ src="<?php echo $plugin_url ?>/images/favicon.ico"> Plugin at WordPress.org </a></li>
20
+ <li>
21
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest"><img
22
+ width="16" height="16" src="<?php echo $plugin_url ?>/images/pp_favicon_x.ico"> Donate with
23
+ Paypal</a></li>
24
+ </ul>
25
+ </div>
26
+ </div>
27
+ <!--
28
+ <div class="wphtc-section">
29
+ <div class="wphtc-section-title stuffbox">
30
+ <h3><?php _e( 'Latest donations', 'wp-htaccess-control' ); ?></h3>
31
+ </div>
32
+
33
+ <div class="wphtc-inputs">
34
+ <iframe width="100%" src="http://antonioandra.de/wp-htaccess-control-donations"></iframe>
35
+ </div>
36
+ </div>
37
+ -->
38
+ <p id="foot">WP htaccess Control <?php _e( 'by', 'wp-htaccess-control' ); ?> António Andrade</p>
39
  </div>
index.php CHANGED
@@ -1,24 +1,51 @@
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
  <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <style type="text/css">
6
- html{background-color:#E4F2FD;}
7
- body{color:#333;font-family:Verdana;font-size:0.8em;width:600px;margin:75px auto;padding:30px;background:white;}
8
- h1,h2{font-family:Georgia;}
9
- a{color:#21759B;text-decoration:none;cursor:pointer;}
10
- a:hover{color:#D54E21;text-decoration:underline;}
11
- </style>
12
- <title>WP htaccess Control Plugin</title>
13
- </head>
14
- <body>
15
- <h1><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/" title="Visit this Plugin at the WordPress Plugin Directory">WP htaccess Control</a></h1>
16
- <p><strong>Plugin Author:</strong> <a href="http://antonioandra.de/" title="Visit the Author">António Andrade</a></p>
17
- <h2>Links</h2>
18
- <ul>
19
- <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/" title="Visit this Plugin at the WordPress Plugin Directory">WP htaccess Control at the Plugin Directory</a></li>
20
- <li><a href="http://antonioandra.de/wp-htaccess-control" title="Visit the Plugin Homepage">Plugin Homepage</a></li>
21
- <li><a href="http://antonioandra.de/" title="Visit the Author">Author Homepage</a></li>
22
- </ul>
23
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  </html>
1
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
  <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <style type="text/css">
6
+ html {
7
+ background-color: #E4F2FD;
8
+ }
9
+
10
+ body {
11
+ color: #333;
12
+ font-family: Verdana;
13
+ font-size: 0.8em;
14
+ width: 600px;
15
+ margin: 75px auto;
16
+ padding: 30px;
17
+ background: white;
18
+ }
19
+
20
+ h1, h2 {
21
+ font-family: Georgia;
22
+ }
23
+
24
+ a {
25
+ color: #21759B;
26
+ text-decoration: none;
27
+ cursor: pointer;
28
+ }
29
+
30
+ a:hover {
31
+ color: #D54E21;
32
+ text-decoration: underline;
33
+ }
34
+ </style>
35
+ <title>WP htaccess Control Plugin</title>
36
+ </head>
37
+ <body>
38
+ <h1><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"
39
+ title="Visit this Plugin at the WordPress Plugin Directory">WP htaccess Control</a></h1>
40
+
41
+ <p><strong>Plugin Author:</strong> <a href="http://antonioandra.de/" title="Visit the Author">António Andrade</a></p>
42
+
43
+ <h2>Links</h2>
44
+ <ul>
45
+ <li><a href="http://wordpress.org/extend/plugins/wp-htaccess-control/"
46
+ title="Visit this Plugin at the WordPress Plugin Directory">WP htaccess Control at the Plugin Directory</a>
47
+ </li>
48
+ <li><a href="http://antonioandra.de/" title="Visit the Author">Author Homepage</a></li>
49
+ </ul>
50
+ </body>
51
  </html>
readme.txt CHANGED
@@ -5,9 +5,9 @@ Plugin URI: http://antonioandra.de/
5
  Contributors: antonioandra.de
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest
7
  Tags: permalinks, permalink, author, htaccess, rewrite, redirect, admin, maintenance, pagination, category, category base, archive, archives
8
- Requires at least: 3.4
9
- Tested up to: 3.9
10
- Stable tag: 3.4.5
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
13
 
5
  Contributors: antonioandra.de
6
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest
7
  Tags: permalinks, permalink, author, htaccess, rewrite, redirect, admin, maintenance, pagination, category, category base, archive, archives
8
+ Requires at least: 3.9
9
+ Tested up to: 4.3.1
10
+ Stable tag: 3.5
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
13
 
wp-htaccess-control-ui.css CHANGED
@@ -1,94 +1,131 @@
1
  #wphtc-sidebar {
2
- width: 19%;
3
- float: right; }
4
- #wphtc-sidebar ul {
5
- margin: 1em 0 1em 10px; }
6
- #wphtc-sidebar a {
7
- text-decoration: none; }
8
- #wphtc-sidebar a img {
9
- margin-right: 5px; }
 
 
 
 
 
 
 
10
 
11
  #wphtc-main {
12
- float: left;
13
- width: 80%;
14
- margin-bottom: 25px; }
 
15
 
16
  div.updated p img {
17
- margin: -5px 15px; }
 
 
18
  div.updated p span {
19
- float: right; }
 
20
 
21
  .wphtc-menu {
22
- margin: 10px 0; }
 
23
 
24
  .wphtc-section {
25
- background: #ddd;
26
- border: 1px solid #ddd;
27
- border-bottom: 0;
28
- margin-top: 15px;
29
- -moz-border-radius: 6px;
30
- -webkit-border-radius: 6px; }
 
31
 
32
  .wphtc-section-title {
33
- -moz-user-select: none;
34
- -khtml-user-select: none;
35
- user-select: none;
36
- margin-bottom: 0;
37
- width: 100%;
38
- border: 0; }
39
- .wphtc-section-title h3 {
 
 
40
  margin: 0;
41
  padding: 10px;
42
  cursor: pointer;
43
  border-bottom: 0;
44
  -moz-border-radius: 6px;
45
- -webkit-border-radius: 6px; }
46
- .wphtc-section-title .handlediv {
 
 
47
  float: right;
48
  height: 34px;
49
  width: 23px;
50
- cursor: pointer; }
 
51
 
52
  .wphtc-inputs {
53
- background: #fff;
54
- border: 1px solid #ddd;
55
- border-left: 0;
56
- border-right: 0;
57
- -moz-border-radius: 6px;
58
- -webkit-border-radius: 6px; }
59
- .wphtc-inputs p, .wphtc-inputs ul {
60
- margin-left: 10px; }
61
- .wphtc-inputs th {
 
 
 
 
62
  font-weight: bold;
63
- padding-left: 12px; }
64
- .wphtc-inputs tr {
65
- border-bottom: 1px solid #dddddd; }
66
- .wphtc-inputs caption {
 
 
 
 
67
  text-align: left;
68
  padding: 10px;
69
- background: #ddd; }
70
- .wphtc-inputs pre {
 
 
71
  margin: 2.5%;
72
  width: 95%;
73
- overflow: auto; }
 
74
 
75
  .form-table {
76
- margin: 0; }
 
77
 
78
  #foot {
79
- text-align: center;
80
- font-size: 8px;
81
- color: #aaa;
82
- margin: 2em 0; }
 
83
 
84
  textarea.readonly {
85
- background-color: #eee; }
 
86
 
87
  ul.description {
88
- margin-top: 1em;
89
- margin-left: 2em;
90
- font-style: italic; }
91
- ul.description a {
92
- text-decoration: none; }
93
- ul.description li {
94
- color: #666; }
 
 
 
 
 
1
  #wphtc-sidebar {
2
+ width: 19%;
3
+ float: right;
4
+ }
5
+
6
+ #wphtc-sidebar ul {
7
+ margin: 1em 0 1em 10px;
8
+ }
9
+
10
+ #wphtc-sidebar a {
11
+ text-decoration: none;
12
+ }
13
+
14
+ #wphtc-sidebar a img {
15
+ margin-right: 5px;
16
+ }
17
 
18
  #wphtc-main {
19
+ float: left;
20
+ width: 80%;
21
+ margin-bottom: 25px;
22
+ }
23
 
24
  div.updated p img {
25
+ margin: -5px 15px;
26
+ }
27
+
28
  div.updated p span {
29
+ float: right;
30
+ }
31
 
32
  .wphtc-menu {
33
+ margin: 10px 0;
34
+ }
35
 
36
  .wphtc-section {
37
+ background: #ddd;
38
+ border: 1px solid #ddd;
39
+ border-bottom: 0;
40
+ margin-top: 15px;
41
+ -moz-border-radius: 6px;
42
+ -webkit-border-radius: 6px;
43
+ }
44
 
45
  .wphtc-section-title {
46
+ -moz-user-select: none;
47
+ -khtml-user-select: none;
48
+ user-select: none;
49
+ margin-bottom: 0;
50
+ width: 100%;
51
+ border: 0;
52
+ }
53
+
54
+ .wphtc-section-title h3 {
55
  margin: 0;
56
  padding: 10px;
57
  cursor: pointer;
58
  border-bottom: 0;
59
  -moz-border-radius: 6px;
60
+ -webkit-border-radius: 6px;
61
+ }
62
+
63
+ .wphtc-section-title .handlediv {
64
  float: right;
65
  height: 34px;
66
  width: 23px;
67
+ cursor: pointer;
68
+ }
69
 
70
  .wphtc-inputs {
71
+ background: #fff;
72
+ border: 1px solid #ddd;
73
+ border-left: 0;
74
+ border-right: 0;
75
+ -moz-border-radius: 6px;
76
+ -webkit-border-radius: 6px;
77
+ }
78
+
79
+ .wphtc-inputs p, .wphtc-inputs ul {
80
+ margin-left: 10px;
81
+ }
82
+
83
+ .wphtc-inputs th {
84
  font-weight: bold;
85
+ padding-left: 12px;
86
+ }
87
+
88
+ .wphtc-inputs tr {
89
+ border-bottom: 1px solid #dddddd;
90
+ }
91
+
92
+ .wphtc-inputs caption {
93
  text-align: left;
94
  padding: 10px;
95
+ background: #ddd;
96
+ }
97
+
98
+ .wphtc-inputs pre {
99
  margin: 2.5%;
100
  width: 95%;
101
+ overflow: auto;
102
+ }
103
 
104
  .form-table {
105
+ margin: 0;
106
+ }
107
 
108
  #foot {
109
+ text-align: center;
110
+ font-size: 8px;
111
+ color: #aaa;
112
+ margin: 2em 0;
113
+ }
114
 
115
  textarea.readonly {
116
+ background-color: #eee;
117
+ }
118
 
119
  ul.description {
120
+ margin-top: 1em;
121
+ margin-left: 2em;
122
+ font-style: italic;
123
+ }
124
+
125
+ ul.description a {
126
+ text-decoration: none;
127
+ }
128
+
129
+ ul.description li {
130
+ color: #666;
131
+ }
wp-htaccess-control-ui.js CHANGED
@@ -1,36 +1,37 @@
1
- jQuery(document).ready(function(){
2
- collapseSections();
3
- editWPhtaJM();
4
- function collapseSections(){
5
- jQuery("#wphtc-main .wphtc-inputs,.wphtc-section-title a").not(".wphtc-inputs.start-open").hide();
6
- jQuery(".handlediv").fadeOut(0);
7
- jQuery("#wphtc-main .wphtc-section").hover(
8
- function(){
9
- jQuery(this).find(".handlediv").fadeIn(150);
10
- },
11
- function(){
12
- jQuery(this).find(".handlediv").fadeOut(150);
13
- }
14
- )
15
- jQuery("#wphtc-main .wphtc-section:not(.permanently-open) .wphtc-section-title h3").click(
16
- function(){
17
- if(jQuery(this).parent().find("a")){
18
- jQuery(this).parent().find("a").toggle();
19
- }
20
- jQuery(this).parent().next(".wphtc-inputs").toggle();
21
- }
22
- );
23
- }
24
- function editWPhtaJM(){
25
- jQuery("input[name='WPhtc_jim_morgan_hta']").click(
26
- function(){
27
- if(jQuery("textarea[name='WPhtc_wp_hta']").attr('readonly')==true){
28
- jQuery("textarea[name='WPhtc_wp_hta']").text('').removeAttr("readonly").removeClass('readonly');
29
- }
30
- else{
31
- jQuery("textarea[name='WPhtc_wp_hta']").addClass('readonly');
32
- }
33
- }
34
- );
35
- }
36
- });
 
1
+ jQuery(document).ready(function () {
2
+ collapseSections();
3
+ editWPhtaJM();
4
+ function collapseSections() {
5
+ jQuery("#wphtc-main .wphtc-inputs,.wphtc-section-title a").not(".wphtc-inputs.start-open").hide();
6
+ jQuery(".handlediv").fadeOut(0);
7
+ jQuery("#wphtc-main .wphtc-section").hover(
8
+ function () {
9
+ jQuery(this).find(".handlediv").fadeIn(150);
10
+ },
11
+ function () {
12
+ jQuery(this).find(".handlediv").fadeOut(150);
13
+ }
14
+ )
15
+ jQuery("#wphtc-main .wphtc-section:not(.permanently-open) .wphtc-section-title h3").click(
16
+ function () {
17
+ if (jQuery(this).parent().find("a")) {
18
+ jQuery(this).parent().find("a").toggle();
19
+ }
20
+ jQuery(this).parent().next(".wphtc-inputs").toggle();
21
+ }
22
+ );
23
+ }
24
+
25
+ function editWPhtaJM() {
26
+ jQuery("input[name='WPhtc_jim_morgan_hta']").click(
27
+ function () {
28
+ if (jQuery("textarea[name='WPhtc_wp_hta']").attr('readonly') == true) {
29
+ jQuery("textarea[name='WPhtc_wp_hta']").text('').removeAttr("readonly").removeClass('readonly');
30
+ }
31
+ else {
32
+ jQuery("textarea[name='WPhtc_wp_hta']").addClass('readonly');
33
+ }
34
+ }
35
+ );
36
+ }
37
+ });
wp-htaccess-control-ui.php CHANGED
@@ -1,139 +1,156 @@
1
  <?php
2
  global $WPhtc, $WPhtcEcho;
3
- $debug = false;
4
- $WPhtc->plugin_path=$plugin_path = WP_CONTENT_DIR . '/plugins/' . plugin_basename(dirname(__FILE__));
5
- $WPhtc->plugin_url=$plugin_url = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__));
6
 
7
  //$q=explode('&',$_SERVER['QUERY_STRING']);
8
  //$purl='http'.((!empty($_SERVER['HTTPS'])) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$q[0];
9
 
10
- $q = explode("&", $_SERVER['REQUEST_URI']);
11
  $purl = $q[0];
12
  $WPhtc->page_action();
13
 
14
- function WPHTCui($namesArray){
15
- $plugin_path = WP_CONTENT_DIR . '/plugins/' . plugin_basename(dirname(__FILE__));
16
- if(!is_array($namesArray)){
17
- $namesArray=array($namesArray);
18
- }
19
- foreach($namesArray as $name){
20
- include($plugin_path.'/admin-ui-includes/'.$name.'.php');
21
- }
22
  }
 
23
  ?>
24
 
25
  <div id="wphtc-page" class="wrap">
26
- <h2>WP htaccess Control</h2>
27
- <?php
28
- if (!current_user_can("administrator")) {
29
- echo '<p>' . __('Please log in as admin', 'wp-htaccess-control') . '</p>';
30
- return;
31
- }
32
- ?>
33
-
34
- <?php WPHTCui('sidebar') ?>
35
-
36
- <div id="wphtc-main">
37
- <form method="post" action="<?php echo $purl ?>">
38
- <?php if ($WPhtcEcho != '') { ?>
39
- <div class="updated fade" id="message" style="background-color: rgb(255, 251, 204);"><p><?php echo $WPhtcEcho; ?></p>
40
- </div>
41
- <?php
42
- }
43
- # Donation Message
44
- if ($WPhtc->get_data('donation_hidden_time') && $WPhtc->get_data('donation_hidden_time') < time()) {
45
- ?>
46
- <div class="updated">
47
- <p>
48
- <strong>Is this plugin useful? Consider making a donation encouraging me to continue supporting it!</strong>
49
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest"><img
50
- alt="Donate" border="0"
51
- src="https://www.paypalobjects.com/WEBSCR-640-20110306-1/en_US/i/btn/btn_donate_SM.gif"></a>
52
- <span><a href="<?php echo $purl ?>&action=hide_donation_message">Hide this message</a></span>
53
- </p>
54
- </div>
55
- <?php } ?>
56
- <?php WPHTCui(array(
57
- 'custom-author-permalink',
58
- 'custom-pagination-permalink',
59
- 'custom-search-permalink',
60
- 'remove-bases',
61
- 'advanced-archives',
62
- 'more-rewrite',
63
- 'custom-htaccess',
64
- 'replace-htaccess',
65
- 'htaccess-suggestions',
66
- 'maintenance-mode'
67
- )) ?>
68
-
69
- <?php wp_nonce_field('WPhtc_settings'); ?>
70
- <input type="hidden" name="action" value="update"/>
71
-
72
- <div class="wphtc-menu">
73
- <a class="button-secondary"
74
- href="<?php echo wp_nonce_url($purl . "&action=reset_rules", 'WPhtc_reset_settings'); ?>"><?php _e('Reset all rules', 'wp-htaccess-control'); ?></a>
75
- <input type="submit" class="button-primary" value="<?php _e('Save all changes', 'wp-htaccess-control'); ?>"/>
76
- </div>
77
- </form>
78
- <div class="wphtc-section">
79
- <div class="wphtc-section-title stuffbox">
80
- <div title="Click to toggle" class="handlediv"
81
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
82
- <br></div>
83
- <h3><?php _e('Current htaccess file as it is generated by WordPress', 'wp-htaccess-control'); ?></h3>
84
- </div>
85
- <div class="wphtc-inputs start-open">
86
- <p>
87
- <code><?php echo str_replace(array("&lt;br /&gt;", "&lt;br/&gt;"), "<br/>", htmlspecialchars($WPhtc->get_data('cur_hta'))); ?></code>
88
- </p>
89
- </div>
90
- </div>
91
-
92
- <!-- INSTRUCTIONS -->
93
- <div class="wphtc-section permanently-open">
94
- <div class="wphtc-section-title stuffbox">
95
- <h3><?php _e('Read Me', 'wp-table-of-paginated-contents'); ?></h3>
96
- </div>
97
- <table class="form-table wphtc-inputs start-open">
98
- <tr valign="top">
99
- <th scope="row" style="width:18%;"></th>
100
- <td>
101
- <p class="description"><?php _e('This plugin has made such a long way that it should really now be called <strong>WP htaccess and Rewrite Control</strong>.', 'wp-htaccess-control'); ?></p>
102
-
103
- <p class="description"><?php _e('Some of the features it provides might not work as expect on all environments and setups. You are advised to test configurations on a separate staging, on the same server and with the same theme and plugins. Please report any issues you might face.', 'wp-htaccess-control'); ?></p>
104
- <p class="description"><?php _e('If your setup seems to get out of control there are a few options to reverse all changes:', 'wp-htaccess-control'); ?></p>
105
- <ul class="description">
106
- <li>1) <?php _e('Click on "Reset all rules", at the bottom of this page;', 'wp-htaccess-control'); ?></li>
107
- <li>2) <?php _e('rename/delete the plugin folder and re-submit your permalink settings under "Settings > Permalinks"', 'wp-htaccess-control'); ?> </li>
108
- <li>3) <?php _e('if the previous did not solve your issue, remove the .htaccess file on your blog\'s root directory and repeat step 2;', 'wp-htaccess-control'); ?></li>
109
- <li>4) <?php _e('in such cases you might want to get back back to the last version you knew working, which you\'ll find at', 'wp-htaccess-control'); ?> <a href="http://wordpress.org/extend/plugins/wp-htaccess-control/download/">http://wordpress.org/extend/plugins/wp-htaccess-control/download/</a>.</li>
110
- </ul>
111
- <p><?php _e('Version 3.3 was tested up to WordPress 3.5.1.', 'wp-htaccess-control'); ?></p>
112
- <p><?php _e('Version 3.4 was tested on WordPress 3.9.', 'wp-htaccess-control'); ?></p>
113
- </td>
114
- </tr>
115
- </table>
116
- </div>
117
-
118
- <?php if ($debug) { ?>
119
- <div class="wphtc-section start-open">
120
- <div class="wphtc-section-title stuffbox">
121
- <div title="Click to toggle" class="handlediv"
122
- style="background:url('<?php bloginfo("wpurl") ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
123
- <br></div>
124
- <h3><?php _e('Debug Data', 'wp-htaccess-control'); ?></h3>
125
- </div>
126
- <div class="wphtc-inputs">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  <pre>
128
- <?php print_r($WPhtc->data); ?>
129
  </pre>
130
 
131
  <pre>
132
  <?php global $wp_rewrite;
133
- print_r($wp_rewrite); ?>
134
  </pre>
135
- </div>
136
- </div>
137
- <?php } ?>
138
- </div>
139
  </div>
1
  <?php
2
  global $WPhtc, $WPhtcEcho;
3
+ $debug = false;
4
+ $WPhtc->plugin_path = $plugin_path = WP_CONTENT_DIR . '/plugins/' . plugin_basename( dirname( __FILE__ ) );
5
+ $WPhtc->plugin_url = $plugin_url = WP_CONTENT_URL . '/plugins/' . plugin_basename( dirname( __FILE__ ) );
6
 
7
  //$q=explode('&',$_SERVER['QUERY_STRING']);
8
  //$purl='http'.((!empty($_SERVER['HTTPS'])) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$q[0];
9
 
10
+ $q = explode( "&", $_SERVER['REQUEST_URI'] );
11
  $purl = $q[0];
12
  $WPhtc->page_action();
13
 
14
+ function WPHTCui( $namesArray ) {
15
+ $plugin_path = WP_CONTENT_DIR . '/plugins/' . plugin_basename( dirname( __FILE__ ) );
16
+ if ( ! is_array( $namesArray ) ) {
17
+ $namesArray = array( $namesArray );
18
+ }
19
+ foreach ( $namesArray as $name ) {
20
+ include( $plugin_path . '/admin-ui-includes/' . $name . '.php' );
21
+ }
22
  }
23
+
24
  ?>
25
 
26
  <div id="wphtc-page" class="wrap">
27
+ <h2>WP htaccess Control</h2>
28
+ <?php
29
+ if ( ! current_user_can( "administrator" ) ) {
30
+ echo '<p>' . __( 'Please log in as admin', 'wp-htaccess-control' ) . '</p>';
31
+
32
+ return;
33
+ }
34
+ ?>
35
+
36
+ <?php WPHTCui( 'sidebar' ) ?>
37
+
38
+ <div id="wphtc-main">
39
+ <form method="post" action="<?php echo $purl ?>">
40
+ <?php if ( $WPhtcEcho != '' ) { ?>
41
+ <div class="updated fade" id="message" style="background-color: rgb(255, 251, 204);">
42
+ <p><?php echo $WPhtcEcho; ?></p>
43
+ </div>
44
+ <?php
45
+ }
46
+ # Donation Message
47
+ if ( $WPhtc->get_data( 'donation_hidden_time' ) && $WPhtc->get_data( 'donation_hidden_time' ) < time() ) {
48
+ ?>
49
+ <div class="updated">
50
+ <p>
51
+ <strong>Is this plugin useful? Consider making a donation encouraging me to continue supporting
52
+ it!</strong>
53
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=antonio%40antonioandra%2ede&lc=US&item_name=WP%20htaccess%20Control%20%28Antonio%20Andrade%29&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest">
54
+ <img alt="Donate" border="0"
55
+ src="https://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_74x21.png">
56
+ </a>
57
+ <span><a href="<?php echo $purl ?>&action=hide_donation_message">Hide this message</a></span>
58
+ </p>
59
+ </div>
60
+ <?php } ?>
61
+ <?php WPHTCui( array(
62
+ 'custom-author-permalink',
63
+ 'custom-pagination-permalink',
64
+ 'custom-search-permalink',
65
+ 'remove-bases',
66
+ 'advanced-archives',
67
+ 'more-rewrite',
68
+ 'custom-htaccess',
69
+ 'replace-htaccess',
70
+ 'htaccess-suggestions',
71
+ 'maintenance-mode'
72
+ ) ) ?>
73
+
74
+ <?php wp_nonce_field( 'WPhtc_settings' ); ?>
75
+ <input type="hidden" name="action" value="update"/>
76
+
77
+ <div class="wphtc-menu">
78
+ <a class="button-secondary"
79
+ href="<?php echo wp_nonce_url( $purl . "&action=reset_rules", 'WPhtc_reset_settings' ); ?>"><?php _e( 'Reset all rules', 'wp-htaccess-control' ); ?></a>
80
+ <input type="submit" class="button-primary"
81
+ value="<?php _e( 'Save all changes', 'wp-htaccess-control' ); ?>"/>
82
+ </div>
83
+ </form>
84
+ <div class="wphtc-section">
85
+ <div class="wphtc-section-title stuffbox">
86
+ <div title="Click to toggle" class="handlediv"
87
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
88
+ <br></div>
89
+ <h3><?php _e( 'Current htaccess file as it is generated by WordPress', 'wp-htaccess-control' ); ?></h3>
90
+ </div>
91
+ <div class="wphtc-inputs start-open">
92
+ <p>
93
+ <code><?php echo str_replace( array(
94
+ "&lt;br /&gt;",
95
+ "&lt;br/&gt;"
96
+ ), "<br/>", htmlspecialchars( $WPhtc->get_data( 'cur_hta' ) ) ); ?></code>
97
+ </p>
98
+ </div>
99
+ </div>
100
+
101
+ <!-- INSTRUCTIONS -->
102
+ <div class="wphtc-section permanently-open">
103
+ <div class="wphtc-section-title stuffbox">
104
+ <h3><?php _e( 'Read Me', 'wp-table-of-paginated-contents' ); ?></h3>
105
+ </div>
106
+ <table class="form-table wphtc-inputs start-open">
107
+ <tr valign="top">
108
+ <th scope="row" style="width:18%;"></th>
109
+ <td>
110
+ <p class="description"><?php _e( 'This plugin has made such a long way that it should really now be called <strong>WP htaccess and Rewrite Control</strong>.', 'wp-htaccess-control' ); ?></p>
111
+
112
+ <p class="description"><?php _e( 'Some of the features it provides might not work as expect on all environments and setups. You are advised to test configurations on a separate staging, on the same server and with the same theme and plugins. Please report any issues you might face.', 'wp-htaccess-control' ); ?></p>
113
+
114
+ <p class="description"><?php _e( 'If your setup seems to get out of control there are a few options to reverse all changes:', 'wp-htaccess-control' ); ?></p>
115
+ <ul class="description">
116
+ <li>
117
+ 1) <?php _e( 'Click on "Reset all rules", at the bottom of this page;', 'wp-htaccess-control' ); ?></li>
118
+ <li>
119
+ 2) <?php _e( 'rename/delete the plugin folder and re-submit your permalink settings under "Settings > Permalinks"', 'wp-htaccess-control' ); ?> </li>
120
+ <li>
121
+ 3) <?php _e( 'if the previous did not solve your issue, remove the .htaccess file on your blog\'s root directory and repeat step 2;', 'wp-htaccess-control' ); ?></li>
122
+ <li>
123
+ 4) <?php _e( 'in such cases you might want to get back back to the last version you knew working, which you\'ll find at', 'wp-htaccess-control' ); ?>
124
+ <a href="http://wordpress.org/extend/plugins/wp-htaccess-control/download/">http://wordpress.org/extend/plugins/wp-htaccess-control/download/</a>.
125
+ </li>
126
+ </ul>
127
+ <p><?php _e( 'Version 3.3 was tested up to WordPress 3.5.1.', 'wp-htaccess-control' ); ?></p>
128
+
129
+ <p><?php _e( 'Version 3.4 was tested on WordPress 3.9.', 'wp-htaccess-control' ); ?></p>
130
+ </td>
131
+ </tr>
132
+ </table>
133
+ </div>
134
+
135
+ <?php if ( $debug ) { ?>
136
+ <div class="wphtc-section start-open">
137
+ <div class="wphtc-section-title stuffbox">
138
+ <div title="Click to toggle" class="handlediv"
139
+ style="background:url('<?php bloginfo( "wpurl" ) ?>/wp-admin/images/menu-bits.gif') no-repeat scroll left -111px transparent">
140
+ <br></div>
141
+ <h3><?php _e( 'Debug Data', 'wp-htaccess-control' ); ?></h3>
142
+ </div>
143
+ <div class="wphtc-inputs">
144
  <pre>
145
+ <?php print_r( $WPhtc->data ); ?>
146
  </pre>
147
 
148
  <pre>
149
  <?php global $wp_rewrite;
150
+ print_r( $wp_rewrite ); ?>
151
  </pre>
152
+ </div>
153
+ </div>
154
+ <?php } ?>
155
+ </div>
156
  </div>
wp-htaccess-control-ui.scss CHANGED
@@ -79,7 +79,7 @@ div.updated p {
79
 
80
  th {
81
  font-weight: bold;
82
- padding-left:12px;
83
  }
84
 
85
  tr {
@@ -116,12 +116,12 @@ textarea.readonly {
116
 
117
  ul.description {
118
  margin-top: 1em;
119
- margin-left:2em;
120
- font-style:italic;
121
  a {
122
  text-decoration: none;
123
  }
124
- li{
125
- color:#666;
126
  }
127
  }
79
 
80
  th {
81
  font-weight: bold;
82
+ padding-left: 12px;
83
  }
84
 
85
  tr {
116
 
117
  ul.description {
118
  margin-top: 1em;
119
+ margin-left: 2em;
120
+ font-style: italic;
121
  a {
122
  text-decoration: none;
123
  }
124
+ li {
125
+ color: #666;
126
  }
127
  }
wp-htaccess-control.php CHANGED
@@ -26,339 +26,330 @@ Author URI: http://antonioandra.de
26
  /* Removal of the Category Base is based on WP No Category Base by Saurabh Gupta, 2008
27
  Search redirection is based on Nice Search by Mark Jaquith, 2011 */
28
 
29
- if (!class_exists("WPhtc")) {
30
- class WPhtc
31
- {
32
-
33
- public $data;
34
-
35
- public $defaultData = array(
36
- "maintenance_active" => false,
37
- "login_disabled" => false,
38
- "hta" => false,
39
- "disable_serversignature" => false,
40
- "admin_email" => false,
41
- "disable_indexes" => false,
42
- "up_limit" => false,
43
- "redirect_500" => false,
44
- "redirect_403" => false,
45
- "protect_wp_config" => false,
46
- "protect_htaccess" => false,
47
- "protect_comments" => false,
48
- "disable_hotlink" => false,
49
- "disable_file_hotlink_ext" => false,
50
- "canon" => false,
51
- "gzip" => false,
52
- "deflate" => false,
53
- "wp_hta" => false,
54
- "cpp" => false,
55
- "cap" => false,
56
- "custom_search_permalink" => false,
57
- "remove_taxonomy_base" => false,
58
- "create_archive" => false,
59
- "remove_author_base" => false,
60
- "htaccess_original" => false,
61
- "suffix_html" => false,
62
- "donation_hidden_time" => false,
63
- );
64
-
65
- function WPhtc()
66
- {
67
- $data = get_option('WPhtc_data');
68
- if ($data) {
69
- $this->data = array_merge($this->defaultData, $data);
70
- } else {
71
- add_option('WPhtc_data', $this->defaultData);
72
- }
73
- }
74
-
75
- /*
76
- * @param $key
77
- */
78
- function get_data($key, $key_inner=null)
79
- {
80
- if (isset($this->data[$key])) {
81
- if ($key_inner != "" && isset($this->data[$key][$key_inner])) {
82
- return $this->data[$key][$key_inner];
83
- } else if(!isset($key_inner)) {
84
- return $this->data[$key];
85
- }
86
- } else {
87
- return null;
88
- }
89
- }
90
-
91
- function init()
92
- {
93
- # set locale
94
- $currentLocale = get_locale();
95
- if (!empty($currentLocale)) {
96
- $moFile = dirname(__FILE__) . "/lang/wp-htaccess-control-" . $currentLocale . ".mo";
97
- if (@file_exists($moFile) && is_readable($moFile)) load_textdomain('wp-htaccess-control', $moFile);
98
- }
99
- }
100
-
101
- function search_template_redirect()
102
- {
103
- # redirect "?s=*" to "/search-base/*"
104
- if ($_GET['s']) {
105
- wp_redirect(home_url($this->data['custom_search_permalink'] . "/" . rawurlencode(get_query_var('s'))));
106
- }
107
-
108
- # rewrite query
109
- if (strpos($_SERVER["REQUEST_URI"], $this->data['custom_search_permalink'])) {
110
- global $wp_query;
111
- if (strpos($_SERVER["REQUEST_URI"], '/feed')) {
112
- preg_match("/feed\/(feed|rdf|rss|rss2|atom)?/", $_SERVER["REQUEST_URI"], $feed);
113
- if ($feed[1]) {
114
- $format = "&feed=" . $feed[1];
115
- } else {
116
- $format = "&feed=feed";
117
- }
118
- }
119
- $page_base = ($this->data['cpp'] != '') ? $this->data['cpp'] : 'page';
120
-
121
- # in need of better regex
122
- if (!strpos($_SERVER["REQUEST_URI"], '/feed') && !strpos($_SERVER["REQUEST_URI"], $page_base)) {
123
- $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
124
- } else {
125
- $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)\/feed|" . $page_base . "?/";
126
- }
127
-
128
- $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
129
- preg_match($pattern, $_SERVER["REQUEST_URI"], $matches);
130
- $results = split("/", $matches[1]);
131
- if ($results[1] == $page_base) {
132
- $page = "&paged=" . $results[2];
133
- }
134
- $wp_query = new WP_Query('s=' . $results[0] . $page . $format);
135
- }
136
- }
137
-
138
- # return get_search_query on custom search base
139
- function get_search_query_filter($query)
140
- {
141
-
142
- if ($this->data['custom_search_permalink'] != '' && strpos($_SERVER["REQUEST_URI"], $this->data['custom_search_permalink'])) {
143
- $page_base = ($this->data['cpp'] != '') ? $this->data['cpp'] : 'page';
144
- # in need of better regex
145
- if (!strpos($_SERVER["REQUEST_URI"], '/feed') && !strpos($_SERVER["REQUEST_URI"], "/" . $page_base)) {
146
- $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
147
- } else {
148
- $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)\/feed|" . $page_base . "?/";
149
- }
150
- preg_match($pattern, $_SERVER["REQUEST_URI"], $matches);
151
- $results = split("/", $matches[1]);
152
- return urldecode($results[0]);
153
- }
154
- return $query;
155
- }
156
-
157
- function search_feed_link($link)
158
- {
159
-
160
- $link = str_replace("search", $this->data['custom_search_permalink'], $link);
161
- return $link;
162
- }
163
-
164
- function check_first_run()
165
- {
166
- # flush rules to get some data filled on first usage
167
- if (!isset($this->data['htaccess_original'])) {
168
- $this->refresh_rewrite_rules();
169
- }
170
- }
171
-
172
- # Flush rules
173
- /*
174
- * @var $wp_rewrite WP_Rewrite
175
- */
176
- function refresh_rewrite_rules()
177
- {
178
- global $wp_rewrite;
179
- $wp_rewrite->flush_rules();
180
- }
181
-
182
- function refresh_rewrite_rules_later()
183
- {
184
- wp_schedule_single_event(time(), 'flush_event');
185
- }
186
-
187
- # Filter pagination links generated by WordPress
188
- function filter_get_pagenum_link($result)
189
- {
190
- $result = preg_replace("/" . urlencode($this->data['cpp']) . "\/[0-9]+[\/]?/", "", $result);
191
- $result = str_replace("page", urlencode($this->data['cpp']), $result);
192
- return $result;
193
- }
194
-
195
- # Filter link generated by get_author_posts_url() to use the Custom Author Permalink
196
- function filter_author_link($link)
197
- {
198
-
199
- if ($this->data['remove_author_base']) {
200
- $link = str_replace("author/", "", $link);
201
- } else if (isset($this->data['cap']) && $this->data['cap'] != '') {
202
- $link = str_replace("author", urlencode($this->data['cap']), $link);
203
- }
204
- return $link;
205
- }
206
-
207
- function filter_redirect_canonical($requested_url)
208
- {
209
- global $wp;
210
-
211
- # Disable canonical redirection on urls using custom pagination permalink
212
- if (isset($this->data['cpp']) && $this->data['cpp'] != '' && get_query_var('paged') > 1 && preg_match("/" . urlencode($this->data['cpp']) . "/", $wp->request)) {
213
- return false;
214
- } else {
215
- return $requested_url;
216
- }
217
- }
218
-
219
- # ancestors nesting method
220
- function term_ancestors($tax, $id)
221
- {
222
- $term = get_term($id, $tax);
223
- $ancestor = $term->slug;
224
-
225
- if ($term->parent != 0 && !$this->data['remove_hierarchy']) {
226
- $ancestor = $this->term_ancestors($tax, $term->parent) . "/" . $ancestor;
227
- }
228
- return $ancestor;
229
- }
230
-
231
- # Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
232
- function filter_rewrite_rules($rewrite_rules)
233
- {
234
-
235
- $new_rules = array();
236
-
237
- $page_base = ($this->data['cpp'] != '') ? $this->data['cpp'] : 'page';
238
-
239
- // if we have either to remove the tax base or create tax archives
240
- if (isset($this->data['create_archive']) or isset($this->data['remove_taxonomy_base'])) {
241
- foreach (get_taxonomies('', 'objects') as $taxonomy) {
242
- if (!$taxonomy->rewrite
243
- or (
244
- (
245
- isset($this->data['remove_taxonomy_base'][$taxonomy->name])
246
- and (
247
- isset($this->data['remove_taxonomy_base'][$taxonomy->name])
248
- and !$this->data['remove_taxonomy_base'][$taxonomy->name])
249
- )
250
- and !$this->data['create_archive'][$taxonomy->name]
251
- )
252
- ) {
253
- continue;
254
- }
255
- /*
256
- * @todo this should be rewritten: UNLESS we are removing the tax base we should be using a wildcard for tax term
257
- */
258
- $terms = get_terms($taxonomy->name, array("hide_empty" => false));
259
- foreach ($terms as $term) {
260
- $base = isset($this->data['remove_taxonomy_base'], $this->data['remove_taxonomy_base'][$taxonomy->name])
261
- ? ""
262
- : $taxonomy->rewrite['slug'] . "/";
263
- if ($term->parent != 0 && !$this->data['remove_hierarchy']) {
264
- $ancestors = $this->term_ancestors($taxonomy->name, $term->parent) . "/";
265
- } else {
266
- $ancestors = "";
267
- }
268
-
269
- $tax_name = $taxonomy->name;
270
-
271
- # create archives
272
- if (isset($this->data['create_archive'][$tax_name])) {
273
- #year
274
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]';
275
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&paged=$matches[3]';
276
- #year/month
277
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]';
278
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]';
279
- #year/month/day
280
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]';
281
- $new_rules[$base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]';
282
- }
283
- # create rewrite rules with tax base
284
-
285
- # appending ".html" to taxonomy permalinks
286
- $suffix = $this->data['suffix_html'] ? ".html" : "";
287
-
288
- if (!$base) {
289
- $new_rules[$ancestors . '(' . $term->slug . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?' . $tax_name . '=$matches[1]&feed=$matches[2]';
290
- $new_rules[$ancestors . '(' . $term->slug . ')/page/?([0-9]{1,})/?$'] = 'index.php?' . $tax_name . '=$matches[1]&paged=$matches[2]';
291
- $new_rules[$ancestors . '(' . $term->slug . ')' . $suffix . '/?$'] = 'index.php?' . $tax_name . '=$matches[1]';
292
- }
293
- $rewrite_rules = $new_rules + $rewrite_rules;
294
- }
295
- }
296
- }
297
-
298
- # Author Archives
299
- if ($this->data['remove_author_base']) {
300
- $blogusers = get_users('who=authors');
301
- foreach ($blogusers as $user) {
302
-
303
- $new_rules = array(
304
- '(' . $user->user_nicename . ')/([0-9]{4})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]',
305
- '(' . $user->user_nicename . ')/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
306
-
307
- '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
308
- '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
309
-
310
- '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
311
- '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]');
312
-
313
- $rewrite_rules = $new_rules + $rewrite_rules;
314
- }
315
- } else if (isset($this->data['author_archives'])) {
316
- $author_base = ($this->data['cap'] != '') ? $this->data['cap'] : 'author';
317
- $new_rules = array(
318
- $author_base . '/([^/]+)/([0-9]{4})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]',
319
- $author_base . '/([^/]+)/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
320
-
321
- $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
322
- $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
323
-
324
- $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
325
- $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]');
326
-
327
- $rewrite_rules = $new_rules + $rewrite_rules;
328
- }
329
-
330
- # Custom Pagination; Custom Author Permalink
331
- if ((isset($this->data['cap']) && $this->data['cap'] != '') || (isset($this->data['cpp']) && $this->data['cpp'] != '')) {
332
- $rewrite_rules = serialize($rewrite_rules);
333
- # Author
334
- if (isset($this->data['cap']) && $this->data['cap'] != '') {
335
- $rewrite_rules = str_replace('author/', $this->data['cap'] . '/', $rewrite_rules);
336
- }
337
- # Pagination
338
- if (isset($this->data['cpp']) && $this->data['cpp'] != '') {
339
- $rewrite_rules = str_replace('page/', $this->data['cpp'] . '/', $rewrite_rules);
340
- }
341
- # Search
342
- if (isset($this->data['custom_search_permalink']) && $this->data['custom_search_permalink'] != '') {
343
- $rewrite_rules = str_replace('search/', $this->data['custom_search_permalink'] . '/', $rewrite_rules);
344
- }
345
-
346
- $rewrite_rules = unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $rewrite_rules));
347
- }
348
- return $rewrite_rules;
349
- }
350
-
351
- # Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
352
- # Adapted from sitemap-core.php (line ~2036)
353
- function set_sm()
354
- {
355
-
356
- if (class_exists('GoogleSitemapGenerator') && $this->data['cap'] != '') {
357
- $generatorObject = & GoogleSitemapGenerator::GetInstance();
358
- if ($generatorObject != null) {
359
- /* var $wpdb WP_DB */
360
- global $wpdb, $wp_version;
361
- $sql = "SELECT DISTINCT
362
  p.ID,
363
  u.user_nicename,
364
  MAX(p.post_modified_gmt) AS last_post
@@ -370,464 +361,501 @@ if (!class_exists("WPhtc")) {
370
  AND p.post_status = 'publish'
371
  AND p.post_type = 'post'
372
  AND p.post_password = ''
373
- " . (floatval($wp_version) < 2.1 ? "AND p.post_date_gmt <= '" . gmdate('Y-m-d H:i:59') . "'" : "") . "
374
  GROUP BY
375
  u.ID,
376
  u.user_nicename";
377
- $authors = $wpdb->get_results($sql);
378
- if ($authors && is_array($authors)) {
379
- foreach ($authors as $author) {
380
- $url = get_bloginfo('url') . "/" . $this->data['cap'] . "/" . $author->user_nicename . "/";
381
- $generatorObject->AddUrl($url, $generatorObject->GetTimestampFromMySql($author->last_post), $generatorObject->GetOption("cf_auth"), $generatorObject->GetOption("pr_auth"));
382
- }
383
- }
384
- }
385
- }
386
- }
387
-
388
- # Adding rewrite pairs to the .htaccess generated by WordPress, everytime the rules are flush
389
- /*
390
- * @var $wp_rewrite WP_Rewrite
391
- * @return WP_Rewrite
392
- */
393
- function wp_rewrite_rules($wp_rewrite)
394
- {
395
- # Keeping a copy of the generated htaccess in our option array for later reviewing
396
- $this->data['cur_hta'] = '# BEGIN WordPress<br/>' . nl2br($wp_rewrite->mod_rewrite_rules()) . "# END WordPress";
397
- update_option('WPhtc_data', $this->data);
398
- return $wp_rewrite;
399
- }
400
-
401
- # Adding Custom Rules to htaccess file generated by WordPress, everytime the rules are flush
402
- function hta_rules($rules)
403
- {
404
-
405
- # keeping original hta
406
- if (!isset($this->data['htaccess_original'])) {
407
- $this->data['htaccess_original'] = $rules;
408
- update_option('WPhtc_data', $this->data);
409
- }
410
-
411
- $new_rules = "";
412
-
413
- # Maintenance Mode
414
- if ($this->data['maintenance_active'] && isset($this->data['maintenance_ips'][0])) {
415
- $no_ips = count($this->data['maintenance_ips']);
416
- $new_rules .= "\n# WPhtc: Begin Maintenance Mode\n";
417
- # redirect
418
- if ($this->data['maintenance_redirection'] != '') {
419
- $new_rules .= "RewriteEngine on\n";
420
- $new_rules .= "RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif) [NC]\n";
421
- for ($i = 0; $i < $no_ips; $i++) {
422
- $new_rules .= "RewriteCond %{REMOTE_HOST} !^" . str_replace(".", "\.", trim($this->data['maintenance_ips'][$i])) . "\n";
423
- }
424
- if (substr($this->data['maintenance_redirection'], 0, 1) == "/") {
425
- $new_rules .= "RewriteCond %{REQUEST_URI} !" . $this->data['maintenance_redirection'] . "$ [NC]\n";
426
- }
427
- $new_rules .= "RewriteRule .* " . $this->data['maintenance_redirection'] . " [R=302,L]\n";
428
- } # no redirection
429
- else {
430
- $new_rules .= "order deny,allow\n";
431
- $new_rules .= "deny from all\n";
432
- foreach ($this->data['maintenance_ips'] as $ip) {
433
- $new_rules .= "allow from " . $ip . "\n";
434
- }
435
- }
436
- $new_rules .= "# WPhtc: End Maintenance Mode\n";
437
- }
438
-
439
- # Login Control
440
- if ($this->data['login_disabled']) {
441
- $no_ips = count($this->data['login_ips']);
442
- $new_rules .= "\n# WPhtc: Begin Login Control (start deleting here if you're having trouble logging in)\n";
443
- # redirect
444
- $new_rules .= "RewriteEngine on\n";
445
- $new_rules .= "RewriteCond %{REQUEST_URI} .wp-login\.php* [NC]\n";
446
- if ($this->data['login_half_mode']) {
447
- $new_rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
448
- $new_rules .= "RewriteCond %{QUERY_STRING} !action=(logout|lostpassword|postpass|retrievepassword|resetpass|rp)*\n";
449
- }
450
- if ($no_ips > 0) {
451
- for ($i = 0; $i < $no_ips; $i++) {
452
- $new_rules .= "RewriteCond %{REMOTE_HOST} !^" . str_replace(".", "\.", trim($this->data['login_ips'][$i])) . "\n";
453
- }
454
- }
455
- $new_rules .= "RewriteRule .* " . $this->data['login_redirection'] . " [R=301,L]\n";
456
- $new_rules .= "# WPhtc: End Login Control Mode (stop deleting here if you're having trouble logging in)\n";
457
- }
458
- # Custom htaccess
459
- if ($this->data['hta']) {
460
- $new_rules .= "\n# WPhtc: Begin Custom htaccess\n";
461
- $new_rules .= stripslashes($this->data['hta']) . "\n";
462
- $new_rules .= "# WPhtc: End Custom htaccess\n";
463
- }
464
- # htaccess suggestions
465
- if ($this->data['disable_serversignature']) {
466
- $new_rules .= "\n# WPhtC: Disable ServerSignature on generated error pages\n";
467
- $new_rules .= "ServerSignature Off\n";
468
- }
469
- if ($this->data['admin_email']) {
470
- $new_rules .= "\n# WPhtC: Set admin email\n";
471
- $new_rules .= "SetEnv SERVER_ADMIN " . $this->data['admin_email'] . "\n\n";
472
- }
473
- if ($this->data['disable_indexes']) {
474
- $new_rules .= "\n# WPhtC: Disable directory browsing\n";
475
- $new_rules .= "Options All -Indexes\n";
476
- }
477
- if ($this->data['up_limit']) {
478
- $new_rules .= "\n# WPhtC: Limit upload size to " . $this->data['up_limit'] . " MB\n";
479
- $new_rules .= "LimitRequestBody " . ($this->data['up_limit'] * 1024 * 1024) . " \n";
480
- }
481
- if ($this->data['redirect_500']) {
482
- $new_rules .= "\n# WPhtC: Setting 500 Error page\n";
483
- $new_rules .= "ErrorDocument 500 " . $this->data['redirect_500'] . "\n";
484
- }
485
- if ($this->data['redirect_403']) {
486
- $new_rules .= "\n# WPhtC: Setting 403 Error page\n";
487
- $new_rules .= "ErrorDocument 403 " . $this->data['redirect_403'] . "\n";
488
- }
489
- if ($this->data['protect_wp_config']) {
490
- $new_rules .= "\n# WPhtC: Protect WP-config.php\n";
491
- $new_rules .= "<files wp-config.php>\n";
492
- $new_rules .= "order allow,deny\n";
493
- $new_rules .= "deny from all\n";
494
- $new_rules .= "</files>\n";
495
- }
496
- if ($this->data['protect_htaccess']) {
497
- $new_rules .= "\n# WPhtC: Protect .htaccess file\n";
498
- $new_rules .= "<files ~ \"^.*\.([Hh][Tt][Aa])\">\n";
499
- $new_rules .= "order allow,deny\n";
500
- $new_rules .= "deny from all\n";
501
- $new_rules .= "</files>\n";
502
- }
503
- if ($this->data['protect_comments']) {
504
- $new_rules .= "\n# WPhtC: Protect comments.php\n";
505
- $new_rules .= "RewriteCond %{REQUEST_METHOD} POST\n";
506
- $new_rules .= "RewriteCond %{REQUEST_URI} .wp-comments-post\.php*\n";
507
- $new_rules .= "RewriteCond %{HTTP_REFERER} !.*" . get_bloginfo('url') . ".* [OR]\n";
508
- $new_rules .= "RewriteCond %{HTTP_USER_AGENT} ^$\n";
509
- $new_rules .= "RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]\n";
510
- }
511
- if ($this->data['disable_hotlink']) {
512
- $new_rules .= "\n# WPhtC: Disable image hotlinking\n";
513
- $new_rules .= "<IfModule mod_rewrite.c>\n";
514
- $new_rules .= "RewriteEngine on\n";
515
- $new_rules .= "RewriteCond %{HTTP_REFERER} !^$\n";
516
- $new_rules .= "RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?" . str_ireplace(array("http://", "www."), "", get_bloginfo("url")) . "/.*$ [NC]\n";
517
- $new_rules .= "RewriteRule \.(jpg|jpeg|png|gif)$ " . $this->data['disable_hotlink'] . " [NC,R,L]\n";
518
- $new_rules .= "</IfModule>\n";
519
- }
520
- if ($this->data['disable_file_hotlink_ext']) {
521
- $redir = $this->data['disable_file_hotlink_redir'] ? $this->data['disable_file_hotlink_redir'] : "_";
522
- $new_rules .= "\n# WPhtC: Disable file hotlinking\n";
523
- $new_rules .= "<IfModule mod_rewrite.c>\n";
524
- $new_rules .= "RewriteEngine on\n";
525
- $new_rules .= "RewriteCond %{HTTP_REFERER} !^$\n";
526
- $new_rules .= "RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?" . str_ireplace(array("http://", "www."), "", get_bloginfo("url")) . "/.*$ [NC]\n";
527
- $new_rules .= "RewriteRule \.(" . str_replace(" ", "|", $this->data['disable_file_hotlink_ext']) . ")$ " . $redir . " [NC,R,L]\n";
528
- $new_rules .= "</IfModule>\n";
529
- }
530
- if ($this->data['canon']) {
531
- $url = str_ireplace(array("http://", "www."), "", get_bloginfo("url"));
532
- $domain = explode("/", $url);
533
- $escaped_domain = str_ireplace(".", "\.", $domain[0]);
534
- if ($this->data['canon'] == 'www') {
535
- $siteurl = get_option('siteurl');
536
- if (!preg_match('/^http:\/\/www\./', $siteurl)) {
537
- $siteurl = str_replace("http://", "http://www.", $siteurl);
538
- update_option('siteurl', $siteurl);
539
- }
540
- $homeurl = get_option('home');
541
- if (!preg_match('/^http:\/\/www\./', $homeurl)) {
542
- $homeurl = str_replace("http://", "http://www.", $homeurl);
543
- update_option('home', $homeurl);
544
- }
545
- } else if ($this->data['canon'] == 'simple') {
546
- $siteurl = get_option('siteurl');
547
- if (preg_match('/^http:\/\/www\./', $siteurl)) {
548
- $siteurl = str_replace("http://www.", "http://", $siteurl);
549
- update_option('siteurl', $siteurl);
550
- }
551
- $homeurl = get_option('home');
552
- if (preg_match('/^http:\/\/www\./', $homeurl)) {
553
- $homeurl = str_replace("http://www.", "http://", $homeurl);
554
- update_option('home', $homeurl);
555
- }
556
- }
557
- }
558
- if ($this->data['gzip']) {
559
- $new_rules .= "\n# WPhtC: Setting mod_gzip\n";
560
- $new_rules .= "<ifModule mod_gzip.c>\n";
561
- $new_rules .= "mod_gzip_on Yes\n";
562
- $new_rules .= "mod_gzip_dechunk Yes\n";
563
- $new_rules .= "mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$\n";
564
- $new_rules .= "mod_gzip_item_include handler ^cgi-script$\n";
565
- $new_rules .= "mod_gzip_item_include mime ^text/.*\n";
566
- $new_rules .= "mod_gzip_item_include mime ^application/x-javascript.*\n";
567
- $new_rules .= "mod_gzip_item_exclude mime ^image/.*\n";
568
- $new_rules .= "mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*\n";
569
- $new_rules .= "</ifModule>\n";
570
- }
571
- if ($this->data['deflate']) {
572
- $new_rules .= "\n# WPhtC: Setting mod_deflate\n";
573
- $new_rules .= "<IfModule mod_deflate.c>\n";
574
- $new_rules .= "AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript\n";
575
- $new_rules .= "BrowserMatch ^Mozilla/4 gzip-only-text/html\n";
576
- $new_rules .= "BrowserMatch ^Mozilla/4.0[678] no-gzip\n";
577
- $new_rules .= "BrowserMatch bMSIE !no-gzip !gzip-only-text/html\n";
578
- $new_rules .= "Header append Vary User-Agent env=!dont-vary\n";
579
- $new_rules .= "</IfModule>\n";
580
- }
581
- if ($this->data['wp_hta'] && trim($this->data['wp_hta']) != '') {
582
- $new_rules .= "\n" . $this->data['wp_hta'];
583
- } else {
584
- $new_rules .= "\n" . $rules;
585
- }
586
- return $new_rules;
587
- }
588
-
589
- # Filter Term Link
590
- function filter_term_link($termlink, $term, $taxonomy)
591
- {
592
- // WPhtc -> this
593
- if ($this->data['remove_taxonomy_base'][$taxonomy]) {
594
- $txs = get_taxonomies(array('name' => $taxonomy), "object");
595
- foreach ($txs as $t) {
596
- //return str_replace($t->rewrite['slug']."/","",$termlink);
597
- if ($term->parent != 0 && !$this->data['remove_hierarchy']) {
598
- return get_bloginfo('url') . "/" . $this->term_ancestors($taxonomy, $term->parent) . "/" . $term->slug;
599
- } else {
600
- return get_bloginfo('url') . "/" . $term->slug;
601
- }
602
- }
603
- } else
604
- return $termlink;
605
- }
606
-
607
- # Filter Taxonomy Base
608
- function remove_taxonomy_base_from_rewrite_rules($rules)
609
- {
610
- # Let's remove every taxonomy rule here, we'll reacreate them at filter_rewrite_rules()
611
- return array();
612
- //return $rules;
613
- }
614
-
615
- # Filter Author Rewrite Rules
616
- function remove_author_base_from_rewrite_rules($author_rewrite)
617
- {
618
-
619
- if ($this->data['remove_author_base']) {
620
- $author_rewrite = array();
621
- $blogusers = get_users('who=authors');
622
- foreach ($blogusers as $user) {
623
- $author_rewrite['(' . $user->user_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?author_name=$matches[1]&feed=$matches[2]';
624
- $author_rewrite['(' . $user->user_nicename . ')/page/?([0-9]{1,})/?$'] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
625
- $author_rewrite['(' . $user->user_nicename . ')/?$'] = 'index.php?author_name=$matches[1]';
626
- }
627
- }
628
- return $author_rewrite;
629
- }
630
-
631
- # WP-htaccess Control options page interface
632
- public static function page()
633
- {
634
- include(dirname(__FILE__) . '/wp-htaccess-control-ui.php');
635
- }
636
-
637
- # Adding our options page to the admin menu
638
- function configure_menu()
639
- {
640
- if (current_user_can("administrator")) {
641
- $page = add_submenu_page("options-general.php", "WP htaccess Control", "htaccess Control", 'activate_plugins', __FILE__, array('WPhtc', 'page'));
642
- add_action('admin_print_scripts-' . $page, array('WPhtc', 'page_script'));
643
- add_action('admin_print_styles-' . $page, array('WPhtc', 'page_style'));
644
- }
645
- }
646
-
647
- # Enqueue Ui Scripts on Plugin page
648
- public static function page_script()
649
- {
650
- wp_enqueue_script("htaccess-control-js", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.js');
651
- }
652
-
653
- # Enqueue Ui Scripts on Plugin page
654
- public static function page_style()
655
- {
656
- wp_enqueue_style("htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css');
657
- }
658
-
659
- # Filter "View" Link on Administration
660
- function filter_tax_table_actions($actions, $tag)
661
- {
662
- if ($tag->parent != 0) {
663
- $actions['view'] = '<a href="' . get_bloginfo('url') . '/' . $this->term_ancestors($tag->taxonomy, $tag->parent) . '/' . $tag->slug . '">View</a>';
664
- }
665
- return $actions;
666
- }
667
-
668
- # Options Page Actions
669
- function page_action()
670
- {
671
- $this->check_first_run();
672
- $this->data = array_merge($this->defaultData, get_option('WPhtc_data'));
673
- if (isset($_REQUEST['action'])) {
674
- $action = $_REQUEST['action'];
675
- global $WPhtcEcho;
676
-
677
- switch ($action) {
678
- # Hide donation message for one month
679
- case 'hide_donation_message':
680
- $this->data['donation_hidden_time'] = time() + 90 * 24 * 60 * 60;
681
- update_option('WPhtc_data', $this->data);
682
- break;
683
- # if reseting everything just delete the option array
684
- case 'reset_rules':
685
- # nonce
686
- if (!check_admin_referer('WPhtc_reset_settings')) {
687
- die("You have no permission to do this.");
688
- }
689
- $this->data = $this->defaultData;
690
- delete_option('WPhtc_data');
691
- //update_option('WPhtc_data',$this->data);
692
- $WPhtcEcho .= __('All rules reset.', 'wp-htaccess-control');
693
- $this->refresh_rewrite_rules();
694
- break;
695
- # if updating, save new rules in database and flush rewrite rules
696
- case 'update':
697
- # first donation hidding time 'now'
698
- if (!$this->data['donation_hidden_time']) {
699
- $this->data['donation_hidden_time'] = time();
700
- }
701
- # nonce
702
- if (!check_admin_referer('WPhtc_settings')) {
703
- die("You have no permission to do this.");
704
- }
705
-
706
- // @todo replace this with defaultData
707
- foreach (array("hta", "cap", "cpp", "custom_search_permalink", "remove_author_base", "category_archives", "author_archives", "tag_archives", "disable_serversignature", "disable_indexes", "protect_wp_config", "protect_htaccess", "protect_comments", "disable_hotlink", "disable_file_hotlink_ext", "disable_file_hotlink_redir", "redirect_500", "redirect_403", "canon", "admin_email", "deflate", "gzip", "maintenance_active", "maintenance_redirection", "login_disabled", "login_half_mode", "login_redirection", "sm_enabled", "remove_hierarchy", "suffix_html")
708
- as $k) {
709
- $this->data[$k] = isset($_POST['WPhtc_' . $k]) ? $_POST['WPhtc_' . $k] : '';
710
- }
711
-
712
- # wordpress htaccess and jim morgan's htaccess
713
- $this->data['wp_hta'] = $_POST['WPhtc_wp_hta'] . "\n";
714
-
715
- # get htaccess Suggestions
716
- $this->data['up_limit'] = (is_numeric($_POST['WPhtc_up_limit']) && $_POST['WPhtc_up_limit'] > 0) ? $_POST['WPhtc_up_limit'] : '';
717
- # get maintenance
718
- $lines = preg_split("/\n|,/", $_POST['WPhtc_maintenance_ips']);
719
- $this->data['maintenance_ips'] = array();
720
- foreach ($lines as $line) {
721
- trim($line);
722
- if (preg_match("/[a-z,0-9,\.]/", $line)) {
723
- $this->data['maintenance_ips'][] = $line;
724
- }
725
- }
726
- # get login control data
727
- if (isset($_POST['WPhtc_login_ips'])) {
728
- $lines = preg_split("/\n|,/", $_POST['WPhtc_login_ips']);
729
- $this->data['login_ips'] = array();
730
- foreach ($lines as $line) {
731
- trim($line);
732
- if (preg_match("/[a-z,0-9,\.]/", $line)) {
733
- $this->data['login_ips'][] = $line;
734
- }
735
- }
736
- }
737
-
738
- # Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
739
- if ($this->data['sm_enabled'] == true) {
740
- $SMoptions = get_option("sm_options");
741
- if ($SMoptions && is_array($SMoptions)) {
742
- $SMoptions = get_option("sm_options");
743
- $SMoptions['sm_in_auth'] = 0;
744
- update_option('sm_options', $SMoptions);
745
- # Try to rebuild Sitemap
746
- do_action("sm_rebuild");
747
- }
748
- }
749
-
750
- # Taxonomy Base removal options
751
- unset($this->data['remove_taxonomy_base']);
752
- if (isset($_POST['WPhtc_remove_base']) and $_POST['WPhtc_remove_base']) {
753
- foreach ($_POST['WPhtc_remove_base'] as $tax_key => $remove) {
754
- $this->data['remove_taxonomy_base'][$tax_key] = $remove;
755
- }
756
- }
757
-
758
- # Advanced archives
759
- unset($this->data['create_archive']);
760
- if (isset($_POST['WPhtc_create_archive'])) {
761
- foreach ($_POST['WPhtc_create_archive'] as $tax_key => $create_archive) {
762
- $this->data['create_archive'][$tax_key] = $create_archive;
763
- }
764
- }
765
-
766
- # Update WP htaccess Control options
767
- update_option('WPhtc_data', $this->data);
768
-
769
- # Flush Rewrite Rules
770
- $this->refresh_rewrite_rules();
771
- $WPhtcEcho .= __('All options updated.', 'wp-htaccess-control');
772
- break;
773
- }
774
- }
775
- }
776
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  }
778
- if (class_exists("WPhtc")) {
779
- $WPhtc = new WPhtc();
780
  }
781
- if (isset($WPhtc)) {
782
-
783
- add_action('init', array($WPhtc, 'init'));
784
- add_filter('mod_rewrite_rules', array($WPhtc, 'hta_rules'));
785
- add_filter('redirect_canonical', array($WPhtc, 'filter_redirect_canonical'), 10, 10);
786
- add_action('admin_menu', array($WPhtc, 'configure_menu'));
787
- add_action('flush_event', array($WPhtc, 'refresh_rewrite_rules'));
788
- add_filter('generate_rewrite_rules', array($WPhtc, 'wp_rewrite_rules'));
789
- add_filter('rewrite_rules_array', array($WPhtc, 'filter_rewrite_rules'));
790
-
791
- // AUTHOR improve this
792
- if ($WPhtc->data['cap'] != '' || $WPhtc->data['remove_author_base']) {
793
- add_filter('author_link', array($WPhtc, 'filter_author_link'));
794
- add_filter('author_rewrite_rules', array($WPhtc, 'remove_author_base_from_rewrite_rules'));
795
- }
796
-
797
- // Filter pagination links
798
- if ($WPhtc->data['cpp'] != '') {
799
- add_filter('get_pagenum_link', array($WPhtc, 'filter_get_pagenum_link'));
800
- }
801
-
802
- // Filter search
803
- if (trim($WPhtc->data['custom_search_permalink']) != '') {
804
- add_filter('search_feed_link', array($WPhtc, 'search_feed_link'), 10, 10);
805
- add_filter('get_search_query', array($WPhtc, 'get_search_query_filter'), 10, 10);
806
- add_action('template_redirect', array($WPhtc, 'search_template_redirect'));
807
- }
808
-
809
-
810
- add_action('sm_buildmap', array($WPhtc, 'set_sm'));
811
-
812
- // Taxonomy Base Removal
813
- if ($WPhtc->data['remove_taxonomy_base']) {
814
- add_filter('term_link', array($WPhtc, 'filter_term_link'), 10, 3);
815
- foreach ($WPhtc->data['remove_taxonomy_base'] as $tax => $v) {
816
- if ($v) {
817
- add_filter($tax . '_rewrite_rules', array($WPhtc, 'remove_taxonomy_base_from_rewrite_rules'));
818
- add_filter($tax . "_row_actions", array($WPhtc, 'filter_tax_table_actions'), 10, 2);
819
- }
820
- }
821
- }
822
- /* Term management actions*/
823
- if ($WPhtc->data['remove_taxonomy_base'] || $WPhtc->data['create_archive']) {
824
- add_action('created_term', array($WPhtc, 'refresh_rewrite_rules_later'));
825
- add_action('edited_term', array($WPhtc, 'refresh_rewrite_rules_later'));
826
- add_action('delete_term', array($WPhtc, 'refresh_rewrite_rules_later'));
827
- }
828
-
829
- /* This flush should maybe be conditional to content authors only, maybe not */
830
- add_action('user_register', array($WPhtc, 'refresh_rewrite_rules_later'));
831
- add_action('delete_user', array($WPhtc, 'refresh_rewrite_rules_later'));
 
832
  }
833
  ?>
26
  /* Removal of the Category Base is based on WP No Category Base by Saurabh Gupta, 2008
27
  Search redirection is based on Nice Search by Mark Jaquith, 2011 */
28
 
29
+ if ( ! class_exists( "WPhtc" ) ) {
30
+ class WPhtc {
31
+
32
+ public $data;
33
+
34
+ public $defaultData = array(
35
+ "maintenance_active" => false,
36
+ "login_disabled" => false,
37
+ "hta" => false,
38
+ "disable_serversignature" => false,
39
+ "admin_email" => false,
40
+ "disable_indexes" => false,
41
+ "up_limit" => false,
42
+ "redirect_500" => false,
43
+ "redirect_403" => false,
44
+ "protect_wp_config" => false,
45
+ "protect_htaccess" => false,
46
+ "protect_comments" => false,
47
+ "disable_hotlink" => false,
48
+ "disable_file_hotlink_ext" => false,
49
+ "canon" => false,
50
+ "gzip" => false,
51
+ "deflate" => false,
52
+ "wp_hta" => false,
53
+ "cpp" => false,
54
+ "cap" => false,
55
+ "custom_search_permalink" => false,
56
+ "remove_taxonomy_base" => false,
57
+ "create_archive" => false,
58
+ "remove_author_base" => false,
59
+ "htaccess_original" => false,
60
+ "suffix_html" => false,
61
+ "donation_hidden_time" => false,
62
+ );
63
+
64
+ function WPhtc() {
65
+ $data = get_option( 'WPhtc_data' );
66
+ if ( $data ) {
67
+ $this->data = array_merge( $this->defaultData, $data );
68
+ } else {
69
+ add_option( 'WPhtc_data', $this->defaultData );
70
+ }
71
+ }
72
+
73
+ /*
74
+ * @param $key
75
+ */
76
+ function get_data( $key, $key_inner = null ) {
77
+ if ( isset( $this->data[ $key ] ) ) {
78
+ if ( $key_inner != "" && isset( $this->data[ $key ][ $key_inner ] ) ) {
79
+ return $this->data[ $key ][ $key_inner ];
80
+ } else if ( ! isset( $key_inner ) ) {
81
+ return $this->data[ $key ];
82
+ }
83
+ } else {
84
+ return null;
85
+ }
86
+ }
87
+
88
+ function init() {
89
+ # set locale
90
+ $currentLocale = get_locale();
91
+ if ( ! empty( $currentLocale ) ) {
92
+ $moFile = dirname( __FILE__ ) . "/lang/wp-htaccess-control-" . $currentLocale . ".mo";
93
+ if ( @file_exists( $moFile ) && is_readable( $moFile ) ) {
94
+ load_textdomain( 'wp-htaccess-control', $moFile );
95
+ }
96
+ }
97
+ }
98
+
99
+ function search_template_redirect() {
100
+ # redirect "?s=*" to "/search-base/*"
101
+ if ( $_GET['s'] ) {
102
+ wp_redirect( home_url( $this->data['custom_search_permalink'] . "/" . rawurlencode( get_query_var( 's' ) ) ) );
103
+ }
104
+
105
+ # rewrite query
106
+ if ( strpos( $_SERVER["REQUEST_URI"], $this->data['custom_search_permalink'] ) ) {
107
+ global $wp_query;
108
+ if ( strpos( $_SERVER["REQUEST_URI"], '/feed' ) ) {
109
+ preg_match( "/feed\/(feed|rdf|rss|rss2|atom)?/", $_SERVER["REQUEST_URI"], $feed );
110
+ if ( $feed[1] ) {
111
+ $format = "&feed=" . $feed[1];
112
+ } else {
113
+ $format = "&feed=feed";
114
+ }
115
+ }
116
+ $page_base = ( $this->data['cpp'] != '' ) ? $this->data['cpp'] : 'page';
117
+
118
+ # in need of better regex
119
+ if ( ! strpos( $_SERVER["REQUEST_URI"], '/feed' ) && ! strpos( $_SERVER["REQUEST_URI"], $page_base ) ) {
120
+ $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
121
+ } else {
122
+ $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)\/feed|" . $page_base . "?/";
123
+ }
124
+
125
+ $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
126
+ preg_match( $pattern, $_SERVER["REQUEST_URI"], $matches );
127
+ $results = split( "/", $matches[1] );
128
+ if ( $results[1] == $page_base ) {
129
+ $page = "&paged=" . $results[2];
130
+ }
131
+ $wp_query = new WP_Query( 's=' . $results[0] . $page . $format );
132
+ }
133
+ }
134
+
135
+ # return get_search_query on custom search base
136
+ function get_search_query_filter( $query ) {
137
+
138
+ if ( $this->data['custom_search_permalink'] != '' && strpos( $_SERVER["REQUEST_URI"], $this->data['custom_search_permalink'] ) ) {
139
+ $page_base = ( $this->data['cpp'] != '' ) ? $this->data['cpp'] : 'page';
140
+ # in need of better regex
141
+ if ( ! strpos( $_SERVER["REQUEST_URI"], '/feed' ) && ! strpos( $_SERVER["REQUEST_URI"], "/" . $page_base ) ) {
142
+ $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)/";
143
+ } else {
144
+ $pattern = "/\/" . $this->data['custom_search_permalink'] . "\/(.+)\/feed|" . $page_base . "?/";
145
+ }
146
+ preg_match( $pattern, $_SERVER["REQUEST_URI"], $matches );
147
+ $results = split( "/", $matches[1] );
148
+
149
+ return urldecode( $results[0] );
150
+ }
151
+
152
+ return $query;
153
+ }
154
+
155
+ function search_feed_link( $link ) {
156
+
157
+ $link = str_replace( "search", $this->data['custom_search_permalink'], $link );
158
+
159
+ return $link;
160
+ }
161
+
162
+ function check_first_run() {
163
+ # flush rules to get some data filled on first usage
164
+ if ( ! isset( $this->data['htaccess_original'] ) ) {
165
+ $this->refresh_rewrite_rules();
166
+ }
167
+ }
168
+
169
+ # Flush rules
170
+ /*
171
+ * @var $wp_rewrite WP_Rewrite
172
+ */
173
+ function refresh_rewrite_rules() {
174
+ global $wp_rewrite;
175
+ $wp_rewrite->flush_rules();
176
+ }
177
+
178
+ function refresh_rewrite_rules_later() {
179
+ wp_schedule_single_event( time(), 'flush_event' );
180
+ }
181
+
182
+ # Filter pagination links generated by WordPress
183
+ function filter_get_pagenum_link( $result ) {
184
+ $result = preg_replace( "/" . urlencode( $this->data['cpp'] ) . "\/[0-9]+[\/]?/", "", $result );
185
+ $result = str_replace( "page", urlencode( $this->data['cpp'] ), $result );
186
+
187
+ return $result;
188
+ }
189
+
190
+ # Filter link generated by get_author_posts_url() to use the Custom Author Permalink
191
+ function filter_author_link( $link ) {
192
+
193
+ if ( $this->data['remove_author_base'] ) {
194
+ $link = str_replace( "author/", "", $link );
195
+ } else if ( isset( $this->data['cap'] ) && $this->data['cap'] != '' ) {
196
+ $link = str_replace( "author", urlencode( $this->data['cap'] ), $link );
197
+ }
198
+
199
+ return $link;
200
+ }
201
+
202
+ function filter_redirect_canonical( $requested_url ) {
203
+ global $wp;
204
+
205
+ # Disable canonical redirection on urls using custom pagination permalink
206
+ if ( isset( $this->data['cpp'] ) && $this->data['cpp'] != '' && get_query_var( 'paged' ) > 1 && preg_match( "/" . urlencode( $this->data['cpp'] ) . "/", $wp->request ) ) {
207
+ return false;
208
+ } else {
209
+ return $requested_url;
210
+ }
211
+ }
212
+
213
+ # ancestors nesting method
214
+ function term_ancestors( $tax, $id ) {
215
+ $term = get_term( $id, $tax );
216
+ $ancestor = $term->slug;
217
+
218
+ if ( $term->parent != 0 && ! $this->data['remove_hierarchy'] ) {
219
+ $ancestor = $this->term_ancestors( $tax, $term->parent ) . "/" . $ancestor;
220
+ }
221
+
222
+ return $ancestor;
223
+ }
224
+
225
+ # Rewrite Rules: Add Category + Tag + Author Archives; Custom Pagination; Custom Author Base
226
+ function filter_rewrite_rules( $rewrite_rules ) {
227
+
228
+ $new_rules = array();
229
+
230
+ $page_base = ( $this->data['cpp'] != '' ) ? $this->data['cpp'] : 'page';
231
+
232
+ // if we have either to remove the tax base or create tax archives
233
+ if ( isset( $this->data['create_archive'] ) or isset( $this->data['remove_taxonomy_base'] ) ) {
234
+ foreach ( get_taxonomies( '', 'objects' ) as $taxonomy ) {
235
+ if ( ! $taxonomy->rewrite
236
+ or (
237
+ (
238
+ isset( $this->data['remove_taxonomy_base'][ $taxonomy->name ] )
239
+ and (
240
+ isset( $this->data['remove_taxonomy_base'][ $taxonomy->name ] )
241
+ and ! $this->data['remove_taxonomy_base'][ $taxonomy->name ] )
242
+ )
243
+ and ! $this->data['create_archive'][ $taxonomy->name ]
244
+ )
245
+ ) {
246
+ continue;
247
+ }
248
+ /*
249
+ * @todo this should be rewritten: UNLESS we are removing the tax base we should be using a wildcard for tax term
250
+ */
251
+ $terms = get_terms( $taxonomy->name, array( "hide_empty" => false ) );
252
+ foreach ( $terms as $term ) {
253
+ $base = isset( $this->data['remove_taxonomy_base'], $this->data['remove_taxonomy_base'][ $taxonomy->name ] )
254
+ ? ""
255
+ : $taxonomy->rewrite['slug'] . "/";
256
+ if ( $term->parent != 0 && ! $this->data['remove_hierarchy'] ) {
257
+ $ancestors = $this->term_ancestors( $taxonomy->name, $term->parent ) . "/";
258
+ } else {
259
+ $ancestors = "";
260
+ }
261
+
262
+ $tax_name = $taxonomy->name;
263
+
264
+ # create archives
265
+ if ( isset( $this->data['create_archive'][ $tax_name ] ) ) {
266
+ #year
267
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]';
268
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&paged=$matches[3]';
269
+ #year/month
270
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]';
271
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]';
272
+ #year/month/day
273
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]';
274
+ $new_rules[ $base . $ancestors . '(' . $term->slug . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]';
275
+ }
276
+ # create rewrite rules with tax base
277
+
278
+ # appending ".html" to taxonomy permalinks
279
+ $suffix = $this->data['suffix_html'] ? ".html" : "";
280
+
281
+ if ( ! $base ) {
282
+ $new_rules[ $ancestors . '(' . $term->slug . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&feed=$matches[2]';
283
+ $new_rules[ $ancestors . '(' . $term->slug . ')/page/?([0-9]{1,})/?$' ] = 'index.php?' . $tax_name . '=$matches[1]&paged=$matches[2]';
284
+ $new_rules[ $ancestors . '(' . $term->slug . ')' . $suffix . '/?$' ] = 'index.php?' . $tax_name . '=$matches[1]';
285
+ }
286
+ $rewrite_rules = $new_rules + $rewrite_rules;
287
+ }
288
+ }
289
+ }
290
+
291
+ # Author Archives
292
+ if ( $this->data['remove_author_base'] ) {
293
+ $blogusers = get_users( 'who=authors' );
294
+ foreach ( $blogusers as $user ) {
295
+
296
+ $new_rules = array(
297
+ '(' . $user->user_nicename . ')/([0-9]{4})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]',
298
+ '(' . $user->user_nicename . ')/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
299
+ '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
300
+ '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
301
+ '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
302
+ '(' . $user->user_nicename . ')/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]'
303
+ );
304
+
305
+ $rewrite_rules = $new_rules + $rewrite_rules;
306
+ }
307
+ } else if ( isset( $this->data['author_archives'] ) ) {
308
+ $author_base = ( $this->data['cap'] != '' ) ? $this->data['cap'] : 'author';
309
+ $new_rules = array(
310
+ $author_base . '/([^/]+)/([0-9]{4})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]',
311
+ $author_base . '/([^/]+)/([0-9]{4})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&paged=$matches[3]',
312
+ $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]',
313
+ $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&paged=$matches[4]',
314
+ $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]',
315
+ $author_base . '/([^/]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/' . $page_base . '/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&year=$matches[2]&monthnum=$matches[3]&day=$matches[4]&paged=$matches[5]'
316
+ );
317
+
318
+ $rewrite_rules = $new_rules + $rewrite_rules;
319
+ }
320
+
321
+ # Custom Pagination; Custom Author Permalink
322
+ if ( ( isset( $this->data['cap'] ) && $this->data['cap'] != '' ) || ( isset( $this->data['cpp'] ) && $this->data['cpp'] != '' ) ) {
323
+ $rewrite_rules = serialize( $rewrite_rules );
324
+ # Author
325
+ if ( isset( $this->data['cap'] ) && $this->data['cap'] != '' ) {
326
+ $rewrite_rules = str_replace( 'author/', $this->data['cap'] . '/', $rewrite_rules );
327
+ }
328
+ # Pagination
329
+ if ( isset( $this->data['cpp'] ) && $this->data['cpp'] != '' ) {
330
+ $rewrite_rules = str_replace( 'page/', $this->data['cpp'] . '/', $rewrite_rules );
331
+ }
332
+ # Search
333
+ if ( isset( $this->data['custom_search_permalink'] ) && $this->data['custom_search_permalink'] != '' ) {
334
+ $rewrite_rules = str_replace( 'search/', $this->data['custom_search_permalink'] . '/', $rewrite_rules );
335
+ }
336
+
337
+ $rewrite_rules = unserialize( preg_replace( '!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $rewrite_rules ) );
338
+ }
339
+
340
+ return $rewrite_rules;
341
+ }
342
+
343
+ # Adding our Custom Author Base to the sitemap generated by Google XML Sitemaps
344
+ # Adapted from sitemap-core.php (line ~2036)
345
+ function set_sm() {
346
+
347
+ if ( class_exists( 'GoogleSitemapGenerator' ) && $this->data['cap'] != '' ) {
348
+ $generatorObject = &GoogleSitemapGenerator::GetInstance();
349
+ if ( $generatorObject != null ) {
350
+ /* var $wpdb WP_DB */
351
+ global $wpdb, $wp_version;
352
+ $sql = "SELECT DISTINCT
 
 
 
 
 
 
 
 
 
353
  p.ID,
354
  u.user_nicename,
355
  MAX(p.post_modified_gmt) AS last_post
361
  AND p.post_status = 'publish'
362
  AND p.post_type = 'post'
363
  AND p.post_password = ''
364
+ " . ( floatval( $wp_version ) < 2.1 ? "AND p.post_date_gmt <= '" . gmdate( 'Y-m-d H:i:59' ) . "'" : "" ) . "
365
  GROUP BY
366
  u.ID,
367
  u.user_nicename";
368
+ $authors = $wpdb->get_results( $sql );
369
+ if ( $authors && is_array( $authors ) ) {
370
+ foreach ( $authors as $author ) {
371
+ $url = get_bloginfo( 'url' ) . "/" . $this->data['cap'] . "/" . $author->user_nicename . "/";
372
+ $generatorObject->AddUrl( $url, $generatorObject->GetTimestampFromMySql( $author->last_post ), $generatorObject->GetOption( "cf_auth" ), $generatorObject->GetOption( "pr_auth" ) );
373
+ }
374
+ }
375
+ }
376
+ }
377
+ }
378
+
379
+ # Adding rewrite pairs to the .htaccess generated by WordPress, everytime the rules are flush
380
+ /*
381
+ * @var $wp_rewrite WP_Rewrite
382
+ * @return WP_Rewrite
383
+ */
384
+ function wp_rewrite_rules( $wp_rewrite ) {
385
+ # Keeping a copy of the generated htaccess in our option array for later reviewing
386
+ $this->data['cur_hta'] = '# BEGIN WordPress<br/>' . nl2br( $wp_rewrite->mod_rewrite_rules() ) . "# END WordPress";
387
+ update_option( 'WPhtc_data', $this->data );
388
+
389
+ return $wp_rewrite;
390
+ }
391
+
392
+ # Adding Custom Rules to htaccess file generated by WordPress, everytime the rules are flush
393
+ function hta_rules( $rules ) {
394
+
395
+ # keeping original hta
396
+ if ( ! isset( $this->data['htaccess_original'] ) ) {
397
+ $this->data['htaccess_original'] = $rules;
398
+ update_option( 'WPhtc_data', $this->data );
399
+ }
400
+
401
+ $new_rules = "";
402
+
403
+ # Maintenance Mode
404
+ if ( $this->data['maintenance_active'] && isset( $this->data['maintenance_ips'][0] ) ) {
405
+ $no_ips = count( $this->data['maintenance_ips'] );
406
+ $new_rules .= "\n# WPhtc: Begin Maintenance Mode\n";
407
+ # redirect
408
+ if ( $this->data['maintenance_redirection'] != '' ) {
409
+ $new_rules .= "RewriteEngine on\n";
410
+ $new_rules .= "RewriteCond %{REQUEST_URI} !\.(jpe?g|png|gif) [NC]\n";
411
+ for ( $i = 0; $i < $no_ips; $i ++ ) {
412
+ $new_rules .= "RewriteCond %{REMOTE_HOST} !^" . str_replace( ".", "\.", trim( $this->data['maintenance_ips'][ $i ] ) ) . "\n";
413
+ }
414
+ if ( substr( $this->data['maintenance_redirection'], 0, 1 ) == "/" ) {
415
+ $new_rules .= "RewriteCond %{REQUEST_URI} !" . $this->data['maintenance_redirection'] . "$ [NC]\n";
416
+ }
417
+ $new_rules .= "RewriteRule .* " . $this->data['maintenance_redirection'] . " [R=302,L]\n";
418
+ } # no redirection
419
+ else {
420
+ $new_rules .= "order deny,allow\n";
421
+ $new_rules .= "deny from all\n";
422
+ foreach ( $this->data['maintenance_ips'] as $ip ) {
423
+ $new_rules .= "allow from " . $ip . "\n";
424
+ }
425
+ }
426
+ $new_rules .= "# WPhtc: End Maintenance Mode\n";
427
+ }
428
+
429
+ # Login Control
430
+ if ( $this->data['login_disabled'] ) {
431
+ $no_ips = count( $this->data['login_ips'] );
432
+ $new_rules .= "\n# WPhtc: Begin Login Control (start deleting here if you're having trouble logging in)\n";
433
+ # redirect
434
+ $new_rules .= "RewriteEngine on\n";
435
+ $new_rules .= "RewriteCond %{REQUEST_URI} .wp-login\.php* [NC]\n";
436
+ if ( $this->data['login_half_mode'] ) {
437
+ $new_rules .= "RewriteCond %{REQUEST_METHOD} !=POST\n";
438
+ $new_rules .= "RewriteCond %{QUERY_STRING} !action=(logout|lostpassword|postpass|retrievepassword|resetpass|rp)*\n";
439
+ }
440
+ if ( $no_ips > 0 ) {
441
+ for ( $i = 0; $i < $no_ips; $i ++ ) {
442
+ $new_rules .= "RewriteCond %{REMOTE_HOST} !^" . str_replace( ".", "\.", trim( $this->data['login_ips'][ $i ] ) ) . "\n";
443
+ }
444
+ }
445
+ $new_rules .= "RewriteRule .* " . $this->data['login_redirection'] . " [R=301,L]\n";
446
+ $new_rules .= "# WPhtc: End Login Control Mode (stop deleting here if you're having trouble logging in)\n";
447
+ }
448
+ # Custom htaccess
449
+ if ( $this->data['hta'] ) {
450
+ $new_rules .= "\n# WPhtc: Begin Custom htaccess\n";
451
+ $new_rules .= stripslashes( $this->data['hta'] ) . "\n";
452
+ $new_rules .= "# WPhtc: End Custom htaccess\n";
453
+ }
454
+ # htaccess suggestions
455
+ if ( $this->data['disable_serversignature'] ) {
456
+ $new_rules .= "\n# WPhtC: Disable ServerSignature on generated error pages\n";
457
+ $new_rules .= "ServerSignature Off\n";
458
+ }
459
+ if ( $this->data['admin_email'] ) {
460
+ $new_rules .= "\n# WPhtC: Set admin email\n";
461
+ $new_rules .= "SetEnv SERVER_ADMIN " . $this->data['admin_email'] . "\n\n";
462
+ }
463
+ if ( $this->data['disable_indexes'] ) {
464
+ $new_rules .= "\n# WPhtC: Disable directory browsing\n";
465
+ $new_rules .= "Options All -Indexes\n";
466
+ }
467
+ if ( $this->data['up_limit'] ) {
468
+ $new_rules .= "\n# WPhtC: Limit upload size to " . $this->data['up_limit'] . " MB\n";
469
+ $new_rules .= "LimitRequestBody " . ( $this->data['up_limit'] * 1024 * 1024 ) . " \n";
470
+ }
471
+ if ( $this->data['redirect_500'] ) {
472
+ $new_rules .= "\n# WPhtC: Setting 500 Error page\n";
473
+ $new_rules .= "ErrorDocument 500 " . $this->data['redirect_500'] . "\n";
474
+ }
475
+ if ( $this->data['redirect_403'] ) {
476
+ $new_rules .= "\n# WPhtC: Setting 403 Error page\n";
477
+ $new_rules .= "ErrorDocument 403 " . $this->data['redirect_403'] . "\n";
478
+ }
479
+ if ( $this->data['protect_wp_config'] ) {
480
+ $new_rules .= "\n# WPhtC: Protect WP-config.php\n";
481
+ $new_rules .= "<files wp-config.php>\n";
482
+ $new_rules .= "order allow,deny\n";
483
+ $new_rules .= "deny from all\n";
484
+ $new_rules .= "</files>\n";
485
+ }
486
+ if ( $this->data['protect_htaccess'] ) {
487
+ $new_rules .= "\n# WPhtC: Protect .htaccess file\n";
488
+ $new_rules .= "<files ~ \"^.*\.([Hh][Tt][Aa])\">\n";
489
+ $new_rules .= "order allow,deny\n";
490
+ $new_rules .= "deny from all\n";
491
+ $new_rules .= "</files>\n";
492
+ }
493
+ if ( $this->data['protect_comments'] ) {
494
+ $new_rules .= "\n# WPhtC: Protect comments.php\n";
495
+ $new_rules .= "RewriteCond %{REQUEST_METHOD} POST\n";
496
+ $new_rules .= "RewriteCond %{REQUEST_URI} .wp-comments-post\.php*\n";
497
+ $new_rules .= "RewriteCond %{HTTP_REFERER} !.*" . get_bloginfo( 'url' ) . ".* [OR]\n";
498
+ $new_rules .= "RewriteCond %{HTTP_USER_AGENT} ^$\n";
499
+ $new_rules .= "RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]\n";
500
+ }
501
+ if ( $this->data['disable_hotlink'] ) {
502
+ $new_rules .= "\n# WPhtC: Disable image hotlinking\n";
503
+ $new_rules .= "<IfModule mod_rewrite.c>\n";
504
+ $new_rules .= "RewriteEngine on\n";
505
+ $new_rules .= "RewriteCond %{HTTP_REFERER} !^$\n";
506
+ $new_rules .= "RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?" . str_ireplace( array(
507
+ "http://",
508
+ "www."
509
+ ), "", get_bloginfo( "url" ) ) . "/.*$ [NC]\n";
510
+ $new_rules .= "RewriteRule \.(jpg|jpeg|png|gif)$ " . $this->data['disable_hotlink'] . " [NC,R,L]\n";
511
+ $new_rules .= "</IfModule>\n";
512
+ }
513
+ if ( $this->data['disable_file_hotlink_ext'] ) {
514
+ $redir = $this->data['disable_file_hotlink_redir'] ? $this->data['disable_file_hotlink_redir'] : "_";
515
+ $new_rules .= "\n# WPhtC: Disable file hotlinking\n";
516
+ $new_rules .= "<IfModule mod_rewrite.c>\n";
517
+ $new_rules .= "RewriteEngine on\n";
518
+ $new_rules .= "RewriteCond %{HTTP_REFERER} !^$\n";
519
+ $new_rules .= "RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?" . str_ireplace( array(
520
+ "http://",
521
+ "www."
522
+ ), "", get_bloginfo( "url" ) ) . "/.*$ [NC]\n";
523
+ $new_rules .= "RewriteRule \.(" . str_replace( " ", "|", $this->data['disable_file_hotlink_ext'] ) . ")$ " . $redir . " [NC,R,L]\n";
524
+ $new_rules .= "</IfModule>\n";
525
+ }
526
+ if ( $this->data['canon'] ) {
527
+ $url = str_ireplace( array( "http://", "www." ), "", get_bloginfo( "url" ) );
528
+ $domain = explode( "/", $url );
529
+ $escaped_domain = str_ireplace( ".", "\.", $domain[0] );
530
+ if ( $this->data['canon'] == 'www' ) {
531
+ $siteurl = get_option( 'siteurl' );
532
+ if ( ! preg_match( '/^http:\/\/www\./', $siteurl ) ) {
533
+ $siteurl = str_replace( "http://", "http://www.", $siteurl );
534
+ update_option( 'siteurl', $siteurl );
535
+ }
536
+ $homeurl = get_option( 'home' );
537
+ if ( ! preg_match( '/^http:\/\/www\./', $homeurl ) ) {
538
+ $homeurl = str_replace( "http://", "http://www.", $homeurl );
539
+ update_option( 'home', $homeurl );
540
+ }
541
+ } else if ( $this->data['canon'] == 'simple' ) {
542
+ $siteurl = get_option( 'siteurl' );
543
+ if ( preg_match( '/^http:\/\/www\./', $siteurl ) ) {
544
+ $siteurl = str_replace( "http://www.", "http://", $siteurl );
545
+ update_option( 'siteurl', $siteurl );
546
+ }
547
+ $homeurl = get_option( 'home' );
548
+ if ( preg_match( '/^http:\/\/www\./', $homeurl ) ) {
549
+ $homeurl = str_replace( "http://www.", "http://", $homeurl );
550
+ update_option( 'home', $homeurl );
551
+ }
552
+ }
553
+ }
554
+ if ( $this->data['gzip'] ) {
555
+ $new_rules .= "\n# WPhtC: Setting mod_gzip\n";
556
+ $new_rules .= "<ifModule mod_gzip.c>\n";
557
+ $new_rules .= "mod_gzip_on Yes\n";
558
+ $new_rules .= "mod_gzip_dechunk Yes\n";
559
+ $new_rules .= "mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$\n";
560
+ $new_rules .= "mod_gzip_item_include handler ^cgi-script$\n";
561
+ $new_rules .= "mod_gzip_item_include mime ^text/.*\n";
562
+ $new_rules .= "mod_gzip_item_include mime ^application/x-javascript.*\n";
563
+ $new_rules .= "mod_gzip_item_exclude mime ^image/.*\n";
564
+ $new_rules .= "mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*\n";
565
+ $new_rules .= "</ifModule>\n";
566
+ }
567
+ if ( $this->data['deflate'] ) {
568
+ $new_rules .= "\n# WPhtC: Setting mod_deflate\n";
569
+ $new_rules .= "<IfModule mod_deflate.c>\n";
570
+ $new_rules .= "AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript\n";
571
+ $new_rules .= "BrowserMatch ^Mozilla/4 gzip-only-text/html\n";
572
+ $new_rules .= "BrowserMatch ^Mozilla/4.0[678] no-gzip\n";
573
+ $new_rules .= "BrowserMatch bMSIE !no-gzip !gzip-only-text/html\n";
574
+ $new_rules .= "Header append Vary User-Agent env=!dont-vary\n";
575
+ $new_rules .= "</IfModule>\n";
576
+ }
577
+ if ( $this->data['wp_hta'] && trim( $this->data['wp_hta'] ) != '' ) {
578
+ $new_rules .= "\n" . $this->data['wp_hta'];
579
+ } else {
580
+ $new_rules .= "\n" . $rules;
581
+ }
582
+
583
+ return $new_rules;
584
+ }
585
+
586
+ # Filter Term Link
587
+ function filter_term_link( $termlink, $term, $taxonomy ) {
588
+ // WPhtc -> this
589
+ if ( $this->data['remove_taxonomy_base'][ $taxonomy ] ) {
590
+ $txs = get_taxonomies( array( 'name' => $taxonomy ), "object" );
591
+ foreach ( $txs as $t ) {
592
+ //return str_replace($t->rewrite['slug']."/","",$termlink);
593
+ if ( $term->parent != 0 && ! $this->data['remove_hierarchy'] ) {
594
+ return get_bloginfo( 'url' ) . "/" . $this->term_ancestors( $taxonomy, $term->parent ) . "/" . $term->slug;
595
+ } else {
596
+ return get_bloginfo( 'url' ) . "/" . $term->slug;
597
+ }
598
+ }
599
+ } else {
600
+ return $termlink;
601
+ }
602
+ }
603
+
604
+ # Filter Taxonomy Base
605
+ function remove_taxonomy_base_from_rewrite_rules( $rules ) {
606
+ # Let's remove every taxonomy rule here, we'll reacreate them at filter_rewrite_rules()
607
+ return array();
608
+ //return $rules;
609
+ }
610
+
611
+ # Filter Author Rewrite Rules
612
+ function remove_author_base_from_rewrite_rules( $author_rewrite ) {
613
+
614
+ if ( $this->data['remove_author_base'] ) {
615
+ $author_rewrite = array();
616
+ $blogusers = get_users( 'who=authors' );
617
+ foreach ( $blogusers as $user ) {
618
+ $author_rewrite[ '(' . $user->user_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$' ] = 'index.php?author_name=$matches[1]&feed=$matches[2]';
619
+ $author_rewrite[ '(' . $user->user_nicename . ')/page/?([0-9]{1,})/?$' ] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
620
+ $author_rewrite[ '(' . $user->user_nicename . ')/?$' ] = 'index.php?author_name=$matches[1]';
621
+ }
622
+ }
623
+
624
+ return $author_rewrite;
625
+ }
626
+
627
+ # WP-htaccess Control options page interface
628
+ public static function page() {
629
+ include( dirname( __FILE__ ) . '/wp-htaccess-control-ui.php' );
630
+ }
631
+
632
+ # Adding our options page to the admin menu
633
+ function configure_menu() {
634
+ if ( current_user_can( "administrator" ) ) {
635
+ $page = add_submenu_page( "options-general.php", "WP htaccess Control", "htaccess Control", 'activate_plugins', __FILE__, array(
636
+ 'WPhtc',
637
+ 'page'
638
+ ) );
639
+ add_action( 'admin_print_scripts-' . $page, array( 'WPhtc', 'page_script' ) );
640
+ add_action( 'admin_print_styles-' . $page, array( 'WPhtc', 'page_style' ) );
641
+ }
642
+ }
643
+
644
+ # Enqueue Ui Scripts on Plugin page
645
+ public static function page_script() {
646
+ wp_enqueue_script( "htaccess-control-js", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.js' );
647
+ }
648
+
649
+ # Enqueue Ui Scripts on Plugin page
650
+ public static function page_style() {
651
+ wp_enqueue_style( "htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css' );
652
+ }
653
+
654
+ # Filter "View" Link on Administration
655
+ function filter_tax_table_actions( $actions, $tag ) {
656
+ if ( $tag->parent != 0 ) {
657
+ $actions['view'] = '<a href="' . get_bloginfo( 'url' ) . '/' . $this->term_ancestors( $tag->taxonomy, $tag->parent ) . '/' . $tag->slug . '">View</a>';
658
+ }
659
+
660
+ return $actions;
661
+ }
662
+
663
+ # Options Page Actions
664
+ function page_action() {
665
+ $this->check_first_run();
666
+ $this->data = array_merge( $this->defaultData, get_option( 'WPhtc_data' ) );
667
+ if ( isset( $_REQUEST['action'] ) ) {
668
+ $action = $_REQUEST['action'];
669
+ global $WPhtcEcho;
670
+
671
+ switch ( $action ) {
672
+ # Hide donation message for one month
673
+ case 'hide_donation_message':
674
+ $this->data['donation_hidden_time'] = time() + 90 * 24 * 60 * 60;
675
+ update_option( 'WPhtc_data', $this->data );
676
+ break;
677
+ # if reseting everything just delete the option array
678
+ case 'reset_rules':
679
+ # nonce
680
+ if ( ! check_admin_referer( 'WPhtc_reset_settings' ) ) {
681
+ die( "You have no permission to do this." );
682
+ }
683
+ $this->data = $this->defaultData;
684
+ delete_option( 'WPhtc_data' );
685
+ //update_option('WPhtc_data',$this->data);
686
+ $WPhtcEcho .= __( 'All rules reset.', 'wp-htaccess-control' );
687
+ $this->refresh_rewrite_rules();
688
+ break;
689
+ # if updating, save new rules in database and flush rewrite rules
690
+ case 'update':
691
+ # first donation hidding time 'now'
692
+ if ( ! $this->data['donation_hidden_time'] ) {
693
+ $this->data['donation_hidden_time'] = time();
694
+ }
695
+ # nonce
696
+ if ( ! check_admin_referer( 'WPhtc_settings' ) ) {
697
+ die( "You have no permission to do this." );
698
+ }
699
+
700
+ // @todo replace this with defaultData
701
+ foreach (
702
+ array(
703
+ "hta",
704
+ "cap",
705
+ "cpp",
706
+ "custom_search_permalink",
707
+ "remove_author_base",
708
+ "category_archives",
709
+ "author_archives",
710
+ "tag_archives",
711
+ "disable_serversignature",
712
+ "disable_indexes",
713
+ "protect_wp_config",
714
+ "protect_htaccess",
715
+ "protect_comments",
716
+ "disable_hotlink",
717
+ "disable_file_hotlink_ext",
718
+ "disable_file_hotlink_redir",
719
+ "redirect_500",
720
+ "redirect_403",
721
+ "canon",
722
+ "admin_email",
723
+ "deflate",
724
+ "gzip",
725
+ "maintenance_active",
726
+ "maintenance_redirection",
727
+ "login_disabled",
728
+ "login_half_mode",
729
+ "login_redirection",
730
+ "sm_enabled",
731
+ "remove_hierarchy",
732
+ "suffix_html"
733
+ )
734
+ as $k
735
+ ) {
736
+ $this->data[ $k ] = isset( $_POST[ 'WPhtc_' . $k ] ) ? $_POST[ 'WPhtc_' . $k ] : '';
737
+ }
738
+
739
+ # wordpress htaccess and jim morgan's htaccess
740
+ $this->data['wp_hta'] = $_POST['WPhtc_wp_hta'] . "\n";
741
+
742
+ # get htaccess Suggestions
743
+ $this->data['up_limit'] = ( is_numeric( $_POST['WPhtc_up_limit'] ) && $_POST['WPhtc_up_limit'] > 0 ) ? $_POST['WPhtc_up_limit'] : '';
744
+ # get maintenance
745
+ $lines = preg_split( "/\n|,/", $_POST['WPhtc_maintenance_ips'] );
746
+ $this->data['maintenance_ips'] = array();
747
+ foreach ( $lines as $line ) {
748
+ trim( $line );
749
+ if ( preg_match( "/[a-z,0-9,\.]/", $line ) ) {
750
+ $this->data['maintenance_ips'][] = $line;
751
+ }
752
+ }
753
+ # get login control data
754
+ if ( isset( $_POST['WPhtc_login_ips'] ) ) {
755
+ $lines = preg_split( "/\n|,/", $_POST['WPhtc_login_ips'] );
756
+ $this->data['login_ips'] = array();
757
+ foreach ( $lines as $line ) {
758
+ trim( $line );
759
+ if ( preg_match( "/[a-z,0-9,\.]/", $line ) ) {
760
+ $this->data['login_ips'][] = $line;
761
+ }
762
+ }
763
+ }
764
+
765
+ # Unsetting inclusion of Author pages on Google XML Sitemap options, we'll add those links to the sitemap later with our Custom Author Permalink
766
+ if ( $this->data['sm_enabled'] == true ) {
767
+ $SMoptions = get_option( "sm_options" );
768
+ if ( $SMoptions && is_array( $SMoptions ) ) {
769
+ $SMoptions = get_option( "sm_options" );
770
+ $SMoptions['sm_in_auth'] = 0;
771
+ update_option( 'sm_options', $SMoptions );
772
+ # Try to rebuild Sitemap
773
+ do_action( "sm_rebuild" );
774
+ }
775
+ }
776
+
777
+ # Taxonomy Base removal options
778
+ unset( $this->data['remove_taxonomy_base'] );
779
+ if ( isset( $_POST['WPhtc_remove_base'] ) and $_POST['WPhtc_remove_base'] ) {
780
+ foreach ( $_POST['WPhtc_remove_base'] as $tax_key => $remove ) {
781
+ $this->data['remove_taxonomy_base'][ $tax_key ] = $remove;
782
+ }
783
+ }
784
+
785
+ # Advanced archives
786
+ unset( $this->data['create_archive'] );
787
+ if ( isset( $_POST['WPhtc_create_archive'] ) ) {
788
+ foreach ( $_POST['WPhtc_create_archive'] as $tax_key => $create_archive ) {
789
+ $this->data['create_archive'][ $tax_key ] = $create_archive;
790
+ }
791
+ }
792
+
793
+ # Update WP htaccess Control options
794
+ update_option( 'WPhtc_data', $this->data );
795
+
796
+ # Flush Rewrite Rules
797
+ $this->refresh_rewrite_rules();
798
+ $WPhtcEcho .= __( 'All options updated.', 'wp-htaccess-control' );
799
+ break;
800
+ }
801
+ }
802
+ }
803
+ }
804
  }
805
+ if ( class_exists( "WPhtc" ) ) {
806
+ $WPhtc = new WPhtc();
807
  }
808
+ if ( isset( $WPhtc ) ) {
809
+
810
+ add_action( 'init', array( $WPhtc, 'init' ) );
811
+ add_filter( 'mod_rewrite_rules', array( $WPhtc, 'hta_rules' ) );
812
+ add_filter( 'redirect_canonical', array( $WPhtc, 'filter_redirect_canonical' ), 10, 10 );
813
+ add_action( 'admin_menu', array( $WPhtc, 'configure_menu' ) );
814
+ add_action( 'flush_event', array( $WPhtc, 'refresh_rewrite_rules' ) );
815
+ add_filter( 'generate_rewrite_rules', array( $WPhtc, 'wp_rewrite_rules' ) );
816
+ add_filter( 'rewrite_rules_array', array( $WPhtc, 'filter_rewrite_rules' ) );
817
+
818
+ // AUTHOR improve this
819
+ if ( $WPhtc->data['cap'] != '' || $WPhtc->data['remove_author_base'] ) {
820
+ add_filter( 'author_link', array( $WPhtc, 'filter_author_link' ) );
821
+ add_filter( 'author_rewrite_rules', array( $WPhtc, 'remove_author_base_from_rewrite_rules' ) );
822
+ }
823
+
824
+ // Filter pagination links
825
+ if ( $WPhtc->data['cpp'] != '' ) {
826
+ add_filter( 'paginate_links', array( $WPhtc, 'filter_get_pagenum_link' ) );
827
+ add_filter( 'get_pagenum_link', array( $WPhtc, 'filter_get_pagenum_link' ) );
828
+ }
829
+
830
+ // Filter search
831
+ if ( trim( $WPhtc->data['custom_search_permalink'] ) != '' ) {
832
+ add_filter( 'search_feed_link', array( $WPhtc, 'search_feed_link' ), 10, 10 );
833
+ add_filter( 'get_search_query', array( $WPhtc, 'get_search_query_filter' ), 10, 10 );
834
+ add_action( 'template_redirect', array( $WPhtc, 'search_template_redirect' ) );
835
+ }
836
+
837
+
838
+ add_action( 'sm_buildmap', array( $WPhtc, 'set_sm' ) );
839
+
840
+ // Taxonomy Base Removal
841
+ if ( $WPhtc->data['remove_taxonomy_base'] ) {
842
+ add_filter( 'term_link', array( $WPhtc, 'filter_term_link' ), 10, 3 );
843
+ foreach ( $WPhtc->data['remove_taxonomy_base'] as $tax => $v ) {
844
+ if ( $v ) {
845
+ add_filter( $tax . '_rewrite_rules', array( $WPhtc, 'remove_taxonomy_base_from_rewrite_rules' ) );
846
+ add_filter( $tax . "_row_actions", array( $WPhtc, 'filter_tax_table_actions' ), 10, 2 );
847
+ }
848
+ }
849
+ }
850
+ /* Term management actions*/
851
+ if ( $WPhtc->data['remove_taxonomy_base'] || $WPhtc->data['create_archive'] ) {
852
+ add_action( 'created_term', array( $WPhtc, 'refresh_rewrite_rules_later' ) );
853
+ add_action( 'edited_term', array( $WPhtc, 'refresh_rewrite_rules_later' ) );
854
+ add_action( 'delete_term', array( $WPhtc, 'refresh_rewrite_rules_later' ) );
855
+ }
856
+
857
+ /* This flush should maybe be conditional to content authors only, maybe not */
858
+ add_action( 'user_register', array( $WPhtc, 'refresh_rewrite_rules_later' ) );
859
+ add_action( 'delete_user', array( $WPhtc, 'refresh_rewrite_rules_later' ) );
860
  }
861
  ?>