PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / classes / http / utm-url.php
jetformbuilder / includes / classes / http Last commit date
http-tools.php 2 years ago utm-url.php 2 years ago
utm-url.php
103 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes\Http;
5
6 use Jet_Form_Builder\Addons\Manager;
7 use Jet_Form_Builder\Classes\Theme\Theme_Info;
8
9 // If this file is called directly, abort.
10 if ( ! defined( 'WPINC' ) ) {
11 die;
12 }
13
14 class Utm_Url {
15
16 private $source = '';
17 private $medium = '';
18 private $campaign = '';
19 private $content = '';
20
21 public function __construct( string $source = '' ) {
22 if ( $source ) {
23 $this->set_source( $source );
24 }
25 }
26
27 public function add_query( string $url ): string {
28 return add_query_arg(
29 iterator_to_array( $this->generate_args() ),
30 $url
31 );
32 }
33
34
35 public function get_license_and_theme( bool $check_license = false ): string {
36 $page = jet_fb_current_page();
37 if ( ! $page ) {
38 $author_slug = ( new Theme_Info() )->author_slug();
39 } else {
40 $author_slug = $page->theme()->author_slug();
41 }
42 $license = $check_license
43 ? jet_form_builder()->addons_manager->get_slug()
44 : Manager::NOT_ACTIVE;
45
46 return "$license/$author_slug";
47 }
48
49 private function generate_args(): \Generator {
50 if ( $this->source ) {
51 yield 'utm_source' => rawurlencode( $this->source );
52 }
53
54 if ( $this->get_medium() ) {
55 yield 'utm_medium' => rawurlencode( $this->get_medium() );
56 }
57
58 if ( $this->campaign ) {
59 yield 'utm_campaign' => rawurlencode( $this->campaign );
60 }
61
62 if ( $this->content ) {
63 yield 'utm_content' => rawurlencode( $this->content );
64 }
65 }
66
67 public function set_campaign( string $campaign ): Utm_Url {
68 $this->campaign = $campaign;
69
70 return $this;
71 }
72
73 public function set_source( string $source ): Utm_Url {
74 $this->source = $source;
75
76 return $this;
77 }
78
79 /**
80 * @param string $content
81 */
82 public function set_content( string $content ) {
83 $this->content = $content;
84 }
85
86 /**
87 * @param string $medium
88 */
89 public function set_medium( string $medium ) {
90 $this->medium = $medium;
91 }
92
93 public function get_medium(): string {
94 if ( ! $this->medium ) {
95 $this->medium = $this->get_license_and_theme();
96 }
97
98 return $this->medium;
99 }
100
101
102 }
103