Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../deprecat.../classes
File: subs-cpt.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
/**
[1] Fix | Delete
* Submission CPT.
[2] Fix | Delete
* This class adds our submission CPT and handles displaying submissions in the wp-admin.
[3] Fix | Delete
*
[4] Fix | Delete
* @package Ninja Forms
[5] Fix | Delete
* @subpackage Classes/Submissions
[6] Fix | Delete
* @copyright Copyright (c) 2014, WPNINJAS
[7] Fix | Delete
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
[8] Fix | Delete
* @since 2.7
[9] Fix | Delete
*/
[10] Fix | Delete
[11] Fix | Delete
class NF_Subs_CPT {
[12] Fix | Delete
[13] Fix | Delete
var $form_id;
[14] Fix | Delete
[15] Fix | Delete
var $screen_options;
[16] Fix | Delete
[17] Fix | Delete
var $filename;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Get things started
[21] Fix | Delete
*
[22] Fix | Delete
* @access public
[23] Fix | Delete
* @since 2.7
[24] Fix | Delete
* @return void
[25] Fix | Delete
*/
[26] Fix | Delete
function __construct() {
[27] Fix | Delete
[28] Fix | Delete
// Register our submission custom post type.
[29] Fix | Delete
add_action( 'init', array( $this, 'register_cpt' ), 5 );
[30] Fix | Delete
[31] Fix | Delete
// Populate our field settings var
[32] Fix | Delete
add_action( 'current_screen', array( $this, 'setup_fields' ) );
[33] Fix | Delete
[34] Fix | Delete
// Filter our hidden columns by form ID.
[35] Fix | Delete
add_action( 'wp', array( $this, 'filter_hidden_columns' ) );
[36] Fix | Delete
[37] Fix | Delete
// Add our submenu for the submissions page.
[38] Fix | Delete
add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 );
[39] Fix | Delete
[40] Fix | Delete
// Change our submission columns.
[41] Fix | Delete
add_filter( 'manage_nf_sub_posts_columns', array( $this, 'change_columns' ) );
[42] Fix | Delete
[43] Fix | Delete
// Make our columns sortable.
[44] Fix | Delete
add_filter( 'manage_edit-nf_sub_sortable_columns', array( $this, 'sortable_columns' ) );
[45] Fix | Delete
[46] Fix | Delete
// Actually do the sorting
[47] Fix | Delete
add_filter( 'request', array( $this, 'sort_columns' ) );
[48] Fix | Delete
[49] Fix | Delete
// Add the appropriate data for our custom columns.
[50] Fix | Delete
add_action( 'manage_posts_custom_column', array( $this, 'custom_columns' ), 10, 2 );
[51] Fix | Delete
[52] Fix | Delete
// Add our submission filters.
[53] Fix | Delete
add_action( 'restrict_manage_posts', array( $this, 'add_filters' ) );
[54] Fix | Delete
add_filter( 'parse_query', array( $this, 'table_filter' ) );
[55] Fix | Delete
add_filter( 'posts_clauses', array( $this, 'search' ), 20 );
[56] Fix | Delete
[57] Fix | Delete
add_action( 'admin_footer', array( $this, 'jquery_remove_counts' ) );
[58] Fix | Delete
[59] Fix | Delete
// Filter our post counts
[60] Fix | Delete
add_filter( 'wp_count_posts', array( $this, 'count_posts' ), 10, 3 );
[61] Fix | Delete
[62] Fix | Delete
// Filter our bulk actions
[63] Fix | Delete
add_filter( 'bulk_actions-edit-nf_sub', array( $this, 'remove_bulk_edit' ) );
[64] Fix | Delete
add_action( 'admin_footer-edit.php', array( $this, 'bulk_admin_footer' ) );
[65] Fix | Delete
[66] Fix | Delete
// Filter our bulk updated/trashed messages
[67] Fix | Delete
add_filter( 'bulk_post_updated_messages', array( $this, 'updated_messages_filter' ), 10, 2 );
[68] Fix | Delete
[69] Fix | Delete
// Filter singular updated/trashed messages
[70] Fix | Delete
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
[71] Fix | Delete
[72] Fix | Delete
// Add our metabox for editing field values
[73] Fix | Delete
add_action( 'add_meta_boxes', array( $this, 'add_metaboxes' ) );
[74] Fix | Delete
[75] Fix | Delete
// Save our metabox values
[76] Fix | Delete
add_action( 'save_post', array( $this, 'save_sub' ), 10, 2 );
[77] Fix | Delete
[78] Fix | Delete
// Save our hidden columns by form id.
[79] Fix | Delete
add_action( 'wp_ajax_nf_hide_columns', array( $this, 'hide_columns' ) );
[80] Fix | Delete
[81] Fix | Delete
// Load any custom screen options
[82] Fix | Delete
add_filter( 'screen_settings', array( $this, 'output_screen_options' ), 10, 2 );
[83] Fix | Delete
[84] Fix | Delete
// Listen for our exports button.
[85] Fix | Delete
add_action( 'load-edit.php', array( $this, 'export_listen' ) );
[86] Fix | Delete
[87] Fix | Delete
// Filter our submission capabilities
[88] Fix | Delete
add_filter( 'user_has_cap', array( $this, 'cap_filter' ), 10, 3 );
[89] Fix | Delete
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Register our submission CPT
[94] Fix | Delete
*
[95] Fix | Delete
* @access public
[96] Fix | Delete
* @since 2.7
[97] Fix | Delete
* @return void
[98] Fix | Delete
*/
[99] Fix | Delete
public function register_cpt() {
[100] Fix | Delete
if ( ! isset ( $_REQUEST['form_id'] ) || empty( $_REQUEST['form_id'] ) ) {
[101] Fix | Delete
$not_found = __( 'Please select a form to view submissions', 'ninja-forms' );
[102] Fix | Delete
} else {
[103] Fix | Delete
$not_found = __( 'No Submissions Found', 'ninja-forms' );
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
$name = _x( 'Submissions', 'post type general name', 'ninja-forms' );
[107] Fix | Delete
[108] Fix | Delete
if ( ! empty ( $_REQUEST['form_id'] ) ) {
[109] Fix | Delete
$form_title = Ninja_Forms()->form( absint( $_REQUEST['form_id'] ) )->get_setting( 'form_title' );
[110] Fix | Delete
$name =$name . ' - ' . $form_title;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
$labels = array(
[114] Fix | Delete
'name' => $name,
[115] Fix | Delete
'singular_name' => _x( 'Submission', 'post type singular name', 'ninja-forms' ),
[116] Fix | Delete
'add_new' => _x( 'Add New', 'nf_sub' ),
[117] Fix | Delete
'add_new_item' => __( 'Add New Submission', 'ninja-forms' ),
[118] Fix | Delete
'edit_item' => __( 'Edit Submission', 'ninja-forms' ),
[119] Fix | Delete
'new_item' => __( 'New Submission', 'ninja-forms' ),
[120] Fix | Delete
'view_item' => __( 'View Submission', 'ninja-forms' ),
[121] Fix | Delete
'search_items' => __( 'Search Submissions', 'ninja-forms' ),
[122] Fix | Delete
'not_found' => $not_found,
[123] Fix | Delete
'not_found_in_trash' => __( 'No Submissions Found In The Trash', 'ninja-forms' ),
[124] Fix | Delete
'parent_item_colon' => ''
[125] Fix | Delete
);
[126] Fix | Delete
[127] Fix | Delete
$args = array(
[128] Fix | Delete
'labels' => $labels,
[129] Fix | Delete
'public' => false,
[130] Fix | Delete
'publicly_queryable' => false,
[131] Fix | Delete
'show_ui' => true,
[132] Fix | Delete
'_builtin' => false, // It's a custom post type, not built in!
[133] Fix | Delete
'query_var' => true,
[134] Fix | Delete
'has_archive' => false,
[135] Fix | Delete
'show_in_menu' => false,
[136] Fix | Delete
'hierarchical' => false,
[137] Fix | Delete
'menu_events' => null,
[138] Fix | Delete
'rewrite' => array( 'slug' => 'nf_sub' ), // Permalinks format
[139] Fix | Delete
'supports' => array( 'custom-fields' ),
[140] Fix | Delete
'capability_type' => 'nf_sub',
[141] Fix | Delete
'capabilities' => array(
[142] Fix | Delete
'publish_posts' => 'nf_sub',
[143] Fix | Delete
'edit_posts' => 'nf_sub',
[144] Fix | Delete
'edit_others_posts' => 'nf_sub',
[145] Fix | Delete
'delete_posts' => 'nf_sub',
[146] Fix | Delete
'delete_others_posts' => 'nf_sub',
[147] Fix | Delete
'read_private_posts' => 'nf_sub',
[148] Fix | Delete
'edit_post' => 'nf_sub',
[149] Fix | Delete
'delete_post' => 'nf_sub',
[150] Fix | Delete
'read_post' => 'nf_sub',
[151] Fix | Delete
),
[152] Fix | Delete
);
[153] Fix | Delete
[154] Fix | Delete
register_post_type( 'nf_sub',$args );
[155] Fix | Delete
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Populate our fields var with all the fields. This keeps us from needing to ping the database later.
[160] Fix | Delete
*
[161] Fix | Delete
* @access public
[162] Fix | Delete
* @since 2.7
[163] Fix | Delete
*/
[164] Fix | Delete
public function setup_fields() {
[165] Fix | Delete
global $pagenow, $typenow;
[166] Fix | Delete
[167] Fix | Delete
// Bail if we aren't on the edit.php page, we aren't editing our custom post type, or we don't have a form_id set.
[168] Fix | Delete
if ( ( $pagenow != 'edit.php' && $pagenow != 'post.php' ) || $typenow != 'nf_sub' )
[169] Fix | Delete
return false;
[170] Fix | Delete
[171] Fix | Delete
if ( isset ( $_REQUEST['form_id'] ) ) {
[172] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[173] Fix | Delete
} else if ( isset ( $_REQUEST['post'] ) ) {
[174] Fix | Delete
$form_id = Ninja_Forms()->sub( absint( $_REQUEST['post'] ) )->form_id;
[175] Fix | Delete
} else {
[176] Fix | Delete
$form_id = '';
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
$this->form_id = $form_id;
[180] Fix | Delete
[181] Fix | Delete
Ninja_Forms()->form( $form_id );
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
/**
[185] Fix | Delete
* Add our submissions submenu
[186] Fix | Delete
*
[187] Fix | Delete
* @access public
[188] Fix | Delete
* @since 2.7
[189] Fix | Delete
* @return void
[190] Fix | Delete
*/
[191] Fix | Delete
public function add_submenu() {
[192] Fix | Delete
// Add our submissions submenu
[193] Fix | Delete
$sub_page = add_submenu_page( 'ninja-forms', __( 'Submissions', 'ninja-forms' ), __( 'Submissions', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_submissions_capabilities', 'manage_options' ), 'edit.php?post_type=nf_sub' );
[194] Fix | Delete
// Enqueue our JS on the edit page.
[195] Fix | Delete
//add_action( 'load-' . $sub_page, array( $this, 'load_js' ) );
[196] Fix | Delete
add_action( 'admin_print_styles', array( $this, 'load_js' ) );
[197] Fix | Delete
add_action( 'admin_print_styles', array( $this, 'load_css' ) );
[198] Fix | Delete
// Remove the publish box from the submission editing page.
[199] Fix | Delete
remove_meta_box( 'submitdiv', 'nf_sub', 'side' );
[200] Fix | Delete
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
/**
[204] Fix | Delete
* Enqueue our submissions JS file.
[205] Fix | Delete
*
[206] Fix | Delete
* @access public
[207] Fix | Delete
* @since 2.7
[208] Fix | Delete
* @return void
[209] Fix | Delete
*/
[210] Fix | Delete
public function load_js() {
[211] Fix | Delete
global $pagenow, $typenow;
[212] Fix | Delete
// Bail if we aren't on the edit.php page or we aren't editing our custom post type.
[213] Fix | Delete
if ( ( $pagenow != 'edit.php' && $pagenow != 'post.php' ) || $typenow != 'nf_sub' )
[214] Fix | Delete
return false;
[215] Fix | Delete
[216] Fix | Delete
$form_id = isset ( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : '';
[217] Fix | Delete
[218] Fix | Delete
if ( defined( 'NINJA_FORMS_JS_DEBUG' ) && NINJA_FORMS_JS_DEBUG ) {
[219] Fix | Delete
$suffix = '';
[220] Fix | Delete
$src = 'dev';
[221] Fix | Delete
} else {
[222] Fix | Delete
$suffix = '.min';
[223] Fix | Delete
$src = 'min';
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
$suffix = '';
[227] Fix | Delete
$src = 'dev';
[228] Fix | Delete
[229] Fix | Delete
$plugin_settings = nf_get_settings();
[230] Fix | Delete
$date_format = ninja_forms_date_to_datepicker( $plugin_settings['date_format'] );
[231] Fix | Delete
[232] Fix | Delete
$datepicker_args = array();
[233] Fix | Delete
if ( !empty( $date_format ) ) {
[234] Fix | Delete
$datepicker_args['dateFormat'] = $date_format;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
wp_enqueue_script( 'subs-cpt',
[238] Fix | Delete
NF_PLUGIN_URL . 'assets/js/' . $src .'/subs-cpt' . $suffix . '.js',
[239] Fix | Delete
array('jquery', 'jquery-ui-datepicker') );
[240] Fix | Delete
[241] Fix | Delete
wp_localize_script( 'subs-cpt', 'nf_sub', array( 'form_id' => $form_id, 'datepicker_args' => apply_filters( 'ninja_forms_admin_submissions_datepicker_args', $datepicker_args ) ) );
[242] Fix | Delete
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
/**
[246] Fix | Delete
* Enqueue our submissions CSS file.
[247] Fix | Delete
*
[248] Fix | Delete
* @access public
[249] Fix | Delete
* @since 2.7
[250] Fix | Delete
* @return void
[251] Fix | Delete
*/
[252] Fix | Delete
public function load_css() {
[253] Fix | Delete
global $pagenow, $typenow;
[254] Fix | Delete
[255] Fix | Delete
// Bail if we aren't on the edit.php page or the post.php page.
[256] Fix | Delete
if ( ( $pagenow != 'edit.php' && $pagenow != 'post.php' ) || $typenow != 'nf_sub' )
[257] Fix | Delete
return false;
[258] Fix | Delete
[259] Fix | Delete
wp_enqueue_style( 'nf-sub', NF_PLUGIN_URL .'assets/css/cpt.css' );
[260] Fix | Delete
wp_enqueue_style( 'nf-jquery-ui-freshness', NF_PLUGIN_URL .'assets/css/jquery-ui-fresh.min.css' );
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Modify the columns of our submissions table.
[265] Fix | Delete
*
[266] Fix | Delete
* @access public
[267] Fix | Delete
* @since 2.7
[268] Fix | Delete
* @return array $cols
[269] Fix | Delete
*/
[270] Fix | Delete
public function change_columns( $cols ) {
[271] Fix | Delete
// Compatibility with old field registration system. Can be removed when the new one is in place.
[272] Fix | Delete
global $ninja_forms_fields;
[273] Fix | Delete
// End Compatibility
[274] Fix | Delete
[275] Fix | Delete
$cols = array(
[276] Fix | Delete
'cb' => '<input type="checkbox" />',
[277] Fix | Delete
'id' => __( '#', 'ninja-forms' ),
[278] Fix | Delete
);
[279] Fix | Delete
[280] Fix | Delete
// Compatibility with old field registration system. Can be removed when the new one is in place.
[281] Fix | Delete
if ( isset ( $_GET['form_id'] ) && $_GET['form_id'] != '' ) {
[282] Fix | Delete
$form_id = absint( $_GET['form_id'] );
[283] Fix | Delete
if ( is_object( Ninja_Forms()->form( $this->form_id ) ) && is_array ( Ninja_Forms()->form( $this->form_id )->fields ) ) {
[284] Fix | Delete
foreach ( Ninja_Forms()->form( $this->form_id )->fields as $field ) {
[285] Fix | Delete
$field_id = $field['id'];
[286] Fix | Delete
$field_type = $field['type'];
[287] Fix | Delete
if ( isset ( $ninja_forms_fields[ $field_type ] ) ) {
[288] Fix | Delete
$reg_field = $ninja_forms_fields[ $field_type ];
[289] Fix | Delete
$process_field = $reg_field['process_field'];
[290] Fix | Delete
} else {
[291] Fix | Delete
$process_field = false;
[292] Fix | Delete
}
[293] Fix | Delete
if ( isset ( $field['data']['admin_label'] ) && ! empty ( $field['data']['admin_label'] ) ) {
[294] Fix | Delete
$label = $field['data']['admin_label'];
[295] Fix | Delete
} else if ( isset ( $field['data']['label'] ) ) {
[296] Fix | Delete
$label = $field['data']['label'];
[297] Fix | Delete
} else {
[298] Fix | Delete
$label = '';
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
if ( strlen( $label ) > 140 )
[302] Fix | Delete
$label = substr( $label, 0, 140 );
[303] Fix | Delete
[304] Fix | Delete
if ( isset ( $field['data']['label'] ) && $process_field )
[305] Fix | Delete
$cols[ 'form_' . $form_id . '_field_' . $field_id ] = $label;
[306] Fix | Delete
}
[307] Fix | Delete
}
[308] Fix | Delete
} else {
[309] Fix | Delete
$form_id = '';
[310] Fix | Delete
}
[311] Fix | Delete
// End Compatibility
[312] Fix | Delete
// Add our date column
[313] Fix | Delete
$cols['sub_date'] = __( 'Date', 'ninja-forms' );
[314] Fix | Delete
[315] Fix | Delete
return apply_filters( 'nf_sub_table_columns', $cols, $form_id );
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
/**
[319] Fix | Delete
* Make our columns sortable
[320] Fix | Delete
*
[321] Fix | Delete
* @access public
[322] Fix | Delete
* @since 2.7
[323] Fix | Delete
* @return array
[324] Fix | Delete
*/
[325] Fix | Delete
public function sortable_columns() {
[326] Fix | Delete
// Get a list of all of our fields.
[327] Fix | Delete
$columns = get_column_headers( 'edit-nf_sub' );
[328] Fix | Delete
$tmp_array = array();
[329] Fix | Delete
foreach ( $columns as $slug => $c ) {
[330] Fix | Delete
if ( $slug != 'cb' ) {
[331] Fix | Delete
$tmp_array[ $slug ] = $slug;
[332] Fix | Delete
}
[333] Fix | Delete
}
[334] Fix | Delete
return $tmp_array;
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
/**
[338] Fix | Delete
* Actually sort our columns
[339] Fix | Delete
*
[340] Fix | Delete
* @access public
[341] Fix | Delete
* @since 2.7
[342] Fix | Delete
* @return array $vars
[343] Fix | Delete
*/
[344] Fix | Delete
public function sort_columns( $vars ) {
[345] Fix | Delete
global $pagenow, $typenow;
[346] Fix | Delete
if( array_key_exists( 'orderby', $vars ) ) {
[347] Fix | Delete
if( strpos( $vars['orderby'], 'form_' ) !== false ) {
[348] Fix | Delete
$args = explode( '_', $vars['orderby'] );
[349] Fix | Delete
$field_id = $args[3];
[350] Fix | Delete
[351] Fix | Delete
if ( isset ( Ninja_Forms()->form( $this->form_id )->fields[ $field_id ]['data']['num_sort'] ) && Ninja_Forms()->form( $this->form_id )->fields[ $field_id ]['data']['num_sort'] == 1 ) {
[352] Fix | Delete
$orderby = 'meta_value_num';
[353] Fix | Delete
} else {
[354] Fix | Delete
$orderby = 'meta_value';
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
$vars['orderby'] = $orderby;
[358] Fix | Delete
$vars['meta_key'] = '_field_' . $field_id;
[359] Fix | Delete
} else if ( $vars['orderby'] == 'id' ) {
[360] Fix | Delete
$vars['orderby'] = 'meta_value_num';
[361] Fix | Delete
$vars['meta_key'] = '_seq_num';
[362] Fix | Delete
}
[363] Fix | Delete
} else if( is_admin() && $typenow == 'nf_sub' && $pagenow == 'edit.php' ) {
[364] Fix | Delete
$vars['orderby'] = 'meta_value_num';
[365] Fix | Delete
$vars['meta_key'] = '_seq_num';
[366] Fix | Delete
$vars['order'] = 'DESC';
[367] Fix | Delete
}
[368] Fix | Delete
return $vars;
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Add our custom column data
[373] Fix | Delete
*
[374] Fix | Delete
* @access public
[375] Fix | Delete
* @since 2.7
[376] Fix | Delete
* @return void
[377] Fix | Delete
*/
[378] Fix | Delete
public function custom_columns( $column, $sub_id ) {
[379] Fix | Delete
if ( isset ( $_GET['form_id'] ) ) {
[380] Fix | Delete
$form_id = absint($_GET['form_id']);
[381] Fix | Delete
if ( $column == 'id' ) {
[382] Fix | Delete
echo apply_filters( 'nf_sub_table_seq_num', Ninja_Forms()->sub( $sub_id )->get_seq_num(), $sub_id, $column );
[383] Fix | Delete
echo '<div class="locked-info"><span class="locked-avatar"></span> <span class="locked-text"></span></div>';
[384] Fix | Delete
if ( !isset ( $_GET['post_status'] ) || $_GET['post_status'] == 'all' ) {
[385] Fix | Delete
echo '<div class="row-actions custom-row-actions">';
[386] Fix | Delete
do_action( 'nf_sub_table_before_row_actions', $sub_id, $column );
[387] Fix | Delete
echo '<span class="edit"><a href="post.php?post=' . $sub_id . '&action=edit&ref=' . urlencode( esc_url( add_query_arg( array() ) ) ) . '" title="' . __( 'Edit this item', 'ninja-forms' ) . '">' . __( 'Edit', 'ninja-forms' ) . '</a> | </span>
[388] Fix | Delete
<span class="edit"><a href="' . esc_url( add_query_arg( array( 'export_single' => $sub_id ) ) ) . '" title="' . __( 'Export this item', 'ninja-forms' ) . '">' . __( 'Export', 'ninja-forms' ) . '</a> | </span>';
[389] Fix | Delete
$row_actions = apply_filters( 'nf_sub_table_row_actions', array(), $sub_id, $form_id );
[390] Fix | Delete
if ( ! empty( $row_actions ) ) {
[391] Fix | Delete
echo implode(" | ", $row_actions);
[392] Fix | Delete
echo '| ';
[393] Fix | Delete
}
[394] Fix | Delete
echo '<span class="trash"><a class="submitdelete" title="' . __( 'Move this item to the Trash', 'ninja-forms' ) . '" href="' . get_delete_post_link( $sub_id ) . '">' . __( 'Trash', 'ninja-forms' ) . '</a> </span>';
[395] Fix | Delete
do_action( 'nf_sub_table_after_row_actions', $sub_id, $column );
[396] Fix | Delete
echo '</div>';
[397] Fix | Delete
} else {
[398] Fix | Delete
echo '<div class="row-actions custom-row-actions">';
[399] Fix | Delete
do_action( 'nf_sub_table_before_row_actions_trash', $sub_id, $column );
[400] Fix | Delete
echo '<span class="untrash"><a title="' . esc_attr( __( 'Restore this item from the Trash', 'ninja-forms' ) ) . '" href="' . wp_nonce_url( sprintf( get_edit_post_link( $sub_id ) . '&amp;action=untrash', $sub_id ) , 'untrash-post_' . $sub_id ) . '">' . __( 'Restore', 'ninja-forms' ) . '</a> | </span>
[401] Fix | Delete
<span class="delete"><a class="submitdelete" title="' . esc_attr( __( 'Delete this item permanently', 'ninja-forms' ) ) . '" href="' . get_delete_post_link( $sub_id, '', true ) . '">' . __( 'Delete Permanently', 'ninja-forms' ) . '</a></span>';
[402] Fix | Delete
do_action( 'nf_sub_table_after_row_actions_trash', $sub_id, $column );
[403] Fix | Delete
echo '</div>';
[404] Fix | Delete
}
[405] Fix | Delete
} else if ( $column == 'sub_date' ) {
[406] Fix | Delete
$post = get_post( $sub_id );
[407] Fix | Delete
if ( '0000-00-00 00:00:00' == $post->post_date ) {
[408] Fix | Delete
$t_time = $h_time = __( 'Unpublished', 'ninja-forms' );
[409] Fix | Delete
$time_diff = 0;
[410] Fix | Delete
} else {
[411] Fix | Delete
$t_time = get_the_time( 'Y/m/d g:i:s A' );
[412] Fix | Delete
$m_time = $post->post_date;
[413] Fix | Delete
$time = get_post_time( 'G', true, $post );
[414] Fix | Delete
[415] Fix | Delete
$time_diff = time() - $time;
[416] Fix | Delete
[417] Fix | Delete
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
[418] Fix | Delete
$h_time = sprintf( __( '%s ago', 'ninja-forms' ), human_time_diff( $time ) );
[419] Fix | Delete
else
[420] Fix | Delete
$h_time = mysql2date( 'Y/m/d', $m_time );
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
$t_time = apply_filters( 'nf_sub_title_time', $t_time );
[424] Fix | Delete
$h_time = apply_filters( 'nf_sub_human_time', $h_time );
[425] Fix | Delete
[426] Fix | Delete
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
[427] Fix | Delete
echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
[428] Fix | Delete
[429] Fix | Delete
echo '<br />';
[430] Fix | Delete
echo apply_filters( 'nf_sub_table_status', __( 'Submitted', 'ninja-forms' ), $sub_id );
[431] Fix | Delete
[432] Fix | Delete
} else if ( strpos( $column, '_field_' ) !== false ) {
[433] Fix | Delete
global $ninja_forms_fields;
[434] Fix | Delete
[435] Fix | Delete
$field_id = str_replace( 'form_' . $form_id . '_field_', '', $column );
[436] Fix | Delete
//if ( apply_filters( 'nf_add_sub_value', Ninja_Forms()->field( $field_id )->type->add_to_sub, $field_id ) ) {
[437] Fix | Delete
$field = Ninja_Forms()->form( $form_id )->fields[ $field_id ];
[438] Fix | Delete
$field_type = $field['type'];
[439] Fix | Delete
if ( isset ( $ninja_forms_fields[ $field_type ] ) ) {
[440] Fix | Delete
$reg_field = $ninja_forms_fields[ $field_type ];
[441] Fix | Delete
} else {
[442] Fix | Delete
$reg_field = array();
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
if ( isset ( $reg_field['sub_table_value'] ) ) {
[446] Fix | Delete
$edit_value_function = $reg_field['sub_table_value'];
[447] Fix | Delete
} else {
[448] Fix | Delete
$edit_value_function = 'nf_field_text_sub_table_value';
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
$user_value = Ninja_Forms()->sub( $sub_id )->get_field( $field_id );
[452] Fix | Delete
[453] Fix | Delete
$args['field_id'] = $field_id;
[454] Fix | Delete
$args['user_value'] = ninja_forms_esc_html_deep( $user_value );
[455] Fix | Delete
$args['field'] = $field;
[456] Fix | Delete
[457] Fix | Delete
call_user_func_array( $edit_value_function, $args );
[458] Fix | Delete
//}
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
/**
[464] Fix | Delete
* Add our submission filters
[465] Fix | Delete
*
[466] Fix | Delete
* @access public
[467] Fix | Delete
* @since 2.7
[468] Fix | Delete
* @return void
[469] Fix | Delete
*/
[470] Fix | Delete
public function add_filters() {
[471] Fix | Delete
global $typenow;
[472] Fix | Delete
[473] Fix | Delete
// Bail if we aren't in our submission custom post type.
[474] Fix | Delete
if ( $typenow != 'nf_sub' )
[475] Fix | Delete
return false;
[476] Fix | Delete
[477] Fix | Delete
// Add our Form selection dropdown.
[478] Fix | Delete
// Get our list of forms
[479] Fix | Delete
$forms = Ninja_Forms()->forms()->get_all();
[480] Fix | Delete
[481] Fix | Delete
$form_id = isset( $_GET['form_id'] ) ? absint($_GET['form_id']) : '';
[482] Fix | Delete
[483] Fix | Delete
$begin_date = isset ( $_GET['begin_date'] ) ? sanitize_text_field($_GET['begin_date']) : '';
[484] Fix | Delete
$end_date = isset ( $_GET['end_date'] ) ? sanitize_text_field($_GET['end_date']) : '';
[485] Fix | Delete
[486] Fix | Delete
// Add begin date and end date filter fields.
[487] Fix | Delete
$html = '<div style="float:left;">';
[488] Fix | Delete
$html .= '<span style="float:left;" class="spinner"></span>';
[489] Fix | Delete
$html .= '<select name="form_id" id="form_id" class="nf-form-jump">';
[490] Fix | Delete
$html .= '<option value="">- ' . __( 'Select a form', 'ninja-forms' ) . '</option>';
[491] Fix | Delete
if ( is_array( $forms ) ) {
[492] Fix | Delete
foreach ( $forms as $f_id ) {
[493] Fix | Delete
$form_title = Ninja_Forms()->form( $f_id )->get_setting( 'form_title' );
[494] Fix | Delete
$html .= '<option value="' . $f_id . '" ' . selected( $form_id, $f_id, false ) . '>' . $form_title . '</option>';
[495] Fix | Delete
}
[496] Fix | Delete
}
[497] Fix | Delete
$html .= '</select>';
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function