Skip to content

Instantly share code, notes, and snippets.

@tjhole
tjhole / WORDPRESS: Base64 Image to Wordpress Uploads directory
Created May 9, 2014 12:35
WORDPRESS: Base64 Image to Wordpress Uploads directory
function tattoo_submit() {
if (isset($_POST["addtattoo"])) {
$title = "Tattoo : ". $_POST["tatooInput"];
$my_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_author' => 1,
@tjhole
tjhole / ACF: Random image from Gallery
Last active January 26, 2020 02:21
ACF: Random image from Gallery
@tjhole
tjhole / WORDPRESS: Function - Idiot Proof Admin
Last active November 6, 2019 19:49
WORDPRESS: Function - Idiot Proof Admin
add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function adjust_the_wp_menu() {
remove_submenu_page( 'themes.php', 'theme-editor.php');
remove_submenu_page( 'themes.php', 'themes.php');
remove_submenu_page( 'themes.php', 'customize.php');
remove_submenu_page( 'themes.php', 'widgets.php');
remove_submenu_page( 'jetpack', 'jetpack');
remove_submenu_page( 'index.php', 'update-core.php');
}
add_action( 'login_head', 'namespace_login_style' );
@tjhole
tjhole / WORDPRESS: Redirect based on location using Cloudflare
Created April 4, 2014 10:27
WORDPRESS: Redirect based on location using Cloudflare
<?php
// Geo Redirect using Cloudflare
$activepage = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
$page_from = "www.domain.tld/";
$page_to = "www.newdomain.tld/";
?>
<!-- Country Code : <?php echo $country_code; ?> -->
<!-- Active URL : <?php echo $activepage; ?> -->
@tjhole
tjhole / ACF: Gallery
Created July 14, 2014 13:21
ACF: Gallery
@tjhole
tjhole / ACF: Image (Interchange Foundation 5)
Created April 2, 2014 14:56
ACF: Image (Interchange Foundation 5)
<?php
$attachment_id = get_field('field_name');
$image_thumbnail = wp_get_attachment_image_src( $attachment_id, "thumbnail" );
$image_medium = wp_get_attachment_image_src( $attachment_id, "medium" );
$image_large = wp_get_attachment_image_src( $attachment_id, "large" );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<img data-interchange="[<?php echo $image_thumbnail[0]; ?>, (default)], [<?php echo $image_medium[0]; ?>, (large)]"/>
@tjhole
tjhole / ACF: Location Get Lat Long
Created December 12, 2013 18:40
ACF: Location Get Lat Long
<?php
$location = get_field('location');
if( !empty($location) ):
?>
<?php echo $location['lat']; ?>
<?php echo $location['lng']; ?>">
<?php endif; ?>
@tjhole
tjhole / WORDPRESS: Get And Cache Vimeo Thumbnails
Created December 5, 2013 13:07
WORDPRESS: Get And Cache Vimeo Thumbnails
// Get And Cache Vimeo Thumbnails
function get_vimeo_thumb($id, $size = 'thumbnail_small')
{
if(get_transient('vimeo_' . $size . '_' . $id))
{
$thumb_image = get_transient('vimeo_' . $size . '_' . $id);
}
else
{
$json = json_decode( file_get_contents( "http://vimeo.com/api/v2/video/" . $id . ".json" ) );
@tjhole
tjhole / functions.php
Created October 14, 2016 13:33 — forked from drewbaker/functions.php
Blurring image using WordPress
/**
* Several functions relatting to blurring images on uploaded.
* @see https://codeable.io/community/how-to-watermark-wordpress-images-with-imagemagick/
*/
add_image_size( 'background-image-blurred', 1920, 1080, true );
function generate_blurred_image( $meta ) {
$time = substr( $meta['file'], 0, 7); // Extract the date in form "2015/04"
$upload_dir = wp_upload_dir( $time ); // Get the "proper" upload dir
@tjhole
tjhole / WORDPRESS: Hide ACF by CSS in Admin Area
Created November 29, 2013 15:32
WORDPRESS: Hide ACF via CSS in admin area
// Editing the WordPress Dashboard Header
function wp_admin_dashboard_header_colour() {
echo '<style type="text/css">
#toplevel_page_edit-post_type-acf { display:none; }
</style>';
}
add_action('admin_head', 'wp_admin_dashboard_header_colour');