WordPress.org

Plugin Directory

Changeset 573739


Ignore:
Timestamp:
07/17/12 19:18:12 (21 months ago)
Author:
ramiy
Message:

Add server ping for stats purpose

File:
1 edited

Legend:

Unmodified
Added
Removed
  • treato/trunk/treato.php

    r568006 r573739  
    195195 
    196196 
     197 
     198/** 
     199 * Server Ping for stats purpose. 
     200 */ 
     201function ping( $host ) { 
     202    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval); 
     203    return $rval === 0; 
     204} 
     205 
     206 
    197207/** 
    198208 * Registers activation hook for the plugin. 
    199209 */ 
    200210function treato_activate() { 
     211    // Send mail 
    201212    $to = 'roee@treato.com'; 
    202     $subject = 'Treato plugin activation'; 
     213    $subject = 'Treato WordPress Plugin Activation'; 
     214    $message = home_url(); 
     215    mail( $to, $subject, $message ); 
     216    // Ping server 
     217    $ping = ping( 'http://treato.com/widgets/general/wordpress/?action=activate&site=' . home_url() ); 
     218} 
     219register_activation_hook( __FILE__, 'treato_activate' ); 
     220 
     221 
     222/** 
     223 * Registers deactivation hook for the plugin. 
     224 */ 
     225function treato_deactivate() { 
     226    // Send mail 
     227    $to = 'roee@treato.com'; 
     228    $subject = 'Treato WordPress Plugin Deactivation'; 
    203229    $message = home_url(); 
    204230    mail( $to, $subject, $message );  
    205 } 
    206 register_activation_hook( __FILE__, 'treato_activate' ); 
    207  
    208  
    209 /** 
    210  * Registers deactivation hook for the plugin. 
    211  */ 
    212 function treato_deactivate() { 
     231    // Ping server 
     232    $ping = ping( 'http://treato.com/widgets/general/wordpress/?action=deactivation&site=' . home_url() ); 
     233} 
     234register_deactivation_hook( __FILE__, 'treato_deactivate' ); 
     235 
     236 
     237/** 
     238 * Registers uninstall hook for the plugin. 
     239 */ 
     240function treato_uninstall() { 
     241    // Send mail 
    213242    $to = 'roee@treato.com'; 
    214     $subject = 'Treato plugin deactivation'; 
     243    $subject = 'Treato WordPress Plugin Uninstall'; 
    215244    $message = home_url(); 
    216245    mail( $to, $subject, $message );  
    217 } 
    218 register_deactivation_hook( __FILE__, 'treato_deactivate' ); 
    219  
    220  
    221 /** 
    222  * Registers uninstall hook for the plugin. 
    223  */ 
    224 function treato_uninstall() { 
    225     $to = 'roee@treato.com'; 
    226     $subject = 'Treato plugin uninstall'; 
    227     $message = home_url(); 
    228     mail( $to, $subject, $message );  
     246    // Ping server 
     247    $ping = ping( 'http://treato.com/widgets/general/wordpress/?action=uninstall&site=' . home_url() ); 
    229248} 
    230249register_uninstall_hook( __FILE__, 'treato_uninstall' ); 
Note: See TracChangeset for help on using the changeset viewer.