芝麻web文件管理V1.00
编辑当前文件:/home/elegucvf/public_html/backup_1740598049/includes/Admin/Ajax.php
get_error_message()); } wp_send_json_success(__('Plugin is installed successfully!', 'simple-301-redirects')); wp_die(); } public function activate_plugin() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); $basename = isset($_POST['basename']) ? sanitize_text_field($_POST['basename']) : ''; $result = activate_plugin($basename, '', false ); if (is_wp_error($result)) { wp_send_json_error($result->get_error_message()); } if ($result === false) { wp_send_json_error(__('Plugin couldn\'t be activated.', 'simple-301-redirects')); } wp_send_json_success(__('BetterLinks is activated!', 'simple-301-redirects')); wp_die(); } public function hide_notice() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); $hide = isset($_POST['hide']) ? sanitize_text_field($_POST['hide']) : false; update_option('simple301redirects_hide_btl_notice', $hide); wp_send_json_success($hide); wp_die(); } public function fetch_all_links() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); wp_send_json_success(get_option('301_redirects', [])); wp_die(); } public function create_new_link() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); $key = (isset($_POST['key']) ? sanitize_text_field($_POST['key']) : ''); $value = (isset($_POST['value']) ? sanitize_text_field($_POST['value']) : ''); $links = get_option('301_redirects', []); if(!empty($key) && !isset($links[$key])){ $links[$key] = $value; update_option('301_redirects', $links); } wp_send_json_success($links); wp_die(); } public function update_link() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); $key = (isset($_POST['key']) ? sanitize_text_field($_POST['key']) : ''); $oldKey = (isset($_POST['oldKey']) ? sanitize_text_field($_POST['oldKey']) : ''); $value = (isset($_POST['value']) ? sanitize_text_field($_POST['value']) : ''); $links = get_option('301_redirects', []); if(isset($links[$oldKey])){ if(isset($oldKey) && $oldKey != $key){ unset($links[$oldKey]); } $links[$key] = $value; update_option('301_redirects', $links); } wp_send_json_success($links); wp_die(); } public function delete_link() { check_ajax_referer('simple301redirects', 'security'); if( ! current_user_can( 'manage_options' ) ) wp_die(); $key = (isset($_POST['key']) ? sanitize_text_field($_POST['key']) : ''); $links = get_option('301_redirects'); if(isset($links[$key])){ unset($links[$key]); update_option('301_redirects', $links); } wp_send_json_success($links); wp_die(); } }