WP Hide & Security Enhancer - Version 1.3.4

Version Description

  • Improved replacement code for Uploads, when "Block uploads URL" is set for "No" it use default media urls within the admin editor, to ensure links are still functional if plugin is disabled.
  • Priority (high, normal, low) for replacement urls
  • Replacement Urls for gziped buffer
  • Fix rule name for child_style_file_clean on web.config IIS
  • bbPress Compatibility
  • BuddyPress Compatibility
  • Prevent replacements on wp_redirect filter if is_404()
  • Updated PO / MO translation files
  • Removed in line components filters which changed the urls, leave for end buffering to make all changes.
  • Fix for mod_rewrite line on child theme when router is turned Off, append the default style.css filename
  • Improvements for Templates default variables to match customized themes like Sage
  • Compatibility fix for Super Cache plugin ob callback
  • Add IfModule mod_env.c before set nSetEnv HTTP_MOD_REWRITE On to prevent server internal error in case mod_env module is not available
  • Check for Empty $saved_field_data within new plugin path component, to avoid creating rewrite rule if empty and existent path
  • Improved get_home_path()
  • Replacements for Relative URL's
Download this release

Release Info

Developer nsp-code
Plugin Icon 128x128 WP Hide & Security Enhancer
Version 1.3.4
Comparing to
See all releases

Code changes from version 1.3.3.2 to 1.3.4

conflicts/super-cache.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class WPH_conflict_handle_super_cache
5
+ {
6
+
7
+ function _construct_()
8
+ {
9
+
10
+ }
11
+
12
+ static function is_plugin_active()
13
+ {
14
+
15
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
16
+
17
+ if(is_plugin_active( 'wp-super-cache/wp-cache.php' ))
18
+ return TRUE;
19
+ else
20
+ return FALSE;
21
+ }
22
+
23
+ static public function init()
24
+ {
25
+ if( ! self::is_plugin_active())
26
+ return FALSE;
27
+
28
+ global $wph;
29
+
30
+ //add bufer filtering for sueprcache plugin
31
+ add_filter('wp_cache_ob_callback_filter', array($wph, 'ob_start_callback'), 999);
32
+
33
+ }
34
+
35
+ }
36
+
37
+
38
+ ?>
css/wph.css CHANGED
@@ -51,10 +51,14 @@ table.wph_input input[type=text]:focus,table.wph_input textarea:focus,table.wph_
51
 
52
  .postbox h3 span {display: inline-block; vertical-align: middle}
53
 
54
- .postbox .icon {width: 20px; height: 18px; background-image:url("../images/sprite.png");background-repeat:no-repeat; margin-right: 10px}
55
- .postbox .icon.settings {background-position: -10px -44px;}
 
 
 
 
 
56
 
57
 
58
- #icon-settings {background-image:url("../images/admin-icon-settings.gif");background-repeat:no-repeat;}
59
  h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold}
60
  .wrap .example { color: #666666; font-size: 11px; font-weight: bold}
51
 
52
  .postbox h3 span {display: inline-block; vertical-align: middle}
53
 
54
+ #info_box {padding: 0 10px; border: 1px dashed #6aadcc; background-color: #FFF; margin: 10px 0 20px 0;-webkit-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);-moz-box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);box-shadow: 1px 1px 7px rgba(50, 50, 50, 0.17);}
55
+ #info_box a {text-decoration: none}
56
+ #info_box #p_right {float: right; width: 230px; background-color:#f5f5f5; border-left: 1px dashed #dedede; border-right: 1px dashed #dedede; margin-left: 10px; text-align: center;}
57
+ #info_box #p_socialize {padding: 20px 0px 20px 0}
58
+ #info_box .p_s_item {float: none; padding: 0px 5px; margin: 0px; display: inline-block; vertical-align: middle;}
59
+ #info_box .p_s_item > iframe, #info_box .p_s_item > div {display: block}
60
+ #info_box .p_s_item.s_gp {padding-top: 3px; margin-left: 0px}
61
 
62
 
 
63
  h2.subtitle {font-size: 15px; font-style: italic; font-weight: bold}
64
  .wrap .example { color: #666666; font-size: 11px; font-weight: bold}
images/admin-icon-settings.gif DELETED
Binary file
images/sprite.png DELETED
Binary file
include/admin-interface.class.php CHANGED
@@ -71,7 +71,9 @@
71
  <h1><?php echo $this->interface_data['title'] ?></h1>
72
 
73
  <?php
74
-
 
 
75
  if($this->module->use_tabs === TRUE)
76
  $this->_generate_interface_tabs();
77
 
71
  <h1><?php echo $this->interface_data['title'] ?></h1>
72
 
73
  <?php
74
+
75
+ echo $this->functions->get_ad_banner();
76
+
77
  if($this->module->use_tabs === TRUE)
78
  $this->_generate_interface_tabs();
79
 
include/functions.class.php CHANGED
@@ -1,1378 +1,1658 @@
1
- <?php
2
-
3
-
4
- class WPH_functions
5
- {
6
- var $wph;
7
-
8
- function __construct()
9
- {
10
- global $wph;
11
- $this->wph = &$wph;
12
- }
13
-
14
- function __destruct()
15
- {
16
-
17
- }
18
-
19
- function get_module_default_setting()
20
- {
21
- $defaults = array (
22
- 'id' => '',
23
- 'visible' => TRUE,
24
- 'label' => '',
25
- 'description' => '',
26
- 'value_description' => '',
27
- 'input_type' => 'text',
28
- 'default_value' => '',
29
- 'sanitize_type' => array('sanitize_title'),
30
-
31
- 'callback' => '',
32
- 'processing_order' => 10,
33
- );
34
-
35
- return $defaults;
36
- }
37
-
38
- function filter_settings($module_settings, $strip_splits = FALSE)
39
- {
40
- if(!is_array($module_settings) || count($module_settings) < 1)
41
- return $module_settings;
42
-
43
- $defaults = $this->get_module_default_setting();
44
-
45
- foreach($module_settings as $key => $module_setting)
46
- {
47
- if(isset($module_setting['type']) && $module_setting['type'] == 'split')
48
- {
49
- if($strip_splits === TRUE)
50
- unset($module_settings[$key]);
51
-
52
- continue;
53
- }
54
-
55
- $module_setting = wp_parse_args( $module_setting, $defaults );
56
-
57
- switch($module_setting['input_type'])
58
- {
59
- case 'text' :
60
- $defaults_type = array (
61
- 'placeholder' => '',
62
- );
63
- $module_setting = wp_parse_args( $module_setting, $defaults_type );
64
-
65
- break;
66
-
67
-
68
- }
69
-
70
- $module_settings[$key] = $module_setting;
71
- }
72
-
73
- $module_settings = array_values($module_settings);
74
-
75
- return $module_settings;
76
-
77
- }
78
-
79
-
80
- function reset_settings()
81
- {
82
-
83
- $nonce = $_POST['_wpnonce'];
84
- if ( ! wp_verify_nonce( $nonce, 'wp-hide-reset-settings' ) )
85
- return FALSE;
86
-
87
- global $wph;
88
-
89
- foreach($wph->modules as $module)
90
- {
91
- //proces the fields
92
- $module_settings = $this->filter_settings( $module->get_module_settings(), TRUE );
93
-
94
- foreach($module_settings as $module_setting)
95
- {
96
- if(isset($module_setting['type']) && $module_setting['type'] == 'split')
97
- continue;
98
-
99
- $field_name = $module_setting['id'];
100
-
101
- $value = isset($module_setting['default_value']) ? $module_setting['default_value'] : '';
102
-
103
- //save the value
104
- $wph->settings['module_settings'][ $field_name ] = $value;
105
- }
106
-
107
- }
108
-
109
- //update the settings
110
- $this->update_settings($wph->settings);
111
-
112
- //trigger the settings changed action
113
- do_action('wph/settings_changed', $screen_slug, $tab_slug);
114
-
115
- //redirect
116
- $new_admin_url = $this->get_module_item_setting('admin_url' , 'admin');
117
- if(!empty($new_admin_url) && $this->is_permalink_enabled())
118
- $new_location = trailingslashit( site_url() ) . $new_admin_url . "/admin.php?page=wp-hide";
119
- else
120
- $new_location = trailingslashit( site_url() ) . "wp-admin/admin.php?page=wp-hide";
121
-
122
- $new_location .= '&reset_settings=true';
123
-
124
- wp_redirect($new_location);
125
- die();
126
-
127
- }
128
-
129
- function process_interface_save()
130
- {
131
- $nonce = $_POST['wph-interface-nonce'];
132
- if ( ! wp_verify_nonce( $nonce, 'wph/interface_fields' ) )
133
- return FALSE;
134
-
135
- $screen_slug = $_GET['page'];
136
- if(empty($screen_slug))
137
- return FALSE;
138
-
139
- $tab_slug = isset($_GET['component']) ? $_GET['component'] : FALSE;
140
-
141
- $module = $this->get_module_by_slug($screen_slug);
142
- if(!is_object($module))
143
- return FALSE;
144
-
145
- //if no tag slug check if module use tabs and use the very first one
146
- if(empty($tab_slug) && $module->use_tabs === TRUE)
147
- {
148
- //get the first component
149
- foreach($module->components as $module_component)
150
- {
151
- if( ! $module_component->title)
152
- continue;
153
-
154
- $tab_slug = $module_component->id;
155
- break;
156
- }
157
-
158
- }
159
-
160
- global $wph;
161
-
162
- //proces the fields
163
- $module_settings = $this->filter_settings( $module->get_module_settings($tab_slug) );
164
-
165
- foreach($module_settings as $module_setting)
166
- {
167
- if(isset($module_setting['type']) && $module_setting['type'] == 'split')
168
- continue;
169
-
170
- $field_name = $module_setting['id'];
171
-
172
- $value = isset($_POST[$field_name]) ? $_POST[$field_name] : '';
173
-
174
- //if empty use the default
175
- if(empty($value))
176
- $value = $module_setting['default_value'];
177
-
178
- //sanitize value
179
- foreach($module_setting['sanitize_type'] as $sanitize)
180
- {
181
- $value = call_user_func_array($sanitize, array($value));
182
- }
183
-
184
- //save the value
185
- $wph->settings['module_settings'][ $field_name ] = $value;
186
- }
187
-
188
- //update the settings
189
- $this->update_settings($wph->settings);
190
-
191
- //trigger the settings changed action
192
- do_action('wph/settings_changed', $screen_slug, $tab_slug);
193
-
194
- //redirect
195
- $new_admin_url = $this->get_module_item_setting('admin_url' , 'admin');
196
- if(!empty($new_admin_url) && $this->is_permalink_enabled())
197
- $new_location = trailingslashit( site_url() ) . $new_admin_url . "/admin.php?page=" . $screen_slug;
198
- else
199
- $new_location = trailingslashit( site_url() ) . "wp-admin/admin.php?page=" . $screen_slug;
200
-
201
- if($tab_slug !== FALSE)
202
- $new_location .= '&component=' . $tab_slug;
203
-
204
- $new_location .= '&settings_updated=true';
205
-
206
- wp_redirect($new_location);
207
- die();
208
- }
209
-
210
-
211
- function settings_changed_check_for_cache_plugins()
212
- {
213
-
214
- $active_plugins = (array) get_option( 'active_plugins', array() );
215
-
216
- //cache plugin nottice
217
- if(array_search('w3-total-cache/w3-total-cache.php', $active_plugins) !== FALSE)
218
- {
219
- //check if just flushed
220
- if(!isset($_GET['w3tc_note']))
221
- echo "<div class='error'><p>". __('W3 Total Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide-security-enhancer') ."</p></div>";
222
- }
223
- if(array_search('wp-super-cache/wp-cache.php', $active_plugins) !== FALSE)
224
- {
225
- echo "<div class='error'><p>". __('WP Super Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide-security-enhancer') ."</p></div>";
226
- }
227
-
228
- }
229
-
230
-
231
- /**
232
- * Return the module class by it's slug
233
- *
234
- * @param mixed $module_slug
235
- */
236
- function get_module_by_slug($module_slug)
237
- {
238
- global $wph;
239
-
240
- $found_module = FALSE;
241
-
242
- foreach($wph->modules as $module)
243
- {
244
- $interface_menu_data = $module->get_module_slug();
245
-
246
- if($interface_menu_data == $module_slug)
247
- {
248
- $found_module = $module;
249
- break;
250
- }
251
- }
252
-
253
- return $found_module;
254
- }
255
-
256
- /**
257
- * Used on early access when WP_Rewrite is not available
258
- *
259
- */
260
- function is_permalink_enabled()
261
- {
262
-
263
- $permalink_structure = get_option('permalink_structure');
264
-
265
- if ( empty($permalink_structure) )
266
- return FALSE;
267
-
268
- return TRUE;
269
-
270
- }
271
-
272
-
273
-
274
- /**
275
- * return the server home path
276
- *
277
- */
278
- function get_home_path()
279
- {
280
-
281
- $home = set_url_scheme( get_option( 'home' ), 'http' );
282
- $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
283
- if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) )
284
- {
285
- $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
286
- $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
287
- $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
288
- $home_path = trailingslashit( $home_path );
289
- }
290
- else
291
- {
292
- $home_path = ABSPATH;
293
- }
294
-
295
- $home_path = str_replace( '\\', '/', $home_path );
296
-
297
- return $home_path;
298
-
299
- }
300
-
301
-
302
- /**
303
- * return whatever server using the .htaccess config file
304
- *
305
- */
306
- function server_use_htaccess_config_file()
307
- {
308
- $home_path = $this->get_home_path();
309
-
310
- $htaccess_file = $home_path.'.htaccess';
311
- if ($this->apache_mod_loaded('mod_rewrite', true))
312
- return TRUE;
313
-
314
- return FALSE;
315
-
316
- }
317
-
318
-
319
- /**
320
- * Does the specified module exist in the Apache config?
321
- *
322
- * @since 2.5.0
323
- *
324
- * @global bool $is_apache
325
- *
326
- * @param string $mod The module, e.g. mod_rewrite.
327
- * @param bool $default Optional. The default return value if the module is not found. Default false.
328
- * @return bool Whether the specified module is loaded.
329
- */
330
- function apache_mod_loaded($mod, $default = false)
331
- {
332
-
333
- if ( function_exists( 'apache_get_modules' ) )
334
- {
335
- $mods = apache_get_modules();
336
- if ( in_array($mod, $mods) )
337
- return true;
338
- }
339
- elseif (getenv('HTTP_MOD_REWRITE') !== FALSE)
340
- {
341
- $mod_found = getenv('HTTP_MOD_REWRITE') == 'On' ? true : false ;
342
- return $mod_found;
343
- }
344
- elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
345
- ob_start();
346
- phpinfo(8);
347
- $phpinfo = ob_get_clean();
348
- if ( false !== strpos($phpinfo, $mod) )
349
- return true;
350
-
351
- }
352
-
353
- return $default;
354
-
355
- }
356
-
357
-
358
- /**
359
- * return whatever the htaccess config file is writable
360
- *
361
- */
362
- function is_writable_htaccess_config_file()
363
- {
364
- $home_path = $this->get_home_path();
365
-
366
- $htaccess_file = $home_path.'.htaccess';
367
-
368
- if ((!file_exists($htaccess_file) && is_writable($home_path) && $this->is_permalink_enabled()) || is_writable($htaccess_file))
369
- return TRUE;
370
-
371
- return FALSE;
372
-
373
- }
374
-
375
- /**
376
- * return whatever server using the .htaccess config file
377
- *
378
- */
379
- function server_use_web_config_file()
380
- {
381
- $home_path = $this->get_home_path();
382
-
383
- $web_config_file = $home_path . 'web.config';
384
-
385
- if ( iis7_supports_permalinks() )
386
- return TRUE;
387
-
388
- return FALSE;
389
-
390
- }
391
-
392
-
393
- /**
394
- * return whatever the web.config config file is writable
395
- *
396
- */
397
- function is_writable_web_config_file()
398
- {
399
- $home_path = $this->get_home_path();
400
-
401
- $web_config_file = $home_path . 'web.config';
402
-
403
- if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $this->is_permalink_enabled() ) || win_is_writable($web_config_file) )
404
- return TRUE;
405
-
406
- return FALSE;
407
-
408
- }
409
-
410
-
411
- function get_write_check_string()
412
- {
413
- $home_path = $this->get_home_path();
414
-
415
- global $wp_rewrite;
416
-
417
- $result = FALSE;
418
-
419
- //check for .htaccess
420
- if ( $this->server_use_htaccess_config_file() && file_exists($home_path . '.htaccess'))
421
- {
422
-
423
- if ( $markerdata = explode( "\n", implode( '', file( $home_path . '.htaccess' ) ) ));
424
- {
425
- foreach ( $markerdata as $markerline )
426
- {
427
- if (strpos($markerline, '#WriteCheckString:') !== false)
428
- {
429
- $result = trim(str_replace( '#WriteCheckString:', '', $markerline));
430
- break;
431
- }
432
- }
433
- }
434
- }
435
-
436
- //check for web.config
437
- if ( $this->server_use_web_config_file() && file_exists( $home_path . 'web.config' ))
438
- {
439
- $file_data = file( $home_path . 'web.config' );
440
- if(!empty($file_data))
441
- {
442
- if ( $markerdata = explode( "\n", implode( '', $file_data ) ));
443
- {
444
- foreach ( $markerdata as $markerline )
445
- {
446
- preg_match("'<rule name=\"wph-.*?<!-- WriteCheckString:([0-9_]+) --></rule>'si", $markerline, $matches);
447
- if(isset($matches[1]))
448
- {
449
- $result = $matches[1];
450
- }
451
-
452
- if (!isset($matches[1]) && strpos($markerline, '<!-- WriteCheckString:') !== false)
453
- {
454
- $result = trim(str_ireplace( '<!-- WriteCheckString:', '', $markerline));
455
- $result = trim(str_replace( '-->', '', $result));
456
- $result = trim($result);
457
-
458
- break;
459
- }
460
- }
461
- }
462
-
463
- }
464
-
465
- }
466
-
467
- return $result;
468
-
469
- }
470
-
471
-
472
- function rewrite_rules_applied()
473
- {
474
- $status = TRUE;
475
-
476
- if(isset($this->wph->settings['write_check_string']) && !empty($this->wph->settings['write_check_string']))
477
- {
478
- $_write_check_string = $this->get_write_check_string();
479
- if(empty($_write_check_string) || $_write_check_string != $this->wph->settings['write_check_string'])
480
- $status = FALSE;
481
- }
482
- else
483
- {
484
- //disable, as settings never being saved or came from old version
485
- $status = FALSE;
486
- }
487
-
488
- return $status;
489
- }
490
-
491
-
492
- /**
493
- *
494
- * Check if theme is is customize mode
495
- *
496
- */
497
- function is_theme_customize()
498
- {
499
-
500
- if ( strpos($_SERVER['REQUEST_URI'] ,'customize.php') !== FALSE )
501
- return TRUE;
502
-
503
- if ( isset($_POST['wp_customize']) && $_POST['wp_customize'] == "on" )
504
- return TRUE;
505
-
506
- return FALSE;
507
-
508
- }
509
-
510
-
511
- /**
512
- * return settings
513
- *
514
- */
515
- function get_settings()
516
- {
517
- $settings = get_option('wph_settings');
518
-
519
- $defaults = array (
520
- 'module_settings' => array(),
521
- 'recovery_code' => ''
522
- );
523
-
524
- $settings = wp_parse_args( $settings, $defaults );
525
-
526
- return $settings;
527
-
528
- }
529
-
530
-
531
-
532
- /**
533
- * Return a Module Item value setting
534
- *
535
- * @param mixed $item_id
536
- */
537
- function get_module_item_setting($item_id)
538
- {
539
-
540
- $settings = $this->get_settings();
541
-
542
- $value = isset($settings['module_settings'][ $item_id ]) ? $settings['module_settings'][ $item_id] : '';
543
-
544
- $value = apply_filters('wp-hide/get_module_item_setting', $value, $item_id);
545
-
546
- return $value;
547
-
548
- }
549
-
550
-
551
- /**
552
- * Save the settings
553
- *
554
- * @param mixed $settings
555
- */
556
- function update_settings($settings)
557
- {
558
- update_option('wph_settings', $settings);
559
- }
560
-
561
-
562
- function get_url_path($url, $is_file_path = FALSE)
563
- {
564
- if(!$is_file_path)
565
- $url = trailingslashit( $url );
566
-
567
- $url_parse = parse_url( $url );
568
-
569
- /*
570
- $root = isset($url_parse['scheme']) ? $url_parse['scheme'] . '://' : '';
571
- $root .= isset($url_parse['host']) ? $url_parse['host'] : '';
572
- */
573
-
574
- $path = $url_parse['path'];
575
-
576
- if(!$is_file_path)
577
- $path = trailingslashit( $path );
578
-
579
- if($path != '/' && strlen($path) > 1)
580
- {
581
- $path = ltrim($path, '/');
582
- $path = '/' . $path;
583
- }
584
-
585
- if(isset($url_parse['query']))
586
- $path .= '?' . $url_parse['query'];
587
-
588
- return $path;
589
-
590
- }
591
-
592
-
593
- /**
594
- * return the url relative to domain root
595
- *
596
- * @param mixed $url
597
- */
598
- function get_url_path_relative_to_domain_root($url)
599
- {
600
-
601
- $url = str_replace(trailingslashit( site_url() ), "" , $url);
602
-
603
- return $url;
604
-
605
- }
606
-
607
-
608
-
609
- function untrailingslashit_all($value)
610
- {
611
- $value = ltrim(rtrim($value, "/"), "/");
612
-
613
- return $value;
614
- }
615
-
616
- function sanitize_file_path_name($value)
617
- {
618
- $value = trim($value);
619
-
620
- if(empty($value))
621
- return $value;
622
-
623
- $parts = explode("/", $value);
624
- $parts = array_filter($parts);
625
-
626
- foreach($parts as $key => $part_item)
627
- {
628
- $parts[$key] = sanitize_file_name($part_item);
629
- }
630
-
631
- $value = implode("/", $parts);
632
-
633
- $value = strtolower($value);
634
-
635
- return $value;
636
- }
637
-
638
- function php_extension_required($value)
639
- {
640
- $value = trim($value);
641
-
642
- if($value == '')
643
- return '';
644
-
645
- $extension = substr($value, -4);
646
- if(strtolower($extension) != '.php')
647
- $value .= '.php';
648
-
649
- return $value;
650
- }
651
-
652
-
653
- function get_current_url()
654
- {
655
-
656
- $current_url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
657
-
658
- return $current_url;
659
-
660
- }
661
-
662
-
663
- function text_urls_replacement($text, $replacements)
664
- {
665
- //process the replacements
666
- if( count($replacements) < 1)
667
- return $text;
668
-
669
- //exclude scheme to match urls without it
670
- $_replacements = array();
671
- foreach($replacements as $old_url => $new_url)
672
- {
673
- $old_url = str_ireplace( array('http://', 'https://'), "", $old_url);
674
- $new_url = str_ireplace( array('http://', 'https://'), "", $new_url);
675
-
676
- $_replacements[$old_url] = $new_url;
677
- }
678
-
679
- $replacements = $_replacements;
680
- unset($_replacements);
681
-
682
- $text = str_ireplace( array_keys($replacements), array_values($replacements) ,$text );
683
-
684
- //check for json encode
685
- foreach($replacements as $old_url => $new_url)
686
- {
687
- $old_url = trim(json_encode($old_url), '"');
688
- $new_url = trim(json_encode($new_url), '"');
689
-
690
- $text = str_ireplace( $old_url, $new_url ,$text );
691
- }
692
-
693
- return $text;
694
- }
695
-
696
-
697
- function default_scripts_styles_replace($object, $replacements)
698
- {
699
- //update default dirs
700
- if(isset($object->default_dirs))
701
- {
702
- foreach($object->default_dirs as $key => $value)
703
- {
704
- $object->default_dirs[$key] = str_replace(array_keys($replacements), array_values($replacements), $value);
705
- }
706
- }
707
-
708
- foreach($object->registered as $script_name => $script_data)
709
- {
710
- $script_data->src = str_replace(array_keys($replacements), array_values($replacements), $script_data->src);
711
-
712
- $object->registered[$script_name] = $script_data;
713
- }
714
-
715
- return $object;
716
- }
717
-
718
-
719
- function check_headers_content_type($header_name, $header_value)
720
- {
721
-
722
- $headers = headers_list();
723
-
724
- foreach($headers as $header)
725
- {
726
- if(stripos($header, $header_name) !== FALSE)
727
- {
728
- if(stripos($header, $header_value) !== FALSE)
729
- return TRUE;
730
- }
731
- }
732
-
733
-
734
- return FALSE;
735
-
736
- }
737
-
738
- function is_other_template($template)
739
- {
740
-
741
- if($this->wph->templates_data['use_child_theme'] === TRUE)
742
- {
743
- if($this->wph->templates_data['child']['folder_name'] == $template)
744
- return FALSE;
745
- }
746
- else
747
- {
748
- if($this->wph->templates_data['main']['folder_name'] == $template)
749
- return FALSE;
750
-
751
- }
752
-
753
- return TRUE;
754
- }
755
-
756
-
757
- function array_sort_by_processing_order($a, $b)
758
- {
759
- return $a['processing_order'] - $b['processing_order'];
760
- }
761
-
762
-
763
-
764
- /**
765
- * Return the recovey code
766
- *
767
- */
768
- function get_recovery_code()
769
- {
770
-
771
- $settings = $this->get_settings();
772
- if(!isset($settings['recovery_code']) || empty($settings['recovery_code']))
773
- {
774
- $recovery_code = $this->generate_recovery_code();
775
- }
776
- else
777
- $recovery_code = $settings['recovery_code'];
778
-
779
-
780
- return $recovery_code;
781
- }
782
-
783
-
784
- /**
785
- * Generate a recovery code
786
- *
787
- */
788
- function generate_recovery_code()
789
- {
790
-
791
- $settings = $this->get_settings();
792
-
793
- $recovery_code = md5(rand(1,9999) . microtime());
794
-
795
- $settings['recovery_code'] = $recovery_code;
796
-
797
- $this->update_settings($settings);
798
-
799
- return $recovery_code;
800
- }
801
-
802
-
803
- /**
804
- * Trigger the recovery actions
805
- *
806
- */
807
- function do_recovery()
808
- {
809
- //feetch a new set of settings
810
- $settings = $this->get_settings();
811
-
812
- $wph_recovery = isset($_GET['wph-recovery']) ? $_GET['wph-recovery'] : '';
813
- if(empty($wph_recovery) || $wph_recovery != $this->wph->settings['recovery_code'])
814
- return;
815
-
816
- //change certain settings to default
817
- $this->wph->settings['module_settings']['new_wp_login_php'] = '';
818
- $this->wph->settings['module_settings']['admin_url'] = '';
819
-
820
- //update the settings
821
- $this->update_settings($this->wph->settings);
822
-
823
- //available for mu-plugins
824
- do_action('wph/do_recovery');
825
-
826
-
827
- //add filter for rewriting the rules
828
- add_action('wp_loaded', array($this, 'wp_loaded_trigger_do_recovery'));
829
-
830
- }
831
-
832
- function wp_loaded_trigger_do_recovery()
833
- {
834
- /** WordPress Misc Administration API */
835
- require_once(ABSPATH . 'wp-admin/includes/misc.php');
836
-
837
- /** WordPress Administration File API */
838
- require_once(ABSPATH . 'wp-admin/includes/file.php');
839
-
840
- flush_rewrite_rules();
841
-
842
- //redirect to homepage
843
- wp_redirect(get_site_url());
844
-
845
- die();
846
- }
847
-
848
-
849
-
850
- function anonymous_object_filter_exists($tag, $class, $method)
851
- {
852
- if ( ! isset( $GLOBALS['wp_filter'][$tag] ) )
853
- return FALSE;
854
-
855
- $filters = $GLOBALS['wp_filter'][$tag];
856
-
857
- if ( ! $filters )
858
- return FALSE;
859
-
860
- foreach ( $filters as $priority => $filter )
861
- {
862
- foreach ( $filter as $identifier => $function )
863
- {
864
- if ( ! is_array( $function ) )
865
- continue;
866
-
867
- if ( ! $function['function'][0] instanceof $class )
868
- continue;
869
-
870
- if ( $method == $function['function'][1] )
871
- {
872
- return TRUE;
873
- }
874
- }
875
- }
876
-
877
- return FALSE;
878
- }
879
-
880
- function remove_anonymous_object_filter( $tag, $class, $method )
881
- {
882
- $filters = false;
883
-
884
- if ( isset( $GLOBALS['wp_filter'][$tag] ) )
885
- $filters = $GLOBALS['wp_filter'][$tag];
886
-
887
- if ( $filters )
888
- foreach ( $filters as $priority => $filter )
889
- {
890
- foreach ( $filter as $identifier => $function )
891
- {
892
- if ( ! is_array( $function ) )
893
- continue;
894
-
895
- if ( ! $function['function'][0] instanceof $class )
896
- continue;
897
-
898
- if ( $method == $function['function'][1] )
899
- {
900
- remove_filter($tag, array( $function['function'][0], $method ), $priority);
901
- }
902
- }
903
- }
904
- }
905
-
906
-
907
- /**
908
- * An early instance of WordPress wp_mail core
909
- * Unable to load pluggable.php where the function exists, as bein loaded using require
910
- *
911
- * @param mixed $to
912
- * @param mixed $subject
913
- * @param mixed $message
914
- * @param mixed $headers
915
- * @param mixed $attachments
916
- */
917
- function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
918
- {
919
- // Compact the input, apply the filters, and extract them back out
920
-
921
- /**
922
- * Filter the wp_mail() arguments.
923
- *
924
- * @since 2.2.0
925
- *
926
- * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
927
- * subject, message, headers, and attachments values.
928
- */
929
- $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
930
-
931
- if ( isset( $atts['to'] ) ) {
932
- $to = $atts['to'];
933
- }
934
-
935
- if ( isset( $atts['subject'] ) ) {
936
- $subject = $atts['subject'];
937
- }
938
-
939
- if ( isset( $atts['message'] ) ) {
940
- $message = $atts['message'];
941
- }
942
-
943
- if ( isset( $atts['headers'] ) ) {
944
- $headers = $atts['headers'];
945
- }
946
-
947
- if ( isset( $atts['attachments'] ) ) {
948
- $attachments = $atts['attachments'];
949
- }
950
-
951
- if ( ! is_array( $attachments ) ) {
952
- $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
953
- }
954
- global $phpmailer;
955
-
956
- // (Re)create it, if it's gone missing
957
- if ( ! ( $phpmailer instanceof PHPMailer ) ) {
958
- require_once ABSPATH . WPINC . '/class-phpmailer.php';
959
- require_once ABSPATH . WPINC . '/class-smtp.php';
960
- $phpmailer = new PHPMailer( true );
961
- }
962
-
963
- // Headers
964
- if ( empty( $headers ) ) {
965
- $headers = array();
966
- } else {
967
- if ( !is_array( $headers ) ) {
968
- // Explode the headers out, so this function can take both
969
- // string headers and an array of headers.
970
- $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
971
- } else {
972
- $tempheaders = $headers;
973
- }
974
- $headers = array();
975
- $cc = array();
976
- $bcc = array();
977
-
978
- // If it's actually got contents
979
- if ( !empty( $tempheaders ) ) {
980
- // Iterate through the raw headers
981
- foreach ( (array) $tempheaders as $header ) {
982
- if ( strpos($header, ':') === false ) {
983
- if ( false !== stripos( $header, 'boundary=' ) ) {
984
- $parts = preg_split('/boundary=/i', trim( $header ) );
985
- $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
986
- }
987
- continue;
988
- }
989
- // Explode them out
990
- list( $name, $content ) = explode( ':', trim( $header ), 2 );
991
-
992
- // Cleanup crew
993
- $name = trim( $name );
994
- $content = trim( $content );
995
-
996
- switch ( strtolower( $name ) ) {
997
- // Mainly for legacy -- process a From: header if it's there
998
- case 'from':
999
- $bracket_pos = strpos( $content, '<' );
1000
- if ( $bracket_pos !== false ) {
1001
- // Text before the bracketed email is the "From" name.
1002
- if ( $bracket_pos > 0 ) {
1003
- $from_name = substr( $content, 0, $bracket_pos - 1 );
1004
- $from_name = str_replace( '"', '', $from_name );
1005
- $from_name = trim( $from_name );
1006
- }
1007
-
1008
- $from_email = substr( $content, $bracket_pos + 1 );
1009
- $from_email = str_replace( '>', '', $from_email );
1010
- $from_email = trim( $from_email );
1011
-
1012
- // Avoid setting an empty $from_email.
1013
- } elseif ( '' !== trim( $content ) ) {
1014
- $from_email = trim( $content );
1015
- }
1016
- break;
1017
- case 'content-type':
1018
- if ( strpos( $content, ';' ) !== false ) {
1019
- list( $type, $charset_content ) = explode( ';', $content );
1020
- $content_type = trim( $type );
1021
- if ( false !== stripos( $charset_content, 'charset=' ) ) {
1022
- $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) );
1023
- } elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
1024
- $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
1025
- $charset = '';
1026
- }
1027
-
1028
- // Avoid setting an empty $content_type.
1029
- } elseif ( '' !== trim( $content ) ) {
1030
- $content_type = trim( $content );
1031
- }
1032
- break;
1033
- case 'cc':
1034
- $cc = array_merge( (array) $cc, explode( ',', $content ) );
1035
- break;
1036
- case 'bcc':
1037
- $bcc = array_merge( (array) $bcc, explode( ',', $content ) );
1038
- break;
1039
- default:
1040
- // Add it to our grand headers array
1041
- $headers[trim( $name )] = trim( $content );
1042
- break;
1043
- }
1044
- }
1045
- }
1046
- }
1047
-
1048
- // Empty out the values that may be set
1049
- $phpmailer->ClearAllRecipients();
1050
- $phpmailer->ClearAttachments();
1051
- $phpmailer->ClearCustomHeaders();
1052
- $phpmailer->ClearReplyTos();
1053
-
1054
- // From email and name
1055
- // If we don't have a name from the input headers
1056
- if ( !isset( $from_name ) )
1057
- $from_name = 'WordPress';
1058
-
1059
- /* If we don't have an email from the input headers default to wordpress@$sitename
1060
- * Some hosts will block outgoing mail from this address if it doesn't exist but
1061
- * there's no easy alternative. Defaulting to admin_email might appear to be another
1062
- * option but some hosts may refuse to relay mail from an unknown domain. See
1063
- * https://core.trac.wordpress.org/ticket/5007.
1064
- */
1065
-
1066
- if ( !isset( $from_email ) ) {
1067
- // Get the site domain and get rid of www.
1068
- $sitename = strtolower( $_SERVER['SERVER_NAME'] );
1069
- if ( substr( $sitename, 0, 4 ) == 'www.' ) {
1070
- $sitename = substr( $sitename, 4 );
1071
- }
1072
-
1073
- $from_email = 'wordpress@' . $sitename;
1074
- }
1075
-
1076
- /**
1077
- * Filter the email address to send from.
1078
- *
1079
- * @since 2.2.0
1080
- *
1081
- * @param string $from_email Email address to send from.
1082
- */
1083
- $phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
1084
-
1085
- /**
1086
- * Filter the name to associate with the "from" email address.
1087
- *
1088
- * @since 2.3.0
1089
- *
1090
- * @param string $from_name Name associated with the "from" email address.
1091
- */
1092
- $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
1093
-
1094
- // Set destination addresses
1095
- if ( !is_array( $to ) )
1096
- $to = explode( ',', $to );
1097
-
1098
- foreach ( (array) $to as $recipient ) {
1099
- try {
1100
- // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1101
- $recipient_name = '';
1102
- if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1103
- if ( count( $matches ) == 3 ) {
1104
- $recipient_name = $matches[1];
1105
- $recipient = $matches[2];
1106
- }
1107
- }
1108
- $phpmailer->AddAddress( $recipient, $recipient_name);
1109
- } catch ( phpmailerException $e ) {
1110
- continue;
1111
- }
1112
- }
1113
-
1114
- // Set mail's subject and body
1115
- $phpmailer->Subject = $subject;
1116
- $phpmailer->Body = $message;
1117
-
1118
- // Add any CC and BCC recipients
1119
- if ( !empty( $cc ) ) {
1120
- foreach ( (array) $cc as $recipient ) {
1121
- try {
1122
- // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1123
- $recipient_name = '';
1124
- if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1125
- if ( count( $matches ) == 3 ) {
1126
- $recipient_name = $matches[1];
1127
- $recipient = $matches[2];
1128
- }
1129
- }
1130
- $phpmailer->AddCc( $recipient, $recipient_name );
1131
- } catch ( phpmailerException $e ) {
1132
- continue;
1133
- }
1134
- }
1135
- }
1136
-
1137
- if ( !empty( $bcc ) ) {
1138
- foreach ( (array) $bcc as $recipient) {
1139
- try {
1140
- // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1141
- $recipient_name = '';
1142
- if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1143
- if ( count( $matches ) == 3 ) {
1144
- $recipient_name = $matches[1];
1145
- $recipient = $matches[2];
1146
- }
1147
- }
1148
- $phpmailer->AddBcc( $recipient, $recipient_name );
1149
- } catch ( phpmailerException $e ) {
1150
- continue;
1151
- }
1152
- }
1153
- }
1154
-
1155
- // Set to use PHP's mail()
1156
- $phpmailer->IsMail();
1157
-
1158
- // Set Content-Type and charset
1159
- // If we don't have a content-type from the input headers
1160
- if ( !isset( $content_type ) )
1161
- $content_type = 'text/plain';
1162
-
1163
- /**
1164
- * Filter the wp_mail() content type.
1165
- *
1166
- * @since 2.3.0
1167
- *
1168
- * @param string $content_type Default wp_mail() content type.
1169
- */
1170
- $content_type = apply_filters( 'wp_mail_content_type', $content_type );
1171
-
1172
- $phpmailer->ContentType = $content_type;
1173
-
1174
- // Set whether it's plaintext, depending on $content_type
1175
- if ( 'text/html' == $content_type )
1176
- $phpmailer->IsHTML( true );
1177
-
1178
- // If we don't have a charset from the input headers
1179
- if ( !isset( $charset ) )
1180
- $charset = get_bloginfo( 'charset' );
1181
-
1182
- // Set the content-type and charset
1183
-
1184
- /**
1185
- * Filter the default wp_mail() charset.
1186
- *
1187
- * @since 2.3.0
1188
- *
1189
- * @param string $charset Default email charset.
1190
- */
1191
- $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
1192
-
1193
- // Set custom headers
1194
- if ( !empty( $headers ) ) {
1195
- foreach ( (array) $headers as $name => $content ) {
1196
- $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
1197
- }
1198
-
1199
- if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
1200
- $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
1201
- }
1202
-
1203
- if ( !empty( $attachments ) ) {
1204
- foreach ( $attachments as $attachment ) {
1205
- try {
1206
- $phpmailer->AddAttachment($attachment);
1207
- } catch ( phpmailerException $e ) {
1208
- continue;
1209
- }
1210
- }
1211
- }
1212
-
1213
- /**
1214
- * Fires after PHPMailer is initialized.
1215
- *
1216
- * @since 2.2.0
1217
- *
1218
- * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
1219
- */
1220
- do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
1221
-
1222
- // Send!
1223
- try {
1224
- return $phpmailer->Send();
1225
- } catch ( phpmailerException $e ) {
1226
-
1227
- $mail_error_data = compact( $to, $subject, $message, $headers, $attachments );
1228
-
1229
- /**
1230
- * Fires after a phpmailerException is caught.
1231
- *
1232
- * @since 4.4.0
1233
- *
1234
- * @param WP_Error $error A WP_Error object with the phpmailerException code, message, and an array
1235
- * containing the mail recipient, subject, message, headers, and attachments.
1236
- */
1237
- do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
1238
-
1239
- return false;
1240
- }
1241
- }
1242
-
1243
-
1244
- /**
1245
- * Check the plugins directory and retrieve all plugin files with plugin data.
1246
- *
1247
- * WordPress only supports plugin files in the base plugins directory
1248
- * (wp-content/plugins) and in one directory above the plugins directory
1249
- * (wp-content/plugins/my-plugin). The file it looks for has the plugin data
1250
- * and must be found in those two locations. It is recommended to keep your
1251
- * plugin files in their own directories.
1252
- *
1253
- * The file with the plugin data is the file that will be included and therefore
1254
- * needs to have the main execution for the plugin. This does not mean
1255
- * everything must be contained in the file and it is recommended that the file
1256
- * be split for maintainability. Keep everything in one file for extreme
1257
- * optimization purposes.
1258
- *
1259
- * @since 1.5.0
1260
- *
1261
- * @param string $plugin_folder Optional. Relative path to single plugin folder.
1262
- * @return array Key is the plugin file path and the value is an array of the plugin data.
1263
- */
1264
- function get_plugins($plugin_folder = '')
1265
- {
1266
-
1267
- $wp_plugins = array ();
1268
- $plugin_root = WP_PLUGIN_DIR;
1269
- if ( !empty($plugin_folder) )
1270
- $plugin_root .= $plugin_folder;
1271
-
1272
- // Files in wp-content/plugins directory
1273
- $plugins_dir = @ opendir( $plugin_root);
1274
- $plugin_files = array();
1275
- if ( $plugins_dir ) {
1276
- while (($file = readdir( $plugins_dir ) ) !== false ) {
1277
- if ( substr($file, 0, 1) == '.' )
1278
- continue;
1279
- if ( is_dir( $plugin_root.'/'.$file ) ) {
1280
- $plugins_subdir = @ opendir( $plugin_root.'/'.$file );
1281
- if ( $plugins_subdir ) {
1282
- while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
1283
- if ( substr($subfile, 0, 1) == '.' )
1284
- continue;
1285
- if ( substr($subfile, -4) == '.php' )
1286
- $plugin_files[] = "$file/$subfile";
1287
- }
1288
- closedir( $plugins_subdir );
1289
- }
1290
- } else {
1291
- if ( substr($file, -4) == '.php' )
1292
- $plugin_files[] = $file;
1293
- }
1294
- }
1295
- closedir( $plugins_dir );
1296
- }
1297
-
1298
- if ( empty($plugin_files) )
1299
- return $wp_plugins;
1300
-
1301
- foreach ( $plugin_files as $plugin_file ) {
1302
- if ( !is_readable( "$plugin_root/$plugin_file" ) )
1303
- continue;
1304
-
1305
- $plugin_data = $this->get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
1306
-
1307
- if ( empty ( $plugin_data['Name'] ) )
1308
- continue;
1309
-
1310
- $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
1311
- }
1312
-
1313
- return $wp_plugins;
1314
- }
1315
-
1316
-
1317
- function get_plugin_data( $plugin_file, $markup = true, $translate = true )
1318
- {
1319
-
1320
- $default_headers = array(
1321
- 'Name' => 'Plugin Name',
1322
- 'PluginURI' => 'Plugin URI',
1323
- 'Version' => 'Version',
1324
- 'Description' => 'Description',
1325
- 'Author' => 'Author',
1326
- 'AuthorURI' => 'Author URI',
1327
- 'TextDomain' => 'Text Domain',
1328
- 'DomainPath' => 'Domain Path',
1329
- 'Network' => 'Network',
1330
- // Site Wide Only is deprecated in favor of Network.
1331
- '_sitewide' => 'Site Wide Only',
1332
- );
1333
-
1334
- $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
1335
-
1336
- // Site Wide Only is the old header for Network
1337
- if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
1338
- /* translators: 1: Site Wide Only: true, 2: Network: true */
1339
- _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
1340
- $plugin_data['Network'] = $plugin_data['_sitewide'];
1341
- }
1342
- $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
1343
- unset( $plugin_data['_sitewide'] );
1344
-
1345
- if ( $markup || $translate ) {
1346
- $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
1347
- } else {
1348
- $plugin_data['Title'] = $plugin_data['Name'];
1349
- $plugin_data['AuthorName'] = $plugin_data['Author'];
1350
- }
1351
-
1352
- return $plugin_data;
1353
- }
1354
-
1355
-
1356
- /**
1357
- * Alternative when apache_response_headers() not available
1358
- *
1359
- */
1360
- function parseRequestHeaders()
1361
- {
1362
- $headers = array();
1363
- foreach($_SERVER as $key => $value)
1364
- {
1365
- if (substr($key, 0, 5) <> 'HTTP_')
1366
- continue;
1367
-
1368
- $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
1369
- $headers[$header] = $value;
1370
- }
1371
-
1372
- return $headers;
1373
- }
1374
-
1375
-
1376
- }
1377
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1378
  ?>
