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.


Top ↑

Return Return

(string)


Top ↑

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;

	}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.0.5Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation