Skip to content

Instantly share code, notes, and snippets.

View skjaved's full-sized avatar
👨‍💻
</>

Javed Shaikh skjaved

👨‍💻
</>
View GitHub Profile
@skjaved
skjaved / wp-query-ref.php
Created January 28, 2021 04:38 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@skjaved
skjaved / wc_custom_redirect.php
Last active January 2, 2021 17:24
This snippet will redirect users based on their cart status to homepage or checkout page
<?php
// Redirect on checkout page after registration
// Redirect new users based on their cart status
function custom_redirection_after_registration() {
if ( WC()->cart->is_empty() ) {
wp_redirect( get_home_url() );
} else {
wp_redirect( get_permalink( get_option( 'woocommerce_checkout_page_id' ) ) );
}
}
<?php
/**
* Custom walker class.
*/
class WPDocs_Walker_Nav_Menu extends Walker_Nav_Menu {
/**
* Starts the list before the elements are added.
*
* Adds classes to the unordered list sub-menus.
<?php
// Display product author on website
add_action( 'woocommerce_single_product_summary', 'woocommerce_product_author', 6);
function woocommerce_product_author() {
the_author();
}
@skjaved
skjaved / wc-display-category-image-archive.php
Last active December 31, 2020 18:21 — forked from woogists/wc-display-category-image-archive.php
[Theming] Display category image on category archive
/**
* Display category image on category archive
*/
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
@skjaved
skjaved / change.js
Created October 16, 2020 09:28 — forked from DmitriyRF/change.js
Remove or don't redirect “thank you” page Mailchimp
/* To use this example:
1. Download this html file
2. Replace the form action url with your own from the MailChimp supplied embed code
3. Within the action url, replace "subscribe/post" with "subscribe/post-json"
4. Be sure the action url starts with http://. If it doesn't, the form will hang when testing the html as a local file in your browser.
5. Open this file in a browser on your local machine
*/
@skjaved
skjaved / echo-enqueued-styles-scripts-wordpress.php
Last active December 31, 2020 18:23 — forked from omurphy27/echo-enqueued-styles-scripts-wordpress.php
Wordpress - Print Out All Enqueued Scripts And Styles On A Page
<?php
// add the below to your functions file
// then visit the page that you want to see
// the enqueued scripts and stylesheets for
function se_inspect_styles() {
global $wp_styles;
echo "<h2>Enqueued CSS Stylesheets</h2><ul>";
foreach( $wp_styles->queue as $handle ) :
echo "<li>" . $handle . "</li>";
@skjaved
skjaved / responsive-font.txt
Created September 8, 2020 06:50
Calculate font size responsively using css calc() function
Responsive font formula
font-size: calc(min font-size + font range * (100vw - min screen size) / screen range);
where font range = (max font-size) - (min font-size)
and screen range = (max screen size) - (min screen size).
@skjaved
skjaved / utility.css
Created September 8, 2020 06:45
CSS utility classes file to use as generic classes file
/* CSS utility classes to use in
* core css projects
*/
/* UTILITY CLASSES */
.container {
display: block;
max-width: 1440px; /* max-width of your design frame */
margin: 0 auto;
}
@skjaved
skjaved / normalize.css
Last active September 8, 2020 06:43
Normalize css created to fix browser default styling
/*! Normalize css created from github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/