Plugin Directory

Changeset 386209


Ignore:
Timestamp:
05/18/2011 09:47:55 AM (15 years ago)
Author:
Rontu
Message:
  • added support for i18n
  • new admin menu
  • added option to set todays visitors visible or not
Location:
piwikcounter/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • piwikcounter/trunk/class.PiwikCounterAdministration.php

    r385726 r386209  
    2121        if (!current_user_can('manage_options'))
    2222        {
    23             wp_die( __('You do not have sufficient permissions to access this page.') );
     23            wp_die( __('You do not have sufficient permissions to access this page.', 'piwikcounter') );
    2424        }
    2525   
     
    3232            update_option( 'piwikcounter_unique_visitors', $_POST[ 'unique_visitors' ] );
    3333           
     34            if (isset($_POST[ 'visits_today_visible' ]) &&  ($_POST[ 'visits_today_visible' ] == 1)) {
     35                update_option( 'piwikcounter_visits_today_visible', $_POST[ 'visits_today_visible' ] );
     36            }
     37            else
     38            {
     39                update_option( 'piwikcounter_visits_today_visible', 0 );
     40            }
     41           
     42            $visitors = new Visitors();
     43            $visitors->updateYesterdayVisitors();
     44           
    3445            ?>
    3546            <div id="message" class="updated fade"><p><strong><?php _e('Options saved.') ?></strong></p></div>
     
    4051        echo '<div class="wrap">';
    4152        echo '<div id="icon-options-general" class="icon32"><br /></div>';
    42         echo "<h2>" . __( 'PiwikCounter Settings', 'PiwikCounter' ) . "</h2>";
     53        echo "<h2>" . __( 'PiwikCounter Settings', 'piwikcounter' ) . "</h2>";
    4354       
    4455        ?>
    45 
    46        
     56               
    4757        <form name="piwik_counter_administration" method="post" action="">
    4858       
    49         <b>Piwik installation: </b><input type="text" name="piwik_url" value="<?php echo get_option('piwikcounter_piwik_url') ?>" /> (http://domain.tld)<br />
    50         <b>Site ID: </b><input type="text" name="site_id" value="<?php echo get_option('piwikcounter_site_id') ?>" /><br />
    51         <b>Authorisation Key: </b><input type="text" name="auth_key" value="<?php echo get_option('piwikcounter_auth_key') ?>" /><br />
     59            <table class="form-table">
     60                <tr valign="top">
     61                    <th scope="row"><?php _e("Piwik installation", 'piwikcounter'); ?></th>
     62                    <td>
     63                        <input type="text" size="40" name="piwik_url" value="<?php echo get_option('piwikcounter_piwik_url') ?>" /> (http://domain.tld)
     64                    </td>
     65                </tr>
     66       
     67                <tr valign="top">
     68                    <th scope="row"><?php _e("Site ID", 'piwikcounter'); ?></th>
     69                    <td>
     70                        <input type="text" size="40" name="site_id" value="<?php echo get_option('piwikcounter_site_id') ?>" />
     71                    </td>
     72                </tr>
     73       
     74                <tr valign="top">
     75                    <th scope="row"><?php _e("Authorisation Key", 'piwikcounter'); ?></th>
     76                    <td>
     77                        <input type="text" size="40" name="auth_key" value="<?php echo get_option('piwikcounter_auth_key') ?>" />
     78                    </td>
     79                </tr>
    5280
    53         <b>Start Date: </b><input type="text" name="start_date" value="<?php echo get_option('piwikcounter_start_date') ?>" /> (YYYY-MM-DD)<br />
     81                <tr valign="top">
     82                    <th scope="row"><?php _e("Start date", 'piwikcounter'); ?></th>
     83                    <td>
     84                        <input type="text" size="10" name="start_date" value="<?php echo get_option('piwikcounter_start_date') ?>" /> (YYYY-MM-DD)
     85                    </td>
     86                </tr>
    5487
    55         <select name="unique_visitors">
    56             <option value="1" <?php if (get_option('piwikcounter_unique_visitors') == 1) { echo 'selected="selected"'; } ?>>unique visitors</option>
    57             <option value="0" <?php if (get_option('piwikcounter_unique_visitors') == 0) { echo 'selected="selected"'; } ?>>all visits</option>
    58         </select><br />
    59 
     88                <tr valign="top">
     89                    <th scope="row"><?php _e("Type of visits", 'piwikcounter'); ?></th>
     90                    <td>
     91                        <input type="radio" name="unique_visitors" value="1"
     92                            <?php if (get_option('piwikcounter_unique_visitors') == 1) { echo 'checked="checked"'; } ?> /> unique visitors<br />
     93                        <input type="radio" name="unique_visitors" value="0"
     94                            <?php if (get_option('piwikcounter_unique_visitors') == 0) { echo 'checked="checked"'; } ?> /> all visits
     95                    </td>
     96                </tr>
     97       
     98                <tr valign="top">
     99                    <th scope="row"><?php _e("Todays visitors", 'piwikcounter'); ?></th>
     100                    <td>
     101                        <input type="checkbox" name="visits_today_visible" value="1"
     102                            <?php if (get_option('piwikcounter_visits_today_visible') == 1) { echo 'checked="checked"'; } ?> />
     103                            <?php _e("Show todays visitors", 'piwikcounter'); ?>
     104                    </td>
     105                </tr>
     106            </table>
     107           
    60108        <p><input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /></p>
    61109
  • piwikcounter/trunk/class.PiwikCounterWidget.php

    r385726 r386209  
    4848       
    4949        echo $before_widget;
     50       
     51        echo '<!-- PiwikCounter -->';
     52       
    5053        if ( $title ) { echo $before_title . $title . $after_title; }
    5154       
     55        echo '<div id="piwikcounter_widget" style="text-align: center;">';
     56       
    5257        // Output complete amount of visitors since the specified date
    53         echo '<div style="text-align: center;">';
    54         printf ( __( "%d visitors<br/>since" ), $all_visits);
     58        if($all_visits == 0)
     59        {
     60            echo __("0<br/>visitors since", 'piwikcounter');
     61        }
     62        else
     63        {
     64            printf( _n( "%d<br/>visitor since", "%d<br/>visitors since", $all_visits, 'piwikcounter' ), $all_visits);   
     65        }
     66
     67        setlocale(LC_TIME, WPLANG);
     68        echo strftime(" %B %Y", strtotime(get_option('piwikcounter_start_date'))) .'<br/>';
     69        //echo date(" F Y", strtotime(get_option('piwikcounter_start_date')) ) .'<br/>';
    5570       
    5671        // Output amount of visitors who came today
    57         echo date(" F Y", strtotime(get_option('piwikcounter_start_date')) ) .'<br/>';
    58         printf ( __( "%d<br/>visits today" ), $visits_today );
     72        if(get_option("piwikcounter_visits_today_visible") == 1)
     73        {
     74            if($visits_today == 0)
     75            {
     76                echo __("0<br/>visits today", 'piwikcounter');
     77            }
     78            else
     79            {
     80                printf(_n("%d<br/>visit today", "%d<br/>visits today", $visits_today, 'piwikcounter'), $visits_today);
     81            }
     82        }
    5983       
    6084        echo '</div>';
    6185   
     86        echo '<!-- End PiwikCounter -->';
    6287        echo $after_widget;
    6388    }
  • piwikcounter/trunk/class.Visitors.php

    r385726 r386209  
    5656        // Get Visitors from Piwik
    5757        $visitors_yesterday = $this->getVisitors( get_option('piwikcounter_start_date'), get_option('piwikcounter_piwik_url'), get_option('piwikcounter_site_id'), get_option('piwikcounter_auth_key'), get_option('piwikcounter_unique_visitors') );
    58    
    59         echo '<!--' .$visitors_yesterday .' -->';
    6058       
    6159        // Update
  • piwikcounter/trunk/piwikcounter.php

    r385726 r386209  
    3232add_option( 'piwikcounter_visitors_yesterday', '', '', 'yes' );     // quantity of visitors until yesterday
    3333add_option( 'piwikcounter_visitors_last_change', '2000-01-01', '', 'yes' ); // last modification date of piwikcounter_visitors_yesterday (date YYYY-MM-DD)
     34add_option( 'piwikcounter_visits_today_visible', '1', '', 'yes' );  // enables visability of visits for today
    3435
    3536$pca = new PiwikCounterAdministration();
Note: See TracChangeset for help on using the changeset viewer.