Skip to content

Instantly share code, notes, and snippets.

View INDIAN2020's full-sized avatar

Gogula Sivannarayana INDIAN2020

View GitHub Profile
@INDIAN2020
INDIAN2020 / add-to-cart-redirect.php
Created June 18, 2018 06:31 — forked from yanknudtskov/add-to-cart-redirect.php
Skip the cart and go directly to checkout #woocommerce #cart
<?php
/**
* Direct Checkout on Add-to-cart
*/
add_filter('add_to_cart_redirect', 'yanco_add_to_cart_redirect');
function yanco_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
@INDIAN2020
INDIAN2020 / woocommerce-extra-registration-fields.php
Created June 18, 2018 06:31 — forked from yanknudtskov/woocommerce-extra-registration-fields.php
Add Extra WooCommerce Registration Fields #woocommerce
<?php
/**
* Add new register fields for WooCommerce registration.
*/
function yanco_woocommerce_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
@INDIAN2020
INDIAN2020 / adobe-typekit-google-fonts.php
Created June 18, 2018 06:30 — forked from yanknudtskov/adobe-typekit-google-fonts.php
Using Adobe TypeKit and Google Fonts with WordPress
<?php
function yanco_scripts() {
if( !is_admin() ) {
$query_args = array(
'family' => 'Open+Sans:300,500,700',
'subset' => 'latin,latin-ext',
wp_register_script( 'adobe-typekit', 'https://use.typekit.net/jkr3fxw.js');
@INDIAN2020
INDIAN2020 / post-type-tax-filter.php
Created June 18, 2018 06:29 — forked from yanknudtskov/post-type-tax-filter.php
Adding a taxonomy filter for post types in Admin Screens #woocommerce #wordpress #wp-admin
<?php
function yanco_add_taxonomy_filters() {
global $typenow;
// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
$taxonomies = array('alle-brands');
// must set this to the post type you want the filter(s) displayed on
if( $typenow == 'product' ){
@INDIAN2020
INDIAN2020 / required-plugins.php
Created June 18, 2018 06:28 — forked from yanknudtskov/required-plugins.php
Require one or more plugins to be installed
<?php
Class PLUGIN_CLASS {
private $required_plugins = array( 'woocommerce' );
function have_required_plugins() {
if (empty($this->required_plugins))
return true;
$active_plugins = (array) get_option('active_plugins', array());
if (is_multisite()) {
@INDIAN2020
INDIAN2020 / google-fonts.php
Created June 18, 2018 06:25 — forked from yanknudtskov/google-fonts.php
Google Fonts for WordPress
<?php
function yanco_scripts() {
if( !is_admin() ) {
$query_args = array(
'family' => 'Lora:400,700,400italic,700italic|Droid+Sans:400,700',
'subset' => 'latin,latin-ext',
);
wp_register_style( 'yanco-google-fonts', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
<?php
function get_youtube_preview_image( $url ) {
$vars = array();
parse_str( parse_url( $url, PHP_URL_QUERY ), $vars );
return 'https://img.youtube.com/vi/'.$vars['v'].'/hqdefault.jpg';
}
@INDIAN2020
INDIAN2020 / get-vimeo-thumbnail.php
Created June 18, 2018 06:24 — forked from yanknudtskov/get-vimeo-thumbnail.php
Get Vimeo Video Thumbnail #vimeo
<?php
function get_vimeo_video_id( $vimeo_url ) {
// ----- http://stackoverflow.com/a/10489007/1291469 ----- //
$video_id = (int) substr(parse_url($vimeo_url, PHP_URL_PATH), 1);
return $video_id;
}
function get_vimeo_thumbnail( $vimeo_url ) {
// ----- http://stackoverflow.com/a/1361192/1291469 ----- //
@INDIAN2020
INDIAN2020 / get-youtube-preview-image.php
Created June 18, 2018 06:24 — forked from yanknudtskov/get-youtube-preview-image.php
Getting YouTube Preview Image #youtube
<?php
function get_youtube_preview_image( $url ) {
$vars = array();
parse_str( parse_url( $url, PHP_URL_QUERY ), $vars );
return 'https://img.youtube.com/vi/'.$vars['v'].'/hqdefault.jpg';
}
@INDIAN2020
INDIAN2020 / robots.txt
Created June 18, 2018 06:23 — forked from yanknudtskov/robots.txt
Prevent robots from crawling WooCommerce add-to-cart links, which can create a huge performance hit. https://closte.com/blog/prevent-robots-crawling-add-to-cart-links-on-woocommerce #woocommerce #htaccess #optimization
User-agent: *
Disallow: /*add-to-cart=*
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/