[ Index ]

MailPress 544

[ 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: 5.4.4
   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          foreach (array('home' => MP_Action_home, 'siteurl' => MP_Action_url) as $k => $v)
  24              if (strpos($url, $v) === 0) $new_url = get_option($k) . '/mail/analytics/';
  25  
  26          if (!empty($args))
  27          {
  28              if (empty($new_url)) $new_url .= substr($url, 0, strpos($url, '?'));
  29              $new_url .= sprintf('%1$s-%2$s-%3$s-%4$s.html', $args['tg'] ,$args['mm'] ,$args['co'] ,$args['us'] );
  30          }
  31  
  32          return $new_url;
  33      }
  34  
  35  	public static function get_args($url)
  36      {
  37          $w = parse_url($url);
  38          if (!isset($w['query'])) return false;
  39  
  40          $args = $w['query'];
  41          $w = explode('&', $args);
  42  
  43          foreach($w as $x)
  44          {
  45              $y = explode('=', $x);
  46              $z[$y[0]] = $y[1];
  47          }
  48          return $z;
  49      }
  50  }
  51  new MailPress_tracking_rewrite_url();
  52  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1