Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../includes
File: shortcode.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
function ninja_forms_shortcode( $atts ){
[2] Fix | Delete
if ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {
[3] Fix | Delete
$return = '[ninja_forms_display_form';
[4] Fix | Delete
if ( is_array ( $atts ) ) {
[5] Fix | Delete
foreach ( $atts as $key => $value ) {
[6] Fix | Delete
$return .= ' ' . $key . '=' . $value;
[7] Fix | Delete
}
[8] Fix | Delete
}
[9] Fix | Delete
$return .= ']';
[10] Fix | Delete
return $return;
[11] Fix | Delete
} else {
[12] Fix | Delete
$form = ninja_forms_return_echo( 'ninja_forms_display_form', $atts['id'] );
[13] Fix | Delete
return $form;
[14] Fix | Delete
}
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
add_shortcode( 'ninja_forms', 'ninja_forms_shortcode' );
[18] Fix | Delete
add_shortcode( 'ninja_form', 'ninja_forms_shortcode' );
[19] Fix | Delete
/**
[20] Fix | Delete
* Old Ninja Forms shortcode
[21] Fix | Delete
*/
[22] Fix | Delete
add_shortcode( 'ninja_forms_display_form', 'ninja_forms_shortcode' );
[23] Fix | Delete
[24] Fix | Delete
function ninja_forms_field_shortcode( $atts ){
[25] Fix | Delete
global $ninja_forms_processing;
[26] Fix | Delete
$field_id = $atts['id'];
[27] Fix | Delete
if ( is_object ( $ninja_forms_processing ) ) {
[28] Fix | Delete
$value = $ninja_forms_processing->get_field_value( $field_id );
[29] Fix | Delete
$value = apply_filters( 'ninja_forms_field_shortcode', $value, $atts );
[30] Fix | Delete
if( is_array( $value ) ){
[31] Fix | Delete
$value = implode( ',', $value );
[32] Fix | Delete
}
[33] Fix | Delete
} else {
[34] Fix | Delete
$value = '';
[35] Fix | Delete
}
[36] Fix | Delete
return nf_wp_kses_post_deep( $value );
[37] Fix | Delete
}
[38] Fix | Delete
add_shortcode( 'ninja_forms_field', 'ninja_forms_field_shortcode' );
[39] Fix | Delete
[40] Fix | Delete
function ninja_forms_sub_date_shortcode( $atts ){
[41] Fix | Delete
global $ninja_forms_processing;
[42] Fix | Delete
if( isset( $atts['format'] ) ){
[43] Fix | Delete
$date_format = $atts['format'];
[44] Fix | Delete
}else{
[45] Fix | Delete
$date_format = 'm/d/Y';
[46] Fix | Delete
}
[47] Fix | Delete
$date = date( $date_format );
[48] Fix | Delete
return $date;
[49] Fix | Delete
}
[50] Fix | Delete
add_shortcode( 'ninja_forms_sub_date', 'ninja_forms_sub_date_shortcode' );
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
function ninja_forms_pre_process_shortcode($content) {
[54] Fix | Delete
global $shortcode_tags;
[55] Fix | Delete
// Remove our previously registered shortcode.
[56] Fix | Delete
//remove_shortcode( 'ninja_forms_display_form' );
[57] Fix | Delete
// Backup current registered shortcodes and clear them all out
[58] Fix | Delete
$current_shortcodes = $shortcode_tags;
[59] Fix | Delete
$shortcode_tags = array();
[60] Fix | Delete
add_shortcode( 'ninja_forms_display_form', 'ninja_forms_shortcode' );
[61] Fix | Delete
// Do the shortcode (only the one above is registered)
[62] Fix | Delete
$content = do_shortcode($content);
[63] Fix | Delete
// Put the original shortcodes back
[64] Fix | Delete
$shortcode_tags = $current_shortcodes;
[65] Fix | Delete
return $content;
[66] Fix | Delete
}
[67] Fix | Delete
add_filter('the_content', 'ninja_forms_pre_process_shortcode', 9999);
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Parse the [nf_sub_seq_num] shortcode
[71] Fix | Delete
*
[72] Fix | Delete
* @since 2.8.4
[73] Fix | Delete
* @return string $setting
[74] Fix | Delete
*/
[75] Fix | Delete
function nf_parse_sub_seq_num_shortcode( $setting, $setting_name = '', $id = '' ) {
[76] Fix | Delete
global $ninja_forms_processing;
[77] Fix | Delete
[78] Fix | Delete
if ( ! is_object( $ninja_forms_processing ) )
[79] Fix | Delete
return $setting;
[80] Fix | Delete
[81] Fix | Delete
$sub_id = $ninja_forms_processing->get_form_setting( 'sub_id' );
[82] Fix | Delete
if ( empty ( $sub_id ) )
[83] Fix | Delete
return $setting;
[84] Fix | Delete
[85] Fix | Delete
$seq_num = Ninja_Forms()->sub( $sub_id )->get_seq_num();
[86] Fix | Delete
[87] Fix | Delete
$setting = str_replace( '[nf_sub_seq_num]', $seq_num, $setting );
[88] Fix | Delete
return $setting;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
add_filter( 'nf_email_notification_process_setting', 'nf_parse_sub_seq_num_shortcode', 10, 3 );
[92] Fix | Delete
add_filter( 'nf_success_msg', 'nf_parse_sub_seq_num_shortcode', 10, 2 );
[93] Fix | Delete
[94] Fix | Delete
/**
[95] Fix | Delete
* Shortcode for ninja_forms_all_fields
[96] Fix | Delete
*
[97] Fix | Delete
* @since 2.8
[98] Fix | Delete
* @return string $content
[99] Fix | Delete
*/
[100] Fix | Delete
function nf_all_fields_shortcode( $atts, $content = '' ) {
[101] Fix | Delete
global $ninja_forms_fields, $ninja_forms_processing;
[102] Fix | Delete
[103] Fix | Delete
if ( ! isset ( $ninja_forms_processing ) )
[104] Fix | Delete
return false;
[105] Fix | Delete
[106] Fix | Delete
$html = isset ( $atts['html'] ) ? $atts['html'] : 1;
[107] Fix | Delete
[108] Fix | Delete
if ( 1 == $html ) {
[109] Fix | Delete
// Generate our "all fields" table for use as a JS var.
[110] Fix | Delete
$field_list = '<table><tbody>';
[111] Fix | Delete
} else {
[112] Fix | Delete
$field_list = '';
[113] Fix | Delete
}
[114] Fix | Delete
foreach ( $ninja_forms_processing->get_all_fields() as $field_id => $user_value ) {
[115] Fix | Delete
if ( ! $user_value )
[116] Fix | Delete
continue;
[117] Fix | Delete
[118] Fix | Delete
$field = $ninja_forms_processing->get_field_settings( $field_id );
[119] Fix | Delete
$type = $field['type'];
[120] Fix | Delete
if ( ! isset ( $ninja_forms_fields[ $type ] ) || ! $ninja_forms_fields[ $type ]['process_field'] )
[121] Fix | Delete
continue;
[122] Fix | Delete
[123] Fix | Delete
$value = apply_filters( 'nf_all_fields_field_value', ninja_forms_field_shortcode( array( 'id' => $field_id ) ), $field_id );
[124] Fix | Delete
[125] Fix | Delete
if( isset( $field[ 'data' ][ 'admin_label' ] ) && $field[ 'data' ][ 'admin_label' ] ){
[126] Fix | Delete
$label = $field[ 'data' ][ 'admin_label' ];
[127] Fix | Delete
} else {
[128] Fix | Delete
$label = $field['data']['label'];
[129] Fix | Delete
}
[130] Fix | Delete
$label = strip_tags( apply_filters( 'nf_all_fields_field_label', $label, $field_id ) );
[131] Fix | Delete
[132] Fix | Delete
if ( 1 == $html ) {
[133] Fix | Delete
$field_list .= '<tr id="ninja_forms_field_' . $field_id . '"><td>' . $label .':</td><td>' . $value . '</td></tr>';
[134] Fix | Delete
} else {
[135] Fix | Delete
$field_list .= $label . ' - ' . $value . "\r\n";
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
if ( 1 == $html )
[140] Fix | Delete
$field_list .= '</tbody></table>';
[141] Fix | Delete
[142] Fix | Delete
return apply_filters( 'nf_all_fields_table', $field_list, $ninja_forms_processing->get_form_ID() );
[143] Fix | Delete
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
add_shortcode( 'ninja_forms_all_fields', 'nf_all_fields_shortcode' );
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Parse our [ninja_forms_field] shortcode, just incase the shortcode parser screwed up.
[150] Fix | Delete
*
[151] Fix | Delete
* @since 2.8.4
[152] Fix | Delete
* @return content
[153] Fix | Delete
*/
[154] Fix | Delete
function nf_parse_fields_shortcode( $content ) {
[155] Fix | Delete
global $ninja_forms_processing;
[156] Fix | Delete
[157] Fix | Delete
if ( ! isset ( $ninja_forms_processing ) )
[158] Fix | Delete
return $content;
[159] Fix | Delete
[160] Fix | Delete
if ( is_array ( $content ) )
[161] Fix | Delete
return $content;
[162] Fix | Delete
[163] Fix | Delete
$matches = array();
[164] Fix | Delete
$pattern = '\[(\[?)(ninja_forms_field|ninja_forms_all_fields)(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)';
[165] Fix | Delete
[166] Fix | Delete
preg_match_all('/'.$pattern.'/s', $content, $matches);
[167] Fix | Delete
[168] Fix | Delete
if ( is_array( $matches ) && ! empty( $matches[2] ) ) {
[169] Fix | Delete
foreach ( $matches[2] as $key => $shortcode ) {
[170] Fix | Delete
[171] Fix | Delete
if ( 'ninja_forms_field' == $shortcode ) {
[172] Fix | Delete
if ( isset ( $matches[3][ $key ] ) ) {
[173] Fix | Delete
$atts = shortcode_parse_atts( $matches[3][ $key ] );
[174] Fix | Delete
$id = $atts['id'];
[175] Fix | Delete
$value = $ninja_forms_processing->get_field_value( $id );
[176] Fix | Delete
if( is_array( $value ) ){
[177] Fix | Delete
$value = implode( ',', $value );
[178] Fix | Delete
}
[179] Fix | Delete
$content = str_replace( $matches[0][ $key ], $value, $content );
[180] Fix | Delete
}
[181] Fix | Delete
} else if ( 'ninja_forms_all_fields' == $shortcode ) {
[182] Fix | Delete
if ( isset ( $matches[3][ $key ] ) ) {
[183] Fix | Delete
$atts = shortcode_parse_atts( $matches[3][ $key ] );
[184] Fix | Delete
$content = str_replace( $matches[0][ $key ], nf_all_fields_shortcode( $atts, $content ), $content );
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
}
[189] Fix | Delete
return $content;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Shortcode for ninja_forms_all_fields
[194] Fix | Delete
*
[195] Fix | Delete
* @since 2.8
[196] Fix | Delete
* @return string sub_limit_number
[197] Fix | Delete
*/
[198] Fix | Delete
function ninja_forms_display_sub_limit_number_shortcode( $atts ){
[199] Fix | Delete
$form = Ninja_Forms()->form( $atts[ 'id' ] );
[200] Fix | Delete
[201] Fix | Delete
if ( isset( $form->settings[ 'sub_limit_number' ] ) ) {
[202] Fix | Delete
return $form->settings[ 'sub_limit_number' ];
[203] Fix | Delete
}
[204] Fix | Delete
else {
[205] Fix | Delete
return null;
[206] Fix | Delete
}
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
add_shortcode( 'ninja_forms_display_sub_limit_number', 'ninja_forms_display_sub_limit_number_shortcode' );
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Shortcode for ninja_forms_display_sub_number
[213] Fix | Delete
*
[214] Fix | Delete
* @since 2.8
[215] Fix | Delete
* @return int nf_get_sub_count()
[216] Fix | Delete
* @see nf_get_sub_count()
[217] Fix | Delete
*/
[218] Fix | Delete
function ninja_forms_display_sub_number_shortcode( $atts ){
[219] Fix | Delete
$sub_count = nf_get_sub_count( $atts[ 'id' ] );
[220] Fix | Delete
return $sub_count;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
add_shortcode( 'ninja_forms_display_sub_number', 'ninja_forms_display_sub_number_shortcode' );
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Shortcode for ninja_forms_display_sub_number_remaining
[227] Fix | Delete
*
[228] Fix | Delete
* @since 2.8
[229] Fix | Delete
* @return int
[230] Fix | Delete
* @see nf_get_sub_count()
[231] Fix | Delete
*/
[232] Fix | Delete
function ninja_forms_display_sub_number_remaining_shortcode( $atts ){
[233] Fix | Delete
$form = Ninja_Forms()->form($atts[ 'id' ]);
[234] Fix | Delete
[235] Fix | Delete
if( isset( $form->settings[ 'sub_limit_number' ] ) ) {
[236] Fix | Delete
$sub_count = nf_get_sub_count( $atts[ 'id' ] );
[237] Fix | Delete
$sub_limit = (int) $form->settings[ 'sub_limit_number' ];
[238] Fix | Delete
[239] Fix | Delete
if( $sub_count > $sub_limit )
[240] Fix | Delete
return 0;
[241] Fix | Delete
[242] Fix | Delete
return $sub_limit - $sub_count;
[243] Fix | Delete
}
[244] Fix | Delete
else {
[245] Fix | Delete
return null;
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
add_shortcode( 'ninja_forms_display_sub_number_remaining', 'ninja_forms_display_sub_number_remaining_shortcode' );
[249] Fix | Delete
[250] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function