Skip to content

Instantly share code, notes, and snippets.

View quangbahoa's full-sized avatar
🎯
Focusing

Le Duy Quang quangbahoa

🎯
Focusing
View GitHub Profile
<?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)) {
@quangbahoa
quangbahoa / Fbsample.php
Created December 12, 2013 02:30
Fbsample.php
<?php
/**
* @author: Javier Reyes Gomez (http://www.sociable.es)
* @date: 05/10/2008
* @license: GPLv2
*/
global $wp_version, $fbconnect,$fb_reg_formfields;
/**
* 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
*/
@quangbahoa
quangbahoa / page.class.php
Created January 7, 2014 06:18
//Add archive class to body tag of specific page templates (those that work as archives)
//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')
<?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
<?php
$content = get_the_content();
$trimmed_content = wp_trim_words( $content, 40, '<a href="'. get_permalink() .'"> ...Read More</a>' );
echo $trimmed_content;
?>
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
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;
}
# If you meet install errors, see abid-hussain's comment
sudo apt-get --force-yes install build-essential openssl libreadline6 libreadline6-dev curl git-core \
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \
libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
&&
\curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
module Jekyll
class ArchivePage
include Convertible
attr_accessor :site, :pager, :name, :ext, :basename, :dir, :data, :content, :output
# Initialize new ArchivePage
# +site+ is the Site
# +month+ is the month
# +posts+ is the list of posts for the month