sub-settings.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. /*
  3. *
  4. * Function used to output the submission sorting option on the backend.
  5. *
  6. * @since 2.9
  7. * @returns void
  8. */
  9. function nf_edit_field_sort_numeric( $field_id, $field_data ) {
  10. global $ninja_forms_fields;
  11. $field_row = ninja_forms_get_field_by_id( $field_id );
  12. $field_type = $field_row['type'];
  13. if ( $ninja_forms_fields[$field_type]['process_field'] && $field_type != '_calc' ) {
  14. if ( isset ( $field_data['admin_label'] ) ) {
  15. $admin_label = $field_data['admin_label'];
  16. } else {
  17. $admin_label = '';
  18. }
  19. if ( isset ( $field_data['num_sort'] ) ) {
  20. $num_sort = $field_data['num_sort'];
  21. } else {
  22. $num_sort = '';
  23. }
  24. ?>
  25. <div class="description description-wide">
  26. <?php
  27. ninja_forms_edit_field_el_output( $field_id, 'checkbox', __( 'Sort as numeric', 'ninja-forms' ), 'num_sort', $num_sort, 'wide', '', '', __( 'If this box is checked, this column in the submissions table will sort by number.', 'ninja-forms' ) );
  28. ?>
  29. </div>
  30. <?php
  31. }
  32. }
  33. add_action( 'nf_edit_field_advanced', 'nf_edit_field_sort_numeric', 9, 2 );
  34. /*
  35. *
  36. * Function used to output our admin label option on the backend.
  37. *
  38. * @since 2.9
  39. * @returns void
  40. */
  41. function nf_edit_field_admin_label( $field_id, $field_data ) {
  42. global $ninja_forms_fields;
  43. $field_row = ninja_forms_get_field_by_id( $field_id );
  44. $field_type = $field_row['type'];
  45. if ( $ninja_forms_fields[$field_type]['process_field'] ) {
  46. if ( isset ( $field_data['admin_label'] ) ) {
  47. $admin_label = $field_data['admin_label'];
  48. } else {
  49. $admin_label = '';
  50. }
  51. if ( isset ( $field_data['num_sort'] ) ) {
  52. $num_sort = $field_data['num_sort'];
  53. } else {
  54. $num_sort = '';
  55. }
  56. ?>
  57. <div class="description description-wide">
  58. <?php
  59. ninja_forms_edit_field_el_output( $field_id, 'text', __( 'Admin Label', 'ninja-forms' ), 'admin_label', $admin_label, 'wide', '', 'widefat code', __( 'This is the label used when viewing/editing/exporting submissions.', 'ninja-forms' ) );
  60. ?>
  61. </div>
  62. <?php
  63. }
  64. }
  65. add_action( 'nf_edit_field_advanced', 'nf_edit_field_admin_label', 10, 2 );