Skip to content

Instantly share code, notes, and snippets.

View rfmeier's full-sized avatar
💭
Nada.

Ryan Meier rfmeier

💭
Nada.
View GitHub Profile
@rfmeier
rfmeier / functions.php
Created June 10, 2013 22:44
Change the image size on the attachment page in WordPress
<?php
//* Do NOT include the opening php tag
add_filter( 'prepend_attachment', 'custom_prepend_attachment' );
/**
* Callback for WordPress 'prepend_attachment' filter.
*
* Change the attachment page image size to 'large'
*
* @package WordPress
@rfmeier
rfmeier / phprc
Last active March 12, 2019 02:50
Enable opcache on DreamHost for php 5.5 and greater
[opcache]
; the path to the .so file
zend_extension=opcache.so
; Enabled. Set to 0 to disable
opcache.enable=1
; Max memory consumption. Default 32 megs
opcache.memory_consumption=32
@rfmeier
rfmeier / functions.php
Last active October 29, 2018 14:36
Add custom nav item to Genesis primary menu
<?php
//* do no include php tags
add_filter( 'wp_nav_menu_items', 'custom_nav_item', 10, 2 );
/**
* Callback for Genesis 'wp_nav_menu_items' filter.
*
* Add custom right nav item to Genesis primary menu.
*
* @package Genesis
@rfmeier
rfmeier / keybase.md
Created August 20, 2018 14:19
keybase.md

Keybase proof

I hereby claim:

  • I am rfmeier on github.
  • I am rfmeier_wpe (https://keybase.io/rfmeier_wpe) on keybase.
  • I have a public key ASCjN3SgSBVet3Pu16VseFbv2e8-rjZDA4NR-T-eG9iQvAo

To claim this, I am signing this object:

@rfmeier
rfmeier / Controller.php
Created June 7, 2018 01:17
Throw a validation exception from a controller.
<?php
/**
* Throw a ValidationException from within a Controller.
*/
use Illuminate\Validation\ValidationException;
throw ValidationException::withMessages([
'form_item_name' => ['Form item error message.'],
]);
@rfmeier
rfmeier / example.php
Last active December 19, 2017 05:02
Get the current User in Laravel
<?php
$is_authenticated = Auth::check();
$is_guest = Auth::guest();
// Using Auth facade
$user = Auth::user();
// Using auth() helper
$user = auth()->user();
@rfmeier
rfmeier / example.sh
Created November 7, 2017 17:46
Laravel artisan to create a ProductUpdateRequest.
$ php artisan make:request ProductUpdateRequest
@rfmeier
rfmeier / update-example.php
Created November 7, 2017 17:45
Simple controller model update in Laravel.
<?php
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Product $product
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Product $product)
@rfmeier
rfmeier / example.php
Created November 7, 2017 17:21
Get all orders for a product in WooCommerce.
<?php
/**
* Get all orders given a product.
*
* @param integer $product_id The product ID.
*
* @return array An array of WC_Order objects.
*/
function rfm_get_orders_by_product( $product_id ) {
@rfmeier
rfmeier / functions.php
Last active November 7, 2017 03:52
Display full content width for a single woocommerce product in Genesis
<?php
add_filter( 'genesis_site_layout', 'sample_genesis_site_layout' );
/**
* Callback for 'genesis_site_layout' filter.
*
* Force full width content on the single product page.
*
* @param $layout The layout slug.
* @return string The layout slug.