Skip to content

Instantly share code, notes, and snippets.

@noameppel
noameppel / Wordpress Multisite Update
Last active December 28, 2015 06:09
WordPress Update Options Across WordPress Multisite Example of how to update thumbnail_crop across a WordPress Multisite.
<?php
define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
require_once( ABSPATH . '/wp-includes/pluggable.php');
$setting = 'thumbnail_crop'; //the setting you want to update.
$newvalue = '1'; //the new value
echo "<h2>Member Sites</h2>";
$allsites = wp_get_sites('limit=0');
@noameppel
noameppel / gist:8557154
Last active January 4, 2016 02:48
WordPress 26879-3.patch
Index: wp-admin/setup-config.php
===================================================================
--- wp-admin/setup-config.php (revision 26873)
+++ wp-admin/setup-config.php (working copy)
@@ -116,7 +116,8 @@
setup_config_display_header();
?>
-<p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
+
@noameppel
noameppel / PHP Overview
Created January 27, 2014 21:30
Good overview of PHP
<?php // PHP code must be enclosed with <?php tags
// If your php file only contains PHP code, it is best practice
// to omit the php closing tag.
// Two forward slashes start a one-line comment.
# So will a hash (aka pound symbol) but // is more common
/*
@noameppel
noameppel / 26879-6.patch
Last active August 29, 2015 13:56
WordPress 26879-6.patch
Index: wp-admin/css/install.css
===================================================================
--- wp-admin/css/install.css (revision 27049)
+++ wp-admin/css/install.css (working copy)
@@ -7,8 +7,8 @@
background: #fff;
color: #555;
font-family: "Open Sans", sans-serif;
- margin: 140px auto 25px;
- padding: 20px 20px 10px 20px;
@noameppel
noameppel / dev-server-media-files.php
Created April 2, 2014 20:00
Any media file not on development server will be loaded from live server.
<?php add_action('init', 'my_replace_image_urls' );
function my_replace_image_urls() {
if ( defined('WP_SITEURL') && defined('LIVE_SITEURL') ) {
if ( WP_SITEURL != LIVE_SITEURL ){
add_filter('wp_get_attachment_url', 'my_wp_get_attachment_url', 10, 2 );
}
}
}
function my_wp_get_attachment_url( $url, $post_id) {
@noameppel
noameppel / cfs-edd-custom-discount.php
Created June 3, 2014 20:02
Allows Easy Digital Downloads discount codes to be passed via URL.
<?php
/**
Plugin Name: CFS EDD Custom Discount
Plugin URI: http://cleanforest.co
Description: Allows EDD discount codes to be passed via URL.
Author: Noam Eppel
Version: 0.99
Author URI: http://cleanforest.co
License: GNU General Public License (Version 2 - GPLv2)
*/
@noameppel
noameppel / wp_custom_registration_fields.php
Last active August 29, 2015 14:03
Add custom fields (First name, Last name) to the WordPress registration form.
<?php
/**
* Custom Login Fields
*/
// Add a new form elements
add_action('register_form','custom_register_form');
function custom_register_form (){
@noameppel
noameppel / Gruntfile.js
Created March 3, 2015 16:08
Sample Gruntfile.js
module.exports = function(grunt) {
// Load multiple grunt tasks using globbing patterns
// This module will read the dependencies/devDependencies/peerDependencies in
// the package.json and load grunt tasks that match the provided patterns.
// Load all grunt tasks:
require('load-grunt-tasks')(grunt);
var PathConfig = require('./grunt-settings.js');
@noameppel
noameppel / package.json
Created March 3, 2015 16:09
Sample package.json
{
"frontend": {
"name": "name",
"stylesheets": "scss",
"javascripts": "js"
},
"name": "grunt-with-node-sass",
"version": "0.9.5",
"devDependencies": {
"bower-move": "^1.0.1",
@noameppel
noameppel / display_user_application_form.php
Created August 20, 2015 03:50
Searches GravityForm Entries. Uses get_entries()
<?php
/**
* [display_user_application_form]
* Searches GravityForm Entries. Uses get_entries()
* Will display form results where do_action( 'form-display', $arg = '' ); is in the template.
* https://www.gravityhelp.com/documentation/article/api-functions/#get_entries
*/
function display_user_application_form() {
$search_criteria = array(
'status' => 'active',