Skip to content

Instantly share code, notes, and snippets.

View ravismakwana's full-sized avatar
:octocat:

Ravi Makwana ravismakwana

:octocat:
  • India
View GitHub Profile
@scribu
scribu / backtrace-errors.php
Created October 14, 2010 07:25
Backtrace Errors
<?php
// Forked from: http://stackoverflow.com/questions/1159216/how-can-i-get-php-to-produce-a-backtrace-upon-errors/1159235#1159235
function process_error_backtrace($errno, $errstr, $errfile, $errline) {
if(!(error_reporting() & $errno))
return;
switch($errno) {
case E_WARNING :
case E_USER_WARNING :
case E_STRICT :
@mikejolley
mikejolley / gist:2044101
Last active May 18, 2021 17:02
WooCommerce - Show number of items in cart and total
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@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(
@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;
}
@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/
*/
/**
@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 hacker01@wp-workshop.hosting.lv

@wpscholar
wpscholar / create-admin-user.php
Last active February 27, 2024 11:54
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 = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );
@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
@darsain
darsain / svg_sprites.md
Last active April 10, 2024 11:15
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">
@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' );
}