Skip to content

Instantly share code, notes, and snippets.

@jeweltheme
jeweltheme / .vimrc
Created August 8, 2017 09:08 — forked from hasinhayder/.vimrc
Vim Auto Indent and Syntaxt Highlighting On
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set autoindent
@jeweltheme
jeweltheme / Sublime Text 3 Build 3103 License Key - CRACK
Created July 18, 2017 22:45
Sublime Text 3 Build 3103 License Key - CRACK
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
@jeweltheme
jeweltheme / vc_custom_icon_set.php
Created July 9, 2017 15:59 — forked from zecka/vc_custom_icon_set.php
Add a custom icon set from icomoon to visual composer vc_icon shortcode
<?php
// Add new custom font to Font Family selection in icon box module
function zeckart_add_new_icon_set_to_iconbox( ) {
$param = WPBMap::getParam( 'vc_icon', 'type' );
$param['value'][__( 'IcoMoon', 'total' )] = 'icomoon';
vc_update_shortcode_param( 'vc_icon', $param );
}
add_filter( 'init', 'zeckart_add_new_icon_set_to_iconbox', 40 );
@jeweltheme
jeweltheme / wordpress-wp_query.php
Created May 30, 2017 19:37 — forked from chuckreynolds/wordpress-wp_query.php
Improve performance of the WordPress WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@jeweltheme
jeweltheme / custom-post-taxonomy-permalinks.php
Created May 28, 2017 18:13 — forked from kasparsd/custom-post-taxonomy-permalinks.php
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@jeweltheme
jeweltheme / remote-image-cache.php
Created May 18, 2017 21:08 — forked from jasondavis/remote-image-cache.php
Cache remote image using PHP
<?php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image
@jeweltheme
jeweltheme / gist:1aa535d1d211be91e223eb909ad96699
Created May 17, 2017 04:34 — forked from wwdboer/gist:4353695
WordPress: Template redirect
<?php
// In functions.php
add_action( 'template_redirect', 'redirect_template' );
function redirect_template() {
global $post;
if ( is_single() && is_post_type( 'custompost' ) ) {
wp_redirect( home_url() . '/custompost/' );
@jeweltheme
jeweltheme / gist:fb80063d7aa8e59c99f1cc27890fc10a
Created May 17, 2017 04:33 — forked from wwdboer/gist:4353758
PHP: Get YouTube ID from URL
<?php
function get_ytid( $url ) {
preg_match( "#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches );
return $matches[0];
}
?>
function get_vimeoid( $url ) {
$regex = '~
# Match Vimeo link and embed code
(?:<iframe [^>]*src=")? # If iframe match up to first quote of src
(?: # Group vimeo url
https?:\/\/ # Either http or https
(?:[\w]+\.)* # Optional subdomains
vimeo\.com # Match vimeo.com
(?:[\/\w]*\/videos?)? # Optional video sub directory this handles groups links also
\/ # Slash before Id
/**
* Wrap embed html with bootstrap responsive embed div
*/
function bootstrap_embed( $html, $url, $attr ) {
if ( ! is_admin() ) {
return "<div class=\"embed-responsive embed-responsive-16by9\">" . $html . "</div>";
} else {
return $html;
}
}