Last active
September 29, 2019 07:49
-
-
Save chwnam/9f3bd818f65ce4ed3e337c834f7f2ba2 to your computer and use it in GitHub Desktop.
WordPress Clean Startup: 허가되지 않은 모든 플러그인과 테마를 사용하지 않고 코어를 동작시킵니다. 굉장히 빠른 시동이 됩니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress Clean Startup | |
* Description: Really clean WordPress Startup. | |
* Author: Changwoo Nam | |
* Author URI: cs.chwnam@gmail.com | |
* Version: 1.0.0 | |
* License: Public domain | |
* | |
* - 허가되지 않은 모든 플러그인과 테마를 사용하지 않고 코어를 동작시킵니다. | |
* - 필터를 적용하려면 반드시 이 플러그인보다 먼저 로드되도록 이름을 지으십시오. 그냥 이 코드를 수정하셔도 됩니다. | |
* - 반드시 MU 플러그인으로 동작해야 합니다. | |
*/ | |
if ( ! function_exists( 'wp_clean_startup_is_enabled' ) ) { | |
function wp_clean_startup_is_enabled() { | |
// Implement your code here. 시작 조건의 코드를 여기에 구현. | |
$result = false; | |
return apply_filters( 'wp_clean_startup_is_enabled', $result ); | |
} | |
} | |
if ( wp_clean_startup_is_enabled() ) { | |
if ( ! function_exists( 'wp_clean_startup_active_plugins' ) ) { | |
function wp_clean_startup_active_plugins( $option ) { | |
// Your plugin whitelist here. 플러그인의 화이트리스트. | |
$whitelist = array(); | |
return array_intersect( | |
$option, | |
apply_filters( 'wp_clean_startup_plugin_whitelist', $whitelist ) | |
); | |
} | |
add_filter( 'option_active_plugins', 'wp_clean_startup_active_plugins' ); | |
} | |
if ( ! function_exists( 'wp_clean_startup_return_fake_path' ) ) { | |
function wp_clean_startup_return_fake_path() { | |
return ABSPATH . 'fake-path/does-not-exist'; | |
} | |
add_filter( 'template_directory', 'wp_clean_startup_return_fake_path' ); | |
add_filter( 'stylesheet_directory', 'wp_clean_startup_return_fake_path' ); | |
} | |
if ( ! function_exists( 'wp_clean_startup_remove_wp_head' ) ) { | |
function wp_clean_startup_remove_wp_head() { | |
remove_action( 'wp_head', 'noindex', 1 ); | |
remove_action( 'wp_head', 'wp_post_preview_js', 1 ); | |
remove_action( 'wp_head', 'wp_resource_hints', 2 ); | |
remove_action( 'wp_head', 'feed_links', 2 ); | |
remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); | |
remove_action( 'wp_head', 'rsd_link', 10 ); | |
remove_action( 'wp_head', 'wlwmanifest_link', 10 ); | |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); | |
remove_action( 'wp_head', 'wp_generator', 10 ); | |
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ); | |
remove_action( 'wp_head', 'wp_oembed_add_host_js', 10 ); | |
remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); | |
remove_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' ); | |
} | |
add_action( 'init', 'wp_clean_startup_remove_wp_head' ); | |
} | |
if ( ! function_exists( 'wp_clean_startup_document_title_parts' ) ) { | |
global $_wp_theme_features; | |
$_wp_theme_features['title-tag'] = true; | |
function wp_clean_startup_document_title_parts() { | |
return array( | |
// Your site title here. 사이트의 창 제목 표시. | |
'title' => apply_filters( 'wp_clean_startup_document_title', 'Your Cleaned WordPress' ), | |
'page' => 'Dashboard', | |
'site' => get_bloginfo( 'name', 'display' ), | |
); | |
} | |
add_filter( 'document_title_parts', 'wp_clean_startup_document_title_parts' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
간단한 예제 플러그인을 구현해 봤습니다. 여기로 이동하여 다운로드 받은 후 테스트용 워드프레스 설치본에 대해 실행해 보세요.