最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - where is admin footer?

programmeradmin2浏览0评论

hi im working on my new wordpress website. and i wanted to add custom order status in my woocommerce order status and i found this code:-

function custom_bulk_admin_footer() {
            global $post_type;

            if ( $post_type == 'shop_order' ) {
                ?>
                    <script type="text/javascript">
                        jQuery(document).ready(function() {
                            jQuery('<option>').val('mark_invoiced').text('<?php _e( 'Mark invoiced', 'textdomain' ); ?>').appendTo("select[name='action']");
                            jQuery('<option>').val('mark_invoiced').text('<?php _e( 'Mark invoiced', 'textdomain' ); ?>').appendTo("select[name='action2']");   
                        });
                    </script>
                <?php
            }
        }

the question is , where should i put the code ? should i put it in my theme function.php ? or put it in admin_footer? if so can someone navigate me to the admin_footer section?

hi im working on my new wordpress website. and i wanted to add custom order status in my woocommerce order status and i found this code:-

function custom_bulk_admin_footer() {
            global $post_type;

            if ( $post_type == 'shop_order' ) {
                ?>
                    <script type="text/javascript">
                        jQuery(document).ready(function() {
                            jQuery('<option>').val('mark_invoiced').text('<?php _e( 'Mark invoiced', 'textdomain' ); ?>').appendTo("select[name='action']");
                            jQuery('<option>').val('mark_invoiced').text('<?php _e( 'Mark invoiced', 'textdomain' ); ?>').appendTo("select[name='action2']");   
                        });
                    </script>
                <?php
            }
        }

the question is , where should i put the code ? should i put it in my theme function.php ? or put it in admin_footer? if so can someone navigate me to the admin_footer section?

Share Improve this question edited Jul 23, 2020 at 8:50 Jacob Peattie 44.1k10 gold badges50 silver badges64 bronze badges asked Jul 23, 2020 at 6:53 Alif AzharAlif Azhar 1 1
  • The problem here is that you have the function, but no action hook - your function will execute where you tell it to, providing you have the correct information. What you need to find is the WooCommerce hook that best suits where this should be placed. Then it'll be add_action( 'the_woocommerce_hook', 'custom_bulk_admin_footer' ); You would then place it all in your functions.php. Additionally, make sure you updated the function name to something unique and also make sure your textdomain matches your theme's textdomain. – Tony Djukic Commented Jul 23, 2020 at 16:11
Add a comment  | 

1 Answer 1

Reset to default 0

So the question that you found this code from here says that they added this to the admin_footer action. So you could add that custom_bulk_admin_footer to your functions.php, and then hook it into the admin_footer action with this after the function:

add_action('admin_footer', 'custom_bulk_admin_footer');

Obviously you need to change the jQuery code to do what you want inside the function too ;-)

HTH

发布评论

评论列表(0)

  1. 暂无评论