Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../includes/Display
File: Preview.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Display_Preview
[3] Fix | Delete
*/
[4] Fix | Delete
final class NF_Display_Preview
[5] Fix | Delete
{
[6] Fix | Delete
protected $form_id = '';
[7] Fix | Delete
protected $_form_id = '';
[8] Fix | Delete
[9] Fix | Delete
public function __construct()
[10] Fix | Delete
{
[11] Fix | Delete
if ( ! isset( $_GET['nf_preview_form'] ) ) return;
[12] Fix | Delete
[13] Fix | Delete
$this->_form_id = WPN_Helper::sanitize_text_field($_GET['nf_preview_form']);
[14] Fix | Delete
[15] Fix | Delete
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
[16] Fix | Delete
[17] Fix | Delete
add_filter('the_title', array( $this, 'the_title' ) );
[18] Fix | Delete
remove_filter( 'the_content', 'wpautop' );
[19] Fix | Delete
remove_filter( 'the_excerpt', 'wpautop' );
[20] Fix | Delete
add_filter('the_content', array( $this, 'the_content' ), 9001 );
[21] Fix | Delete
add_filter('get_the_excerpt', array( $this, 'the_content' ) );
[22] Fix | Delete
//switched from template_include to template redirect filter hook to work with block-based (FSE) themes
[23] Fix | Delete
add_filter('template_redirect', array( $this, 'template_include' ) );
[24] Fix | Delete
[25] Fix | Delete
add_filter('post_thumbnail_html', array( $this, 'post_thumbnail_html' ) );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
public function pre_get_posts( $query )
[29] Fix | Delete
{
[30] Fix | Delete
$query->set( 'posts_per_page', 1 );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* @return string
[35] Fix | Delete
*/
[36] Fix | Delete
function the_title( $title )
[37] Fix | Delete
{
[38] Fix | Delete
if( ! in_the_loop() ) return $title;
[39] Fix | Delete
[40] Fix | Delete
$form_title = Ninja_Forms()->form( $this->_form_id )->get()->get_setting( 'title' );
[41] Fix | Delete
[42] Fix | Delete
return esc_html( $form_title ) . " " . esc_html__( 'Preview', 'ninja-forms' );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* @return string
[47] Fix | Delete
*/
[48] Fix | Delete
function the_content()
[49] Fix | Delete
{
[50] Fix | Delete
if ( ! is_user_logged_in() ) return esc_html__( 'You must be logged in to preview a form.', 'ninja-forms' );
[51] Fix | Delete
[52] Fix | Delete
// takes into account if we are trying to preview a non-published form
[53] Fix | Delete
$tmp_id_test = explode( '-', $this->_form_id );
[54] Fix | Delete
[55] Fix | Delete
// if only 1 element, then is it numeric
[56] Fix | Delete
if( 1 === count( $tmp_id_test) && ! is_numeric( $tmp_id_test[ 0 ] ) ) {
[57] Fix | Delete
return esc_html__( 'You must provide a valid form ID.', 'ninja-forms' );
[58] Fix | Delete
}
[59] Fix | Delete
// if 2 array elements, is the first equal to 'tmp' and the second numeric
[60] Fix | Delete
elseif ( ( 2 === count( $tmp_id_test )
[61] Fix | Delete
&& ('tmp' != $tmp_id_test[ 0 ]
[62] Fix | Delete
|| ! is_numeric( $tmp_id_test[ 1 ] ) ) ) ) {
[63] Fix | Delete
return esc_html__( 'You must provide a valid form ID.', 'ninja-forms' );
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
return do_shortcode( "[nf_preview id='". esc_attr($this->_form_id) . "']" );
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Locate_template will be loaded using second argument of the get_query_templates() function
[71] Fix | Delete
* First argument will be prefixed with _template to create a hook
[72] Fix | Delete
* @return void
[73] Fix | Delete
*/
[74] Fix | Delete
function template_include()
[75] Fix | Delete
{
[76] Fix | Delete
$templates = array( 'page.php', 'single.php', 'index.php');
[77] Fix | Delete
include( get_query_template('ninja-forms', $templates) );
[78] Fix | Delete
[79] Fix | Delete
exit;
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
function post_thumbnail_html() {
[83] Fix | Delete
return '';
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
} // END CLASS NF_Display_Preview
[87] Fix | Delete
[88] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function