I have updated my server PHP from 5.x to 7.x but now my plugin shows error I have two files
1- link_removal_lite.php
<?php
/*
Plugin Name: Link Remover Lite
Plugin URI:
Description: Remove or replace any word/phrase or URL quickly and easily throughout your entire site.
Version: 1.6.3
Author: Outsourcing Exposed
Author URI: http://www.outsourcingexposed.com
*/
/* Copyright 2010 Outsourcing Exposed
*/
// The text domain for strings localization
define( 'LINKREM_TEXT_DOMAIN', 'link-removal-tool-lite' );
/**
* Load translate textdomain file.
*/
function pclaen_load_textdomain() {
load_plugin_textdomain( LINKREM_TEXT_DOMAIN, false, dirname( __FILE__ ) . '/languages/' );
}
add_action( 'plugins_loaded', 'pclaen_load_textdomain' );
// Hook for adding admin menus
add_action('admin_menu', 'pclaen_add_pages');
// action function for above hook
function pclaen_add_pages() {
// Add a new top-level menu:
$pclaen_page = add_menu_page( 'Link Remover Lite', 'Link Remover Lite', 'administrator', 'link-removal-lite', 'pclaen_page', plugins_url( 'link_removal_lite_brush.png' , 'link-removal-tool-lite/link_removal_lite.php' ) );
wp_register_style( 'pclaen_Stylesheet', plugins_url( 'link_removal_lite_style.css' , 'link-removal-tool-lite/link_removal_lite.php' ) );
wp_enqueue_style( 'pclaen_Stylesheet' );
}
function pclaen_page() {
include( 'link_removal_lite_page.php' );
}
function pclaen_all_posts_check() {
// do something with the post data
global $wpdb;
$sql = "SELECT * FROM $wpdb->posts WHERE post_parent=0";
$wpdb->query( $sql );
$posts = $wpdb->last_result;
$posts = ( array ) $posts;;
$searchText = $_POST['pclaen_searchText'];
$urlsdel = 0;
$postIsChange = 0;
foreach( $posts as $post ) {
$stroke = preg_quote( $searchText, "/" );
if( ( preg_match( '/<a.*?href=[\'"](.*?)' . $stroke . '(.*?)["\'][^>]*?>.*?<\/a>/im', $post->post_content ) ) ) {
$post->post_content = preg_replace( '/(<a.*?href=[\'"])(.*?)' . $stroke . '(.*?)(["\'][^>]*?>(.*?)<\/a>)/im', "$5", $post->post_content );
$postIsChange = 1;
$urlsdel++;
}
if( ( get_post( $post->ID ) != NULL ) AND $postIsChange == 1 ) {
$wpdb->query( "UPDATE ". $wpdb->posts . " SET post_content = '". mysql_escape_string($post->post_content) . "' WHERE ID = " . $post->ID . "" );
}
$postIsChange = 0;
}
$answer = "<br /> Deleted URLs: " . $urlsdel . "<br />";
return $answer;
}
?>
2- link_removal_lite_page.php
<?php
if ( isset( $_POST['pclaen_action'] ) && $_POST['pclaen_action'] == "pclaen_all_posts" && !empty( $_POST['pclaen_searchText'] ) ) {
$all_posts_Text = pclaen_all_posts_check();
}
$text = '<p>You’ve got the Lite version of this Link Removal Tool plugin. The Pro version is <strong>FREE</strong> and offers <strong>all these benefits</strong>.</p><ol>';
$text .= '<li>You can add <strong>unlimited URLs</strong> as you want</li>';
$text .= '<li>Future check. Your site will scan and stop any bad link URLs going onto your site ever again</li>';
$text .= '<li>Wildcard option. Click <a href="http://www.outsourcingexposed.com/155/free-link-removal-tool/" target="_blank" title="Click here">here</a> for details</li>';
$text .= '<li><strong>REPLACE URL</strong> option (or delete). Replace with a good URL.</li>';
$text .= '<li>Centralized URL list option. Apply the same URL rules to any or all of your sites.</li>';
//$text .= '</ol><p>So click this button to get the <strong>FREE Pro version</strong></p>';
$text .= '</ol>';
?>
<div class="wrap">
<script language="JavaScript">
<!--
function pclaen_all_posts() {
if ( document.pclaen_searchForm.pclaen_searchText.value == "" )
{
alert( 'Please write search text!' );
document.pclaen_searchForm.pclaen_searchText.focus();
return false;
} else {
document.pclaen_searchForm.pclaen_action.value = "pclaen_all_posts";
document.pclaen_searchForm.submit();
return true;
}
}
//-->
</script>
<h2>Link Remover</h2>
<br clear="all"/>
<br clear="all"/>
<table>
<tr>
<td valign="top" width="285">
<div>URL to un-link. This will remove all hyperlinks on your site pointing to this URL.<br />Add only the root domain, not a sub page and without the <i>http://www. part.</i>
<br />For example to remove links to <i>http://www.dodgysite.com/this-page/</i> add only <i>dodgysite.com</i></div><br />
<form action="" method="post" name="pclaen_searchForm">
<input type="hidden" name="pclaen_action" value="" />
<input type="hidden" name="pclaen_del_ID" value="" />
<input type="text" name="pclaen_searchText" size="50" />
<br clear="all"/>
<br clear="all"/>
<input type="button" onclick="pclaen_all_posts();" value="Clear all posts"/>
<br clear="all"/>
<br clear="all"/>
<?php
echo isset( $all_posts_Text ) ? $all_posts_Text : '';
?>
</form>
</td>
<td valign="top">
<a style="margin-left:480px;" href="http://www.outsourcingexposed.com/im-superhero-quiz/" title="www.outsourcingexposed.com" target="_blank"><img src="<?php echo plugins_url( 'ad.gif' , 'link-removal-tool-lite/link_removal_lite.php' ) ?>" border="0" width="300" height="180" alt="AD"></a>
</td>
</tr>
</table>
<div id="message" class="updated">
<div class="squeezer">
<?php _e( $text, LINKREM_TEXT_DOMAIN ) ?>
<p class="submit">
<a href="http://www.outsourcingexposed.com/155/free-link-removal-tool/" class="button-primary">
<?php _e( 'Download now', LINKREM_TEXT_DOMAIN ) ?>
</a>
</p>
</div>
</div>
</div>
Now after php upgrade I get this error:
Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in public_html/wp-content/plugins/link-removal-tool/link_removal_lite.php:71 Stack trace: #0 /public_html/wp-content/plugins/link-removal-tool/link_removal_lite_page.php(4): pclaen_all_posts_check() #1 /public_html/wp-content/plugins/link-removal-tool/link_removal_lite.php(41): include('/w...') #2 /public_html/wp-includes/class-wp-hook.php(286): pclaen_page('') #3 /public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #4 /public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #5 /public_html/wp-admin/admin.php(224): do_action('toplevel_page_l...') #6 {main} thrown in /public_html/wp-content/plugins/link-removal-tool/link_removal_lite.php on line 71