Advertisement
HoogleyBoogley

function-admin.php

Aug 3rd, 2016
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.    
  5. @package animatedtheme
  6.    
  7.     ========================
  8.         ADMIN PAGE
  9.     ========================
  10. */
  11.  
  12. function animated_add_admin_page() {
  13.    
  14.     //Generate animated Admin Page
  15.     add_menu_page( 'animated Theme Options', 'Animated', 'manage_options', 'hoogleyboogley_animated', 'animated_theme_create_page', get_template_directory_uri() . '/img/hb-icon.png', 110 );
  16.    
  17.     //Generate animated Admin Sub Pages
  18.     add_submenu_page( 'hoogleyboogley_animated', 'Animated Theme Options', 'General', 'manage_options', 'hoogleyboogley_animated', 'animated_theme_create_page' );
  19.     add_submenu_page( 'hoogleyboogley_animated', 'Animated CSS Options', 'Custom CSS', 'manage_options', 'hoogleyboogley_animated_css', 'animated_theme_settings_page');
  20.    
  21.    
  22.    
  23. }
  24. add_action( 'admin_menu', 'animated_add_admin_page' );
  25.  
  26. //Activate custom settings
  27.     add_action( 'admin_init', 'animated_custom_settings' );
  28.  
  29. function animated_custom_settings() {
  30.     register_setting( 'animated-settings-group', 'first_name' );
  31.     register_setting( 'animated-settings-group', 'last_name' );
  32.     register_setting( 'animated-settings-group', 'user_description' );
  33.     register_setting( 'animated-settings-group', 'twitter_handler', 'animated_sanitize_twitter_handler' );
  34.     register_setting( 'animated-settings-group', 'facebook_handler' );
  35.     register_setting( 'animated-settings-group', 'gplus_handler' );
  36.    
  37.     add_settings_section( 'animated-sidebar-options', 'Sidebar Option', 'animated_sidebar_options', 'hoogleyboogley_animated');
  38.    
  39.     add_settings_field( 'sidebar-name', 'Full Name', 'animated_sidebar_name', 'hoogleyboogley_animated', 'animated-sidebar-options');
  40.     add_settings_field( 'sidebar-description', 'Description', 'animated_sidebar_description', 'hoogleyboogley_animated', 'animated-sidebar-options');
  41.     add_settings_field( 'sidebar-twitter', 'Twitter handler', 'animated_sidebar_twitter', 'hoogleyboogley_animated', 'animated-sidebar-options');
  42.     add_settings_field( 'sidebar-facebook', 'Facebook handler', 'animated_sidebar_facebook', 'hoogleyboogley_animated', 'animated-sidebar-options');
  43.     add_settings_field( 'sidebar-gplus', 'Google+ handler', 'animated_sidebar_gplus', 'hoogleyboogley_animated', 'animated-sidebar-options');
  44. }
  45.  
  46. function animated_sidebar_options() {
  47.     echo 'Customize your Sidebar Information';
  48. }
  49.  
  50. function animated_sidebar_name() {
  51.     $firstName = esc_attr( get_option( 'first_name' ) );
  52.     $lastName = esc_attr( get_option( 'last_name' ) );
  53.     echo '<input type="text" name="first_name" value="'.$firstName.'" placeholder="First Name" /> <input type="text" name="last_name" value="'.$lastName.'" placeholder="Last Name" />';
  54. }
  55. function animated_sidebar_description() {
  56.     $description = esc_attr( get_option( 'user_description' ) );
  57.     echo '<input type="text" name="user_description" value="'.$description.'" placeholder="Description" /><p class="description">Write something about your business.</p>';
  58. }
  59. function animated_sidebar_twitter() {
  60.     $twitter = esc_attr( get_option( 'twitter_handler' ) );
  61.     echo '<input type="text" name="twitter_handler" value="'.$twitter.'" placeholder="Twitter" /><p class="description">Input your Twitter username without the @.</p>';
  62. }
  63. function animated_sidebar_facebook() {
  64.     $facebook = esc_attr( get_option( 'facebook_handler' ) );
  65.     echo '<input type="text" name="facebook_handler" value="'.$facebook.'" placeholder="Facebook" />';
  66. }
  67. function animated_sidebar_gplus() {
  68.     $gplus = esc_attr( get_option( 'gplus_handler' ) );
  69.     echo '<input type="text" name="gplus_handler" value="'.$gplus.'" placeholder="Google+" />';
  70. }
  71.  
  72. //Sanitization settings
  73. function animated_sanitize_twitter_handler( $input ){
  74.     $output = sanitize_text_field( $input );
  75.     $output = str_replace('@', '', $output);
  76.     return $output;
  77. }
  78.  
  79. function animated_theme_create_page() {
  80.     require_once( get_template_directory() . '/inc/templates/animated-admin.php' );
  81. }
  82.  
  83. function animated_theme_settings_page() {
  84.    
  85.     echo '<h1>Animated Custom CSS</h1>';
  86.    
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement