Guest User

Untitled

a guest
Jan 12th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.78 KB | None | 0 0
  1. /**
  2.  * Register Contact Details Settings Page
  3.  *
  4.  * @author: Archie Makuwa
  5.  */
  6.  
  7. add_action( 'admin_menu', 'contact_details_add_admin_menu' );
  8. add_action( 'admin_init', 'contact_details_settings_init' );
  9.  
  10.  
  11. function contact_details_add_admin_menu() {
  12.  
  13.     add_menu_page( 'Contact Details', 'Contact Details', 'manage_options', 'contact_details', 'contact_details_options_page', 'dashicons-phone', 28 );
  14.  
  15. }
  16.  
  17.  
  18. function contact_details_settings_init(  ) {
  19.  
  20.     register_setting( 'pluginPage', 'contact_details_settings' );
  21.  
  22.     add_settings_section(
  23.         'contact_details_pluginPage_section',
  24.         __( '', 'steps' ),
  25.         'contact_details_settings_section_callback',
  26.         'pluginPage'
  27.     );
  28.  
  29.     add_settings_field(
  30.         'contact_details_telephone',
  31.         __( 'Telephone Number', 'steps' ),
  32.         'contact_details_telephone_render',
  33.         'pluginPage',
  34.         'contact_details_pluginPage_section'
  35.     );
  36.  
  37.     add_settings_field(
  38.         'contact_details_fax',
  39.         __( 'Fax Number', 'steps' ),
  40.         'contact_details_fax_render',
  41.         'pluginPage',
  42.         'contact_details_pluginPage_section'
  43.     );
  44.  
  45.     add_settings_field(
  46.         'contact_details_email',
  47.         __( 'Email Address', 'steps' ),
  48.         'contact_details_email_render',
  49.         'pluginPage',
  50.         'contact_details_pluginPage_section'
  51.     );
  52.  
  53.     add_settings_field(
  54.         'contact_details_facebook_url',
  55.         __( 'Facebook URL', 'steps' ),
  56.         'contact_details_facebook_url_render',
  57.         'pluginPage',
  58.         'contact_details_pluginPage_section'
  59.     );
  60.  
  61.     add_settings_field(
  62.         'contact_details_twitter',
  63.         __( 'Twitter URL', 'steps' ),
  64.         'contact_details_twitter_render',
  65.         'pluginPage',
  66.         'contact_details_pluginPage_section'
  67.     );
  68.  
  69.     add_settings_field(
  70.         'contact_details_youtube',
  71.         __( 'YouTube URL', 'steps' ),
  72.         'contact_details_youtube_render',
  73.         'pluginPage',
  74.         'contact_details_pluginPage_section'
  75.     );
  76.  
  77.     add_settings_field(
  78.         'contact_details_vimeo',
  79.         __( 'Vimeo URL', 'steps' ),
  80.         'contact_details_vimeo_render',
  81.         'pluginPage',
  82.         'contact_details_pluginPage_section'
  83.     );
  84.  
  85.     add_settings_field(
  86.         'contact_details_textarea_field_5',
  87.         __( 'Physical Address', 'steps' ),
  88.         'contact_details_textarea_field_5_render',
  89.         'pluginPage',
  90.         'contact_details_pluginPage_section'
  91.     );
  92.  
  93.  
  94. }
  95.  
  96.  
  97. function contact_details_telephone_render(  ) {
  98.  
  99.     $options = get_option( 'contact_details_settings' );
  100.     ?>
  101.     <input type='text' name='contact_details_settings[contact_details_telephone]' value='<?php echo $options['contact_details_telephone']; ?>'>
  102.     <?php
  103.  
  104. }
  105.  
  106.  
  107. function contact_details_fax_render(  ) {
  108.  
  109.     $options = get_option( 'contact_details_settings' );
  110.     ?>
  111.     <input type='text' name='contact_details_settings[contact_details_fax]' value='<?php echo $options['contact_details_fax']; ?>'>
  112.     <?php
  113.  
  114. }
  115.  
  116.  
  117. function contact_details_email_render(  ) {
  118.  
  119.     $options = get_option( 'contact_details_settings' );
  120.     ?>
  121.     <input type='text' name='contact_details_settings[contact_details_email]' value='<?php echo $options['contact_details_email']; ?>'>
  122.     <?php
  123.  
  124. }
  125.  
  126.  
  127. function contact_details_facebook_url_render(  ) {
  128.  
  129.     $options = get_option( 'contact_details_settings' );
  130.     ?>
  131.     <input type='text' name='contact_details_settings[contact_details_facebook_url]' value='<?php echo $options['contact_details_facebook_url']; ?>'>
  132.     <?php
  133.  
  134. }
  135.  
  136.  
  137. function contact_details_twitter_render(  ) {
  138.  
  139.     $options = get_option( 'contact_details_settings' );
  140.     ?>
  141.     <input type='text' name='contact_details_settings[contact_details_twitter]' value='<?php echo $options['contact_details_twitter']; ?>'>
  142.     <?php
  143.  
  144. }
  145.  
  146.  
  147. function contact_details_youtube_render(  ) {
  148.  
  149.     $options = get_option( 'contact_details_settings' );
  150.     ?>
  151.     <input type='text' name='contact_details_settings[contact_details_youtube]' value='<?php echo $options['contact_details_youtube']; ?>'>
  152.     <?php
  153.  
  154. }
  155.  
  156.  
  157. function contact_details_vimeo_render(  ) {
  158.  
  159.     $options = get_option( 'contact_details_settings' );
  160.     //var_dump($options);
  161.     ?>
  162.     <input type='text' name='contact_details_settings[contact_details_vimeo]' value='<?php echo $options['contact_details_vimeo']; ?>'>
  163.     <?php
  164.  
  165. }
  166.  
  167.  
  168. function contact_details_textarea_field_5_render(  ) {
  169.  
  170.     $options = get_option( 'contact_details_settings' );
  171.     ?>
  172.     <textarea cols='40' rows='5' name='contact_details_settings[contact_details_textarea_field_5]'><?php echo $options['contact_details_textarea_field_5']; ?>
  173.     </textarea>
  174.     <?php
  175.  
  176. }
  177.  
  178.  
  179. function contact_details_settings_section_callback(  ) {
  180.  
  181.     echo __( 'All contact details on the website are added here and reused all over the website.', 'steps' );
  182.  
  183. }
  184.  
  185.  
  186. function contact_details_options_page(  ) { ?>
  187.  
  188.     <form action='options.php' method='post'>
  189.  
  190.         <h2>Contact Details</h2>
  191.  
  192.         <?php
  193.         settings_fields( 'pluginPage' );
  194.         do_settings_sections( 'pluginPage' );
  195.         submit_button();
  196.         ?>
  197.  
  198.     </form>
  199.    
  200. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment