diff --git a/permalinks-customizer.php b/permalinks-customizer.php index 398fc55..b7a2722 100644 --- a/permalinks-customizer.php +++ b/permalinks-customizer.php @@ -2,7 +2,7 @@ /** * Plugin Name: Permalinks Customizer - * Version: 0.3.1 + * Version: 0.3.2 * Plugin URI: https://wordpress.org/plugins/permalinks-customizer/ * Description: Set permalinks for default post-type and custom post-type which can be changed from the single post edit page. * Author: Sami Ahmed Siddiqui @@ -55,6 +55,7 @@ function permalinks_customizer_menu() { add_menu_page('Set Your Permalinks', 'Permalinks Customizer', 'administrator', 'permalinks-customizer-settings', 'permalinks_customizer_options_page'); add_submenu_page( 'permalinks-customizer-settings', 'Set Your Permalinks', 'Set Permanlinks', 'administrator', 'permalinks-customizer-settings', 'permalinks_customizer_options_page' ); add_submenu_page( 'permalinks-customizer-settings', 'Structure Tags', 'Structure Tags', 'administrator', 'permalinks-customizer-tags', 'permalinks_customizer_tags_page' ); + add_submenu_page( 'permalinks-customizer-settings', 'Convert Custom Permalink', 'Convert Custom Permalink', 'administrator', 'permalinks-customizer-convert-url', 'permalinks_customizer_convert_url' ); add_action( 'admin_init', 'register_permalinks_customizer_settings' ); } @@ -632,6 +633,67 @@ function permalinks_customizer_original_page_link($post_id) { return $originalPermalink; } +function permalinks_customizer_convert_url() { + global $wpdb; + $plugin_slug = 'permalinks-customizer-convert-url'; + $step = isset( $_GET['processing'] ) ? absint( $_GET['processing'] ) : 1; + $steps = isset( $_GET['limit'] ) ? $_GET['limit'] : 0; + $data = $wpdb->get_row( 'SELECT meta_id from wp_postmeta where meta_key = "custom_permalink" LIMIT 1'); + echo '

'.esc_html( get_admin_page_title() ).'

'; + if ( isset( $_GET['processing'] ) ) : + if ( isset($data) && !empty($data) ) { + $wpdb->query( $wpdb->prepare( 'UPDATE wp_postmeta SET meta_key = "permalink_customizer" where meta_id = %d ', $data->meta_id) ); + echo '

The batch update routine has started. Please be patient as this may take some time to complete Loading...

'; + echo '

Converting '.(int) $step.' out of '.(int) $steps.' custom permalinks

'; + ?> + + + +get_row( 'SELECT option_id from wp_options where option_name LIKE "%custom_permalink_table%" ' ); + if( isset($cat_data) && !empty($cat_data)) { + $wpdb->query( $wpdb->prepare( 'UPDATE wp_options SET option_name = "permalinks_customizer_table" where option_id = %d ', $cat_data->option_id) ); + } + echo '

'. $completed .' Custom Permalink have been converted to Permalink Customizer successfully.

'; + } elseif( $_GET["processed"] > 0 ) { + $cat_data = $wpdb->get_row( 'SELECT option_id from wp_options where option_name LIKE "%custom_permalink_table%" ' ); + if( isset($cat_data) && !empty($cat_data)) { + $wpdb->query( $wpdb->prepare( 'UPDATE wp_options SET option_name = "permalinks_customizer_table" where option_id = %d ', $cat_data->option_id) ); + } + echo '

'. $_GET["processed"] .' Custom Permalink have been converted to Permalink Customizer successfully.

'; + } + echo '

Click on the "Convert Permalink" button to convert custom permalink to Permalink Customizer. By doing this, all of your previous permalink which was created by custom permalink plugin would be converted to Permalink Customizer.

'; + echo ''; + endif; + echo '
'; +} + if (function_exists("add_action") && function_exists("add_filter")) { add_action( 'template_redirect', 'permalinks_customizer_redirect', 5 ); add_filter( 'post_link', 'permalinks_customizer_post_link', 'edit_files', 2 ); diff --git a/readme.txt b/readme.txt index 54686aa..bc65772 100644 --- a/readme.txt +++ b/readme.txt @@ -1,11 +1,11 @@ === Permalinks Customizer === -Contributors: sasiddiqui, michaeltyson +Contributors: sasiddiqui, yasglobal, michaeltyson License: GPLv3 License URI: http://www.gnu.org/licenses/gpl.html Tags: address, category, custom, custom permalink, custom post permalinks, link, permalink, rewrite slug, redirects, slug, tags, url Requires at least: 3.5 -Tested up to: 4.4 -Stable tag: 0.3.1 +Tested up to: 4.5 +Stable tag: 0.3.2 Set permalinks for default post-type and custom post-type which can be changed from the single post edit page. @@ -57,7 +57,7 @@ If you leave the some post-type fields empty. So, Permalinks Customizer< = Tags = -address, permalink, permalinks, custom permalink, custom post permalink, url, tag, category, redirects, slug, set permalink, change permalink, rewrite slug +address, permalink, permalinks, custom permalink, custom post permalink, url, tag, category, redirects, slug, set permalink, change permalink, rewrite slug, convert permalink, convert custom permalink, batch processing == Installation == @@ -73,6 +73,10 @@ address, permalink, permalinks, custom permalink, custom post permalink, url, ta * Permalinks can easily be changed for the single post from its post edit page. +* You can easily convert the custom permalink to permalink customizer by going on [permalinks settings page](http://www.example.com/wp-admin/admin.php?page=permalinks-customizer-convert-url) + +* Permalink conversion varies from servr to server. So, make sure to convert the url at a time on depending on your server capability. + == Frequently Asked Questions == = Q. How to define slug of the post type? = @@ -86,6 +90,10 @@ A. No, This plugin does not work with [custom permalinks](https://wordpress.org/ == Changelog == += 0.3.2 = + + * Convert custom permalink to permalink customizer + = 0.3.1 = * Add product_cat tag which is specially used for WooCommerce Products