Skip to content

Instantly share code, notes, and snippets.

View ashfame's full-sized avatar
💭
What parts of our society are best governed by code?

Ashish Kumar ashfame

💭
What parts of our society are best governed by code?
View GitHub Profile
@ashfame
ashfame / woocommerce-category-images-from-product.php
Last active June 6, 2023 00:46
Use WooCommerce product image as its category image, if category image is missing
<?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 / Correct-way-to-enqueue-scripts-and-style-in-WordPress.php
Created February 27, 2012 13:36
Correct way to enqueue scripts and style in WordPress
<?php
/**
* Register Styles and Scripts
*/
add_action( 'wp_enqueue_scripts', 'ft_scripts_styles' );
function ft_scripts_styles() {
@ashfame
ashfame / awesome-wp-config-file.php
Created February 27, 2012 13:30
awesome-wp-config-file
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@ashfame
ashfame / delete-all-tags.php
Created November 25, 2011 10:11
Delete all tags of a WP install
<?php
/**
* Delete all tags of a WordPress blog
*
* @author Ashfame
*
* Place this file in root of your WordPress install and open it in the browser - domain.com/delete-all-tags.php
*/
@ashfame
ashfame / snippet.php
Created March 19, 2014 20:20
Querying post relationships in reverse direction when using Advanced Custom Fields plugin on WordPress
<?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 / magento-set-defaults-address.php
Created June 13, 2013 14:40
Programmatically set default billing/shipping address of customers if they are not set in magento
<?php
require_once ("app/Mage.php");
umask(0);
Mage::app("default");
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
foreach ($collection as $customer) {
@ashfame
ashfame / modify-page-title.php
Created August 3, 2012 15:43
Modifying page title using the_title filter in WordPress
<?php
add_filter( 'the_title', 'nine11day_modify_post_title' );
function nine11day_modify_post_title( $title ) {
if ( is_page() && in_the_loop() && $title == 'Existing Title' )
$title = '<span>Existing</span> Title';
return $title;
}
@ashfame
ashfame / nginx.conf
Created June 21, 2020 08:41
Shared nginx file for streaming to multiple platforms - untested, shared by a friend
#user nobody;
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
http {
@ashfame
ashfame / local-config-awesome-wp-config-file.php
Created February 27, 2012 13:34
Local config file to hold db credentials and for defining keys & salts along with the use of awesome wp-config.php file
<?php
/**
* WordPress config file to use one directory above WordPress root, when awesome version of wp-config.php is in use.
*
* Awesome wp-config.php file - https://gist.github.com/1923821
*/
/* WordPress Local Environment DB credentials */
@ashfame
ashfame / Recharge_Compliant_CSV_From_SubscribePro_Export.php
Created July 12, 2018 20:16
Feed the export from SubscribePro to it and it will generate a CSV that's Recharge compliant
<?php
// For reuse, just look inside get_mapped_value() that's where all the specific data handling is, which is what you will need to change
// To understand, how this works, head to run()
// ini_set( 'memory_limit', '2000M' );
class Recharge_Compliant_CSV_From_SubscribePro_Export {
private $source_csv_filename;