Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Building AirGapped Crypto Vault

Ashish Kumar ashfame

💭
Building AirGapped Crypto Vault
View GitHub Profile
View filtering-expiration-transient-wordpress.php
<?php
add_action( 'set_transient_my_transient', function( $value, $expiration ) {
$desired_expiration = 600;
if ( $expiration != $desired_expiration ) {
set_transient( 'my_transient', $value, $desired_expiration );
}
});
@ashfame
ashfame / synthesis.php
Created Sep 3, 2014
WP CLI commands available on web-synthesis servers
View synthesis.php
<?php
function synth_clear_mem_check () {
delete_transient( 'synthesis_memory_check' );
}
add_action('update_option_active_plugins', 'synth_clear_mem_check');
// If we're running from WP CLI, add our CLI commands.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
class Synthesis_Ops_Commands extends WP_CLI_Command {
/**
@ashfame
ashfame / facebook-like-thumbnail-force-default-image-everywhere.php
Last active Aug 29, 2015
Forcing single thumbnail to be used on Facebook with "Facebook Like Thumbnail" plugin
View facebook-like-thumbnail-force-default-image-everywhere.php
<?php
/**
* Plugin Name: Facebook Like Thumbnail - Force Default Image everywhere
* Plugin URI: https://gist.github.com/ashfame/62f59587aaa5c8ecb1ce
* Description: Forces the default image to be used as FB Thumbnail for every page
* Author: Ashfame
* Author URI: http://ashfame.com/
*/
@ashfame
ashfame / snippet.php
Created Mar 19, 2014
Querying post relationships in reverse direction when using Advanced Custom Fields plugin on WordPress
View snippet.php
<?php
$tour_pages = get_posts(
array(
'post_type' => 'tour',
'meta_query' => array(
array(
'key' => 'tour_author_relationship', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
@ashfame
ashfame / woocommerce-category-images-from-product.php
Last active Sep 10, 2020
Use WooCommerce product image as its category image, if category image is missing
View woocommerce-category-images-from-product.php
<?php
/**
* Plugin Name: WooCommerce Category Images Modification
* Plugin URI: http://blog.ashfame.com/?p=1117
* Description: Use product image as its category image on category archive pages (To override image for product category, upload one for that category and it will override)
* Author: Ashfame
* Version: 0.1.2
* Author URI: http://ashfame.com/
*/
@ashfame
ashfame / after.php
Created Mar 17, 2014
Using WooCommerce email design in custom emails
View after.php
$email = 'ashfame@example.com';
$subject = 'Custom stuff email';
$email_heading = 'Custom Heading';
$email_content = ''; // whatever it is
ob_start();
do_action( 'woocommerce_email_header', $email_heading );
echo $email_content; // or simply have HTML markup outside PHP tags here
@ashfame
ashfame / magento-set-defaults-address.php
Created Jun 13, 2013
Programmatically set default billing/shipping address of customers if they are not set in magento
View magento-set-defaults-address.php
<?php
require_once ("app/Mage.php");
umask(0);
Mage::app("default");
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
foreach ($collection as $customer) {
@ashfame
ashfame / ios-test.css
Created Dec 9, 2012 — forked from tonywok/ios-test.css
iOS Media Queries
View ios-test.css
// iOS Media Queries
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2
//
// Author: Tony Schneider (@tonywok)
// Please tell me where I fail. :)
// iPhone v(4,4S) portrait
// test: black text (overwritten by v* portrait) with blue background
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {
a {
@ashfame
ashfame / .gitignore
Created Dec 5, 2012
Magento repo sample .gitignore
View .gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@ashfame
ashfame / driver.js
Created Aug 7, 2012
kissmetrics-property-device
View driver.js
(function(){
var isFirstVisit = false;
if ( document.referrer == '' ) {
isFirstVisit = true;
} else {
// If referrer is not the site itself
if ( ! ( document.referrer.match( window.location.host ) ) )
isFirstVisit = true;
}
if ( isFirstVisit ) {
You can’t perform that action at this time.