Created
March 31, 2016 15:50
-
-
Save chancesmith/74e84bdf0062b3cb67f7f462a0b64fcb to your computer and use it in GitHub Desktop.
Wordpress Functions (background image, Appearance/Menus, dashboard link for tutorial videos, ifMobile function)
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 | |
// functions.php file | |
// anchor all forms on site on submission (Gravity Forms) | |
add_filter( 'gform_confirmation_anchor', '__return_true' ); | |
//if mobile function | |
function isMobile() { | |
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); | |
} | |
if ( function_exists( 'add_theme_support' ) ) { | |
add_theme_support( 'post-thumbnails' ); | |
set_post_thumbnail_size( 150, 150, true ); // default Post Thumbnail dimensions (cropped) | |
// additional image sizes | |
add_image_size( 'news-index-thumbnail', 345, 400 ); //345 pixels wide | |
} | |
// add Menu | |
function mytheme_register_nav_menus() { | |
register_nav_menus( | |
array( | |
'primary_navigation' => 'Primary Navigation', | |
'footer_navigation' => 'Footer Navigation' | |
) | |
); | |
} | |
add_action( 'after_setup_theme', 'mytheme_register_nav_menus' ); | |
// background and header image | |
function mytheme_setup() { | |
add_custom_background(); | |
add_custom_image_header(); | |
} | |
add_action( 'after_setup_theme', 'mytheme_setup' ); | |
// DASHBOARD | |
/** | |
* Add a widget to the dashboard. | |
* | |
* This function is hooked into the 'wp_dashboard_setup' action below. | |
*/ | |
function example_add_dashboard_widgets() { | |
wp_add_dashboard_widget( | |
'tutorial_dashboard_widget', // Widget slug. | |
'Tutorial Videos', // Title. | |
'tutorial_dashboard_widget_function' // Display function. | |
); | |
} | |
add_action( 'wp_dashboard_setup', 'example_add_dashboard_widgets' ); | |
/** | |
* Create the function to output the contents of our Dashboard Widget. | |
*/ | |
function tutorial_dashboard_widget_function() { | |
// Display whatever it is you want to show. | |
echo "<h1>Hello, CLIENT NAME!</h1><br><br>"; | |
echo '<p>The tutorial videos can be seen <a href="/tuts/" target="_blank"><strong>here</strong></a>.</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment