Changeset 393936
- Timestamp:
- 06/06/2011 06:30:37 PM (15 years ago)
- Location:
- speedy-page-redirect/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
speedy-page-redirect.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
speedy-page-redirect/trunk/readme.txt
r382594 r393936 12 12 This plugin adds a meta box to your page and post screens. You can enter a new destination URL to which the page will be redirected. 13 13 14 **Features** 15 14 = Features = 16 15 * Choose between permanent and temporary redirects. 17 16 * Support for custom post types out of the box. … … 31 30 == Changelog == 32 31 32 = 0.2 = 33 * Relative URLs are now supported (start with a slash). 34 * Entering a protocol only is considered empty input. 35 33 36 = 0.1 = 34 * First version.37 * Initial release. -
speedy-page-redirect/trunk/speedy-page-redirect.php
r382483 r393936 4 4 Plugin URI: http://wordpress.org/extend/plugins/speedy-page-redirect/ 5 5 Description: Redirect pages and posts to other locations. 6 Version: 0. 16 Version: 0.2 7 7 Author: Geert De Deckere 8 8 Author URI: http://www.geertdedeckere.be/ … … 26 26 */ 27 27 28 // Start your engines! 29 new GDD_Speedy_Page_Redirect; 30 28 31 class GDD_Speedy_Page_Redirect { 29 32 … … 33 36 * @var string 34 37 */ 35 const VERSION = '0. 1';38 const VERSION = '0.2'; 36 39 37 40 /** … … 185 188 echo '<p>'; 186 189 echo '<label for="gdd_spr_url">'.__('Destination URL:', 'page-redirect').'</label> '; 187 echo '<input id="gdd_spr_url" name="gdd_spr_url" type="text" value="'.esc_url($values['url ']).'" size="50" style="width:80%">';190 echo '<input id="gdd_spr_url" name="gdd_spr_url" type="text" value="'.esc_url($values['url_raw']).'" size="50" style="width:80%">'; 188 191 echo '</p>'; 189 192 … … 220 223 $url = (isset($_POST['gdd_spr_url'])) ? trim((string) $_POST['gdd_spr_url']) : ''; 221 224 222 // A URL was entered 223 if ($url !== '' && $url !== 'http://')225 // A URL was entered (standalone protocols like "http://" are considered emtpy) 226 if ($url !== '' && ! preg_match('~^[-a-z0-9+.]++://$~i', $url)) 224 227 { 225 228 // Prepare data array to store in the database … … 260 263 $post_id = (isset($post->ID)) ? $post->ID : $post; 261 264 262 // If redirection data is found, only return the destination URL in case of a permanent redirect 263 if (($data = $this->get_post_data($post_id)) && $data['status'] == 301) 264 return $data['url']; 265 266 // Return the original URL 267 return $url; 265 // No redirection data found 266 if ( ! $data = $this->get_post_data($post_id)) 267 return $url; 268 269 // Only hard-code the destionation URL in case of a permanent redirect 270 if ($data['status'] != 301) 271 return $url; 272 273 // Return the destination URL 274 return $data['url']; 268 275 } 269 276 … … 325 332 foreach ($rows as $row) 326 333 { 334 // Unserialize data 335 $data = unserialize($row->meta_value); 336 337 // Store the originally saved URL as raw_url 338 $data['url_raw'] = $data['url']; 339 340 // Generate the full URL in case a relative URL is stored in the database 341 if (substr($data['url'], 0, 1) === '/') 342 { 343 $data['url'] = trailingslashit(get_bloginfo('url')).ltrim($data['url'], '/'); 344 } 345 327 346 // Cache redirection data in object property 328 $this->data[$blog_id][(int) $row->post_id] = unserialize($row->meta_value);347 $this->data[$blog_id][(int) $row->post_id] = $data; 329 348 } 330 349 } … … 335 354 336 355 } 337 338 // Start your engines!339 new GDD_Speedy_Page_Redirect;
Note: See TracChangeset
for help on using the changeset viewer.