1
+ <?php
2
+
3
+
4
+ class WPH_functions
5
+ {
6
+ var $wph;
7
+
8
+ function __construct()
9
+ {
10
+ global $wph;
11
+ $this->wph = &$wph;
12
+ }
13
+
14
+ function __destruct()
15
+ {
16
+
17
+ }
18
+
19
+ function get_module_default_setting()
20
+ {
21
+ $defaults = array (
22
+ 'id' => '',
23
+ 'visible' => TRUE,
24
+ 'label' => '',
25
+ 'description' => '',
26
+ 'value_description' => '',
27
+ 'input_type' => 'text',
28
+ 'default_value' => '',
29
+ 'sanitize_type' => array('sanitize_title'),
30
+
31
+ 'callback' => '',
32
+ 'processing_order' => 10,
33
+ );
34
+
35
+ return $defaults;
36
+ }
37
+
38
+ function filter_settings($module_settings, $strip_splits = FALSE)
39
+ {
40
+ if(!is_array($module_settings) || count($module_settings) < 1)
41
+ return $module_settings;
42
+
43
+ $defaults = $this->get_module_default_setting();
44
+
45
+ foreach($module_settings as $key => $module_setting)
46
+ {
47
+ if(isset($module_setting['type']) && $module_setting['type'] == 'split')
48
+ {
49
+ if($strip_splits === TRUE)
50
+ unset($module_settings[$key]);
51
+
52
+ continue;
53
+ }
54
+
55
+ $module_setting = wp_parse_args( $module_setting, $defaults );
56
+
57
+ switch($module_setting['input_type'])
58
+ {
59
+ case 'text' :
60
+ $defaults_type = array (
61
+ 'placeholder' => '',
62
+ );
63
+ $module_setting = wp_parse_args( $module_setting, $defaults_type );
64
+
65
+ break;
66
+
67
+
68
+ }
69
+
70
+ $module_settings[$key] = $module_setting;
71
+ }
72
+
73
+ $module_settings = array_values($module_settings);
74
+
75
+ return $module_settings;
76
+
77
+ }
78
+
79
+
80
+ function reset_settings()
81
+ {
82
+
83
+ $nonce = $_POST['_wpnonce'];
84
+ if ( ! wp_verify_nonce( $nonce, 'wp-hide-reset-settings' ) )
85
+ return FALSE;
86
+
87
+ global $wph;
88
+
89
+ foreach($wph->modules as $module)
90
+ {
91
+ //proces the fields
92
+ $module_settings = $this->filter_settings( $module->get_module_settings(), TRUE );
93
+
94
+ foreach($module_settings as $module_setting)
95
+ {
96
+ if(isset($module_setting['type']) && $module_setting['type'] == 'split')
97
+ continue;
98
+
99
+ $field_name = $module_setting['id'];
100
+
101
+ $value = isset($module_setting['default_value']) ? $module_setting['default_value'] : '';
102
+
103
+ //save the value
104
+ $wph->settings['module_settings'][ $field_name ] = $value;
105
+ }
106
+
107
+ }
108
+
109
+ //update the settings
110
+ $this->update_settings($wph->settings);
111
+
112
+ //trigger the settings changed action
113
+ do_action('wph/settings_changed', $screen_slug, $tab_slug);
114
+
115
+ //redirect
116
+ $new_admin_url = $this->get_module_item_setting('admin_url' , 'admin');
117
+ if(!empty($new_admin_url) && $this->is_permalink_enabled())
118
+ $new_location = trailingslashit( site_url() ) . $new_admin_url . "/admin.php?page=wp-hide";
119
+ else
120
+ $new_location = trailingslashit( site_url() ) . "wp-admin/admin.php?page=wp-hide";
121
+
122
+ $new_location .= '&reset_settings=true';
123
+
124
+ wp_redirect($new_location);
125
+ die();
126
+
127
+ }
128
+
129
+ function process_interface_save()
130
+ {
131
+ $nonce = $_POST['wph-interface-nonce'];
132
+ if ( ! wp_verify_nonce( $nonce, 'wph/interface_fields' ) )
133
+ return FALSE;
134
+
135
+ $screen_slug = $_GET['page'];
136
+ if(empty($screen_slug))
137
+ return FALSE;
138
+
139
+ $tab_slug = isset($_GET['component']) ? $_GET['component'] : FALSE;
140
+
141
+ $module = $this->get_module_by_slug($screen_slug);
142
+ if(!is_object($module))
143
+ return FALSE;
144
+
145
+ //if no tag slug check if module use tabs and use the very first one
146
+ if(empty($tab_slug) && $module->use_tabs === TRUE)
147
+ {
148
+ //get the first component
149
+ foreach($module->components as $module_component)
150
+ {
151
+ if( ! $module_component->title)
152
+ continue;
153
+
154
+ $tab_slug = $module_component->id;
155
+ break;
156
+ }
157
+
158
+ }
159
+
160
+ global $wph;
161
+
162
+ //proces the fields
163
+ $module_settings = $this->filter_settings( $module->get_module_settings($tab_slug) );
164
+
165
+ foreach($module_settings as $module_setting)
166
+ {
167
+ if(isset($module_setting['type']) && $module_setting['type'] == 'split')
168
+ continue;
169
+
170
+ $field_name = $module_setting['id'];
171
+
172
+ $value = isset($_POST[$field_name]) ? $_POST[$field_name] : '';
173
+
174
+ //if empty use the default
175
+ if(empty($value))
176
+ $value = $module_setting['default_value'];
177
+
178
+ //sanitize value
179
+ foreach($module_setting['sanitize_type'] as $sanitize)
180
+ {
181
+ $value = call_user_func_array($sanitize, array($value));
182
+ }
183
+
184
+ //save the value
185
+ $wph->settings['module_settings'][ $field_name ] = $value;
186
+ }
187
+
188
+ //update the settings
189
+ $this->update_settings($wph->settings);
190
+
191
+ //trigger the settings changed action
192
+ do_action('wph/settings_changed', $screen_slug, $tab_slug);
193
+
194
+ //redirect
195
+ $new_admin_url = $this->get_module_item_setting('admin_url' , 'admin');
196
+ if(!empty($new_admin_url) && $this->is_permalink_enabled())
197
+ $new_location = trailingslashit( site_url() ) . $new_admin_url . "/admin.php?page=" . $screen_slug;
198
+ else
199
+ $new_location = trailingslashit( site_url() ) . "wp-admin/admin.php?page=" . $screen_slug;
200
+
201
+ if($tab_slug !== FALSE)
202
+ $new_location .= '&component=' . $tab_slug;
203
+
204
+ $new_location .= '&settings_updated=true';
205
+
206
+ wp_redirect($new_location);
207
+ die();
208
+ }
209
+
210
+
211
+ function settings_changed_check_for_cache_plugins()
212
+ {
213
+
214
+ $active_plugins = (array) get_option( 'active_plugins', array() );
215
+
216
+ //cache plugin nottice
217
+ if(array_search('w3-total-cache/w3-total-cache.php', $active_plugins) !== FALSE)
218
+ {
219
+ //check if just flushed
220
+ if(!isset($_GET['w3tc_note']))
221
+ echo "<div class='error'><p>". __('W3 Total Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide-security-enhancer') ."</p></div>";
222
+ }
223
+ if(array_search('wp-super-cache/wp-cache.php', $active_plugins) !== FALSE)
224
+ {
225
+ echo "<div class='error'><p>". __('WP Super Cache Plugin is active, make sure you clear the cache for new changes to apply', 'wp-hide-security-enhancer') ."</p></div>";
226
+ }
227
+
228
+ }
229
+
230
+
231
+ /**
232
+ * Return the module class by it's slug
233
+ *
234
+ * @param mixed $module_slug
235
+ */
236
+ function get_module_by_slug($module_slug)
237
+ {
238
+ global $wph;
239
+
240
+ $found_module = FALSE;
241
+
242
+ foreach($wph->modules as $module)
243
+ {
244
+ $interface_menu_data = $module->get_module_slug();
245
+
246
+ if($interface_menu_data == $module_slug)
247
+ {
248
+ $found_module = $module;
249
+ break;
250
+ }
251
+ }
252
+
253
+ return $found_module;
254
+ }
255
+
256
+ /**
257
+ * Used on early access when WP_Rewrite is not available
258
+ *
259
+ */
260
+ function is_permalink_enabled()
261
+ {
262
+
263
+ $permalink_structure = get_option('permalink_structure');
264
+
265
+ if ( empty($permalink_structure) )
266
+ return FALSE;
267
+
268
+ return TRUE;
269
+
270
+ }
271
+
272
+
273
+
274
+ /**
275
+ * return the server home path
276
+ *
277
+ */
278
+ function get_home_path()
279
+ {
280
+
281
+ $home = set_url_scheme( get_option( 'home' ), 'http' );
282
+ $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' );
283
+ if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) )
284
+ {
285
+ $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
286
+ $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) );
287
+
288
+ if($pos !== FALSE)
289
+ {
290
+ $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
291
+ $home_path = trailingslashit( $home_path );
292
+ }
293
+ else
294
+ {
295
+ $wp_path_rel_to_home = '\\' . trim($wp_path_rel_to_home, '/');
296
+ $pos = strpos( realpath(ABSPATH), $wp_path_rel_to_home);
297
+ $home_path = substr( realpath(ABSPATH), 0, $pos );
298
+ $home_path = trailingslashit( $home_path );
299
+ }
300
+ }
301
+ else
302
+ {
303
+ $home_path = ABSPATH;
304
+ }
305
+
306
+ $home_path = str_replace( '\\', '/', $home_path );
307
+
308
+ return $home_path;
309
+
310
+ }
311
+
312
+
313
+ /**
314
+ * return whatever server using the .htaccess config file
315
+ *
316
+ */
317
+ function server_use_htaccess_config_file()
318
+ {
319
+ $home_path = $this->get_home_path();
320
+
321
+ $htaccess_file = $home_path.'.htaccess';
322
+ if ($this->apache_mod_loaded('mod_rewrite', true))
323
+ return TRUE;
324
+
325
+ return FALSE;
326
+
327
+ }
328
+
329
+
330
+ /**
331
+ * Does the specified module exist in the Apache config?
332
+ *
333
+ * @since 2.5.0
334
+ *
335
+ * @global bool $is_apache
336
+ *
337
+ * @param string $mod The module, e.g. mod_rewrite.
338
+ * @param bool $default Optional. The default return value if the module is not found. Default false.
339
+ * @return bool Whether the specified module is loaded.
340
+ */
341
+ function apache_mod_loaded($mod, $default = false)
342
+ {
343
+
344
+ if ( function_exists( 'apache_get_modules' ) )
345
+ {
346
+ $mods = apache_get_modules();
347
+ if ( in_array($mod, $mods) )
348
+ return true;
349
+ }
350
+ elseif (getenv('HTTP_MOD_REWRITE') !== FALSE)
351
+ {
352
+ $mod_found = getenv('HTTP_MOD_REWRITE') == 'On' ? true : false ;
353
+ return $mod_found;
354
+ }
355
+ elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
356
+ ob_start();
357
+ phpinfo(8);
358
+ $phpinfo = ob_get_clean();
359
+ if ( false !== strpos($phpinfo, $mod) )
360
+ return true;
361
+
362
+ }
363
+
364
+ return $default;
365
+
366
+ }
367
+
368
+
369
+ /**
370
+ * return whatever the htaccess config file is writable
371
+ *
372
+ */
373
+ function is_writable_htaccess_config_file()
374
+ {
375
+ $home_path = $this->get_home_path();
376
+
377
+ $htaccess_file = $home_path.'.htaccess';
378
+
379
+ if ((!file_exists($htaccess_file) && is_writable($home_path) && $this->is_permalink_enabled()) || is_writable($htaccess_file))
380
+ return TRUE;
381
+
382
+ return FALSE;
383
+
384
+ }
385
+
386
+ /**
387
+ * return whatever server using the .htaccess config file
388
+ *
389
+ */
390
+ function server_use_web_config_file()
391
+ {
392
+ $home_path = $this->get_home_path();
393
+
394
+ $web_config_file = $home_path . 'web.config';
395
+
396
+ if ( iis7_supports_permalinks() )
397
+ return TRUE;
398
+
399
+ return FALSE;
400
+
401
+ }
402
+
403
+
404
+ /**
405
+ * return whatever the web.config config file is writable
406
+ *
407
+ */
408
+ function is_writable_web_config_file()
409
+ {
410
+ $home_path = $this->get_home_path();
411
+
412
+ $web_config_file = $home_path . 'web.config';
413
+
414
+ if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $this->is_permalink_enabled() ) || win_is_writable($web_config_file) )
415
+ return TRUE;
416
+
417
+ return FALSE;
418
+
419
+ }
420
+
421
+
422
+ function get_write_check_string()
423
+ {
424
+ $home_path = $this->get_home_path();
425
+
426
+ global $wp_rewrite;
427
+
428
+ $result = FALSE;
429
+
430
+ //check for .htaccess
431
+ if ( $this->server_use_htaccess_config_file() && file_exists($home_path . '.htaccess'))
432
+ {
433
+
434
+ if ( $markerdata = explode( "\n", implode( '', file( $home_path . '.htaccess' ) ) ));
435
+ {
436
+ foreach ( $markerdata as $markerline )
437
+ {
438
+ if (strpos($markerline, '#WriteCheckString:') !== false)
439
+ {
440
+ $result = trim(str_replace( '#WriteCheckString:', '', $markerline));
441
+ break;
442
+ }
443
+ }
444
+ }
445
+ }
446
+
447
+ //check for web.config
448
+ if ( $this->server_use_web_config_file() && file_exists( $home_path . 'web.config' ))
449
+ {
450
+ $file_data = file( $home_path . 'web.config' );
451
+ if(!empty($file_data))
452
+ {
453
+ if ( $markerdata = explode( "\n", implode( '', $file_data ) ));
454
+ {
455
+ foreach ( $markerdata as $markerline )
456
+ {
457
+ preg_match("'<rule name=\"wph-.*?<!-- WriteCheckString:([0-9_]+) --></rule>'si", $markerline, $matches);
458
+ if(isset($matches[1]))
459
+ {
460
+ $result = $matches[1];
461
+ }
462
+
463
+ if (!isset($matches[1]) && strpos($markerline, '<!-- WriteCheckString:') !== false)
464
+ {
465
+ $result = trim(str_ireplace( '<!-- WriteCheckString:', '', $markerline));
466
+ $result = trim(str_replace( '-->', '', $result));
467
+ $result = trim($result);
468
+
469
+ break;
470
+ }
471
+ }
472
+ }
473
+
474
+ }
475
+
476
+ }
477
+
478
+ return $result;
479
+
480
+ }
481
+
482
+
483
+ function rewrite_rules_applied()
484
+ {
485
+ $status = TRUE;
486
+
487
+ if(isset($this->wph->settings['write_check_string']) && !empty($this->wph->settings['write_check_string']))
488
+ {
489
+ $_write_check_string = $this->get_write_check_string();
490
+ if(empty($_write_check_string) || $_write_check_string != $this->wph->settings['write_check_string'])
491
+ $status = FALSE;
492
+ }
493
+ else
494
+ {
495
+ //disable, as settings never being saved or came from old version
496
+ $status = FALSE;
497
+ }
498
+
499
+ return $status;
500
+ }
501
+
502
+
503
+ /**
504
+ *
505
+ * Check if theme is is customize mode
506
+ *
507
+ */
508
+ function is_theme_customize()
509
+ {
510
+
511
+ if ( strpos($_SERVER['REQUEST_URI'] ,'customize.php') !== FALSE )
512
+ return TRUE;
513
+
514
+ if ( isset($_POST['wp_customize']) && $_POST['wp_customize'] == "on" )
515
+ return TRUE;
516
+
517
+ return FALSE;
518
+
519
+ }
520
+
521
+
522
+ /**
523
+ * return settings
524
+ *
525
+ */
526
+ function get_settings()
527
+ {
528
+ $settings = get_option('wph_settings');
529
+
530
+ $defaults = array (
531
+ 'module_settings' => array(),
532
+ 'recovery_code' => ''
533
+ );
534
+
535
+ $settings = wp_parse_args( $settings, $defaults );
536
+
537
+ return $settings;
538
+
539
+ }
540
+
541
+
542
+
543
+ /**
544
+ * Return a Module Item value setting
545
+ *
546
+ * @param mixed $item_id
547
+ */
548
+ function get_module_item_setting($item_id)
549
+ {
550
+
551
+ $settings = $this->get_settings();
552
+
553
+ $value = isset($settings['module_settings'][ $item_id ]) ? $settings['module_settings'][ $item_id] : '';
554
+
555
+ $value = apply_filters('wp-hide/get_module_item_setting', $value, $item_id);
556
+
557
+ return $value;
558
+
559
+ }
560
+
561
+
562
+ /**
563
+ * Save the settings
564
+ *
565
+ * @param mixed $settings
566
+ */
567
+ function update_settings($settings)
568
+ {
569
+ update_option('wph_settings', $settings);
570
+ }
571
+
572
+
573
+ function get_url_path($url, $is_file_path = FALSE)
574
+ {
575
+ if(!$is_file_path)
576
+ $url = trailingslashit( $url );
577
+
578
+ $url_parse = parse_url( $url );
579
+
580
+ /*
581
+ $root = isset($url_parse['scheme']) ? $url_parse['scheme'] . '://' : '';
582
+ $root .= isset($url_parse['host']) ? $url_parse['host'] : '';
583
+ */
584
+
585
+ $path = $url_parse['path'];
586
+
587
+ if(!$is_file_path)
588
+ $path = trailingslashit( $path );
589
+
590
+ if($path != '/' && strlen($path) > 1)
591
+ {
592
+ $path = ltrim($path, '/');
593
+ $path = '/' . $path;
594
+ }
595
+
596
+ if(isset($url_parse['query']))
597
+ $path .= '?' . $url_parse['query'];
598
+
599
+ return $path;
600
+
601
+ }
602
+
603
+
604
+ /**
605
+ * return the url relative to domain root
606
+ *
607
+ * @param mixed $url
608
+ */
609
+ function get_url_path_relative_to_domain_root($url)
610
+ {
611
+
612
+ $url = str_replace(trailingslashit( site_url() ), "" , $url);
613
+
614
+ return $url;
615
+
616
+ }
617
+
618
+
619
+
620
+ function untrailingslashit_all($value)
621
+ {
622
+ $value = ltrim(rtrim($value, "/"), "/");
623
+
624
+ return $value;
625
+ }
626
+
627
+ function sanitize_file_path_name($value)
628
+ {
629
+ $value = trim($value);
630
+
631
+ if(empty($value))
632
+ return $value;
633
+
634
+ $parts = explode("/", $value);
635
+ $parts = array_filter($parts);
636
+
637
+ foreach($parts as $key => $part_item)
638
+ {
639
+ $parts[$key] = sanitize_file_name($part_item);
640
+ }
641
+
642
+ $value = implode("/", $parts);
643
+
644
+ $value = strtolower($value);
645
+
646
+ return $value;
647
+ }
648
+
649
+ function php_extension_required($value)
650
+ {
651
+ $value = trim($value);
652
+
653
+ if($value == '')
654
+ return '';
655
+
656
+ $extension = substr($value, -4);
657
+ if(strtolower($extension) != '.php')
658
+ $value .= '.php';
659
+
660
+ return $value;
661
+ }
662
+
663
+
664
+ function get_current_url()
665
+ {
666
+
667
+ $current_url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
668
+
669
+ return $current_url;
670
+
671
+ }
672
+
673
+
674
+ /**
675
+ * Add replacement withint the list
676
+ *
677
+ * @param mixed $old_url
678
+ * @param mixed $new_url
679
+ */
680
+ function add_replacement($old_url, $new_url, $priority = 'normal')
681
+ {
682
+
683
+ if($this->replacement_exists($old_url))
684
+ return;
685
+
686
+ $this->wph->urls_replacement[ $priority ][ $old_url ] = $new_url;
687
+
688
+ }
689
+
690
+
691
+ /**
692
+ * Return whatever a replacement exists or not
693
+ * The old url should be provided
694
+ *
695
+ * @param mixed $old_url
696
+ */
697
+ function replacement_exists($old_url)
698
+ {
699
+
700
+ if(count($this->wph->urls_replacement) < 1)
701
+ return FALSE;
702
+
703
+ foreach($this->wph->urls_replacement as $priority => $replacements_block)
704
+ {
705
+ if(isset($this->wph->urls_replacement[ $old_url ]))
706
+ return TRUE;
707
+ }
708
+
709
+ return FALSE;
710
+
711
+ }
712
+
713
+
714
+
715
+ /**
716
+ * Return a list of replacements
717
+ *
718
+ */
719
+ function get_replacement_list()
720
+ {
721
+
722
+ $replacements = array();
723
+
724
+ if(count($this->wph->urls_replacement) < 1)
725
+ return $replacements;
726
+
727
+ foreach($this->wph->urls_replacement as $priority => $replacements_block)
728
+ {
729
+ if(!is_array($replacements_block) || count($replacements_block) < 1)
730
+ continue;
731
+
732
+ foreach($replacements_block as $old_url => $new_url)
733
+ {
734
+ $replacements[ $old_url ] = $new_url;
735
+ }
736
+ }
737
+
738
+ return $replacements;
739
+
740
+ }
741
+
742
+
743
+ /**
744
+ * Replace the urls within given content
745
+ *
746
+ * @param mixed $text
747
+ * @param mixed $replacements
748
+ */
749
+ function content_urls_replacement($text, $replacements)
750
+ {
751
+ //process the replacements
752
+ if( count($replacements) < 1)
753
+ return $text;
754
+
755
+ //exclude scheme to match urls without it
756
+ $_replacements = array();
757
+ $_relative_url_replacements = array();
758
+
759
+ $home_url = home_url();
760
+
761
+ foreach($replacements as $old_url => $new_url)
762
+ {
763
+ //add quote to make sure it's actualy a link value and is right at the start of text
764
+ $_relative_url_replacements[ '"' . str_ireplace( $home_url, "", $old_url) ] = '"' . str_ireplace( $home_url, "", $new_url);
765
+ $_relative_url_replacements[ "'" . str_ireplace( $home_url, "", $old_url) ] = "'" . str_ireplace( $home_url, "", $new_url);
766
+
767
+ $old_url = str_ireplace( array('http://', 'https://'), "", $old_url);
768
+ $new_url = str_ireplace( array('http://', 'https://'), "", $new_url);
769
+
770
+ $_replacements[$old_url] = $new_url;
771
+ }
772
+
773
+
774
+ $text = str_ireplace( array_keys($_replacements), array_values($_replacements) ,$text );
775
+ //relative urls replacements
776
+ $text = str_ireplace( array_keys($_relative_url_replacements), array_values($_relative_url_replacements) ,$text );
777
+
778
+ //check for json encoded urls
779
+ foreach($_replacements as $old_url => $new_url)
780
+ {
781
+ $old_url = trim(json_encode($old_url), '"');
782
+ $new_url = trim(json_encode($new_url), '"');
783
+
784
+ $text = str_ireplace( $old_url, $new_url ,$text );
785
+ }
786
+
787
+ return $text;
788
+ }
789
+
790
+
791
+ function default_scripts_styles_replace($object, $replacements)
792
+ {
793
+ //update default dirs
794
+ if(isset($object->default_dirs))
795
+ {
796
+ foreach($object->default_dirs as $key => $value)
797
+ {
798
+ $object->default_dirs[$key] = str_replace(array_keys($replacements), array_values($replacements), $value);
799
+ }
800
+ }
801
+
802
+ foreach($object->registered as $script_name => $script_data)
803
+ {
804
+ $script_data->src = str_replace(array_keys($replacements), array_values($replacements), $script_data->src);
805
+
806
+ $object->registered[$script_name] = $script_data;
807
+ }
808
+
809
+ return $object;
810
+ }
811
+
812
+
813
+ function check_headers_content_type($header_name, $header_value)
814
+ {
815
+
816
+ $headers = headers_list();
817
+
818
+ foreach($headers as $header)
819
+ {
820
+ if(stripos($header, $header_name) !== FALSE)
821
+ {
822
+ if(stripos($header, $header_value) !== FALSE)
823
+ return TRUE;
824
+ }
825
+ }
826
+
827
+
828
+ return FALSE;
829
+
830
+ }
831
+
832
+
833
+ function array_sort_by_processing_order($a, $b)
834
+ {
835
+ return $a['processing_order'] - $b['processing_order'];
836
+ }
837
+
838
+
839
+
840
+ /**
841
+ * Return the recovey code
842
+ *
843
+ */
844
+ function get_recovery_code()
845
+ {
846
+
847
+ $settings = $this->get_settings();
848
+ if(!isset($settings['recovery_code']) || empty($settings['recovery_code']))
849
+ {
850
+ $recovery_code = $this->generate_recovery_code();
851
+ }
852
+ else
853
+ $recovery_code = $settings['recovery_code'];
854
+
855
+
856
+ return $recovery_code;
857
+ }
858
+
859
+
860
+ /**
861
+ * Generate a recovery code
862
+ *
863
+ */
864
+ function generate_recovery_code()
865
+ {
866
+
867
+ $settings = $this->get_settings();
868
+
869
+ $recovery_code = md5(rand(1,9999) . microtime());
870
+
871
+ $settings['recovery_code'] = $recovery_code;
872
+
873
+ $this->update_settings($settings);
874
+
875
+ return $recovery_code;
876
+ }
877
+
878
+
879
+ /**
880
+ * Trigger the recovery actions
881
+ *
882
+ */
883
+ function do_recovery()
884
+ {
885
+ //feetch a new set of settings
886
+ $settings = $this->get_settings();
887
+
888
+ $wph_recovery = isset($_GET['wph-recovery']) ? $_GET['wph-recovery'] : '';
889
+ if(empty($wph_recovery) || $wph_recovery != $this->wph->settings['recovery_code'])
890
+ return;
891
+
892
+ //change certain settings to default
893
+ $this->wph->settings['module_settings']['new_wp_login_php'] = '';
894
+ $this->wph->settings['module_settings']['admin_url'] = '';
895
+
896
+ //update the settings
897
+ $this->update_settings($this->wph->settings);
898
+
899
+ //available for mu-plugins
900
+ do_action('wph/do_recovery');
901
+
902
+
903
+ //add filter for rewriting the rules
904
+ add_action('wp_loaded', array($this, 'wp_loaded_trigger_do_recovery'));
905
+
906
+ }
907
+
908
+
909
+ function wp_loaded_trigger_do_recovery()
910
+ {
911
+ /** WordPress Misc Administration API */
912
+ require_once(ABSPATH . 'wp-admin/includes/misc.php');
913
+
914
+ /** WordPress Administration File API */
915
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
916
+
917
+ flush_rewrite_rules();
918
+
919
+ //redirect to homepage
920
+ wp_redirect(get_site_url());
921
+
922
+ die();
923
+ }
924
+
925
+
926
+ /**
927
+ * Check if filter / action exists for anonymous object
928
+ *
929
+ * @param mixed $tag
930
+ * @param mixed $class
931
+ * @param mixed $method
932
+ */
933
+ function anonymous_object_filter_exists($tag, $class, $method)
934
+ {
935
+ if ( ! isset( $GLOBALS['wp_filter'][$tag] ) )
936
+ return FALSE;
937
+
938
+ $filters = $GLOBALS['wp_filter'][$tag];
939
+
940
+ if ( ! $filters )
941
+ return FALSE;
942
+
943
+ foreach ( $filters as $priority => $filter )
944
+ {
945
+ foreach ( $filter as $identifier => $function )
946
+ {
947
+ if ( ! is_array( $function ) )
948
+ continue;
949
+
950
+ if ( ! $function['function'][0] instanceof $class )
951
+ continue;
952
+
953
+ if ( $method == $function['function'][1] )
954
+ {
955
+ return TRUE;
956
+ }
957
+ }
958
+ }
959
+
960
+ return FALSE;
961
+ }
962
+
963
+ /**
964
+ * Replace a filter / action from anonymous object
965
+ *
966
+ * @param mixed $tag
967
+ * @param mixed $class
968
+ * @param mixed $method
969
+ */
970
+ function remove_anonymous_object_filter( $tag, $class, $method )
971
+ {
972
+ $filters = false;
973
+
974
+ if ( isset( $GLOBALS['wp_filter'][$tag] ) )
975
+ $filters = $GLOBALS['wp_filter'][$tag];
976
+
977
+ if ( $filters )
978
+ foreach ( $filters as $priority => $filter )
979
+ {
980
+ foreach ( $filter as $identifier => $function )
981
+ {
982
+ if ( ! is_array( $function ) )
983
+ continue;
984
+
985
+ if ( ! $function['function'][0] instanceof $class )
986
+ continue;
987
+
988
+ if ( $method == $function['function'][1] )
989
+ {
990
+ remove_filter($tag, array( $function['function'][0], $method ), $priority);
991
+ }
992
+ }
993
+ }
994
+ }
995
+
996
+
997
+ /**
998
+ * An early instance of WordPress wp_mail core
999
+ * Unable to load pluggable.php where the function exists, as bein loaded using require
1000
+ *
1001
+ * @param mixed $to
1002
+ * @param mixed $subject
1003
+ * @param mixed $message
1004
+ * @param mixed $headers
1005
+ * @param mixed $attachments
1006
+ */
1007
+ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
1008
+ {
1009
+ // Compact the input, apply the filters, and extract them back out
1010
+
1011
+ /**
1012
+ * Filter the wp_mail() arguments.
1013
+ *
1014
+ * @since 2.2.0
1015
+ *
1016
+ * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
1017
+ * subject, message, headers, and attachments values.
1018
+ */
1019
+ $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
1020
+
1021
+ if ( isset( $atts['to'] ) ) {
1022
+ $to = $atts['to'];
1023
+ }
1024
+
1025
+ if ( isset( $atts['subject'] ) ) {
1026
+ $subject = $atts['subject'];
1027
+ }
1028
+
1029
+ if ( isset( $atts['message'] ) ) {
1030
+ $message = $atts['message'];
1031
+ }
1032
+
1033
+ if ( isset( $atts['headers'] ) ) {
1034
+ $headers = $atts['headers'];
1035
+ }
1036
+
1037
+ if ( isset( $atts['attachments'] ) ) {
1038
+ $attachments = $atts['attachments'];
1039
+ }
1040
+
1041
+ if ( ! is_array( $attachments ) ) {
1042
+ $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
1043
+ }
1044
+ global $phpmailer;
1045
+
1046
+ // (Re)create it, if it's gone missing
1047
+ if ( ! ( $phpmailer instanceof PHPMailer ) ) {
1048
+ require_once ABSPATH . WPINC . '/class-phpmailer.php';
1049
+ require_once ABSPATH . WPINC . '/class-smtp.php';
1050
+ $phpmailer = new PHPMailer( true );
1051
+ }
1052
+
1053
+ // Headers
1054
+ if ( empty( $headers ) ) {
1055
+ $headers = array();
1056
+ } else {
1057
+ if ( !is_array( $headers ) ) {
1058
+ // Explode the headers out, so this function can take both
1059
+ // string headers and an array of headers.
1060
+ $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) );
1061
+ } else {
1062
+ $tempheaders = $headers;
1063
+ }
1064
+ $headers = array();
1065
+ $cc = array();
1066
+ $bcc = array();
1067
+
1068
+ // If it's actually got contents
1069
+ if ( !empty( $tempheaders ) ) {
1070
+ // Iterate through the raw headers
1071
+ foreach ( (array) $tempheaders as $header ) {
1072
+ if ( strpos($header, ':') === false ) {
1073
+ if ( false !== stripos( $header, 'boundary=' ) ) {
1074
+ $parts = preg_split('/boundary=/i', trim( $header ) );
1075
+ $boundary = trim( str_replace( array( "'", '"' ), '', $parts[1] ) );
1076
+ }
1077
+ continue;
1078
+ }
1079
+ // Explode them out
1080
+ list( $name, $content ) = explode( ':', trim( $header ), 2 );
1081
+
1082
+ // Cleanup crew
1083
+ $name = trim( $name );
1084
+ $content = trim( $content );
1085
+
1086
+ switch ( strtolower( $name ) ) {
1087
+ // Mainly for legacy -- process a From: header if it's there
1088
+ case 'from':
1089
+ $bracket_pos = strpos( $content, '<' );
1090
+ if ( $bracket_pos !== false ) {
1091
+ // Text before the bracketed email is the "From" name.
1092
+ if ( $bracket_pos > 0 ) {
1093
+ $from_name = substr( $content, 0, $bracket_pos - 1 );
1094
+ $from_name = str_replace( '"', '', $from_name );
1095
+ $from_name = trim( $from_name );
1096
+ }
1097
+
1098
+ $from_email = substr( $content, $bracket_pos + 1 );
1099
+ $from_email = str_replace( '>', '', $from_email );
1100
+ $from_email = trim( $from_email );
1101
+
1102
+ // Avoid setting an empty $from_email.
1103
+ } elseif ( '' !== trim( $content ) ) {
1104
+ $from_email = trim( $content );
1105
+ }
1106
+ break;
1107
+ case 'content-type':
1108
+ if ( strpos( $content, ';' ) !== false ) {
1109
+ list( $type, $charset_content ) = explode( ';', $content );
1110
+ $content_type = trim( $type );
1111
+ if ( false !== stripos( $charset_content, 'charset=' ) ) {
1112
+ $charset = trim( str_replace( array( 'charset=', '"' ), '', $charset_content ) );
1113
+ } elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
1114
+ $boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
1115
+ $charset = '';
1116
+ }
1117
+
1118
+ // Avoid setting an empty $content_type.
1119
+ } elseif ( '' !== trim( $content ) ) {
1120
+ $content_type = trim( $content );
1121
+ }
1122
+ break;
1123
+ case 'cc':
1124
+ $cc = array_merge( (array) $cc, explode( ',', $content ) );
1125
+ break;
1126
+ case 'bcc':
1127
+ $bcc = array_merge( (array) $bcc, explode( ',', $content ) );
1128
+ break;
1129
+ default:
1130
+ // Add it to our grand headers array
1131
+ $headers[trim( $name )] = trim( $content );
1132
+ break;
1133
+ }
1134
+ }
1135
+ }
1136
+ }
1137
+
1138
+ // Empty out the values that may be set
1139
+ $phpmailer->ClearAllRecipients();
1140
+ $phpmailer->ClearAttachments();
1141
+ $phpmailer->ClearCustomHeaders();
1142
+ $phpmailer->ClearReplyTos();
1143
+
1144
+ // From email and name
1145
+ // If we don't have a name from the input headers
1146
+ if ( !isset( $from_name ) )
1147
+ $from_name = 'WordPress';
1148
+
1149
+ /* If we don't have an email from the input headers default to wordpress@$sitename
1150
+ * Some hosts will block outgoing mail from this address if it doesn't exist but
1151
+ * there's no easy alternative. Defaulting to admin_email might appear to be another
1152
+ * option but some hosts may refuse to relay mail from an unknown domain. See
1153
+ * https://core.trac.wordpress.org/ticket/5007.
1154
+ */
1155
+
1156
+ if ( !isset( $from_email ) ) {
1157
+ // Get the site domain and get rid of www.
1158
+ $sitename = strtolower( $_SERVER['SERVER_NAME'] );
1159
+ if ( substr( $sitename, 0, 4 ) == 'www.' ) {
1160
+ $sitename = substr( $sitename, 4 );
1161
+ }
1162
+
1163
+ $from_email = 'wordpress@' . $sitename;
1164
+ }
1165
+
1166
+ /**
1167
+ * Filter the email address to send from.
1168
+ *
1169
+ * @since 2.2.0
1170
+ *
1171
+ * @param string $from_email Email address to send from.
1172
+ */
1173
+ $phpmailer->From = apply_filters( 'wp_mail_from', $from_email );
1174
+
1175
+ /**
1176
+ * Filter the name to associate with the "from" email address.
1177
+ *
1178
+ * @since 2.3.0
1179
+ *
1180
+ * @param string $from_name Name associated with the "from" email address.
1181
+ */
1182
+ $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
1183
+
1184
+ // Set destination addresses
1185
+ if ( !is_array( $to ) )
1186
+ $to = explode( ',', $to );
1187
+
1188
+ foreach ( (array) $to as $recipient ) {
1189
+ try {
1190
+ // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1191
+ $recipient_name = '';
1192
+ if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1193
+ if ( count( $matches ) == 3 ) {
1194
+ $recipient_name = $matches[1];
1195
+ $recipient = $matches[2];
1196
+ }
1197
+ }
1198
+ $phpmailer->AddAddress( $recipient, $recipient_name);
1199
+ } catch ( phpmailerException $e ) {
1200
+ continue;
1201
+ }
1202
+ }
1203
+
1204
+ // Set mail's subject and body
1205
+ $phpmailer->Subject = $subject;
1206
+ $phpmailer->Body = $message;
1207
+
1208
+ // Add any CC and BCC recipients
1209
+ if ( !empty( $cc ) ) {
1210
+ foreach ( (array) $cc as $recipient ) {
1211
+ try {
1212
+ // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1213
+ $recipient_name = '';
1214
+ if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1215
+ if ( count( $matches ) == 3 ) {
1216
+ $recipient_name = $matches[1];
1217
+ $recipient = $matches[2];
1218
+ }
1219
+ }
1220
+ $phpmailer->AddCc( $recipient, $recipient_name );
1221
+ } catch ( phpmailerException $e ) {
1222
+ continue;
1223
+ }
1224
+ }
1225
+ }
1226
+
1227
+ if ( !empty( $bcc ) ) {
1228
+ foreach ( (array) $bcc as $recipient) {
1229
+ try {
1230
+ // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
1231
+ $recipient_name = '';
1232
+ if ( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
1233
+ if ( count( $matches ) == 3 ) {
1234
+ $recipient_name = $matches[1];
1235
+ $recipient = $matches[2];
1236
+ }
1237
+ }
1238
+ $phpmailer->AddBcc( $recipient, $recipient_name );
1239
+ } catch ( phpmailerException $e ) {
1240
+ continue;
1241
+ }
1242
+ }
1243
+ }
1244
+
1245
+ // Set to use PHP's mail()
1246
+ $phpmailer->IsMail();
1247
+
1248
+ // Set Content-Type and charset
1249
+ // If we don't have a content-type from the input headers
1250
+ if ( !isset( $content_type ) )
1251
+ $content_type = 'text/plain';
1252
+
1253
+ /**
1254
+ * Filter the wp_mail() content type.
1255
+ *
1256
+ * @since 2.3.0
1257
+ *
1258
+ * @param string $content_type Default wp_mail() content type.
1259
+ */
1260
+ $content_type = apply_filters( 'wp_mail_content_type', $content_type );
1261
+
1262
+ $phpmailer->ContentType = $content_type;
1263
+
1264
+ // Set whether it's plaintext, depending on $content_type
1265
+ if ( 'text/html' == $content_type )
1266
+ $phpmailer->IsHTML( true );
1267
+
1268
+ // If we don't have a charset from the input headers
1269
+ if ( !isset( $charset ) )
1270
+ $charset = get_bloginfo( 'charset' );
1271
+
1272
+ // Set the content-type and charset
1273
+
1274
+ /**
1275
+ * Filter the default wp_mail() charset.
1276
+ *
1277
+ * @since 2.3.0
1278
+ *
1279
+ * @param string $charset Default email charset.
1280
+ */
1281
+ $phpmailer->CharSet = apply_filters( 'wp_mail_charset', $charset );
1282
+
1283
+ // Set custom headers
1284
+ if ( !empty( $headers ) ) {
1285
+ foreach ( (array) $headers as $name => $content ) {
1286
+ $phpmailer->AddCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
1287
+ }
1288
+
1289
+ if ( false !== stripos( $content_type, 'multipart' ) && ! empty($boundary) )
1290
+ $phpmailer->AddCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
1291
+ }
1292
+
1293
+ if ( !empty( $attachments ) ) {
1294
+ foreach ( $attachments as $attachment ) {
1295
+ try {
1296
+ $phpmailer->AddAttachment($attachment);
1297
+ } catch ( phpmailerException $e ) {
1298
+ continue;
1299
+ }
1300
+ }
1301
+ }
1302
+
1303
+ /**
1304
+ * Fires after PHPMailer is initialized.
1305
+ *
1306
+ * @since 2.2.0
1307
+ *
1308
+ * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
1309
+ */
1310
+ do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
1311
+
1312
+ // Send!
1313
+ try {
1314
+ return $phpmailer->Send();
1315
+ } catch ( phpmailerException $e ) {
1316
+
1317
+ $mail_error_data = compact( $to, $subject, $message, $headers, $attachments );
1318
+
1319
+ /**
1320
+ * Fires after a phpmailerException is caught.
1321
+ *
1322
+ * @since 4.4.0
1323
+ *
1324
+ * @param WP_Error $error A WP_Error object with the phpmailerException code, message, and an array
1325
+ * containing the mail recipient, subject, message, headers, and attachments.
1326
+ */
1327
+ do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
1328
+
1329
+ return false;
1330
+ }
1331
+ }
1332
+
1333
+
1334
+ /**
1335
+ * Check the plugins directory and retrieve all plugin files with plugin data.
1336
+ *
1337
+ * WordPress only supports plugin files in the base plugins directory
1338
+ * (wp-content/plugins) and in one directory above the plugins directory
1339
+ * (wp-content/plugins/my-plugin). The file it looks for has the plugin data
1340
+ * and must be found in those two locations. It is recommended to keep your
1341
+ * plugin files in their own directories.
1342
+ *
1343
+ * The file with the plugin data is the file that will be included and therefore
1344
+ * needs to have the main execution for the plugin. This does not mean
1345
+ * everything must be contained in the file and it is recommended that the file
1346
+ * be split for maintainability. Keep everything in one file for extreme
1347
+ * optimization purposes.
1348
+ *
1349
+ * @since 1.5.0
1350
+ *
1351
+ * @param string $plugin_folder Optional. Relative path to single plugin folder.
1352
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
1353
+ */
1354
+ function get_plugins($plugin_folder = '')
1355
+ {
1356
+
1357
+ $wp_plugins = array ();
1358
+ $plugin_root = WP_PLUGIN_DIR;
1359
+ if ( !empty($plugin_folder) )
1360
+ $plugin_root .= $plugin_folder;
1361
+
1362
+ // Files in wp-content/plugins directory
1363
+ $plugins_dir = @ opendir( $plugin_root);
1364
+ $plugin_files = array();
1365
+ if ( $plugins_dir ) {
1366
+ while (($file = readdir( $plugins_dir ) ) !== false ) {
1367
+ if ( substr($file, 0, 1) == '.' )
1368
+ continue;
1369
+ if ( is_dir( $plugin_root.'/'.$file ) ) {
1370
+ $plugins_subdir = @ opendir( $plugin_root.'/'.$file );
1371
+ if ( $plugins_subdir ) {
1372
+ while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
1373
+ if ( substr($subfile, 0, 1) == '.' )
1374
+ continue;
1375
+ if ( substr($subfile, -4) == '.php' )
1376
+ $plugin_files[] = "$file/$subfile";
1377
+ }
1378
+ closedir( $plugins_subdir );
1379
+ }
1380
+ } else {
1381
+ if ( substr($file, -4) == '.php' )
1382
+ $plugin_files[] = $file;
1383
+ }
1384
+ }
1385
+ closedir( $plugins_dir );
1386
+ }
1387
+
1388
+ if ( empty($plugin_files) )
1389
+ return $wp_plugins;
1390
+
1391
+ foreach ( $plugin_files as $plugin_file ) {
1392
+ if ( !is_readable( "$plugin_root/$plugin_file" ) )
1393
+ continue;
1394
+
1395
+ $plugin_data = $this->get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
1396
+
1397
+ if ( empty ( $plugin_data['Name'] ) )
1398
+ continue;
1399
+
1400
+ $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
1401
+ }
1402
+
1403
+ return $wp_plugins;
1404
+ }
1405
+
1406
+
1407
+ /**
1408
+ * Parse plugin headers data
1409
+ *
1410
+ * @param mixed $plugin_file
1411
+ * @param mixed $markup
1412
+ * @param mixed $translate
1413
+ */
1414
+ function get_plugin_data( $plugin_file, $markup = true, $translate = true )
1415
+ {
1416
+
1417
+ $default_headers = array(
1418
+ 'Name' => 'Plugin Name',
1419
+ 'PluginURI' => 'Plugin URI',
1420
+ 'Version' => 'Version',
1421
+ 'Description' => 'Description',
1422
+ 'Author' => 'Author',
1423
+ 'AuthorURI' => 'Author URI',
1424
+ 'TextDomain' => 'Text Domain',
1425
+ 'DomainPath' => 'Domain Path',
1426
+ 'Network' => 'Network',
1427
+ // Site Wide Only is deprecated in favor of Network.
1428
+ '_sitewide' => 'Site Wide Only',
1429
+ );
1430
+
1431
+ $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
1432
+
1433
+ // Site Wide Only is the old header for Network
1434
+ if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
1435
+ /* translators: 1: Site Wide Only: true, 2: Network: true */
1436
+ _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
1437
+ $plugin_data['Network'] = $plugin_data['_sitewide'];
1438
+ }
1439
+ $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
1440
+ unset( $plugin_data['_sitewide'] );
1441
+
1442
+ if ( $markup || $translate ) {
1443
+ $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
1444
+ } else {
1445
+ $plugin_data['Title'] = $plugin_data['Name'];
1446
+ $plugin_data['AuthorName'] = $plugin_data['Author'];
1447
+ }
1448
+
1449
+ return $plugin_data;
1450
+ }
1451
+
1452
+
1453
+ /**
1454
+ * Alternative when apache_response_headers() not available
1455
+ *
1456
+ */
1457
+ function parseRequestHeaders()
1458
+ {
1459
+ $headers = array();
1460
+ foreach($_SERVER as $key => $value)
1461
+ {
1462
+ if (substr($key, 0, 5) <> 'HTTP_')
1463
+ continue;
1464
+
1465
+ $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
1466
+ $headers[$header] = $value;
1467
+ }
1468
+
1469
+ return $headers;
1470
+ }
1471
+
1472
+
1473
+
1474
+ /**
1475
+ * Get available themes
1476
+ *
1477
+ * @param mixed $args
1478
+ */
1479
+ function get_themes( $args = array() )
1480
+ {
1481
+ global $wp_theme_directories;
1482
+
1483
+ $defaults = array( 'errors' => false, 'allowed' => null, 'blog_id' => 0 );
1484
+ $args = wp_parse_args( $args, $defaults );
1485
+
1486
+ $theme_directories = search_theme_directories();
1487
+
1488
+ if ( count( $wp_theme_directories ) > 1 ) {
1489
+ // Make sure the current theme wins out, in case search_theme_directories() picks the wrong
1490
+ // one in the case of a conflict. (Normally, last registered theme root wins.)
1491
+ $current_theme = get_stylesheet();
1492
+ if ( isset( $theme_directories[ $current_theme ] ) ) {
1493
+ $root_of_current_theme = get_raw_theme_root( $current_theme );
1494
+ if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) )
1495
+ $root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
1496
+ $theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
1497
+ }
1498
+ }
1499
+
1500
+ if ( empty( $theme_directories ) )
1501
+ return array();
1502
+
1503
+ if ( is_multisite() && null !== $args['allowed'] ) {
1504
+ $allowed = $args['allowed'];
1505
+ if ( 'network' === $allowed )
1506
+ $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_network() );
1507
+ elseif ( 'site' === $allowed )
1508
+ $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed_on_site( $args['blog_id'] ) );
1509
+ elseif ( $allowed )
1510
+ $theme_directories = array_intersect_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
1511
+ else
1512
+ $theme_directories = array_diff_key( $theme_directories, WP_Theme::get_allowed( $args['blog_id'] ) );
1513
+ }
1514
+
1515
+ return $theme_directories;
1516
+
1517
+ }
1518
+
1519
+
1520
+ /**
1521
+ * Parse available themes headers
1522
+ *
1523
+ */
1524
+ function parse_themes_headers( $all_templates )
1525
+ {
1526
+ foreach( $all_templates as $directory => $theme_data)
1527
+ {
1528
+
1529
+ $theme_headers = $this->get_theme_headers( trailingslashit( $theme_data['theme_root']) . $theme_data['theme_file']);
1530
+ $all_templates[$directory]['headers'] = $theme_headers;
1531
+
1532
+ }
1533
+
1534
+ return $all_templates;
1535
+
1536
+ }
1537
+
1538
+
1539
+ function get_theme_headers($stylesheet_path)
1540
+ {
1541
+
1542
+ $file_headers = array(
1543
+ 'Name' => 'Theme Name',
1544
+ 'ThemeURI' => 'Theme URI',
1545
+ 'Description' => 'Description',
1546
+ 'Author' => 'Author',
1547
+ 'AuthorURI' => 'Author URI',
1548
+ 'Version' => 'Version',
1549
+ 'Template' => 'Template',
1550
+ 'Status' => 'Status',
1551
+ 'Tags' => 'Tags',
1552
+ 'TextDomain' => 'Text Domain',
1553
+ 'DomainPath' => 'Domain Path',
1554
+ );
1555
+
1556
+ $theme_headers = get_file_data( $stylesheet_path, $file_headers, 'theme' );
1557
+
1558
+ return $theme_headers;
1559
+
1560
+ }
1561
+
1562
+
1563
+ /**
1564
+ * Return if a theme is child or not
1565
+ *
1566
+ * @param mixed $theme_slug
1567
+ * @param mixed $all_themes
1568
+ */
1569
+ function is_child_theme($theme_slug, $all_themes)
1570
+ {
1571
+
1572
+ $theme_data = $all_themes[$theme_slug];
1573
+
1574
+ if( isset($theme_data['headers']['Template']) && !empty($theme_data['headers']['Template']))
1575
+ return TRUE;
1576
+
1577
+ return FALSE;
1578
+
1579
+ }
1580
+
1581
+
1582
+ /**
1583
+ * Return main theme directory slug
1584
+ *
1585
+ * @param mixed $theme_slug
1586
+ * @param mixed $all_themes
1587
+ */
1588
+ function get_main_theme_directory($theme_slug, $all_themes)
1589
+ {
1590
+
1591
+ $theme_data = $all_themes[$theme_slug];
1592
+ $theme_directory = $theme_slug;
1593
+
1594
+ if( isset($theme_data['headers']['Template']) && !empty($theme_data['headers']['Template']))
1595
+ {
1596
+ $theme_directory = $theme_data['headers']['Template'];
1597
+ }
1598
+
1599
+ return $theme_directory;
1600
+
1601
+ }
1602
+
1603
+
1604
+ function get_ad_banner()
1605
+ {
1606
+ ob_start();
1607
+ ?><div id="info_box">
1608
+ <div id="p_right">
1609
+
1610
+ <div id="p_socialize">
1611
+
1612
+ <div class="p_s_item s_f">
1613
+ <div id="fb-root"></div>
1614
+ <script>(function(d, s, id) {
1615
+ var js, fjs = d.getElementsByTagName(s)[0];
1616
+ if (d.getElementById(id)) return;
1617
+ js = d.createElement(s); js.id = id;
1618
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
1619
+ fjs.parentNode.insertBefore(js, fjs);
1620
+ }(document, 'script', 'facebook-jssdk'));</script>
1621
+
1622
+ <div class="fb-like" data-href="https://www.facebook.com/Nsp-Code-190329887674484/" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
1623
+
1624
+ </div>
1625
+
1626
+ <div class="p_s_item s_t">
1627
+ <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.wp-hide.com" data-text="Hide and increase Security for your WordPress website instance using smart techniques. No files are being changed." data-count="none">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
1628
+ </div>
1629
+
1630
+ <div class="p_s_item s_gp">
1631
+ <!-- Place this tag in your head or just before your close body tag -->
1632
+ <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
1633
+
1634
+ <!-- Place this tag where you want the +1 button to render -->
1635
+ <div class="g-plusone" data-size="small" data-annotation="none" data-href="http://nsp-code.com/"></div>
1636
+ </div>
1637
+
1638
+ <div class="clear"></div>
1639
+ </div>
1640
+
1641
+ </div>
1642
+ <p><?php _e('Help us to improve this plugin by sending any improvement suggestions and reporting any issues at ', 'wp-hide-security-enhancer') ?><a target="_blank" href="http://www.wp-hide.com/">www.wp-hide.com</a></p>
1643
+ <p><?php _e('Did you find this plugin useful? Please support our work by spread the word about this, or write an article about the plugin in your blog with a link to development site', 'wp-hide-security-enhancer') ?> <a href="http://www.wp-hide.com/" target="_blank"><strong>http://www.wp-hide.com/</strong></a></p>
1644
+
1645
+ <div class="clear"></div>
1646
+ </div><?php
1647
+
1648
+ $content = ob_get_contents();
1649
+ ob_end_clean();
1650
+
1651
+ return $content;
1652
+
1653
+ }
1654
+
1655
+
1656
+ }
1657
+
1658
  ?>
