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>');
<?php
add_theme_support('menus');
/*
http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
'top-bar-r' => 'Right Top Bar'
));
@Narga
Narga / wordpress-trim-excerpt.php
Last active December 15, 2015 05:49
# Function to trim the excerpt
# Function to trim the excerpt
if (!function_exists('narga_excerpts')) :
function narga_excerpts($content = false) {
# If is the home page, an archive, or search results
if(is_front_page() || is_archive() || is_search()) :
global $post;
$content = $post->post_excerpt;
$content = strip_shortcodes($content);
$content = str_replace(']]>', ']]&gt;', $content);
$content = strip_tags($content);
// Facebook Social Tracking
window.fbAsyncInit = function() {
FB.init({
appId : '123456789', // ENTER your FB App ID
channelUrl : 'WWW.YOUR_DOMAIN.COM', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
WebFontConfig = {
google: { families: [ 'Istok+Web:400,700:latin' , 'Lora:400,700:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
<?php
add_theme_support('menus');
/**
* http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'main-menu' => 'Main Menu',
));
@Narga
Narga / excerpt.rb
Created August 24, 2013 17:12 — forked from stympy/excerpt.rb
# This goes in _plugins/excerpt.rb
module Jekyll
class Post
alias_method :original_to_liquid, :to_liquid
def to_liquid
original_to_liquid.deep_merge({
'excerpt' => content.match('<!--more-->') ? content.split('<!--more-->').first : nil
})
end
end
# Jekyll category page generator.
# http://recursive-design.com/projects/jekyll-plugins/
#
# Version: 0.1.4 (201101061053)
#
# Copyright (c) 2010 Dave Perrett, http://recursive-design.com/
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
#
# A generator that creates category pages for jekyll sites.
#
<?php
add_theme_support('menus');
/**
* Register Menus
* http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
*/
register_nav_menus(array(
'top-bar-l' => 'Left Top Bar', // registers the menu in the WordPress admin menu editor
'top-bar-r' => 'Right Top Bar'
@Narga
Narga / jetpack.php
Created August 27, 2013 01:10
WordPress Jetpack snippets
/*
* Check if Jetpack Modules Are Enabled
* carousel
* contact-form
* custom-css
* gravatar-hovercards
* infinite-scroll
* minileven (mobile theme)
* sharedaddy
* shortcodes