Skip to content

Instantly share code, notes, and snippets.

View mdunbavan's full-sized avatar

Mark Dunbavan mdunbavan

View GitHub Profile
<?php
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
global $woocommerce;
$cart_url = $woocommerce->cart->get_cart_url();
$cart_count = sprintf(_n('%d', '%d', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);
$cart_total = $woocommerce->cart->get_cart_total();
if ($args->theme_location == 'primary') {
<form id="contact" name="contact" method="post">
<fieldset>
<label for="name" id="name">Name<span class="required">*</span></label>
<input type="text" name="name" id="name" size="30" value="" required/>
<label for="email" id="email">Email<span class="required">*</span></label>
<input type="text" name="email" id="email" size="30" value="" required/>
<label for="phone" id="phone">Phone</label>
<input type="text" name="phone" id="phone" size="30" value="" />
@mdunbavan
mdunbavan / fields.json
Last active August 29, 2015 14:23
Getting objects in json.
work_content: Array[4]
Object 0:
acf_fc_layout: "content_area"
text: "<p>test text</p>↵"
Object 1: Object
acf_fc_layout: "gallery"
images:
Object 2: Object
acf_fc_layout: "full_screen_video"
video_url: "&lt;iframe width=&quot;560&quot; type=&quot;text/html&quot; height=&quot;315&quot; id=&quot;windows&quot; src=&quot;//www.youtube.com/embed/1S7He-ShRLg?version=3&amp;enablejsapi=1&amp;html5=1&quot; frameborder=&quot;0&quot; webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;"
[
{
"ID": 4434,
"title": "new brand case",
"status": "publish",
"type": "case-studies",
"author": {},
"content": "<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>\n",
"parent": null,
"link": "http://wmh.dev/case-studies/new-brand-case/",
@mdunbavan
mdunbavan / Homestead.yaml
Created July 13, 2015 16:56
Homestead config file
folders:
- map: /Freelance/scoff-api/scoff-api
to: /Freelance/scoff-api/scoff-api
sites:
- map: scoff_api.local
to: /Freelance/scoff-api/scoff-api/public
databases:
- homestead
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Offer extends Model
{
/**
* The database table used by the model.
@mdunbavan
mdunbavan / Offer.php
Created July 24, 2015 11:59
Laravel updates
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Offer extends Model
{
/**
* The database table used by the model.
@mdunbavan
mdunbavan / OffersController.php
Created July 28, 2015 16:03
Image upload in controller
$path = str_replace("/home/vagrant/projects/scoff/scoff-api/public", "", public_path('images/offers'));
Image::make($file->getRealPath())
->resize(600, 600)
->save(public_path('images/offers').$filename);
$data['image'] = $path.$filename;
<?php
//include the class you created
use App\Navigation
public function index(Navigation, $navigation)
{
// location var to use in the blade template
$nav = Navigation;
//compact the nav for use in views which passes it through
return view('your.view', compact('nav'));
@mdunbavan
mdunbavan / OffersController.php
Last active August 29, 2015 14:27
Query chains
<?php
/**
* Show all offers queries by current date
*
* Get a JSON representation of all the offers.
* @Get("/")
* @Versions({"v1"})
*/
public function getOffers(Offer $offer)