Skip to content

Instantly share code, notes, and snippets.

View Narga's full-sized avatar

Nguyễn Đình Quân Narga

View GitHub Profile
@Narga
Narga / definition-lists-with-wp_nav_menu.php
Created November 27, 2012 01:49
Use definition lists with wp_nav_menu
// Secondary Menu is Widgetable
function widget_secondary_navigation() {
$args = array(
'echo' => false,
'items_wrap' => '<dl id="%1$s" class="%2$s myclass">%3$s</dl>','theme_location' => 'secondary_navigation', 'container' => false, 'menu_class' => 'sub-nav'
);
$subject = wp_nav_menu( $args );
$search = array('<ul', '</ul>', '<li', '</li>');
$replace = array('<dl', '</dl>', '<dd', '</dd>');
@Narga
Narga / WordPress Theme Customizer Sample.php
Created November 19, 2012 01:58 — forked from Abban/WordPress Theme Customizer Sample.php
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
@Narga
Narga / gist:3162558
Created July 23, 2012 08:22 — forked from mhawksey/gist:1106744
Bunch of Google Apps Script snippets for getting social bookmark/share counts. Used in http://mashe.hawksey.info/2011/07/shared-counts/
/*
All code apart from getPlusones()
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@Narga
Narga / foundation wp link pages
Created July 10, 2012 08:03 — forked from Firestorm-Graphics/foundation wp link pages
custom wp_link_pages() for Foundation
@Narga
Narga / more.md
Created July 1, 2012 10:12 — forked from vasilisvg/more.md
This is my backup script which syncs my server to my dropbox every day.

The script below is triggered every day from my Mac. I use Hazel to move the tar.gz to an external hard disk once it's finished. This happens every day without me noticing.

You should have a similar script.

@Narga
Narga / wordpress-remove-recent-comment-style.php
Created June 7, 2012 08:26
Wordpress Snippets - remove recent comments style
<?php
//http://www.narga.net/how-to-remove-or-disable-comment-reply-js-and-recentcomments-from-wordpress-header
function twentyten_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
?>
@Narga
Narga / delicious-text-count.js
Created June 7, 2012 04:13
Show how many times your url has been added to Delicious
//http://www.narga.net/display-plan-text-counter-of-feedburner-delicious-and-twitter/
<script type="text/javascript">
//the callback -- what do we do with the json response?
function get_delicious_count(info) {
//get the number of saves
var num = info[0].total_posts
//if none, do nothing
if(!num) return;
//if some, I add the number to the end of my link, like at the top of every one of my article posts.
return $('delic').set({
@Narga
Narga / feedburner-text-count.php
Created June 7, 2012 04:11
Display your FeedBurner count in full text
//http://www.narga.net/display-plan-text-counter-of-feedburner-delicious-and-twitter/
<?php
//get cool FeedBurner count
$fburl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";
//Initialize the Curl session
$ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);
@Narga
Narga / jquery-form-inline-label.css
Created June 7, 2012 02:52
Form's Inline Label CSS Code
/* http://www.narga.net/making-awesome-forms-inline-labels-with-jquery */
input {
border: 1px solid #ccc;
color: #000;
font: inherit;
padding: 4px;
width: 230px;
}
input:focus { border-color: #99B32D;}
.focus { color: #8F8F8F; }
@Narga
Narga / jquery-form-inline-label.js
Created June 7, 2012 02:49
jQuery - Form's Inline Label
//http://www.narga.net/making-awesome-forms-inline-labels-with-jquery
$(document).ready(function() {
$.fn.setCursorPosition = function(pos) {
if ($(this).get(0).setSelectionRange) {
$(this).get(0).setSelectionRange(pos, pos);
} else if ($(this).get(0).createTextRange) {
var range = $(this).get(0).createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);