include/wph.class.php CHANGED
@@ -1,923 +1,936 @@
1
- <?php
2
-
3
-
4
- class WPH
5
- {
6
- var $default_variables = array();
7
- var $templates_data = array();
8
- var $urls_replacement = array();
9
-
10
- var $server_htaccess_config = FALSE;
11
- var $server_web_config = FALSE;
12
-
13
- var $modules = array();
14
-
15
- var $settings;
16
-
17
- var $functions;
18
-
19
- var $disable_filters = FALSE;
20
- var $permalinks_not_applied = FALSE;
21
-
22
- var $doing_interface_save = FALSE;
23
- var $doing_reset_settings = FALSE;
24
-
25
- var $uninstall = FALSE;
26
-
27
- var $is_initialised = FALSE;
28
-
29
- var $conflicts = array();
30
-
31
- function __construct()
32
- {
33
-
34
- }
35
-
36
- function __destruct()
37
- {
38
-
39
- }
40
-
41
-
42
- function init()
43
- {
44
- $this->functions = new WPH_functions();
45
-
46
- $this->settings = $this->functions->get_settings();
47
-
48
- //check for plugin update
49
- $this->update();
50
-
51
- //set whatever the server use htaccess or web.config configuration file
52
- $this->server_htaccess_config = $this->functions->server_use_htaccess_config_file();
53
- $this->server_web_config = $this->functions->server_use_web_config_file();
54
-
55
- //check for recovery link run
56
- if(isset($_GET['wph-recovery']))
57
- $this->functions->do_recovery();
58
-
59
- //check for interface submit
60
- if(is_admin() && isset($_POST['wph-interface-nonce']))
61
- {
62
- $this->doing_interface_save = TRUE;
63
- $this->disable_filters = TRUE;
64
- }
65
-
66
- //check for reset setings
67
- if(is_admin() && isset($_POST['reset-settings']))
68
- {
69
- $this->doing_reset_settings = TRUE;
70
- $this->disable_filters = TRUE;
71
- }
72
-
73
- //check for permalink issues
74
- $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
75
-
76
- $this->get_default_variables();
77
-
78
- $this->_load_modules();
79
-
80
- $this->add_default_replacements();
81
-
82
- /**
83
- * Filters
84
- */
85
- add_action( 'activated_plugin', array($this, 'activated_plugin'), 999, 2 );
86
-
87
- remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
88
-
89
- add_action('plugins_loaded', array($this, 'plugin_conflicts') , -1);
90
-
91
- //change any links within email message
92
- add_filter('wp_mail', array($this, 'apply_for_wp_mail') , 999);
93
-
94
- //process redirects
95
- add_action('wp_redirect', array($this, 'wp_redirect') , 999, 2);
96
- //hijack a redirect on permalink change
97
- add_action('admin_head', array($this, 'permalink_change_redirect') , 999, 2);
98
-
99
- add_action('logout_redirect', array($this, 'logout_redirect') , 999, 3);
100
-
101
- add_action('wp', array($this, '_action_wp'));
102
-
103
- add_action('admin_menu', array($this, 'admin_menus'));
104
- add_action('admin_init', array($this, 'admin_init'), 11);
105
-
106
-
107
- //rebuild and change uppon settings modified
108
- add_action('wph/settings_changed', array($this, 'settings_changed'));
109
-
110
- //apache
111
- add_filter('mod_rewrite_rules', array($this, 'mod_rewrite_rules'), 999);
112
- //IIS7 server
113
- add_filter('iis7_url_rewrite_rules', array($this, 'iis7_url_rewrite_rules'), 999);
114
-
115
- //on switch theme
116
- add_action('switch_theme', array($this, 'switch_theme'));
117
-
118
- //admin notices
119
- add_action( 'admin_notices', array(&$this, 'admin_notices'));
120
-
121
- $this->is_initialised = TRUE;
122
- }
123
-
124
-
125
- /**
126
- * Update wrapper
127
- *
128
- */
129
- function update()
130
- {
131
-
132
- //check for update from older version
133
- include_once(WPH_PATH . '/include/update.class.php');
134
- new WPH_update();
135
-
136
- }
137
-
138
- function _load_modules()
139
- {
140
-
141
- $module_files = glob(WPH_PATH . "/modules/module-*.php");
142
-
143
- foreach ($module_files as $filename)
144
- {
145
- $path_parts = pathinfo($filename);
146
-
147
- include_once(WPH_PATH . '/modules/' . $path_parts['basename']);
148
-
149
- $module_name = str_replace('module-' , '', $path_parts['filename']);
150
- $module_class_name = 'WPH_module_' . $module_name;
151
- $module = new $module_class_name;
152
-
153
- //action available for mu-plugins
154
- do_action('wp-hide/loaded_module', $module);
155
-
156
- $interface_menu_data = $module->get_interface_menu_data();
157
- $menu_position = $interface_menu_data['menu_position'];
158
-
159
- $this->modules[$menu_position] = $module;
160
-
161
- }
162
-
163
- //sort the modules array
164
- ksort($this->modules);
165
-
166
- $this->_modules_components_run();
167
-
168
- //filter available for mu-plugins
169
- $this->modules = apply_filters('wp-hide/loaded_modules', $this->modules);
170
-
171
- //sort the replacement urls ?? by the length
172
- //$keys = array_map('strlen', array_keys($arr));
173
- //array_multisort($keys, SORT_DESC, $arr);
174
-
175
- }
176
-
177
-
178
- /**
179
- * Runt the components of loaded modules
180
- *
181
- */
182
- function _modules_components_run()
183
- {
184
- foreach($this->modules as $module)
185
- {
186
- //process the module fields
187
- $module_settings = $this->functions->filter_settings( $module->get_module_settings(), TRUE );
188
-
189
- usort($module_settings, array($this->functions, 'array_sort_by_processing_order'));
190
-
191
-
192
- if($this->disable_filters || !is_array($module_settings) || count($module_settings) < 1)
193
- continue;
194
-
195
- foreach($module_settings as $module_setting)
196
- {
197
-
198
- $field_id = $module_setting['id'];
199
- $saved_field_value = isset($this->settings['module_settings'][ $field_id ]) ? $this->settings['module_settings'][ $field_id ] : '';
200
-
201
- $_class_instance = isset($module_setting['class_instance']) ? $module_setting['class_instance'] : $module;
202
-
203
- //ignore callbacks if permalink is turned OFF
204
- if($this->functions->is_permalink_enabled() && $this->permalinks_not_applied !== TRUE)
205
- {
206
- $_callback = isset($module_setting['callback']) ? $module_setting['callback'] : '';
207
- if(empty($_callback))
208
- $_callback = '_init_' . $field_id;
209
-
210
- if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
211
- $processing_data[] = call_user_func(array($_class_instance, $_callback), $saved_field_value);
212
- }
213
-
214
- //action available for mu-plugins
215
- do_action('wp-hide/module_settings_process', $field_id, $saved_field_value, $_class_instance, $module);
216
- }
217
-
218
- }
219
-
220
- }
221
-
222
-
223
-
224
- /**
225
- * run on admin_init action
226
- *
227
- */
228
- function admin_init()
229
- {
230
- //check for settings reset
231
- if($this->doing_reset_settings === TRUE)
232
- {
233
- $this->functions->reset_settings();
234
- }
235
-
236
- //check for interface submit
237
- if($this->doing_interface_save === TRUE)
238
- {
239
- $this->functions->process_interface_save();
240
- }
241
- }
242
-
243
-
244
- function admin_print_styles()
245
- {
246
-
247
- wp_register_style('WPHStyle', WPH_URL . '/css/wph.css');
248
- wp_enqueue_style( 'WPHStyle');
249
-
250
- }
251
-
252
-
253
- function admin_print_scripts()
254
- {
255
-
256
- wp_register_script('wph', WPH_URL . '/js/wph.js');
257
-
258
- // Localize the script with new data
259
- $translation_array = array(
260
- 'reset_confirmation' => __('Are you sure to reset all settings? All options will be removed.', 'wp-hide-security-enhancer')
261
- );
262
- wp_localize_script( 'wph', 'wph_vars', $translation_array );
263
-
264
- wp_enqueue_script( 'wph');
265
-
266
- }
267
-
268
-
269
- function admin_menus()
270
- {
271
- include_once(WPH_PATH . '/include/admin-interface.class.php');
272
-
273
- $this->admin_interface = new WPH_interface();
274
-
275
- $hookID = add_menu_page('WP Hide', 'WP Hide', 'manage_options', 'wp-hide');
276
-
277
- foreach($this->modules as $module)
278
- {
279
- $interface_menu_data = $module->get_interface_menu_data();
280
-
281
- $hookID = add_submenu_page( 'wp-hide', 'WP Hide', $interface_menu_data['menu_title'], 'manage_options', $interface_menu_data['menu_slug'], array($this->admin_interface,'_render'));
282
-
283
- add_action('admin_print_styles-' . $hookID , array($this, 'admin_print_styles'));
284
- add_action('admin_print_scripts-' . $hookID , array($this, 'admin_print_scripts'));
285
- }
286
-
287
- }
288
-
289
-
290
- function admin_notices()
291
- {
292
- global $wp_rewrite;
293
-
294
- //help nottice
295
- foreach($this->modules as $module)
296
- {
297
- $interface_menu_data = $module->get_interface_menu_data();
298
-
299
- if(isset($_GET['page']) && $_GET['page'] == $interface_menu_data['menu_slug'])
300
- echo "<div class='updated'><p>". __('Help us to improve this plugin by reporting any issues at ', 'wp-hide-security-enhancer') .'<a target="_blank" href="http://www.wp-hide.com/">www.wp-hide.com</a></p></div>';
301
- }
302
-
303
-
304
- //check for permalinks enabled
305
- if (!$this->functions->is_permalink_enabled())
306
- {
307
- echo "<div class='error'><p>". __('Permalink is required to be turned ON for WP Hide & Security Enhancer to work', 'wp-hide-security-enhancer') ."</p></div>";
308
- }
309
-
310
- //check if the htaccess file is not writable
311
- if(isset($this->settings['write_check_string']) && !empty($this->settings['write_check_string']))
312
- {
313
- $_write_check_string = $this->functions->get_write_check_string();
314
- if(empty($_write_check_string) || $_write_check_string != $this->settings['write_check_string'])
315
- {
316
- if($this->server_htaccess_config === TRUE)
317
- echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
318
-
319
- if($this->server_web_config === TRUE)
320
- echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
321
- }
322
- }
323
-
324
- if(isset($_GET['reset_settings']))
325
- {
326
- echo "<div class='updated'><p>". __('All Settings where restored to default', 'wp-hide-security-enhancer') ."</p></div>";
327
-
328
- $this->functions->settings_changed_check_for_cache_plugins();
329
- }
330
-
331
-
332
- if(isset($_GET['settings_updated']))
333
- {
334
-
335
- //check for write permision
336
- if($this->server_htaccess_config === TRUE && !$this->functions->is_writable_htaccess_config_file())
337
- echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
338
-
339
- if($this->server_web_config === TRUE && !$this->functions->is_writable_web_config_file())
340
- echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
341
-
342
- echo "<div class='updated'><p>". __('Settings saved', 'wp-hide-security-enhancer') ."</p></div>";
343
-
344
- $this->functions->settings_changed_check_for_cache_plugins();
345
- }
346
-
347
- }
348
-
349
- /**
350
- * Buffer Callback. This is the place to replace all data
351
- *
352
- * @param mixed $buffer
353
- */
354
- function ob_start_callback( $buffer )
355
- {
356
-
357
- //check headers fir content-encoding
358
- if(function_exists('apache_response_headers'))
359
- {
360
- $response_headers = apache_response_headers();
361
- }
362
- else
363
- {
364
- $response_headers = $this->functions->parseRequestHeaders();
365
- }
366
-
367
- if(isset($response_headers['Content-Encoding']) && $response_headers['Content-Encoding'] == "gzip")
368
- return $buffer;
369
-
370
- //replace the urls
371
- $buffer = $this->functions->text_urls_replacement($buffer, $this->urls_replacement);
372
-
373
- /*
374
- foreach ($this->urls_replacement as $key => $data)
375
- {
376
- $buffer .= "\n $key => $data";
377
- }
378
- */
379
-
380
- $buffer = apply_filters( 'wph/ob_start_callback', $buffer );
381
-
382
- return $buffer;
383
-
384
- }
385
-
386
- /**
387
- * check for any query and headers change
388
- *
389
- */
390
- function _action_wp()
391
- {
392
- if(!isset($_GET['throw_404']))
393
- return;
394
-
395
- global $wp_query;
396
-
397
- $wp_query->set_404();
398
- status_header(404);
399
-
400
- remove_action( 'template_redirect', 'wp_redirect_admin_locations', 999 );
401
-
402
- }
403
-
404
- /**
405
- * The plugin always need to load first to ensure filters are loading before anything else
406
- *
407
- */
408
- function activated_plugin($plugin, $network_wide)
409
- {
410
- if($network_wide)
411
- {
412
- $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
413
-
414
-
415
-
416
- //$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
417
-
418
- return;
419
- }
420
-
421
-
422
- $active_plugins = (array) get_option( 'active_plugins', array() );
423
-
424
- if(count($active_plugins) < 2)
425
- return;
426
-
427
- $plugin_path = 'wp-hide-security-enhancer/wp-hide.php';
428
-
429
- $key = array_search( $plugin_path, $active_plugins );
430
- if($key === FALSE || $key < 1)
431
- return;
432
-
433
- array_splice ( $active_plugins, $key, 1 );
434
- array_unshift ( $active_plugins, $plugin_path );
435
-
436
- update_option( 'active_plugins', $active_plugins );
437
-
438
- }
439
-
440
-
441
- function wp_redirect($location, $status)
442
- {
443
- if($this->uninstall === TRUE)
444
- return $location;
445
-
446
- $location = $this->functions->text_urls_replacement($location, $this->urls_replacement);
447
-
448
- return $location;
449
- }
450
-
451
- function logout_redirect($redirect_to, $requested_redirect_to, $user)
452
- {
453
- $new_wp_login_php = $this->functions->get_module_item_setting('new_wp_login_php' , 'admin');
454
- if (empty( $new_wp_login_php ))
455
- return $redirect_to;
456
-
457
- $redirect_to = str_replace('wp-login.php', $new_wp_login_php, $redirect_to);
458
-
459
- return $redirect_to;
460
- }
461
-
462
- function generic_string_replacement($text)
463
- {
464
- $text = $this->functions->text_urls_replacement($text, $this->urls_replacement);
465
-
466
- return $text;
467
-
468
- }
469
-
470
- function get_setting_value($setting_name, $default_value = '')
471
- {
472
- $setting_value = isset($this->settings['module_settings'][$setting_name]) ? $this->settings['module_settings'][$setting_name] : $default_value;
473
-
474
- return $setting_value;
475
- }
476
-
477
-
478
- function settings_changed()
479
- {
480
- //allow rewrite
481
- flush_rewrite_rules();
482
- }
483
-
484
- function mod_rewrite_rules( $rules )
485
- {
486
- if($this->uninstall === TRUE)
487
- return $rules;
488
-
489
- $processing_data = $this->get_components_rules();
490
-
491
- //post-process the htaccess data
492
- $_rewrite_data = array();
493
- $_page_refresh = FALSE;
494
- foreach($processing_data as $response)
495
- {
496
- if(isset($response['rewrite']) && !empty($response['rewrite']))
497
- {
498
- $_rewrite_data[] = $response['rewrite'];
499
- }
500
-
501
- if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
502
- $_page_refresh = TRUE;
503
- }
504
-
505
- $write_check_string = time() . '_' . mt_rand(100, 99999);
506
- $this->settings['write_check_string'] = $write_check_string;
507
- $this->functions->update_settings($this->settings);
508
-
509
- $new_rules = "RewriteRule ^index\.php$ - [L] \n\n#START - WP Hide & Security Enhancer\n#WriteCheckString:" . $write_check_string;
510
- $new_rules .= "\nSetEnv HTTP_MOD_REWRITE On";
511
- if(count($_rewrite_data) > 0)
512
- {
513
- foreach($_rewrite_data as $_htaccess_data_line)
514
- {
515
- $new_rules .= "\n" . $_htaccess_data_line;
516
- }
517
- }
518
-
519
- $new_rules .= "\n#END - WP Hide & Security Enhancer\n";
520
-
521
- $new_rules = apply_filters('wp-hide/mod_rewrite_rules', $new_rules);
522
-
523
- //update the main rule variable
524
- $rules = str_replace('RewriteRule ^index\\.php$ - [L]', $new_rules, $rules);
525
-
526
- return $rules;
527
-
528
- }
529
-
530
-
531
- function get_components_rules()
532
- {
533
-
534
- $processing_data = array();
535
-
536
- //loop all module settings and run the callback functions
537
- foreach($this->modules as $module)
538
- {
539
- $module_settings = $this->functions->filter_settings( $module->get_module_settings(), TRUE );
540
-
541
- //sort by processing order
542
- usort($module_settings, array($this->functions, 'array_sort_by_processing_order'));
543
-
544
- if(is_array($module_settings) && count($module_settings) > 0)
545
- foreach($module_settings as $module_setting)
546
- {
547
-
548
- $field_id = $module_setting['id'];
549
- $saved_field_value = isset($this->settings['module_settings'][ $field_id ]) ? $this->settings['module_settings'][ $field_id ] : '';
550
-
551
- $_class_instance = isset($module_setting['class_instance']) ? $module_setting['class_instance'] : $module;
552
- $_callback = isset($module_setting['callback_saved']) ? $module_setting['callback_saved'] : '';
553
- if(empty($_callback))
554
- $_callback = '_callback_saved_' . $field_id;
555
-
556
- if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
557
- {
558
- $module_mod_rewrite_rules = call_user_func(array($_class_instance, $_callback), $saved_field_value);
559
- $module_mod_rewrite_rules = apply_filters('wp-hide/module_mod_rewrite_rules', $module_mod_rewrite_rules, $_class_instance);
560
-
561
- $processing_data[] = $module_mod_rewrite_rules;
562
- }
563
-
564
- }
565
- }
566
-
567
-
568
- return $processing_data;
569
-
570
- }
571
-
572
-
573
- function iis7_url_rewrite_rules( $wp_rules )
574
- {
575
- $home_path = get_home_path();
576
- $web_config_file = $home_path . 'web.config';
577
-
578
- //delete all WPH rules
579
- $this->iis7_delete_rewrite_rules($web_config_file);
580
-
581
- if($this->uninstall === TRUE)
582
- return $wp_rules;
583
-
584
- $processing_data = $this->get_components_rules();
585
-
586
- //post-process the htaccess data
587
- $_rewrite_data = array();
588
- $_page_refresh = FALSE;
589
- foreach($processing_data as $response)
590
- {
591
- if(isset($response['rewrite']) && !empty($response['rewrite']))
592
- {
593
- $_rewrite_data[] = $response['rewrite'];
594
- }
595
-
596
- if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
597
- $_page_refresh = TRUE;
598
- }
599
-
600
- $write_check_string = time() . '_' . mt_rand(100, 99999);
601
- $this->settings['write_check_string'] = $write_check_string;
602
- $this->functions->update_settings($this->settings);
603
-
604
- //add a write stricng
605
- $_writestring_rule = '
606
- <rule name="wph-CheckString">
607
- <!-- WriteCheckString:'. $write_check_string .' -->
608
- </rule>';
609
- array_unshift($_rewrite_data, $_writestring_rule);
610
-
611
- $this->iis7_add_rewrite_rule( $_rewrite_data, $web_config_file );
612
-
613
- return $wp_rules;
614
-
615
- }
616
-
617
-
618
-
619
- /**
620
- * Add a rewrite rule within specified file
621
- *
622
- * @param mixed $filename
623
- */
624
- function iis7_add_rewrite_rule( $rules, $filename )
625
- {
626
-
627
- if (!is_array($rules) || count($rules) < 1)
628
- return false;
629
-
630
- if ( ! class_exists( 'DOMDocument', false ) ) {
631
- return false;
632
- }
633
-
634
- // If configuration file does not exist then we create one.
635
- if ( ! file_exists($filename) ) {
636
- $fp = fopen( $filename, 'w');
637
- fwrite($fp, '<configuration/>');
638
- fclose($fp);
639
- }
640
-
641
- $doc = new DOMDocument();
642
- $doc->preserveWhiteSpace = false;
643
-
644
- if ( $doc->load($filename) === false )
645
- return false;
646
-
647
- $xpath = new DOMXPath($doc);
648
-
649
- // Check the XPath to the rewrite rule and create XML nodes if they do not exist
650
- $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
651
- if ( $xmlnodes->length > 0 ) {
652
- $rules_node = $xmlnodes->item(0);
653
- } else {
654
- $rules_node = $doc->createElement('rules');
655
-
656
- $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
657
- if ( $xmlnodes->length > 0 ) {
658
- $rewrite_node = $xmlnodes->item(0);
659
- $rewrite_node->appendChild($rules_node);
660
- } else {
661
- $rewrite_node = $doc->createElement('rewrite');
662
- $rewrite_node->appendChild($rules_node);
663
-
664
- $xmlnodes = $xpath->query('/configuration/system.webServer');
665
- if ( $xmlnodes->length > 0 ) {
666
- $system_webServer_node = $xmlnodes->item(0);
667
- $system_webServer_node->appendChild($rewrite_node);
668
- } else {
669
- $system_webServer_node = $doc->createElement('system.webServer');
670
- $system_webServer_node->appendChild($rewrite_node);
671
-
672
- $xmlnodes = $xpath->query('/configuration');
673
- if ( $xmlnodes->length > 0 ) {
674
- $config_node = $xmlnodes->item(0);
675
- $config_node->appendChild($system_webServer_node);
676
- } else {
677
- $config_node = $doc->createElement('configuration');
678
- $doc->appendChild($config_node);
679
- $config_node->appendChild($system_webServer_node);
680
- }
681
- }
682
- }
683
- }
684
-
685
- //append before other rules
686
- $ref_node = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
687
-
688
- foreach($rules as $rule)
689
- {
690
- $rule_fragment = $doc->createDocumentFragment();
691
- $rule_fragment->appendXML($rule);
692
-
693
- if($ref_node->length > 0)
694
- $rules_node->insertBefore($rule_fragment, $ref_node->item(0));
695
- else
696
- $rules_node->appendChild($rule_fragment);
697
- }
698
-
699
- $doc->encoding = "UTF-8";
700
- $doc->formatOutput = true;
701
- saveDomDocument($doc, $filename);
702
-
703
- return true;
704
-
705
-
706
- }
707
-
708
-
709
-
710
- /**
711
- * Delete all wph rules within specified filename
712
- *
713
- * @param mixed $filename
714
- */
715
- function iis7_delete_rewrite_rules( $filename )
716
- {
717
-
718
- if ( ! file_exists($filename) )
719
- return true;
720
-
721
- if ( ! class_exists( 'DOMDocument', false ) ) {
722
- return false;
723
- }
724
-
725
- $doc = new DOMDocument();
726
- $doc->preserveWhiteSpace = false;
727
-
728
- if ( $doc -> load($filename) === false )
729
- return false;
730
- $xpath = new DOMXPath($doc);
731
- $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wph\')]');
732
- if ( $rules->length > 0 )
733
- {
734
-
735
- foreach($rules as $child)
736
- {
737
- $parent = $child->parentNode;
738
- $parent->removeChild($child);
739
- }
740
-
741
- $doc->formatOutput = true;
742
- saveDomDocument($doc, $filename);
743
- }
744
-
745
- return true;
746
-
747
- }
748
-
749
-
750
-
751
- function get_default_variables()
752
- {
753
- $this->default_variables['include_url'] = trailingslashit( site_url() ) . WPINC;
754
-
755
- $this->default_variables['template_url'] = get_bloginfo('template_url');
756
- $this->default_variables['stylesheet_uri'] = get_stylesheet_uri();
757
-
758
- $this->default_variables['plugins_url'] = plugins_url();
759
-
760
- $wp_upload_dir = wp_upload_dir();
761
- $this->default_variables['upload_url'] = $wp_upload_dir['baseurl'];
762
-
763
- //used across modules
764
- $this->default_variables['site_relative_path'] = $this->functions->get_url_path( trailingslashit( site_url() ));
765
-
766
- $template = get_template();
767
-
768
- $this->templates_data['use_child_theme'] = (get_option( 'stylesheet' ) != get_option( 'template' )) ? TRUE : FALSE;
769
- $this->templates_data['themes_url'] = trailingslashit( str_replace($template, "", get_bloginfo('template_url')) );
770
-
771
- $this->templates_data['main'] = array();
772
- $this->templates_data['main']['folder_name'] = $template;
773
- $this->templates_data['_template_' . $template] = 'main';
774
-
775
- if($this->templates_data['use_child_theme'])
776
- {
777
- $this->templates_data['child'] = array();
778
-
779
- $child_template = get_stylesheet();
780
- $this->templates_data['child']['folder_name'] = $child_template;
781
- $this->templates_data['_template_' . $child_template] = 'child';
782
- }
783
-
784
- //catch the absolute siteurl in case wp folder is different than domain root
785
- $this->default_variables['wordpress_directory'] = '';
786
- $this->default_variables['content_directory'] = '';
787
- $this->default_variables['plugins_directory'] = '';
788
-
789
-
790
- //content_directory
791
- $this->default_variables['content_directory'] = str_replace(ABSPATH, "", WP_CONTENT_DIR);
792
-
793
- $home_url = defined('WP_HOME') ? WP_HOME : get_option('home');
794
- $home_url = untrailingslashit($home_url);
795
-
796
- $siteurl = defined('WP_HOME') ? WP_SITEURL : get_option('siteurl');
797
- $siteurl = untrailingslashit($siteurl);
798
-
799
- $wp_directory = str_replace($home_url, "" , $siteurl);
800
- $wp_directory = trim(trim($wp_directory), '/');
801
-
802
- if($wp_directory != '')
803
- {
804
- $this->default_variables['wordpress_directory'] = $wp_directory;
805
-
806
- $domain_ABSPATH = str_replace($wp_directory, "", untrailingslashit( realpath( ABSPATH )));
807
-
808
- $content_directory = str_replace($domain_ABSPATH, "" , untrailingslashit( realpath( WP_CONTENT_DIR )));
809
- $this->default_variables['content_directory'] = $content_directory;
810
- }
811
-
812
- }
813
-
814
-
815
- /**
816
- * Apply new changes for e-mail content too
817
- *
818
- * @param mixed $atts
819
- */
820
- function apply_for_wp_mail($atts)
821
- {
822
-
823
- $atts['message'] = $this->functions->text_urls_replacement($atts['message'], $this->urls_replacement);
824
-
825
- return $atts;
826
-
827
- }
828
-
829
-
830
- /**
831
- * Add default Url Replacements
832
- *
833
- */
834
- function add_default_replacements()
835
- {
836
-
837
- do_action('wp-hide/add_default_replacements', $this->urls_replacement);
838
- }
839
-
840
-
841
- function switch_theme()
842
- {
843
- $this->disable_filters = TRUE;
844
- $this->get_default_variables();
845
-
846
- //allow rewrite
847
- flush_rewrite_rules();
848
-
849
- $this->disable_filters = FALSE;
850
- }
851
-
852
- function permalink_change_redirect()
853
- {
854
- $screen = get_current_screen();
855
-
856
- if(empty($screen))
857
- return;
858
-
859
- if($screen->base != "options-permalink")
860
- return;
861
-
862
- //recheck if the permalinks where sucesfully saved
863
- $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
864
-
865
- //ignore if permalinks are available
866
- if($this->permalinks_not_applied === TRUE)
867
- return;
868
-
869
- $new_location = trailingslashit( site_url() ) . "wp-admin/options-permalink.php";
870
-
871
- if($this->functions->is_permalink_enabled())
872
- {
873
- $new_admin_url = $this->functions->get_module_item_setting('admin_url' , 'admin');
874
- if(!empty($new_admin_url))
875
- $new_location = trailingslashit( site_url() ) . $new_admin_url . "/options-permalink.php";
876
- }
877
-
878
- $new_location .= '?settings-updated=true';
879
-
880
- //no need to redirect if it's on the same path
881
- $request_uri = $_SERVER['REQUEST_URI'];
882
-
883
- $new_location_uri = $this->functions->get_url_path($new_location, TRUE);
884
- if($request_uri == $new_location_uri)
885
- return;
886
-
887
- wp_redirect( $new_location );
888
- die();
889
- }
890
-
891
-
892
- /**
893
- * General Plugins Conflicts Handle
894
- *
895
- */
896
- function plugin_conflicts()
897
- {
898
-
899
- //w3-cache conflicts handle
900
- include_once(WPH_PATH . 'conflicts/w3-cache.php');
901
- WPH_conflict_handle_w3_cache::pagecache();
902
-
903
-
904
-
905
- }
906
-
907
-
908
-
909
- function log_save($text)
910
- {
911
-
912
- $myfile = fopen(WPH_PATH . "/debug.txt", "a") or die("Unable to open file!");
913
- $txt = $text . "\n";
914
- fwrite($myfile, $txt);
915
- fclose($myfile);
916
-
917
- }
918
-
919
-
920
- }
921
-
922
-
 
 
 
 
 
 
 
 
 
 
 
 
 
923
  ?>
1
+ <?php
2
+
3
+
4
+ class WPH
5
+ {
6
+ var $default_variables = array();
7
+ var $templates_data = array();
8
+ var $urls_replacement = array();
9
+
10
+ var $server_htaccess_config = FALSE;
11
+ var $server_web_config = FALSE;
12
+
13
+ var $modules = array();
14
+
15
+ var $settings;
16
+
17
+ var $functions;
18
+
19
+ var $disable_filters = FALSE;
20
+ var $permalinks_not_applied = FALSE;
21
+
22
+ var $doing_interface_save = FALSE;
23
+ var $doing_reset_settings = FALSE;
24
+
25
+ var $uninstall = FALSE;
26
+
27
+ var $is_initialised = FALSE;
28
+
29
+ var $conflicts = array();
30
+
31
+ function __construct()
32
+ {
33
+
34
+ }
35
+
36
+ function __destruct()
37
+ {
38
+
39
+ }
40
+
41
+
42
+ function init()
43
+ {
44
+ $this->functions = new WPH_functions();
45
+
46
+ $this->settings = $this->functions->get_settings();
47
+
48
+ //set the urls_replacement priority blocks
49
+ $this->urls_replacement['high'] = array();
50
+ $this->urls_replacement['normal'] = array();
51
+ $this->urls_replacement['low'] = array();
52
+
53
+ //check for plugin update
54
+ $this->update();
55
+
56
+ //set whatever the server use htaccess or web.config configuration file
57
+ $this->server_htaccess_config = $this->functions->server_use_htaccess_config_file();
58
+ $this->server_web_config = $this->functions->server_use_web_config_file();
59
+
60
+ //check for recovery link run
61
+ if(isset($_GET['wph-recovery']))
62
+ $this->functions->do_recovery();
63
+
64
+ //check for interface submit
65
+ if(is_admin() && isset($_POST['wph-interface-nonce']))
66
+ {
67
+ $this->doing_interface_save = TRUE;
68
+ $this->disable_filters = TRUE;
69
+ }
70
+
71
+ //check for reset setings
72
+ if(is_admin() && isset($_POST['reset-settings']))
73
+ {
74
+ $this->doing_reset_settings = TRUE;
75
+ $this->disable_filters = TRUE;
76
+ }
77
+
78
+ //check for permalink issues
79
+ $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
80
+
81
+ $this->get_default_variables();
82
+
83
+ $this->_load_modules();
84
+
85
+ $this->add_default_replacements();
86
+
87
+ /**
88
+ * Filters
89
+ */
90
+ add_action( 'activated_plugin', array($this, 'activated_plugin'), 999, 2 );
91
+
92
+ remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
93
+
94
+ add_action('plugins_loaded', array($this, 'plugin_conflicts') , -1);
95
+
96
+ //change any links within email message
97
+ add_filter('wp_mail', array($this, 'apply_for_wp_mail') , 999);
98
+
99
+ //process redirects
100
+ add_action('wp_redirect', array($this, 'wp_redirect') , 999, 2);
101
+ //hijack a redirect on permalink change
102
+ add_action('admin_head', array($this, 'permalink_change_redirect') , 999, 2);
103
+
104
+ add_action('logout_redirect', array($this, 'logout_redirect') , 999, 3);
105
+
106
+ add_action('wp', array($this, '_action_wp'));
107
+
108
+ add_action('admin_menu', array($this, 'admin_menus'));
109
+ add_action('admin_init', array($this, 'admin_init'), 11);
110
+
111
+
112
+ //rebuild and change uppon settings modified
113
+ add_action('wph/settings_changed', array($this, 'settings_changed'));
114
+
115
+ //apache
116
+ add_filter('mod_rewrite_rules', array($this, 'mod_rewrite_rules'), 999);
117
+ //IIS7 server
118
+ add_filter('iis7_url_rewrite_rules', array($this, 'iis7_url_rewrite_rules'), 999);
119
+
120
+ //on switch theme
121
+ add_action('switch_theme', array($this, 'switch_theme'));
122
+
123
+ //admin notices
124
+ add_action( 'admin_notices', array(&$this, 'admin_notices'));
125
+
126
+ $this->is_initialised = TRUE;
127
+ }
128
+
129
+
130
+ /**
131
+ * Update wrapper
132
+ *
133
+ */
134
+ function update()
135
+ {
136
+
137
+ //check for update from older version
138
+ include_once(WPH_PATH . '/include/update.class.php');
139
+ new WPH_update();
140
+
141
+ }
142
+
143
+ function _load_modules()
144
+ {
145
+
146
+ $module_files = glob(WPH_PATH . "/modules/module-*.php");
147
+
148
+ foreach ($module_files as $filename)
149
+ {
150
+ $path_parts = pathinfo($filename);
151
+
152
+ include_once(WPH_PATH . '/modules/' . $path_parts['basename']);
153
+
154
+ $module_name = str_replace('module-' , '', $path_parts['filename']);
155
+ $module_class_name = 'WPH_module_' . $module_name;
156
+ $module = new $module_class_name;
157
+
158
+ //action available for mu-plugins
159
+ do_action('wp-hide/loaded_module', $module);
160
+
161
+ $interface_menu_data = $module->get_interface_menu_data();
162
+ $menu_position = $interface_menu_data['menu_position'];
163
+
164
+ $this->modules[$menu_position] = $module;
165
+
166
+ }
167
+
168
+ //sort the modules array
169
+ ksort($this->modules);
170
+
171
+ $this->_modules_components_run();
172
+
173
+ //filter available for mu-plugins
174
+ $this->modules = apply_filters('wp-hide/loaded_modules', $this->modules);
175
+
176
+ //sort the replacement urls ?? by the length
177
+ //$keys = array_map('strlen', array_keys($arr));
178
+ //array_multisort($keys, SORT_DESC, $arr);
179
+
180
+ }
181
+
182
+
183
+ /**
184
+ * Runt the components of loaded modules
185
+ *
186
+ */
187
+ function _modules_components_run()
188
+ {
189
+ foreach($this->modules as $module)
190
+ {
191
+ //process the module fields
192
+ $module_settings = $this->functions->filter_settings( $module->get_module_settings(), TRUE );
193
+
194
+ usort($module_settings, array($this->functions, 'array_sort_by_processing_order'));
195
+
196
+
197
+ if($this->disable_filters || !is_array($module_settings) || count($module_settings) < 1)
198
+ continue;
199
+
200
+ foreach($module_settings as $module_setting)
201
+ {
202
+
203
+ $field_id = $module_setting['id'];
204
+ $saved_field_value = isset($this->settings['module_settings'][ $field_id ]) ? $this->settings['module_settings'][ $field_id ] : '';
205
+
206
+ $_class_instance = isset($module_setting['class_instance']) ? $module_setting['class_instance'] : $module;
207
+
208
+ //ignore callbacks if permalink is turned OFF
209
+ if($this->functions->is_permalink_enabled() && $this->permalinks_not_applied !== TRUE)
210
+ {
211
+ $_callback = isset($module_setting['callback']) ? $module_setting['callback'] : '';
212
+ if(empty($_callback))
213
+ $_callback = '_init_' . $field_id;
214
+
215
+ if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
216
+ $processing_data[] = call_user_func(array($_class_instance, $_callback), $saved_field_value);
217
+ }
218
+
219
+ //action available for mu-plugins
220
+ do_action('wp-hide/module_settings_process', $field_id, $saved_field_value, $_class_instance, $module);
221
+ }
222
+
223
+ }
224
+
225
+ }
226
+
227
+
228
+
229
+ /**
230
+ * run on admin_init action
231
+ *
232
+ */
233
+ function admin_init()
234
+ {
235
+ //check for settings reset
236
+ if($this->doing_reset_settings === TRUE)
237
+ {
238
+ $this->functions->reset_settings();
239
+ }
240
+
241
+ //check for interface submit
242
+ if($this->doing_interface_save === TRUE)
243
+ {
244
+ $this->functions->process_interface_save();
245
+ }
246
+ }
247
+
248
+
249
+ function admin_print_styles()
250
+ {
251
+
252
+ wp_register_style('WPHStyle', WPH_URL . '/css/wph.css');
253
+ wp_enqueue_style( 'WPHStyle');
254
+
255
+ }
256
+
257
+
258
+ function admin_print_scripts()
259
+ {
260
+
261
+ wp_register_script('wph', WPH_URL . '/js/wph.js');
262
+
263
+ // Localize the script with new data
264
+ $translation_array = array(
265
+ 'reset_confirmation' => __('Are you sure to reset all settings? All options will be removed.', 'wp-hide-security-enhancer')
266
+ );
267
+ wp_localize_script( 'wph', 'wph_vars', $translation_array );
268
+
269
+ wp_enqueue_script( 'wph');
270
+
271
+ }
272
+
273
+
274
+ function admin_menus()
275
+ {
276
+ include_once(WPH_PATH . '/include/admin-interface.class.php');
277
+
278
+ $this->admin_interface = new WPH_interface();
279
+
280
+ $hookID = add_menu_page('WP Hide', 'WP Hide', 'manage_options', 'wp-hide');
281
+
282
+ foreach($this->modules as $module)
283
+ {
284
+ $interface_menu_data = $module->get_interface_menu_data();
285
+
286
+ $hookID = add_submenu_page( 'wp-hide', 'WP Hide', $interface_menu_data['menu_title'], 'manage_options', $interface_menu_data['menu_slug'], array($this->admin_interface,'_render'));
287
+
288
+ add_action('admin_print_styles-' . $hookID , array($this, 'admin_print_styles'));
289
+ add_action('admin_print_scripts-' . $hookID , array($this, 'admin_print_scripts'));
290
+ }
291
+
292
+ }
293
+
294
+
295
+ function admin_notices()
296
+ {
297
+ global $wp_rewrite;
298
+
299
+
300
+ //check for permalinks enabled
301
+ if (!$this->functions->is_permalink_enabled())
302
+ {
303
+ echo "<div class='error'><p>". __('Permalink is required to be turned ON for WP Hide & Security Enhancer to work', 'wp-hide-security-enhancer') ."</p></div>";
304
+ }
305
+
306
+ //check if the htaccess file is not writable
307
+ if(isset($this->settings['write_check_string']) && !empty($this->settings['write_check_string']))
308
+ {
309
+ $_write_check_string = $this->functions->get_write_check_string();
310
+ if(empty($_write_check_string) || $_write_check_string != $this->settings['write_check_string'])
311
+ {
312
+ if($this->server_htaccess_config === TRUE)
313
+ echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
314
+
315
+ if($this->server_web_config === TRUE)
316
+ echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
317
+ }
318
+ }
319
+
320
+ if(isset($_GET['reset_settings']))
321
+ {
322
+ echo "<div class='updated'><p>". __('All Settings where restored to default', 'wp-hide-security-enhancer') ."</p></div>";
323
+
324
+ $this->functions->settings_changed_check_for_cache_plugins();
325
+ }
326
+
327
+
328
+ if(isset($_GET['settings_updated']))
329
+ {
330
+
331
+ //check for write permision
332
+ if($this->server_htaccess_config === TRUE && !$this->functions->is_writable_htaccess_config_file())
333
+ echo "<div class='error'><p>". __('Unable to write custom rules to your .htaccess. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
334
+
335
+ if($this->server_web_config === TRUE && !$this->functions->is_writable_web_config_file())
336
+ echo "<div class='error'><p>". __('Unable to write custom rules to your web.config. Is this file writable? <br />No mod is being applied.', 'wp-hide-security-enhancer') ."</p></div>";
337
+
338
+ echo "<div class='updated'><p>". __('Settings saved', 'wp-hide-security-enhancer') ."</p></div>";
339
+
340
+ $this->functions->settings_changed_check_for_cache_plugins();
341
+ }
342
+
343
+ }
344
+
345
+ /**
346
+ * Buffer Callback. This is the place to replace all data
347
+ *
348
+ * @param mixed $buffer
349
+ */
350
+ function ob_start_callback( $buffer )
351
+ {
352
+
353
+ //check headers fir content-encoding
354
+ if(function_exists('apache_response_headers'))
355
+ {
356
+ $response_headers = apache_response_headers();
357
+ }
358
+ else
359
+ {
360
+ $response_headers = $this->functions->parseRequestHeaders();
361
+ }
362
+
363
+ if(isset($response_headers['Content-Encoding']) && $response_headers['Content-Encoding'] == "gzip")
364
+ {
365
+ //Decodes the gzip compressed buffer
366
+ $decoded = gzdecode($buffer);
367
+ if($decoded === FALSE || $decoded == '')
368
+ return $buffer;
369
+
370
+ $buffer = $decoded;
371
+ }
372
+
373
+ //replace the urls
374
+ $buffer = $this->functions->content_urls_replacement($buffer, $this->functions->get_replacement_list() );
375
+
376
+ $buffer = apply_filters( 'wph/ob_start_callback', $buffer );
377
+
378
+ if(isset($response_headers['Content-Encoding']) && $response_headers['Content-Encoding'] == "gzip")
379
+ {
380
+ //Codes the buffer
381
+ $buffer = gzencode($buffer);
382
+ }
383
+
384
+ return $buffer;
385
+
386
+ }
387
+
388
+ /**
389
+ * check for any query and headers change
390
+ *
391
+ */
392
+ function _action_wp()
393
+ {
394
+ if(!isset($_GET['throw_404']))
395
+ return;
396
+
397
+ global $wp_query;
398
+
399
+ $wp_query->set_404();
400
+ status_header(404);
401
+
402
+ remove_action( 'template_redirect', 'wp_redirect_admin_locations', 999 );
403
+
404
+ }
405
+
406
+ /**
407
+ * The plugin always need to load first to ensure filters are loading before anything else
408
+ *
409
+ */
410
+ function activated_plugin($plugin, $network_wide)
411
+ {
412
+ if($network_wide)
413
+ {
414
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
415
+
416
+
417
+
418
+ //$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
419
+
420
+ return;
421
+ }
422
+
423
+
424
+ $active_plugins = (array) get_option( 'active_plugins', array() );
425
+
426
+ if(count($active_plugins) < 2)
427
+ return;
428
+
429
+ $plugin_path = 'wp-hide-security-enhancer/wp-hide.php';
430
+
431
+ $key = array_search( $plugin_path, $active_plugins );
432
+ if($key === FALSE || $key < 1)
433
+ return;
434
+
435
+ array_splice ( $active_plugins, $key, 1 );
436
+ array_unshift ( $active_plugins, $plugin_path );
437
+
438
+ update_option( 'active_plugins', $active_plugins );
439
+
440
+ }
441
+
442
+
443
+ function wp_redirect($location, $status)
444
+ {
445
+ if($this->uninstall === TRUE)
446
+ return $location;
447
+
448
+ //do not replace 404 pages
449
+ global $wp_the_query;
450
+ if($wp_the_query->is_404())
451
+ return $location;
452
+
453
+ $location = $this->functions->content_urls_replacement($location, $this->functions->get_replacement_list() );
454
+
455
+ return $location;
456
+ }
457
+
458
+ function logout_redirect($redirect_to, $requested_redirect_to, $user)
459
+ {
460
+ $new_wp_login_php = $this->functions->get_module_item_setting('new_wp_login_php' , 'admin');
461
+ if (empty( $new_wp_login_php ))
462
+ return $redirect_to;
463
+
464
+ $redirect_to = str_replace('wp-login.php', $new_wp_login_php, $redirect_to);
465
+
466
+ return $redirect_to;
467
+ }
468
+
469
+ function generic_string_replacement($text)
470
+ {
471
+ $text = $this->functions->content_urls_replacement($text, $this->functions->get_replacement_list() );
472
+
473
+ return $text;
474
+
475
+ }
476
+
477
+ function get_setting_value($setting_name, $default_value = '')
478
+ {
479
+ $setting_value = isset($this->settings['module_settings'][$setting_name]) ? $this->settings['module_settings'][$setting_name] : $default_value;
480
+
481
+ return $setting_value;
482
+ }
483
+
484
+
485
+ function settings_changed()
486
+ {
487
+ //allow rewrite
488
+ flush_rewrite_rules();
489
+ }
490
+
491
+ function mod_rewrite_rules( $rules )
492
+ {
493
+ if($this->uninstall === TRUE)
494
+ return $rules;
495
+
496
+ $processing_data = $this->get_components_rules();
497
+
498
+ //post-process the htaccess data
499
+ $_rewrite_data = array();
500
+ $_page_refresh = FALSE;
501
+ foreach($processing_data as $response)
502
+ {
503
+ if(isset($response['rewrite']) && !empty($response['rewrite']))
504
+ {
505
+ $_rewrite_data[] = $response['rewrite'];
506
+ }
507
+
508
+ if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
509
+ $_page_refresh = TRUE;
510
+ }
511
+
512
+ $write_check_string = time() . '_' . mt_rand(100, 99999);
513
+ $this->settings['write_check_string'] = $write_check_string;
514
+ $this->functions->update_settings($this->settings);
515
+
516
+ $new_rules = "RewriteRule ^index\.php$ - [L] \n\n#START - WP Hide & Security Enhancer\n#WriteCheckString:" . $write_check_string;
517
+ $new_rules .= "\n<IfModule mod_env.c>\nSetEnv HTTP_MOD_REWRITE On\n</IfModule>";
518
+ if(count($_rewrite_data) > 0)
519
+ {
520
+ foreach($_rewrite_data as $_htaccess_data_line)
521
+ {
522
+ $new_rules .= "\n" . $_htaccess_data_line;
523
+ }
524
+ }
525
+
526
+ $new_rules .= "\n#END - WP Hide & Security Enhancer\n";
527
+
528
+ $new_rules = apply_filters('wp-hide/mod_rewrite_rules', $new_rules);
529
+
530
+ //update the main rule variable
531
+ $rules = str_replace('RewriteRule ^index\\.php$ - [L]', $new_rules, $rules);
532
+
533
+ return $rules;
534
+
535
+ }
536
+
537
+
538
+ function get_components_rules()
539
+ {
540
+
541
+ $processing_data = array();
542
+
543
+ //loop all module settings and run the callback functions
544
+ foreach($this->modules as $module)
545
+ {
546
+ $module_settings = $this->functions->filter_settings( $module->get_module_settings(), TRUE );
547
+
548
+ //sort by processing order
549
+ usort($module_settings, array($this->functions, 'array_sort_by_processing_order'));
550
+
551
+ if(is_array($module_settings) && count($module_settings) > 0)
552
+ foreach($module_settings as $module_setting)
553
+ {
554
+
555
+ $field_id = $module_setting['id'];
556
+ $saved_field_value = isset($this->settings['module_settings'][ $field_id ]) ? $this->settings['module_settings'][ $field_id ] : '';
557
+
558
+ $_class_instance = isset($module_setting['class_instance']) ? $module_setting['class_instance'] : $module;
559
+ $_callback = isset($module_setting['callback_saved']) ? $module_setting['callback_saved'] : '';
560
+ if(empty($_callback))
561
+ $_callback = '_callback_saved_' . $field_id;
562
+
563
+ if (method_exists($_class_instance, $_callback) && is_callable(array($_class_instance, $_callback)))
564
+ {
565
+ $module_mod_rewrite_rules = call_user_func(array($_class_instance, $_callback), $saved_field_value);
566
+ $module_mod_rewrite_rules = apply_filters('wp-hide/module_mod_rewrite_rules', $module_mod_rewrite_rules, $_class_instance);
567
+
568
+ $processing_data[] = $module_mod_rewrite_rules;
569
+ }
570
+
571
+ }
572
+ }
573
+
574
+
575
+ return $processing_data;
576
+
577
+ }
578
+
579
+
580
+ function iis7_url_rewrite_rules( $wp_rules )
581
+ {
582
+ $home_path = get_home_path();
583
+ $web_config_file = $home_path . 'web.config';
584
+
585
+ //delete all WPH rules
586
+ $this->iis7_delete_rewrite_rules($web_config_file);
587
+
588
+ if($this->uninstall === TRUE)
589
+ return $wp_rules;
590
+
591
+ $processing_data = $this->get_components_rules();
592
+
593
+ //post-process the htaccess data
594
+ $_rewrite_data = array();
595
+ $_page_refresh = FALSE;
596
+ foreach($processing_data as $response)
597
+ {
598
+ if(isset($response['rewrite']) && !empty($response['rewrite']))
599
+ {
600
+ $_rewrite_data[] = $response['rewrite'];
601
+ }
602
+
603
+ if(isset($response['page_refresh']) && $response['page_refresh'] === TRUE)
604
+ $_page_refresh = TRUE;
605
+ }
606
+
607
+ $write_check_string = time() . '_' . mt_rand(100, 99999);
608
+ $this->settings['write_check_string'] = $write_check_string;
609
+ $this->functions->update_settings($this->settings);
610
+
611
+ //add a write stricng
612
+ $_writestring_rule = '
613
+ <rule name="wph-CheckString">
614
+ <!-- WriteCheckString:'. $write_check_string .' -->
615
+ </rule>';
616
+ array_unshift($_rewrite_data, $_writestring_rule);
617
+
618
+ $this->iis7_add_rewrite_rule( $_rewrite_data, $web_config_file );
619
+
620
+ return $wp_rules;
621
+
622
+ }
623
+
624
+
625
+
626
+ /**
627
+ * Add a rewrite rule within specified file
628
+ *
629
+ * @param mixed $filename
630
+ */
631
+ function iis7_add_rewrite_rule( $rules, $filename )
632
+ {
633
+
634
+ if (!is_array($rules) || count($rules) < 1)
635
+ return false;
636
+
637
+ if ( ! class_exists( 'DOMDocument', false ) ) {
638
+ return false;
639
+ }
640
+
641
+ // If configuration file does not exist then we create one.
642
+ if ( ! file_exists($filename) ) {
643
+ $fp = fopen( $filename, 'w');
644
+ fwrite($fp, '<configuration/>');
645
+ fclose($fp);
646
+ }
647
+
648
+ $doc = new DOMDocument();
649
+ $doc->preserveWhiteSpace = false;
650
+
651
+ if ( $doc->load($filename) === false )
652
+ return false;
653
+
654
+ $xpath = new DOMXPath($doc);
655
+
656
+ // Check the XPath to the rewrite rule and create XML nodes if they do not exist
657
+ $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite/rules');
658
+ if ( $xmlnodes->length > 0 ) {
659
+ $rules_node = $xmlnodes->item(0);
660
+ } else {
661
+ $rules_node = $doc->createElement('rules');
662
+
663
+ $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
664
+ if ( $xmlnodes->length > 0 ) {
665
+ $rewrite_node = $xmlnodes->item(0);
666
+ $rewrite_node->appendChild($rules_node);
667
+ } else {
668
+ $rewrite_node = $doc->createElement('rewrite');
669
+ $rewrite_node->appendChild($rules_node);
670
+
671
+ $xmlnodes = $xpath->query('/configuration/system.webServer');
672
+ if ( $xmlnodes->length > 0 ) {
673
+ $system_webServer_node = $xmlnodes->item(0);
674
+ $system_webServer_node->appendChild($rewrite_node);
675
+ } else {
676
+ $system_webServer_node = $doc->createElement('system.webServer');
677
+ $system_webServer_node->appendChild($rewrite_node);
678
+
679
+ $xmlnodes = $xpath->query('/configuration');
680
+ if ( $xmlnodes->length > 0 ) {
681
+ $config_node = $xmlnodes->item(0);
682
+ $config_node->appendChild($system_webServer_node);
683
+ } else {
684
+ $config_node = $doc->createElement('configuration');
685
+ $doc->appendChild($config_node);
686
+ $config_node->appendChild($system_webServer_node);
687
+ }
688
+ }
689
+ }
690
+ }
691
+
692
+ //append before other rules
693
+ $ref_node = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
694
+
695
+ foreach($rules as $rule)
696
+ {
697
+ $rule_fragment = $doc->createDocumentFragment();
698
+ $rule_fragment->appendXML($rule);
699
+
700
+ if($ref_node->length > 0)
701
+ $rules_node->insertBefore($rule_fragment, $ref_node->item(0));
702
+ else
703
+ $rules_node->appendChild($rule_fragment);
704
+ }
705
+
706
+ $doc->encoding = "UTF-8";
707
+ $doc->formatOutput = true;
708
+ saveDomDocument($doc, $filename);
709
+
710
+ return true;
711
+
712
+
713
+ }
714
+
715
+
716
+
717
+ /**
718
+ * Delete all wph rules within specified filename
719
+ *
720
+ * @param mixed $filename
721
+ */
722
+ function iis7_delete_rewrite_rules( $filename )
723
+ {
724
+
725
+ if ( ! file_exists($filename) )
726
+ return true;
727
+
728
+ if ( ! class_exists( 'DOMDocument', false ) ) {
729
+ return false;
730
+ }
731
+
732
+ $doc = new DOMDocument();
733
+ $doc->preserveWhiteSpace = false;
734
+
735
+ if ( $doc -> load($filename) === false )
736
+ return false;
737
+ $xpath = new DOMXPath($doc);
738
+ $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wph\')]');
739
+ if ( $rules->length > 0 )
740
+ {
741
+
742
+ foreach($rules as $child)
743
+ {
744
+ $parent = $child->parentNode;
745
+ $parent->removeChild($child);
746
+ }
747
+
748
+ $doc->formatOutput = true;
749
+ saveDomDocument($doc, $filename);
750
+ }
751
+
752
+ return true;
753
+
754
+ }
755
+
756
+
757
+
758
+ function get_default_variables()
759
+ {
760
+ $this->default_variables['include_url'] = trailingslashit( site_url() ) . WPINC;
761
+
762
+ $this->default_variables['template_url'] = get_bloginfo('template_url');
763
+ $this->default_variables['stylesheet_uri'] = get_stylesheet_directory_uri();
764
+
765
+ $this->default_variables['plugins_url'] = plugins_url();
766
+
767
+ $wp_upload_dir = wp_upload_dir();
768
+ $this->default_variables['upload_url'] = $wp_upload_dir['baseurl'];
769
+
770
+ //used across modules
771
+ $this->default_variables['site_relative_path'] = $this->functions->get_url_path( trailingslashit( site_url() ));
772
+
773
+ //themes url
774
+ $this->templates_data['themes_url'] = trailingslashit( get_theme_root_uri() );
775
+
776
+ $all_templates = $this->functions->get_themes();
777
+ $all_templates = $this->functions->parse_themes_headers($all_templates);
778
+
779
+ $stylesheet = get_option( 'stylesheet' );
780
+
781
+ $this->templates_data['use_child_theme'] = $this->functions->is_child_theme($stylesheet, $all_templates);
782
+
783
+ $main_theme_directory = $this->functions->get_main_theme_directory($stylesheet, $all_templates);
784
+ $this->templates_data['main'] = array();
785
+ $this->templates_data['main']['folder_name'] = $main_theme_directory;
786
+ $this->templates_data['_template_' . $main_theme_directory] = 'main';
787
+
788
+ if($this->templates_data['use_child_theme'])
789
+ {
790
+ $this->templates_data['child'] = array();
791
+ $this->templates_data['child']['folder_name'] = $stylesheet;
792
+ $this->templates_data['_template_' . $stylesheet] = 'child';
793
+ }
794
+
795
+ //catch the absolute siteurl in case wp folder is different than domain root
796
+ $this->default_variables['wordpress_directory'] = '';
797
+ $this->default_variables['content_directory'] = '';
798
+ $this->default_variables['plugins_directory'] = '';
799
+
800
+
801
+ //content_directory
802
+ $this->default_variables['content_directory'] = str_replace(ABSPATH, "", WP_CONTENT_DIR);
803
+
804
+ $home_url = defined('WP_HOME') ? WP_HOME : get_option('home');
805
+ $home_url = untrailingslashit($home_url);
806
+
807
+ $siteurl = defined('WP_HOME') ? WP_SITEURL : get_option('siteurl');
808
+ $siteurl = untrailingslashit($siteurl);
809
+
810
+ $wp_directory = str_replace($home_url, "" , $siteurl);
811
+ $wp_directory = trim(trim($wp_directory), '/');
812
+
813
+ if($wp_directory != '')
814
+ {
815
+ $this->default_variables['wordpress_directory'] = $wp_directory;
816
+
817
+ $domain_ABSPATH = str_replace($wp_directory, "", untrailingslashit( realpath( ABSPATH )));
818
+
819
+ $content_directory = str_replace($domain_ABSPATH, "" , untrailingslashit( realpath( WP_CONTENT_DIR )));
820
+ $this->default_variables['content_directory'] = $content_directory;
821
+ }
822
+
823
+ }
824
+
825
+
826
+ /**
827
+ * Apply new changes for e-mail content too
828
+ *
829
+ * @param mixed $atts
830
+ */
831
+ function apply_for_wp_mail($atts)
832
+ {
833
+
834
+ $atts['message'] = $this->functions->content_urls_replacement($atts['message'], $this->functions->get_replacement_list() );
835
+
836
+ return $atts;
837
+
838
+ }
839
+
840
+
841
+ /**
842
+ * Add default Url Replacements
843
+ *
844
+ */
845
+ function add_default_replacements()
846
+ {
847
+
848
+ do_action('wp-hide/add_default_replacements', $this->urls_replacement);
849
+ }
850
+
851
+
852
+ function switch_theme()
853
+ {
854
+ $this->disable_filters = TRUE;
855
+ $this->get_default_variables();
856
+
857
+ //allow rewrite
858
+ flush_rewrite_rules();
859
+
860
+ $this->disable_filters = FALSE;
861
+ }
862
+
863
+ function permalink_change_redirect()
864
+ {
865
+ $screen = get_current_screen();
866
+
867
+ if(empty($screen))
868
+ return;
869
+
870
+ if($screen->base != "options-permalink")
871
+ return;
872
+
873
+ //recheck if the permalinks where sucesfully saved
874
+ $this->permalinks_not_applied = ! $this->functions->rewrite_rules_applied();
875
+
876
+ //ignore if permalinks are available
877
+ if($this->permalinks_not_applied === TRUE)
878
+ return;
879
+
880
+ $new_location = trailingslashit( site_url() ) . "wp-admin/options-permalink.php";
881
+
882
+ if($this->functions->is_permalink_enabled())
883
+ {
884
+ $new_admin_url = $this->functions->get_module_item_setting('admin_url' , 'admin');
885
+ if(!empty($new_admin_url))
886
+ $new_location = trailingslashit( site_url() ) . $new_admin_url . "/options-permalink.php";
887
+ }
888
+
889
+ $new_location .= '?settings-updated=true';
890
+
891
+ //no need to redirect if it's on the same path
892
+ $request_uri = $_SERVER['REQUEST_URI'];
893
+
894
+ $new_location_uri = $this->functions->get_url_path($new_location, TRUE);
895
+ if($request_uri == $new_location_uri)
896
+ return;
897
+
898
+ wp_redirect( $new_location );
899
+ die();
900
+ }
901
+
902
+
903
+ /**
904
+ * General Plugins Conflicts Handle
905
+ *
906
+ */
907
+ function plugin_conflicts()
908
+ {
909
+
910
+ //w3-cache conflicts handle
911
+ include_once(WPH_PATH . 'conflicts/w3-cache.php');
912
+ WPH_conflict_handle_w3_cache::pagecache();
913
+
914
+ //super-cache conflicts handle
915
+ include_once(WPH_PATH . 'conflicts/super-cache.php');
916
+ WPH_conflict_handle_super_cache::init();
917
+
918
+ }
919
+
920
+
921
+
922
+ function log_save($text)
923
+ {
924
+
925
+ $myfile = fopen(WPH_PATH . "/debug.txt", "a") or die("Unable to open file!");
926
+ $txt = $text . "\n";
927
+ fwrite($myfile, $txt);
928
+ fclose($myfile);
929
+
930
+ }
931
+
932
+
933
+ }
934
+
935
+
936
  ?>
languages/wp-hide-security-enhancer.mo CHANGED
Binary file
languages/wp-hide-security-enhancer.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Post Types Order\n"
4
- "POT-Creation-Date: 2016-04-01 14:34+0200\n"
5
- "PO-Revision-Date: 2016-04-01 14:34+0200\n"
6
  "Last-Translator: nsp-code <electronice_delphi@yahoo.com>\n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
@@ -20,34 +20,63 @@ msgid ""
20
  "Login Url change. "
21
  msgstr ""
22
 
23
- #: include/functions.class.php:1025
 
 
 
 
 
 
 
 
 
 
 
 
24
  #, php-format
25
  msgid "The %1$s plugin header is deprecated. Use %2$s instead."
26
  msgstr ""
27
 
28
- #: include/wph.class.php:198
29
- msgid "Help us to improve this plugin by reporting any issues at "
 
 
30
  msgstr ""
31
 
32
- #: include/wph.class.php:203
33
  msgid ""
34
- "Permalink is required to be turned ON for WP Hide & Security Enhancer to work"
 
 
35
  msgstr ""
36
 
37
- #: include/wph.class.php:208
38
- msgid "Settings saved"
39
  msgstr ""
40
 
41
- #: include/wph.class.php:215
42
  msgid ""
43
- "W3 Total Cache Plugin is active, make sure you clear the cache for new "
44
- "changes to apply"
45
  msgstr ""
46
 
47
- #: include/wph.class.php:219
48
  msgid ""
49
- "WP Super Cache Plugin is active, make sure you clear the cache for new "
50
- "changes to apply"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  msgstr ""
52
 
53
  #: modules/module-admin.php:44
@@ -58,19 +87,19 @@ msgstr ""
58
  msgid "WP Hide & Security Enhancer - Admin"
59
  msgstr ""
60
 
61
- #: modules/module-general.php:41
62
  msgid "General / Html"
63
  msgstr ""
64
 
65
- #: modules/module-general.php:53
66
  msgid "WP Hide & Security Enhancer - General / Html"
67
  msgstr ""
68
 
69
- #: modules/module-rewrite.php:61 modules/module-rewrite.php:72
70
  msgid "Rewrite"
71
  msgstr ""
72
 
73
- #: modules/module-rewrite.php:72
74
  msgid "WP Hide & Security Enhancer"
75
  msgstr ""
76
 
@@ -103,75 +132,101 @@ msgstr ""
103
 
104
  #: modules/components/admin-admin_url.php:35
105
  #: modules/components/admin-new_wp_login_php.php:34
106
- #: modules/components/general-meta.php:15
107
- #: modules/components/general-meta.php:31
108
- #: modules/components/general-meta.php:48
109
- #: modules/components/general-meta.php:64
110
- #: modules/components/general-meta.php:82
111
- #: modules/components/general-meta.php:98
112
- #: modules/components/general-meta.php:114
113
- #: modules/components/general-remove_version.php:15
114
- #: modules/components/general-wpemoji.php:15
115
- #: modules/components/general-wpemoji.php:31
 
 
 
 
 
 
 
116
  #: modules/components/rewrite-new_include_path.php:32
117
  #: modules/components/rewrite-new_plugin_path.php:33
 
 
118
  #: modules/components/rewrite-new_upload_path.php:33
119
  #: modules/components/rewrite-new_xml-rpc-path.php:32
120
  #: modules/components/rewrite-new_xml-rpc-path.php:49
121
- #: modules/components/rewrite-root-files.php:20
122
- #: modules/components/rewrite-root-files.php:36
123
- #: modules/components/rewrite-root-files.php:52
124
- #: modules/components/rewrite-root-files.php:68
125
- #: modules/components/rewrite-root-files.php:85
 
 
 
 
126
  #: modules/components/rewrite-wp_content_path.php:34
127
  msgid "Yes"
128
  msgstr ""
129
 
130
  #: modules/components/admin-admin_url.php:36
131
  #: modules/components/admin-new_wp_login_php.php:35
132
- #: modules/components/general-meta.php:16
133
- #: modules/components/general-meta.php:32
134
- #: modules/components/general-meta.php:49
135
- #: modules/components/general-meta.php:65
136
- #: modules/components/general-meta.php:83
137
- #: modules/components/general-meta.php:99
138
- #: modules/components/general-meta.php:115
139
- #: modules/components/general-remove_version.php:16
140
- #: modules/components/general-wpemoji.php:16
141
- #: modules/components/general-wpemoji.php:32
 
 
 
 
 
 
 
142
  #: modules/components/rewrite-new_include_path.php:33
143
  #: modules/components/rewrite-new_plugin_path.php:34
 
 
144
  #: modules/components/rewrite-new_upload_path.php:34
145
  #: modules/components/rewrite-new_xml-rpc-path.php:33
146
  #: modules/components/rewrite-new_xml-rpc-path.php:50
147
- #: modules/components/rewrite-root-files.php:21
148
- #: modules/components/rewrite-root-files.php:37
149
- #: modules/components/rewrite-root-files.php:53
150
- #: modules/components/rewrite-root-files.php:69
151
- #: modules/components/rewrite-root-files.php:86
 
 
 
 
152
  #: modules/components/rewrite-wp_content_path.php:35
153
  msgid "No"
154
  msgstr ""
155
 
156
- #: modules/components/admin-admin_url.php:187
157
  msgid "Hello"
158
  msgstr ""
159
 
160
- #: modules/components/admin-admin_url.php:188
161
  msgid ""
162
  "This is an automated message to inform that your login url has been changed "
163
  "at"
164
  msgstr ""
165
 
166
- #: modules/components/admin-admin_url.php:189
167
  msgid "The new login url is"
168
  msgstr ""
169
 
170
- #: modules/components/admin-admin_url.php:190
171
  msgid "Additionality you can use this to recover the old login / admin links "
172
  msgstr ""
173
 
174
- #: modules/components/admin-admin_url.php:191
175
  msgid "Please keep this url safe for recover, if forgot"
176
  msgstr ""
177
 
@@ -192,44 +247,81 @@ msgstr ""
192
  msgid "Block default wp-login.php file from being accesible."
193
  msgstr ""
194
 
195
- #: modules/components/general-meta.php:11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  msgid ""
197
  "Remove the autogenerated meta generator tag within head (WordPress Version)."
198
  msgstr ""
199
 
200
- #: modules/components/general-meta.php:27
201
  msgid "Remove the wlwmanifest tag within head."
202
  msgstr ""
203
 
204
- #: modules/components/general-meta.php:44
205
  msgid "Remove the feed_links tag within head."
206
  msgstr ""
207
 
208
- #: modules/components/general-meta.php:60
209
  msgid "Remove the rsd_link tag within head."
210
  msgstr ""
211
 
212
- #: modules/components/general-meta.php:78
213
  msgid "Remove the adjacent_posts_rel tag within head."
214
  msgstr ""
215
 
216
- #: modules/components/general-meta.php:94
217
  msgid "Remove profile link meta tag within head."
218
  msgstr ""
219
 
220
- #: modules/components/general-meta.php:110
221
  msgid "Remove canonical link meta tag within head."
222
  msgstr ""
223
 
224
- #: modules/components/general-remove_version.php:11
225
- msgid "Remove version number from enqueued style and script files."
 
 
 
 
 
 
 
 
226
  msgstr ""
227
 
228
- #: modules/components/general-wpemoji.php:11
229
  msgid "Disable the Emoji icon library from being loaded."
230
  msgstr ""
231
 
232
- #: modules/components/general-wpemoji.php:27
233
  msgid "Disable the TinyMC Emoji icons library from being loaded into TinyMC."
234
  msgstr ""
235
 
@@ -239,14 +331,14 @@ msgstr ""
239
 
240
  #: modules/components/rewrite-new_include_path.php:16
241
  #: modules/components/rewrite-new_theme_path.php:17
242
- #: modules/components/rewrite-new_theme_path.php:32
243
  msgid "The default theme path is set to"
244
  msgstr ""
245
 
246
  #: modules/components/rewrite-new_include_path.php:17
247
  #: modules/components/rewrite-new_plugin_path.php:17
248
  #: modules/components/rewrite-new_theme_path.php:18
249
- #: modules/components/rewrite-new_theme_path.php:33
250
  #: modules/components/rewrite-new_upload_path.php:17
251
  #: modules/components/rewrite-wp_content_path.php:16
252
  msgid "More details can be found at"
@@ -273,11 +365,13 @@ msgid "Block plugins files from being accesible through default urls."
273
  msgstr ""
274
 
275
  #: modules/components/rewrite-new_plugin_path.php:29
 
276
  msgid "Apply only if "
277
  msgstr ""
278
 
279
  #: modules/components/rewrite-new_plugin_path.php:29
280
  #: modules/components/rewrite-new_upload_path.php:29
 
281
  msgid "is not empty."
282
  msgstr ""
283
 
@@ -309,24 +403,65 @@ msgstr ""
309
  msgid "e.g. my_template"
310
  msgstr ""
311
 
 
 
 
 
312
  #: modules/components/rewrite-new_theme_path.php:31
313
- msgid "New Theme Child Path"
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  msgstr ""
315
 
316
  #: modules/components/rewrite-new_theme_path.php:35
317
- msgid "e.g. my_child_template"
 
318
  msgstr ""
319
 
320
  #: modules/components/rewrite-new_theme_path.php:45
321
- msgid "New Style File Path"
322
  msgstr ""
323
 
324
  #: modules/components/rewrite-new_theme_path.php:46
325
- msgid "The default theme style file style.css path is set to"
 
 
 
 
326
  msgstr ""
327
 
328
- #: modules/components/rewrite-new_theme_path.php:48
329
- msgid "e.g. custom-style-file.css"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  msgstr ""
331
 
332
  #: modules/components/rewrite-new_upload_path.php:15
@@ -386,34 +521,60 @@ msgid ""
386
  msgstr ""
387
 
388
  #: modules/components/rewrite-new_xml-rpc-path.php:44
389
- msgid "Remove pingback"
390
  msgstr ""
391
 
392
  #: modules/components/rewrite-new_xml-rpc-path.php:45
 
 
 
 
 
 
 
 
 
 
393
  msgid "Remove pingback link tag from theme."
394
  msgstr ""
395
 
396
  #: modules/components/rewrite-root-files.php:15
397
- msgid "Block license.txt"
398
  msgstr ""
399
 
400
  #: modules/components/rewrite-root-files.php:16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  msgid "Block access to license.txt root file"
402
  msgstr ""
403
 
404
- #: modules/components/rewrite-root-files.php:31
405
  msgid "Block readme.html"
406
  msgstr ""
407
 
408
- #: modules/components/rewrite-root-files.php:32
409
  msgid "Block access to readme.html root file"
410
  msgstr ""
411
 
412
- #: modules/components/rewrite-root-files.php:47
413
  msgid "Block wp-activate.php"
414
  msgstr ""
415
 
416
- #: modules/components/rewrite-root-files.php:48
417
  msgid ""
418
  "Block access to wp-activate.php file. This file confirms that the activation "
419
  "key that is sent in an email after a user signs up for a new blog matches "
@@ -421,13 +582,23 @@ msgid ""
421
  "keep this off."
422
  msgstr ""
423
 
424
- #: modules/components/rewrite-root-files.php:64
 
 
 
 
 
 
 
 
 
 
425
  msgid ""
426
  "Block default wp-signup.php file. If <b>anyone can register</b> on your "
427
  "site, you shold keep this off."
428
  msgstr ""
429
 
430
- #: modules/components/rewrite-root-files.php:81
431
  msgid ""
432
  "Block other wp-*.php files. E.g. wp-blog-header.php, wp-config.php, wp-cron."
433
  "php. Those files are used internally, blocking those will not affect any "
@@ -435,6 +606,21 @@ msgid ""
435
  "php) are ignored, they can be controlled through own setting."
436
  msgstr ""
437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  #: modules/components/rewrite-wp_content_path.php:14
439
  msgid "New Content Path"
440
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Post Types Order\n"
4
+ "POT-Creation-Date: 2016-07-13 10:42+0200\n"
5
+ "PO-Revision-Date: 2016-07-13 10:42+0200\n"
6
  "Last-Translator: nsp-code <electronice_delphi@yahoo.com>\n"
7
  "Language-Team: \n"
8
  "MIME-Version: 1.0\n"
20
  "Login Url change. "
21
  msgstr ""
22
 
23
+ #: include/functions.class.php:221
24
+ msgid ""
25
+ "W3 Total Cache Plugin is active, make sure you clear the cache for new "
26
+ "changes to apply"
27
+ msgstr ""
28
+
29
+ #: include/functions.class.php:225
30
+ msgid ""
31
+ "WP Super Cache Plugin is active, make sure you clear the cache for new "
32
+ "changes to apply"
33
+ msgstr ""
34
+
35
+ #: include/functions.class.php:1436
36
  #, php-format
37
  msgid "The %1$s plugin header is deprecated. Use %2$s instead."
38
  msgstr ""
39
 
40
+ #: include/functions.class.php:1642
41
+ msgid ""
42
+ "Help us to improve this plugin by sending any improvement suggestions and "
43
+ "reporting any issues at "
44
  msgstr ""
45
 
46
+ #: include/functions.class.php:1643
47
  msgid ""
48
+ "Did you find this plugin useful? Please support our work by spread the word "
49
+ "about this, or write an article about the plugin in your blog with a link to "
50
+ "development site"
51
  msgstr ""
52
 
53
+ #: include/wph.class.php:265
54
+ msgid "Are you sure to reset all settings? All options will be removed."
55
  msgstr ""
56
 
57
+ #: include/wph.class.php:303
58
  msgid ""
59
+ "Permalink is required to be turned ON for WP Hide & Security Enhancer to work"
 
60
  msgstr ""
61
 
62
+ #: include/wph.class.php:313 include/wph.class.php:333
63
  msgid ""
64
+ "Unable to write custom rules to your .htaccess. Is this file writable? <br /"
65
+ ">No mod is being applied."
66
+ msgstr ""
67
+
68
+ #: include/wph.class.php:316 include/wph.class.php:336
69
+ msgid ""
70
+ "Unable to write custom rules to your web.config. Is this file writable? <br /"
71
+ ">No mod is being applied."
72
+ msgstr ""
73
+
74
+ #: include/wph.class.php:322
75
+ msgid "All Settings where restored to default"
76
+ msgstr ""
77
+
78
+ #: include/wph.class.php:338
79
+ msgid "Settings saved"
80
  msgstr ""
81
 
82
  #: modules/module-admin.php:44
87
  msgid "WP Hide & Security Enhancer - Admin"
88
  msgstr ""
89
 
90
+ #: modules/module-general.php:56
91
  msgid "General / Html"
92
  msgstr ""
93
 
94
+ #: modules/module-general.php:68
95
  msgid "WP Hide & Security Enhancer - General / Html"
96
  msgstr ""
97
 
98
+ #: modules/module-rewrite.php:64 modules/module-rewrite.php:75
99
  msgid "Rewrite"
100
  msgstr ""
101
 
102
+ #: modules/module-rewrite.php:75
103
  msgid "WP Hide & Security Enhancer"
104
  msgstr ""
105
 
132
 
133
  #: modules/components/admin-admin_url.php:35
134
  #: modules/components/admin-new_wp_login_php.php:34
135
+ #: modules/components/general-headers.php:20
136
+ #: modules/components/general-headers.php:37
137
+ #: modules/components/general-html.php:19
138
+ #: modules/components/general-html.php:35
139
+ #: modules/components/general-html.php:51
140
+ #: modules/components/general-meta.php:20
141
+ #: modules/components/general-meta.php:36
142
+ #: modules/components/general-meta.php:53
143
+ #: modules/components/general-meta.php:69
144
+ #: modules/components/general-meta.php:87
145
+ #: modules/components/general-meta.php:103
146
+ #: modules/components/general-meta.php:119
147
+ #: modules/components/general-scripts.php:19
148
+ #: modules/components/general-styles.php:19
149
+ #: modules/components/general-styles.php:35
150
+ #: modules/components/general-wpemoji.php:19
151
+ #: modules/components/general-wpemoji.php:35
152
  #: modules/components/rewrite-new_include_path.php:32
153
  #: modules/components/rewrite-new_plugin_path.php:33
154
+ #: modules/components/rewrite-new_theme_path.php:51
155
+ #: modules/components/rewrite-new_theme_path.php:104
156
  #: modules/components/rewrite-new_upload_path.php:33
157
  #: modules/components/rewrite-new_xml-rpc-path.php:32
158
  #: modules/components/rewrite-new_xml-rpc-path.php:49
159
+ #: modules/components/rewrite-new_xml-rpc-path.php:66
160
+ #: modules/components/rewrite-root-files.php:32
161
+ #: modules/components/rewrite-root-files.php:57
162
+ #: modules/components/rewrite-root-files.php:73
163
+ #: modules/components/rewrite-root-files.php:89
164
+ #: modules/components/rewrite-root-files.php:105
165
+ #: modules/components/rewrite-root-files.php:121
166
+ #: modules/components/rewrite-root-files.php:138
167
+ #: modules/components/rewrite-slash.php:19
168
  #: modules/components/rewrite-wp_content_path.php:34
169
  msgid "Yes"
170
  msgstr ""
171
 
172
  #: modules/components/admin-admin_url.php:36
173
  #: modules/components/admin-new_wp_login_php.php:35
174
+ #: modules/components/general-headers.php:21
175
+ #: modules/components/general-headers.php:38
176
+ #: modules/components/general-html.php:20
177
+ #: modules/components/general-html.php:36
178
+ #: modules/components/general-html.php:52
179
+ #: modules/components/general-meta.php:21
180
+ #: modules/components/general-meta.php:37
181
+ #: modules/components/general-meta.php:54
182
+ #: modules/components/general-meta.php:70
183
+ #: modules/components/general-meta.php:88
184
+ #: modules/components/general-meta.php:104
185
+ #: modules/components/general-meta.php:120
186
+ #: modules/components/general-scripts.php:20
187
+ #: modules/components/general-styles.php:20
188
+ #: modules/components/general-styles.php:36
189
+ #: modules/components/general-wpemoji.php:20
190
+ #: modules/components/general-wpemoji.php:36
191
  #: modules/components/rewrite-new_include_path.php:33
192
  #: modules/components/rewrite-new_plugin_path.php:34
193
+ #: modules/components/rewrite-new_theme_path.php:52
194
+ #: modules/components/rewrite-new_theme_path.php:105
195
  #: modules/components/rewrite-new_upload_path.php:34
196
  #: modules/components/rewrite-new_xml-rpc-path.php:33
197
  #: modules/components/rewrite-new_xml-rpc-path.php:50
198
+ #: modules/components/rewrite-new_xml-rpc-path.php:67
199
+ #: modules/components/rewrite-root-files.php:33
200
+ #: modules/components/rewrite-root-files.php:58
201
+ #: modules/components/rewrite-root-files.php:74
202
+ #: modules/components/rewrite-root-files.php:90
203
+ #: modules/components/rewrite-root-files.php:106
204
+ #: modules/components/rewrite-root-files.php:122
205
+ #: modules/components/rewrite-root-files.php:139
206
+ #: modules/components/rewrite-slash.php:20
207
  #: modules/components/rewrite-wp_content_path.php:35
208
  msgid "No"
209
  msgstr ""
210
 
211
+ #: modules/components/admin-admin_url.php:201
212
  msgid "Hello"
213
  msgstr ""
214
 
215
+ #: modules/components/admin-admin_url.php:202
216
  msgid ""
217
  "This is an automated message to inform that your login url has been changed "
218
  "at"
219
  msgstr ""
220
 
221
+ #: modules/components/admin-admin_url.php:203
222
  msgid "The new login url is"
223
  msgstr ""
224
 
225
+ #: modules/components/admin-admin_url.php:204
226
  msgid "Additionality you can use this to recover the old login / admin links "
227
  msgstr ""
228
 
229
+ #: modules/components/admin-admin_url.php:205
230
  msgid "Please keep this url safe for recover, if forgot"
231
  msgstr ""
232
 
247
  msgid "Block default wp-login.php file from being accesible."
248
  msgstr ""
249
 
250
+ #: modules/components/general-headers.php:15
251
+ msgid "Remove X-Powered-By Header if being set."
252
+ msgstr ""
253
+
254
+ #: modules/components/general-headers.php:16
255
+ #: modules/components/general-headers.php:33
256
+ msgid "More details at "
257
+ msgstr ""
258
+
259
+ #: modules/components/general-headers.php:32
260
+ msgid "Remove X-Pingback Header if being set."
261
+ msgstr ""
262
+
263
+ #: modules/components/general-html.php:15
264
+ msgid ""
265
+ "Remove all HTML Comments which usualy specify Plugins Name and Versio. Any "
266
+ "Internet Exploreer conditional tags are preserved."
267
+ msgstr ""
268
+
269
+ #: modules/components/general-html.php:31
270
+ msgid "Remove ID attribute from all menu items."
271
+ msgstr ""
272
+
273
+ #: modules/components/general-html.php:47
274
+ msgid ""
275
+ "Remove class attribute from all menu items. Any classes which include a "
276
+ "\"current\" prefix or contain \"has-children\" will be preserved."
277
+ msgstr ""
278
+
279
+ #: modules/components/general-meta.php:16
280
  msgid ""
281
  "Remove the autogenerated meta generator tag within head (WordPress Version)."
282
  msgstr ""
283
 
284
+ #: modules/components/general-meta.php:32
285
  msgid "Remove the wlwmanifest tag within head."
286
  msgstr ""
287
 
288
+ #: modules/components/general-meta.php:49
289
  msgid "Remove the feed_links tag within head."
290
  msgstr ""
291
 
292
+ #: modules/components/general-meta.php:65
293
  msgid "Remove the rsd_link tag within head."
294
  msgstr ""
295
 
296
+ #: modules/components/general-meta.php:83
297
  msgid "Remove the adjacent_posts_rel tag within head."
298
  msgstr ""
299
 
300
+ #: modules/components/general-meta.php:99
301
  msgid "Remove profile link meta tag within head."
302
  msgstr ""
303
 
304
+ #: modules/components/general-meta.php:115
305
  msgid "Remove canonical link meta tag within head."
306
  msgstr ""
307
 
308
+ #: modules/components/general-scripts.php:15
309
+ msgid "Remove version number from enqueued script files."
310
+ msgstr ""
311
+
312
+ #: modules/components/general-styles.php:15
313
+ msgid "Remove version number from enqueued style files."
314
+ msgstr ""
315
+
316
+ #: modules/components/general-styles.php:31
317
+ msgid "Remove ID attribute from all link tags which include a stylesheet."
318
  msgstr ""
319
 
320
+ #: modules/components/general-wpemoji.php:15
321
  msgid "Disable the Emoji icon library from being loaded."
322
  msgstr ""
323
 
324
+ #: modules/components/general-wpemoji.php:31
325
  msgid "Disable the TinyMC Emoji icons library from being loaded into TinyMC."
326
  msgstr ""
327
 
331
 
332
  #: modules/components/rewrite-new_include_path.php:16
333
  #: modules/components/rewrite-new_theme_path.php:17
334
+ #: modules/components/rewrite-new_theme_path.php:72
335
  msgid "The default theme path is set to"
336
  msgstr ""
337
 
338
  #: modules/components/rewrite-new_include_path.php:17
339
  #: modules/components/rewrite-new_plugin_path.php:17
340
  #: modules/components/rewrite-new_theme_path.php:18
341
+ #: modules/components/rewrite-new_theme_path.php:73
342
  #: modules/components/rewrite-new_upload_path.php:17
343
  #: modules/components/rewrite-wp_content_path.php:16
344
  msgid "More details can be found at"
365
  msgstr ""
366
 
367
  #: modules/components/rewrite-new_plugin_path.php:29
368
+ #: modules/components/rewrite-root-files.php:28
369
  msgid "Apply only if "
370
  msgstr ""
371
 
372
  #: modules/components/rewrite-new_plugin_path.php:29
373
  #: modules/components/rewrite-new_upload_path.php:29
374
+ #: modules/components/rewrite-root-files.php:28
375
  msgid "is not empty."
376
  msgstr ""
377
 
403
  msgid "e.g. my_template"
404
  msgstr ""
405
 
406
+ #: modules/components/rewrite-new_theme_path.php:30
407
+ msgid "New Style File Path"
408
+ msgstr ""
409
+
410
  #: modules/components/rewrite-new_theme_path.php:31
411
+ #: modules/components/rewrite-new_theme_path.php:85
412
+ msgid "The default theme style file style.css path is set to"
413
+ msgstr ""
414
+
415
+ #: modules/components/rewrite-new_theme_path.php:32
416
+ #: modules/components/rewrite-new_theme_path.php:86
417
+ msgid ""
418
+ "If style file contain relative URLs it should not include additional path, "
419
+ "just the actual filename."
420
+ msgstr ""
421
+
422
+ #: modules/components/rewrite-new_theme_path.php:32
423
+ #: modules/components/rewrite-new_theme_path.php:86
424
+ msgid "More details at"
425
  msgstr ""
426
 
427
  #: modules/components/rewrite-new_theme_path.php:35
428
+ #: modules/components/rewrite-new_theme_path.php:88
429
+ msgid "e.g. custom-style-file.css"
430
  msgstr ""
431
 
432
  #: modules/components/rewrite-new_theme_path.php:45
433
+ msgid "Remove description header from Style file"
434
  msgstr ""
435
 
436
  #: modules/components/rewrite-new_theme_path.php:46
437
+ #: modules/components/rewrite-new_theme_path.php:99
438
+ msgid ""
439
+ "Strip out all meta data from style file e.g. Theme Name, Theme URI, Author "
440
+ "etc. Those are important information to find out possible theme security "
441
+ "breaches."
442
  msgstr ""
443
 
444
+ #: modules/components/rewrite-new_theme_path.php:47
445
+ #: modules/components/rewrite-new_theme_path.php:100
446
+ msgid ""
447
+ "This feature may not work if style file url not available on html (being "
448
+ "concatenated)."
449
+ msgstr ""
450
+
451
+ #: modules/components/rewrite-new_theme_path.php:71
452
+ msgid "Child - New Theme Path"
453
+ msgstr ""
454
+
455
+ #: modules/components/rewrite-new_theme_path.php:75
456
+ msgid "e.g. my_child_template"
457
+ msgstr ""
458
+
459
+ #: modules/components/rewrite-new_theme_path.php:84
460
+ msgid "Child - New Style File Path"
461
+ msgstr ""
462
+
463
+ #: modules/components/rewrite-new_theme_path.php:98
464
+ msgid "Child - Remove description header from Style file"
465
  msgstr ""
466
 
467
  #: modules/components/rewrite-new_upload_path.php:15
521
  msgstr ""
522
 
523
  #: modules/components/rewrite-new_xml-rpc-path.php:44
524
+ msgid "Disable XML-RPC authentication"
525
  msgstr ""
526
 
527
  #: modules/components/rewrite-new_xml-rpc-path.php:45
528
+ msgid ""
529
+ "Filter whether XML-RPC methods requiring authentication, such as for "
530
+ "publishing purposes, are enabled."
531
+ msgstr ""
532
+
533
+ #: modules/components/rewrite-new_xml-rpc-path.php:61
534
+ msgid "Remove pingback"
535
+ msgstr ""
536
+
537
+ #: modules/components/rewrite-new_xml-rpc-path.php:62
538
  msgid "Remove pingback link tag from theme."
539
  msgstr ""
540
 
541
  #: modules/components/rewrite-root-files.php:15
542
+ msgid "New wp-comments-post.php Path"
543
  msgstr ""
544
 
545
  #: modules/components/rewrite-root-files.php:16
546
+ msgid "The default path is set to wp-comments-post.php"
547
+ msgstr ""
548
+
549
+ #: modules/components/rewrite-root-files.php:27
550
+ msgid "Block wp-comments-post.php"
551
+ msgstr ""
552
+
553
+ #: modules/components/rewrite-root-files.php:28
554
+ msgid "Block default wp-comments-post.php."
555
+ msgstr ""
556
+
557
+ #: modules/components/rewrite-root-files.php:52
558
+ msgid "Block license.txt"
559
+ msgstr ""
560
+
561
+ #: modules/components/rewrite-root-files.php:53
562
  msgid "Block access to license.txt root file"
563
  msgstr ""
564
 
565
+ #: modules/components/rewrite-root-files.php:68
566
  msgid "Block readme.html"
567
  msgstr ""
568
 
569
+ #: modules/components/rewrite-root-files.php:69
570
  msgid "Block access to readme.html root file"
571
  msgstr ""
572
 
573
+ #: modules/components/rewrite-root-files.php:84
574
  msgid "Block wp-activate.php"
575
  msgstr ""
576
 
577
+ #: modules/components/rewrite-root-files.php:85
578
  msgid ""
579
  "Block access to wp-activate.php file. This file confirms that the activation "
580
  "key that is sent in an email after a user signs up for a new blog matches "
582
  "keep this off."
583
  msgstr ""
584
 
585
+ #: modules/components/rewrite-root-files.php:100
586
+ msgid "Block wp-cron.php"
587
+ msgstr ""
588
+
589
+ #: modules/components/rewrite-root-files.php:101
590
+ msgid ""
591
+ "Block access to wp-cron.php file. If remote cron calls not being used this "
592
+ "can be set to Yes."
593
+ msgstr ""
594
+
595
+ #: modules/components/rewrite-root-files.php:117
596
  msgid ""
597
  "Block default wp-signup.php file. If <b>anyone can register</b> on your "
598
  "site, you shold keep this off."
599
  msgstr ""
600
 
601
+ #: modules/components/rewrite-root-files.php:134
602
  msgid ""
603
  "Block other wp-*.php files. E.g. wp-blog-header.php, wp-config.php, wp-cron."
604
  "php. Those files are used internally, blocking those will not affect any "
606
  "php) are ignored, they can be controlled through own setting."
607
  msgstr ""
608
 
609
+ #: modules/components/rewrite-slash.php:14
610
+ msgid "URL's add Slash"
611
+ msgstr ""
612
+
613
+ #: modules/components/rewrite-slash.php:15
614
+ msgid ""
615
+ "Add an end slash to any links without. This disguise any existance uppon a "
616
+ "file, folder or a wrong url, they will be all slashed."
617
+ msgstr ""
618
+
619
+ #: modules/components/rewrite-slash.php:15
620
+ msgid ""
621
+ "On certain systems this can produce a small lag measured in milliseconds."
622
+ msgstr ""
623
+
624
  #: modules/components/rewrite-wp_content_path.php:14
625
  msgid "New Content Path"
626
  msgstr ""
modules/components/admin-admin_url.php CHANGED
@@ -69,14 +69,13 @@
69
 
70
 
71
  //add replacement
72
- if(!isset($this->wph->urls_replacement[$default_url]))
73
- {
74
- $this->wph->urls_replacement[$default_url] = $new_url;
75
- }
76
 
77
  add_filter('admin_url', array($this,'admin_url'), 999, 3 );
78
  add_action('set_auth_cookie', array($this,'set_auth_cookie'), 999, 5);
79
- add_filter('style_loader_src', array($this->wph, 'generic_string_replacement' ), 999);
 
 
80
 
81
  add_filter('wp_default_scripts', array($this, 'wp_default_scripts' ), 999);
82
  }
@@ -136,10 +135,7 @@
136
  $new_url = trailingslashit( $admin_dir_uri ) . $path;
137
 
138
  //add replacement
139
- if(!isset($this->wph->urls_replacement[$url]))
140
- {
141
- $this->wph->urls_replacement[$url] = $new_url;
142
- }
143
 
144
  return $new_url;
145
 
69
 
70
 
71
  //add replacement
72
+ $this->wph->functions->add_replacement( $default_url, $new_url);
 
 
 
73
 
74
  add_filter('admin_url', array($this,'admin_url'), 999, 3 );
75
  add_action('set_auth_cookie', array($this,'set_auth_cookie'), 999, 5);
76
+
77
+ //?????
78
+ //add_filter('style_loader_src', array($this->wph, 'generic_string_replacement' ), 999);
79
 
80
  add_filter('wp_default_scripts', array($this, 'wp_default_scripts' ), 999);
81
  }
135
  $new_url = trailingslashit( $admin_dir_uri ) . $path;
136
 
137
  //add replacement
138
+ $this->wph->functions->add_replacement($url, $new_url);
 
 
 
139
 
140
  return $new_url;
141
 
modules/components/admin-new_wp_login_php.php CHANGED
@@ -62,15 +62,10 @@
62
 
63
  //add replacement
64
  $url = trailingslashit( site_url() ) . 'wp-login.php';
65
- if(!isset($this->wph->urls_replacement[$url]))
66
- {
67
- $this->wph->urls_replacement[ $url ] = trailingslashit( site_url() ) . $saved_field_data;
68
- }
69
  //add relative too
70
- if(!isset($this->wph->urls_replacement[ 'wp-login.php' ]))
71
- {
72
- $this->wph->urls_replacement[ 'wp-login.php' ] = $saved_field_data;
73
- }
74
 
75
  }
76
 
62
 
63
  //add replacement
64
  $url = trailingslashit( site_url() ) . 'wp-login.php';
65
+ $this->wph->functions->add_replacement( $url, trailingslashit( site_url() ) . $saved_field_data );
66
+
 
 
67
  //add relative too
68
+ $this->wph->functions->add_replacement( 'wp-login.php', $saved_field_data );
 
 
 
69
 
70
  }
71
 
modules/components/rewrite-new_include_path.php CHANGED
@@ -57,7 +57,7 @@
57
  //add default plugin path replacement
58
  $new_include_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_include_path') );
59
  $new_include_path = trailingslashit( site_url() ) . untrailingslashit( $new_include_path );
60
- $this->wph->urls_replacement[trailingslashit( site_url() ) . 'wp-includes' ] = $new_include_path;
61
  }
62
 
63
  function _callback_saved_new_include_path($saved_field_data)
57
  //add default plugin path replacement
58
  $new_include_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_include_path') );
59
  $new_include_path = trailingslashit( site_url() ) . untrailingslashit( $new_include_path );
60
+ $this->wph->functions->add_replacement( trailingslashit( site_url() ) . 'wp-includes', $new_include_path );
61
  }
62
 
63
  function _callback_saved_new_include_path($saved_field_data)
modules/components/rewrite-new_plugin_path.php CHANGED
@@ -1,258 +1,262 @@
1
- <?php
2
-
3
- class WPH_module_rewrite_new_plugin_path extends WPH_module_component
4
- {
5
-
6
- function get_component_title()
7
- {
8
- return "Plugins";
9
- }
10
-
11
- function get_module_settings()
12
- {
13
- $this->module_settings[] = array(
14
- 'id' => 'new_plugin_path',
15
- 'label' => __('New Plugins Path', 'wp-hide-security-enhancer'),
16
- 'description' => __('The default plugins path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['plugins_url']) .'</strong>
17
- '. __('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
18
-
19
- 'value_description' => 'e.g. my_plugins',
20
- 'input_type' => 'text',
21
-
22
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
23
- 'processing_order' => 17
24
- );
25
-
26
- $this->module_settings[] = array(
27
- 'id' => 'block_plugins_url',
28
- 'label' => __('Block plugins URL', 'wp-hide-security-enhancer'),
29
- 'description' => __('Block plugins files from being accesible through default urls.', 'wp-hide-security-enhancer') . '<br />'.__('Apply only if ', 'wp-hide-security-enhancer') . '<b>New Plugin Path</b> ' . __('is not empty.', 'wp-hide-security-enhancer'),
30
-
31
- 'input_type' => 'radio',
32
- 'options' => array(
33
- 'yes' => __('Yes', 'wp-hide-security-enhancer'),
34
- 'no' => __('No', 'wp-hide-security-enhancer'),
35
- ),
36
- 'default_value' => 'no',
37
-
38
- 'sanitize_type' => array('sanitize_title', 'strtolower'),
39
- 'processing_order' => 18
40
-
41
- );
42
-
43
-
44
- $this->module_settings[] = array(
45
- 'type' => 'split'
46
-
47
- );
48
-
49
- $all_plugins = $this->wph->functions->get_plugins();
50
-
51
- //get active plugins
52
- $active_plugins = (array) get_option( 'active_plugins', array() );
53
- foreach($active_plugins as $active_plugin)
54
- {
55
- //exclude this plugin
56
- if('wp-hide-security-enhancer/wp-hide.php' == $active_plugin)
57
- continue;
58
-
59
- $plugin_slug = sanitize_title($active_plugin);
60
-
61
- $pluding_data = $all_plugins[$active_plugin];
62
-
63
- $this->module_settings[] = array(
64
- 'id' => 'new_plugin_path_' . $plugin_slug,
65
- 'label' => __('New Path for', 'wp-hide-security-enhancer') . " <i>" . $pluding_data['Name'] ."</i> ". __('plugin', 'wp-hide-security-enhancer'),
66
- 'description' => __('This setting overwrite the', 'wp-hide-security-enhancer') . ' ' . __('New Plugin Path', 'wp-hide-security-enhancer') . ' ' . __('setting for this plugin, if set.', 'wp-hide-security-enhancer'),
67
- 'value_description' => 'e.g. my_plugins/module',
68
- 'input_type' => 'text',
69
-
70
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
71
-
72
- 'processing_order' => 16
73
- );
74
-
75
- }
76
-
77
- return $this->module_settings;
78
- }
79
-
80
-
81
-
82
- function _init_new_plugin_path($saved_field_data)
83
- {
84
- add_filter('plugins_url', array( $this, 'plugins_url' ), 10, 3);
85
-
86
- if(empty($saved_field_data))
87
- return FALSE;
88
-
89
- //add default plugin path replacement
90
- $new_plugin_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_plugin_path') );
91
- $new_plugin_path = trailingslashit( site_url() ) . untrailingslashit( $new_plugin_path );
92
- $this->wph->urls_replacement[WP_PLUGIN_URL] = $new_plugin_path;
93
-
94
- return TRUE;
95
- }
96
-
97
- function plugins_url($url, $path, $plugin)
98
- {
99
-
100
- if(empty($plugin))
101
- return $url;
102
-
103
- $strip_url = str_replace(WP_PLUGIN_URL, "", $url);
104
- $strip_url = str_replace($path, "", $strip_url);
105
- $strip_url = $this->wph->functions->untrailingslashit_all( $strip_url );
106
-
107
- //strip out any slashes in front of $path
108
- $path = ltrim($path, '/');
109
-
110
- $new_url = $url;
111
-
112
- //get active plugins
113
- $active_plugins = (array) get_option( 'active_plugins', array() );
114
- foreach($active_plugins as $active_plugin)
115
- {
116
- $active_plugin_split = explode('/', $active_plugin);
117
- $active_plugin_directory = $active_plugin_split[0];
118
-
119
- if($active_plugin_directory != $strip_url)
120
- continue;
121
-
122
- $plugin_slug = sanitize_title($active_plugin);
123
- $option_namespace = 'new_plugin_path_' . $plugin_slug;
124
-
125
- //check if plugin have custom url
126
- $plugin_custom_path = $this->wph->functions->get_module_item_setting($option_namespace);
127
- if(empty($plugin_custom_path))
128
- continue;
129
-
130
- //add custom path
131
- $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
132
- if(!empty($path))
133
- $new_url = trailingslashit( $new_url ) . $path;
134
-
135
- //add replacement
136
- $new_plugin_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_plugin_path') );
137
- $replace_url = trailingslashit( site_url() ) . trailingslashit( $new_plugin_path ) . $active_plugin_directory;
138
- $replacement_url = trailingslashit( site_url() ) . $plugin_custom_path;
139
- $this->wph->urls_replacement[$replace_url] = $replacement_url;
140
-
141
- break;
142
- }
143
-
144
- return $new_url;
145
-
146
-
147
- }
148
-
149
- function _callback_saved_new_plugin_path($saved_field_data)
150
- {
151
- $processing_response = array();
152
-
153
- $rewrite = '';
154
-
155
- $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
156
-
157
- $path = '';
158
- if(!empty($this->wph->default_variables['wordpress_directory']))
159
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
160
- $path .= trailingslashit( $saved_field_data );
161
-
162
-
163
- //add custom rewrite for plugins
164
- //get active plugins
165
- $active_plugins = (array) get_option( 'active_plugins', array() );
166
- foreach($active_plugins as $active_plugin)
167
- {
168
- $active_plugin_split = explode('/', $active_plugin);
169
- $active_plugin_directory = $active_plugin_split[0];
170
-
171
- $plugin_slug = sanitize_title($active_plugin);
172
- $option_namespace = 'new_plugin_path_' . $plugin_slug;
173
-
174
- //check if plugin have custom url
175
- $plugin_custom_path = $this->wph->functions->get_module_item_setting($option_namespace);
176
- if(empty($plugin_custom_path))
177
- continue;
178
-
179
- //add custom path
180
- $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
181
- if($path != '/')
182
- $new_url = trailingslashit( $new_url ) . $path;
183
-
184
- if($this->wph->server_htaccess_config === TRUE)
185
- $rewrite .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.*) '. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'$1 [L,QSA]';
186
-
187
- if($this->wph->server_web_config === TRUE)
188
- $rewrite .= '
189
- <rule name="wph-new_plugin_path-'. $plugin_slug .'" stopProcessing="true">
190
- <match url="^'. trailingslashit( $plugin_custom_path ) .'(.*)" />
191
- <action type="Rewrite" url="'. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'{R:1}" appendQueryString="true" />
192
- </rule>
193
- ';
194
- }
195
-
196
- if($path != '/')
197
- {
198
- if($this->wph->server_htaccess_config === TRUE)
199
- $rewrite .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.*) '. $plugin_path .'$1 [L,QSA]';
200
-
201
- if($this->wph->server_web_config === TRUE)
202
- $rewrite .= '
203
- <rule name="wph-new_plugin_path" stopProcessing="true">
204
- <match url="^'. trailingslashit( $path ) .'(.*)" />
205
- <action type="Rewrite" url="'. $plugin_path .'{R:1}" appendQueryString="true" />
206
- </rule>
207
- ';
208
- }
209
-
210
- $processing_response['rewrite'] = $rewrite;
211
-
212
- return $processing_response;
213
- }
214
-
215
-
216
- function _callback_saved_block_plugins_url($saved_field_data)
217
- {
218
- $processing_response = array();
219
-
220
- if(empty($saved_field_data) || $saved_field_data == 'no')
221
- return FALSE;
222
-
223
- //prevent from blocking if the wp-include is not modified
224
- $new_theme_path = ltrim(rtrim($this->wph->functions->get_module_item_setting('new_plugin_path'), "/"), "/");
225
- if (empty( $new_theme_path ))
226
- return FALSE;
227
-
228
- $home_url = defined('WP_HOME') ? WP_HOME : get_option('home');
229
- $home_url = untrailingslashit($home_url);
230
-
231
- $default_plugin_url = untrailingslashit ( WP_PLUGIN_URL );
232
- $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
233
- $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
234
-
235
- if($this->wph->server_htaccess_config === TRUE)
236
- {
237
- $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
238
- $text .= "RewriteRule ^". $default_plugin_url ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
239
- }
240
-
241
- if($this->wph->server_web_config === TRUE)
242
- $text = '
243
- <rule name="wph-block_plugins_url" stopProcessing="true">
244
- <match url="^'. $default_plugin_url .'(.*)" />
245
- <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
246
- </rule>
247
- ';
248
-
249
- $processing_response['rewrite'] = $text;
250
-
251
- return $processing_response;
252
-
253
-
254
- }
255
-
256
-
257
- }
 
 
 
 
258
  ?>
