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 | |
/* | |
Based on https://gist.github.com/daltonrooney/470619cca87a6c29cb84f92d856b9ec1 | |
and http://github.com/deliciousbrains/wp-migrate-db-pro-tweaks | |
*/ | |
class ACF_WP_Migrate_DB_Pro_Tweaks { | |
function __construct() { | |
add_filter( 'wpmdb_preserved_options', array( $this, 'preserved_options' ) ); | |
} |
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 | |
// Use an ACF image field | |
// Set the 'return value' option to "array" (this is the default) | |
// This example uses three image sizes, called medium, medium_large, thumbnail | |
$imageobject = get_field('image'); | |
if( !empty($imageobject) ): | |
echo '<img alt="' . $imageobject['title'] . '" src="' . $imageobject['sizes']['medium'] . '" srcset="' . $imageobject['sizes']['medium_large'] .' '. $imageobject['sizes']['medium_large-width'] .'w, '. $imageobject['sizes']['medium'] .' '. $imageobject['sizes']['medium-width'] .'w, '. $imageobject['sizes']['thumbnail'] .' '. $imageobject['sizes']['thumbnail-width'] .'w">'; | |
endif; | |
?> |
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 | |
/** | |
* Preselect dropdown field based on URL parameter. | |
* | |
* @param array $field | |
* @param array $field_atts | |
* @param array $form_data | |
* @return array | |
*/ | |
function wpf_preselect_dropdown( $field, $field_atts, $form_data ) { |
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 | |
/* | |
Debug preview with custom fields | |
Taken from: http://support.advancedcustomfields.com/forums/topic/preview-solution/ | |
See also: http://support.advancedcustomfields.com/forums/topic/2nd-every-other-post-preview-throws-notice/ | |
*/ | |
add_filter('_wp_post_revision_fields', 'add_field_debug_preview'); | |
function add_field_debug_preview($fields){ | |
$fields["debug_preview"] = "debug_preview"; | |
return $fields; |
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 | |
$file = '/path/to/file.png'; | |
$filename = basename($file); | |
$upload_file = wp_upload_bits($filename, null, file_get_contents($file)); | |
if (!$upload_file['error']) { | |
$wp_filetype = wp_check_filetype($filename, null ); | |
$attachment = array( | |
'post_mime_type' => $wp_filetype['type'], | |
'post_parent' => $parent_post_id, |
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
vhost( ) { | |
if [[ -z $1 ]]; then | |
echo 'usage: vhost [hostname]' | |
return | |
fi | |
HOST=$1 | |
HOSTNAME="$HOST.dev" | |
ADDRESS="127.0.0.1" | |
SITEPATH="$HOME/Sites/$HOST" |
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 | |
// Your functions.php content | |
function has_children() { | |
global $post; | |
$pages = get_pages('child_of=' . $post->ID); | |
return count($pages); |