public function test_post_slug_by_id() { $this->assertEquals('test-post', ppp_get_post_slug_by_id($this->_post_id)); }
/** * The core option of Google Analytics Tags for anaytlics tracking * @param string $share_link The link to share * @param int $post_id The Post ID of the link * @param string $name The Name attribute from the cron * @return string The String with the GA Tags applied */ function ppp_generate_google_utm_link($share_link, $post_id, $name) { $name_parts = explode('_', $name); switch ($name_parts[3]) { case 'li': $network = 'LinkedIn'; break; case 'fb': $network = 'Facebook'; break; case 'tw': default: $network = 'Twitter'; break; } $utm['source'] = $network; $utm['medium'] = 'social'; $utm['term'] = ppp_get_post_slug_by_id($post_id); $utm['content'] = $name_parts[1]; // The day after publishing $utm['campaign'] = 'PostPromoterPro'; $utm_string = strpos($share_link, '?') ? '&' : '?'; $first = true; foreach ($utm as $key => $value) { if (!$first) { $utm_string .= '&'; } $utm_string .= 'utm_' . $key . '=' . $value; $first = false; } $share_link .= $utm_string; return $share_link; }