Skip to content

Instantly share code, notes, and snippets.

@vishalbasnet23
vishalbasnet23 / client-side
Created November 14, 2014 11:05
Setting up git repo in remote server
git remote add server ssh://user@server.com:p/home/user/repo.git/
git push server master
@vishalbasnet23
vishalbasnet23 / Functions.php
Created November 17, 2014 10:04
Add Custom Image Upload Meta Field WordPress.
<?php
/*************************************************************************/
/* Adding Images Meta Boxes */
/*************************************************************************/
add_action('add_meta_boxes', 'add_images_meta_boxes');
function add_images_meta_boxes() {
// Define the images attachment for gallery
add_meta_box(
'code-gallery-attachment',
@vishalbasnet23
vishalbasnet23 / functions.php
Created November 17, 2014 10:05
Custom Load Template Function WordPress
<?php
/*******************************************************************************/
/* Loading templates */
/*******************************************************************************/
add_filter( 'single_template', 'get_custom_post_type_template' );
function get_custom_post_type_template($single_template) {
global $post;
if ($post->post_type == 'code_gallery') {
@vishalbasnet23
vishalbasnet23 / functions.php
Created November 17, 2014 10:06
Adding Extra Field in Term Field both on Add and Edit Form WordPress
<?php
add_action( 'edited_album', 'save_extra_taxonomy_fields', 10, 2);
add_action( 'album_edit_form_fields', 'album_edit_tax_fields', 10, 2 );
//edit taxonomy update
add_action('album_edit_tax_fields','save_extra_taxonomy_fields',10,2);
function album_edit_tax_fields($tag) {
//check for existing taxonomy meta for term ID
@vishalbasnet23
vishalbasnet23 / register-post-type.sublime-snippet
Last active August 29, 2015 14:10
Essential Snippets For Wordpress
<snippet>
<content><![CDATA[
/**************************************/
/* Registering post type */
/**************************************/
add_action('init','register_post_type_gallery');
function register_post_type_gallery() {
@vishalbasnet23
vishalbasnet23 / functions.php
Created November 27, 2014 06:48
Simple Slider with bootstrap carousel for WordPress
<?php
add_action('init','register_post_type_slider');
function register_post_type_slider() {
$labels = array(
'name' => __('Slider','_cpm'),
'singular_name' => __('Slider','_cpm'),
'add_new' => __('Add New Slider Image','_cpm'),
'add_new_item' => __('Add New Slider Image','_cpm'),
@vishalbasnet23
vishalbasnet23 / Readme.txt
Last active August 29, 2015 14:10
Simple excerpt by word count WordPress
Usage:
<?php echo code_content( $limit ); ?>
@vishalbasnet23
vishalbasnet23 / Readme.txt
Last active December 17, 2015 05:03
Thumb Resizer with BFI_thumb WordPress
Usage:
Download BFI_thumb.php file from https://github.com/bfintal/bfi_thumb and copy it into your 'inc' folder of your theme.
<img src="<?php echo code_project_img( $thumb_size, $image_width, $image_height );?> />
@vishalbasnet23
vishalbasnet23 / Readme.txt
Created December 15, 2014 11:20
Custom Activation Link on Sign Up WordPress
Step by step guide.
First Phase:
1.First create a html form with first name, last name and email field for signing up process.( Remember the action of the form it has to be the page slug of email confirmation page that you will be creating at in next phase. )
Second Phase :
1.Create a Page ( Remember the slug has to be the same of that of action of the form of phase one ) and assign the template template-confirmation-mail.php
2.This page is responsible for generating unqiue hash key and sending that hash key along with the user's new account credentials to their email.
3.Remember the link of the activation_link has to the link to the email-verification template, which we will be creating in next phase.
Third Phase :
1. Create a page and assign it to Email Verification Template.( Remember this template has to be assigned to the page that you sent in the mail in previous step )
2. This page is responsilble matching that unqiue key sent on the email once new user visit that page.
@vishalbasnet23
vishalbasnet23 / OAuth.php
Created December 16, 2014 10:47
Twitter Feed By Hashtag with PHP
<?php
// vim: foldmethod=marker
/* Generic exception class
*/
if (!class_exists('OAuthException')) {
class OAuthException extends Exception {
// pass
}
}