WordPress 在线修改 php 文件提示 Scrape key check failed. Please try again
共计 1480 个字符,预计需要花费 4 分钟才能阅读完成。
挺郁闷的,清朝云今天修改 php 文件时报错了。
/>
网上找了一圈没结果,但是这个功能又不能不管,于是只能使用下策了,修改 wordpress 核心文件。
找到 wp-includes
文件夹下面的 load.php
文件,修改 wp_start_scraping_edited_file_errors
函数。
原代码:
function wp_start_scraping_edited_file_errors() {
if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) {
return;
}
$key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 );
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] );
if ( get_transient( 'scrape_key_' . $key ) !== $nonce ) {
echo "###### wp_scraping_result_start:$key ######";
echo wp_json_encode(
array(
'code' => 'scrape_nonce_failure',
'message' => __( 'Scrape key check failed. Please try again.' ),
)
);
echo "###### wp_scraping_result_end:$key ######";
die();
}
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true );
}
register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key );
}
这里只需要修改一下判断逻辑即可。
function wp_start_scraping_edited_file_errors() {
if ( ! isset( $_REQUEST['wp_scrape_key'] ) || ! isset( $_REQUEST['wp_scrape_nonce'] ) ) {
return;
}
$key = substr( sanitize_key( wp_unslash( $_REQUEST['wp_scrape_key'] ) ), 0, 32 );
$nonce = wp_unslash( $_REQUEST['wp_scrape_nonce'] );
if ( get_transient( 'scrape_key_' . $key ) == $nonce ) {
echo "###### wp_scraping_result_start:$key ######";
echo wp_json_encode(
array(
'code' => 'scrape_nonce_failure',
'message' => __( 'Scrape key check failed. Please try again.' ),
)
);
echo "###### wp_scraping_result_end:$key ######";
die();
}
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true );
}
register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key );
}
提醒:本文发布于518天前,文中所关联的信息可能已发生改变,请知悉!
Tips:清朝云网络工作室
阅读剩余
THE END

0

分享

二维码

海报
发表评论
您需要登录后评论
赶快来坐沙发