Created
April 23, 2013 03:15
-
-
Save haroldkyle/5440567 to your computer and use it in GitHub Desktop.
Posts and custom post types do not work over SSL with the Custom Permalinks plugin for Wordpress. This patch uses home_url() instead of get_options('home') so that we respect the protocol for the custom permalink.
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
Index: custom-permalinks.php | |
=================================================================== | |
--- custom-permalinks.php (revision 2657) | |
+++ custom-permalinks.php (revision 2658) | |
@@ -41,7 +41,7 @@ | |
function custom_permalinks_post_link($permalink, $post) { | |
$custom_permalink = get_post_meta( $post->ID, 'custom_permalink', true ); | |
if ( $custom_permalink ) { | |
- return get_home_url()."/".$custom_permalink; | |
+ return home_url()."/".$custom_permalink; | |
} | |
return $permalink; | |
@@ -57,7 +57,7 @@ | |
function custom_permalinks_page_link($permalink, $page) { | |
$custom_permalink = get_post_meta( $page, 'custom_permalink', true ); | |
if ( $custom_permalink ) { | |
- return get_home_url()."/".$custom_permalink; | |
+ return home_url()."/".$custom_permalink; | |
} | |
return $permalink; | |
@@ -77,7 +77,7 @@ | |
$custom_permalink = custom_permalinks_permalink_for_term($term); | |
if ( $custom_permalink ) { | |
- return get_home_url()."/".$custom_permalink; | |
+ return home_url()."/".$custom_permalink; | |
} | |
return $permalink; | |
@@ -131,7 +131,7 @@ | |
// Append any query compenent | |
$url .= strstr($_SERVER['REQUEST_URI'], "?"); | |
- wp_redirect( get_home_url()."/".$url, 301 ); | |
+ wp_redirect( home_url()."/".$url, 301 ); | |
exit(); | |
} | |
} | |
@@ -411,7 +411,7 @@ | |
<th scope="row"><?php _e('Custom Permalink', 'custom-permalink') ?></th> | |
<td> | |
<?php endif; ?> | |
- <?php echo get_home_url() ?>/ | |
+ <?php echo home_url() ?>/ | |
<input type="text" class="text" value="<?php echo htmlspecialchars($permalink ? urldecode($permalink) : urldecode($original)) ?>" | |
style="width: 250px; <?php if ( !$permalink ) echo 'color: #ddd;' ?>" | |
onfocus="if ( this.style.color = '#ddd' ) { this.style.color = '#000'; }" | |
@@ -630,7 +630,7 @@ | |
$row = array(); | |
$term = get_term($info['id'], ($info['kind'] == 'tag' ? 'post_tag' : 'category')); | |
$row['id'] = $info['kind'].'.'.$info['id']; | |
- $row['permalink'] = get_home_url()."/".$permalink; | |
+ $row['permalink'] = home_url()."/".$permalink; | |
$row['type'] = ucwords($info['kind']); | |
$row['title'] = $term->name; | |
$row['editlink'] = ( $info['kind'] == 'tag' ? 'edit-tags.php?action=edit&taxonomy=post_tag&tag_ID='.$info['id'] : 'edit-tags.php?action=edit&taxonomy=category&tag_ID='.$info['id'] ); | |
@@ -666,7 +666,7 @@ | |
function custom_permalinks_original_post_link($post_id) { | |
remove_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 ); // original hook | |
remove_filter( 'post_type_link', 'custom_permalinks_post_link', 10, 2 ); | |
- $originalPermalink = ltrim(str_replace(get_option('home'), '', get_permalink( $post_id )), '/'); | |
+ $originalPermalink = ltrim(str_replace(home_url(), '', get_permalink( $post_id )), '/'); | |
add_filter( 'post_link', 'custom_permalinks_post_link', 10, 2 ); // original hook | |
add_filter( 'post_type_link', 'custom_permalinks_post_link', 10, 2 ); | |
return $originalPermalink; | |
@@ -681,7 +681,7 @@ | |
function custom_permalinks_original_page_link($post_id) { | |
remove_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 ); | |
remove_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
- $originalPermalink = ltrim(str_replace(get_home_url(), '', get_permalink( $post_id )), '/'); | |
+ $originalPermalink = ltrim(str_replace(home_url(), '', get_permalink( $post_id )), '/'); | |
add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
add_filter( 'page_link', 'custom_permalinks_page_link', 10, 2 ); | |
return $originalPermalink; | |
@@ -697,7 +697,7 @@ | |
function custom_permalinks_original_tag_link($tag_id) { | |
remove_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 ); | |
remove_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
- $originalPermalink = ltrim(str_replace(get_home_url(), '', get_tag_link($tag_id)), '/'); | |
+ $originalPermalink = ltrim(str_replace(home_url(), '', get_tag_link($tag_id)), '/'); | |
add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
add_filter( 'tag_link', 'custom_permalinks_term_link', 10, 2 ); | |
return $originalPermalink; | |
@@ -712,7 +712,7 @@ | |
function custom_permalinks_original_category_link($category_id) { | |
remove_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 ); | |
remove_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
- $originalPermalink = ltrim(str_replace(get_home_url(), '', get_category_link($category_id)), '/'); | |
+ $originalPermalink = ltrim(str_replace(home_url(), '', get_category_link($category_id)), '/'); | |
add_filter( 'user_trailingslashit', 'custom_permalinks_trailingslash', 10, 2 ); | |
add_filter( 'category_link', 'custom_permalinks_term_link', 10, 2 ); | |
return $originalPermalink; | |
@@ -747,12 +747,6 @@ | |
wp_enqueue_script('admin-forms'); | |
} | |
-if ( !function_exists("get_home_url") ) { | |
- function get_home_url() { | |
- return get_option('home'); | |
- } | |
-} | |
- | |
# Check whether we're running within the WP environment, to avoid showing errors like | |
# "Fatal error: Call to undefined function get_bloginfo() in C:\xampp\htdocs\custom-permalinks\custom-permalinks.php on line 753" | |
# and similar errors that occurs when the script is called directly to e.g. find out the full path. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment