Noptin_Inpost::append_inpost( string $content )
Appends opt in forms to post content
Parameters Parameters
- $content
(string) (Required) The content to append an opt-in form to.
Return Return
(string)
Source Source
File: includes/class-noptin-inpost.php
public function append_inpost( $content ) { global $post; // Maybe abort early. if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_noptin_actions_page() || is_preview() ) { return $content; } // ...or the user is hiding all opt-in forms. if ( ! empty( $_GET['noptin_hide'] ) ) { return $content; } // Do not show on elementor previews. if ( isset( $_GET['elementor-preview'] ) ) { return $content; } // Do not show on Ninja Forms previews. if ( isset( $_GET['nf_preview_form'] ) || isset( $_GET['nf_iframe'] ) ) { return $content; } // Or elementor pages. if ( $post && noptin_is_page_built_with_elementor( $post->ID ) ) { return $content; } $forms = $this->get_forms(); foreach ( $forms as $form ) { // Prepare the form. $form = noptin_get_optin_form( $form ); // Can it be displayed? if ( ! $form->can_show() || empty( $form->inject ) ) { continue; } // Type of injection. $inject = noptin_clean( $form->inject ); // If we are to prepend. if ( 'both' === $inject || 'before' === $inject ) { $content = $form->get_html() . $content; } // If we are to append. if ( 'both' === $inject || 'after' === $inject ) { $content .= $form->get_html(); } } return $content; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.5 | Introduced. |