Skip to content

Instantly share code, notes, and snippets.

View ravismakwana's full-sized avatar
:octocat:

Ravi Makwana ravismakwana

:octocat:
  • India
View GitHub Profile
@bavington
bavington / wp_speed_functions.php
Last active October 1, 2020 10:15
WordPress functions to remove (potentially) redundant functionality and page speed improvements.
<?php
// REMOVE EMOJIS
// Emojis are enabled by default, so if you don't want to use these you can remove the script and stylesheet:
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
// REMOVE COMMENT-REPLY.MIN.JS
// This is added by default to the footer, if you're not using post comments or DISQUS you can remove the script:
function remove_comment_reply_script(){
@chromaphobic
chromaphobic / gist:1636d87f6b230e87345c
Created October 26, 2015 15:51
Museo Slab Web Font
<!-- Include the following snippet in the "Custom CSS and JS" section of Sitecore: -->
<script src="//use.typekit.net/nwl5dzm.js"></script><script>try{Typekit.load({ async: true });}catch(e){}</script>
<!-- For the CSS, use the following example font-family declration: -->
<style>
h1 {
font-family: 'Museo Slab', 'museo-slab', 'Helvetica', 'Arial', sans-serif;
}
</style>
<!-- Currentlym the valid font weights are 300, 500, and 700 -->
@Rhymes2k
Rhymes2k / functions.php
Created October 18, 2015 16:33
Wordpress: Boilerplate Functions.php
/** ******** ******** ******** ******** ******** ******** ******** ********
* Faster than @import
*
* http://codex.wordpress.org/Customizing_the_Login_Form
*
*/
function my_child_theme_scripts() {
wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
@darsain
darsain / svg_sprites.md
Last active February 19, 2025 07:08
How to use SVG sprites in img[src] and css backgrounds

To make this work in CSS:

background: url('images.svg#chart');

or img:

<img src="images.svg#chart">
@dededey
dededey / custom_field_woocommerce_product_category.php
Created August 5, 2015 10:21
add custom field to woocommerce product category
// Add term page
function custom_url_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Custom url category', 'custom_url_category' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Inserisci un custom url prodotto per la categoria','custom_url_category' ); ?></p>
</div>
<?php
@wpscholar
wpscholar / create-admin-user.php
Last active January 30, 2025 17:31
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = '[email protected]';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
@arkadijs
arkadijs / _README.md
Last active January 9, 2021 14:21
Workshop: Deploying WordPress on Google App Engine :: PHP and Cloud SQL http://ldn.lv/events/166755872 http://goo.gl/F5K4Qn

Google Cloud SDK

There are two alternatives to start with the SDK:

  1. install SDK locally;
  2. use provided Linux VM in the cloud via ssh.

Note: everyone will get a separate index, ie. hacker02, hacker03, etc.

$ ssh [email protected]

@westonruter
westonruter / functions.php
Last active December 31, 2021 11:47
Demonstrate how to add support to Widget Customizer for sidebars and widgets which have JavaScript initialization http://wordpress.org/plugins/widget-customizer/
<?php
/**
* The functions.php for a theme, adding theme support for widget-customizer,
* and registering a sidebar whose widgets maintain equal heights even when
* widgets in the sidebar are updated via Customizer. This is for demonstration
* purposes, and normally JS wouldn't be embedded in PHP.
* @see http://wordpress.org/plugins/widget-customizer/
*/
/**
@kloon
kloon / gist:4015657
Created November 5, 2012 06:24
WooCommerce add login/logout buttons to wordpress menu
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li><a href="'. wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) .'">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li><a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '">Log In</a></li>';
}
return $items;
}
@kprimdal
kprimdal / wp-query-ref.php
Created September 29, 2012 14:57 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(