PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.4.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.4.0
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 2.2.9 2.3.0 All 197 releases
← All changes | includes/class-convertkit-output.php +51 -2 2.2.9 → 2.4.0 View file →
@@ -71,8 +71,9 @@
71 71 add_action( 'template_redirect', array( $this, 'output_form' ) );
72 72 add_action( 'template_redirect', array( $this, 'page_takeover' ) );
73 73 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
74 74 add_filter( 'the_content', array( $this, 'append_form_to_content' ) );
75 + add_action( 'wp_footer', array( $this, 'output_global_non_inline_form' ), 1 );
75 76 add_action( 'wp_footer', array( $this, 'output_scripts_footer' ) );
76 77
77 78 }
78 79
@@ -156,8 +157,11 @@
156 157 if ( is_wp_error( $landing_page ) ) {
157 158 return;
158 159 }
159 160
161 + // Replace the favicon with the WordPress site's favicon, if specified.
162 + $landing_page = $this->landing_pages->replace_favicon( $landing_page );
163 +
160 164 // Output Landing Page.
161 165 // Output is supplied from ConvertKit's API, which is already sanitized.
162 166 echo $landing_page; // phpcs:ignore WordPress.Security.EscapeOutput
163 167 exit;
@@ -171,10 +175,10 @@
171 175 * @return string Post Content with Form Appended, if applicable
172 176 */
173 177 public function append_form_to_content( $content ) {
174 178
175 - // Bail if not a singular Post Type.
176 - if ( ! is_singular() ) {
179 + // Bail if not a singular Post Type supported by ConvertKit.
180 + if ( ! is_singular( convertkit_get_supported_post_types() ) ) {
177 181 return $content;
178 182 }
179 183
180 184 // Get Post ID and ConvertKit Form ID for the Post.
@@ -403,8 +407,53 @@
403 407 return;
404 408 }
405 409
406 410 $this->subscriber_id = $subscriber_id;
411 +
412 + }
413 +
414 + /**
415 + * Outputs a non-inline form if defined in the Plugin's settings >
416 + * Default Non-Inline Form (Global) setting.
417 + *
418 + * @since 2.3.3
419 + */
420 + public function output_global_non_inline_form() {
421 +
422 + // Get Settings, if they have not yet been loaded.
423 + if ( ! $this->settings ) {
424 + $this->settings = new ConvertKit_Settings();
425 + }
426 +
427 + // Bail if no non-inline form setting is specified.
428 + if ( ! $this->settings->has_non_inline_form() ) {
429 + return;
430 + }
431 +
432 + // Get form.
433 + $convertkit_forms = new ConvertKit_Resource_Forms();
434 + $form = $convertkit_forms->get_by_id( (int) $this->settings->get_non_inline_form() );
435 +
436 + // Bail if the Form doesn't exist (this shouldn't happen, but you never know).
437 + if ( ! $form ) {
438 + return;
439 + }
440 +
441 + // Add the form to the scripts array so it is included in the output.
442 + add_filter(
443 + 'convertkit_output_scripts_footer',
444 + function ( $scripts ) use ( $form ) {
445 +
446 + $scripts[] = array(
447 + 'async' => true,
448 + 'data-uid' => $form['uid'],
449 + 'src' => $form['embed_js'],
450 + );
451 +
452 + return $scripts;
453 +
454 + }
455 + );
407 456
408 457 }
409 458
410 459 /**