All 404 Redirect to Homepage - Version 3.1

Version Description

  • New feature - Replace all broken images with a custom image
Download this release

Release Info

Developer osamaesh
Plugin Icon 128x128 All 404 Redirect to Homepage
Version 3.1
Comparing to
See all releases

Code changes from version 2.3 to 3.1

all-404-redirect-to-homepage.php CHANGED
@@ -1,14 +1,17 @@
1
  <?php
2
  /*
3
- Plugin Name: All 404 Redirect to Homepage
4
  Plugin URI: https://www.wp-buy.com
5
  Description: a plugin to redirect 404 pages to home page or any custom page
6
  Author: wp-buy
7
- Version: 2.3
8
  Author URI: https://www.wp-buy.com
9
  */
 
 
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit;
 
12
 
13
  define( 'OPTIONS404', 'options-404-redirect-group' );
14
  require_once ('functions.php');
@@ -19,6 +22,14 @@ add_action( 'admin_enqueue_scripts', 'p404_enqueue_styles_scripts' );
19
  add_action('wp_ajax_P404REDIRECT_HideMsg', 'P404REDIRECT_HideMsg');
20
 
21
 
 
 
 
 
 
 
 
 
22
  function p404_redirect()
23
  {
24
  if(is_404())
@@ -116,4 +127,120 @@ function p404_options_menu() {
116
 
117
  //---------------------------------------------------------------
118
  $path = plugin_basename( __FILE__ );
119
- add_action("after_plugin_row_{$path}", 'P404REDIRECT_after_plugin_row', 10, 3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /*
3
+ Plugin Name: All 404 Redirect to Homepage
4
  Plugin URI: https://www.wp-buy.com
5
  Description: a plugin to redirect 404 pages to home page or any custom page
6
  Author: wp-buy
7
+ Version: 3.1
8
  Author URI: https://www.wp-buy.com
9
  */
10
+ register_activation_hook( __FILE__, 'p404_modify_htaccess' );
11
+ register_deactivation_hook( __FILE__, 'p404_clear_htaccess' );
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
+ if ( ! defined( 'WP_CONTENT_DIR' ) ) exit;
15
 
16
  define( 'OPTIONS404', 'options-404-redirect-group' );
17
  require_once ('functions.php');
22
  add_action('wp_ajax_P404REDIRECT_HideMsg', 'P404REDIRECT_HideMsg');
23
 
24
 
25
+ function P404REDIRECT__filter_action_links( $links ) {
26
+ $links['settings'] = sprintf('<a href="%s">Settings</a>', admin_url( 'admin.php?page=all-404-redirect-to-homepage.php' ));
27
+ return $links;
28
+ }
29
+ add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'P404REDIRECT__filter_action_links', 10, 1 );
30
+
31
+
32
+
33
  function p404_redirect()
34
  {
35
  if(is_404())
127
 
128
  //---------------------------------------------------------------
129
  $path = plugin_basename( __FILE__ );
130
+ add_action("after_plugin_row_{$path}", 'P404REDIRECT_after_plugin_row', 10, 3);
131
+
132
+
133
+
134
+
135
+ add_action( 'admin_enqueue_scripts', 'misha_include_js' );
136
+
137
+ function misha_include_js()
138
+ {
139
+
140
+ if ($_GET['page'] = 'all-404-redirect-to-homepage.php') {
141
+ if (!did_action('wp_enqueue_media')) {
142
+ wp_enqueue_media();
143
+ }
144
+
145
+
146
+ wp_enqueue_script('myuploadscript', plugin_dir_url(__FILE__) . '/js/custom.js', array('jquery'));
147
+ }
148
+ }
149
+
150
+
151
+
152
+ function p404_modify_htaccess()
153
+ {
154
+ $options= P404REDIRECT_get_my_options();
155
+ if(isset($options['img_p404_status']) && $options['img_p404_status'] == 1) {
156
+ $image_id = isset($options['image_id_p404_redirect_to']) ? absint($options['image_id_p404_redirect_to']) : '';
157
+ if ($image_id != '') {
158
+ $image = wp_get_attachment_image_src($image_id);
159
+ $image = $image[0];
160
+
161
+ $ruls[] = <<<EOT
162
+ RewriteOptions inherit
163
+ <IfModule mod_rewrite.c>
164
+ RewriteEngine on
165
+ RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
166
+ RewriteRule \.(gif|jpe?g|png|bmp) $image [NC,L]
167
+ </IfModule>
168
+
169
+ EOT;
170
+ //NC (no case, case insensitive, useless in this context) and L (last rule if applied)
171
+ return p404_add_htaccess($ruls);
172
+ }
173
+ }
174
+ }
175
+
176
+
177
+ //echo WP_CONTENT_DIR;echo"<br>";
178
+ //echo ABSPATH;exit;
179
+ function p404_add_htaccess($insertion) {
180
+ //Clear the old htaccess file located inside the main website directory
181
+ $htaccess_file = WP_CONTENT_DIR.'/.htaccess';
182
+ $filename = $htaccess_file;
183
+ if (!file_exists($filename)) {
184
+ touch($filename);
185
+ }
186
+ if (is_writable($filename)) {
187
+ return array('status'=>true,'massage'=>p404_insert_with_markers_htaccess($htaccess_file, 'All_404_marker_comment_image', (array) $insertion));
188
+ }else{
189
+ return array('status'=>false,'massage'=>$insertion);
190
+ }
191
+ }
192
+
193
+ function p404_clear_htaccess()
194
+ {
195
+ $htaccess_file = WP_CONTENT_DIR.'/.htaccess';
196
+
197
+ p404_insert_with_markers_htaccess($htaccess_file, 'All_404_marker_comment_image', "");
198
+ }
199
+
200
+ function p404_insert_with_markers_htaccess( $filename, $marker, $insertion ) {
201
+ if (!file_exists( $filename ) || is_writeable( $filename ) ) {
202
+ if (!file_exists( $filename ) ) {
203
+ $markerdata = '';
204
+ } else {
205
+ $markerdata = explode( "\n", implode( '', file( $filename ) ) );
206
+ }
207
+
208
+ if ( !$f = @fopen( $filename, 'w' ) )
209
+ return false;
210
+
211
+ $foundit = false;
212
+ if ( $markerdata ) {
213
+ $state = true;
214
+ foreach ( $markerdata as $n => $markerline ) {
215
+ if (strpos($markerline, '# BEGIN ' . $marker) !== false)
216
+ $state = false;
217
+ if ( $state ) {
218
+ if ( $n + 1 < count( $markerdata ) )
219
+ fwrite( $f, "{$markerline}\n" );
220
+ else
221
+ fwrite( $f, "{$markerline}" );
222
+ }
223
+ if (strpos($markerline, '# END ' . $marker) !== false) {
224
+ fwrite( $f, "# BEGIN {$marker}\n" );
225
+ if ( is_array( $insertion ))
226
+ foreach ( $insertion as $insertline )
227
+ fwrite( $f, "{$insertline}\n" );
228
+ fwrite( $f, "# END {$marker}\n" );
229
+ $state = true;
230
+ $foundit = true;
231
+ }
232
+ }
233
+ }
234
+ if (!$foundit) {
235
+ fwrite( $f, "\n# BEGIN {$marker}\n" );
236
+ if ( is_array( $insertion ))
237
+ foreach ( $insertion as $insertline )
238
+ fwrite( $f, "{$insertline}\n" );
239
+ fwrite( $f, "# END {$marker}\n" );
240
+ }
241
+ fclose( $f );
242
+ return true;
243
+ } else {
244
+ return false;
245
+ }
246
+ }
functions.php CHANGED
@@ -200,3 +200,4 @@ function P404REDIRECT_there_is_cache()
200
  }
201
  return '';
202
  }
 
200
  }
