close

Plugin Directory

Changeset 218145


Ignore:
Timestamp:
03/16/2010 02:46:10 AM (16 years ago)
Author:
jkmassel
Message:

Version 1.03

Location:
underconstruction/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • underconstruction/trunk/defaultMessage.php

    r128189 r218145  
    1 <?php
     1<?php 
    22/*
    33 This file is part of underConstruction.
     4 underConstruction is free software: you can redistribute it and/or modify
     5 it under the terms of the GNU General Public License as published by
     6 the Free Software Foundation, either version 3 of the License, or
     7 (at your option) any later version.
     8 underConstruction is distributed in the hope that it will be useful,
     9 but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 GNU General Public License for more details.
     12 You should have received a copy of the GNU General Public License
     13 along with underConstruction.  If not, see <http://www.gnu.org/licenses/>.
     14 */
    415
    5     underConstruction is free software: you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation, either version 3 of the License, or
    8     (at your option) any later version.
     16function displayDefaultComingSoonPage()
     17{
     18    displayComingSoonPage(trim(get_bloginfo('title')).' is coming soon', get_bloginfo('url'), 'is coming soon');
     19}
    920
    10     underConstruction is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13     GNU General Public License for more details.
    14 
    15     You should have received a copy of the GNU General Public License
    16     along with underConstruction.  If not, see <http://www.gnu.org/licenses/>.
    17  */
     21function displayComingSoonPage($title, $headerText, $bodyText)
     22{
     23   
    1824?>
    19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    2026<html xmlns="http://www.w3.org/1999/xhtml">
    21 <head>
    22 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    23 <title>Coming Soon</title>
    24 <style type="text/css">
    25 .comingSoon {
    26     height: 92px;
    27     width: 177px;
    28     margin-top: 25%;
    29     margin-right: auto;
    30     margin-left: auto;
    31     background-repeat: no-repeat;
    32     color: #FFF;
    33     font-size: 28px;
    34     display:block;
    35     text-align:center;
     27    <head>
     28        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     29        <title>
     30            <?php echo $title; ?>
     31        </title>
     32        <style type="text/css">
     33           
     34            .headerText {
     35                width: 550px;
     36                margin-top: 10%;
     37                margin-right: auto;
     38                margin-left: auto;
     39                font-size: 28px;
     40                font-weight: normal;
     41                display: block;
     42                text-align: center;
     43            }
     44           
     45            .bodyText {
     46                width: 550px;
     47                margin-top: 15px;
     48                margin-right: auto;
     49                margin-left: auto;
     50                font-size: 14px;
     51                font-weight: normal;
     52                display: block;
     53                text-align: center;
     54            }
     55           
     56            body {
     57                margin-left: 0px;
     58                margin-top: 0px;
     59                margin-right: 0px;
     60                margin-bottom: 0px;
     61                background-color: #222222;
     62                color: #FFF;
     63                font-family: Arial, Helvetica, sans-serif;
     64            }
     65        </style>
     66    </head>
     67    <body>
     68        <span class="headerText">
     69            <?php echo $headerText; ?>
     70        </span>
     71        <br/>
     72        <span class="bodyText">
     73            <?php echo $bodyText; ?>
     74        </span>
     75    </body>
     76</html>
     77<?php
    3678}
    37 body,td,th {
    38     font-family: Helvetica, arial, sans-serif;
    39     font-size: 14px;
    40 }
    41 body {
    42     margin-left: 0px;
    43     margin-top: 0px;
    44     margin-right: 0px;
    45     margin-bottom: 0px;
    46     background-color:#222222;
    47 }
    48 </style>
    49 </head>
    50 
    51 <body>
    52 <div class="comingSoon">Coming Soon
    53 </div>
    54 </body>
    55 </html>
    56 <?php
    5779/* EOF */
    5880?>
  • underconstruction/trunk/underConstruction.php

    r135928 r218145  
    1 <?php
     1<?php 
    22/*
    33 Plugin Name: Under Construction
     
    1111/*
    1212 This file is part of underConstruction.
    13 
    14     underConstruction is free software: you can redistribute it and/or modify
    15     it under the terms of the GNU General Public License as published by
    16     the Free Software Foundation, either version 3 of the License, or
    17     (at your option) any later version.
    18 
    19     underConstruction is distributed in the hope that it will be useful,
    20     but WITHOUT ANY WARRANTY; without even the implied warranty of
    21     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    22     GNU General Public License for more details.
    23 
    24     You should have received a copy of the GNU General Public License
    25     along with underConstruction.  If not, see <http://www.gnu.org/licenses/>.
     13 underConstruction is free software: you can redistribute it and/or modify
     14 it under the terms of the GNU General Public License as published by
     15 the Free Software Foundation, either version 3 of the License, or
     16 (at your option) any later version.
     17 underConstruction is distributed in the hope that it will be useful,
     18 but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 GNU General Public License for more details.
     21 You should have received a copy of the GNU General Public License
     22 along with underConstruction.  If not, see <http://www.gnu.org/licenses/>.
    2623 */
    2724
    2825?>
    29 <?php
    30 
    31 add_action('get_header', 'uc_overrideWP');
    32 add_action('admin_menu', 'uc_adminMenu');
    33 register_deactivation_hook(__FILE__, 'uc_remove');
    34 
    35 function uc_overrideWP()
     26<?php
     27class underConstruction
    3628{
    37     if (!is_user_logged_in())
    38     {
    39         if (get_option('underConstructionHTML'))
    40         {
    41             echo ucGetHTML();
    42             die();
    43         }
    44         else
    45         {
    46             require_once ('defaultMessage.php');
    47             die();
    48         }
    49     }
     29    var $installedFolder = "";
     30    var $mainOptionsPage = "underConstructionMainOptions";
     31   
     32    function __construct()
     33    {
     34        $this->installedFolder = basename(dirname(__FILE__));
     35    }
     36   
     37    function underConstruction()
     38    {
     39        $this->__construct();
     40    }
     41   
     42    function getMainOptionsPage()
     43    {
     44        return $this->mainOptionsPage;
     45    }
     46   
     47    function underConstructionAdminInit()
     48    {
     49        /* Register our script. */
     50        wp_register_script('underConstructionJS', WP_PLUGIN_URL.'/'.$this->installedFolder.'/underconstruction.min.js');
     51    }
     52   
     53    function uc_changeMessage()
     54    {
     55        require_once ('ucOptions.php');
     56    }
     57   
     58    function uc_adminMenu()
     59    {
     60        /* Register our plugin page */
     61        $page = add_options_page('Under Construction Settings', 'Under Construction', 8, $this->mainOptionsPage, array($this, 'uc_changeMessage'));
     62       
     63        /* Using registered $page handle to hook script load */
     64        add_action('admin_print_scripts-'.$page, array($this, 'underConstructionEnqueueScripts'));
     65       
     66    }
     67   
     68    function underConstructionEnqueueScripts()
     69    {
     70        /*
     71         * It will be called only on your plugin admin page, enqueue our script here
     72         */
     73        wp_enqueue_script('scriptaculous');
     74        wp_enqueue_script('underConstructionJS');
     75    }
     76   
     77    function uc_overrideWP()
     78    {
     79        if ($this->pluginIsActive())
     80        {
     81            if (!is_user_logged_in())
     82            {
     83                //send a 503 if the setting requires it
     84                if (get_option('underConstructionHTTPStatus') == 503)
     85                {
     86                    header('HTTP/1.1 503 Service Unavailable');
     87                }
     88               
     89                if ($this->displayStatusCodeIs(0)) //they want the default!
     90                {
     91                    require_once ('defaultMessage.php');
     92                    displayDefaultComingSoonPage();
     93                    die();
     94                }
     95               
     96                if ($this->displayStatusCodeIs(1)) //they want the default with custom text!
     97                {
     98                    require_once ('defaultMessage.php');
     99                    displayComingSoonPage($this->getCustomPageTitle(), $this->getCustomHeaderText(), $this->getCustomBodyText());
     100                    die();
     101                }
     102               
     103                if ($this->displayStatusCodeIs(2)) //they want custom HTML!
     104                {
     105                    echo html_entity_decode($this->getCustomHTML());
     106                    die();
     107                }
     108            }
     109        }
     110    }
     111   
     112    function getCustomHTML()
     113    {
     114        return stripslashes(get_option('underConstructionHTML'));
     115    }
     116   
     117    function uc_remove()
     118    {
     119        delete_option('underConstructionHTML');
     120    }
     121   
     122    function pluginIsActive()
     123    {
     124   
     125        if (!get_option('underConstructionActivationStatus')) //if it's not set yet
     126        {
     127            return false;
     128        }
     129       
     130        if (get_option('underConstructionActivationStatus') == 1)
     131        {
     132            return true;
     133        }
     134        else
     135        {
     136            return false;
     137        }
     138    }
     139   
     140    function httpStatusCodeIs($status)
     141    {
     142        if (!get_option('underConstructionHTTPStatus')) //if it's not set yet
     143        {
     144            update_option('underConstructionHTTPStatus', 200); //set it
     145        }
     146       
     147        if (get_option('underConstructionHTTPStatus') == $status)
     148        {
     149            return true;
     150        }
     151        else
     152        {
     153            return false;
     154        }
     155       
     156    }
     157   
     158    function displayStatusCodeIs($status)
     159    {
     160        if (!get_option('underConstructionDisplayOption')) //if it's not set yet
     161        {
     162            update_option('underConstructionDisplayOption', 0); //set it
     163        }
     164       
     165        if (get_option('underConstructionDisplayOption') == $status)
     166        {
     167            return true;
     168        }
     169        else
     170        {
     171            return false;
     172        }
     173    }
     174   
     175    function getCustomPageTitle()
     176    {
     177        if (get_option('underConstructionCustomText') != false)
     178        {
     179            $fields = get_option('underConstructionCustomText');
     180            return stripslashes($fields['pageTitle']);
     181        }
     182        else
     183        {
     184            return 'empty';
     185        }
     186    }
     187   
     188    function getCustomHeaderText()
     189    {
     190        if (get_option('underConstructionCustomText') != false)
     191        {
     192            $fields = get_option('underConstructionCustomText');
     193            return stripslashes($fields['headerText']);
     194        }
     195        else
     196        {
     197            return 'empty';
     198        }
     199    }
     200   
     201    function getCustomBodyText()
     202    {
     203        if (get_option('underConstructionCustomText') != false)
     204        {
     205            $fields = get_option('underConstructionCustomText');
     206            return stripslashes($fields['bodyText']);
     207        }
     208        else
     209        {
     210            return 'empty';
     211        }
     212    }
     213
     214   
    50215}
    51216
    52 function uc_adminMenu()
     217$underConstructionPlugin = new underConstruction();
     218
     219add_action('template_redirect', array($underConstructionPlugin, 'uc_overrideWP'));
     220register_deactivation_hook(__FILE__, array($underConstructionPlugin, 'uc_remove'));
     221
     222add_action('admin_init', array($underConstructionPlugin, 'underConstructionAdminInit'));
     223add_action('admin_menu', array($underConstructionPlugin, 'uc_adminMenu'));
     224
     225
     226function underConstructionPluginLinks($links, $file)
    53227{
    54     add_options_page('Under Construction Message', 'Under Construction', 8, basename(__FILE__) , 'uc_changeMessage');
     228    global $underConstructionPlugin;
     229    if ($file == basename(dirname(__FILE__)).'/'.basename(__FILE__) && function_exists("admin_url"))
     230    {
     231        //add settings page
     232        $manage_link = '<a href="'.admin_url('options-general.php?page='.$underConstructionPlugin->getMainOptionsPage()).'">'.__('Settings').'</a>';
     233        array_unshift($links, $manage_link);
     234       
     235        if ($underConstructionPlugin->pluginIsActive())
     236        {
     237            $manage_link = '<a href="#" class="hide-if-no-js"  onclick="ajaxTurnOnUnderConstructionMode();">'.__('Turn off Under Construction Mode').'</a>';
     238            $manage_link .= '<noscript><a href="'.admin_url('options-general.php?page='.$underConstructionPlugin->getMainOptionsPage().'&turnOffUnderConstructionMode').'">'.__('Turn off Under Construction Mode').'</a></noscript>';
     239           
     240            array_unshift($links, $manage_link);
     241        }
     242       
     243        if (!$underConstructionPlugin->pluginIsActive())
     244        {
     245            $managePageLink = 'options-general.php?page=underConstructionMainOptions';
     246            $manage_link = '<a class="hide-if-no-js" href="#" onclick="ajaxTurnOnUnderConstructionMode();">'.__('Turn on Under Construction Mode').'</a>';
     247            $manage_link .= '<noscript><a href="'.admin_url('options-general.php?page='.$underConstructionPlugin->getMainOptionsPage().'&turnOnUnderConstructionMode').'">'.__('Turn on Under Construction Mode').'</a></noscript>';
     248           
     249            array_unshift($links, $manage_link);
     250        }
     251
     252       
     253    }
     254    return $links;
    55255}
    56256
    57 function uc_changeMessage()
    58 {
    59     if(isset($_POST['ucHTML'])){
    60         if(trim($_POST['ucHTML'])){
    61             update_option('underConstructionHTML', attribute_escape($_POST['ucHTML']));
    62         }
    63         else{
    64             uc_remove();
    65         }
    66     }
    67    
     257add_filter('plugin_action_links', 'underConstructionPluginLinks', 10, 2);
     258
    68259?>
    69 <div class="wrap">
    70     <div id="icon-options-general" class="icon32">
    71         <br/>
    72     </div>
    73     <h2>Under Construction</h2>
    74     <form method="post" action="<?php echo $GLOBALS['PHP_SELF'] . '?page=underConstruction.php'; ?>">
    75         <h3>Under Construction Page HTML</h3>
    76         <p>Put in this area the HTML you want to show up on your front page</p>
    77         <textarea name="ucHTML" rows="15" cols="75"><?php if(get_option('underConstructionHTML')){echo ucGetHTML();}?></textarea>
    78      
    79         <p class="submit">
    80         <input type="submit" name="Submit" class="button-primary" value="Save Changes" id="submitCalendarAdd"/>
    81         </p>
    82     </form>
    83 </div>
    84 <?php
    85 }
    86 
    87 function ucGetHTML()
    88 {
    89     return stripslashes(html_entity_decode(get_option('underConstructionHTML')));
    90 }
    91 
    92 function uc_remove(){
    93     delete_option('underConstructionHTML');
    94 }
    95 ?>
Note: See TracChangeset for help on using the changeset viewer.