Skip to content

Instantly share code, notes, and snippets.

Vien Hoang vienhoang

Block or report user

Report or block vienhoang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:04a3e843266f92413409
<?php
/*
Plugin Name: Movies Post Type
Plugin URI: http://vienhoang.com
Description: Offers a method for managing a movie collection.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
View gist:242bb9e3cf0ea33e595e
function add_url_to_text( $text ) {
// Look for anything that is not a space, i = case insensitive, m = multiple line
$text = preg_replace('/(http[^s])+/im', '<a href="$1">$1</a>', $text );
return $text;
}
@vienhoang
vienhoang / messenger.php
Created Aug 11, 2014
WordPress: Custom widget
View messenger.php
<?php
/*
Plugin Name: Messenger Widget
Plugin URI: http://vienhoang.com
Description: Display any messages.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / movies_post_type.php
Created Aug 11, 2014
WordPress: Custom post type
View movies_post_type.php
<?php
/*
Plugin Name: Movies Post Type
Plugin URI: http://vienhoang.com
Description: Offers a method for managing a movie collection.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / movies_post_type_shortcode.php
Created Aug 11, 2014
WordPress: Custom post type shortcode
View movies_post_type_shortcode.php
<?php
add_shortcode( 'vh_movies', function() {
$loop = new WP_Query(
array(
'post_type' => 'vh_movie',
'orderby' => 'title'
)
);
if ( $loop->have_posts() ) {
@vienhoang
vienhoang / index.php
Created Aug 11, 2014
WordPress: Custom shortcode
View index.php
<?php
/*
Plugin Name: Twitter Shower
Plugin URI: http://vienhoang.com
Description: Display message.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / vh_cron.php
Created Aug 11, 2014
WordPress: Custom cron job
View vh_cron.php
<?php
/*
Plugin Name: VH Cron
Plugin URI: http://vienhoang.com
Description: Demo for running WP Cron Jobs
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / vh_filter.php
Created Aug 11, 2014
WordPress: Create custom filter
View vh_filter.php
<?php
/*
Plugin Name: VH Filter
Plugin URI: http://vienhoang.com
Description: Filter the content.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / vh_options.php
Created Aug 11, 2014
WordPress: Create custom options page
View vh_options.php
<?php
/*
Plugin Name: VH Options
Plugin URI: http://vienhoang.com
Description: Options page for a theme.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
@vienhoang
vienhoang / gist:e4c7dec93bd3e1c259ce
Created Aug 11, 2014
PHP: Break out of foreach func
View gist:e4c7dec93bd3e1c259ce
function limiting($num) {
$fruits = array('bananas', 'apples', 'pear');
foreach ( $fruits as $v ) {
if ( $num-- === 0) {
break;
}
You can’t perform that action at this time.