WordPress.org

Plugin Directory


Ignore:
Timestamp:
09/19/09 02:28:03 (8 years ago)
Author:
ikailo
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-hive/tags/0.5/wp-hive.php

    r151196 r156140  
    1414 */ 
    1515 
    16 function wphive_force_permalinks() { 
    17     global $wp_rewrite, $wpdb; 
    18     if (!$wp_rewrite->using_permalinks()) { 
    19         $permalink_structure = $wpdb->get_var("SELECT val FROM wphive_config WHERE item = 'default_permalinks'"); 
    20         $wp_rewrite->set_permalink_structure($permalink_structure); 
    21         $wp_rewrite->flush_rules(); 
     16function wphive_check_permalinks() { 
     17    global $wp_rewrite, $wphive; 
     18    if (!$wp_rewrite->using_permalinks() && $wphive->site_has_subdirs($wphive->current_site)) { 
     19        echo "<div id='wphive-warning' class='updated fade'><p><strong>WP Hive Warning:</strong><br/>A 
     20subdirectory site is installed using WP Hive, but you are not using pretty permalinks.<br/>Fix the problem now by 
     21<a href='/wp-admin/options-permalink.php'>configuring this site to use pretty permalinks</a>. 
     22</p></div>"; 
    2223    } 
    2324} 
    24 add_action('init', 'wphive_force_permalinks', 1); 
     25if ( isset($_REQUEST['wphive_save_site'])) { 
     26    add_action('wphive_site_added', 'wphive_check_permalinks'); 
     27} 
     28elseif ( isset($_REQUEST['wphive_remove_site']) ) { 
     29    add_action('wphive_site_removed', 'wphive_check_permalinks'); 
     30} 
     31elseif ( version_compare(get_bloginfo('version'), '2.8', '>=') &&  isset($_REQUEST['permalink_structure']) ) { 
     32    add_action('permalink_structure_changed', 'wphive_check_permalinks'); 
     33} 
     34else { 
     35    add_action('admin_notices', 'wphive_check_permalinks'); 
     36} 
    2537 
    2638/* 
     
    3951add_action('admin_menu', 'wphive_admin_hook'); 
    4052 
     53 
     54/* Trying to sort out wp-admin confusion, when logging into subdirectories. */ 
     55// Probably doesn't work 
     56if ( isset($_COOKIE['wphive_pathname']) ) { 
     57    if ( isset($_REQUEST['clearwphive']) && $_REQUEST['clearwphive'] == 'true') { 
     58        function wphive_return_login_root() { 
     59            wphive_remove_site_cookie(); 
     60            wp_redirect('http://'.$_SERVER['HTTP_HOST'].'/wp-login.php'); // TODO: Parse target url 
     61        } 
     62        add_action('init', 'wphive_return_login_root'); 
     63    } 
     64    else { 
     65        function wphive_login_name($message) { 
     66            return '<p class="message">' . sprintf('Logging into %s', get_bloginfo('title', 'display' )) . ' | <a href="wp-login.php?clearwphive=true">Login to root site</a></p>'; 
     67        // TODO: Redirect with GET url 
     68        } 
     69        add_filter('login_message', 'wphive_login_name' ); 
     70        function wphive_admin_name() { 
     71            echo "<div id='wphive-warning' class='updated fade'><p>".sprintf('WP Hive Notice: Administrating %s', get_bloginfo('title', 'display' )).". <a href='".wp_logout_url()."'>Log out</a> to administer root site.</a></p></div>"; 
     72        } 
     73        add_action('admin_notices', 'wphive_admin_name'); 
     74    } 
     75} 
     76 
    4177/* Cookies */ 
    4278 
     
    4682add_action('wp_logout', 'wphive_remove_site_cookie'); 
    4783 
    48  
    4984/* 
    5085 * Add-ons 
Note: See TracChangeset for help on using the changeset viewer.