PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.0.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.0.0
3.4.6 3.4.5 3.4.4 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 All 199 releases
← All changes | includes/class-convertkit-output.php +5 -78 2.3.0 → 2.0.0 View file →
@@ -14,17 +14,8 @@
14 14 */
15 15 class ConvertKit_Output {
16 16
17 17 /**
18 - * Holds the ConvertKit Subscriber ID.
19 - *
20 - * @since 2.0.6
21 - *
22 - * @var int|string
23 - */
24 - private $subscriber_id = 0;
25 -
26 - /**
27 18 * Holds the ConvertKit Plugin Settings class
28 19 *
29 20 * @since 1.9.6
30 21 *
@@ -66,14 +57,12 @@
66 57 * @since 1.9.6
67 58 */
68 59 public function __construct() {
69 60
70 - add_action( 'init', array( $this, 'get_subscriber_id_from_request' ), 1 );
71 61 add_action( 'template_redirect', array( $this, 'output_form' ) );
72 62 add_action( 'template_redirect', array( $this, 'page_takeover' ) );
73 63 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
74 64 add_filter( 'the_content', array( $this, 'append_form_to_content' ) );
75 - add_action( 'wp_footer', array( $this, 'output_scripts_footer' ) );
76 65
77 66 }
78 67
79 68 /**
@@ -156,11 +145,8 @@
156 145 if ( is_wp_error( $landing_page ) ) {
157 146 return;
158 147 }
159 148
160 - // Replace the favicon with the WordPress site's favicon, if specified.
161 - $landing_page = $this->landing_pages->replace_favicon( $landing_page );
162 -
163 149 // Output Landing Page.
164 150 // Output is supplied from ConvertKit's API, which is already sanitized.
165 151 echo $landing_page; // phpcs:ignore WordPress.Security.EscapeOutput
166 152 exit;
@@ -373,9 +359,9 @@
373 359 array(
374 360 'ajaxurl' => admin_url( 'admin-ajax.php' ),
375 361 'debug' => $settings->debug_enabled(),
376 362 'nonce' => wp_create_nonce( 'convertkit' ),
377 - 'subscriber_id' => $this->subscriber_id,
363 + 'subscriber_id' => $this->get_subscriber_id_from_request(),
378 364 'tag' => ( ( is_singular() && $convertkit_post->has_tag() ) ? $convertkit_post->get_tag() : false ),
379 365 'post_id' => $post->ID,
380 366 )
381 367 );
@@ -393,8 +379,10 @@
393 379 /**
394 380 * Gets the subscriber ID from the request (either the cookie or the URL).
395 381 *
396 382 * @since 1.9.6
383 + *
384 + * @return int Subscriber ID
397 385 */
398 386 public function get_subscriber_id_from_request() {
399 387
400 388 // Use ConvertKit_Subscriber class to fetch and validate the subscriber ID.
@@ -402,73 +390,12 @@
402 390 $subscriber_id = $subscriber->get_subscriber_id();
403 391
404 392 // If an error occured, the subscriber ID in the request/cookie is not a valid subscriber.
405 393 if ( is_wp_error( $subscriber_id ) ) {
406 - return;
394 + return 0;
407 395 }
408 396
409 - $this->subscriber_id = $subscriber_id;
410 -
411 - }
412 -
413 - /**
414 - * Outputs any JS <script> tags registered with the convertkit_output_scripts_footer
415 - * filter
416 - *
417 - * @since 2.1.4
418 - */
419 - public function output_scripts_footer() {
420 -
421 - // Define array of scripts.
422 - $scripts = array();
423 -
424 - /**
425 - * Define an array of scripts to output in the footer of the WordPress site.
426 - *
427 - * @since 2.1.4
428 - *
429 - * @param array $scripts Scripts.
430 - */
431 - $scripts = apply_filters( 'convertkit_output_scripts_footer', $scripts );
432 -
433 - // Bail if no scripts exist.
434 - if ( ! count( $scripts ) ) {
435 - return;
436 - }
437 -
438 - // Define array to store <script> outputs.
439 - $output_scripts = array();
440 -
441 - // Iterate through scripts, building the <script> tag for each.
442 - foreach ( $scripts as $script ) {
443 - $output = '<script';
444 -
445 - foreach ( $script as $attribute => $value ) {
446 - // If the value is true, just output the attribute.
447 - if ( $value === true ) {
448 - $output .= ' ' . esc_attr( $attribute );
449 - continue;
450 - }
451 -
452 - // Output the attribute and value.
453 - $output .= ' ' . esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
454 - }
455 - $output .= '></script>';
456 -
457 - // Add to array.
458 - $output_scripts[] = $output;
459 - }
460 -
461 - // Remove duplicate scripts.
462 - // This prevents the same non-inline form displaying twice. For example, if a modal form is specified both
463 - // in the Page's settings and the Form block, the user would see the same modal form displayed twice
464 - // because the script would be output twice.
465 - $output_scripts = array_unique( $output_scripts );
466 -
467 - // Output scripts.
468 - foreach ( $output_scripts as $output_script ) {
469 - echo $output_script . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
470 - }
397 + return $subscriber_id;
471 398
472 399 }
473 400
474 401 }