WP htaccess Control - Version 1.0

Version Description

Download this release

Release Info

Developer andrad
Plugin Icon wp plugin WP htaccess Control
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (4) hide show
  1. readme.txt +32 -0
  2. screenshot-1.png +0 -0
  3. screenshot-2.jpg +0 -0
  4. wp-htaccess-control.php +139 -0
readme.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP htaccess Control ===
2
+ Author: andrad
3
+ Author URI: http://dardna.com/
4
+ Plugin URI: http://dardna.com/wp-htaccess-control
5
+ Donate link:
6
+ Tags: permalinks, author, htaccess
7
+ Requires at least: 2.7
8
+ Tested up to: 2.7.1
9
+ Stable tag: 1.0
10
+
11
+ WP htaccess Control provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress. It also includes an improved and much more stable version of Custom Author Permalink .
12
+
13
+ == Description ==
14
+
15
+ **WP htaccess Control** provides an interface to add custom htaccess rules to the htaccess file generated by Wordpress. It also includes an improved and much more stable version of **Custom Author Permalink**. Take a look at the screenshots..
16
+
17
+ == Installation ==
18
+
19
+ 1. Download **WP htaccess Control**;
20
+ 2. Extract its content;
21
+ 3. Upload the **wp-htaccess-control** folder to **wp-content/plugins**;
22
+ 4. Activate it under **Plugins**;
23
+ 5. Configurate it under **Settings** > **WP htaControl**.
24
+
25
+ == Frequently Asked Questions ==
26
+
27
+ = Do you have any questions? =
28
+
29
+ == Screenshots ==
30
+
31
+ 1. Administration
32
+ 2. Resulting .htaccess file
screenshot-1.png ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
wp-htaccess-control.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP htaccess Control
4
+ Plugin URI: http://dardna.com/wp-htaccess-control
5
+ Description: Provides an interface to add custom htaccess rules to the htaccess file generated by wordpress. Also includes an improved and much more stable version of Custom Author Permalink
6
+ Version: 1
7
+ Author: dardna
8
+ Author URI: http://dardna.com
9
+ */
10
+
11
+ if (!class_exists("WPhtc")) {
12
+ class WPhtc {
13
+ function WPhtc() {
14
+ }
15
+ function wphtc_cap($rules){
16
+ $WPhtc_data=get_option('WPhtc_data');
17
+ if(isset($WPhtc_data['cap']) && $WPhtc_data['cap']!=''){
18
+ $rules=unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'",str_replace('author/',$WPhtc_data['cap'].'/',serialize($rules))));
19
+ }
20
+ return $rules;
21
+ }
22
+ function wphtc_rules($wp_rewrite){
23
+ $WPhtc_data=get_option('WPhtc_data');
24
+ for($i=0;$i<count($WPhtc_data['pats']);$i++){
25
+ if($WPhtc_data['pats'][$i]!=''&&$WPhtc_data['subs'][$i]!=''){
26
+ $wp_rewrite->non_wp_rules[$WPhtc_data['pats'][$i]]=$WPhtc_data['subs'][$i];
27
+ }
28
+ }
29
+ return $wp_rewrite;
30
+ }
31
+ function wphtc_page(){
32
+ $q=explode('&',$_SERVER['QUERY_STRING']);
33
+ $purl='http'.((!empty($_SERVER['HTTPS'])) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$q[0];
34
+ ?>
35
+ <?php
36
+ $WPhtc_data=get_option('WPhtc_data');
37
+ $action=$_POST['action']?$_POST['action']:$_GET['action'];
38
+ if(isset($action)){
39
+ switch($action){
40
+ case 'update':
41
+ for($i=0;$i<$_POST['WPhtc_num'];$i++){
42
+ if(!empty($_POST['WPhtc_pat'.$i]) && !empty($_POST['WPhtc_sub'.$i])){
43
+ $WPhtc_data['pats'][$i]=$_POST['WPhtc_pat'.$i];
44
+ $WPhtc_data['subs'][$i]=$_POST['WPhtc_sub'.$i];
45
+ }
46
+ }
47
+ $WPhtc_data['cap']=$_POST['WPhtc_cap'];
48
+ update_option('WPhtc_data',$WPhtc_data);
49
+ global $wp_rewrite;
50
+ $wp_rewrite->flush_rules();
51
+ $echo.="Author permalink structure and htaccess updated.";
52
+ break;
53
+ case 'reset_rules':
54
+ $WPhtc_data=array(
55
+ 'pats'=>'',
56
+ 'subs'=>'',
57
+ );
58
+ update_option('WPhtc_data',$WPhtc_data);
59
+ $echo.="Rules reset.";
60
+ break;
61
+ case 'add_rule':
62
+ $add_rule=true;
63
+ $echo='New pair available!';
64
+ break;
65
+ case 'delete_pair':
66
+ if(isset($_GET['pair'])){
67
+ unset($WPhtc_data['pats'][$_GET['pair']],$WPhtc_data['subs'][$_GET['pair']]);
68
+ $WPhtc_data['pats']=array_values($WPhtc_data['pats']);
69
+ $WPhtc_data['subs']=array_values($WPhtc_data['subs']);
70
+ update_option('WPhtc_data',$WPhtc_data);
71
+ $echo='Pair deleted!';
72
+ }
73
+ break;
74
+ }
75
+ }
76
+ ?>
77
+ <div class="wrap">
78
+ <h2>Wp htaccess Control</h2>
79
+ <?php if($echo!=''){?>
80
+ <div class="updated fade" id="message" style="background-color: rgb(255, 251, 204);"><p><?php echo $echo;?></p></div>
81
+ <?php }?>
82
+ <form method="post" action="<?php echo $purl?>">
83
+ <h3>Rewrite Pairs</h3>
84
+ <p><a href="<?php echo $purl?>&action=add_rule">Add rule</a> - <a href="<?php echo $purl?>&action=reset_rules">Reset all rules</a></p>
85
+ <table class="form-table">
86
+ <?php
87
+ $num=count($WPhtc_data['pats']);
88
+ if($add_rule){$num++;};
89
+ for($i=0;$i<$num;$i++){?>
90
+ <tr valign="top">
91
+ <td><input type="text" style="width:100%" name="WPhtc_pat<?php echo $i;?>" value="<?php echo $WPhtc_data['pats'][$i]; ?>" /></td>
92
+ <td><input type="text" style="width:100%" name="WPhtc_sub<?php echo $i;?>" value="<?php echo $WPhtc_data['subs'][$i]; ?>" /></td>
93
+ <td><a href="<?php echo $purl ?>&action=delete_pair&pair=<?php echo $i?>">Delete Pair</a></td>
94
+ </tr>
95
+ <?php } ?>
96
+ </table>
97
+ <h3>Custom Author Permalink</h3>
98
+ <table class="form-table">
99
+ <tr valign="top">
100
+ <th scope="row">Author Permalink Base</th>
101
+ <td><input type="text" name="WPhtc_cap" value="<?php echo $WPhtc_data['cap']; ?>" /></td>
102
+ <td><p><strong><?php bloginfo('home')?>/<em>(your-base)</em>/admin</strong></p></td>
103
+ </tr>
104
+ </table>
105
+ <input type="hidden" name="action" value="update" />
106
+ <input type="hidden" name="WPhtc_num" value="<?php echo $num;?>" />
107
+ <p class="submit">
108
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
109
+ </p>
110
+ </form>
111
+ </div><?php
112
+ }
113
+ function ConfigureMenu(){
114
+ add_submenu_page("options-general.php","WP htaccess Control", "WP htaControl", 6, __FILE__, array('WPhtc','wphtc_page'));
115
+ }
116
+ }
117
+ }
118
+
119
+ if (class_exists("WPhtc")) {
120
+ $WPhtc = new WPhtc();
121
+ }
122
+
123
+
124
+ if (isset($WPhtc)) {
125
+ add_filter('generate_rewrite_rules', array($WPhtc,'wphtc_rules'));
126
+ add_filter('rewrite_rules_array',array($WPhtc,'wphtc_cap'));
127
+ add_action('admin_menu', array($WPhtc,'ConfigureMenu'));
128
+ }
129
+
130
+ register_activation_hook(__FILE__,'WPhtc_install');
131
+
132
+ function WPhtc_install() {
133
+ $WPhtc_data=array(
134
+ 'pats'=>'',
135
+ 'subs'=>'',
136
+ );
137
+ update_option('WPhtc_data',$WPhtc_data);
138
+ }
139
+ ?>