Skip to content

Instantly share code, notes, and snippets.

View rovente's full-sized avatar

Rovente Web rovente

View GitHub Profile
@fburatti
fburatti / include-js.php
Created January 28, 2019 21:34
Open street map with ACF
function properties_map_script() {
wp_register_style(
'leaflet',
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css",
array(),
null
);
wp_register_script(
@fburatti
fburatti / open-street-map-script.js
Last active March 28, 2024 13:48
Open street map with Leaflet.js
// leaflet.js required
// the properties array can contain multiple pointers (markers) and is included with wordpress wp_localize_script
//var properties = [{"title":"Some title","lat":"42.75410269263614","lng":"12.758049219846725","thumb":"http:\/\/www.mysite.ext\/wp-content\/uploads\/2016\/05\/image.jpg","url":"http:\/\/www.www.mysite.ext\/"}];
var map;
function render_map( $el ) {
var $markers = properties;
@JacobDB
JacobDB / install-acf.sh
Last active June 22, 2024 18:59
Download and install ACF Pro via a bash script – to be used with WP CLI. Set an environemnt variable ACF_KEY first!
#!/bin/sh
# Adapted from https://support.advancedcustomfields.com/forums/topic/download-acf-with-wp-cli-on-clean-install/#post-26191
# get plugin path
acf_zip_file="$(wp plugin path)/advanced-custom-fields-pro.zip"
# get acf zip file
wget -O ${acf_zip_file} "http://connect.advancedcustomfields.com/index.php?p=pro&a=download&k=$ACF_KEY"
@RadGH
RadGH / custom-page-template-in-plugin.php
Last active August 26, 2022 21:00
Add custom page template to WordPress through a plugin
<?php
/*
This code will let you have a page template in your plugin, and show that template in the "Page Templates" dropdown.
It can also work for other post type templates, just change the filter "theme_page_templates" as needed.
WP 4.7 only.
Setup:
1. Replace "cppt" with your own plugin prefix.
2. Replace custom_plugin_page_template.php with whatever made-up template name you want.
3. Replace templates/custom-template.php with the real template (and directory) you want to load.
@gummiforweb
gummiforweb / functions.php
Last active February 21, 2019 09:49
ACF Component Field - Save component in sub folders
<?php
// NOTE: You'd have to create /acf-json/components/ foler in the theme manually first,
// just like how you'd manutally create the acf-json folder
/**
* In /includes/json.php:17, is where the acf_json write the local json file.
* So this hook has to be 9, just before acf write the file.
*/
# These instructions cover how to install Laravel Valet (including its requirements) on macOS and prep it for WordPress development.
@smutek
smutek / Bootstrap4Nav-Sage9.md
Last active July 30, 2022 06:50
Bootstrap 4 Walker for Sage 9

Credit

This is a frankensteind version of the current Soil nav walker, by the Roots team, and Michael Remoero's Sagextras walker. All credit goes to those good folks. :)

Use

  • Replace the contents of header.blade.php with the attached header.
  • Copy the walker.php file to the /app directory.
  • Add walker.php to the Sage required files array in resources/functions.php - eg. on a stock Sage install the entry would look like:
/**
@mshick
mshick / install.sh
Last active April 2, 2020 10:01
Installing Node.js with Homebrew and nvm
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install nvm
brew install nvm
# Export nvm environment
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
@yratof
yratof / functions.php
Created June 2, 2015 12:35
Getting the Video ID from ACF OEmbed, then using that ID to call in videos without bloat
<?php
/* Parse the video uri/url to determine the video type/source and the video id */
function parse_video_uri( $url ) {
// Parse the url
$parse = parse_url( $url );
// Set blank variables
$video_type = '';
$video_id = '';
@jessepearson
jessepearson / acf-update-via-json.php
Created March 24, 2015 12:58
Automatically update Advanced Custom Fields field groups via JSON
<?php
/**
* Function that will automatically update ACF field groups via JSON file update.
*
* @link http://www.advancedcustomfields.com/resources/synchronized-json/
*/
function jp_sync_acf_fields() {
// vars