Advertisement
ovizii

global-header.php

Jun 17th, 2011
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 28.36 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Global Header - WPMU
  4. Plugin URI: http://wpmudev.org/project/global-header
  5. Description: Add a Global Header to your WPMU install
  6. Author: Hiranthi Molhoek-Herlaar (illutic WebDesign)
  7. Version: 1.7
  8. Author URI: http://www.illutic.nl
  9. */
  10.  
  11. /*
  12.     CHANGELOG
  13.    
  14.     v1.0 - 06/21/2009
  15.     First version of the plugin: add HTML/CSS for your global header, including the possibility of enabling/disabling the plugin from your backend (for every site and for mainblog only).
  16.    
  17.     v1.1 - 06/21/2009
  18.     Added the same abilities for a global footer (by request of Ovidiu).
  19.    
  20.     v1.2 - 06/21/2009
  21.     Added the possibility of adding PHP code to both header and footer.
  22.     Merged the globalheader_html/globalheader_html_footer and globalheader_css/globalheader_css_footer functions.
  23.     Added the functionality of adding blogIDs where you don't want the global header/footer enabled.
  24.    
  25.     v1.2.1 - 06/21/2009
  26.     Small bugfix (removed add_action for globalheader_html_footer and globalheader_css_footer).
  27.    
  28.     v1.3 - 06/21/2009
  29.     Added Supporter (WPMUDEV Premium plugin) support.
  30.    
  31.     v1.3.1 - 06/30/2009
  32.     CSS bugfix for the header-part.
  33.    
  34.     v1.4 - 06/30/2009
  35.     A few bugfixes.
  36.     Changed looks in admin-page.
  37.     Added the functionality of enabling the header/footer for supporters only (if Premium Supporters plugin is available).
  38.    
  39.     v1.5 - 06/30/2009
  40.     Added labels to the headers all form-fields
  41.     Added a 'revert to default settings' option
  42.    
  43.     v1.6 - 07/22/2009
  44.     Added stripslashes() to output on blog
  45.    
  46.     v1.7 - 07/23/2009
  47.     Added stripslashes() to saving to DB (for those that are still having problems with slashes saved into their DB)
  48.    
  49. */
  50.  
  51. /**************************************************************
  52.     Hooks
  53. **************************************************************/
  54. add_action('admin_menu',    'globalheader_admin_menu');
  55. add_action('wp_footer',     'globalheader_html');
  56. add_action('wp_head',       'globalheader_css');
  57.  
  58.  
  59. /**************************************************************
  60.     Functions
  61. **************************************************************/
  62. load_muplugin_textdomain('globalheader');
  63.  
  64. /*
  65. add subpage to site admin menu
  66. */
  67. function globalheader_admin_menu()
  68. {
  69.     global $wpdb, $wp_roles, $current_user;
  70.     add_submenu_page('ms-admin.php', __('Global Header', 'globalheader'), __('Global Header', 'globalheader'), 10, 'global-header', 'globalheader_output');
  71. } // adp_admin_menu
  72.  
  73. /*
  74. output for admin page
  75. */
  76. function globalheader_output()
  77. {
  78.     global $wpdb;
  79.    
  80.     if( !current_user_can('edit_users') )
  81.     {
  82.         echo "<p>" . __('Nice Try...', 'globalheader') . "</p>";  // If accessed properly, this message doesn't appear.
  83.         return;
  84.     }
  85.     if (isset($_GET['updated'])) {
  86.         ?><div id="message" class="updated fade"><p><?php _e('' . urldecode($_GET['updatedmsg']) . '') ?></p></div><?php
  87.     }
  88.    
  89.     echo '<div class="wrap">';
  90.     switch ( strtolower( $_GET['action'] ) )
  91.     {
  92.        
  93.         /* DEFAULT CASE */
  94.         case '':
  95.         default:
  96.         ?>
  97.         <h2><?php _e('Settings for the Global Header plugin', 'globalheader') ?></h2>
  98.         <p><?php _e('This plugin was initially meant to add a global header to your WPMU website. Since a global footer was a requested feature, this was added too. But don\'t let the Global header/footer parts on this page keep you down. Because you could easily use it for other purposes (double headers, double footers, etc.).', 'globalheader') ?></p>
  99.        
  100.         <form method="post" action="ms-admin.php?page=global-header&action=process">
  101.             <table class="widefat">
  102.             <thead>
  103.             <tr>
  104.                 <th colspan="2"><?php _e('Global header settings', 'globalheader') ?></th>
  105.             </tr>
  106.             </thead>
  107.             <tbody>
  108.             <tr valign="top">
  109.                 <th scope="row"><label for="globalheader_enabled"><?php _e('Enable the header', 'globalheader') ?></label></th>
  110.                 <td><input type="checkbox" name="globalheader_enabled" id="globalheader_enabled" value="on"<?php echo ( get_site_option('globalheader_enabled') == 'on' ) ? ' checked="checked"' : ''; ?> />
  111.                     <br /><small><?php _e('Check to enable the global header.', 'globalheader') ?></small></td>
  112.             </tr>
  113.             <tr valign="top">
  114.                 <th scope="row"><label for="globalheader_mainsite_enabled"><?php _e('Enable the header on the main site', 'globalheader') ?></label></th>
  115.                 <td><input type="checkbox" name="globalheader_mainsite_enabled" id="globalheader_mainsite_enabled" value="on"<?php echo ( get_site_option('globalheader_mainsite_enabled') == 'on' ) ? ' checked="checked"' : ''; ?> />
  116.                     <br /><small><?php _e('Check to enable the global header on the mainblog too (disabled by default).', 'globalheader') ?></small></td>
  117.             </tr>
  118.             <?php
  119.             if ( function_exists( 'supporter_check' ) ) // supporter_check exists
  120.             {
  121.             ?>
  122.             <tr valign="top">
  123.                 <th scope="row"><label for="globalheader_supporters_enabled"><?php _e('Enable header for Supporters', 'globalheader') ?></label></th>
  124.                 <td><input type="checkbox" name="globalheader_supporters_enabled" id="globalheader_supporters_enabled" value="on"<?php echo ( get_site_option('globalheader_supporters_enabled') != 'off' ) ? ' checked="checked"' : ''; ?> />
  125.                     <br /><small><?php _e('Check to enable the global header on Supporter blogs (enabled by default).', 'globalheader') ?></small></td>
  126.             </tr>
  127.             <tr valign="top">
  128.                 <th scope="row"><label for="globalheader_supportersonly_enabled"><?php _e('Make this header SUPPORTERS ONLY', 'globalheader') ?></label></th>
  129.                 <td><input type="checkbox" name="globalheader_supportersonly_enabled" id="globalheader_supportersonly_enabled" value="on"<?php echo ( get_site_option('globalheader_supportersonly_enabled') == 'on' ) ? ' checked="checked"' : ''; ?> />
  130.                     <br /><small><?php _e('Check to enable the global header on Supporter blogs only (disabled by default, only works if the header is enabled for supporters).', 'globalheader') ?></small></td>
  131.             </tr>
  132.             <?php
  133.             } // end if ptb
  134.             ?>
  135.             <tr valign="top">
  136.                 <th scope="row"><label for="globalheader_php_enabled"><?php _e('Enable executing PHP in the header', 'globalheader') ?></label></th>
  137.                 <td><input type="checkbox" name="globalheader_php_enabled" id="globalheader_php_enabled" value="on"<?php echo ( get_site_option('globalheader_php_enabled') == 'on' ) ? ' checked="checked"' : ''; ?> />
  138.                     <br /><small><?php _e('Check to enable the possibility of using PHP in your header HTML (disabled by default).', 'globalheader') ?></small></td>
  139.             </tr>
  140.             <tr valign="top">
  141.                 <th scope="row"><label for="globalheader_html"><?php _e('HTML to add', 'globalheader') ?></label></th>
  142.                 <td><textarea name="globalheader_html" id="globalheader_html" style="width:100%" rows="8"><?php if ( get_site_option('globalheader_html') ) { echo stripslashes( get_site_option('globalheader_html') ); } else { ?><div id="global-header"><a href="%SITEURL%">%SITETITLE%</a></div><?php } ?></textarea>
  143.                     <br /><small><?php _e('The HTML that will be added to every blog (will be placed in the footer). %SITEURL% will be replaced with the URL of the mainblog, %SITETITLE% by its title.', 'globalheader') ?></small></td>
  144.             </tr>
  145.             <tr valign="top">
  146.                 <th scope="row"><label for="globalheader_css"><?php _e('CSS', 'globalheader') ?></label></th>
  147.                 <td><textarea name="globalheader_css" id="globalheader_css" style="width:100%" rows="8"><?php if ( get_site_option('globalheader_css') ) { echo stripslashes( get_site_option('globalheader_css') ); } else { ?>body { margin:30px 0 0; position:relative; }
  148. #global-header { position:absolute; top:-30px; left:0; background-color:#000; width:100%; height:30px; display:block; }
  149. #global-header a { color:#fff; padding:5px; }<?php } ?></textarea>
  150.                     <br /><small><?php _e('Use CSS to place the HTML to the top of the page.', 'globalheader') ?></small></td>
  151.             </tr>
  152.             <tr valign="top">
  153.                 <th scope="row"><label for="globalheader_excludeblogs"><?php _e('Exclude blogs', 'globalheader') ?></label></th>
  154.                 <td><input type="text" name="globalheader_excludeblogs" id="globalheader_excludeblogs" style="width:100%" value="<?php if ( get_site_option('globalheader_excludeblogs') ) { echo stripslashes( get_site_option('globalheader_excludeblogs') ); } ?>" />
  155.                     <br /><small><?php _e('Blogs that you don\'t want to have the global header on. Seperate blogIDs with a comma (ie: 2,3).', 'globalheader') ?></small></td>
  156.             </tr>
  157.             </tbody>
  158.             </table>
  159.            
  160.             <p>&nbsp;</p>
  161.             <?php /***************************************************************************************************************/ ?>
  162.            
  163.             <table class="widefat">
  164.             <thead>
  165.             <tr>
  166.                 <th colspan="2"><?php _e('Global footer settings','globalheader'); ?></th>
  167.             </tr>
  168.             </thead>
  169.             <tbody>
  170.             <tr valign="top">
  171.                 <th scope="row"><label for="globalheader_enabled_footer"><?php _e('Enable the footer', 'globalheader') ?></label></th>
  172.                 <td><input type="checkbox" name="globalheader_enabled_footer" id="globalheader_enabled_footer" value="on"<?php echo ( get_site_option('globalheader_enabled_footer') == 'on' ) ? ' checked="checked"' : ''; ?> />
  173.                     <br /><small><?php _e('Check to enable the global footer.', 'globalheader') ?></small></td>
  174.             </tr>
  175.             <tr valign="top">
  176.                 <th scope="row"><label for="globalheader_mainsite_enabled_footer"><?php _e('Enable the footer on the main site', 'globalheader') ?></label></th>
  177.                 <td><input type="checkbox" name="globalheader_mainsite_enabled_footer" id="globalheader_mainsite_enabled_footer" value="on"<?php echo ( get_site_option('globalheader_mainsite_enabled_footer') == 'on' ) ? ' checked="checked"' : ''; ?> />
  178.                     <br /><small><?php _e('Check to enable the global footer on the mainblog too (disabled by default).', 'globalheader') ?></small></td>
  179.             </tr>
  180.             <?php
  181.             if ( function_exists( 'supporter_check' ) ) // supporter_check exists
  182.             {
  183.             ?>
  184.             <tr valign="top">
  185.                 <th scope="row"><label for="globalheader_supporters_enabled_footer"><?php _e('Enable footer for Supporters', 'globalheader') ?></label></th>
  186.                 <td><input type="checkbox" name="globalheader_supporters_enabled_footer" id="globalheader_supporters_enabled_footer" value="on"<?php echo ( get_site_option('globalheader_supporters_enabled_footer') != 'off' ) ? ' checked="checked"' : ''; ?> />
  187.                     <br /><small><?php _e('Check to enable the global footer on Supporter blogs (enabled by default).', 'globalheader') ?></small></td>
  188.             </tr>
  189.             <tr valign="top">
  190.                 <th scope="row"><label for="globalheader_supportersonly_enabled_footer"><?php _e('Make this footer SUPPORTERS ONLY', 'globalheader') ?></label></th>
  191.                 <td><input type="checkbox" name="globalheader_supportersonly_enabled_footer" id="globalheader_supportersonly_enabled_footer" value="on"<?php echo ( get_site_option('globalheader_supportersonly_enabled_footer') == 'on' ) ? ' checked="checked"' : ''; ?> />
  192.                     <br /><small><?php _e('Check to enable the global footer on Supporter blogs only (disabled by default, only works if the footer is enabled for supporters).', 'globalheader') ?></small></td>
  193.             </tr>
  194.             <?php
  195.             } // end if ptb
  196.             ?>
  197.             <tr valign="top">
  198.                 <th scope="row"><label for="globalheader_php_enabled_footer"><?php _e('Enable executing PHP in the footer', 'globalheader') ?></label></th>
  199.                 <td><input type="checkbox" name="globalheader_php_enabled_footer" id="globalheader_php_enabled_footer" value="on"<?php echo ( get_site_option('globalheader_php_enabled_footer') == 'on' ) ? ' checked="checked"' : ''; ?> />
  200.                     <br /><small><?php _e('Check to enable the possibility of using PHP in your footer HTML (disabled by default).', 'globalheader') ?></small></td>
  201.             </tr>
  202.             <tr valign="top">
  203.                 <th scope="row"><label for="globalheader_html_footer"><?php _e('HTML to add', 'globalheader') ?></label></th>
  204.                 <td><textarea name="globalheader_html_footer" id="globalheader_html_footer" style="width:100%" rows="8"><?php if ( get_site_option('globalheader_html_footer') ) { echo stripslashes( get_site_option('globalheader_html_footer') ); } else { ?><div id="global-footer"><a href="%SITEURL%">%SITETITLE%</a></div><?php } ?></textarea>
  205.                     <br /><small><?php _e('The HTML that will be added to every blog (will be placed in the footer). %SITEURL% will be replaced with the URL of the mainblog, %SITETITLE% by its title.', 'globalheader') ?></small></td>
  206.             </tr>
  207.             <tr valign="top">
  208.                 <th scope="row"><label for="globalheader_css_footer"><?php _e('CSS', 'globalheader') ?></label></th>
  209.                 <td><textarea name="globalheader_css_footer" id="globalheader_css_footer" style="width:100%" rows="8"><?php if ( get_site_option('globalheader_css_footer') ) { echo stripslashes( get_site_option('globalheader_css_footer') ); } else { ?>#global-footer { background-color:#000; width:100%; height:30px; display:block; }
  210. #global-footer a { color:#fff; padding:5px; }<?php } ?></textarea>
  211.                     <br /><small><?php _e('Use CSS to place the HTML to the bottom of the page.', 'globalheader') ?></small></td>
  212.             </tr>
  213.             <tr valign="top">
  214.                 <th scope="row"><label for="globalheader_excludeblogs_footer"><?php _e('Exclude blogs', 'globalheader') ?></label></th>
  215.                 <td><input type="text" name="globalheader_excludeblogs_footer" id="globalheader_excludeblogs_footer" style="width:100%" value="<?php if ( get_site_option('globalheader_excludeblogs_footer') ) { echo stripslashes( get_site_option('globalheader_excludeblogs_footer') ); } ?>" />
  216.                     <br /><small><?php _e('Blogs that you don\'t want to have the global footer on. Seperate blogIDs with a comma (ie: 2,3).', 'globalheader') ?></small></td>
  217.             </tr>
  218.             </tbody>
  219.             </table>
  220.             <p class="submit"><input type="submit" name="gh_Submit" class="button-primary" value="<?php _e('Save settings', 'globalheader') ?>" /> <input type="reset" class="button-secondary" value="<?php _e('Reset settings', 'globalheader') ?>" /></p>
  221.         </form>
  222.        
  223.         <br class="clear" />
  224.        
  225.         <form method="post" action="ms-admin.php?page=global-header&action=reset">
  226.         <table class="widefat">
  227.         <thead>
  228.         <tr>
  229.             <th><?php _e('Revert to default settings', 'globalheader') ?></th>
  230.         </tr>
  231.         </thead>
  232.         <tbody>
  233.         <tr>
  234.             <td><label for="globalheader_default_settings"><input type="checkbox" name="globalheader_default_settings" id="globalheader_default_settings" value="1" /> <?php _e('Check this to revert to the default settings in case of emergency.', 'globalheader') ?></label>
  235.                 <br /><small><?php _e('Use wisely, this cannot be undone!', 'globalheader') ?></small></td>
  236.         </tr>
  237.         </tbody>
  238.         </table>
  239.         <p class="submit"><input type="submit" name="reset_Submit" class="button-primary" value="<?php _e('Revert to default settings', 'globalheader') ?>" /></p>
  240.         </form>
  241.         <?php
  242.         break;
  243.         //---------------------------------------------------//
  244.         case "process":
  245.        
  246.             if ( isset($_POST['gh_Submit']) )
  247.             {
  248.                 if ( isset($_POST['globalheader_enabled']) ) { update_site_option( 'globalheader_enabled', $_POST['globalheader_enabled'] ); } else { update_site_option( 'globalheader_enabled', 'off' ); }
  249.                 if ( isset($_POST['globalheader_mainsite_enabled']) ) { update_site_option( 'globalheader_mainsite_enabled', $_POST['globalheader_mainsite_enabled'] ); } else { update_site_option( 'globalheader_mainsite_enabled', 'off' ); }
  250.                 if ( isset($_POST['globalheader_php_enabled']) ) { update_site_option( 'globalheader_php_enabled', $_POST['globalheader_php_enabled'] ); } else { update_site_option( 'globalheader_php_enabled', 'off' ); }
  251.                 if ( isset($_POST['globalheader_supporters_enabled']) ) { update_site_option( 'globalheader_supporters_enabled', $_POST['globalheader_supporters_enabled'] ); } else { update_site_option( 'globalheader_supporters_enabled', 'off' ); }
  252.                 if ( isset($_POST['globalheader_supportersonly_enabled']) ) { update_site_option( 'globalheader_supportersonly_enabled', $_POST['globalheader_supportersonly_enabled'] ); } else { update_site_option( 'globalheader_supportersonly_enabled', 'off' ); }
  253.                
  254.                 update_site_option( 'globalheader_excludeblogs',    $_POST['globalheader_excludeblogs'] );
  255.                 update_site_option( 'globalheader_html',            stripslashes($_POST['globalheader_html']) );
  256.                 update_site_option( 'globalheader_css',             stripslashes($_POST['globalheader_css']) );
  257.                
  258.                
  259.                 if ( isset($_POST['globalheader_enabled_footer']) ) { update_site_option( 'globalheader_enabled_footer', $_POST['globalheader_enabled_footer'] ); } else { update_site_option( 'globalheader_enabled_footer', 'off' ); }
  260.                 if ( isset($_POST['globalheader_mainsite_enabled_footer']) ) { update_site_option( 'globalheader_mainsite_enabled_footer', $_POST['globalheader_mainsite_enabled_footer'] ); } else { update_site_option( 'globalheader_mainsite_enabled_footer', 'off' ); }
  261.                 if ( isset($_POST['globalheader_php_enabled_footer']) ) { update_site_option( 'globalheader_php_enabled_footer', $_POST['globalheader_php_enabled_footer'] ); } else { update_site_option( 'globalheader_php_enabled_footer', 'off' ); }
  262.                 if ( isset($_POST['globalheader_supporters_enabled_footer']) ) { update_site_option( 'globalheader_supporters_enabled_footer', $_POST['globalheader_supporters_enabled_footer'] ); } else { update_site_option( 'globalheader_supporters_enabled_footer', 'off' ); }
  263.                 if ( isset($_POST['globalheader_supportersonly_enabled_footer']) ) { update_site_option( 'globalheader_supportersonly_enabled_footer', $_POST['globalheader_supportersonly_enabled_footer'] ); } else { update_site_option( 'globalheader_supportersonly_enabled_footer', 'off' ); }
  264.                
  265.                 update_site_option( 'globalheader_excludeblogs_footer', $_POST['globalheader_excludeblogs_footer'] );
  266.                 update_site_option( 'globalheader_html_footer',         stripslashes($_POST['globalheader_html_footer']) );
  267.                 update_site_option( 'globalheader_css_footer',          stripslashes($_POST['globalheader_css_footer']) );
  268.                
  269.                 echo '
  270.                 <script language="javascript">
  271.                 window.location="ms-admin.php?page=global-header&updated=true&updatedmsg=' . urlencode(__('Changes saved.', 'globalheader')) . '";
  272.                 </script>
  273.                 ';
  274.             }
  275.             else
  276.             {
  277.                 echo '
  278.                 <script language="javascript">
  279.                 window.location="ms-admin.php?page=global-header";
  280.                 </script>
  281.                 ';
  282.             }
  283.            
  284.         break;
  285.         //---------------------------------------------------//
  286.         case "reset":
  287.        
  288.             if ( isset($_POST['reset_Submit']) && $_POST['globalheader_default_settings'] == 1 )
  289.             {
  290.                 update_site_option( 'globalheader_enabled', 'off' );
  291.                 update_site_option( 'globalheader_mainsite_enabled', 'off' );
  292.                 update_site_option( 'globalheader_php_enabled', 'off' );
  293.                 update_site_option( 'globalheader_supporters_enabled', 'on' );
  294.                 update_site_option( 'globalheader_supportersonly_enabled', 'off' );
  295.                 update_site_option( 'globalheader_excludeblogs', '' );
  296.                 update_site_option( 'globalheader_html', '<div id="global-header"><a href="%SITEURL%">%SITETITLE%</a></div>' );
  297.                 update_site_option( 'globalheader_css', 'body { margin:30px 0 0; position:relative; }
  298. #global-header { position:absolute; top:-30px; left:0; background-color:#000; width:100%; height:30px; display:block; }
  299. #global-header a { color:#fff; padding:5px; }' );
  300.                
  301.                 update_site_option( 'globalheader_enabled_footer', 'off' );
  302.                 update_site_option( 'globalheader_mainsite_enabled_footer', 'off' );
  303.                 update_site_option( 'globalheader_php_enabled_footer', 'off' );
  304.                 update_site_option( 'globalheader_supporters_enabled_footer', 'on' );
  305.                 update_site_option( 'globalheader_supportersonly_enabled_footer', 'off' );
  306.                 update_site_option( 'globalheader_excludeblogs_footer', '' );
  307.                 update_site_option( 'globalheader_html_footer', '<div id="global-footer"><a href="%SITEURL%">%SITETITLE%</a></div>' );
  308.                 update_site_option( 'globalheader_css_footer', '#global-footer { background-color:#000; width:100%; height:30px; display:block; }
  309. #global-footer a { color:#fff; padding:5px; }' );
  310.                
  311.                 echo '
  312.                 <script language="javascript">
  313.                 window.location="ms-admin.php?page=global-header&updated=true&updatedmsg=' . urlencode(__('Settings are back to default.', 'globalheader')) . '";
  314.                 </script>
  315.                 ';
  316.             }
  317.             else
  318.             {
  319.                 echo '
  320.                 <script language="javascript">
  321.                 window.location="ms-admin.php?page=global-header";
  322.                 </script>
  323.                 ';
  324.             }
  325.            
  326.         break;
  327.         //---------------------------------------------------//
  328.     }
  329.     echo '</div>';
  330. } // end globalheader_output
  331.  
  332.  
  333. function globalheader_html()
  334. {
  335.     global $blog_id;
  336.     $excludeblogs_header = explode(',', get_site_option('globalheader_excludeblogs'));
  337.     $excludeblogs_footer = explode(',', get_site_option('globalheader_excludeblogs_footer'));
  338.    
  339.     $is_supporter       = false; // set to false by default for when Supporters plugin is not available
  340.     $is_supporter_only  = false; // set to false by default for when Supporters plugin is not available
  341.     $is_supporter_only_footer = false; // set to false by default for when Supporters plugin is not available
  342.     $supp_header        = true; // set to true by default for when Supporters plugin is not available
  343.     $supp_footer        = true; // set to true by default for when Supporters plugin is not available
  344.    
  345.     if ( function_exists( 'supporter_check' ) ) // when the Supporters plugin IS available
  346.     {
  347.         $is_supporter = is_supporter($blog_id);
  348.         $is_supporter_only = (( get_site_option('globalheader_supportersonly_enabled') == 'off' ) ? false : true );
  349.         $is_supporter_only_footer = (( get_site_option('globalheader_supportersonly_enabled_footer') == 'off' ) ? false : true );
  350.         $supp_header = (( get_site_option('globalheader_supporters_enabled') == 'off' ) ? false : true );
  351.         $supp_footer = (( get_site_option('globalheader_supporters_enabled_footer') == 'off' ) ? false : true );
  352.     }
  353.    
  354.     /* header */
  355.     if ( ( get_site_option('globalheader_enabled') == 'on' ) ) // header is enabled
  356.     {
  357.         if ( $is_supporter == true && $is_supporter_only == true && $supp_header == true )
  358.         {
  359.             $globalheader = get_site_option('globalheader_html');
  360.             $globalheader = str_replace( '%SITEURL%', get_blogaddress_by_id( 1 ), $globalheader);
  361.             $globalheader = str_replace( '%SITETITLE%', get_blog_option( 1, 'blogname' ), $globalheader);
  362.            
  363.             echo (( get_site_option('globalheader_php_enabled') == 'on' ) ? execute_php( $globalheader ) : $globalheader )."\n";
  364.         }
  365.         elseif ( $is_supporter_only == false )
  366.         {
  367.             if ( $is_supporter == false || ( $is_supporter == true && $supp_header == true ) ) // not a supporter or footer is enabled for supporters
  368.             {
  369.                 if (( ( $blog_id != 1 ) || (( $blog_id == 1 ) && ( get_site_option('globalheader_mainsite_enabled') == 'on' )) ) && ( !in_array( $blog_id, $excludeblogs_header) ) )
  370.                 {
  371.                     $globalheader = get_site_option('globalheader_html');
  372.                     $globalheader = str_replace( '%SITEURL%', get_blogaddress_by_id( 1 ), $globalheader);
  373.                     $globalheader = str_replace( '%SITETITLE%', get_blog_option( 1, 'blogname' ), $globalheader);
  374.                    
  375.                     echo (( get_site_option('globalheader_php_enabled') == 'on' ) ? execute_php( $globalheader ) : $globalheader )."\n";
  376.                 }
  377.             }
  378.         }
  379.     }
  380.     /* footer */
  381.     if ( ( get_site_option('globalheader_enabled_footer') == 'on' ) ) // footer is enabled
  382.     {
  383.         if ( $is_supporter == true && $is_supporter_only_footer == true && $supp_footer == true )
  384.         {
  385.             $globalfooter = get_site_option('globalheader_html_footer');
  386.             $globalfooter = str_replace( '%SITEURL%', get_blogaddress_by_id( 1 ), $globalfooter);
  387.             $globalfooter = str_replace( '%SITETITLE%', get_blog_option( 1, 'blogname' ), $globalfooter);
  388.            
  389.             echo (( get_site_option('globalheader_php_enabled_footer') == 'on' ) ? execute_php( $globalfooter ) : $globalfooter )."\n";
  390.         }
  391.         elseif ( $is_supporter_only_footer == false )
  392.         {
  393.             if ( $is_supporter == false || ( $is_supporter == true && $supp_footer == true ) ) // not a supporter or footer is enabled for supporters
  394.             {
  395.                 if (( ( $blog_id != 1 ) || (( $blog_id == 1 ) && ( get_site_option('globalheader_mainsite_enabled_footer') == 'on' )) ) && ( !in_array( $blog_id, $excludeblogs_footer) ) )
  396.                 {
  397.                     $globalfooter = get_site_option('globalheader_html_footer');
  398.                     $globalfooter = str_replace( '%SITEURL%', get_blogaddress_by_id( 1 ), $globalfooter);
  399.                     $globalfooter = str_replace( '%SITETITLE%', get_blog_option( 1, 'blogname' ), $globalfooter);
  400.                    
  401.                     echo '<!-- generated by Global Header -->'."\n".(( get_site_option('globalheader_php_enabled_footer') == 'on' ) ? execute_php( stripslashes($globalfooter) ) : stripslashes($globalfooter) )."\n".'<!-- / generated by Global Header -->'."\n";
  402.                 }
  403.             }
  404.         }
  405.     }
  406. } // end globalheader_html
  407.  
  408. function globalheader_css()
  409. {
  410.     global $blog_id;
  411.     $excludeblogs_header = explode(',', get_site_option('globalheader_excludeblogs'));
  412.     $excludeblogs_footer = explode(',', get_site_option('globalheader_excludeblogs_footer'));
  413.    
  414.     $css = '';
  415.    
  416.     $is_supporter       = false; // set to false by default for when Supporters plugin is not available
  417.     $is_supporter_only  = false; // set to false by default for when Supporters plugin is not available
  418.     $is_supporter_only_footer = false; // set to false by default for when Supporters plugin is not available
  419.     $supp_header        = true; // set to true by default for when Supporters plugin is not available
  420.     $supp_footer        = true; // set to true by default for when Supporters plugin is not available
  421.    
  422.     if ( function_exists( 'supporter_check' ) ) // when the Supporters plugin IS available
  423.     {
  424.         $is_supporter = is_supporter($blog_id); // whether the blog is a Supporter blog or not
  425.         $is_supporter_only = (( get_site_option('globalheader_supportersonly_enabled') == 'off' ) ? false : true );
  426.         $is_supporter_only_footer = (( get_site_option('globalheader_supportersonly_enabled_footer') == 'off' ) ? false : true );
  427.         $supp_header = (( get_site_option('globalheader_supporters_enabled') == 'off' ) ? false : true );
  428.         $supp_footer = (( get_site_option('globalheader_supporters_enabled_footer') == 'off' ) ? false : true );
  429.     }
  430.    
  431.     /* header */
  432.     if ( ( get_site_option('globalheader_enabled') == 'on' ) ) // header is enabled
  433.     {
  434.         if ( $is_supporter == true && $is_supporter_only == true && $supp_header == true )
  435.         {
  436.             $css .= get_site_option('globalheader_css')."\n";
  437.         }
  438.         elseif ( $is_supporter_only == false )
  439.         {
  440.             if ( $is_supporter == false || ( $is_supporter == true && $supp_header == true ) ) // not a supporter or header is enabled for supporters
  441.             {
  442.                 if (( ( $blog_id != 1 ) || (( $blog_id == 1 ) && ( get_site_option('globalheader_mainsite_enabled') == 'on' )) ) && ( !in_array( $blog_id, $excludeblogs_header) ) )
  443.                 {
  444.                     $css .= get_site_option('globalheader_css')."\n";
  445.                 }
  446.             }
  447.         }
  448.     }
  449.     /* footer */
  450.     if ( ( get_site_option('globalheader_enabled_footer') == 'on' ) ) // footer is enabled
  451.     {
  452.         if ( $is_supporter == true && $is_supporter_only_footer == true && $supp_footer == true )
  453.         {
  454.             $css .= get_site_option('globalheader_css_footer')."\n";
  455.         }
  456.         elseif ( $is_supporter_only_footer == false )
  457.         {
  458.             if ( $is_supporter == false || ( $is_supporter == true && $supp_footer == true ) ) // not a supporter or header is enabled for supporters
  459.             {  
  460.                 if (( ( $blog_id != 1 ) || (( $blog_id == 1 ) && ( get_site_option('globalheader_mainsite_enabled_footer') == 'on' )) ) && ( !in_array( $blog_id, $excludeblogs_footer) ) )
  461.                 {              
  462.                     $css .= get_site_option('globalheader_css_footer')."\n";
  463.                 }
  464.             }
  465.         }
  466.     }
  467.    
  468.     echo ( ( $css != '' ) ? '<!-- generated by Global Header -->'."\n".'<style type="text/css">'."\n".stripslashes($css)."\n".'</style>'."\n".'<!-- / generated by Global Header -->'."\n" : '');
  469. } // end globalheader_css
  470.  
  471. if ( !function_exists('execute_php') )
  472. {
  473.     function execute_php( $content )
  474.     {
  475.         ob_start();
  476.         eval("?>$content<?php ");
  477.         $output = ob_get_contents();
  478.         ob_end_clean();
  479.         return $output;
  480.     }
  481. } // execute_php
  482.  
  483. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement