View load-images-from-production.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Load Images From Production (for staging/dev) | |
* Description: Hooks into WP's media URL generation and replaces the domain with the production domain. | |
* Author: Phil Kurth | |
* Author URI: https://hookturn.io | |
*/ | |
// If this file is called directly, abort. | |
defined( 'WPINC' ) or die(); |
View replace-images-with-kittens.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_get_attachment_image_src', function ( $image ) { | |
$image[0] = "https://placekitten.com/$image[1]/$image[2]"; | |
return $image; | |
}, 10 ); |
View LocalValetDriver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class LocalValetDriver | |
* | |
* This class demonstrates how we might go about proxying any missing local images to a remote host. i.e; the production | |
* site. This has been created with WordPress in mind but could be adjusted to work with any other system. | |
*/ | |
class LocalValetDriver extends WordPressValetDriver { |
View register-custom-admin-columns.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_type = 'my_post_type'; | |
// Register the columns. | |
add_filter( "manage_{$post_type}_posts_columns", function ( $defaults ) { | |
$defaults['custom-one'] = 'Custom One'; | |
$defaults['custom-two'] = 'Custom Two'; |
View how-to-update-acf-google-map-field.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The field accepts a value with this structure | |
$value = [ | |
'address' => '123 Example St, Townsville XYZ 1234, Country', | |
'lat' => - 38.1486228, | |
'lng' => 144.360414, | |
'zoom' => 14, | |
'place_id' => 'Ei0xMjMgTW9vcmFib29sIFN0LCBHZWVsb25nIFZJQyAzMjIwLCBBdXN0cmFsaWEiMBIuChQKEgmX0JaIHBTUahFyH_LC9sYD8hB7KhQKEglDz-DYDxTUahECZY8QisCjzg', | |
'street_number' => 123, |
View register-acf-options-page.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// register a top-level options page | |
if ( function_exists( 'acf_add_options_page' ) ) { | |
acf_add_options_page( [ | |
'page_title' => 'My Options Page', | |
'menu_title' => 'My Options Page', | |
'menu_slug' => 'my-options-page', | |
'capability' => 'edit_posts', | |
'parent_slug' => '', |
View load-flexi-field-layout-partials-in-templates.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In a post/page template, loop over the ACF flexible field layouts and load the partial | |
// responsible for rendering the layout. | |
while ( the_flexible_field('my_flexi_field') ) { | |
get_template_part( 'components/'. get_row_layout() ); | |
} |
View define-google-maps-api-key-for-acf.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define this in the site's wp-config.php file. | |
define('GOOGLE_API_KEY', 'your-google-api-key-here'); | |
// Add this to your functions.php file, or a config plugin/MU plugin. | |
add_filter( 'acf/fields/google_map/api', function ( $api ) { | |
$api['key'] = GOOGLE_API_KEY; | |
return $api; |
View disable-core-meta-metabox.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('acf/settings/remove_wp_meta_box', '__return_true'); |
NewerOlder