1
+ <?php
2
+
3
+ class WPH_module_rewrite_new_plugin_path extends WPH_module_component
4
+ {
5
+
6
+ function get_component_title()
7
+ {
8
+ return "Plugins";
9
+ }
10
+
11
+ function get_module_settings()
12
+ {
13
+ $this->module_settings[] = array(
14
+ 'id' => 'new_plugin_path',
15
+ 'label' => __('New Plugins Path', 'wp-hide-security-enhancer'),
16
+ 'description' => __('The default plugins path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['plugins_url']) .'</strong>
17
+ '. __('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
18
+
19
+ 'value_description' => 'e.g. my_plugins',
20
+ 'input_type' => 'text',
21
+
22
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
23
+ 'processing_order' => 17
24
+ );
25
+
26
+ $this->module_settings[] = array(
27
+ 'id' => 'block_plugins_url',
28
+ 'label' => __('Block plugins URL', 'wp-hide-security-enhancer'),
29
+ 'description' => __('Block plugins files from being accesible through default urls.', 'wp-hide-security-enhancer') . '<br />'.__('Apply only if ', 'wp-hide-security-enhancer') . '<b>New Plugin Path</b> ' . __('is not empty.', 'wp-hide-security-enhancer'),
30
+
31
+ 'input_type' => 'radio',
32
+ 'options' => array(
33
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
34
+ 'no' => __('No', 'wp-hide-security-enhancer'),
35
+ ),
36
+ 'default_value' => 'no',
37
+
38
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
39
+ 'processing_order' => 18
40
+
41
+ );
42
+
43
+
44
+ $this->module_settings[] = array(
45
+ 'type' => 'split'
46
+
47
+ );
48
+
49
+ $all_plugins = $this->wph->functions->get_plugins();
50
+
51
+ //get active plugins
52
+ $active_plugins = (array) get_option( 'active_plugins', array() );
53
+ foreach($active_plugins as $active_plugin)
54
+ {
55
+ //exclude this plugin
56
+ if('wp-hide-security-enhancer/wp-hide.php' == $active_plugin)
57
+ continue;
58
+
59
+ $plugin_slug = sanitize_title($active_plugin);
60
+
61
+ $pluding_data = $all_plugins[$active_plugin];
62
+
63
+ $this->module_settings[] = array(
64
+ 'id' => 'new_plugin_path_' . $plugin_slug,
65
+ 'label' => __('New Path for', 'wp-hide-security-enhancer') . " <i>" . $pluding_data['Name'] ."</i> ". __('plugin', 'wp-hide-security-enhancer'),
66
+ 'description' => __('This setting overwrite the', 'wp-hide-security-enhancer') . ' ' . __('New Plugin Path', 'wp-hide-security-enhancer') . ' ' . __('setting for this plugin, if set.', 'wp-hide-security-enhancer'),
67
+ 'value_description' => 'e.g. my_plugins/module',
68
+ 'input_type' => 'text',
69
+
70
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
71
+
72
+ 'processing_order' => 16
73
+ );
74
+
75
+ }
76
+
77
+ return $this->module_settings;
78
+ }
79
+
80
+
81
+
82
+ function _init_new_plugin_path($saved_field_data)
83
+ {
84
+ add_filter('plugins_url', array( $this, 'plugins_url' ), 10, 3);
85
+
86
+ if(empty($saved_field_data))
87
+ return FALSE;
88
+
89
+ //add default plugin path replacement
90
+ $new_plugin_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_plugin_path') );
91
+ $new_plugin_path = trailingslashit( site_url() ) . untrailingslashit( $new_plugin_path );
92
+ $this->wph->functions->add_replacement( WP_PLUGIN_URL, $new_plugin_path );
93
+
94
+ return TRUE;
95
+ }
96
+
97
+ function plugins_url($url, $path, $plugin)
98
+ {
99
+
100
+ if(empty($plugin))
101
+ return $url;
102
+
103
+ $strip_url = str_replace(WP_PLUGIN_URL, "", $url);
104
+ $strip_url = str_replace($path, "", $strip_url);
105
+ $strip_url = $this->wph->functions->untrailingslashit_all( $strip_url );
106
+
107
+ //strip out any slashes in front of $path
108
+ $path = ltrim($path, '/');
109
+
110
+ $new_url = $url;
111
+
112
+ //get active plugins
113
+ $active_plugins = (array) get_option( 'active_plugins', array() );
114
+ foreach($active_plugins as $active_plugin)
115
+ {
116
+ $active_plugin_split = explode('/', $active_plugin);
117
+ $active_plugin_directory = $active_plugin_split[0];
118
+
119
+ if($active_plugin_directory != $strip_url)
120
+ continue;
121
+
122
+ $plugin_slug = sanitize_title($active_plugin);
123
+ $option_namespace = 'new_plugin_path_' . $plugin_slug;
124
+
125
+ //check if plugin have custom url
126
+ $plugin_custom_path = $this->wph->functions->get_module_item_setting($option_namespace);
127
+ if(empty($plugin_custom_path))
128
+ continue;
129
+
130
+ //add custom path
131
+ $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
132
+ if(!empty($path))
133
+ $new_url = trailingslashit( $new_url ) . $path;
134
+
135
+ //add replacement
136
+ $new_plugin_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_plugin_path') );
137
+ $replace_url = trailingslashit( site_url() ) . trailingslashit( $new_plugin_path ) . $active_plugin_directory;
138
+ $replacement_url = trailingslashit( site_url() ) . $plugin_custom_path;
139
+ $this->wph->functions->add_replacement( $replace_url, $replacement_url);
140
+
141
+ break;
142
+ }
143
+
144
+ return $new_url;
145
+
146
+
147
+ }
148
+
149
+ function _callback_saved_new_plugin_path($saved_field_data)
150
+ {
151
+ $processing_response = array();
152
+
153
+ $rewrite = '';
154
+
155
+ $plugin_path = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
156
+
157
+ $path = '';
158
+ /*
159
+ if(!empty($this->wph->default_variables['wordpress_directory']))
160
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
161
+ */
162
+
163
+ if(!empty($saved_field_data))
164
+ $path .= trailingslashit( $saved_field_data );
165
+
166
+
167
+ //add custom rewrite for plugins
168
+ //get active plugins
169
+ $active_plugins = (array) get_option( 'active_plugins', array() );
170
+ foreach($active_plugins as $active_plugin)
171
+ {
172
+ $active_plugin_split = explode('/', $active_plugin);
173
+ $active_plugin_directory = $active_plugin_split[0];
174
+
175
+ $plugin_slug = sanitize_title($active_plugin);
176
+ $option_namespace = 'new_plugin_path_' . $plugin_slug;
177
+
178
+ //check if plugin have custom url
179
+ $plugin_custom_path = $this->wph->functions->get_module_item_setting($option_namespace);
180
+ if(empty($plugin_custom_path))
181
+ continue;
182
+
183
+ //add custom path
184
+ $new_url = trailingslashit( site_url() ) . $plugin_custom_path;
185
+ if($path != '/')
186
+ $new_url = trailingslashit( $new_url ) . $path;
187
+
188
+ if($this->wph->server_htaccess_config === TRUE)
189
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $plugin_custom_path ) . '(.*) '. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'$1 [L,QSA]';
190
+
191
+ if($this->wph->server_web_config === TRUE)
192
+ $rewrite .= '
193
+ <rule name="wph-new_plugin_path-'. $plugin_slug .'" stopProcessing="true">
194
+ <match url="^'. trailingslashit( $plugin_custom_path ) .'(.*)" />
195
+ <action type="Rewrite" url="'. trailingslashit($plugin_path) . trailingslashit($active_plugin_directory) .'{R:1}" appendQueryString="true" />
196
+ </rule>
197
+ ';
198
+ }
199
+
200
+ if( !empty($path) && !empty($saved_field_data))
201
+ {
202
+ if($this->wph->server_htaccess_config === TRUE)
203
+ $rewrite .= "\nRewriteRule ^" . trailingslashit( $path ) . '(.*) '. $plugin_path .'$1 [L,QSA]';
204
+
205
+ if($this->wph->server_web_config === TRUE)
206
+ $rewrite .= '
207
+ <rule name="wph-new_plugin_path" stopProcessing="true">
208
+ <match url="^'. trailingslashit( $path ) .'(.*)" />
209
+ <action type="Rewrite" url="'. $plugin_path .'{R:1}" appendQueryString="true" />
210
+ </rule>
211
+ ';
212
+ }
213
+
214
+ $processing_response['rewrite'] = $rewrite;
215
+
216
+ return $processing_response;
217
+ }
218
+
219
+
220
+ function _callback_saved_block_plugins_url($saved_field_data)
221
+ {
222
+ $processing_response = array();
223
+
224
+ if(empty($saved_field_data) || $saved_field_data == 'no')
225
+ return FALSE;
226
+
227
+ //prevent from blocking if the wp-include is not modified
228
+ $new_theme_path = ltrim(rtrim($this->wph->functions->get_module_item_setting('new_plugin_path'), "/"), "/");
229
+ if (empty( $new_theme_path ))
230
+ return FALSE;
231
+
232
+ $home_url = defined('WP_HOME') ? WP_HOME : get_option('home');
233
+ $home_url = untrailingslashit($home_url);
234
+
235
+ $default_plugin_url = untrailingslashit ( WP_PLUGIN_URL );
236
+ $default_plugin_url = str_replace( $home_url, "", $default_plugin_url);
237
+ $default_plugin_url = ltrim(rtrim($default_plugin_url, "/"), "/");
238
+
239
+ if($this->wph->server_htaccess_config === TRUE)
240
+ {
241
+ $text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
242
+ $text .= "RewriteRule ^". $default_plugin_url ."(.*) ". $this->wph->default_variables['site_relative_path'] ."index.php [L]";
243
+ }
244
+
245
+ if($this->wph->server_web_config === TRUE)
246
+ $text = '
247
+ <rule name="wph-block_plugins_url" stopProcessing="true">
248
+ <match url="^'. $default_plugin_url .'(.*)" />
249
+ <action type="Rewrite" url="'. $this->wph->default_variables['site_relative_path'] .'index.php" />
250
+ </rule>
251
+ ';
252
+
253
+ $processing_response['rewrite'] = $text;
254
+
255
+ return $processing_response;
256
+
257
+
258
+ }
259
+
260
+
261
+ }
262
  ?>
modules/components/rewrite-new_theme_path.php CHANGED
@@ -1,655 +1,691 @@
1
- <?php
2
-
3
- class WPH_module_rewrite_new_theme_path extends WPH_module_component
4
- {
5
-
6
- function get_component_title()
7
- {
8
- return "Theme";
9
- }
10
-
11
-
12
- function get_module_settings()
13
- {
14
- $this->module_settings[] = array(
15
- 'id' => 'new_theme_path',
16
- 'label' => __('New Theme Path', 'wp-hide-security-enhancer'),
17
- 'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['template_url']) .'</strong>
18
- '. __('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
19
-
20
- 'value_description' => __('e.g. my_template', 'wp-hide-security-enhancer'),
21
- 'input_type' => 'text',
22
-
23
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
24
- 'processing_order' => 10
25
- );
26
-
27
-
28
- $this->module_settings[] = array(
29
- 'id' => 'new_style_file_path',
30
- 'label' => __('New Style File Path', 'wp-hide-security-enhancer'),
31
- 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/style.css</strong>'
32
- .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>'
33
- ,
34
-
35
- 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
36
- 'input_type' => 'text',
37
-
38
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
39
-
40
- 'processing_order' => 5
41
- );
42
-
43
- $this->module_settings[] = array(
44
- 'id' => 'style_file_clean',
45
- 'label' => __('Remove description header from Style file', 'wp-hide-security-enhancer'),
46
- 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
47
- . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
48
-
49
- 'input_type' => 'radio',
50
- 'options' => array(
51
- 'yes' => __('Yes', 'wp-hide-security-enhancer'),
52
- 'no' => __('No', 'wp-hide-security-enhancer'),
53
- ),
54
- 'default_value' => 'no',
55
-
56
- 'sanitize_type' => array('sanitize_title', 'strtolower'),
57
- 'processing_order' => 3
58
-
59
- );
60
-
61
-
62
- if($this->wph->templates_data['use_child_theme'])
63
- {
64
- $this->module_settings[] = array(
65
- 'type' => 'split'
66
-
67
- );
68
-
69
- $this->module_settings[] = array(
70
- 'id' => 'new_theme_child_path',
71
- 'label' => __('Child - New Theme Path', 'wp-hide-security-enhancer'),
72
- 'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , trailingslashit($this->wph->templates_data['themes_url']) . $this->wph->templates_data['child']['folder_name']) .'</strong>
73
- '.__('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
74
-
75
- 'value_description' => __('e.g. my_child_template', 'wp-hide-security-enhancer'),
76
- 'input_type' => 'text',
77
-
78
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
79
- 'processing_order' => 15
80
- );
81
-
82
- $this->module_settings[] = array(
83
- 'id' => 'child_style_file_path',
84
- 'label' => __('Child - New Style File Path', 'wp-hide-security-enhancer'),
85
- 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['stylesheet_uri']) .'</strong>'
86
- .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>',
87
-
88
- 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
89
- 'input_type' => 'text',
90
-
91
- 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
92
-
93
- 'processing_order' => 5
94
- );
95
-
96
- $this->module_settings[] = array(
97
- 'id' => 'child_style_file_clean',
98
- 'label' => __('Child - Remove description header from Style file', 'wp-hide-security-enhancer'),
99
- 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
100
- . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
101
-
102
- 'input_type' => 'radio',
103
- 'options' => array(
104
- 'yes' => __('Yes', 'wp-hide-security-enhancer'),
105
- 'no' => __('No', 'wp-hide-security-enhancer'),
106
- ),
107
- 'default_value' => 'no',
108
-
109
- 'sanitize_type' => array('sanitize_title', 'strtolower'),
110
- 'processing_order' => 3
111
-
112
- );
113
- }
114
-
115
- return $this->module_settings;
116
- }
117
-
118
-
119
-
120
-
121
- /**
122
- * New Theme Path
123
- *
124
- * @param mixed $saved_field_data
125
- */
126
- function _init_new_theme_path($saved_field_data)
127
- {
128
- //rely on this callback function for booth parent and child theme
129
- $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
130
-
131
- if(
132
- ($this->wph->templates_data['use_child_theme'] === FALSE && empty($saved_field_data))
133
- || ($this->wph->templates_data['use_child_theme'] === TRUE && empty($saved_field_data) && empty( $child_theme_saved_field_data ))
134
- )
135
- {
136
- return FALSE;
137
- }
138
-
139
-
140
- /*
141
- //check for child
142
- if($this->wph->templates_data['use_child_theme'] === TRUE)
143
- {
144
- $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
145
- if(empty($child_theme_saved_field_data) && empty($saved_field_data))
146
- return FALSE;
147
- }
148
- else
149
- {
150
- if(empty($saved_field_data))
151
- return FALSE;
152
- }
153
- */
154
-
155
- //applay when not admin and not customize.php
156
- /*
157
- if(is_admin() || $this->functions->is_theme_customize())
158
- return;
159
- */
160
-
161
- add_filter('stylesheet_directory_uri', array(&$this, 'stylesheet_directory_uri'), 999, 1);
162
- add_filter('template_directory_uri', array(&$this, 'template_directory_uri'), 999, 3);
163
- //add_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 999, 3);
164
-
165
- }
166
-
167
- function _callback_saved_new_theme_path($saved_field_data)
168
- {
169
- $processing_response = array();
170
-
171
- //check if the field is noe empty
172
- if(empty($saved_field_data))
173
- return $processing_response;
174
-
175
- $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['main']['folder_name'] );
176
-
177
- $path = '';
178
- if(!empty($this->wph->default_variables['wordpress_directory']))
179
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
180
- $path .= trailingslashit( $saved_field_data );
181
-
182
- $theme_path = str_replace(' ', '%20', $theme_path);
183
-
184
- if($this->wph->server_htaccess_config === TRUE)
185
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
186
-
187
- if($this->wph->server_web_config === TRUE)
188
- $processing_response['rewrite'] = '
189
- <rule name="wph-new_theme_path" stopProcessing="true">
190
- <match url="^'. $path .'(.*)" />
191
- <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
192
- </rule>
193
- ';
194
-
195
- return $processing_response;
196
- }
197
-
198
-
199
-
200
- function stylesheet_directory_uri($url)
201
- {
202
- if ( $this->wph->disable_filters )
203
- return $url;
204
-
205
- $template_slug = str_replace($this->wph->templates_data['themes_url'], "", $url);
206
-
207
- //??
208
- /*
209
- if($this->wph->functions->is_other_template($template))
210
- return $url;
211
- */
212
-
213
- if($this->wph->templates_data['_template_' . $template_slug] == 'main')
214
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
215
- else
216
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
217
-
218
- if(empty($new_theme_path))
219
- return $url;
220
-
221
- $template_dir_uri = trailingslashit( site_url() ) . ltrim(rtrim($new_theme_path, "/"), "/");
222
-
223
- //add replacement
224
- if(!isset($this->wph->urls_replacement[$url]))
225
- {
226
- $this->wph->urls_replacement[$url] = $template_dir_uri;
227
- }
228
-
229
- return $template_dir_uri;
230
- }
231
-
232
-
233
- function template_directory_uri($template_dir_uri, $template, $theme_root_uri)
234
- {
235
- if ( $this->wph->disable_filters )
236
- return $template_dir_uri;
237
-
238
-
239
- //????
240
- /*
241
- if($this->wph->functions->is_other_template($template))
242
- return $template_dir_uri;
243
- */
244
-
245
- if($this->wph->templates_data['_template_' . $template] == 'main')
246
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
247
- else
248
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
249
-
250
- if(empty($new_theme_path))
251
- return $template_dir_uri;
252
-
253
- $new_template_dir_uri = trailingslashit( site_url() ) . trim($new_theme_path, "/") ;
254
-
255
- //add replacement
256
- if(!isset($this->wph->urls_replacement[$template_dir_uri]))
257
- {
258
- $this->wph->urls_replacement[$template_dir_uri] = $new_template_dir_uri;
259
- }
260
-
261
- return $new_template_dir_uri;
262
- }
263
-
264
-
265
- /*
266
- function theme_root_uri($theme_root_uri, $siteurl, $stylesheet_or_template)
267
- {
268
- if ( $this->wph->disable_filters )
269
- return $theme_root_uri;
270
-
271
- //only for current theme
272
- $current_theme = get_stylesheet();
273
- if($current_theme != $stylesheet_or_template)
274
- return $theme_root_uri;
275
-
276
- $theme_root_uri = untrailingslashit( site_url() ) ;
277
-
278
- return $theme_root_uri;
279
- }
280
- */
281
-
282
-
283
- function _callback_saved_new_theme_child_path($saved_field_data)
284
- {
285
- $processing_response = array();
286
-
287
- //check if the field is noe empty
288
- if(empty($saved_field_data))
289
- return $processing_response;
290
-
291
- $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['child']['folder_name'] );
292
-
293
- $path = '';
294
- if(!empty($this->wph->default_variables['wordpress_directory']))
295
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
296
- $path .= trailingslashit( $saved_field_data );
297
-
298
-
299
- $theme_path = str_replace(' ', '%20', $theme_path);
300
-
301
- if($this->wph->server_htaccess_config === TRUE)
302
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
303
-
304
- if($this->wph->server_web_config === TRUE)
305
- $processing_response['rewrite'] = '
306
- <rule name="wph-new_theme_child_path" stopProcessing="true">
307
- <match url="^'. $path .'(.*)" />
308
- <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
309
- </rule>
310
- ';
311
-
312
- return $processing_response;
313
- }
314
-
315
-
316
-
317
- function _init_new_style_file_path($saved_field_data)
318
- {
319
- if(empty($saved_field_data))
320
- return FALSE;
321
-
322
- if($this->wph->functions->is_theme_customize())
323
- return;
324
-
325
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
326
-
327
- //add default replacements
328
- $template_url = trailingslashit( $this->wph->default_variables['template_url'] );
329
- $old_style_file_path = trailingslashit( $this->wph->default_variables['template_url'] ) . 'style.css';
330
-
331
- if(!empty($new_theme_path))
332
- {
333
- $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
334
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
335
- }
336
- else
337
- {
338
- $new_style_file_path = $template_url . $saved_field_data;
339
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
340
- }
341
-
342
-
343
-
344
- //add replacement for style.css when already template name replaced
345
- if(!empty($new_theme_path))
346
- {
347
- $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
348
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
349
- }
350
-
351
- }
352
-
353
- function _callback_saved_new_style_file_path($saved_field_data)
354
- {
355
- $processing_response = array();
356
-
357
- //check if the field is noe empty
358
- if(empty($saved_field_data))
359
- return $processing_response;
360
-
361
- $current_stylesheet_uri = $this->wph->default_variables['template_url'];
362
- $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
363
- $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
364
-
365
- $path = '';
366
- if(!empty($this->wph->default_variables['wordpress_directory']))
367
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
368
-
369
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
370
- if(!empty($new_theme_path))
371
- {
372
- $path .= trailingslashit($new_theme_path) . $saved_field_data;
373
- }
374
- else
375
- {
376
- $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
377
- $path .= trailingslashit($template_relative_url) . $saved_field_data;
378
- }
379
-
380
- $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
381
-
382
- if($this->wph->server_htaccess_config === TRUE)
383
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
384
-
385
- if($this->wph->server_web_config === TRUE)
386
- $processing_response['rewrite'] = '
387
- <rule name="wph-new_style_file_path" stopProcessing="true">
388
- <match url="^'. $path .'" />
389
- <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
390
- </rule>
391
- ';
392
-
393
- return $processing_response;
394
- }
395
-
396
-
397
-
398
- function _callback_saved_style_file_clean($saved_field_data)
399
- {
400
-
401
- if(empty($saved_field_data) || $saved_field_data == 'no')
402
- return FALSE;
403
-
404
- $processing_response = array();
405
-
406
- //actual style file path
407
- $current_stylesheet_uri = $this->wph->default_variables['template_url'];
408
- $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
409
- $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
410
-
411
- //current style file path
412
- $path = '';
413
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
414
- $new_style_file_path = $this->wph->functions->get_module_item_setting('new_style_file_path');
415
- if(!empty($new_style_file_path))
416
- {
417
- if(!empty($this->wph->default_variables['wordpress_directory']))
418
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
419
-
420
- if(!empty($new_theme_path))
421
- {
422
- $path .= trailingslashit($new_theme_path) . $new_style_file_path;
423
- }
424
- else
425
- {
426
- $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
427
- $path .= trailingslashit($template_relative_url) . $new_style_file_path;
428
- }
429
-
430
- }
431
- else if(!empty($new_theme_path))
432
- {
433
- $path = trailingslashit( $new_theme_path ) . 'style.css';
434
- }
435
- else
436
- {
437
- //use the default
438
- // cont/themes/twentyfifteen/style.css
439
-
440
- $default_path = get_template_directory_uri();
441
-
442
- //check for modified wp-content folder
443
- $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
444
- if(!empty($new_content_path))
445
- {
446
- $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
447
- $path = $new_content_path . $path;
448
- }
449
- else
450
- {
451
- $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
452
-
453
- $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
454
- $wp_content_folder = trim($wp_content_folder, '/');
455
-
456
- $path = $wp_content_folder . $path;
457
- }
458
-
459
- //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
460
- $path = trailingslashit( $path ) . 'style.css';
461
- }
462
-
463
- //plugin File Processor router path
464
- $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
465
- $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
466
-
467
- $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
468
-
469
- if($this->wph->server_htaccess_config === TRUE)
470
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
471
-
472
- if($this->wph->server_web_config === TRUE)
473
- $processing_response['rewrite'] = '
474
- <rule name="wph-style_file_clean" stopProcessing="true">
475
- <match url="^'. $path .'" />
476
- <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
477
- </rule>
478
- ';
479
-
480
- return $processing_response;
481
-
482
- }
483
-
484
-
485
-
486
- function _init_child_style_file_path($saved_field_data)
487
- {
488
-
489
- if(empty($saved_field_data))
490
- return FALSE;
491
-
492
- if($this->wph->functions->is_theme_customize())
493
- return;
494
-
495
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
496
-
497
- //add default replacements
498
- $template_url = trailingslashit( $this->wph->default_variables['stylesheet_uri'] );
499
- $old_style_file_path = trailingslashit( $this->wph->default_variables['stylesheet_uri'] ) . 'style.css';
500
-
501
- if(!empty($new_theme_path))
502
- {
503
- $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
504
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
505
- }
506
- else
507
- {
508
- $new_style_file_path = $template_url . $saved_field_data;
509
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
510
- }
511
-
512
-
513
-
514
- //add replacement for style.css when already template name replaced
515
- if(!empty($new_theme_path))
516
- {
517
- $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
518
- $this->wph->urls_replacement[ $old_style_file_path ] = $new_style_file_path;
519
- }
520
-
521
-
522
- }
523
-
524
- function _callback_saved_child_style_file_path($saved_field_data)
525
- {
526
-
527
- $processing_response = array();
528
-
529
- //check if the field is noe empty
530
- if(empty($saved_field_data))
531
- return $processing_response;
532
-
533
- $current_stylesheet_uri = $this->wph->default_variables['stylesheet_uri'];
534
-
535
- $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri, TRUE );
536
-
537
- $path = '';
538
- if(!empty($this->wph->default_variables['wordpress_directory']))
539
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
540
-
541
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
542
- if(!empty($new_theme_path))
543
- {
544
- $path .= trailingslashit($new_theme_path) . $saved_field_data;
545
- }
546
- else
547
- {
548
- $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
549
- $path .= trailingslashit($template_relative_url) . $saved_field_data;
550
- }
551
-
552
- $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
553
-
554
- if($this->wph->server_htaccess_config === TRUE)
555
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
556
-
557
- if($this->wph->server_web_config === TRUE)
558
- $processing_response['rewrite'] = '
559
- <rule name="wph-child_style_file_path" stopProcessing="true">
560
- <match url="^'. $path .'" />
561
- <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
562
- </rule>
563
- ';
564
-
565
- return $processing_response;
566
- }
567
-
568
-
569
- function _callback_saved_child_style_file_clean($saved_field_data)
570
- {
571
-
572
- if(empty($saved_field_data) || $saved_field_data == 'no')
573
- return FALSE;
574
-
575
- $processing_response = array();
576
-
577
- //actual style file path
578
- $current_stylesheet_uri = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
579
- $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
580
- $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
581
-
582
- //current style file path
583
- $path = '';
584
- $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
585
- $new_style_file_path = $this->wph->functions->get_module_item_setting('child_style_file_path');
586
- if(!empty($new_style_file_path))
587
- {
588
- if(!empty($this->wph->default_variables['wordpress_directory']))
589
- $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
590
-
591
- if(!empty($new_theme_path))
592
- {
593
- $path .= trailingslashit($new_theme_path) . $new_style_file_path;
594
- }
595
- else
596
- {
597
- $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
598
- $path .= trailingslashit($template_relative_url) . $new_style_file_path;
599
- }
600
- }
601
- else if(!empty($new_theme_path))
602
- {
603
- $path = trailingslashit( $new_theme_path ) . 'style.css';
604
- }
605
- else
606
- {
607
- //use the default
608
- // cont/themes/twentyfifteen/style.css
609
-
610
- $default_path = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
611
-
612
- //check for modified wp-content folder
613
- $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
614
- if(!empty($new_content_path))
615
- {
616
- $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
617
- $path = $new_content_path . $path;
618
- }
619
- else
620
- {
621
- $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
622
-
623
- $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
624
- $wp_content_folder = trim($wp_content_folder, '/');
625
-
626
- $path = $wp_content_folder . $path;
627
- }
628
-
629
- //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
630
- $path = trailingslashit( $path ) . 'style.css';
631
- }
632
-
633
- //plugin File Processor router path
634
- $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
635
- $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
636
-
637
- $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
638
-
639
- if($this->wph->server_htaccess_config === TRUE)
640
- $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
641
-
642
-
643
- if($this->wph->server_web_config === TRUE)
644
- $processing_response['rewrite'] = '
645
- <rule name="wph-style_file_clean" stopProcessing="true">
646
- <match url="^'. $path .'" />
647
- <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
648
- </rule>
649
- ';
650
-
651
- return $processing_response;
652
-
653
- }
654
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
  ?>
