/includes/Display/Render.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. final class NF_Display_Render 
  4. protected static $loaded_templates = array( 
  5. 'app-layout',  
  6. 'app-before-form',  
  7. 'app-after-form',  
  8. 'app-before-fields',  
  9. 'app-after-fields',  
  10. 'app-before-field',  
  11. 'app-after-field',  
  12. 'form-layout',  
  13. 'form-hp',  
  14. 'field-layout',  
  15. 'field-before',  
  16. 'field-after',  
  17. 'fields-wrap',  
  18. 'fields-wrap-no-label',  
  19. 'fields-wrap-no-container',  
  20. 'fields-label',  
  21. 'fields-error',  
  22. 'form-error',  
  23. 'field-input-limit',  
  24. 'field-null' 
  25. ); 
  26.  
  27. protected static $use_test_values = FALSE; 
  28.  
  29. public static function localize( $form_id ) 
  30. $capability = apply_filters( 'ninja_forms_display_test_values_capabilities', 'read' ); 
  31. if( isset( $_GET[ 'ninja_forms_test_values' ] ) && current_user_can( $capability ) ) { 
  32. self::$use_test_values = TRUE; 
  33.  
  34. if( ! has_action( 'wp_footer', 'NF_Display_Render::output_templates', 9999 ) ) { 
  35. add_action( 'wp_footer', 'NF_Display_Render::output_templates', 9999 ); 
  36. $form = Ninja_Forms()->form( $form_id )->get(); 
  37.  
  38. if( $form->get_setting( 'logged_in' ) && ! is_user_logged_in() ) { 
  39. echo $form->get_setting( 'not_logged_in_msg' ); 
  40. return; 
  41.  
  42. if( $form->get_setting( 'sub_limit_number' ) ) { 
  43. $subs = Ninja_Forms()->form( $form_id )->get_subs(); 
  44.  
  45. // TODO: Optimize Query 
  46. global $wpdb; 
  47. $count = 0; 
  48. $subs = $wpdb->get_results( "SELECT post_id FROM wp_postmeta WHERE `meta_key` = '_form_id' AND `meta_value` = $form_id" ); 
  49. foreach( $subs as $sub ) { 
  50. if( 'publish' == get_post_status( $sub->post_id ) ) $count++; 
  51.  
  52. if( $count >= $form->get_setting( 'sub_limit_number' ) ) { 
  53. echo apply_filters( 'nf_sub_limit_reached_msg', $form->get_setting( 'sub_limit_msg' ), $form_id ); 
  54. return; 
  55.  
  56. $currency = $form->get_setting( 'currency', Ninja_Forms()->get_setting( 'currency' ) ); 
  57. $currency_symbol = Ninja_Forms::config( 'CurrencySymbol' ); 
  58. $form->update_setting( 'currency_symbol', ( isset( $currency_symbol[ $currency ] ) ) ? $currency_symbol[ $currency ] : '' ); 
  59.  
  60. $title = apply_filters( 'ninja_forms_form_title', $form->get_setting( 'title' ), $form_id ); 
  61. $form->update_setting( 'title', $title ); 
  62.  
  63. $before_form = apply_filters( 'ninja_forms_display_before_form', '', $form_id ); 
  64. $form->update_setting( 'beforeForm', $before_form ); 
  65.  
  66. $before_fields = apply_filters( 'ninja_forms_display_before_fields', '', $form_id ); 
  67. $form->update_setting( 'beforeFields', $before_fields ); 
  68.  
  69. $after_fields = apply_filters( 'ninja_forms_display_after_fields', '', $form_id ); 
  70. $form->update_setting( 'afterFields', $after_fields ); 
  71.  
  72. $after_form = apply_filters( 'ninja_forms_display_after_form', '', $form_id ); 
  73. $form->update_setting( 'afterForm', $after_form ); 
  74.  
  75. $form_fields = Ninja_Forms()->form( $form_id )->get_fields(); 
  76.  
  77. $fields = array(); 
  78.  
  79. if( empty( $form_fields ) ) { 
  80. echo __( 'No Fields Found.', 'ninja-forms' ); 
  81. } else { 
  82. foreach ($form_fields as $field) { 
  83.  
  84. $field_type = $field->get_settings('type'); 
  85.  
  86. if( ! isset( Ninja_Forms()->fields[ $field_type ] ) ) { 
  87. $field = NF_Fields_Unknown::create( $field ); 
  88. $field_type = $field->get_setting( 'type' ); 
  89.  
  90. $field = apply_filters('ninja_forms_localize_fields', $field); 
  91. $field = apply_filters('ninja_forms_localize_field_' . $field_type, $field); 
  92.  
  93. $field_class = Ninja_Forms()->fields[$field_type]; 
  94.  
  95. if (self::$use_test_values) { 
  96. $field->update_setting('value', $field_class->get_test_value()); 
  97.  
  98. $field->update_setting('id', $field->get_id()); 
  99.  
  100. /** 
  101. * TODO: For backwards compatibility, run the original action, get contents from the output buffer, and return the contents through the filter. Also display a PHP Notice for a deprecate filter. 
  102. */ 
  103.  
  104. $display_before = apply_filters( 'ninja_forms_display_before_field_type_' . $field->get_setting( 'type' ), '' ); 
  105. $display_before = apply_filters( 'ninja_forms_display_before_field_key_' . $field->get_setting( 'key' ), $display_before ); 
  106. $field->update_setting( 'beforeField', $display_before ); 
  107.  
  108. $display_after = apply_filters( 'ninja_forms_display_after_field_type_' . $field->get_setting( 'type' ), '' ); 
  109. $display_after = apply_filters( 'ninja_forms_display_after_field_key_' . $field->get_setting( 'key' ), $display_after ); 
  110. $field->update_setting( 'afterField', $display_after ); 
  111.  
  112. $templates = $field_class->get_templates(); 
  113.  
  114. if (!array($templates)) { 
  115. $templates = array($templates); 
  116.  
  117. foreach ($templates as $template) { 
  118. self::load_template('fields-' . $template); 
  119.  
  120. $settings = $field->get_settings(); 
  121.  
  122. foreach ($settings as $key => $setting) { 
  123. if (is_numeric($setting)) $settings[$key] = floatval($setting); 
  124.  
  125. if( ! isset( $settings[ 'label_pos' ] ) || 'default' == $settings[ 'label_pos' ] ) { 
  126. $settings[ 'label_pos' ] = $form->get_setting( 'default_label_pos' ); 
  127.  
  128. $settings[ 'parentType' ] = $field_class->get_parent_type(); 
  129.  
  130. if( 'list' == $settings[ 'parentType' ] && isset( $settings[ 'options' ] ) && is_array( $settings[ 'options' ] ) ) { 
  131. $settings[ 'options' ] = apply_filters( 'ninja_forms_render_options', $settings[ 'options' ], $settings ); 
  132. $settings[ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field_type, $settings[ 'options' ], $settings ); 
  133.  
  134. if (isset($settings['default'])) { 
  135. $default_value = apply_filters('ninja_forms_render_default_value', $settings['default'], $field_type, $settings); 
  136.  
  137. $default_value = preg_replace( '/{.*}/', '', $default_value ); 
  138.  
  139. if ($default_value) { 
  140. $settings['value'] = $default_value; 
  141.  
  142. ob_start(); 
  143. do_shortcode( $settings['value'] ); 
  144. $ob = ob_get_clean(); 
  145.  
  146. if( $ob ) { 
  147. $settings['value'] = $ob; 
  148.  
  149. // TODO: Find a better way to do this. 
  150. if ('shipping' == $settings['type']) { 
  151. $settings['shipping_cost'] = preg_replace ('/[^\d, \.]/', '', $settings['shipping_cost']); 
  152. $settings['shipping_cost'] = str_replace( Ninja_Forms()->get_setting( 'currency_symbol' ), '', $settings['shipping_cost']); 
  153. $settings['shipping_cost'] = number_format($settings['shipping_cost'], 2); 
  154. } elseif ('product' == $settings['type']) { 
  155. $settings['product_price'] = preg_replace ('/[^\d, \.]/', '', $settings[ 'product_price' ] ); 
  156. $settings['product_price'] = str_replace( Ninja_Forms()->get_setting( 'currency_symbol' ), '', $settings['product_price']); 
  157. $settings['product_price'] = number_format($settings['product_price'], 2); 
  158. } elseif ('total' == $settings['type'] && isset($settings['value'])) { 
  159. $settings['value'] = number_format($settings['value'], 2); 
  160.  
  161. $settings['element_templates'] = $templates; 
  162. $settings['old_classname'] = $field_class->get_old_classname(); 
  163. $settings['wrap_template'] = $field_class->get_wrap_template(); 
  164.  
  165. $fields[] = apply_filters( 'ninja_forms_localize_field_settings_' . $field_type, $settings, $form ); 
  166.  
  167. // Output Form Container 
  168. do_action( 'ninja_forms_before_container', $form_id, $form->get_settings(), $form_fields ); 
  169. Ninja_Forms::template( 'display-form-container.html.php', compact( 'form_id' ) ); 
  170.  
  171. ?> 
  172. <!-- TODO: Move to Template File. --> 
  173. <script> 
  174. var formDisplay = 1; 
  175.  
  176. // Maybe initialize nfForms object 
  177. var nfForms = nfForms || []; 
  178.  
  179. // Build Form Data 
  180. var form = []; 
  181. form.id = '<?php echo $form_id; ?>'; 
  182. form.settings = <?php echo wp_json_encode( $form->get_settings() ); ?>; 
  183.  
  184. form.fields = <?php echo wp_json_encode( $fields ); ?>; 
  185.  
  186. // Add Form Data to nfForms object 
  187. nfForms.push( form ); 
  188. </script> 
  189.  
  190. <?php 
  191. self::enqueue_scripts( $form_id ); 
  192.  
  193. public static function localize_preview( $form_id ) 
  194. $capability = apply_filters( 'ninja_forms_display_test_values_capabilities', 'read' ); 
  195. if( isset( $_GET[ 'ninja_forms_test_values' ] ) && current_user_can( $capability ) ) { 
  196. self::$use_test_values = TRUE; 
  197.  
  198. add_action( 'wp_footer', 'NF_Display_Render::output_templates', 9999 ); 
  199.  
  200. $form = get_user_option( 'nf_form_preview_' . $form_id ); 
  201.  
  202. if( ! $form ) { 
  203. self::localize( $form_id ); 
  204. return; 
  205.  
  206. if( isset( $form[ 'settings' ][ 'logged_in' ] ) && $form[ 'settings' ][ 'logged_in' ] && ! is_user_logged_in() ) { 
  207. echo $form[ 'settings' ][ 'not_logged_in_msg' ]; 
  208. return; 
  209.  
  210. $form[ 'settings' ][ 'is_preview' ] = TRUE; 
  211.  
  212. $currency = ( isset( $form[ 'settings' ][ 'currency' ] ) && $form[ 'settings' ][ 'currency' ] ) ? $form[ 'settings' ][ 'currency' ] : Ninja_Forms()->get_setting( 'currency' ) ; 
  213. $currency_symbol = Ninja_Forms::config( 'CurrencySymbol' ); 
  214. $form[ 'settings' ][ 'currency_symbol' ] = ( isset( $currency_symbol[ $currency ] ) ) ? $currency_symbol[ $currency ] : ''; 
  215.  
  216. $before_form = apply_filters( 'ninja_forms_display_before_form', '', $form_id, TRUE ); 
  217. $form[ 'settings' ][ 'beforeForm'] = $before_form; 
  218.  
  219. $before_fields = apply_filters( 'ninja_forms_display_before_fields', '', $form_id, TRUE ); 
  220. $form[ 'settings' ][ 'beforeFields'] = $before_fields; 
  221.  
  222. $after_fields = apply_filters( 'ninja_forms_display_after_fields', '', $form_id, TRUE ); 
  223. $form[ 'settings' ][ 'afterFields'] = $after_fields; 
  224.  
  225. $after_form = apply_filters( 'ninja_forms_display_after_form', '', $form_id, TRUE ); 
  226. $form[ 'settings' ][ 'afterForm'] = $after_form; 
  227.  
  228. $fields = array(); 
  229.  
  230. if( empty( $form['fields'] ) ) { 
  231. echo __( 'No Fields Found.', 'ninja-forms' ); 
  232. } else { 
  233. foreach ($form['fields'] as $field_id => $field) { 
  234.  
  235. $field_type = $field['settings']['type']; 
  236.  
  237. if( ! isset( Ninja_Forms()->fields[ $field_type ] ) ) continue; 
  238. if( ! apply_filters( 'ninja_forms_preview_display_type_' . $field_type, TRUE ) ) continue; 
  239. if( ! apply_filters( 'ninja_forms_preview_display_field', $field ) ) continue; 
  240.  
  241. $field['settings']['id'] = $field_id; 
  242.  
  243. $field = apply_filters('ninja_forms_localize_fields_preview', $field); 
  244. $field = apply_filters('ninja_forms_localize_field_' . $field_type . '_preview', $field); 
  245.  
  246. $display_before = apply_filters( 'ninja_forms_display_before_field_type_' . $field['settings'][ 'type' ], '' ); 
  247. $display_before = apply_filters( 'ninja_forms_display_before_field_key_' . $field['settings'][ 'key' ], $display_before ); 
  248. $field['settings'][ 'beforeField' ] = $display_before; 
  249.  
  250. $display_after = apply_filters( 'ninja_forms_display_after_field_type_' . $field['settings'][ 'type' ], '' ); 
  251. $display_after = apply_filters( 'ninja_forms_display_after_field_key_' . $field['settings'][ 'key' ], $display_after ); 
  252. $field['settings'][ 'afterField' ] = $display_after; 
  253.  
  254. foreach ($field['settings'] as $key => $setting) { 
  255. if (is_numeric($setting)) $field['settings'][$key] = floatval($setting); 
  256.  
  257. if( ! isset( $field['settings'][ 'label_pos' ] ) || 'default' == $field['settings'][ 'label_pos' ] ) { 
  258. if( isset( $form[ 'settings' ][ 'default_label_pos' ] ) ) { 
  259. $field['settings'][ 'label_pos' ] = $form[ 'settings' ][ 'default_label_pos' ]; 
  260.  
  261. $field_class = Ninja_Forms()->fields[$field_type]; 
  262.  
  263. $templates = $field_class->get_templates(); 
  264.  
  265. if (!array($templates)) { 
  266. $templates = array($templates); 
  267.  
  268. foreach ($templates as $template) { 
  269. self::load_template('fields-' . $template); 
  270.  
  271. if (self::$use_test_values) { 
  272. $field['settings']['value'] = $field_class->get_test_value(); 
  273.  
  274. $field[ 'settings' ][ 'parentType' ] = $field_class->get_parent_type(); 
  275.  
  276. if( 'list' == $field[ 'settings' ][ 'parentType' ] && isset( $field['settings'][ 'options' ] ) && is_array( $field['settings'][ 'options' ] ) ) { 
  277. $field['settings'][ 'options' ] = apply_filters( 'ninja_forms_render_options', $field['settings'][ 'options' ], $field['settings'] ); 
  278.  
  279. if (isset($field['settings']['default'])) { 
  280. $default_value = apply_filters('ninja_forms_render_default_value', $field['settings']['default'], $field_type, $field['settings']); 
  281.  
  282. $default_value = preg_replace( '/{.*}/', '', $default_value ); 
  283.  
  284. if ($default_value) { 
  285. $field['settings']['value'] = $default_value; 
  286.  
  287. ob_start(); 
  288. do_shortcode( $field['settings']['value'] ); 
  289. $ob = ob_get_clean(); 
  290.  
  291. if( $ob ) { 
  292. $field['settings']['value'] = $ob; 
  293.  
  294. // TODO: Find a better way to do this. 
  295. if ('shipping' == $field['settings']['type']) { 
  296. $field['settings']['shipping_cost'] = preg_replace ('/[^\d, \.]/', '', $field['settings']['shipping_cost'] ); 
  297. $field['settings']['shipping_cost'] = str_replace( Ninja_Forms()->get_setting( 'currency_symbol' ), '', $field['settings']['shipping_cost'] ); 
  298. $field['settings']['shipping_cost'] = number_format($field['settings']['shipping_cost'], 2); 
  299. } elseif ('product' == $field['settings']['type']) { 
  300. // TODO: Does the currency marker need to stripped here? 
  301. $field['settings']['product_price'] = preg_replace ('/[^\d, \.]/', '', $field['settings']['product_price'] ); 
  302. $field['settings']['product_price'] = str_replace( Ninja_Forms()->get_setting( 'currency_symbol' ), '', $field['settings']['product_price'] ); 
  303. $field['settings']['product_price'] = number_format($field['settings']['product_price'], 2); 
  304. } elseif ('total' == $field['settings']['type']) { 
  305. if( ! isset( $field[ 'settings' ][ 'value' ] ) ) $field[ 'settings' ][ 'value' ] = 0; 
  306. $field['settings']['value'] = number_format($field['settings']['value'], 2); 
  307.  
  308. $field['settings']['element_templates'] = $templates; 
  309. $field['settings']['old_classname'] = $field_class->get_old_classname(); 
  310. $field['settings']['wrap_template'] = $field_class->get_wrap_template(); 
  311.  
  312. $fields[] = apply_filters( 'ninja_forms_localize_field_settings_' . $field_type, $field['settings'], $form ); 
  313.  
  314. // Output Form Container 
  315. do_action( 'ninja_forms_before_container_preview', $form_id, $form[ 'settings' ], $fields ); 
  316. Ninja_Forms::template( 'display-form-container.html.php', compact( 'form_id' ) ); 
  317.  
  318. ?> 
  319. <!-- TODO: Move to Template File. --> 
  320. <script> 
  321. // Maybe initialize nfForms object 
  322. var nfForms = nfForms || []; 
  323.  
  324. // Build Form Data 
  325. var form = []; 
  326. form.id = '<?php echo $form['id']; ?>'; 
  327. form.settings = JSON.parse( '<?php echo WPN_Helper::addslashes( wp_json_encode( $form['settings'] ) ); ?>' ); 
  328.  
  329. form.fields = JSON.parse( '<?php echo WPN_Helper::addslashes( wp_json_encode( $fields ) ); ?>' ); 
  330.  
  331. // Add Form Data to nfForms object 
  332. nfForms.push( form ); 
  333. </script> 
  334.  
  335. <?php 
  336. self::enqueue_scripts( $form_id ); 
  337.  
  338. public static function enqueue_scripts( $form_id ) 
  339. $form = Ninja_Forms()->form( $form_id )->get(); 
  340. $is_preview = ( $form->get_tmp_id() ); 
  341.  
  342. $ver = Ninja_Forms::VERSION; 
  343. $js_dir = Ninja_Forms::$url . 'assets/js/min/'; 
  344. $css_dir = Ninja_Forms::$url . 'assets/css/'; 
  345.  
  346.  
  347. switch( Ninja_Forms()->get_setting( 'opinionated_styles' ) ) { 
  348. case 'light': 
  349. wp_enqueue_style( 'nf-display', $css_dir . 'display-opinions-light.css' ); 
  350. wp_enqueue_style( 'nf-font-awesome', $css_dir . 'font-awesome.min.css' ); 
  351. break; 
  352. case 'dark': 
  353. wp_enqueue_style( 'nf-display', $css_dir . 'display-opinions-dark.css' ); 
  354. wp_enqueue_style( 'nf-font-awesome', $css_dir . 'font-awesome.min.css' ); 
  355. break; 
  356. default: 
  357. wp_enqueue_style( 'nf-display', $css_dir . 'display-structure.css' ); 
  358.  
  359. if( $is_preview || self::form_uses_recaptcha( $form_id ) ) { 
  360. $recaptcha_lang = Ninja_Forms()->get_setting('recaptcha_lang'); 
  361. wp_enqueue_script('google-recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_lang, array( 'jquery' ), $ver ); 
  362.  
  363. if( $is_preview || self::form_uses_datepicker( $form_id ) ) { 
  364. wp_enqueue_style( 'pikaday-responsive', $css_dir . 'pikaday-package.css', $ver ); 
  365. wp_enqueue_script('nf-front-end--datepicker', $js_dir . 'front-end--datepicker.min.js', array( 'jquery' ), $ver ); 
  366.  
  367. if( $is_preview || self::form_uses_inputmask( $form_id ) ) { 
  368. wp_enqueue_script('nf-front-end--inputmask', $js_dir . 'front-end--inputmask.min.js', array( 'jquery' ), $ver ); 
  369.  
  370. if( $is_preview || self::form_uses_rte( $form_id ) ) { 
  371. if( $is_preview || self::form_uses_textarea_media( $form_id ) ) { 
  372. wp_enqueue_media(); 
  373.  
  374. wp_enqueue_style( 'summernote', $css_dir . 'summernote.css' , $ver ); 
  375. wp_enqueue_style( 'codemirror', $css_dir . 'codemirror.css' , $ver ); 
  376. wp_enqueue_style( 'codemirror-monokai', $css_dir . 'monokai-theme.css', $ver ); 
  377. wp_enqueue_script('nf-front-end--rte', $js_dir . 'front-end--rte.min.js', array( 'jquery' ), $ver ); 
  378.  
  379. if( $is_preview || self::form_uses_helptext( $form_id ) ) { 
  380. wp_enqueue_style( 'jBox', $css_dir . 'jBox.css', $ver ); 
  381. wp_enqueue_script('nf-front-end--helptext', $js_dir . 'front-end--helptext.min.js', array( 'jquery' ), $ver ); 
  382.  
  383. if( $is_preview || self::form_uses_starrating( $form_id ) ) { 
  384. wp_enqueue_style( 'rating', $css_dir . 'rating.css', Ninja_Forms::VERSION ); 
  385. wp_enqueue_script('nf-front-end--starrating', $js_dir . 'front-end--starrating.min.js', array( 'jquery' ), $ver ); 
  386.  
  387. wp_enqueue_script( 'nf-front-end-deps', $js_dir . 'front-end-deps.js', array( 'jquery', 'backbone' ), $ver ); 
  388. wp_enqueue_script( 'nf-front-end', $js_dir . 'front-end.js', array( 'nf-front-end-deps' ), $ver ); 
  389.  
  390. wp_localize_script( 'nf-front-end', 'nfi18n', Ninja_Forms::config( 'i18nFrontEnd' ) ); 
  391.  
  392. $data = apply_filters( 'ninja_forms_render_localize_script_data', array( 
  393. 'ajaxNonce' => wp_create_nonce( 'ninja_forms_display_nonce' ),  
  394. 'adminAjax' => admin_url( 'admin-ajax.php' ),  
  395. 'requireBaseUrl' => Ninja_Forms::$url . 'assets/js/',  
  396. 'use_merge_tags' => array(),  
  397. 'opinionated_styles' => Ninja_Forms()->get_setting( 'opinionated_styles' ) 
  398. )); 
  399.  
  400. foreach( Ninja_Forms()->fields as $field ) { 
  401. foreach( $field->use_merge_tags() as $merge_tag ) { 
  402. $data[ 'use_merge_tags' ][ $merge_tag ][ $field->get_type() ] = $field->get_type(); 
  403.  
  404. wp_localize_script( 'nf-front-end', 'nfFrontEnd', $data ); 
  405.  
  406. do_action( 'ninja_forms_enqueue_scripts', array( 'form_id' => $form_id ) ); 
  407.  
  408. do_action( 'nf_display_enqueue_scripts' ); 
  409.  
  410. protected static function load_template( $file_name = '' ) 
  411. if( ! $file_name ) return; 
  412.  
  413. if( self::is_template_loaded( $file_name ) ) return; 
  414.  
  415. self::$loaded_templates[] = $file_name; 
  416.  
  417. public static function output_templates() 
  418. // Build File Path Hierarchy 
  419. $file_paths = apply_filters( 'ninja_forms_field_template_file_paths', array( 
  420. get_template_directory() . '/ninja-forms/templates/',  
  421. )); 
  422.  
  423. $file_paths[] = Ninja_Forms::$dir . 'includes/Templates/'; 
  424.  
  425. // Search for and Output File Templates 
  426. foreach( self::$loaded_templates as $file_name ) { 
  427.  
  428. foreach( $file_paths as $path ) { 
  429.  
  430. if( file_exists( $path . "$file_name.html" ) ) { 
  431. echo file_get_contents( $path . "$file_name.html" ); 
  432. break; 
  433.  
  434. ?> 
  435. <script> 
  436. var post_max_size = '<?php echo WPN_Helper::string_to_bytes( ini_get('post_max_size') ); ?>'; 
  437. var upload_max_filesize = '<?php echo WPN_Helper::string_to_bytes( ini_get( 'upload_max_filesize' ) ); ?>'; 
  438. var wp_memory_limit = '<?php echo WPN_Helper::string_to_bytes( WP_MEMORY_LIMIT ); ?>'; 
  439. </script> 
  440. <?php 
  441.  
  442. // Action to Output Custom Templates 
  443. do_action( 'ninja_forms_output_templates' ); 
  444.  
  445. /** 
  446. * UTILITY 
  447. */ 
  448.  
  449. protected static function is_template_loaded( $template_name ) 
  450. return ( in_array( $template_name, self::$loaded_templates ) ) ? TRUE : FALSE ; 
  451.  
  452. protected static function form_uses_recaptcha( $form_id ) 
  453. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  454. if( 'recaptcha' == $field->get_setting( 'type' ) ) return true; 
  455. return false; 
  456.  
  457. protected static function form_uses_datepicker( $form_id ) 
  458. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  459. if( 'date' == $field->get_setting( 'type' ) ) return true; 
  460. return false; 
  461.  
  462. protected static function form_uses_inputmask( $form_id ) 
  463. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  464. if( $field->get_setting( 'mask' ) ) return true; 
  465. return false; 
  466.  
  467. protected static function form_uses_rte( $form_id ) 
  468. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  469. if( $field->get_setting( 'textarea_rte' ) ) return true; 
  470. return false; 
  471.  
  472. protected static function form_uses_textarea_media( $form_id ) 
  473. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  474. if( $field->get_setting( 'textarea_media' ) ) return true; 
  475. return false; 
  476.  
  477. protected static function form_uses_helptext( $form_id ) 
  478. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  479. if( strip_tags( $field->get_setting( 'help_text' ) ) ) return true; 
  480. return false; 
  481.  
  482. protected static function form_uses_starrating( $form_id ) 
  483. foreach( Ninja_Forms()->form( $form_id )->get_fields() as $field ) { 
  484. if( 'starrating' == $field->get_setting( 'type' ) ) return true; 
  485. return false; 
  486.  
  487. } // End Class NF_Display_Render 
.