| Server IP : 68.183.124.220 / Your IP : 216.73.216.141 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/ninja-forms/includes/Admin/Metaboxes/ |
Upload File : |
<?php if ( ! defined( 'ABSPATH' ) ) exit;
final class NF_Admin_Metaboxes_AppendAForm extends NF_Abstracts_Metabox
{
protected $_post_types = array( 'post', 'page' );
public function __construct()
{
parent::__construct();
$this->_title = __( 'Append a Ninja Form', 'ninja-forms' );
add_filter( 'the_content', array( $this, 'append_form' ) );
}
public function append_form( $content )
{
if ( isset( $GLOBALS[ 'post' ] ) ) {
$post = $GLOBALS[ 'post' ];
} else {
$post = NULL;
}
if( ! $post || ! is_object( $post ) ) return $content;
$form_id = get_post_meta( $post->ID, 'ninja_forms_form', TRUE );
if( ! $form_id ) return $content;
return $content . "[ninja_forms id=$form_id]";
}
public function save_post( $post_id )
{
if (
defined('DOING_AUTOSAVE') && DOING_AUTOSAVE
|| ! isset( $_POST['nf_append_form'] )
|| ! wp_verify_nonce( $_POST['nf_append_form'], 'ninja_forms_append_form' )
|| ( 'page' == $_POST['post_type'] && !current_user_can( 'edit_page', $post_id ) )
|| ( 'post' == $_POST['post_type'] && !current_user_can( 'edit_post', $post_id ) )
) return $post_id;
$post_id = absint( $post_id );
$form_id = absint( $_POST['ninja_form_select'] );
if ( empty ( $form_id ) ) {
delete_post_meta( $post_id, 'ninja_forms_form' );
} else {
update_post_meta( $post_id, 'ninja_forms_form', $form_id );
}
}
public function render_metabox( $post, $metabox )
{
wp_nonce_field( 'ninja_forms_append_form', 'nf_append_form' );
$forms = Ninja_Forms()->form()->get_forms();
$form_id = get_post_meta( $post->ID, 'ninja_forms_form', true );
$none_text = '-- ' . __( 'None', 'ninja-forms' );
Ninja_Forms()->template( 'admin-metabox-append-a-form.html.php', compact( 'forms', 'form_id', 'none_text' ) );
}
}