Plugin Directory

Changeset 471313


Ignore:
Timestamp:
12/05/2011 09:05:38 PM (14 years ago)
Author:
rrolfe
Message:

Added optional admin notification when captured URLs goes above specified level

Location:
404-redirected/trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 404-redirected/trunk/includes/admin.php

    r469171 r471313  
    66
    77function wbz404_addAdminPage() {
     8    global $menu;
    89        if (function_exists('add_options_page')) {
    9                 add_options_page('404 Redirected', '404 Redirected', 'manage_options', 'wbz404_redirected', 'wbz404_adminPage');
     10        $options = wbz404_getOptions();
     11        $pageName = "404 Redirected";
     12        if ($options['admin_notification'] != '0') {
     13            $captured = wbz404_capturedCount();
     14            if ($captured >= $options['admin_notification']) {
     15                $pageName .= " <span class='update-plugins count-1'><span class='update-count'>" . $captured . "</span></span>";
     16                $pos = strpos($menu[80][0], 'update-plugins');
     17                if ($pos === false) {
     18                    $menu[80][0] = $menu[80][0] . " <span class='update-plugins count-1'><span class='update-count'>1</span></span>";
     19                }
     20            }
     21        }
     22                add_options_page('404 Redirected', $pageName, 'manage_options', 'wbz404_redirected', 'wbz404_adminPage');
    1023        }
    1124}
    1225
    1326add_action('admin_menu', 'wbz404_addAdminPage');
     27
     28function wbz404_dashboardNotification() {
     29    global $pagenow;
     30    if ( current_user_can('manage_options') ) {
     31        if ((isset($_GET['page']) && $_GET['page'] == "wbz404_redirected") || ( $pagenow == 'index.php' && (!(isset($_GET['page']))))) {
     32            $options = wbz404_getOptions();
     33            if ($options['admin_notification'] != '0') {
     34                $captured = wbz404_capturedCount();
     35                if ($captured >= $options['admin_notification']) {
     36                    echo "<div class=\"updated\"><p><strong>" . wbz404_trans('404 Redirected') . ":</strong> " . wbz404_trans('There are ' . $captured . ' captured 404 URLs that need to be processed.') . "</p></div>";
     37                }
     38            }
     39        }
     40    }
     41}
     42
     43add_action('admin_notices', 'wbz404_dashboardNotification' );
    1444
    1545function wbz404_postbox($id, $title, $content) {
     
    2050}
    2151
     52function wbz404_capturedCount() {
     53    global $wpdb;
     54    $query="select count(id) from " . $wpdb->prefix . "wbz404_redirects where status = " . $wpdb->escape(WBZ404_CAPTURED);
     55    $captured = $wpdb->get_col($query, 0);
     56    if (count($captured) == 0) {
     57        $captured[0] = 0;
     58    }
     59    return $captured[0];
     60}
     61
    2262function wbz404_updateOptions() {
    2363    $message="";
     
    3373    } else {
    3474        $options['capture_404'] = '0';
     75    }
     76
     77    if (preg_match('/^[0-9]+$/', $_POST['admin_notification']) == 1) {
     78        $options['admin_notification'] = $_POST['admin_notification'];
    3579    }
    3680
     
    717761    echo "<a href=\"http://twitter.com/Weberz\" title=\"Weberz Hosting on Twitter\" target=\"_blank\">Weberz on Twitter</a> | ";
    718762    echo "<a href=\"http://www.facebook.com/Weberz\" title=\"Weberz Hosting on Facebook\" target=\"_blank\">Weberz on Facebook</a><br>";
    719     echo "<br>";   
     763    echo "<br>";
     764   
    720765    $class="";
    721766    if ($sub == "redirects") {
     
    10471092                $content .= "<p>" . wbz404_trans('Collect incoming 404 URLs') . ": <input type=\"checkbox\" name=\"capture_404\" value=\"1\"" . $selected . "></p>";
    10481093
     1094                $content .= "<p>" . wbz404_trans('Admin notification level') . ": <input type=\"text\" name=\"admin_notification\" value=\"" . $options['admin_notification'] . "\" style=\"width: 50px;\"> " . wbz404_trans('Captured URLs (0 Disables Notification)') . "<br>";
     1095                $content .= wbz404_trans('Display WordPress admin notifications when number of captured URLs goes above specified level') . "</p>";
     1096
    10491097                $content .= "<p>" . wbz404_trans('Collected 404 URL deletion') . ": <input type=\"text\" name=\"capture_deletion\" value=\"" . $options['capture_deletion'] . "\" style=\"width: 50px;\"> " . wbz404_trans('Days (0 Disables Auto Delete)') . "<br>";
    10501098                $content .= wbz404_trans('Automatically removes 404 URLs that have been captured if they haven\'t been used for the specified amount of time.') . "</p>";
  • 404-redirected/trunk/includes/functions.php

    r471272 r471313  
    4848        'capture_deletion' => 1095,
    4949        'manual_deletion' => '0',
     50        'admin_notification' => '200',
    5051        'remove_matches' => '1',
    5152        'display_suggest' => '1',
Note: See TracChangeset for help on using the changeset viewer.