Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Регистрируем поле по всем правилом, тут лишь само поле
- Field::make( 'html', 'order_info_data' )
- ->set_html( '<div class="order_info_data"></div>' ),
- Field::make( 'association', 'products' )
- ->set_min( 5 ),
- ] );
- // Заполняем поле любым html
- add_action( 'admin_print_footer_scripts', 'insert_html_orders' );
- function insert_html_orders() {
- $post_id = (int) filter_input( INPUT_GET, 'post' );
- $html = 'Пока заказов нет.';
- if ( $post_id ) {
- $data = carbon_get_post_meta( $post_id, 'products' );
- $html = sprintf( '<pre><code style="display: block;">%s</code></pre>', print_r( $data, true ) );
- }
- // Обязательно строку (html) надо так пропустить
- $json = wp_json_encode( $html );
- ?>
- <script>
- jQuery(document).ready(function ($) {
- var html = <?php echo $json;?>;
- $('.order_info_data').html(html);
- });
- </script>
- <?php
- }
Add Comment
Please, Sign In to add comment