[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-content/add-ons/ -> MailPress_tracking_rewrite_url.php (source)

   1  <?php
   2  if ( class_exists( 'MailPress' ) && class_exists( 'MailPress_tracking' ) && !class_exists( 'MailPress_tracking_rewrite_url' ) )
   3  {
   4  /*
   5  Plugin Name: MailPress_tracking_rewrite_url
   6  Plugin URI: http://blog.mailpress.org/tutorials/add-ons/tracking_rewrite_url/ 
   7  Description: Tracking : rewrite urls  ( <span style="color:red;">required !</span> <span style="color:#D54E21;">Tracking</span> add-on + modified <span style="color:#D54E21;">.htaccess</span> ( sample in mp-content/xtras/mp_tracking_rewrite_url ) )
   8  Version: 7.2
   9  */
  10  
  11  class MailPress_tracking_rewrite_url
  12  {
  13  	function __construct()
  14      {
  15          add_filter( 'MailPress_tracking_url',    array( __CLASS__, 'url' ), 1, 1 );
  16      }
  17  
  18  	public static function url( $url )
  19      {
  20          $new_url = '';
  21          $args = self::get_args( $url );
  22  
  23          if ( strpos( $url, admin_url( 'admin-ajax.php' ) ) === 0 ) $new_url =  trailingslashit( site_url() ) . 'mail/analytics/';
  24  
  25          if ( !empty( $args ) )
  26          {
  27              if ( empty( $new_url ) ) $new_url .= substr( $url, 0, strpos( $url, '?' ) );
  28              $new_url .= sprintf( '%1$s-%2$s-%3$s-%4$s.html', $args['tg'] ,$args['mm'] ,$args['co'] ,$args['us'] );
  29          }
  30  
  31          return $new_url;
  32      }
  33  
  34  	public static function get_args( $url )
  35      {
  36          $w = parse_url( $url );
  37          if ( !isset( $w['query'] ) ) return false;
  38  
  39          $args = $w['query'];
  40          $w = explode( '&', $args );
  41  
  42          foreach( $w as $x )
  43          {
  44              $y = explode( '=', $x );
  45              $z[$y[0]] = $y[1];
  46          }
  47          return $z;
  48      }
  49  }
  50  new MailPress_tracking_rewrite_url();
  51  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1