Skip to content

Instantly share code, notes, and snippets.

@Sean-Spallen
Sean-Spallen / dynamic-option-fields.js
Last active February 27, 2017 12:10
Example code for passing an ACF options page variable to JavaScript through the wp_admin_footer
// holder is the ID of the invisible Div that holds the option field.
// Function to find the option_test text field and populate it with data that is echoed in the option_holder div
jQuery(document).ready(function () {
var option_populate_FIELD_NAME = document.getElementById('acf-field_58b2d845dda65');
var option_holder_FIELD_NAME = jQuery('#option_holder_FIELD_NAME');
var option_test_FIELD_NAME = option_holder_FIELD_NAME["0"].innerText;
// Checks that the field is empty before populating
@Sean-Spallen
Sean-Spallen / Dynamic Select Fields
Last active May 3, 2017 18:36
Snippet allows the user to store ACF data which is on the page and load it as select options.
// Loads the venues into the Formidable Venue Select Field on page load
jQuery('document').ready(function(){
for(var i = 0; i < venueHolder.children.length; i++) {
// Adds the child divs of '.venue-holder' to an array
var arr = venueHolder.children;
// Selects the current individual item of this array
@Sean-Spallen
Sean-Spallen / migrate up function.
Created May 3, 2019 18:44
Laravel - Migrate Up sample
public function up()
{
Schema::create('groceries', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('type');
$table->integer('price');
$table->timestamps();
});
}
@Sean-Spallen
Sean-Spallen / Laravel - Store Function
Last active May 10, 2019 08:45
Laravel - Store Function
<?php
namespace App\Http\Controllers;
use App\Flight;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class FlightController extends Controller
{
@Sean-Spallen
Sean-Spallen / Laravel - Update Function
Last active May 10, 2019 08:45
Laravel - Update Function
$flight = App\Flight::find(1);
$flight->name = 'New Flight Name';
$flight->save();
@Sean-Spallen
Sean-Spallen / Laravel - Delete Function
Last active May 10, 2019 08:45
Laravel - Delete Function
$flight = App\Flight::find(1);
$flight->delete();
@Sean-Spallen
Sean-Spallen / Laravel - Migrate Up Function
Created May 10, 2019 08:43
Laravel - Migrate Up Function
public function up()
{
Schema::create('groceries', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('type');
$table->integer('price');
$table->timestamps();
});
}
@Sean-Spallen
Sean-Spallen / Laravel - AJAX Request
Created May 10, 2019 08:43
Laravel - AJAX Request
<script src="http://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
</script>
<script>
jQuery(document).ready(function(){
jQuery('#ajaxSubmit').click(function(e){
e.preventDefault();
$.ajaxSetup({
headers: {
@Sean-Spallen
Sean-Spallen / Laravel - AJAX Store Function
Created May 10, 2019 08:45
Laravel - AJAX Store Function
use App\Grocery;
public function store(Request $request)
{
$grocery = new Grocery();
$grocery->name = $request->name;
$grocery->type = $request->type;
$grocery->price = $request->price;
$grocery->save();
@Sean-Spallen
Sean-Spallen / laravel - Controller Template
Last active May 13, 2019 14:52
laravel - Controller Template
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ShareController extends Controller
{
/**
* Display a listing of the resource.