-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding ver 2.0.1 from http://plugins.svn.wordpress.org/canonical/tags…
- Loading branch information
Matt Richmond
committed
Feb 10, 2012
0 parents
commit 957f402
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/* | ||
Plugin Name: Canonical URL's | ||
Version: 2.0.1 | ||
Plugin URI: http://yoast.com/wordpress/canonical/ | ||
Description: Adds rel="canonical" URL's of your choice to the <head> of your posts and pages, instead of the default. | ||
Author: Joost de Valk | ||
Author URI: http://yoast.com/ | ||
Revision Author: Jesse Heap | ||
Copyright 2009-2010 Joost de Valk (email: joost@yoast.com) | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
/* | ||
Changelog: | ||
2.0.1 Only remove the default canonical when there is a cross domain one | ||
2.0 Removed automatic canonical on pages, and added option to canonicalize URL's | ||
1.0.1 Fixed double slashes on category and tag pages | ||
1.0 Initial version | ||
*/ | ||
|
||
if (!is_admin()) { | ||
|
||
function yoast_canonical_link() { | ||
global $post; | ||
$url = get_post_meta($post->ID, '_canonical', true); | ||
if ( $url ) { | ||
echo '<link rel="canonical" href="'.$url.'"/>'."\n"; | ||
remove_action('wp_head','rel_canonical'); | ||
} | ||
} | ||
add_action('wp_head', 'yoast_canonical_link',1); | ||
|
||
} else { | ||
|
||
function save_canonical_postdata( $post_id ) { | ||
if (isset($_POST['canonical'])) { | ||
$newcanonical = $_POST['canonical']; | ||
$curcanonical = get_post_meta($post_id, '_canonical'); | ||
if($curcanonical == "") | ||
add_post_meta($post_id, '_canonical', $newcanonical, true); | ||
elseif($newcanonical != $curcanonical) | ||
update_post_meta($post_id, '_canonical', $newcanonical); | ||
elseif($newcanonical == "") | ||
delete_post_meta($post_id, '_canonical', $curcanonical); | ||
} | ||
} | ||
|
||
function canonical_box() { | ||
global $post; | ||
echo '<table class="form_table">'; | ||
echo '<tr>'; | ||
echo '<th width="30%"><label for="canonical">Canonical link for this page</label></th>'; | ||
echo '<td width="70%"><input type="text" size="60" name="canonical" id="canonical" value="'.get_post_meta($post->ID, '_canonical', true).'"/></td>'; | ||
echo '</table>'; | ||
} | ||
|
||
function create_canonical_meta_box() { | ||
if ( function_exists('add_meta_box') ) { | ||
add_meta_box( 'canonical-box', 'Canonical', 'canonical_box', 'post', 'normal', 'high' ); | ||
add_meta_box( 'canonical-box', 'Canonical', 'canonical_box', 'page', 'normal', 'high' ); | ||
} | ||
} | ||
add_action('admin_menu', 'create_canonical_meta_box'); | ||
add_action('save_post', 'save_canonical_postdata'); | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
=== Canonical URL's === | ||
Contributors: joostdevalk | ||
Donate link: http://yoast.com/donate/ | ||
Tags: seo, canonical, search engines, google, yahoo, msn, live | ||
Requires at least: 2.9 | ||
Tested up to: 3.1 | ||
stable tag: 2.0.1 | ||
|
||
Adds rel="canonical" URL's of your choice to the <head> of your posts and pages, instead of the default canonical link that was introduced in WordPress 2.9. | ||
|
||
== Description == | ||
|
||
Adds rel="canonical" URL's of your choice to the <head> of your posts and pages, instead of the default canonical link that was introduced in WordPress 2.9. | ||
|
||
More info: | ||
|
||
* [Canonical URL's for WordPress](http://yoast.com/wordpress/canonical/). | ||
* Read more about how to improve your [WordPress SEO](http://yoast.com/articles/wordpress-seo/), so you can get the most out of this plugin. | ||
* Check out the other [Wordpress plugins](http://yoast.com/wordpress/) by the same author. | ||
* Check out the authors [Wordpress hosting](http://yoast.com/wordpress-hosting/) experiences. | ||
|
||
== Changelog == | ||
|
||
= 2.0.1 = | ||
|
||
* Only remove the default canonical when there is a cross domain one. | ||
|
||
= 2.0 = | ||
|
||
* Removed automatic canonical on pages, and added option to canonicalize URL's | ||
|
||
= 1.0.1 = | ||
|
||
* Fixed double slashes on category and tag pages | ||
|
||
= 1.0 = | ||
|
||
* Initial version | ||
|
||
== Installation == | ||
|
||
* Unzip. | ||
* Upload the directory to your plugins directory. | ||
* Activate. | ||
* Go to any post or page and add a canonical link there. | ||
* You're done. |