Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
vishalbasnet23 / index.html
Created May 5, 2015 11:23
Enable Events on disabled input fields (cheat)
<span style="position:relative;">
<input type="text" disabled />
<div style="position:absolute; left:0; right:0; top:0; bottom:0; cursor: pointer;" ></div>
</span>
<script>
$("span > div").click(function (evt) {
$(this).hide().prev("input[disabled]").prop("disabled", false).focus();
});
</script>
@vishalbasnet23
vishalbasnet23 / acf-option-select
Last active August 29, 2015 14:19
Country List Drop Down
AF : Afghanistan
AL : Albania
DZ : Algeria
AS : Samoa American
AD : Andorra
AG : Antigua &amp; Barbuda
AI : Anguilla
AR : Argentina
AA : Armenia
AW : Aruba

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

@vishalbasnet23
vishalbasnet23 / function.php
Created March 30, 2015 07:40
disable user registration from wp-login screen
<?php
add_action( 'login_head', 'hide_login_nav' );
function hide_login_nav()
{
?><style>#backtoblog{display:none}</style><?php
}
/**
* remove the register link from the wp-login.php script
@vishalbasnet23
vishalbasnet23 / _.md
Last active August 29, 2015 14:17 — forked from klange/_.md

Since this is on Hacker News...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later).
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • They're all while loops because shut up, you're overthinking a joke.
@vishalbasnet23
vishalbasnet23 / functions.php
Created March 16, 2015 08:44
Simple Heart Extenstion for WordPress Posts
<?php
/**
* Get Ip function
*/
function get_current_user_ip() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) :
$ip = $_SERVER['HTTP_CLIENT_IP'];
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) :
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
@vishalbasnet23
vishalbasnet23 / functions.php
Created March 16, 2015 08:37
Get Current User's IP
<?php
/**
* Get Ip function
*/
function get_current_user_ip() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) :
$ip = $_SERVER['HTTP_CLIENT_IP'];
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) :
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
@vishalbasnet23
vishalbasnet23 / functions.php
Created March 16, 2015 08:33
Adding Custom attributes to Oembed WordPress
<?php
/**
* Add 'id' attribute to Vimeo oEmbed HTML
*/
function prefix_embed_oembed_html( $html, $url, $attr, $post_ID ) {
$fix = true;
$fix &= strpos( $html, 'youtube.com' ) !== false; // Embed code from Vimeo
$fix &= strpos( $html, ' id=' ) === false; // No ID attribute supplied by Vimeo
$fix &= isset( $attr['player_id'] ); // Player ID supplied
@vishalbasnet23
vishalbasnet23 / functions.php
Created March 16, 2015 08:32
Customizing Comment form WordPress
<?php
/**
* Comment Style Callback
*/
function fuji_comment_callback($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
@vishalbasnet23
vishalbasnet23 / functions.php
Created March 16, 2015 08:31
Login redirect WP
<?php
function my_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
global $user;
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if ( in_array( 'administrator', $user->roles ) ) {
// redirect them to the default place
return $redirect_to;
} else {