Skip to content

Instantly share code, notes, and snippets.

View tiendungdev's full-sized avatar

Tien Dung Dao tiendungdev

View GitHub Profile
p.comment-form-rating{float:left;display:inline-block;margin-right:5px;height:32px;}
p.stars:after,p.comment-form-rating:after{content:"";display:block;clear:both;}
p.stars span{width:80px;height:16px;position:relative;float:left;background:url(img/star.png) repeat-x left 0;}
p.stars span a{float:left;position:absolute;left:0;top:0;width:16px;height:0;padding-top:16px;overflow:hidden;}
p.stars span a:focus,p.stars span a:hover{background:url(img/star.png) repeat-x left -16px;}
p.stars span a.star-1{width:16px;z-index:10;}
p.stars span a.star-2{width:32px;z-index:9;}
p.stars span a.star-3{width:48px;z-index:8;}
p.stars span a.star-4{width:64px;z-index:7;}
p.stars span a.star-5{width:80px;z-index:6;}
// Unload CF7 assests
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
add_action( 'the_content', 'load_cf7_assets' );
function load_cf7_assets($content){
global $post;
// Load assests when content contains CF7 shortcode.
$post_content = $post->post_content;
if ( has_shortcode( $post_content, 'contact-form-7' ) ) { // Check if content contains CF7 shortcode
function unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_Tag_Cloud');
unregister_widget('WP_Widget_RSS');
@tiendungdev
tiendungdev / Disable jQuery migrate
Created March 18, 2018 15:39
Disable jQuery migrate in WP
function deregister_migrate() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
}
}
add_action('wp_enqueue_scripts', 'deregister_migrate');
@tiendungdev
tiendungdev / class-wp-numeric-pagination.php
Created March 18, 2018 15:40 — forked from cyberwani/class-wp-numeric-pagination.php
Wordpress Numeric Pagination Class that enables you to set the classes of each LI and A html tag.
<?php
/**
* Numeric Pagination Class
* @author Alexandre Plennevaux https://pixeline.be
*
* This class returns a list of LI > A. It is up to you to set the wrapping NAV > UL around your function call.
*
* @usage (setting specific classes)
*
* // Sets the css classes you want to be used for the output
@tiendungdev
tiendungdev / media-query.css
Created March 20, 2018 05:01 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* STYLES GO HERE */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@tiendungdev
tiendungdev / index.php
Created April 5, 2018 05:20 — forked from jbutko/index.php
PHP, WP, Contact Form 7: Echo Contact Form 7 form if it is installed (if function_exists)
<?php
if (function_exists('wpcf7')) {
echo do_shortcode( '[contact-form-7 id="413" title="Contact form 1"]' );
} else {
echo "<p class='title'>Please install <a href='http://wordpress.org/plugins/contact-form-7/' rel='nofollow'>Contact Form 7</a> plugin and build some contact form. Then use your shortcode on the contact page.</p>";
}
?>
@tiendungdev
tiendungdev / Add defer to loading of scripts WordPress
Created April 9, 2018 04:37
Add defer to loading of scripts WordPress
//to add defer to loading of scripts - use defer to keep loading order
function script_tag_defer($tag, $handle) {
if (is_admin()){
return $tag;
}
if (strpos($tag, '/wp-includes/js/jquery/jquery')) {
return $tag;
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 9.') !==false) {
return $tag;
function custom_unregister_theme_post_types() {
global $wp_post_types;
if ( isset( $wp_post_types["agent"] ) ) {
unset( $wp_post_types[ "agent" ] ); //UPDATED
}
}
add_action( 'init', 'custom_unregister_theme_post_types', 20 );