functions.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. //set builder mode to debug
  3. //add_action('avia_builder_mode', "builder_set_debug");
  4. //function builder_set_debug()
  5. //{
  6. // return "debug";
  7. //}
  8. add_action('after_setup_theme', 'remove_portfolio');
  9. function remove_portfolio() {
  10. remove_action('init', 'portfolio_register');
  11. }
  12. /******************* START NOTIFICATIONS *********************/
  13. add_action( 'admin_menu', 'srh_notice_add_admin_menu' );
  14. function srh_notice_add_admin_menu() {
  15. add_options_page( 'SRH Notifications', 'SRH Notifications', 'manage_options', 'srh_notice', 'srh_notice_options_page' );
  16. }
  17. add_action( 'admin_init', 'srh_notice_settings_init' );
  18. function srh_notice_settings_init() {
  19. register_setting('srh_notices', 'srh_notice_settings');
  20. register_setting('srh_notices', 'srh_notice_message');
  21. register_setting('srh_notices', 'srh_notice_message_body');
  22. add_settings_section('srh_notice_active_section', 'Notifications', 'srh_notice_settings_section_callback', 'srh_notices');
  23. add_settings_field('srh_notice_select_field_0', 'Notifications Active', 'srh_notice_select_field_0_render', 'srh_notices', 'srh_notice_active_section' );
  24. add_settings_field('srh_notice_message', 'Notification Title', 'srh_notice_message_render', 'srh_notices', 'srh_notice_active_section');
  25. add_settings_field('srh_notice_message_body', 'Notification Message', 'srh_notice_message_body_render', 'srh_notices', 'srh_notice_active_section');
  26. }
  27. function srh_notice_settings_section_callback( ) {
  28. echo __( 'This form sets a Notification Message for All Pages', 'wordpress' );
  29. }
  30. function srh_notice_select_field_0_render() {
  31. $options = get_option( 'srh_notice_settings' ); ?>
  32. <select name='srh_notice_settings[srh_notice_select_field_0]'>
  33. <option value='1' <?php selected( $options['srh_notice_select_field_0'], 1 ); ?>>Yes</option>
  34. <option value='2' <?php selected( $options['srh_notice_select_field_0'], 2 ); ?>>No</option>
  35. </select>
  36. <?php }
  37. function srh_notice_message_render() {
  38. echo '<input name="srh_notice_message" id="srh_notice_message" type="text" size="70" value="' . get_option( 'srh_notice_message' ) . '" />';
  39. }
  40. function srh_notice_message_body_render() {
  41. echo '<textarea name="srh_notice_message_body" id="srh_notice_message_body" rows="5" cols="70" value="" >' . get_option( 'srh_notice_message_body' ) . '</textarea>';
  42. }
  43. function srh_notice_options_page() { ?>
  44. <div class="wrap">
  45. <h1>Self Regional - Sitewide Notifications</h1>
  46. <form action='options.php' method='post'>
  47. <?php
  48. settings_fields('srh_notices');
  49. do_settings_sections('srh_notices');
  50. submit_button();
  51. ?>
  52. </form>
  53. </div>
  54. <?php }
  55. function srh_notice_display_message() {
  56. echo '<div class="container" style="padding-top: 20px;"><div class="post-entry post-entry-type-page"><div class="entry-content-wrapper clearfix">';
  57. echo '<article class="iconbox iconbox_top main_color avia-builder-el-0 avia-builder-el-no-sibling "><div class="iconbox_content">';
  58. echo '<header class="entry-content-header"><div class="iconbox_icon heading-color " style="background-color: #ed9600;" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></div>';
  59. echo '<h3 class="iconbox_content_title " style="color: #ed9600;">';
  60. echo get_option('srh_notice_message');
  61. echo '</h3></header>';
  62. echo '<div class="iconbox_content_container ">';
  63. echo get_option('srh_notice_message_body');
  64. echo '</div>';
  65. echo '</div></article>';
  66. echo '</div></div></div>';
  67. }
  68. $srh_status = get_option('srh_notice_settings');
  69. if( $srh_status['srh_notice_select_field_0'] == '1' ) {
  70. add_action('ava_after_main_container', 'srh_notice_display_message');
  71. }
  72. /******************* END NOTIFICATIONS *********************/