201
  return '';
202
  }
203
+
js/custom.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($){
2
+
3
+ // on upload button click
4
+ $('body').on( 'click', '.misha-upl', function(e){
5
+
6
+ e.preventDefault();
7
+
8
+ var button = $(this),
9
+ custom_uploader = wp.media({
10
+ title: 'Insert image',
11
+ library : {
12
+ // uploadedTo : wp.media.view.settings.post.id, // attach to the current post?
13
+ type : 'image'
14
+ },
15
+ button: {
16
+ text: 'Use this image' // button label text
17
+ },
18
+ multiple: false
19
+ }).on('select', function() { // it also has "open" and "close" events
20
+ var attachment = custom_uploader.state().get('selection').first().toJSON();
21
+ button.html('<img src="' + attachment.url + '" style="max-width: 80px;">').next().val(attachment.id).next().show();
22
+ $(".misha-img").val(attachment.id);
23
+ $(".misha-rmv").show();
24
+ }).open();
25
+
26
+ });
27
+
28
+ // on remove button click
29
+ $('body').on('click', '.misha-rmv', function(e){
30
+
31
+ e.preventDefault();
32
+
33
+ var button = $(this);
34
+ button.next().val(''); // emptying the hidden field
35
+ button.hide().prev().html('<span>Upload image</span>');
36
+ $(".misha-rmv").hide();
37
+ });
38
+
39
+ });
option_page.php CHANGED
@@ -11,12 +11,52 @@ $nonce = isset($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce'
11
 
12
  if($redirect_to !=='')
13
  {
14
- if(wp_verify_nonce( $nonce, 'p404home_nounce' ))
 
15
  {
16
  P404REDIRECT_save_option_value('p404_redirect_to',$redirect_to);
17
- P404REDIRECT_save_option_value('p404_status',sanitize_text_field($_POST['p404_status']));
18
- P404REDIRECT_option_msg('Options Saved!');
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }else
21
  {
22
  P404REDIRECT_failure_option_msg('Unable to save data!');
@@ -26,7 +66,7 @@ $options= P404REDIRECT_get_my_options();
26
  ?>
27
 
28
  <?php
29
- if(P404REDIRECT_there_is_cache()!='')
30
  P404REDIRECT_info_option_msg("You have a cache plugin installed <b>'" . P404REDIRECT_there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! ");
31
  ?>
32
  <style>
@@ -41,53 +81,119 @@ P404REDIRECT_info_option_msg("You have a cache plugin installed <b>'" . P404REDI
41
  border: 1px solid #ccc;
42
  border-top: 0;
43
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  </style>
45
  <div class="wrap">
46
  <div ><div class='inner'>
47
  <h2>All 404 Redirect to Homepage</h2>
48
-
49
  <?php
50
- $tab = "options";
51
- if(array_key_exists('tab',$_GET))
52
- {
53
- $tab = htmlspecialchars(strip_tags(filter_var($_GET['tab'], FILTER_SANITIZE_URL)));
54
- }
55
  ?>
56
 
57
  <nav class="nav-tab-wrapper wp-clearfix" aria-label="Secondary menu">
58
- <a href="?page=all-404-redirect-to-homepage.php&tab=options" class="nav-tab <?php if($tab=='options' ) echo 'nav-tab-active';?>">Options</a>
59
- <a href="?page=all-404-redirect-to-homepage.php&tab=404urls" class="nav-tab <?php if($tab=='404urls' ) echo 'nav-tab-active';?>">404 URLs</a>
60
  </nav>
61
  <div id="tabs_content">
62
  <?php
63
  // ---- Options Tab ----------------
64
- if($tab == "options"){
65
  ?>
66
  <form method="POST">
67
- 404 Redirection Status:
 
68
  <?php
69
  $drop = new p404redirect_dropdown('p404_status');
70
- $drop->add('Enabled','1');
71
  $drop->add('Disabled','2');
72
  $drop->dropdown_print();
73
  $drop->select($options['p404_status']);
74
  ?>
75
-
76
  <br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
- Redirect all 404 pages to:
79
- <input type="text" name="redirect_to" id="redirect_to" size="30" value="<?php echo esc_attr($options['p404_redirect_to']);?>">
80
-
 
 
 
 
 
 
 
 
 
 
 
81
  <br/>
 
 
 
 
 
 
 
 
 
 
 
 
82
  <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce = wp_create_nonce('p404home_nounce'); ?>" />
83
  <br />
84
- <input class="button-primary" type="submit" value=" Update Options " name="Save_Options"></form>
 
 
 
85
  <?php
86
- }else if($tab == "404urls"){
87
  // ---- 404 URLs Tab ----------------
88
  ?>
89
  <div>
90
-
91
  <hr/>
92
 
93
  <b style="color:red"><?php echo esc_html(P404REDIRECT_read_option_value('links',0));?></b> URLs redirected since the plugin install in <?php echo esc_attr(P404REDIRECT_read_option_value('install_date',date("Y-m-d h:i a")));?>
@@ -105,14 +211,14 @@ if($tab == "options"){
105
  </thead>
106
  <tbody>
107
 
108
-
109
  <?php
110
  $links = P404REDIRECT_read_option_value('redirected_links',array());
111
  if(count($links)==0){
112
  ?>
113
  <tr><td colspan="3">No 404 links redirected yet.</td></tr>
114
  <?php
115
- } else{
116
  for($i=0; $i<count($links); $i++){
117
  ?>
118
  <tr>
@@ -121,7 +227,7 @@ if(count($links)==0){
121
  <td><a target="_blank" href="<?php echo esc_url($links[$i]['link']);?>"><?php echo esc_url($links[$i]['link']);?></a></td>
122
  </tr>
123
  <?php }} ?>
124
-
125
 
126
  </tbody>
127
  </table>
@@ -137,4 +243,4 @@ if(count($links)==0){
137
  <p>
138
  <a href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/#404plugin_img" target="_blank"><img src="<?php echo esc_url(plugin_dir_url(__FILE__));?>/images/seopro.png" /></a>
139
  </p>
140
- </div></div></div>
11
 
12
  if($redirect_to !=='')
13
  {
14
+
15
+ if(wp_verify_nonce( $nonce, 'p404home_nounce' ))
16
  {
17
  P404REDIRECT_save_option_value('p404_redirect_to',$redirect_to);
18
+ P404REDIRECT_save_option_value('p404_status',sanitize_text_field($_POST['p404_status']));
19
+ P404REDIRECT_save_option_value('img_p404_status',sanitize_text_field($_POST['img_p404_status']));
20
+ P404REDIRECT_save_option_value('image_id_p404_redirect_to',sanitize_text_field($_POST['misha-img']));
21
+ if(isset($_POST['img_p404_status']) && $_POST['img_p404_status'] == 1 ) {
22
+ if(isset($_POST['misha-img']) && $_POST['misha-img'] != ''){
23
+ $mod_file = p404_modify_htaccess();
24
+
25
+ if($mod_file['status']){
26
+ P404REDIRECT_option_msg('Options Saved!');
27
+ }else{
28
+ ?>
29
+ <div class="no_access">
30
+ Your .htaccess file is not writable; You need to modify the file manually.<br>
31
+ Please copy and paste the following code into the first line of the .htaccess file <br>
32
+ <code>
33
+ <?php
34
+ $image = wp_get_attachment_image_src(absint($_POST['misha-img']));
35
+ $image = $image[0];
36
+
37
+ ?>
38
+ <br><br>
39
+ RewriteOptions inherit<br>
40
+ &#60;IfModule mod_rewrite.c><br>
41
+ RewriteEngine on<br>
42
+ RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f<br>
43
+ RewriteRule \.(gif|jpe?g|png|bmp) <?php echo esc_url($image);?> [NC,L]<br>
44
+ &#60;/IfModule><br>
45
+
46
+ </code><br><br>
47
+ </div>
48
+ <?php
49
+ }
50
+ }else{
51
+ P404REDIRECT_warning_option_msg('Please upload a new default image');
52
+ }
53
+
54
+ }else{
55
+ p404_clear_htaccess();
56
+ P404REDIRECT_option_msg('Options Saved!');
57
+ }
58
+
59
+
60
  }else
61
  {
62
  P404REDIRECT_failure_option_msg('Unable to save data!');
66
  ?>
67
 
68
  <?php
69
+ if(P404REDIRECT_there_is_cache()!='')
70
  P404REDIRECT_info_option_msg("You have a cache plugin installed <b>'" . P404REDIRECT_there_is_cache() . "'</b>, you have to clear cache after any changes to get the changes reflected immediately! ");
71
  ?>
72
  <style>
81
  border: 1px solid #ccc;
82
  border-top: 0;
83
  }
84
+ a.misha-upl>span {
85
+ text-decoration: underline;
86
+
87
+
88
+ }
89
+
90
+ a.misha-rmv {
91
+ text-decoration: underline;
92
+ }
93
+
94
+ .no_access {
95
+ background-color: #f7dbdb;
96
+ width: 98%;
97
+ border: 2px dashed red;
98
+ padding: 20px;
99
+ font-size: 15px;
100
+ font-weight: bold;
101
+ }
102
+ .form-input-titles{
103
+ width:300px; line-height:40px
104
+ }
105
  </style>
106
  <div class="wrap">
107
  <div ><div class='inner'>
108
  <h2>All 404 Redirect to Homepage</h2>
109
+
110
  <?php
111
+ $mytab = isset($_REQUEST['mytab']) ? sanitize_text_field($_REQUEST['mytab']) : "options";
112
+
 
 
 
113
  ?>
114
 
115
  <nav class="nav-tab-wrapper wp-clearfix" aria-label="Secondary menu">
116
+ <a href="?page=all-404-redirect-to-homepage.php&mytab=options" class="nav-tab <?php if($mytab=='options' ) echo 'nav-tab-active';?>">Options</a>
117
+ <a href="?page=all-404-redirect-to-homepage.php&mytab=404urls" class="nav-tab <?php if($mytab=='404urls' ) echo 'nav-tab-active';?>">404 URLs</a>
118
  </nav>
119
  <div id="tabs_content">
120
  <?php
121
  // ---- Options Tab ----------------
122
+ if($mytab == "options"){
123
  ?>
124
  <form method="POST">
125
+ <h3>404 Pages</h3>
126
+ <div class="form-input-titles">404 Redirection Status:</div>
127
  <?php
128
  $drop = new p404redirect_dropdown('p404_status');
129
+ $drop->add('Enabled','1');
130
  $drop->add('Disabled','2');
131
  $drop->dropdown_print();
132
  $drop->select($options['p404_status']);
133
  ?>
134
+
135
  <br/><br/>
136
+
137
+ <div class="form-input-titles">Redirect all 404 pages to:</div>
138
+ <input type="text" name="redirect_to" id="redirect_to" size="30" value="<?php echo esc_attr($options['p404_redirect_to']);?>">
139
+ <br>
140
+ <br>
141
+
142
+ <h3>404 Images</h3>
143
+ <div class="form-input-titles">Image 404 Redirection Status:</div>
144
+ <?php
145
+ $drop = new p404redirect_dropdown('img_p404_status');
146
+ $drop->add('Enabled','1');
147
+ $drop->add('Disabled','2');
148
+ $drop->dropdown_print();
149
+ $image_status_val = '';
150
+ if(isset($options['img_p404_status'])){
151
+ $image_status_val = $options['img_p404_status'];
152
+ }
153
+ $drop->select($image_status_val);
154
+ ?>
155
+
156
+ <br/><br/>
157
 
158
+ <div id="myimage404_lable">
159
+ Redirect all 404 images to:
160
+ </div>
161
+ <?php
162
+ $image_id = isset($options['image_id_p404_redirect_to'])?absint($options['image_id_p404_redirect_to']):'';
163
+ if( !wp_get_attachment_image_src($image_id) && $image_id == '') {
164
+
165
+ ?>
166
+ <a href="#" class="misha-upl"><span>Upload image</span></a>
167
+ <a href="#" onclick="javascript:document.getElementById('myimage404').style.display='none'; document.getElementById('myimage404_lable').style.display='none'; " class="misha-rmv" style="display:none">Remove image</a>
168
+ <input type="hidden" class="misha-img" name="misha-img" value="" >
169
+ <?php
170
+ }
171
+ ?>
172
  <br/>
173
+
174
+ <?php
175
+ if( wp_get_attachment_image_src($image_id) && $image_id != '') {
176
+ $image = wp_get_attachment_image_src($image_id);
177
+ ?>
178
+
179
+ <br><a href="#" class="misha-upl"><img id="myimage404" src="<?php echo esc_url($image[0]);?>" style="max-width: 80px;"/></a><br>
180
+ <a href="#" onclick="javascript:document.getElementById('myimage404').style.display='none'; document.getElementById('myimage404_lable').style.display='none'; " class="misha-rmv">Remove image</a>
181
+ <input type="hidden" class="misha-img" name="misha-img" value="<?php esc_attr_e($image_id);?>">
182
+ <?php
183
+ }?>
184
+
185
  <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce = wp_create_nonce('p404home_nounce'); ?>" />
186
  <br />
187
+ <br />
188
+ <hr>
189
+ <br />
190
+ <input class="button-primary" type="submit" value=" Update Options " name="Save_Options"></form>
191
  <?php
192
+ }else if($mytab == "404urls"){
193
  // ---- 404 URLs Tab ----------------
194
  ?>
195
  <div>
196
+
197
  <hr/>
198
 
199
  <b style="color:red"><?php echo esc_html(P404REDIRECT_read_option_value('links',0));?></b> URLs redirected since the plugin install in <?php echo esc_attr(P404REDIRECT_read_option_value('install_date',date("Y-m-d h:i a")));?>
211
  </thead>
212
  <tbody>
213
 
214
+
215
  <?php
216
  $links = P404REDIRECT_read_option_value('redirected_links',array());
217
  if(count($links)==0){
218
  ?>
219
  <tr><td colspan="3">No 404 links redirected yet.</td></tr>
220
  <?php
221
+ } else{
222
  for($i=0; $i<count($links); $i++){
223
  ?>
224
  <tr>
227
  <td><a target="_blank" href="<?php echo esc_url($links[$i]['link']);?>"><?php echo esc_url($links[$i]['link']);?></a></td>
228
  </tr>
229
  <?php }} ?>
230
+
231
 
232
  </tbody>
233
  </table>
243
  <p>
244
  <a href="https://www.wp-buy.com/product/seo-redirection-premium-wordpress-plugin/#404plugin_img" target="_blank"><img src="<?php echo esc_url(plugin_dir_url(__FILE__));?>/images/seopro.png" /></a>
245
  </p>
246
+ </div></div></div>
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === All 404 Redirect to Homepage ===
2
  Contributors: wp-buy, osama.esh
3
- Tags: 404 error, redirection, homepage, redirection, https, automatic redirection, 404 link,redirect, soft 404, redirected, 301 seo redirect, post redirect plugin, broken links, fix 404
4
  Requires at least: 3.5
5
- Tested up to: 5.8
6
- Stable tag: 2.3
7
 
8
  By using this smart plugin, you can fix all 404 error links by redirecting them to homepage using the SEO 301 redirection. Improve your visibility in search engines now..
9
 
@@ -13,11 +13,11 @@ By this plugin you can fix all random 404 links appear in you your website and r
13
 
14
  **How to use the plugin?**
15
 
16
- <p>1. After installing the plugin go to the plugin control panel from settings menu.</p>
17
- <p>2. Put the link where the plugin should redirect all 404 links in the text box.</p>
18
- <p>3. Select the plugin status to be enabled.</p>
19
- <p>4. Click the button <b>Update Options</b> to save the from.</p>
20
- <p>5. Go to <b>404 URLs</b> tab to see the latest 404 links discovered and redirected</p>
21
 
22
  **Note**
23
  Please make sure than the page you put above in the control panel to redirect all 404 to it is a valid link. If this page is not valid it will be considred as an 404 link and will result in redirect loop. In case of redirect loop you can simply disable the plugin and check the page is valid or not.
@@ -34,6 +34,10 @@ Extract the zip file and just drop the contents in the wp-content/plugins/ direc
34
 
35
  == Changelog ==
36
 
 
 
 
 
37
  = 2.3 =
38
  * Bug Fixes - Escaping URLs
39
 
1
+ === All 404 Redirect to Homepage & Broken images Redirection ===
2
  Contributors: wp-buy, osama.esh
3
+ Tags: 404 error, redirection, homepage, broken images, redirection, https, automatic redirection, 404 link,redirect, soft 404, redirected, 301 seo redirect, post redirect plugin, broken links, fix 404
4
  Requires at least: 3.5
5
+ Tested up to: 5.8.1
6
+ Stable tag: 3.1
7
 
8
  By using this smart plugin, you can fix all 404 error links by redirecting them to homepage using the SEO 301 redirection. Improve your visibility in search engines now..
9
 
13
 
14
  **How to use the plugin?**
15
 
16
+ - 1. After installing the plugin go to the plugin control panel from settings menu.
17
+ - 2. Put the link where the plugin should redirect all 404 links in the text box.
18
+ - 3. Select the plugin status to be enabled.
19
+ - 4. Click the button <b>Update Options</b> to save the from.
20
+ - 5. Go to <b>404 URLs</b> tab to see the latest 404 links discovered and redirected
21
 
22
  **Note**
23
  Please make sure than the page you put above in the control panel to redirect all 404 to it is a valid link. If this page is not valid it will be considred as an 404 link and will result in redirect loop. In case of redirect loop you can simply disable the plugin and check the page is valid or not.
34
 
35
  == Changelog ==
36
 
37
+ = 3.1 =
38
+ * New feature - Replace all broken images with a custom image
39
+
40
+
41
  = 2.3 =
42
  * Bug Fixes - Escaping URLs
43
 
screenshot-1.png CHANGED
Binary file
uninstall.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * All 404 Redirect to Homepage Uninstall
4
+ *
5
+ * Uninstalling All 404 Redirect to Homepage .
6
+ *
7
+ */
8
+
9
+ defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
10
+ p404_Uninstall_clear_htaccess();
11
+ function p404_Uninstall_clear_htaccess()
12
+ {
13
+ $htaccess_file = wp_upload_dir(null, true, true).'/.htaccess';
14
+
15
+ p404_Uninstall_insert_with_markers_htaccess($htaccess_file, 'All_404_marker_comment_image', "");
16
+ }
17
+ function p404_Uninstall_insert_with_markers_htaccess( $filename, $marker, $insertion ) {
18
+ if (!file_exists( $filename ) || is_writeable( $filename ) ) {
19
+ if (!file_exists( $filename ) ) {
20
+ $markerdata = '';
21
+ } else {
22
+ $markerdata = explode( "\n", implode( '', file( $filename ) ) );
23
+ }
24
+
25
+ if ( !$f = @fopen( $filename, 'w' ) )
26
+ return false;
27
+
28
+ $foundit = false;
29
+ if ( $markerdata ) {
30
+ $state = true;
31
+ foreach ( $markerdata as $n => $markerline ) {
32
+ if (strpos($markerline, '# BEGIN ' . $marker) !== false)
33
+ $state = false;
34
+ if ( $state ) {
35
+ if ( $n + 1 < count( $markerdata ) )
36
+ fwrite( $f, "{$markerline}\n" );
37
+ else
38
+ fwrite( $f, "{$markerline}" );
39
+ }
40
+ if (strpos($markerline, '# END ' . $marker) !== false) {
41
+ fwrite( $f, "# BEGIN {$marker}\n" );
42
+ if ( is_array( $insertion ))
43
+ foreach ( $insertion as $insertline )
44
+ fwrite( $f, "{$insertline}\n" );
45
+ fwrite( $f, "# END {$marker}\n" );
46
+ $state = true;
47
+ $foundit = true;
48
+ }
49
+ }
50
+ }
51
+ if (!$foundit) {
52
+ fwrite( $f, "\n# BEGIN {$marker}\n" );
53
+ if ( is_array( $insertion ))
54
+ foreach ( $insertion as $insertline )
55
+ fwrite( $f, "{$insertline}\n" );
56
+ fwrite( $f, "# END {$marker}\n" );
57
+ }
58
+ fclose( $f );
59
+ return true;
60
+ } else {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ wp_cache_flush();
66
+