PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
← All changes | includes/class-convertkit-output.php +5 -64 3.3.23.4.3 View file →
@@ -66,9 +66,8 @@
66 66 * @since 1.9.6
67 67 */
68 68 public function __construct() {
69 69
70 - add_action( 'rest_api_init', array( $this, 'register_routes' ) );
71 70 add_action( 'wp', array( $this, 'maybe_tag_subscriber' ) );
72 71 add_action( 'template_redirect', array( $this, 'output_form' ) );
73 72 add_action( 'template_redirect', array( $this, 'page_takeover' ) );
74 73 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -80,64 +79,8 @@
80 79
81 80 }
82 81
83 82 /**
84 - * Register REST API routes.
85 - *
86 - * @since 3.1.7
87 - */
88 - public function register_routes() {
89 -
90 - // Register route to store the Kit subscriber's email's ID in a cookie.
91 - register_rest_route(
92 - 'kit/v1',
93 - '/subscriber/store-email-as-id-in-cookie',
94 - array(
95 - 'methods' => WP_REST_Server::CREATABLE,
96 - 'args' => array(
97 - // Email: Validate email is included in the request, a valid email address
98 - // and sanitize the email address.
99 - 'email' => array(
100 - 'required' => true,
101 - 'validate_callback' => function ( $param ) {
102 -
103 - return is_string( $param ) && is_email( $param );
104 -
105 - },
106 - 'sanitize_callback' => 'sanitize_email',
107 - ),
108 - ),
109 - 'callback' => function ( $request ) {
110 -
111 - // Get email address.
112 - $email = $request->get_param( 'email' );
113 -
114 - // Get subscriber ID.
115 - $subscriber = new ConvertKit_Subscriber();
116 - $subscriber_id = $subscriber->validate_and_store_subscriber_email( $email );
117 -
118 - // Bail if an error occured i.e. API hasn't been configured.
119 - if ( is_wp_error( $subscriber_id ) ) {
120 - return rest_ensure_response( $subscriber_id );
121 - }
122 -
123 - // Return the subscriber ID.
124 - return rest_ensure_response(
125 - array(
126 - 'id' => $subscriber_id,
127 - )
128 - );
129 -
130 - },
131 -
132 - // No authentication required, as this is on the frontend site.
133 - 'permission_callback' => '__return_true',
134 - )
135 - );
136 -
137 - }
138 -
139 - /**
140 83 * Tags the subscriber, if:
141 84 * - a subscriber ID exists in the cookie or URL,
142 85 * - the WordPress Page has the "Add a Tag" setting specified
143 86 *
@@ -201,9 +144,9 @@
201 144 // Fetch the underlying subscriber ID for the tag_subscriber() method.
202 145 if ( ! is_numeric( $this->subscriber_id ) ) {
203 146 $result = $api->profile( $this->subscriber_id );
204 147
205 - // If an error occured, the subscriber ID is invalid.
148 + // If an error occurred, the subscriber ID is invalid.
206 149 if ( is_wp_error( $result ) ) {
207 150 return;
208 151 }
209 152
@@ -291,9 +234,9 @@
291 234
292 235 // Get Landing Page.
293 236 $landing_page = $this->landing_pages->get_html( $this->post_settings->get_landing_page() );
294 237
295 - // Bail if an error occured.
238 + // Bail if an error occurred.
296 239 if ( is_wp_error( $landing_page ) ) {
297 240 return;
298 241 }
299 242
@@ -371,9 +314,9 @@
371 314
372 315 // Get Form HTML.
373 316 $form = $this->forms->get_html( $form_id, $post_id );
374 317
375 - // If an error occured, it could be because the specified Form ID for the Post either:
318 + // If an error occurred, it could be because the specified Form ID for the Post either:
376 319 // - belongs to another ConvertKit account (i.e. API credentials were changed in the Plugin, but this Post's specified Form was not changed), or
377 320 // - the form was deleted from the ConvertKit account.
378 321 // Attempt to fallback to the default form for this Post Type.
379 322 if ( is_wp_error( $form ) ) {
@@ -395,9 +338,9 @@
395 338
396 339 // Get Form HTML.
397 340 $form = $this->forms->get_html( $form_id, $post_id );
398 341
399 - // If an error occured again, the default form doesn't exist in this ConvertKit account.
342 + // If an error occurred again, the default form doesn't exist in this ConvertKit account.
400 343 // Just return the Post Content, unedited.
401 344 if ( is_wp_error( $form ) ) {
402 345 if ( $this->settings->debug_enabled() ) {
403 346 $content .= '<!-- Kit append_form_to_content(): Default Form: ' . $form->get_error_message() . ' -->';
@@ -819,11 +762,9 @@
819 762 wp_localize_script(
820 763 'convertkit-js',
821 764 'convertkit',
822 765 array(
823 - 'ajaxurl' => rest_url( 'kit/v1/subscriber/store-email-as-id-in-cookie' ),
824 766 'debug' => $settings->debug_enabled(),
825 - 'nonce' => wp_create_nonce( 'wp_rest' ),
826 767 'subscriber_id' => $this->subscriber_id,
827 768 )
828 769 );
829 770
@@ -839,9 +780,9 @@
839 780 // Use ConvertKit_Subscriber class to fetch and validate the subscriber ID.
840 781 $subscriber = new ConvertKit_Subscriber();
841 782 $subscriber_id = $subscriber->get_subscriber_id();
842 783
843 - // If an error occured, the subscriber ID in the request/cookie is not a valid subscriber.
784 + // If an error occurred, the subscriber ID in the request/cookie is not a valid subscriber.
844 785 if ( is_wp_error( $subscriber_id ) ) {
845 786 return;
846 787 }
847 788