acf_controller_input

Acf_controller_input.

Defined (1)

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

/core/controllers/input.php  
  1. class acf_controller_input 
  2.  
  3. /** 
  4. * __construct 
  5. * @description:  
  6. * @since 3.1.8 
  7. * @created: 23/06/12 
  8. */ 
  9.  
  10. function __construct() 
  11. // actions 
  12. add_action('acf/input/admin_head', array($this, 'input_admin_head')); 
  13. add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts')); 
  14.  
  15.  
  16. /** 
  17. * input_admin_head 
  18. * action called when rendering the head of an admin screen. Used primarily for passing PHP to JS 
  19. * @type action 
  20. * @date 27/05/13 
  21. * @param N/A 
  22. * @return N/A 
  23. */ 
  24.  
  25. function input_admin_head() 
  26. // global 
  27. global $wp_version, $post; 
  28.  
  29.  
  30. // vars 
  31. $toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', array() ); 
  32. $post_id = 0; 
  33. if( $post ) 
  34. $post_id = intval( $post->ID ); 
  35.  
  36.  
  37. // l10n 
  38. $l10n = apply_filters( 'acf/input/admin_l10n', array( 
  39. 'core' => array( 
  40. 'expand_details' => __("Expand Details", 'acf'),  
  41. 'collapse_details' => __("Collapse Details", 'acf') 
  42. ),  
  43. 'validation' => array( 
  44. 'error' => __("Validation Failed. One or more fields below are required.", 'acf') 
  45. )); 
  46.  
  47.  
  48. // options 
  49. $o = array( 
  50. 'post_id' => $post_id,  
  51. 'nonce' => wp_create_nonce( 'acf_nonce' ),  
  52. 'admin_url' => admin_url(),  
  53. 'ajaxurl' => admin_url( 'admin-ajax.php' ),  
  54. 'wp_version' => $wp_version 
  55. ); 
  56.  
  57.  
  58. // toolbars 
  59. $t = array(); 
  60.  
  61. if( is_array($toolbars) ) { foreach( $toolbars as $label => $rows ) { 
  62.  
  63. $label = sanitize_title( $label ); 
  64. $label = str_replace('-', '_', $label); 
  65.  
  66. $t[ $label ] = array(); 
  67.  
  68. if( is_array($rows) ) { foreach( $rows as $k => $v ) { 
  69.  
  70. $t[ $label ][ 'theme_advanced_buttons' . $k ] = implode(', ', $v); 
  71.  
  72. }} 
  73. }} 
  74.  
  75.  
  76. ?> 
  77. <script type="text/javascript"> 
  78. (function($) { 
  79.  
  80. // vars 
  81. acf.post_id = <?php echo is_numeric($post_id) ? $post_id : '"' . $post_id . '"'; ?>; 
  82. acf.nonce = "<?php echo wp_create_nonce( 'acf_nonce' ); ?>"; 
  83. acf.admin_url = "<?php echo admin_url(); ?>"; 
  84. acf.ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>"; 
  85. acf.wp_version = "<?php echo $wp_version; ?>"; 
  86.  
  87.  
  88. // new vars 
  89. acf.o = <?php echo json_encode( $o ); ?>; 
  90. acf.l10n = <?php echo json_encode( $l10n ); ?>; 
  91. acf.fields.wysiwyg.toolbars = <?php echo json_encode( $t ); ?>; 
  92.  
  93. })(jQuery);  
  94. </script> 
  95. <?php 
  96.  
  97.  
  98.  
  99. /** 
  100. * input_admin_enqueue_scripts 
  101. * @description:  
  102. * @since: 3.6 
  103. * @created: 30/01/13 
  104. */ 
  105.  
  106. function input_admin_enqueue_scripts() 
  107.  
  108. // scripts 
  109. wp_enqueue_script(array( 
  110. 'jquery',  
  111. 'jquery-ui-core',  
  112. 'jquery-ui-tabs',  
  113. 'jquery-ui-sortable',  
  114. 'wp-color-picker',  
  115. 'thickbox',  
  116. 'media-upload',  
  117. 'acf-input',  
  118. 'acf-datepicker',  
  119. )); 
  120.  
  121.  
  122. // 3.5 media gallery 
  123. if( function_exists('wp_enqueue_media') && !did_action( 'wp_enqueue_media' )) 
  124. wp_enqueue_media(); 
  125.  
  126.  
  127. // styles 
  128. wp_enqueue_style(array( 
  129. 'thickbox',  
  130. 'wp-color-picker',  
  131. 'acf-global',  
  132. 'acf-input',  
  133. 'acf-datepicker',  
  134. )); 
  135.