1
+ <?php
2
+
3
+ class WPH_module_rewrite_new_theme_path extends WPH_module_component
4
+ {
5
+
6
+ function get_component_title()
7
+ {
8
+ return "Theme";
9
+ }
10
+
11
+
12
+ function get_module_settings()
13
+ {
14
+ $this->module_settings[] = array(
15
+ 'id' => 'new_theme_path',
16
+ 'label' => __('New Theme Path', 'wp-hide-security-enhancer'),
17
+ 'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' ,$this->wph->default_variables['template_url']) .'</strong>
18
+ '. __('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
19
+
20
+ 'value_description' => __('e.g. my_template', 'wp-hide-security-enhancer'),
21
+ 'input_type' => 'text',
22
+
23
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
24
+ 'processing_order' => 10
25
+ );
26
+
27
+
28
+ $this->module_settings[] = array(
29
+ 'id' => 'new_style_file_path',
30
+ 'label' => __('New Style File Path', 'wp-hide-security-enhancer'),
31
+ 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['template_url']) .'/style.css</strong>'
32
+ .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>'
33
+ ,
34
+
35
+ 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
36
+ 'input_type' => 'text',
37
+
38
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
39
+
40
+ 'processing_order' => 5
41
+ );
42
+
43
+ $this->module_settings[] = array(
44
+ 'id' => 'style_file_clean',
45
+ 'label' => __('Remove description header from Style file', 'wp-hide-security-enhancer'),
46
+ 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
47
+ . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
48
+
49
+ 'input_type' => 'radio',
50
+ 'options' => array(
51
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
52
+ 'no' => __('No', 'wp-hide-security-enhancer'),
53
+ ),
54
+ 'default_value' => 'no',
55
+
56
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
57
+ 'processing_order' => 3
58
+
59
+ );
60
+
61
+
62
+ if($this->wph->templates_data['use_child_theme'])
63
+ {
64
+ $this->module_settings[] = array(
65
+ 'type' => 'split'
66
+
67
+ );
68
+
69
+ $this->module_settings[] = array(
70
+ 'id' => 'new_theme_child_path',
71
+ 'label' => __('Child - New Theme Path', 'wp-hide-security-enhancer'),
72
+ 'description' => __('The default theme path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , trailingslashit($this->wph->templates_data['themes_url']) . $this->wph->templates_data['child']['folder_name']) .'</strong>
73
+ '.__('More details can be found at', 'wp-hide-security-enhancer') .' <a href="http://www.nsp-code.com" target="_blank">Link</a>',
74
+
75
+ 'value_description' => __('e.g. my_child_template', 'wp-hide-security-enhancer'),
76
+ 'input_type' => 'text',
77
+
78
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
79
+ 'processing_order' => 15
80
+ );
81
+
82
+ $this->module_settings[] = array(
83
+ 'id' => 'child_style_file_path',
84
+ 'label' => __('Child - New Style File Path', 'wp-hide-security-enhancer'),
85
+ 'description' => __('The default theme style file style.css path is set to', 'wp-hide-security-enhancer') . ' <strong>'. str_replace(get_bloginfo('wpurl'), '' , $this->wph->default_variables['stylesheet_uri']) .'</strong>'
86
+ .'<div class="description"><div class="notice-error"><div alt="f534" class="dashicons dashicons-warning">warning</div> <span class="important">'. __('If style file contain relative URLs it should not include additional path, just the actual filename.', 'wp-hide-security-enhancer') .'. '. __('More details at', 'wp-hide-security-enhancer') .' <a href="http://www.wp-hide.com/new-style-file-path-along-relative-urls/" target="_blank">New Style File Path along with relative URLs</a></span></div></div>',
87
+
88
+ 'value_description' => __('e.g. custom-style-file.css', 'wp-hide-security-enhancer'),
89
+ 'input_type' => 'text',
90
+
91
+ 'sanitize_type' => array(array($this->wph->functions, 'sanitize_file_path_name')),
92
+
93
+ 'processing_order' => 5
94
+ );
95
+
96
+ $this->module_settings[] = array(
97
+ 'id' => 'child_style_file_clean',
98
+ 'label' => __('Child - Remove description header from Style file', 'wp-hide-security-enhancer'),
99
+ 'description' => __('Strip out all meta data from style file e.g. Theme Name, Theme URI, Author etc. Those are important information to find out possible theme security breaches.', 'wp-hide-security-enhancer')
100
+ . '<br />' . __('This feature may not work if style file url not available on html (being concatenated).', 'wp-hide-security-enhancer'),
101
+
102
+ 'input_type' => 'radio',
103
+ 'options' => array(
104
+ 'yes' => __('Yes', 'wp-hide-security-enhancer'),
105
+ 'no' => __('No', 'wp-hide-security-enhancer'),
106
+ ),
107
+ 'default_value' => 'no',
108
+
109
+ 'sanitize_type' => array('sanitize_title', 'strtolower'),
110
+ 'processing_order' => 3
111
+
112
+ );
113
+ }
114
+
115
+ return $this->module_settings;
116
+ }
117
+
118
+
119
+
120
+
121
+ /**
122
+ * New Theme Path
123
+ *
124
+ * @param mixed $saved_field_data
125
+ */
126
+ function _init_new_theme_path($saved_field_data)
127
+ {
128
+ if(empty($saved_field_data))
129
+ return FALSE;
130
+
131
+
132
+ /*
133
+ //check for child
134
+ if($this->wph->templates_data['use_child_theme'] === TRUE)
135
+ {
136
+ $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
137
+ if(empty($child_theme_saved_field_data) && empty($saved_field_data))
138
+ return FALSE;
139
+ }
140
+ else
141
+ {
142
+ if(empty($saved_field_data))
143
+ return FALSE;
144
+ }
145
+ */
146
+
147
+ //applay when not admin and not customize.php
148
+ /*
149
+ if(is_admin() || $this->functions->is_theme_customize())
150
+ return;
151
+ */
152
+
153
+
154
+ //???? to remove?
155
+ //add_filter('stylesheet_directory_uri', array(&$this, 'stylesheet_directory_uri'), 999, 1);
156
+ //add_filter('template_directory_uri', array(&$this, 'template_directory_uri'), 999, 3);
157
+
158
+
159
+
160
+ //add_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 999, 3);
161
+
162
+ //add replacement url
163
+ $this->wph->functions->add_replacement( trailingslashit( $this->wph->default_variables['template_url']), trailingslashit( site_url() ) . trailingslashit( $saved_field_data ));
164
+
165
+ }
166
+
167
+ function _callback_saved_new_theme_path($saved_field_data)
168
+ {
169
+ $processing_response = array();
170
+
171
+ //check if the field is noe empty
172
+ if(empty($saved_field_data))
173
+ return $processing_response;
174
+
175
+ $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['main']['folder_name'] );
176
+
177
+ $path = '';
178
+ /*
179
+ if(!empty($this->wph->default_variables['wordpress_directory']))
180
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
181
+ */
182
+ $path .= trailingslashit( $saved_field_data );
183
+
184
+ $theme_path = str_replace(' ', '%20', $theme_path);
185
+
186
+ if($this->wph->server_htaccess_config === TRUE)
187
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
188
+
189
+ if($this->wph->server_web_config === TRUE)
190
+ $processing_response['rewrite'] = '
191
+ <rule name="wph-new_theme_path" stopProcessing="true">
192
+ <match url="^'. $path .'(.*)" />
193
+ <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
194
+ </rule>
195
+ ';
196
+
197
+ return $processing_response;
198
+ }
199
+
200
+
201
+
202
+ function stylesheet_directory_uri($url)
203
+ {
204
+ if ( $this->wph->disable_filters )
205
+ return $url;
206
+
207
+ $template_slug = str_replace($this->wph->templates_data['themes_url'], "", $url);
208
+ return $url;
209
+
210
+ if($this->wph->templates_data['_template_' . $template_slug] == 'main')
211
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
212
+ else
213
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
214
+
215
+ if(empty($new_theme_path))
216
+ return $url;
217
+
218
+ $template_dir_uri = trailingslashit( home_url() ) . ltrim(rtrim($new_theme_path, "/"), "/");
219
+
220
+ //add replacement
221
+ $this->wph->functions->add_replacement( $url, $template_dir_uri );
222
+
223
+ return $template_dir_uri;
224
+ }
225
+
226
+
227
+ function template_directory_uri($template_dir_uri, $template, $theme_root_uri)
228
+ {
229
+ if ( $this->wph->disable_filters )
230
+ return $template_dir_uri;
231
+
232
+ if($this->wph->templates_data['_template_' . $template] == 'main')
233
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
234
+ else
235
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
236
+
237
+ if(empty($new_theme_path))
238
+ return $template_dir_uri;
239
+
240
+ $new_template_dir_uri = trailingslashit( home_url() ) . trim($new_theme_path, "/") ;
241
+
242
+ //add replacement
243
+ $this->wph->functions->add_replacement( $template_dir_uri, $new_template_dir_uri );
244
+
245
+ return $new_template_dir_uri;
246
+ }
247
+
248
+
249
+ /*
250
+ function theme_root_uri($theme_root_uri, $siteurl, $stylesheet_or_template)
251
+ {
252
+ if ( $this->wph->disable_filters )
253
+ return $theme_root_uri;
254
+
255
+ //only for current theme
256
+ $current_theme = get_stylesheet();
257
+ if($current_theme != $stylesheet_or_template)
258
+ return $theme_root_uri;
259
+
260
+ $theme_root_uri = untrailingslashit( site_url() ) ;
261
+
262
+ return $theme_root_uri;
263
+ }
264
+ */
265
+
266
+
267
+ function _init_new_theme_child_path($saved_field_data)
268
+ {
269
+ if(empty($saved_field_data))
270
+ return FALSE;
271
+
272
+
273
+ /*
274
+ //check for child
275
+ if($this->wph->templates_data['use_child_theme'] === TRUE)
276
+ {
277
+ $child_theme_saved_field_data = $this->wph->functions->get_module_item_setting('new_theme_child_path');
278
+ if(empty($child_theme_saved_field_data) && empty($saved_field_data))
279
+ return FALSE;
280
+ }
281
+ else
282
+ {
283
+ if(empty($saved_field_data))
284
+ return FALSE;
285
+ }
286
+ */
287
+
288
+ //applay when not admin and not customize.php
289
+ /*
290
+ if(is_admin() || $this->functions->is_theme_customize())
291
+ return;
292
+ */
293
+
294
+
295
+ //???? to remove?
296
+ //add_filter('stylesheet_directory_uri', array(&$this, 'stylesheet_directory_uri'), 999, 1);
297
+ //add_filter('template_directory_uri', array(&$this, 'template_directory_uri'), 999, 3);
298
+
299
+
300
+
301
+ //add_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 999, 3);
302
+
303
+ //add replacement url
304
+ $this->wph->functions->add_replacement( trailingslashit( $this->wph->default_variables['stylesheet_uri'] ) , trailingslashit( site_url() ) . trailingslashit( $saved_field_data ) );
305
+
306
+ }
307
+
308
+ function _callback_saved_new_theme_child_path($saved_field_data)
309
+ {
310
+ $processing_response = array();
311
+
312
+ //check if the field is noe empty
313
+ if(empty($saved_field_data))
314
+ return $processing_response;
315
+
316
+ $theme_path = $this->wph->functions->get_url_path( $this->wph->templates_data['themes_url'] . $this->wph->templates_data['child']['folder_name'] );
317
+
318
+ $path = '';
319
+ /*
320
+ if(!empty($this->wph->default_variables['wordpress_directory']))
321
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
322
+ */
323
+ $path .= trailingslashit( $saved_field_data );
324
+
325
+
326
+ $theme_path = str_replace(' ', '%20', $theme_path);
327
+
328
+ if($this->wph->server_htaccess_config === TRUE)
329
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . '(.*) '. $theme_path .'$1 [L,QSA]';
330
+
331
+ if($this->wph->server_web_config === TRUE)
332
+ $processing_response['rewrite'] = '
333
+ <rule name="wph-new_theme_child_path" stopProcessing="true">
334
+ <match url="^'. $path .'(.*)" />
335
+ <action type="Rewrite" url="'. $theme_path .'{R:1}" appendQueryString="true" />
336
+ </rule>
337
+ ';
338
+
339
+ return $processing_response;
340
+ }
341
+
342
+
343
+
344
+ function _init_new_style_file_path($saved_field_data)
345
+ {
346
+ if(empty($saved_field_data))
347
+ return FALSE;
348
+
349
+ if($this->wph->functions->is_theme_customize())
350
+ return;
351
+
352
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
353
+
354
+ //add default replacements
355
+ $template_url = trailingslashit( $this->wph->default_variables['template_url'] );
356
+ $old_style_file_path = trailingslashit( $this->wph->default_variables['template_url'] ) . 'style.css';
357
+
358
+ if(!empty($new_theme_path))
359
+ {
360
+ $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
361
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
362
+ }
363
+ else
364
+ {
365
+ $new_style_file_path = $template_url . $saved_field_data;
366
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
367
+ }
368
+
369
+
370
+
371
+ //add replacement for style.css when already template name replaced
372
+ if(!empty($new_theme_path))
373
+ {
374
+ $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
375
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
376
+ }
377
+
378
+ }
379
+
380
+ function _callback_saved_new_style_file_path($saved_field_data)
381
+ {
382
+ $processing_response = array();
383
+
384
+ //check if the field is noe empty
385
+ if(empty($saved_field_data))
386
+ return $processing_response;
387
+
388
+ $current_stylesheet_uri = $this->wph->default_variables['template_url'];
389
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
390
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
391
+
392
+ $path = '';
393
+ /*
394
+ if(!empty($this->wph->default_variables['wordpress_directory']))
395
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
396
+ */
397
+
398
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
399
+ if(!empty($new_theme_path))
400
+ {
401
+ $path .= trailingslashit($new_theme_path) . $saved_field_data;
402
+ }
403
+ else
404
+ {
405
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
406
+ $path .= trailingslashit($template_relative_url) . $saved_field_data;
407
+ }
408
+
409
+ $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
410
+
411
+ if($this->wph->server_htaccess_config === TRUE)
412
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
413
+
414
+ if($this->wph->server_web_config === TRUE)
415
+ $processing_response['rewrite'] = '
416
+ <rule name="wph-new_style_file_path" stopProcessing="true">
417
+ <match url="^'. $path .'" />
418
+ <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
419
+ </rule>
420
+ ';
421
+
422
+ return $processing_response;
423
+ }
424
+
425
+
426
+
427
+ function _callback_saved_style_file_clean($saved_field_data)
428
+ {
429
+
430
+ if(empty($saved_field_data) || $saved_field_data == 'no')
431
+ return FALSE;
432
+
433
+ $processing_response = array();
434
+
435
+ //actual style file path
436
+ $current_stylesheet_uri = $this->wph->default_variables['template_url'];
437
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
438
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
439
+
440
+ //current style file path
441
+ $path = '';
442
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_path');
443
+ $new_style_file_path = $this->wph->functions->get_module_item_setting('new_style_file_path');
444
+ if(!empty($new_style_file_path))
445
+ {
446
+ /*
447
+ if(!empty($this->wph->default_variables['wordpress_directory']))
448
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
449
+ */
450
+
451
+
452
+ if(!empty($new_theme_path))
453
+ {
454
+ $path .= trailingslashit($new_theme_path) . $new_style_file_path;
455
+ }
456
+ else
457
+ {
458
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
459
+ $path .= trailingslashit($template_relative_url) . $new_style_file_path;
460
+ }
461
+
462
+ }
463
+ else if(!empty($new_theme_path))
464
+ {
465
+ $path = trailingslashit( $new_theme_path ) . 'style.css';
466
+ }
467
+ else
468
+ {
469
+ //use the default
470
+ // cont/themes/twentyfifteen/style.css
471
+
472
+ $default_path = get_template_directory_uri();
473
+
474
+ //check for modified wp-content folder
475
+ $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
476
+ if(!empty($new_content_path))
477
+ {
478
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
479
+ $path = $new_content_path . $path;
480
+ }
481
+ else
482
+ {
483
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
484
+
485
+ $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
486
+ $wp_content_folder = trim($wp_content_folder, '/');
487
+
488
+ $path = $wp_content_folder . $path;
489
+ }
490
+
491
+ //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
492
+ $path = trailingslashit( $path ) . 'style.css';
493
+ }
494
+
495
+ //plugin File Processor router path
496
+ $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
497
+ $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
498
+
499
+ $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
500
+
501
+ if($this->wph->server_htaccess_config === TRUE)
502
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
503
+
504
+ if($this->wph->server_web_config === TRUE)
505
+ $processing_response['rewrite'] = '
506
+ <rule name="wph-style_file_clean" stopProcessing="true">
507
+ <match url="^'. $path .'" />
508
+ <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
509
+ </rule>
510
+ ';
511
+
512
+ return $processing_response;
513
+
514
+ }
515
+
516
+
517
+
518
+ function _init_child_style_file_path($saved_field_data)
519
+ {
520
+
521
+ if(empty($saved_field_data))
522
+ return FALSE;
523
+
524
+ if($this->wph->functions->is_theme_customize())
525
+ return;
526
+
527
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
528
+
529
+ //add default replacements
530
+ $template_url = trailingslashit( $this->wph->default_variables['stylesheet_uri'] );
531
+ $old_style_file_path = trailingslashit( $this->wph->default_variables['stylesheet_uri'] ) . 'style.css';
532
+
533
+ if(!empty($new_theme_path))
534
+ {
535
+ $new_style_file_path = trailingslashit( site_url() ) . trailingslashit($new_theme_path) . $saved_field_data;
536
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
537
+ }
538
+ else
539
+ {
540
+ $new_style_file_path = $template_url . $saved_field_data;
541
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
542
+ }
543
+
544
+
545
+
546
+ //add replacement for style.css when already template name replaced
547
+ if(!empty($new_theme_path))
548
+ {
549
+ $old_style_file_path = trailingslashit( site_url() ) . trailingslashit( $new_theme_path ) . 'style.css';
550
+ $this->wph->functions->add_replacement( $old_style_file_path , $new_style_file_path );
551
+ }
552
+
553
+
554
+ }
555
+
556
+ function _callback_saved_child_style_file_path($saved_field_data)
557
+ {
558
+
559
+ $processing_response = array();
560
+
561
+ //check if the field is noe empty
562
+ if(empty($saved_field_data))
563
+ return $processing_response;
564
+
565
+ $current_stylesheet_uri = $this->wph->default_variables['stylesheet_uri'];
566
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri, TRUE );
567
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
568
+
569
+ $path = '';
570
+ /*
571
+ if(!empty($this->wph->default_variables['wordpress_directory']))
572
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
573
+ */
574
+
575
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
576
+ if(!empty($new_theme_path))
577
+ {
578
+ $path .= trailingslashit($new_theme_path) . $saved_field_data;
579
+ }
580
+ else
581
+ {
582
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
583
+ $path .= trailingslashit($template_relative_url) . $saved_field_data;
584
+ }
585
+
586
+ $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
587
+
588
+ if($this->wph->server_htaccess_config === TRUE)
589
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $current_stylesheet_uri .' [L,QSA]';
590
+
591
+ if($this->wph->server_web_config === TRUE)
592
+ $processing_response['rewrite'] = '
593
+ <rule name="wph-child_style_file_path" stopProcessing="true">
594
+ <match url="^'. $path .'" />
595
+ <action type="Rewrite" url="'. $current_stylesheet_uri .'" appendQueryString="true" />
596
+ </rule>
597
+ ';
598
+
599
+ return $processing_response;
600
+ }
601
+
602
+
603
+ function _callback_saved_child_style_file_clean($saved_field_data)
604
+ {
605
+
606
+ if(empty($saved_field_data) || $saved_field_data == 'no')
607
+ return FALSE;
608
+
609
+ $processing_response = array();
610
+
611
+ //actual style file path
612
+ $current_stylesheet_uri = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
613
+ $current_stylesheet_uri = $this->wph->functions->get_url_path( $current_stylesheet_uri );
614
+ $current_stylesheet_uri = trailingslashit( $current_stylesheet_uri ) . 'style.css';
615
+
616
+ //current style file path
617
+ $path = '';
618
+ $new_theme_path = $this->wph->functions->get_module_item_setting('new_theme_child_path');
619
+ $new_style_file_path = $this->wph->functions->get_module_item_setting('child_style_file_path');
620
+ if(!empty($new_style_file_path))
621
+ {
622
+ /*
623
+ if(!empty($this->wph->default_variables['wordpress_directory']))
624
+ $path = trailingslashit($this->wph->default_variables['wordpress_directory']);
625
+ */
626
+
627
+ if(!empty($new_theme_path))
628
+ {
629
+ $path .= trailingslashit($new_theme_path) . $new_style_file_path;
630
+ }
631
+ else
632
+ {
633
+ $template_relative_url = $this->wph->functions->get_url_path_relative_to_domain_root($this->wph->default_variables['template_url']);
634
+ $path .= trailingslashit($template_relative_url) . $new_style_file_path;
635
+ }
636
+ }
637
+ else if(!empty($new_theme_path))
638
+ {
639
+ $path = trailingslashit( $new_theme_path ) . 'style.css';
640
+ }
641
+ else
642
+ {
643
+ //use the default
644
+ // cont/themes/twentyfifteen/style.css
645
+
646
+ $default_path = trailingslashit ( $this->wph->templates_data['themes_url'] ) . $this->wph->templates_data['child']['folder_name'];
647
+
648
+ //check for modified wp-content folder
649
+ $new_content_path = $this->wph->functions->get_module_item_setting('new_content_path');
650
+ if(!empty($new_content_path))
651
+ {
652
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
653
+ $path = $new_content_path . $path;
654
+ }
655
+ else
656
+ {
657
+ $path = str_replace( trailingslashit( WP_CONTENT_URL ) , "/", $default_path);
658
+
659
+ $wp_content_folder = str_replace( site_url() , '' , WP_CONTENT_URL);
660
+ $wp_content_folder = trim($wp_content_folder, '/');
661
+
662
+ $path = $wp_content_folder . $path;
663
+ }
664
+
665
+ //$path = $this->wph->functions->get_url_path( get_template_directory_uri() );
666
+ $path = trailingslashit( $path ) . 'style.css';
667
+ }
668
+
669
+ //plugin File Processor router path
670
+ $file_processor = $this->wph->functions->get_url_path( WP_PLUGIN_URL );
671
+ $file_processor = trailingslashit( $file_processor ) . 'wp-hide-security-enhancer/router/file-process.php';
672
+
673
+ $current_stylesheet_uri = str_replace(' ', '%20', $current_stylesheet_uri);
674
+
675
+ if($this->wph->server_htaccess_config === TRUE)
676
+ $processing_response['rewrite'] = "\nRewriteRule ^" . $path . ' '. $file_processor . '?action=style-clean&file_path=' . $current_stylesheet_uri .' [L,QSA]';
677
+
678
+
679
+ if($this->wph->server_web_config === TRUE)
680
+ $processing_response['rewrite'] = '
681
+ <rule name="wph-child-style_file_clean" stopProcessing="true">
682
+ <match url="^'. $path .'" />
683
+ <action type="Rewrite" url="'. $file_processor .'?action=style-clean&amp;file_path=' . $current_stylesheet_uri .'" appendQueryString="true" />
684
+ </rule>
685
+ ';
686
+
687
+ return $processing_response;
688
+
689
+ }
690
+ }
691
  ?>
modules/components/rewrite-new_upload_path.php CHANGED
@@ -49,15 +49,40 @@
49
  {
50
  if(empty($saved_field_data))
51
  return FALSE;
52
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  add_filter('upload_dir', array( $this, 'upload_dir' ), 999);
55
- //add_filter('wp_get_attachment_url', array( $this, 'wp_get_attachment_url' ), 999, 2);
56
 
57
  //add default plugin path replacement
58
  $new_upload_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_upload_path') );
59
  $new_url = trailingslashit( site_url() ) . $new_upload_path;
60
- $this->wph->urls_replacement[$this->wph->default_variables['upload_url']] = $new_url;
 
61
  }
62
 
63
  function _callback_saved_new_upload_path($saved_field_data)
@@ -102,13 +127,13 @@
102
  //$data['baseurl'] = $new_url;
103
 
104
  //add replacement
105
- if(!isset($this->wph->urls_replacement[ $this->wph->default_variables['upload_url'] ]))
106
  {
107
  //prevent media images from being replaced on admin, as when plugin disable the links will not work anymore
108
  $block_upload_url = $this->wph->functions->get_module_item_setting('block_upload_url');
109
  if(!is_admin() || (is_admin() && !empty($block_upload_url) && $block_upload_url != 'no'))
110
  {
111
- $this->wph->urls_replacement[$this->wph->default_variables['upload_url']] = $new_url;
112
  }
113
  }
114
 
49
  {
50
  if(empty($saved_field_data))
51
  return FALSE;
52
+
53
+ //Preserver uploads urls
54
+ $preserve_upload_url = TRUE;
55
+ //only within admin
56
+ if( ! is_admin() )
57
+ $preserve_upload_url = FALSE;
58
+ //only if block_upload_url is set to no
59
+ if($preserve_upload_url && $this->wph->functions->get_module_item_setting('block_upload_url') != 'no')
60
+ $preserve_upload_url = FALSE;
61
+ if($preserve_upload_url && defined('DOING_AJAX') && constant('DOING_AJAX') === TRUE)
62
+ {
63
+ if(isset($_POST['action']) && !in_array($_POST['action'], array('query-attachments', 'upload-attachment', 'send-attachment-to-editor', 'set-post-thumbnail')))
64
+ $preserve_upload_url = FALSE;
65
+ }
66
+
67
+ if( $preserve_upload_url === TRUE )
68
+ {
69
+ //preserve the links
70
+ $this->wph->functions->add_replacement( $this->wph->default_variables['upload_url'], 'WPH-preserved-upload-url', 'high');
71
+
72
+ //restore the original url
73
+ $this->wph->functions->add_replacement( 'WPH-preserved-upload-url', $this->wph->default_variables['upload_url'], 'low');
74
+
75
+ return;
76
+ }
77
+
78
 
79
  add_filter('upload_dir', array( $this, 'upload_dir' ), 999);
 
80
 
81
  //add default plugin path replacement
82
  $new_upload_path = $this->wph->functions->untrailingslashit_all( $this->wph->functions->get_module_item_setting('new_upload_path') );
83
  $new_url = trailingslashit( site_url() ) . $new_upload_path;
84
+ $this->wph->functions->add_replacement( $this->wph->default_variables['upload_url'], $new_url);
85
+
86
  }
87
 
88
  function _callback_saved_new_upload_path($saved_field_data)
127
  //$data['baseurl'] = $new_url;
128
 
129
  //add replacement
130
+ if(!isset($this->wph->functions->replacement_exists[ $this->wph->default_variables['upload_url'] ]))
131
  {
132
  //prevent media images from being replaced on admin, as when plugin disable the links will not work anymore
133
  $block_upload_url = $this->wph->functions->get_module_item_setting('block_upload_url');
134
  if(!is_admin() || (is_admin() && !empty($block_upload_url) && $block_upload_url != 'no'))
135
  {
136
+ $this->wph->functions->add_replacement($this->wph->default_variables['upload_url'], $new_url);
137
  }
138
  }
139
 
modules/components/rewrite-new_xml-rpc-path.php CHANGED
@@ -86,7 +86,7 @@
86
  //add default plugin path replacement
87
  $old_url = trailingslashit( site_url() ) . 'xmlrpc.php';
88
  $new_url = trailingslashit( site_url() ) . $saved_field_data;
89
- $this->wph->urls_replacement[$old_url] = $new_url;
90
  }
91
 
92
  function _callback_saved_new_xml_rpc_path($saved_field_data)
86
  //add default plugin path replacement
87
  $old_url = trailingslashit( site_url() ) . 'xmlrpc.php';
88
  $new_url = trailingslashit( site_url() ) . $saved_field_data;
89
+ $this->wph->functions->add_replacement( $old_url , $new_url );
90
  }
91
 
92
  function _callback_saved_new_xml_rpc_path($saved_field_data)
modules/components/rewrite-root-files.php CHANGED
@@ -159,7 +159,7 @@
159
  //add default plugin path replacement
160
  $url = trailingslashit( site_url() ) . 'wp-comments-post.php';
161
  $replacement = trailingslashit( site_url() ) . $saved_field_data;
162
- $this->wph->urls_replacement[ $url] = $replacement;
163
 
164
  return TRUE;
165
  }
159
  //add default plugin path replacement
160
  $url = trailingslashit( site_url() ) . 'wp-comments-post.php';
161
  $replacement = trailingslashit( site_url() ) . $saved_field_data;
162
+ $this->wph->functions->add_replacement( $url , $replacement );
163
 
164
  return TRUE;
165
  }
modules/components/rewrite-wp_content_path.php CHANGED
@@ -53,7 +53,7 @@
53
 
54
  //add default plugin path replacement
55
  $new_content_path = trailingslashit( site_url() ) . untrailingslashit( $saved_field_data );
56
- $this->wph->urls_replacement[trailingslashit( site_url() ) . $content_directory ] = $new_content_path;
57
 
58
  return TRUE;
59
  }
53
 
54
  //add default plugin path replacement
55
  $new_content_path = trailingslashit( site_url() ) . untrailingslashit( $saved_field_data );
56
+ $this->wph->functions->add_replacement( trailingslashit( site_url() ) . $content_directory , $new_content_path );
57
 
58
  return TRUE;
59
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.nsp-code.com/donate.php
4
  Tags: hide, security, improve security, hacking, wp hide, wordpress hide, custom login url, wp-loging.php, ap-admin
5
  Requires at least: 2.8
6
  Tested up to: 4.5.3
7
- Stable tag: 1.3.3.2
8
 
9
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
10
 
@@ -208,6 +208,24 @@ Please get in touch with us and we'll do our best to include it for a next versi
208
 
209
  == Changelog ==
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  = 1.3.3.2 =
212
  * DOMDocument encoding fix for "Remove the autogenerated meta generator"
213
 
4
  Tags: hide, security, improve security, hacking, wp hide, wordpress hide, custom login url, wp-loging.php, ap-admin
5
  Requires at least: 2.8
6
  Tested up to: 4.5.3
7
+ Stable tag: 1.3.4
8
 
9
  Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
10
 
208
 
209
  == Changelog ==
210
 
211
+ = 1.3.4 =
212
+ * Improved replacement code for Uploads, when "Block uploads URL" is set for "No" it use default media urls within the admin editor, to ensure links are still functional if plugin is disabled.
213
+ * Priority (high, normal, low) for replacement urls
214
+ * Replacement Urls for gziped buffer
215
+ * Fix rule name for child_style_file_clean on web.config IIS
216
+ * bbPress Compatibility
217
+ * BuddyPress Compatibility
218
+ * Prevent replacements on wp_redirect filter if is_404()
219
+ * Updated PO / MO translation files
220
+ * Removed in line components filters which changed the urls, leave for end buffering to make all changes.
221
+ * Fix for mod_rewrite line on child theme when router is turned Off, append the default style.css filename
222
+ * Improvements for Templates default variables to match customized themes like Sage
223
+ * Compatibility fix for Super Cache plugin ob callback
224
+ * Add IfModule mod_env.c before set nSetEnv HTTP_MOD_REWRITE On to prevent server internal error in case mod_env module is not available
225
+ * Check for Empty $saved_field_data within new plugin path component, to avoid creating rewrite rule if empty and existent path
226
+ * Improved get_home_path()
227
+ * Replacements for Relative URL's
228
+
229
  = 1.3.3.2 =
230
  * DOMDocument encoding fix for "Remove the autogenerated meta generator"
231
 
screenshot-1.png CHANGED
Binary file
wp-hide.php CHANGED
@@ -1,76 +1,74 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Hide & Security Enhancer
4
- Plugin URI: http://www.nsp-code.com
5
- Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
- Author: Nsp Code
7
- Author URI: http://www.nsp-code.com
8
- Version: 1.3.3.2
9
- Text Domain: wp-hide-security-enhancer
10
- Domain Path: /languages/
11
- */
12
-
13
-
14
- define('WPH_PATH', plugin_dir_path(__FILE__));
15
- define('WPH_VERSION', '1.3.3.2');
16
-
17
- //load language files
18
- add_action( 'plugins_loaded', 'WPH_load_textdomain');
19
- function WPH_load_textdomain()
20
- {
21
- load_plugin_textdomain('wp-hide-security-enhancer', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
22
- }
23
-
24
- include_once(WPH_PATH . '/include/wph.class.php');
25
- include_once(WPH_PATH . '/include/functions.class.php');
26
-
27
- include_once(WPH_PATH . '/include/module.class.php');
28
- include_once(WPH_PATH . '/include/module.component.class.php');
29
-
30
- register_deactivation_hook(__FILE__, 'WPH_deactivated');
31
- register_activation_hook(__FILE__, 'WPH_activated');
32
-
33
- function WPH_activated($network_wide)
34
- {
35
-
36
- flush_rewrite_rules();
37
-
38
- global $wph;
39
-
40
- //check if permalinks where saved
41
- $wph->permalinks_not_applied = ! $wph->functions->rewrite_rules_applied();
42
-
43
- //reprocess components if the permalinks where applied
44
- if($wph->permalinks_not_applied !== TRUE)
45
- {
46
- $wph->_modules_components_run();
47
- }
48
-
49
- }
50
-
51
- function WPH_deactivated()
52
- {
53
- global $wph;
54
-
55
- $wph->uninstall = TRUE;
56
- flush_rewrite_rules();
57
-
58
- //redirect to old url
59
- }
60
-
61
-
62
- global $wph;
63
- $wph = new WPH();
64
- $wph->init();
65
-
66
- /**
67
- * Early Turn ON buffering to allow a callback
68
- *
69
- */
70
- ob_start(array($wph, 'ob_start_callback'));
71
-
72
-
73
- define('WPH_URL', plugins_url('', __FILE__));
74
-
75
-
76
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Hide & Security Enhancer
4
+ Plugin URI: http://www.nsp-code.com
5
+ Description: Hide and increase Security for your WordPress website instance using smart techniques. No files are changed on your server.
6
+ Author: Nsp Code
7
+ Author URI: http://www.nsp-code.com
8
+ Version: 1.3.4
9
+ Text Domain: wp-hide-security-enhancer
10
+ Domain Path: /languages/
11
+ */
12
+
13
+
14
+ define('WPH_PATH', plugin_dir_path(__FILE__));
15
+ define('WPH_VERSION', '1.3.4');
16
+
17
+ //load language files
18
+ add_action( 'plugins_loaded', 'WPH_load_textdomain');
19
+ function WPH_load_textdomain()
20
+ {
21
+ load_plugin_textdomain('wp-hide-security-enhancer', FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages');
22
+ }
23
+
24
+ include_once(WPH_PATH . '/include/wph.class.php');
25
+ include_once(WPH_PATH . '/include/functions.class.php');
26
+
27
+ include_once(WPH_PATH . '/include/module.class.php');
28
+ include_once(WPH_PATH . '/include/module.component.class.php');
29
+
30
+ register_deactivation_hook(__FILE__, 'WPH_deactivated');
31
+ register_activation_hook(__FILE__, 'WPH_activated');
32
+
33
+ function WPH_activated($network_wide)
34
+ {
35
+
36
+ flush_rewrite_rules();
37
+
38
+ global $wph;
39
+
40
+ //check if permalinks where saved
41
+ $wph->permalinks_not_applied = ! $wph->functions->rewrite_rules_applied();
42
+
43
+ //reprocess components if the permalinks where applied
44
+ if($wph->permalinks_not_applied !== TRUE)
45
+ {
46
+ $wph->_modules_components_run();
47
+ }
48
+
49
+ }
50
+
51
+ function WPH_deactivated()
52
+ {
53
+ global $wph;
54
+
55
+ $wph->uninstall = TRUE;
56
+ flush_rewrite_rules();
57
+
58
+ //redirect to old url
59
+ }
60
+
61
+
62
+ global $wph;
63
+ $wph = new WPH();
64
+ $wph->init();
65
+
66
+ /**
67
+ * Early Turn ON buffering to allow a callback
68
+ *
69
+ */
70
+ ob_start(array($wph, 'ob_start_callback'));
71
+
72
+ define('WPH_URL', plugins_url('', __FILE__));
73
+
 
 
74
  ?>