Created
December 4, 2013 18:08
-
-
Save johnReeve/7792478 to your computer and use it in GitHub Desktop.
How I do my WordPRess site specific configuration 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 | |
/* setup custom general settings */ | |
function ts_theme_settings () { | |
register_setting( 'general', 'homepage_slider_wide' ); | |
add_settings_field( | |
'homepage_slider_wide', | |
'Homepage Slider (Wide)', | |
'homepage_slider_wide_callback', | |
'general' | |
); | |
register_setting( 'general', 'homepage_slider_narrow' ); | |
add_settings_field( | |
'homepage_slider_narrow', | |
'Homepage Slider (Narrow)', | |
'homepage_slider_narrow_callback', | |
'general' | |
); | |
register_setting( 'general', 'footer_disclaimer' ); | |
add_settings_field( | |
'footer_disclaimer', | |
'Footer Disclaimer', | |
'footer_disclaimer_callback', | |
'general' | |
); | |
register_setting( 'general', 'site_phone' ); | |
add_settings_field( | |
'site_phone', | |
'Contact Phone', | |
'site_phone_callback', | |
'general' | |
); | |
register_setting( 'general', 'social_fb' ); | |
add_settings_field( | |
'social_fb', | |
'Facebook Link', | |
'social_fb_callback', | |
'general' | |
); | |
register_setting( 'general', 'social_yt' ); | |
add_settings_field( | |
'social_yt', | |
'Youtube Link', | |
'social_yt_callback', | |
'general' | |
); | |
register_setting( 'general', 'social_tw' ); | |
add_settings_field( | |
'social_tw', | |
'Twitter Link', | |
'social_tw_callback', | |
'general' | |
); | |
register_setting( 'general', 'social_pn' ); | |
add_settings_field( | |
'social_pn', | |
'Pintrest Link', | |
'social_pn_callback', | |
'general' | |
); | |
register_setting( 'general', 'ga_analytics' ); | |
add_settings_field( | |
'ga_analytics', | |
'Google Analytics Code', | |
'ga_analytics_callback', | |
'general' | |
); | |
} | |
add_action( 'admin_init', 'ts_theme_settings' ); | |
function homepage_slider_wide_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="homepage_slider_wide" name="homepage_slider_wide" value="' . htmlspecialchars(get_option('homepage_slider_wide'), ENT_QUOTES, 'utf-8') . '"/>'; | |
echo "<br>NOTE: This is the whole short code for the full-width home page gallery, for example: [nivoslider id=\"1315\"]or [nivoslider slug=\"home_wide-dev\"]"; | |
} | |
function homepage_slider_narrow_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="homepage_slider_narrow" name="homepage_slider_narrow" value="' . htmlspecialchars(get_option('homepage_slider_narrow'), ENT_QUOTES, 'utf-8') . '"/>'; | |
echo "<br>NOTE: This is the whole short code for the tablet/mobile home page gallery, for example: [nivoslider id=\"1316\"]or [nivoslider slug=\"home_narrow-dev\"]"; | |
} | |
function footer_disclaimer_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="footer_disclaimer" name="footer_disclaimer" value="' . get_option('footer_disclaimer') . '"/>'; | |
//echo "<br>NOTE: Use the whole address, including http://-- like https://www.facebook.com/john.r.reeve"; | |
} | |
function site_phone_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="site_phone" name="site_phone" value="' . get_option('site_phone') . '"/>'; | |
echo "<br>NOTE: Whole phone number - 800-555-5555"; | |
} | |
function social_fb_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="social_fb" name="social_fb" value="' . get_option('social_fb') . '"/>'; | |
echo "<br>NOTE: Use the whole address, including http://-- like https://www.facebook.com/john.r.reeve"; | |
} | |
function social_yt_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="social_yt" name="social_yt" value="' . get_option('social_yt') . '"/>'; | |
echo "<br>NOTE: Use the whole address for external links including http://-- like http://www.youtube.com/user/ERB"; | |
} | |
function social_tw_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="social_tw" name="social_tw" value="' . get_option('social_tw') . '"/>'; | |
echo "<br>NOTE: Use the whole address, including http://-- like https://www.facebook.com/john.r.reeve"; | |
} | |
function social_pn_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="social_pn" name="social_pn" value="' . get_option('social_pn') . '"/>'; | |
echo "<br>NOTE: Use the whole address, including http://-- like http://www.pinterest.com/gibsonguitar/"; | |
} | |
function ga_analytics_callback ($args) { | |
echo '<input class="regular-text ltr" type="text" id="ga_analytics" name="ga_analytics" value="' . get_option('ga_analytics') . '"/>'; | |
echo "<br>NOTE: This should take the form UA-XXXXX-Y"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment