WP htaccess Control - Version 3.4.4

Version Description

(21/4/2014) =

  • Fix: taxonomy base removal admin interface would agglomerate settings;
  • Fix: wiped a number of php warnings.
Download this release

Release Info

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

Code changes from version 3.4.3 to 3.4.4

Files changed (2) hide show
  1. readme.txt +6 -1
  2. wp-htaccess-control.php +65 -21
readme.txt CHANGED
@@ -7,7 +7,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=anton
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.3
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
13
 
@@ -93,6 +93,11 @@ For WordPress versions prior to 3.4 use the plugin version 2.7.2.1.
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
96
  = 3.4.3 (20/4/2014) =
97
 
98
  * Fix: taxonomy base removal.
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.4
11
 
12
  Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
13
 
93
 
94
  == Changelog ==
95
 
96
+ = 3.4.4 (21/4/2014) =
97
+
98
+ * Fix: taxonomy base removal admin interface would agglomerate settings;
99
+ * Fix: wiped a number of php warnings.
100
+
101
  = 3.4.3 (20/4/2014) =
102
 
103
  * Fix: taxonomy base removal.
wp-htaccess-control.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP htaccess Control
4
  Plugin URI: http://antonioandra.de
5
  Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
6
- Version: 3.4.3
7
  Author: António Andrade
8
  Author URI: http://antonioandra.de
9
  */
@@ -32,9 +32,44 @@ if (!class_exists("WPhtc")) {
32
 
33
  public $data;
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  function WPhtc()
36
  {
37
- $this->data = get_option('WPhtc_data');
 
 
 
 
 
38
  }
39
 
40
  /*
@@ -42,14 +77,15 @@ if (!class_exists("WPhtc")) {
42
  */
43
  function get_data($key, $key_inner = "")
44
  {
 
45
  if (isset($this->data[$key])) {
46
  if ($key_inner != "" && isset($this->data[$key][$key_inner])) {
47
  return $this->data[$key][$key_inner];
48
- } else {
49
  return $this->data[$key];
50
  }
51
  } else {
52
- return false;
53
  }
54
  }
55
 
@@ -128,7 +164,6 @@ if (!class_exists("WPhtc")) {
128
 
129
  function check_first_run()
130
  {
131
-
132
  # flush rules to get some data filled on first usage
133
  if (!isset($this->data['htaccess_original'])) {
134
  $this->refresh_rewrite_rules();
@@ -224,8 +259,8 @@ if (!class_exists("WPhtc")) {
224
  $terms = get_terms($taxonomy->name, array("hide_empty" => false));
225
  foreach ($terms as $term) {
226
  $base = isset($this->data['remove_taxonomy_base'], $this->data['remove_taxonomy_base'][$taxonomy->name])
227
- ? ""
228
- : $taxonomy->rewrite['slug'] . "/";
229
  if ($term->parent != 0 && !$this->data['remove_hierarchy']) {
230
  $ancestors = $this->term_ancestors($taxonomy->name, $term->parent) . "/";
231
  } else {
@@ -367,12 +402,15 @@ if (!class_exists("WPhtc")) {
367
  # Adding Custom Rules to htaccess file generated by WordPress, everytime the rules are flush
368
  function hta_rules($rules)
369
  {
370
- $new_rules = "";
371
  # keeping original hta
372
  if (!isset($this->data['htaccess_original'])) {
373
  $this->data['htaccess_original'] = $rules;
374
  update_option('WPhtc_data', $this->data);
375
  }
 
 
 
376
  # Maintenance Mode
377
  if ($this->data['maintenance_active'] && isset($this->data['maintenance_ips'][0])) {
378
  $no_ips = count($this->data['maintenance_ips']);
@@ -592,7 +630,7 @@ if (!class_exists("WPhtc")) {
592
  }
593
 
594
  # WP-htaccess Control options page interface
595
- function page()
596
  {
597
  include(dirname(__FILE__) . '/wp-htaccess-control-ui.php');
598
  }
@@ -608,13 +646,13 @@ if (!class_exists("WPhtc")) {
608
  }
609
 
610
  # Enqueue Ui Scripts on Plugin page
611
- function page_script()
612
  {
613
  wp_enqueue_script("htaccess-control-js", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.js');
614
  }
615
 
616
  # Enqueue Ui Scripts on Plugin page
617
- function page_style()
618
  {
619
  wp_enqueue_style("htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css');
620
  }
@@ -632,6 +670,7 @@ if (!class_exists("WPhtc")) {
632
  function page_action()
633
  {
634
  $this->check_first_run();
 
635
  if (isset($_REQUEST['action'])) {
636
  $action = $_REQUEST['action'];
637
  global $WPhtcEcho;
@@ -648,7 +687,7 @@ if (!class_exists("WPhtc")) {
648
  if (!check_admin_referer('WPhtc_reset_settings')) {
649
  die("You have no permission to do this.");
650
  }
651
- $this->data = array();
652
  delete_option('WPhtc_data');
653
  //update_option('WPhtc_data',$this->data);
654
  $WPhtcEcho .= __('All rules reset.', 'wp-htaccess-control');
@@ -665,7 +704,8 @@ if (!class_exists("WPhtc")) {
665
  die("You have no permission to do this.");
666
  }
667
 
668
- 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", "jim_morgan_hta", "remove_hierarchy", "suffix_html")
 
669
  as $k) {
670
  $this->data[$k] = isset($_POST['WPhtc_' . $k]) ? $_POST['WPhtc_' . $k] : '';
671
  }
@@ -685,12 +725,14 @@ if (!class_exists("WPhtc")) {
685
  }
686
  }
687
  # get login control data
688
- $lines = preg_split("/\n|,/", $_POST['WPhtc_login_ips']);
689
- $this->data['login_ips'] = array();
690
- foreach ($lines as $line) {
691
- trim($line);
692
- if (preg_match("/[a-z,0-9,\.]/", $line)) {
693
- $this->data['login_ips'][] = $line;
 
 
694
  }
695
  }
696
 
@@ -708,7 +750,7 @@ if (!class_exists("WPhtc")) {
708
 
709
  # Taxonomy Base removal options
710
  unset($this->data['remove_taxonomy_base']);
711
- if ($_POST['WPhtc_remove_base']) {
712
  foreach ($_POST['WPhtc_remove_base'] as $tax_key => $remove) {
713
  $this->data['remove_taxonomy_base'][$tax_key] = $remove;
714
  }
@@ -754,7 +796,9 @@ if (isset($WPhtc)) {
754
  }
755
 
756
  // Filter pagination links
757
- if ($WPhtc->data['cpp'] != '') add_filter('get_pagenum_link', array($WPhtc, 'filter_get_pagenum_link'));
 
 
758
 
759
  // Filter search
760
  if (trim($WPhtc->data['custom_search_permalink']) != '') {
3
  Plugin Name: WP htaccess Control
4
  Plugin URI: http://antonioandra.de
5
  Description: Interface to customize the permalinks (author, category, archives and pagination) and htaccess file generated by WordPress.
6
+ Version: 3.4.4
7
  Author: António Andrade
8
  Author URI: http://antonioandra.de
9
  */
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
  /*
77
  */
78
  function get_data($key, $key_inner = "")
79
  {
80
+
81
  if (isset($this->data[$key])) {
82
  if ($key_inner != "" && isset($this->data[$key][$key_inner])) {
83
  return $this->data[$key][$key_inner];
84
+ } else if(!isset($key_inner) and isset($this->data[$key])) {
85
  return $this->data[$key];
86
  }
87
  } else {
88
+ return null;
89
  }
90
  }
91
 
164
 
165
  function check_first_run()
166
  {
 
167
  # flush rules to get some data filled on first usage
168
  if (!isset($this->data['htaccess_original'])) {
169
  $this->refresh_rewrite_rules();
259
  $terms = get_terms($taxonomy->name, array("hide_empty" => false));
260
  foreach ($terms as $term) {
261
  $base = isset($this->data['remove_taxonomy_base'], $this->data['remove_taxonomy_base'][$taxonomy->name])
262
+ ? ""
263
+ : $taxonomy->rewrite['slug'] . "/";
264
  if ($term->parent != 0 && !$this->data['remove_hierarchy']) {
265
  $ancestors = $this->term_ancestors($taxonomy->name, $term->parent) . "/";
266
  } else {
402
  # Adding Custom Rules to htaccess file generated by WordPress, everytime the rules are flush
403
  function hta_rules($rules)
404
  {
405
+
406
  # keeping original hta
407
  if (!isset($this->data['htaccess_original'])) {
408
  $this->data['htaccess_original'] = $rules;
409
  update_option('WPhtc_data', $this->data);
410
  }
411
+
412
+ $new_rules = "";
413
+
414
  # Maintenance Mode
415
  if ($this->data['maintenance_active'] && isset($this->data['maintenance_ips'][0])) {
416
  $no_ips = count($this->data['maintenance_ips']);
630
  }
631
 
632
  # WP-htaccess Control options page interface
633
+ public static function page()
634
  {
635
  include(dirname(__FILE__) . '/wp-htaccess-control-ui.php');
636
  }
646
  }
647
 
648
  # Enqueue Ui Scripts on Plugin page
649
+ public static function page_script()
650
  {
651
  wp_enqueue_script("htaccess-control-js", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.js');
652
  }
653
 
654
  # Enqueue Ui Scripts on Plugin page
655
+ public static function page_style()
656
  {
657
  wp_enqueue_style("htaccess-control-css", WP_PLUGIN_URL . '/wp-htaccess-control/wp-htaccess-control-ui.css');
658
  }
670
  function page_action()
671
  {
672
  $this->check_first_run();
673
+ $this->data = array_merge($this->defaultData, get_option('WPhtc_data'));
674
  if (isset($_REQUEST['action'])) {
675
  $action = $_REQUEST['action'];
676
  global $WPhtcEcho;
687
  if (!check_admin_referer('WPhtc_reset_settings')) {
688
  die("You have no permission to do this.");
689
  }
690
+ $this->data = $this->defaultData;
691
  delete_option('WPhtc_data');
692
  //update_option('WPhtc_data',$this->data);
693
  $WPhtcEcho .= __('All rules reset.', 'wp-htaccess-control');
704
  die("You have no permission to do this.");
705
  }
706
 
707
+ // @todo replace this with defaultData
708
+ 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")
709
  as $k) {
710
  $this->data[$k] = isset($_POST['WPhtc_' . $k]) ? $_POST['WPhtc_' . $k] : '';
711
  }
725
  }
726
  }
727
  # get login control data
728
+ if (isset($_POST['WPhtc_login_ips'])) {
729
+ $lines = preg_split("/\n|,/", $_POST['WPhtc_login_ips']);
730
+ $this->data['login_ips'] = array();
731
+ foreach ($lines as $line) {
732
+ trim($line);
733
+ if (preg_match("/[a-z,0-9,\.]/", $line)) {
734
+ $this->data['login_ips'][] = $line;
735
+ }
736
  }
737
  }
738
 
750
 
751
  # Taxonomy Base removal options
752
  unset($this->data['remove_taxonomy_base']);
753
+ if (isset($_POST['WPhtc_remove_base']) and $_POST['WPhtc_remove_base']) {
754
  foreach ($_POST['WPhtc_remove_base'] as $tax_key => $remove) {
755
  $this->data['remove_taxonomy_base'][$tax_key] = $remove;
756
  }
796
  }
797
 
798
  // Filter pagination links
799
+ if ($WPhtc->data['cpp'] != '') {
800
+ add_filter('get_pagenum_link', array($WPhtc, 'filter_get_pagenum_link'));
801
+ }
802
 
803
  // Filter search
804
  if (trim($WPhtc->data['custom_search_permalink']) != '') {