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 +0 -59 3.3.33.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 occurred 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 *
@@ -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