Skip to content

Instantly share code, notes, and snippets.

View CodeNegar's full-sized avatar

CodeNegar CodeNegar

View GitHub Profile
@CodeNegar
CodeNegar / gist:3134079
Created July 18, 2012 03:58
html: javascript google plus one button
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<!-- Place this tag where you want the +1 button to render -->
<g:plusone></g:plusone>
or:
@CodeNegar
CodeNegar / gist:3134111
Created July 18, 2012 04:10
html: javascript facebook like button for wordpress
<script src="http://connect.facebook.net/sl_SI/all.js#xfbml=1"></script><fb:like href="<?php echo get_permalink()?>"; layout="standard" show_faces="true" width="450" font="arial"></fb:like>
@CodeNegar
CodeNegar / gist:3134116
Created July 18, 2012 04:11
html: javascript facebook share button
<div class="fbshare"><script src="http://widgets.fbshare.me/files/fbshare.js"></script></div>
@CodeNegar
CodeNegar / gist:3134171
Created July 18, 2012 04:23
php: wordpress get featured image
$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
echo $imgsrc[0];
@CodeNegar
CodeNegar / gist:3153958
Created July 21, 2012 00:11
php: email validation function
<?php
/**
Email validation function. Thanks to http://www.linuxjournal.com/article/9585
*/
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
@CodeNegar
CodeNegar / gist:3173462
Created July 24, 2012 23:47
sublime text 2 install package conttrol
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
@CodeNegar
CodeNegar / gist:3175630
Created July 25, 2012 11:25
javascript string replace
var str="Visit Microsoft!";
var n=str.replace("Microsoft","W3Schools");
alert(n); //Visit W3Schools!
@CodeNegar
CodeNegar / CustomWidgetFile.php
Created August 1, 2012 18:22 — forked from jonathonbyrdziak/CustomWidgetFile.php
EMPTY WIDGET Plugin code to create a single widget in wordpress.
<?php
/**
* Duplicate this file as many times as you would like, just be sure to change the
* Empty_Widget class name to a custom name of your choice. Have fun! redrokk.com
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Contact_RedRokk_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@CodeNegar
CodeNegar / gist:3417854
Created August 21, 2012 17:53
html: javascript textbox watermark
<input type="text" id="terms" size="40" onblur="if ( this.value == '' ) this.value = this.defaultValue" onfocus="if ( this.value == this.defaultValue ) this.value = ''" value="type your search here">
@CodeNegar
CodeNegar / gist:3462679
Created August 25, 2012 08:54
php: current page url
<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}