Skip to content

Instantly share code, notes, and snippets.

View CodeNegar's full-sized avatar

CodeNegar CodeNegar

View GitHub Profile
@CodeNegar
CodeNegar / gist:fb8401406dacfa85af10
Created July 13, 2012 16:29
php: wordpress run shortcode outside post
<?php echo do_shortcode('[sample_shortcode]'); ?>
@CodeNegar
CodeNegar / gist:3126773
Created July 17, 2012 03:15
javascript: jquery findout running version
jQuery.fn.jquery
@CodeNegar
CodeNegar / gist:3126805
Created July 17, 2012 03:21
javascript: jquery current page url
jQuery(location).attr('href');
@CodeNegar
CodeNegar / gist:3126872
Created July 17, 2012 03:38
javascript: jquery no conflict
var jqzk = jQuery.noConflict();
jqzk("#update-cart").html("<b>something</b>");
@CodeNegar
CodeNegar / gist:3127369
Created July 17, 2012 05:19
javascript: add script to document dynamicly
var scriptTag = document.createElement("script");
scriptTag.src = "http://example.com/myscript.js";
bodyTag.appendChild(scriptTag);
@CodeNegar
CodeNegar / gist:3127674
Created July 17, 2012 06:45
javascript: jquery selected dropdown value and text
jQuery("#drop1 option:selected").text(); // text
$("#drop1option").is("selected").text() // text, a little faster
jQuery("#drop1").val(); // value
@CodeNegar
CodeNegar / gist:3127782
Created July 17, 2012 07:20
javascript: jquery document ready
$(document).ready(function() {
// put all your jQuery goodness in here.
});
@CodeNegar
CodeNegar / gist:3128542
Created July 17, 2012 10:07
php: wordpress current theme path
TEMPLATEPATH
bloginfo('template_url');
get_template_directory()
@CodeNegar
CodeNegar / gist:3128698
Created July 17, 2012 10:52
php: get local time, region time and date
<?php
date_default_timezone_set('Asia/Tehran');
echo date("H:i:s"); // prints eg. 04:29:55 tehran local time
?>
@CodeNegar
CodeNegar / gist:3133988
Created July 18, 2012 03:28
php: wordpress custom shortcode
function helloworld() {
return 'Hello World!';
}
add_shortcode('hello', 'helloworld');