PluginProbe
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification / 5.8.0
Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification v5.8.0
5.8.0 5.8.1 5.7.0 5.6.2 5.6.3 5.6.1 5.6.0 5.5.0 5.4.0 5.3.2 5.3.1 5.1.6 5.1.5 trunk 2.1.5 2.11 2.12 2.13 2.15 3.0.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.51 All 41 releases
double-opt-in / core / feedback.php

feedback.php in Double Opt-In for Contact Form 7 – Secure, GDPR-Compliant Email Verification 5.8.0, at core/feedback.php

173 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Where the plugin sends people who want to tell us something.
4 *
5 * One place for both destinations, because they are linked from five different
6 * spots and a URL that has to be changed in five files is a URL that ends up
7 * inconsistent.
8 *
9 * These addresses ship inside every installed copy and stay there until the site
10 * updates, which for a WordPress plugin can be years. They have to be addresses
11 * we can redirect later, not addresses that happen to point at today's helpdesk.
12 */
13
14 namespace forge12\contactform7\CF7DoubleOptIn;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Base of the product site. No language segment — see product_lang().
22 */
23 const PRODUCT_BASE = 'https://www.forge12.com';
24
25 /**
26 * The product page, without a language segment.
27 *
28 * forge12.com prefixes the locale itself (a request to /shop/… lands on
29 * /de/shop/…), so the short form survives whatever the site does with its
30 * language routing later. That matters here more than elsewhere: this URL is
31 * used for the plugin headers, and a `Plugin URI:` is a static string that
32 * cannot carry any locale logic at all.
33 */
34 const PRODUCT_PATH = '/shop/contact-form-7-double-opt-in';
35
36 /**
37 * Feedback form — for "this could be better" and "this is broken for me".
38 *
39 * Deliberately without a language segment, unlike the support link below:
40 * only the German page exists (`/de/shop/…/feedback`). Sending an English
41 * speaker to a German page is a poor greeting; sending them to a 404 is worse.
42 * Once `/en/shop/…/feedback` exists, this can take the same `%s` treatment as
43 * SUPPORT_URL and the distinction disappears.
44 */
45 const FEEDBACK_URL = PRODUCT_BASE . PRODUCT_PATH . '/feedback';
46
47 /**
48 * Support — for "I need help with my installation".
49 *
50 * Exists in both languages, so this one does resolve the segment. May sit
51 * behind the login, since accounts live on the same domain.
52 */
53 const SUPPORT_URL = PRODUCT_BASE . '/%s/account/support';
54
55 /**
56 * The language segment forge12.com expects.
57 *
58 * The site serves /de and /en. Shared by every link the plugin builds so they
59 * cannot drift apart.
60 *
61 * @return string 'de' or 'en'.
62 */
63 function product_lang(): string {
64 $locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
65
66 return strpos( (string) $locale, 'de' ) === 0 ? 'de' : 'en';
67 }
68
69 /**
70 * Query arguments every outbound link carries.
71 *
72 * The plugin version and nothing else: enough to tell a report about 5.1 from
73 * one about 4.0, without saying anything about the site it came from. The
74 * `from` value names the entry point so we can see which of them people
75 * actually use.
76 *
77 * @param string $from Which entry point the click came from (e.g. 'review-notice').
78 *
79 * @return array<string, string>
80 */
81 function link_args( string $from = '' ): array {
82 $args = array( 'v' => defined( 'FORGE12_OPTIN_VERSION' ) ? FORGE12_OPTIN_VERSION : '' );
83
84 if ( $from !== '' ) {
85 $args['from'] = $from;
86 }
87
88 return $args;
89 }
90
91 /**
92 * Campaign tags for links into the shop.
93 *
94 * forge12.com runs WooCommerce, whose Order Attribution stores the utm_*
95 * parameters a buyer arrived with on the order. `from` alone only shows up in
96 * server logs; these make a sale traceable to the place in the plugin that led
97 * to it. Product links only — a feedback or support visit is not a sale.
98 *
99 * @param string $from Which entry point the click came from.
100 *
101 * @return array<string, string>
102 */
103 function campaign_args( string $from ): array {
104 return array(
105 'utm_source' => 'double-opt-in',
106 'utm_medium' => 'plugin',
107 'utm_campaign' => $from !== '' ? $from : 'unspecified',
108 );
109 }
110
111 /**
112 * Build a link to the product page.
113 *
114 * @param string $from Which entry point the click came from.
115 *
116 * @return string
117 */
118 function get_product_url( string $from = '' ): string {
119 $url = add_query_arg( link_args( $from ) + campaign_args( $from ), PRODUCT_BASE . PRODUCT_PATH );
120
121 /**
122 * Filter a link to the product site.
123 *
124 * @param string $url The full URL including its query arguments.
125 * @param string $from Which entry point this is.
126 *
127 * @since 5.2.0
128 */
129 return (string) apply_filters( 'f12_doi_product_url', $url, $from );
130 }
131
132 /**
133 * Build a feedback link.
134 *
135 * @param string $from Which entry point the click came from.
136 *
137 * @return string
138 */
139 function get_feedback_url( string $from = '' ): string {
140 $url = add_query_arg( link_args( $from ), FEEDBACK_URL );
141
142 /**
143 * Filter the feedback destination.
144 *
145 * @param string $url The full URL including its query arguments.
146 * @param string $from Which entry point this is.
147 *
148 * @since 5.2.0
149 */
150 return (string) apply_filters( 'f12_doi_feedback_url', $url, $from );
151 }
152
153 /**
154 * Build a support link. Same rules as get_feedback_url().
155 *
156 * @param string $from Which entry point the click came from.
157 *
158 * @return string
159 */
160 function get_support_url( string $from = '' ): string {
161 $url = add_query_arg( link_args( $from ), sprintf( SUPPORT_URL, product_lang() ) );
162
163 /**
164 * Filter the support destination.
165 *
166 * @param string $url The full URL including its query arguments.
167 * @param string $from Which entry point this is.
168 *
169 * @since 5.2.0
170 */
171 return (string) apply_filters( 'f12_doi_support_url', $url, $from );
172 }
173