lastest update now crashing sites
-
last update 15min old, site now in the toilet…
does anyone know of another plugin that works the same way as this.. I cant continue using plugins that fail.. i will pay for one if it works
-
Yes bug too on my site, a very big problem for SEO, so that needs to be fixed ASAP, thanks
I recommand do not upgrade for last version of Custom Permalinksits not a bug its a complete disaster.. the site is now a total disaster, cannot even recover any of the urls, am now trying to quickly reset over 200 pages and do redirects.. but its impossible as the site is not following category v post names v anything.. possibly because all the urls were created around this plugin working..
recommend developers use a local host to develop and test plugins and not use the business community..
In function custom_permalinks_original_post_link, it seems to have changed to using an admin only function “get_sample_permalink”.
Still not working, on my site only the 0.7.21 works, nor the .22 and the .23
Same here, downgraded to 0.7.21
I returned the site to 0.7.21 however its highlighted issues with the pages that were not there previously.. I had to re-asign new pages off the root directory to a subdirectory/category in order for them to work.
The original ones on the root prior to the update are working when I apply the old version of this plugin, but unable to create new pages to appear as if off the root, thus they only work as if in a subdirectory/category, which defeats the purpose of the plugin as wordpress already forces us to do this with posts, a page could be used but I migrate old sites from html to wordpress and we want to keep the extension thus pages are useless for this….
I dont know what the answer is for this plugin, I’m realizing it needs to go and i need to locate another one, but lets hope wordpress gets it act together and adds this ability built into the system as its been long overdue.
Damn, same here. How do I downgrade to 0.7.21 ?
Thanks
D
My site is till working, but previewing posts was broken. I rolled back using the edit button in the plugin page. Paste this:
<?php
/*
Plugin Name: Custom Permalinks
Plugin URI: https://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
Donate link: https://atastypixel.com/blog/wordpress/plugins/custom-permalinks/
Description: Set custom permalinks on a per-post basis
Version: 0.7.21
Author: Michael Tyson
Author URI: https://atastypixel.com/blog
Text Domain: custom-permalinks
*//* Copyright 2008-2015 Michael Tyson <[email protected]>
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*//**
** Actions and filters
**
**//**
* Filter to replace the post permalink with the custom one
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_post_link($permalink, $post) {
$custom_permalink = get_post_meta( $post->ID, ‘custom_permalink’, true );
if ( $custom_permalink ) {
return home_url().”/”.$custom_permalink;
}return $permalink;
}/**
* Filter to replace the page permalink with the custom one
*
* @package CustomPermalinks
* @since 0.4
*/
function custom_permalinks_page_link($permalink, $page) {
$custom_permalink = get_post_meta( $page, ‘custom_permalink’, true );
if ( $custom_permalink ) {
return home_url().”/”.$custom_permalink;
}return $permalink;
}/**
* Filter to replace the term permalink with the custom one
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_term_link($permalink, $term) {
$table = get_option(‘custom_permalink_table’);
if ( is_object($term) ) $term = $term->term_id;$custom_permalink = custom_permalinks_permalink_for_term($term);
if ( $custom_permalink ) {
return home_url().”/”.$custom_permalink;
}return $permalink;
}/**
* Action to redirect to the custom permalink
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_redirect() {// Get request URI, strip parameters
$url = parse_url(get_bloginfo(‘url’));
$url = isset($url[‘path’]) ? $url[‘path’] : ”;
$request = ltrim(substr($_SERVER[‘REQUEST_URI’], strlen($url)),’/’);
if ( ($pos=strpos($request, “?”)) ) $request = substr($request, 0, $pos);global $wp_query;
$custom_permalink = ”;
$original_permalink = ”;// If the post/tag/category we’re on has a custom permalink, get it and check against the request
if ( is_single() || is_page() ) {
$post = $wp_query->post;
$custom_permalink = get_post_meta( $post->ID, ‘custom_permalink’, true );
$original_permalink = ( $post->post_type == ‘page’ ? custom_permalinks_original_page_link( $post->ID ) : custom_permalinks_original_post_link( $post->ID ) );
} else if ( is_tag() || is_category() ) {
$theTerm = $wp_query->get_queried_object();
$custom_permalink = custom_permalinks_permalink_for_term($theTerm->term_id);
$original_permalink = (is_tag() ? custom_permalinks_original_tag_link($theTerm->term_id) :
custom_permalinks_original_category_link($theTerm->term_id));
}if ( $custom_permalink &&
(substr($request, 0, strlen($custom_permalink)) != $custom_permalink ||
$request == $custom_permalink.”/” ) ) {
// Request doesn’t match permalink – redirect
$url = $custom_permalink;if ( substr($request, 0, strlen($original_permalink)) == $original_permalink &&
trim($request,’/’) != trim($original_permalink,’/’) ) {
// This is the original link; we can use this url to derive the new one
$url = preg_replace(‘@//*@’, ‘/’, str_replace(trim($original_permalink,’/’), trim($custom_permalink,’/’), $request));
$url = preg_replace(‘@([^?]*)&@’, ‘\1?’, $url);
}// Append any query compenent
$url .= strstr($_SERVER[‘REQUEST_URI’], “?”);wp_redirect( home_url().”/”.$url, 301 );
exit();
}
}/**
* Filter to rewrite the query if we have a matching post
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_request($query) {
global $wpdb;
global $_CPRegisteredURL;// First, search for a matching custom permalink, and if found, generate the corresponding
// original URL$originalUrl = NULL;
// Get request URI, strip parameters and /’s
$url = parse_url(get_bloginfo(‘url’));
$url = isset($url[‘path’]) ? $url[‘path’] : ”;
$request = ltrim(substr($_SERVER[‘REQUEST_URI’], strlen($url)),’/’);
$request = (($pos=strpos($request, ‘?’)) ? substr($request, 0, $pos) : $request);
$request_noslash = preg_replace(‘@/+@’,’/’, trim($request, ‘/’));if ( !$request ) return $query;
// Queries are now WP3.9 compatible (by Steve from Sowmedia.nl)
$sql = $wpdb->prepare(“SELECT $wpdb->posts.ID, $wpdb->postmeta.meta_value, $wpdb->posts.post_type FROM $wpdb->posts “.
“LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE “.
” meta_key = ‘custom_permalink’ AND “.
” meta_value != ” AND “.
” ( LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(meta_value)) OR “.
” LOWER(meta_value) = LEFT(LOWER(‘%s’), LENGTH(meta_value)) ) “.
” AND post_status != ‘trash’ AND post_type != ‘nav_menu_item'”.
” ORDER BY LENGTH(meta_value) DESC, “.
” FIELD(post_status,’publish’,’private’,’draft’,’auto-draft’,’inherit’),”.
” FIELD(post_type,’post’,’page’),”.
“$wpdb->posts.ID ASC LIMIT 1”,
$request_noslash,
$request_noslash.”/”
);$posts = $wpdb->get_results($sql);
if ( $posts ) {
// A post matches our request// Preserve this url for later if it’s the same as the permalink (no extra stuff)
if ( $request_noslash == trim($posts[0]->meta_value,’/’) )
$_CPRegisteredURL = $request;$originalUrl = preg_replace( ‘@/+@’, ‘/’, str_replace( trim( strtolower($posts[0]->meta_value),’/’ ),
( $posts[0]->post_type == ‘page’ ?
custom_permalinks_original_page_link($posts[0]->ID)
: custom_permalinks_original_post_link($posts[0]->ID) ),
strtolower($request_noslash) ) );
}if ( $originalUrl === NULL ) {
// See if any terms have a matching permalink
$table = get_option(‘custom_permalink_table’);
if ( !$table ) return $query;foreach ( array_keys($table) as $permalink ) {
if ( $permalink == substr($request_noslash, 0, strlen($permalink)) ||
$permalink == substr($request_noslash.”/”, 0, strlen($permalink)) ) {
$term = $table[$permalink];// Preserve this url for later if it’s the same as the permalink (no extra stuff)
if ( $request_noslash == trim($permalink,’/’) )
$_CPRegisteredURL = $request;if ( $term[‘kind’] == ‘category’) {
$originalUrl = str_replace(trim($permalink,’/’),
custom_permalinks_original_category_link($term[‘id’]),
trim($request,’/’));
} else {
$originalUrl = str_replace(trim($permalink,’/’),
custom_permalinks_original_tag_link($term[‘id’]),
trim($request,’/’));
}
}
}
}if ( $originalUrl !== NULL ) {
$originalUrl = str_replace(‘//’, ‘/’, $originalUrl);if ( ($pos=strpos($_SERVER[‘REQUEST_URI’], ‘?’)) !== false ) {
$queryVars = substr($_SERVER[‘REQUEST_URI’], $pos+1);
$originalUrl .= (strpos($originalUrl, ‘?’) === false ? ‘?’ : ‘&’) . $queryVars;
}// Now we have the original URL, run this back through WP->parse_request, in order to
// parse parameters properly. We set $_SERVER variables to fool the function.
$oldRequestUri = $_SERVER[‘REQUEST_URI’]; $oldQueryString = $_SERVER[‘QUERY_STRING’];
$_SERVER[‘REQUEST_URI’] = ‘/’.ltrim($originalUrl,’/’);
$_SERVER[‘QUERY_STRING’] = (($pos=strpos($originalUrl, ‘?’)) !== false ? substr($originalUrl, $pos+1) : ”);
parse_str($_SERVER[‘QUERY_STRING’], $queryArray);
$oldValues = array();
if ( is_array($queryArray) )
foreach ( $queryArray as $key => $value ) {
$oldValues[$key] = $_REQUEST[$key];
$_REQUEST[$key] = $_GET[$key] = $value;
}// Re-run the filter, now with original environment in place
remove_filter( ‘request’, ‘custom_permalinks_request’, ‘edit_files’, 1 );
global $wp;
$wp->parse_request();
$query = $wp->query_vars;
add_filter( ‘request’, ‘custom_permalinks_request’, ‘edit_files’, 1 );// Restore values
$_SERVER[‘REQUEST_URI’] = $oldRequestUri; $_SERVER[‘QUERY_STRING’] = $oldQueryString;
foreach ( $oldValues as $key => $value ) {
$_REQUEST[$key] = $value;
}
}return $query;
}/**
* Filter to handle trailing slashes correctly
*
* @package CustomPermalinks
* @since 0.3
*/
function custom_permalinks_trailingslash($string, $type) {
global $_CPRegisteredURL;$url = parse_url(get_bloginfo(‘url’));
$request = ltrim(isset($url[‘path’]) ? substr($string, strlen($url[‘path’])) : $string, ‘/’);if ( !trim($request) ) return $string;
if ( trim($_CPRegisteredURL,’/’) == trim($request,’/’) ) {
return ($string{0} == ‘/’ ? ‘/’ : ”) . trailingslashit($url[‘path’]) . $_CPRegisteredURL;
}
return $string;
}/**
** Administration
**
**//**
* Per-post/page options (WordPress > 2.9)
*
* @package CustomPermalinks
* @since 0.6
*/
function custom_permalink_get_sample_permalink_html($html, $id, $new_title, $new_slug) {
$permalink = get_post_meta( $id, ‘custom_permalink’, true );
$post = &get_post($id);ob_start();
?>
<?php custom_permalinks_form($permalink, ($post->post_type == “page” ? custom_permalinks_original_page_link($id) : custom_permalinks_original_post_link($id)), false); ?>
<?php
$content = ob_get_contents();
ob_end_clean();if ( ‘publish’ == $post->post_status ) {
$view_post = ‘page’ == $post->post_type ? __(‘View Page’, ‘custom-permalinks’) : __(‘View Post’, ‘custom-permalinks’);
}if ( preg_match(“@view-post-btn.*?href='([^’]+)’@s”, $html, $matches) ) {
$permalink = $matches[1];
} else {
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
if ( false !== strpos($permalink, ‘%postname%’) || false !== strpos($permalink, ‘%pagename%’) ) {
$permalink = str_replace(array(‘%pagename%’,’%postname%’), $post_name, $permalink);
}
}return ‘‘ . __(‘Permalink:’, ‘custom-permalinks’) . “\n” . $content .
( isset($view_post) ? “<span id=’view-post-btn’>$view_post</span>\n” : “” );
}/**
* Per-post options (WordPress < 2.9)
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_post_options() {
global $post;
$post_id = $post;
if (is_object($post_id)) {
$post_id = $post_id->ID;
}$permalink = get_post_meta( $post_id, ‘custom_permalink’, true );
?>
<div class=”postbox closed”>
<h3><?php _e(‘Custom Permalink’, ‘custom-permalinks’) ?></h3>
<div class=”inside”>
<?php custom_permalinks_form($permalink, custom_permalinks_original_post_link($post_id)); ?>
</div>
</div>
<?php
}/**
* Per-page options (WordPress < 2.9)
*
* @package CustomPermalinks
* @since 0.4
*/
function custom_permalinks_page_options() {
global $post;
$post_id = $post;
if (is_object($post_id)) {
$post_id = $post_id->ID;
}$permalink = get_post_meta( $post_id, ‘custom_permalink’, true );
?>
<div class=”postbox closed”>
<h3><?php _e(‘Custom Permalink’, ‘custom-permalinks’) ?></h3>
<div class=”inside”>
<?php custom_permalinks_form($permalink, custom_permalinks_original_page_link($post_id)); ?>
</div>
</div>
<?php
}/**
* Per-category/tag options
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_term_options($object) {
$permalink = custom_permalinks_permalink_for_term($object->term_id);if ( $object->term_id ) {
$originalPermalink = ($object->taxonomy == ‘post_tag’ ?
custom_permalinks_original_tag_link($object->term_id) :
custom_permalinks_original_category_link($object->term_id) );
}custom_permalinks_form($permalink, $originalPermalink);
// Move the save button to above this form
wp_enqueue_script(‘jquery’);
?>
<script type=”text/javascript”>
jQuery(document).ready(function() {
var button = jQuery(‘#custom_permalink_form’).parent().find(‘.submit’);
button.remove().insertAfter(jQuery(‘#custom_permalink_form’));
});
</script>
<?php
}/**
* Helper function to render form
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_form($permalink, $original=””, $renderContainers=true) {
?>
<input value=”true” type=”hidden” name=”custom_permalinks_edit” />
<input value=”<?php echo htmlspecialchars(urldecode($permalink)) ?>” type=”hidden” name=”custom_permalink” id=”custom_permalink” /><?php if ( $renderContainers ) : ?>
<table class=”form-table” id=”custom_permalink_form”>
<tr>
<th scope=”row”><?php _e(‘Custom Permalink’, ‘custom-permalinks’) ?></th>
<td>
<?php endif; ?>
<?php echo home_url() ?>/
<span id=”editable-post-name” title=”Click to edit this part of the permalink”>
<input type=”text” id=”new-post-slug” 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’; }”
onblur=”document.getElementById(‘custom_permalink’).value = this.value; if ( this.value == ” || this.value == ‘<?php echo htmlspecialchars(urldecode($original)) ?>’ ) { this.value = ‘<?php echo htmlspecialchars(urldecode($original)) ?>’; this.style.color = ‘#ddd’; }”/>
</span>
<?php if ( $renderContainers ) : ?><small><?php _e(‘Leave blank to disable’, ‘custom-permalinks’) ?></small>
</td>
</tr>
</table>
<?php
endif;
}/**
* Save per-post options
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_save_post($id) {
if ( !isset($_REQUEST[‘custom_permalinks_edit’]) ) return;delete_post_meta( $id, ‘custom_permalink’ );
$original_link = custom_permalinks_original_post_link($id);
$permalink_structure = get_option(‘permalink_structure’);if ( $_REQUEST[‘custom_permalink’] && $_REQUEST[‘custom_permalink’] != $original_link ) {
add_post_meta( $id, ‘custom_permalink’, str_replace(‘%2F’, ‘/’, urlencode(ltrim(stripcslashes($_REQUEST[‘custom_permalink’]),”/”))) );
}
}/**
* Save per-tag options
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_save_tag($id) {
if ( !isset($_REQUEST[‘custom_permalinks_edit’]) || isset($_REQUEST[‘post_ID’]) ) return;
$newPermalink = ltrim(stripcslashes($_REQUEST[‘custom_permalink’]),”/”);if ( $newPermalink == custom_permalinks_original_tag_link($id) )
$newPermalink = ”;$term = get_term($id, ‘post_tag’);
custom_permalinks_save_term($term, str_replace(‘%2F’, ‘/’, urlencode($newPermalink)));
}/**
* Save per-category options
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_save_category($id) {
if ( !isset($_REQUEST[‘custom_permalinks_edit’]) || isset($_REQUEST[‘post_ID’]) ) return;
$newPermalink = ltrim(stripcslashes($_REQUEST[‘custom_permalink’]),”/”);if ( $newPermalink == custom_permalinks_original_category_link($id) )
$newPermalink = ”;$term = get_term($id, ‘category’);
custom_permalinks_save_term($term, str_replace(‘%2F’, ‘/’, urlencode($newPermalink)));
}/**
* Save term (common to tags and categories)
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_save_term($term, $permalink) {custom_permalinks_delete_term($term->term_id);
$table = get_option(‘custom_permalink_table’);
if ( $permalink )
$table[$permalink] = array(
‘id’ => $term->term_id,
‘kind’ => ($term->taxonomy == ‘category’ ? ‘category’ : ‘tag’),
‘slug’ => $term->slug);update_option(‘custom_permalink_table’, $table);
}/**
* Delete post
*
* @package CustomPermalinks
* @since 0.7.14
* @author Piero <[email protected]>
*/
function custom_permalinks_delete_permalink( $id ){
global $wpdb;
// Queries are now WP3.9 compatible (by Steve from Sowmedia.nl)
$wpdb->query($wpdb->prepare(“DELETE FROM $wpdb->postmeta WHEREmeta_key
= ‘custom_permalink’ ANDpost_id
= %d”,$id));
}/**
* Delete term
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_delete_term($id) {$table = get_option(‘custom_permalink_table’);
if ( $table )
foreach ( $table as $link => $info ) {
if ( $info[‘id’] == $id ) {
unset($table[$link]);
break;
}
}update_option(‘custom_permalink_table’, $table);
}/**
* Options page
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_options_page() {// Handle revert
if ( isset($_REQUEST[‘revertit’]) && isset($_REQUEST[‘revert’]) ) {
check_admin_referer(‘custom-permalinks-bulk’);
foreach ( (array)$_REQUEST[‘revert’] as $identifier ) {
list($kind, $id) = explode(‘.’, $identifier);
switch ( $kind ) {
case ‘post’:
case ‘page’:
delete_post_meta( $id, ‘custom_permalink’ );
break;
case ‘tag’:
case ‘category’:
custom_permalinks_delete_term($id);
break;
}
}// Redirect
$redirectUrl = $_SERVER[‘REQUEST_URI’];
?>
<script type=”text/javascript”>
document.location = ‘<?php echo $redirectUrl ?>’
</script>
<?php ;
}?>
<div class=”wrap”>
<h2><?php _e(‘Custom Permalinks’, ‘custom-permalinks’) ?></h2><form method=”post” action=”<?php echo $_SERVER[‘REQUEST_URI’] ?>”>
<?php wp_nonce_field(‘custom-permalinks-bulk’) ?><div class=”tablenav”>
<div class=”alignleft”>
<input type=”submit” value=”<?php _e(‘Revert’, ‘custom-permalinks’); ?>” name=”revertit” class=”button-secondary delete” />
</div>
<br class=”clear” />
</div>
<br class=”clear” />
<table class=”widefat”>
<thead>
<tr>
<th scope=”col” class=”check-column”><input type=”checkbox” /></th>
<th scope=”col”><?php _e(‘Title’, ‘custom-permalinks’) ?></th>
<th scope=”col”><?php _e(‘Type’, ‘custom-permalinks’) ?></th>
<th scope=”col”><?php _e(‘Permalink’, ‘custom-permalinks’) ?></th>
</tr>
</thead>
<tbody>
<?php
$rows = custom_permalinks_admin_rows();
foreach ( $rows as $row ) {
?>
<tr valign=”top”>
<th scope=”row” class=”check-column”><input type=”checkbox” name=”revert[]” value=”<?php echo $row[‘id’] ?>” /></th>
<td>“><?php echo htmlspecialchars($row[‘title’]) ?></td>
<td><?php echo htmlspecialchars($row[‘type’]) ?></td>
<td>” target=”_blank” title=”<?php printf(__(‘Visit %s’, ‘custom-permalinks’), htmlspecialchars($row[‘title’])) ?>”>
<?php echo htmlspecialchars(urldecode($row[‘permalink’])) ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</form>
</div>
<?php
}/**
* Get rows for management view
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_admin_rows() {
$rows = array();// List tags/categories
$table = get_option(‘custom_permalink_table’);
if ( $table && is_array($table) ) {
foreach ( $table as $permalink => $info ) {
$row = array();
$term = get_term($info[‘id’], ($info[‘kind’] == ‘tag’ ? ‘post_tag’ : ‘category’));
$row[‘id’] = $info[‘kind’].’.’.$info[‘id’];
$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’] );
$rows[] = $row;
}
}// List posts/pages
global $wpdb;
$query = “SELECT $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE
$wpdb->postmeta.meta_key = ‘custom_permalink’ AND $wpdb->postmeta.meta_value != ”;”;
$posts = $wpdb->get_results($query);
foreach ( $posts as $post ) {
$row = array();
$row[‘id’] = ‘post.’.$post->ID;
$row[‘permalink’] = get_permalink($post->ID);
$row[‘type’] = ucwords( $post->post_type );
$row[‘title’] = $post->post_title;
$row[‘editlink’] = ‘post.php?action=edit&post=’.$post->ID;
$rows[] = $row;
}return $rows;
}/**
* Get original permalink for post
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_original_post_link($post_id) {
remove_filter( ‘post_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 ); // original hook
remove_filter( ‘post_type_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 );
$originalPermalink = ltrim(str_replace(home_url(), ”, get_permalink( $post_id )), ‘/’);
add_filter( ‘post_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 ); // original hook
add_filter( ‘post_type_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 );
return $originalPermalink;
}/**
* Get original permalink for page
*
* @package CustomPermalinks
* @since 0.4
*/
function custom_permalinks_original_page_link($post_id) {
remove_filter( ‘page_link’, ‘custom_permalinks_page_link’, ‘edit_files’, 2 );
remove_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
$originalPermalink = ltrim(str_replace(home_url(), ”, get_permalink( $post_id )), ‘/’);
add_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
add_filter( ‘page_link’, ‘custom_permalinks_page_link’, ‘edit_files’, 2 );
return $originalPermalink;
}/**
* Get original permalink for tag
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_original_tag_link($tag_id) {
remove_filter( ‘tag_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
remove_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
$originalPermalink = ltrim(str_replace(home_url(), ”, get_tag_link($tag_id)), ‘/’);
add_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
add_filter( ‘tag_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
return $originalPermalink;
}/**
* Get original permalink for category
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_original_category_link($category_id) {
remove_filter( ‘category_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
remove_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
$originalPermalink = ltrim(str_replace(home_url(), ”, get_category_link($category_id)), ‘/’);
add_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );
add_filter( ‘category_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
return $originalPermalink;
}/**
* Get permalink for term
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_permalink_for_term($id) {
$table = get_option(‘custom_permalink_table’);
if ( $table )
foreach ( $table as $link => $info ) {
if ( $info[‘id’] == $id ) {
return $link;
}
}
return false;
}/**
* Set up administration menu
*
* @package CustomPermalinks
* @since 0.1
*/
function custom_permalinks_setup_admin_menu() {
add_management_page( ‘Custom Permalinks’, ‘Custom Permalinks’, ‘edit_others_pages’, ‘custom_permalinks’, ‘custom_permalinks_options_page’ );
}/**
* Set up administration header
*
* @package CustomPermalinks
* @since 0.7.20
*/
function custom_permalinks_setup_admin_head() {
wp_enqueue_script(‘admin-forms’);
}# 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.if (function_exists(“add_action”) && function_exists(“add_filter”)) {
add_action( ‘template_redirect’, ‘custom_permalinks_redirect’, 5 );
add_filter( ‘post_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 );
add_filter( ‘post_type_link’, ‘custom_permalinks_post_link’, ‘edit_files’, 2 );
add_filter( ‘page_link’, ‘custom_permalinks_page_link’, ‘edit_files’, 2 );
add_filter( ‘tag_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
add_filter( ‘category_link’, ‘custom_permalinks_term_link’, ‘edit_files’, 2 );
add_filter( ‘request’, ‘custom_permalinks_request’, ‘edit_files’, 1 );
add_filter( ‘user_trailingslashit’, ‘custom_permalinks_trailingslash’, ‘edit_files’, 2 );if (function_exists(“get_bloginfo”)) {
$v = explode(‘.’, get_bloginfo(‘version’));
}if ( $v[0] >= 2 ) {
add_filter( ‘get_sample_permalink_html’, ‘custom_permalink_get_sample_permalink_html’, ‘edit_files’, 4 );
} else {
add_action( ‘edit_form_advanced’, ‘custom_permalinks_post_options’ );
add_action( ‘edit_page_form’, ‘custom_permalinks_page_options’ );
}add_action( ‘edit_tag_form’, ‘custom_permalinks_term_options’ );
add_action( ‘add_tag_form’, ‘custom_permalinks_term_options’ );
add_action( ‘edit_category_form’, ‘custom_permalinks_term_options’ );
add_action( ‘save_post’, ‘custom_permalinks_save_post’ );
add_action( ‘save_page’, ‘custom_permalinks_save_post’ );
add_action( ‘edited_post_tag’, ‘custom_permalinks_save_tag’ );
add_action( ‘edited_category’, ‘custom_permalinks_save_category’ );
add_action( ‘create_post_tag’, ‘custom_permalinks_save_tag’ );
add_action( ‘create_category’, ‘custom_permalinks_save_category’ );
add_action( ‘delete_post’, ‘custom_permalinks_delete_permalink’, ‘edit_files’);
add_action( ‘delete_post_tag’, ‘custom_permalinks_delete_term’ );
add_action( ‘delete_post_category’, ‘custom_permalinks_delete_term’ );
add_action( ‘admin_head’, ‘custom_permalinks_setup_admin_head’ );
add_action( ‘admin_menu’, ‘custom_permalinks_setup_admin_menu’ );
}
?>@superjany THANKS YOU SO MUCH!
I am having the same issue. Testing the downgrade.
Hi guys, I have created a fork of this plugin with some additional functionalities. If you guys have some dev or local server so, please test it and give me your feedback.
https://www.ads-software.com/plugins/permalinks-customizer/
Any feedback would be very appreciable ??
Thanks,
SamiHey Sami, just wondering; would you be interested in getting repo access/taking over the original plugin? I’ve got zero time to do stuff with it lately, and am obviously struggling; I’m only accepting changes from others and my testing resources are sorely limited – I do test every version on my own sites, but clearly it’s not always working out. I’d love the help!
Hey Michael, Great to hear from you.
Hope everything is fine with you and your work is going great.
I have faced some issues with the custom permalink plugin that’s why i have created a fork of this plugin. Also, i have added some new functionalities which i thought, it might be useful for others as is did for me.
Your plugin was just too great and did great work for me on many sites. It “Works like a charm” ??
It’s my pleasure to help you in the such a great plugin.
Thanks,
SamiThanks Sami!! Absolutely, and fair enough – it’s a shame WordPress doesn’t use Github, because that’d be much easier for collaboration on plugins.
Okay, I’ve added you as a committer. Inasmuch as you feel like it, please do have at it, with my thanks =)
Thanks michaeltyson. I have commited the code today to solve the one issue.
Thanks for adding me as a committer ??
Regards,
Sami
- The topic ‘lastest update now crashing sites’ is closed to new replies.