ninja_forms_admin_js

The Ninja Forms ninja forms admin js function.

Description

ninja_forms_admin_js(); 

Usage

  1. if ( !function_exists( 'ninja_forms_admin_js' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/scripts.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ninja_forms_admin_js(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/scripts.php  
  1. function ninja_forms_admin_js() { 
  2. global $version_compare, $public_query_vars; 
  3.  
  4. $form_id = isset ( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : ''; 
  5.  
  6. if ( defined( 'NINJA_FORMS_JS_DEBUG' ) && NINJA_FORMS_JS_DEBUG ) { 
  7. $suffix = ''; 
  8. $src = 'dev'; 
  9. } else { 
  10. $suffix = '.min'; 
  11. $src = 'min'; 
  12.  
  13. $plugin_settings = nf_get_settings(); 
  14. if(isset($plugin_settings['date_format'])) { 
  15. $date_format = $plugin_settings['date_format']; 
  16. }else{ 
  17. $date_format = 'm/d/Y'; 
  18.  
  19. $date_format = ninja_forms_date_to_datepicker($date_format); 
  20.  
  21. $datepicker_args = array(); 
  22. if ( !empty( $date_format ) ) { 
  23. $datepicker_args['dateFormat'] = $date_format; 
  24.  
  25. wp_enqueue_script('ninja-forms-admin',  
  26. NINJA_FORMS_URL . 'js/' . $src .'/ninja-forms-admin' . $suffix . '.js?nf_ver=' . NF_PLUGIN_VERSION,  
  27. array('jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'nf-admin-modal' ) ); 
  28.  
  29. wp_localize_script( 'ninja-forms-admin', 'ninja_forms_settings', array( 'nf_ajax_nonce' => wp_create_nonce( 'nf_ajax'), 'form_id' => $form_id, 'datepicker_args' => apply_filters( 'ninja_forms_admin_forms_datepicker_args', $datepicker_args ), 'add_fav_prompt' => __( 'What would you like to name this favorite?', 'ninja-forms' ), 'add_fav_error' => __( 'You must supply a name for this favorite.', 'ninja-forms' ), 'deactivate_all_licenses_confirm' => __( 'Really deactivate all licenses?', 'ninja-forms' ) ) ); 
  30. wp_localize_script( 'ninja-forms-admin', 'nf_conversion_title', __( 'Reset the form conversion process for v2.9+', 'ninja-forms' ) ); 
  31. wp_localize_script( 'ninja-forms-admin', 'nf_nuke_title', __( 'Remove ALL Ninja Forms data upon uninstall?', 'ninja-forms' ) ); 
  32.  
  33.  
  34. if ( isset ( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ninja-forms' && isset ( $_REQUEST['tab'] ) ) { 
  35. wp_enqueue_script( 'nf-builder',  
  36. NINJA_FORMS_URL . 'assets/js/' . $src .'/builder' . $suffix . '.js?nf_ver=' . NF_PLUGIN_VERSION,  
  37. array( 'backbone' ) ); 
  38.  
  39. if ( '' != $form_id ) { 
  40. $fields = Ninja_Forms()->form( $form_id )->fields; 
  41.  
  42. $current_tab = ninja_forms_get_current_tab(); 
  43. $current_page = isset ( $_REQUEST['page'] ) ? esc_html( $_REQUEST['page'] ) : ''; 
  44.  
  45. foreach ( $fields as $field_id => $field ) { 
  46. $fields[ $field_id ]['metabox_state'] = 0; 
  47.  
  48. $form_status = Ninja_Forms()->form( $form_id )->get_setting( 'status' ); 
  49. $form_title = Ninja_Forms()->form( $form_id )->get_setting( 'form_title' ); 
  50.  
  51. wp_localize_script( 'nf-builder', 'nf_admin', array( 'edit_form_text' => __( 'Edit Form', 'ninja-forms' ), 'form_title' => $form_title, 'form_status' => $form_status, 'fields' => $fields, 'saved_text' => __( 'Saved', 'ninja-forms' ), 'save_text' => __( 'Save', 'ninja-forms' ), 'saving_text' => __( 'Saving...', 'ninja-forms' ), 'remove_field' => __( 'Remove this field? It will be removed even if you do not save.', 'ninja-forms' ) ) ); 
  52.  
  53. $reserved_terms = array(  
  54. 'attachment',  
  55. 'attachment_id',  
  56. 'author',  
  57. 'author_name',  
  58. 'calendar',  
  59. 'cat',  
  60. 'category',  
  61. 'category__and',  
  62. 'category__in',  
  63. 'category__not_in',  
  64. 'category_name',  
  65. 'comments_per_page',  
  66. 'comments_popup',  
  67. 'customize_messenger_channel',  
  68. 'customized',  
  69. 'cpage',  
  70. 'day',  
  71. 'debug',  
  72. error,  
  73. 'exact',  
  74. 'feed',  
  75. 'hour',  
  76. 'link_category',  
  77. 'm',  
  78. 'minute',  
  79. 'monthnum',  
  80. 'more',  
  81. 'name',  
  82. 'nav_menu',  
  83. 'nonce',  
  84. 'nopaging',  
  85. 'offset',  
  86. 'order',  
  87. 'orderby',  
  88. 'p',  
  89. 'page',  
  90. 'page_id',  
  91. 'paged',  
  92. 'pagename',  
  93. 'pb',  
  94. 'perm',  
  95. 'post',  
  96. 'post__in',  
  97. 'post__not_in',  
  98. 'post_format',  
  99. 'post_mime_type',  
  100. 'post_status',  
  101. 'post_tag',  
  102. 'post_type',  
  103. 'posts',  
  104. 'posts_per_archive_page',  
  105. 'posts_per_page',  
  106. 'preview',  
  107. 'robots',  
  108. 's',  
  109. 'search',  
  110. 'second',  
  111. 'sentence',  
  112. 'showposts',  
  113. 'static',  
  114. 'subpost',  
  115. 'subpost_id',  
  116. 'tag',  
  117. 'tag__and',  
  118. 'tag__in',  
  119. 'tag__not_in',  
  120. 'tag_id',  
  121. 'tag_slug__and',  
  122. 'tag_slug__in',  
  123. 'taxonomy',  
  124. 'tb',  
  125. 'term',  
  126. 'theme',  
  127. 'type',  
  128. 'w',  
  129. 'withcomments',  
  130. 'withoutcomments',  
  131. 'year',  
  132. ); 
  133.  
  134. wp_localize_script( 'nf-builder', 'wp_reserved_terms', $reserved_terms );