Title: Plugin Not working in wordpress 3.9
Last modified: August 21, 2016

---

# Plugin Not working in wordpress 3.9

 *  [sher123](https://wordpress.org/support/users/daniyalesire/)
 * (@daniyalesire)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/)
 * Hi guys.
    When i am using WordPress 3.8. I had installed this plugin and its 
   all working great. i want to add .html at the end of the URL and this plugin 
   helps me to do it , i really love this plugin , but now when i upgrade to WordPress
   3.9 . Booom all the product URLs or pages URLs that i had been customized through
   this plugin not working , when i click any of my product page it says page not
   found. So any idea whats wrong? any help would be appreciated.
 * [https://wordpress.org/plugins/custom-permalinks/](https://wordpress.org/plugins/custom-permalinks/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [j0hnsmith](https://wordpress.org/support/users/j0hnsmith/)
 * (@j0hnsmith)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826823)
 * +1
 *  [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * (@mathewcantore)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826884)
 * On lines 167 and 168 of custom-permalinks.php, there are references to a function
   called mysql_real_escape_string. This function does not seem to be supported 
   any more. I found simply removing the references seemed to work, though I cannot
   say it would work for other sites.
 * Original lines:
 * > ” ( LOWER(meta_value) = LEFT(LOWER(‘”.mysql_real_escape_string($request_noslash).”‘),
   > LENGTH(meta_value)) OR “.
   >  ” LOWER(meta_value) = LEFT(LOWER(‘”.mysql_real_escape_string(
   > $request_noslash.”/”).”‘), LENGTH(meta_value)) ) “.
 * My changes:
 * > ” ( LOWER(meta_value) = LEFT(LOWER(‘”.$request_noslash.”‘), LENGTH(meta_value))
   > OR “.
   >  ” LOWER(meta_value) = LEFT(LOWER(‘”.$request_noslash.”/’), LENGTH(meta_value)))“.
 * Remember to make backups of any files you modify BEFORE you modify.
 * Hope this helps!
 *  [dellax](https://wordpress.org/support/users/dellax/)
 * (@dellax)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826885)
 * nice fix, its working now, thanks
 *  [dellax](https://wordpress.org/support/users/dellax/)
 * (@dellax)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826886)
 * i added this function and then replaced mysql_real_escape_string with ms_escape_string
 *     ```
       function ms_escape_string($data) {
               if ( !isset($data) or empty($data) ) return '';
               if ( is_numeric($data) ) return $data;
   
               $non_displayables = array(
                   '/%0[0-8bcef]/',            // url encoded 00-08, 11, 12, 14, 15
                   '/%1[0-9a-f]/',             // url encoded 16-31
                   '/[\x00-\x08]/',            // 00-08
                   '/\x0b/',                   // 11
                   '/\x0c/',                   // 12
                   '/[\x0e-\x1f]/'             // 14-31
               );
               foreach ( $non_displayables as $regex )
                   $data = preg_replace( $regex, '', $data );
               $data = str_replace("'", "''", $data );
               return $data;
           }
       ```
   
 *  [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * (@mathewcantore)
 * [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826896)
 * I actually decided to work within the framework of WP itself, and applied this(
   better) fix than my above fix. WordPress provides SQL sterilization natively 
   if the right commands are use, so here it is, with no warranties:
 * In the WP plugins directory, in custom-permalinks, in custom-permalinks.php find
   the following lines:
 * >  $sql = “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(‘”.mysql_real_escape_string($
   > request_noslash).”‘), LENGTH(meta_value)) OR “. ” LOWER(meta_value) = LEFT(
   > LOWER(‘”.mysql_real_escape_string($request_noslash.”/”).”‘), 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”;
 *  Replace them with:
 * >  $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 . “/”);
 * This restored my permalinks to working order. As always, make a backup of the
   custom-permalinks.php file before modifying it in case something goes horribly
   wrong. Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Plugin Not working in wordpress 3.9’ is closed to new replies.

 * ![](https://ps.w.org/custom-permalinks/assets/icon.svg?rev=1785367)
 * [Custom Permalinks](https://wordpress.org/plugins/custom-permalinks/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-permalinks/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-permalinks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-permalinks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-permalinks/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [mathew.cantore](https://wordpress.org/support/users/mathewcantore/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/plugin-not-working-in-wordpress-39/#post-4826896)
 * Status: not resolved