campusboy

Для Влада

May 28th, 2020
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. // Регистрируем поле по всем правилом, тут лишь само поле
  4. Field::make( 'html', 'order_info_data' )
  5.      ->set_html( '<div class="order_info_data"></div>' ),
  6.             Field::make( 'association', 'products' )
  7.                  ->set_min( 5 ),
  8.         ] );
  9.  
  10. // Заполняем поле любым html
  11. add_action( 'admin_print_footer_scripts', 'insert_html_orders' );
  12.  
  13. function insert_html_orders() {
  14.     $post_id = (int) filter_input( INPUT_GET, 'post' );
  15.     $html    = 'Пока заказов нет.';
  16.  
  17.     if ( $post_id ) {
  18.         $data = carbon_get_post_meta( $post_id, 'products' );
  19.         $html = sprintf( '<pre><code style="display: block;">%s</code></pre>', print_r( $data, true ) );
  20.     }
  21.  
  22.     // Обязательно строку (html) надо так пропустить
  23.     $json = wp_json_encode( $html );
  24.     ?>
  25.     <script>
  26.         jQuery(document).ready(function ($) {
  27.             var html = <?php echo $json;?>;
  28.             $('.order_info_data').html(html);
  29.         });
  30.     </script>
  31.     <?php
  32. }
Add Comment
Please, Sign In to add comment