Created
January 6, 2016 19:36
-
-
Save amberhinds/d9c9ee6eb38446eb9cf9 to your computer and use it in GitHub Desktop.
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 | |
//* Archive Image Settings: this file registers the archive image settings to Theme Settings. | |
//* Register Defaults | |
function acd_archive_img_defaults( $defaults ) { | |
$defaults['locations_image_url'] = ''; | |
$defaults['doctors_image_url'] = ''; | |
$defaults['services_image_url'] = ''; | |
return $defaults; | |
} | |
add_filter( 'genesis_theme_settings_defaults', 'acd_archive_img_defaults' ); | |
//* Sanitization (for security) | |
function acd_register_img_sanitization_filters() { | |
genesis_add_option_filter( 'no_html', GENESIS_SETTINGS_FIELD, | |
array( | |
'locations_image_url', | |
'doctors_image_url', | |
'services_image_url', | |
) ); | |
} | |
add_action( 'genesis_settings_sanitizer_init', 'acd_register_img_sanitization_filters' ); | |
//* Register Metabox | |
function acd_register_cpt_img_settings_box( $_genesis_theme_settings_pagehook ) { | |
add_meta_box('acd-cpt-img-settings', 'Set Image for Custom Post Type Archive & Single Pages', 'acd_cpt_img_settings_box', $_genesis_theme_settings_pagehook, 'main', 'high'); | |
} | |
add_action('genesis_theme_settings_metaboxes', 'acd_register_cpt_img_settings_box'); | |
//* Create Metabox | |
function acd_cpt_img_settings_box() { | |
?> | |
<p>Paste in the image URL after uploading to media library. <a href="http://www.wpbeginner.com/beginners-guide/how-to-get-the-url-of-images-you-upload-in-wordpress/" target="_blank">How to find the image url.</a></p> | |
<p>Locations Featured Image:<br /> | |
<input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[locations_image_url]" value="<?php echo esc_attr( genesis_get_option('locations_image_url') ); ?>" size="50" /> </p> | |
<p>Doctors Featured Image:<br /> | |
<input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[doctors_image_url]" value="<?php echo esc_attr( genesis_get_option('doctors_image_url') ); ?>" size="50" /> </p> | |
<p>Services Featured Image:<br /> | |
<input type="text" name="<?php echo GENESIS_SETTINGS_FIELD; ?>[services_image_url]" value="<?php echo esc_attr( genesis_get_option('services_image_url') ); ?>" size="50" /> </p> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment