404 to Start - Version 1.3.2

Version Description

(27.02.2013) = * Replacing deprecated function

Download this release

Release Info

Developer 1manfactory
Plugin Icon 128x128 404 to Start
Version 1.3.2
Comparing to
See all releases

Version 1.3.2

Files changed (8) hide show
  1. 404-to-start.php +207 -0
  2. lang/de_DE.mo +0 -0
  3. lang/de_DE.po +57 -0
  4. lang/k_SK.po +56 -0
  5. lang/sk_SK.mo +0 -0
  6. readme.txt +95 -0
  7. screenshot-1.png +0 -0
  8. whatsup.php +1 -0
404-to-start.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: 404-to-start
4
+ Plugin URI: http://1manfactory.com/4042start
5
+ Description: Send every 404 page not found error directly to start page (or any other page/site) to overcome problems with search engines
6
+ Version: 1.3.2
7
+ Author: J&uuml;rgen Schulze
8
+ Author URI: http://1manfactory.com
9
+ License: GNU GPL
10
+ */
11
+
12
+ /* Copyright 2010-2013 Juergen Schulze, 1manfactory.com (email : 1manfactory@gmail.com)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ */
28
+
29
+
30
+ f042start_set_lang_file();
31
+ add_action('admin_init', 'f042start_register_settings' );
32
+ add_action('admin_menu', 'f042start_plugin_admin_menu');
33
+ add_action('template_redirect', 'f042start_output_header');
34
+ register_activation_hook(__FILE__, 'f042start_activate');
35
+ register_deactivation_hook(__FILE__, 'f042start_deactivate');
36
+ register_uninstall_hook(__FILE__, 'f042start_uninstall');
37
+
38
+ function f042start_register_settings() { // whitelist options
39
+ register_setting( 'f042start_option-group', 'f042start_type' );
40
+ register_setting( 'f042start_option-group', 'f042start_target', 'f042start_check_values');
41
+ }
42
+
43
+
44
+ function f042start_set_lang_file() {
45
+ # set the language file
46
+ $currentLocale = get_locale();
47
+ if(!empty($currentLocale)) {
48
+ $moFile = dirname(__FILE__) . "/lang/" . $currentLocale . ".mo";
49
+ if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('f042start', $moFile);
50
+ }
51
+ }
52
+
53
+ function f042start_deactivate() {
54
+ // needed
55
+ delete_option('f042start_type');
56
+ delete_option('f042start_target');
57
+ }
58
+
59
+ function f042start_activate() {
60
+ # setting default values
61
+ add_option('f042start_type', '301');
62
+ add_option('f042start_target', home_url());
63
+ }
64
+
65
+
66
+ function f042start_uninstall() {
67
+ # delete all data stored
68
+ delete_option('f042start_type');
69
+ delete_option('f042start_target');
70
+ }
71
+
72
+ function f042start_plugin_admin_menu() {
73
+ add_options_page(__('404 to Start Settings', 'f042start'), "404 to Start", 'manage_options', basename(__FILE__), 'f042start_plugin_options');
74
+ }
75
+
76
+
77
+ function f042start_plugin_options(){
78
+
79
+ if (!current_user_can('manage_options')) {
80
+ wp_die( __('You do not have sufficient permissions to access this page.') );
81
+ }
82
+
83
+ if (get_option("f042start_target")=="") {
84
+ // setting target value to home url if empty (maybe because of plugin update)
85
+ add_option('f042start_target', home_url());
86
+ }
87
+
88
+ print '<div class="wrap">';
89
+
90
+ print '<h2>'.__('404 to Start Settings', 'f042start').'</h2>';
91
+
92
+ print '<form method="post" action="options.php" id="f042start_form">';
93
+ wp_nonce_field('update-options', '_wpnonce');
94
+ settings_fields( 'f042start_option-group');
95
+
96
+ print'
97
+ <input type="hidden" name="page_options" value="f042start_type, f042start_target" />
98
+ <table class="form-table">
99
+ <tr valign="top">
100
+ <th scope="row">'.__('404 Redirect', 'f042start').'</th>
101
+ </tr>
102
+ <tr>
103
+ <td>
104
+ <input type="radio" name="f042start_type" value="off" '.f042start_checked("f042start_type", "off").'/> '.__('off', 'f042start').' <br />
105
+ <input type="radio" name="f042start_type" value="301" '.f042start_checked("f042start_type", "301").'/> '.__('301 - Moved permanently', 'f042start').'<br />
106
+ <input type="radio" name="f042start_type" value="302" '.f042start_checked("f042start_type", "302").'/> '.__('302 - Found/ Moved temporarily (not recommended)', 'f042start').'<br />
107
+ </td>
108
+ </tr>
109
+ <tr>
110
+ <td>
111
+ '.__('Target Url: (Start with http://)', 'f042start').' <input type="text" name="f042start_target" value="'.get_option("f042start_target").'" size="100">
112
+ </td>
113
+ </tr>
114
+ </table>
115
+ <input type="hidden" name="action" value="update" />
116
+
117
+ ';
118
+
119
+
120
+ print '<p class="submit"><input type="submit" name="submit" value="'.__('Save Changes', 'f042start').'" /></p>';
121
+
122
+ print '</form>';
123
+ print '</div>';
124
+
125
+ print '<br /><br /><br />';
126
+ require_once('whatsup.php');
127
+
128
+ }
129
+
130
+ // sanitize function
131
+ function f042start_check_values($input) {
132
+ # check target url
133
+ if (!f042start_is_valid_url($input)) {
134
+ add_settings_error('f042start_option-group', 'settings_updated', __('This is not a valid Url', 'f042start'), $type = 'error');
135
+ }
136
+ return $input;
137
+ }
138
+
139
+
140
+ function f042start_checked($checkOption, $checkValue) {
141
+ return get_option($checkOption)==$checkValue ? " checked" : "";
142
+ }
143
+
144
+
145
+ // Trap 404 errors and redirect them to start page
146
+ // 301=permanently moved
147
+ // 302=temporary
148
+ function f042start_output_header() {
149
+
150
+ if ( !is_404() || get_option("f042start_type")=="off" ) return;
151
+
152
+ # setting default target to prevent errors
153
+ if (get_option('f042start_target')=="") {
154
+ $target=home_url();
155
+ } else {
156
+ $target=get_option("f042start_target");
157
+ }
158
+
159
+ wp_redirect( $target, get_option("f042start_type") );
160
+ }
161
+
162
+
163
+ # http://www.roscripts.com/snippets/show/156
164
+ function f042start_is_valid_url ( $url )
165
+ {
166
+ $url = @parse_url($url);
167
+
168
+ if ( ! $url) {
169
+ return false;
170
+ }
171
+
172
+ $url = array_map('trim', $url);
173
+ $url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port'];
174
+ $path = (isset($url['path'])) ? $url['path'] : '';
175
+
176
+ if ($path == '')
177
+ {
178
+ $path = '/';
179
+ }
180
+
181
+ $path .= ( isset ( $url['query'] ) ) ? "?$url[query]" : '';
182
+
183
+ if ( isset ( $url['host'] ) AND $url['host'] != gethostbyname ( $url['host'] ) )
184
+ {
185
+ if ( PHP_VERSION >= 5 )
186
+ {
187
+ $headers = get_headers("$url[scheme]://$url[host]:$url[port]$path");
188
+ }
189
+ else
190
+ {
191
+ $fp = fsockopen($url['host'], $url['port'], $errno, $errstr, 30);
192
+
193
+ if ( ! $fp )
194
+ {
195
+ return false;
196
+ }
197
+ fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $url[host]\r\n\r\n");
198
+ $headers = fread ( $fp, 128 );
199
+ fclose ( $fp );
200
+ }
201
+ $headers = ( is_array ( $headers ) ) ? implode ( "\n", $headers ) : $headers;
202
+ return ( bool ) preg_match ( '#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers );
203
+ }
204
+ return false;
205
+ }
206
+
207
+ ?>
lang/de_DE.mo ADDED
Binary file
lang/de_DE.po ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: f042start\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-03-03 12:59+0100\n"
6
+ "PO-Revision-Date: 2011-03-03 12:59+0100\n"
7
+ "Last-Translator: Juergen <1manfactory@gmail.com>\n"
8
+ "Language-Team: Juergen Schulze <1manfactory@gmail.com>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: c:\\Programme\\xampp\\htdocs\\blog\\\n"
14
+ "X-Poedit-Language: German\n"
15
+ "X-Poedit-Country: GERMANY\n"
16
+ "X-Poedit-SearchPath-0: wp-content\\plugins\\404-to-start\n"
17
+
18
+ #: wp-content\plugins\404-to-start/404-to-start.php:76
19
+ #: wp-content\plugins\404-to-start/404-to-start.php:93
20
+ msgid "404 to Start Settings"
21
+ msgstr "404 to Start Einstellungen"
22
+
23
+ #: wp-content\plugins\404-to-start/404-to-start.php:83
24
+ msgid "You do not have sufficient permissions to access this page."
25
+ msgstr "Sie haben nicht ausreichend Rechte, um auf diese Seite zuzugreifen."
26
+
27
+ #: wp-content\plugins\404-to-start/404-to-start.php:103
28
+ msgid "404 Redirect"
29
+ msgstr "404 Umleitung"
30
+
31
+ #: wp-content\plugins\404-to-start/404-to-start.php:107
32
+ msgid "off"
33
+ msgstr "aus"
34
+
35
+ #: wp-content\plugins\404-to-start/404-to-start.php:108
36
+ #, fuzzy
37
+ msgid "301 - Moved permanently"
38
+ msgstr "301 - Moved Permanently"
39
+
40
+ #: wp-content\plugins\404-to-start/404-to-start.php:109
41
+ msgid "302 - Found/ Moved temporarily (not recommended)"
42
+ msgstr "302 - Found/ Moved temporarily (nicht empfohlen)"
43
+
44
+ #: wp-content\plugins\404-to-start/404-to-start.php:114
45
+ msgid "Target Url: (Start with http://)"
46
+ msgstr "Ziel Url: (Beginnen mit http://)"
47
+
48
+ #: wp-content\plugins\404-to-start/404-to-start.php:123
49
+ msgid "Save Changes"
50
+ msgstr "Änderungen speichern"
51
+
52
+ #: wp-content\plugins\404-to-start/404-to-start.php:137
53
+ msgid "This is not a valid Url"
54
+ msgstr "Die ist keine gültige Url"
55
+
56
+ #~ msgid "404 Redirect to:"
57
+ #~ msgstr "404 Umleitung nach:"
lang/k_SK.po ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: f042start\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-03-03 12:59+0100\n"
6
+ "PO-Revision-Date: 2012-12-21 13:44+0200\n"
7
+ "Last-Translator: Juergen <1manfactory@gmail.com>\n"
8
+ "Language-Team: Juergen Schulze <1manfactory@gmail.com>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__\n"
13
+ "X-Poedit-Basepath: c:\\Programme\\xampp\\htdocs\\blog\\\n"
14
+ "Language: de_DE\n"
15
+ "X-Generator: Poedit 1.5.4\n"
16
+ "X-Poedit-SearchPath-0: wp-content\\plugins\\404-to-start\n"
17
+
18
+ #: wp-content\plugins\404-to-start/404-to-start.php:76
19
+ #: wp-content\plugins\404-to-start/404-to-start.php:93
20
+ msgid "404 to Start Settings"
21
+ msgstr "404 na Štart Nastavenie"
22
+
23
+ #: wp-content\plugins\404-to-start/404-to-start.php:83
24
+ msgid "You do not have sufficient permissions to access this page."
25
+ msgstr "Nemáte dostatočné oprávnenie k prístupu na túto stránku."
26
+
27
+ #: wp-content\plugins\404-to-start/404-to-start.php:103
28
+ msgid "404 Redirect"
29
+ msgstr "404 Presmerovanie"
30
+
31
+ #: wp-content\plugins\404-to-start/404-to-start.php:107
32
+ msgid "off"
33
+ msgstr "zo"
34
+
35
+ #: wp-content\plugins\404-to-start/404-to-start.php:108
36
+ msgid "301 - Moved permanently"
37
+ msgstr "301 - Trvalo presunuté"
38
+
39
+ #: wp-content\plugins\404-to-start/404-to-start.php:109
40
+ msgid "302 - Found/ Moved temporarily (not recommended)"
41
+ msgstr "302 - Nájdené / presunuté dočasne (neodporúča sa)"
42
+
43
+ #: wp-content\plugins\404-to-start/404-to-start.php:114
44
+ msgid "Target Url: (Start with http://)"
45
+ msgstr "Cieľová adresa URL: (Začnite s http://)"
46
+
47
+ #: wp-content\plugins\404-to-start/404-to-start.php:123
48
+ msgid "Save Changes"
49
+ msgstr "Uložiť zmeny"
50
+
51
+ #: wp-content\plugins\404-to-start/404-to-start.php:137
52
+ msgid "This is not a valid Url"
53
+ msgstr "Toto nie je platná adresa URL"
54
+
55
+ #~ msgid "404 Redirect to:"
56
+ #~ msgstr "404 Umleitung nach:"
lang/sk_SK.mo ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === 404-to-start ===
2
+ Contributors: 1manfactory
3
+ Donate link: http://1manfactory.com/donate
4
+ Tags: 404, start, start page, page not found, redirect, umleiten, startseite, fehler
5
+ Requires at least: 3.0
6
+ Tested up to: 3.5
7
+ Stable tag: 1.3.2
8
+
9
+ Send every 404 page not found error directly to start page (or any other page/site) to overcome problems with search engines
10
+
11
+ == Description ==
12
+
13
+ If you don't like the typical 404 page than you can redirect all 404 page not found errors permantly (or temporarily) to the start page or any other site/page you like.
14
+
15
+ This will help you solve problems with external bad links which are not under your influence.
16
+
17
+ Chose between 301 - Moved permanently (default) and 302 - Moved temporarily.
18
+
19
+ == Installation ==
20
+
21
+ 1. Upload 404-to-start to the `/wp-content/plugins/` directory
22
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
23
+ 3. Adjust settings
24
+
25
+ == Remove plugin ==
26
+
27
+ 1. Deactivate plugin through the 'Plugins' menu in WordPress
28
+ 2. Delete plugin through the 'Plugins' menu in WordPress
29
+
30
+ It's best to use the build in delete function of wordpress. That way all the stored data will be removed and no orphaned data will stay.
31
+
32
+ == Screenshots ==
33
+
34
+ 1. Basic Settings
35
+
36
+ == Frequently Asked Questions ==
37
+
38
+ = 301 or 302? =
39
+
40
+ It is generally not recommended to use a 302 redirect unless you are a search engine expert and can make a unique redirect page for each search engine. Each of the three major search engines (Google, Yahoo and MSN) process 302 redirects in a different manner. [How to Write a 301 or 302 Website Redirect Using Php](http://www.ehow.com/how_2319373_write-301-302-website-redirect.html)
41
+
42
+ = Is there anything I should be aware of? Any limitations? =
43
+
44
+ No.
45
+
46
+ = How can I support you? =
47
+
48
+ Post a comment on [404-to-start](http://1manfactory.com/4042start)
49
+
50
+ = What is the plugin page? =
51
+
52
+ [404-to-start](http://1manfactory.com/4042start)
53
+
54
+ = Do you have other plugins? =
55
+
56
+ Check out my other [Wordpress Plugins](http://wordpress.org/extend/plugins/profile/1manfactory)
57
+
58
+ = Where do I post my feedback? =
59
+
60
+ Post it at the plugin page: [404-to-start](http://1manfactory.com/4042start)
61
+
62
+ == Upgrade Notice ==
63
+
64
+ Just do a normal upgrade.
65
+
66
+ == Changelog ==
67
+
68
+ = 1.3.2 (27.02.2013) =
69
+ * Replacing deprecated function
70
+
71
+ = 1.3.1 (10.01.2013) =
72
+ * Tested on Wordpress 3.5 - OK
73
+ * Slovak translation, thanks to Branco from www.webhostinggeeks.com
74
+
75
+ = 1.3 (03.03.2011) =
76
+ * Set custom target Url (any page or site you like)
77
+
78
+ = 1.2 (24.02.2011) =
79
+ * tested with Wordpress 3.1
80
+
81
+ = 1.1 (10.02.2011) =
82
+ * new settings menu
83
+ * chose between 301 and 302 redirect
84
+ * tested with Wordpress 3.0.5
85
+
86
+ = 1.0 (02.01.2011) =
87
+ * first version
88
+
89
+ == Upgrade Notice ==
90
+
91
+ Just do a normal upgrade.
92
+
93
+ == To do ==
94
+
95
+ More translations. Does someone wants to help?
screenshot-1.png ADDED
Binary file
whatsup.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php