Skip to content

Instantly share code, notes, and snippets.

View rwkyyy's full-sized avatar
🏠
Working from home

RwkY rwkyyy

🏠
Working from home
View GitHub Profile
@robflaherty
robflaherty / csv-to-json.php
Created September 1, 2011 02:26
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
@thomasgriffin
thomasgriffin / gist:4159035
Last active December 30, 2019 18:27
Add custom post types to search results in WordPress.
<?php
add_filter( 'pre_get_posts', 'tgm_io_cpt_search' );
/**
* This function modifies the main WordPress query to include an array of
* post types instead of the default 'post' post type.
*
* @param object $query The original query.
* @return object $query The amended query.
*/
function tgm_io_cpt_search( $query ) {
@claudiosanches
claudiosanches / add-to-cart.php
Last active October 18, 2023 14:02
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@maxrice
maxrice / wc-hide-coupons-cart-checkout.php
Created January 21, 2014 23:43
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
@jillmugge
jillmugge / wp-config.php
Last active December 7, 2018 15:19
wp-config.php
/* Place after define('WP-DBUG', false);*/
define('FORCE_SSL_ADMIN', true); //will force login thru SSL https://entire site: goto general settings add https://
//define('ALTERNATE_WP_CRON', true); //posts not getting published? redirect cron
//define('DISALLOW_FILE_EDIT', true); //will disable WP editor
//define('DISALLOW_FILE_MODS', true); //disables add/delete theme & plugins
define('WP_CASHE', true); //wp default cashe.
//define('WP_POST_REVISIONS', 4); //limits revisions false to turn off
//define('AUTOSAVE_INTERVAL', 240); //minutes
//define( 'WP_SITEURL', 'https://jmgmarketinggroup.com' ); //hard code into gen settings
//define( 'WP_HOME', 'https://jmgmarketinggroup.com' );
@bramchi
bramchi / searchform.php
Last active November 1, 2022 12:07
Roots.io searchform.php template hack to get search widget working in Polylang, only searching within the active language. 'soil-nice-search' disabled btw.
<?php
/*
*
* Roots.io searchform.php template hack to fix Polylang search
*
* Note: Polylang setting 'Hide URL language info for default language' should be enabled for this to work.
* Soil-nice-search disabled in Roots.
*
*/
@wpmark
wpmark / gist:9d5d2395cb01a2de0179
Created October 8, 2014 11:06
Check If WordPress Post is Older than X Days
<?php
/*******************************
* this will work in the loop
*******************************/
/* check if the posts publish date is older than 60 days */
if( strtotime( $post->post_date ) < strtotime('-60 days') ) {
/* post is older than 60 days - do something with it!! */
@bekarice
bekarice / edit-woocommerce-checkout-template.php
Last active March 27, 2023 23:12
Add content and notices to the WooCommerce checkout - sample code
/**
* Each of these samples can be used - note that you should pick one rather than add them all.
*
* How to use WC notices: https://github.com/woothemes/woocommerce/blob/master/includes/wc-notice-functions.php#L96
* Tutorial: http://www.skyverge.com/blog/edit-woocommerce-templates/
**/
/**
* Add a content block after all notices, such as the login and coupon notices.
*
@r-a-y
r-a-y / bp-disable-translation.php
Created February 15, 2015 18:40
Disable automatic translations by WordPress.org / GlotPress for BuddyPress.
<?php
/*
Plugin Name: BP Disable Auto Translation
Description: Disables automatic translations by WordPress.org / GlotPress for BuddyPress.
Author: r-a-y
License: GPLv2 or later
*/
/**
* Disables automatic translations for BuddyPress.
@iMazed
iMazed / contactform7-form.php
Created February 27, 2015 09:11
Great for when you want to use FontAwesome in a submit button in Contact Form 7
//add instead of [submit] in Contact Form 7
<button type="submit" class="btn btn-large btn-primary"><i class="fa fa-bed"></i></button>
<img class="ajax-loader" src="http://www.yoursite.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden; opacity: 1;">