This file contains hidden or 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 | |
//password resetter | |
include("wp-config.php"); | |
include("wp-blog-header.php"); | |
if (empty($_POST['emergency_pass'])) { | |
?> | |
<form method="post"> | |
set admin password: <input name="emergency_pass" type="password" /> | |
<input type="submit" /> | |
</form> |
This file contains hidden or 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 | |
/* | |
*压缩html代码 | |
*/ | |
function wp_compress_html() | |
{ | |
function wp_compress_html_main ($buffer) | |
{ | |
$initial=strlen($buffer); |
This file contains hidden or 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
①将以下代码粘贴到functions.php文件中。 | |
function catch_that_image() { | |
global $post, $posts; | |
$first_img = ''; | |
ob_start(); | |
ob_end_clean(); | |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
//获取文章中第一张图片的路径并输出 |
This file contains hidden or 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 | |
//第一次代码 | |
<script type="text/javascript"> | |
google.load('search', '1', {language : 'zh-CN'}); | |
google.setOnLoadCallback(function(){ | |
var customSearchControl = new google.search.CustomSearchControl('003292911367075971799:8iziecydkbw'); | |
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); | |
customSearchControl.draw('cse'); | |
var match = location.search.match(/q=([^&]*)(&|$)/); | |
if(match && match[1]){ |
This file contains hidden or 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
//将以下代码复制到index_html.php文件中,然后上传到网站根目录下 | |
<?php | |
$baseCmsUrl = "http://www.wenchenhk.com"; | |
$dmPageName = "index.php"; | |
$stPageName = "index.html"; | |
$tureStFile = dirname(__FILE__).'/'.$stPageName; | |
{ | |
$body = file_get_contents($baseCmsUrl.'/'.$dmPageName); | |
$fp = fopen($tureStFile, 'w'); | |
fwrite($fp, $body); |
This file contains hidden or 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 | |
//前几篇后几篇文章 | |
function wenchenhk_get_post( $previous = true, $number = 1 ) { | |
//global当前文章变量 $post 和数据库操作类wpdb | |
global $post, $wpdb; | |
if ( empty( $post ) ) | |
return null; | |
$current_post_date = $post->post_date;//当前文章的时间 |
This file contains hidden or 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 | |
//优化head()函数 | |
remove_action( 'wp_head', 'feed_links', 2 ); | |
remove_action( 'wp_head', 'feed_links_extra', 3 ); | |
remove_action( 'wp_head', 'rsd_link' ); | |
remove_action( 'wp_head', 'wlwmanifest_link' ); | |
remove_action( 'wp_head', 'index_rel_link' ); | |
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); | |
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); | |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); |
This file contains hidden or 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 | |
//自定义登陆页面信息 | |
function wenchenhk_login_message( $message ) { | |
if ( empty($message) ){ | |
return "<p class='message'>这个地方加入想要的提示信息</p>"; | |
} else { | |
return $message; | |
} | |
} | |
add_filter( 'login_message', 'wenchenhk_login_message' ); |
This file contains hidden or 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 | |
/** | |
* Programmatically logs a user in | |
* | |
* @param string $username | |
* @return bool True if the login was successful; false if it wasn't | |
*/ | |
function programmatic_login( $username ) { | |
if ( is_user_logged_in() ) { |