F
F
Fqwd1232020-11-23 12:45:52
WordPress
Fqwd123, 2020-11-23 12:45:52

Display information in the admin panel?

I have a function that calculates the sum of the cost of all products on the site. How can this information be displayed in the admin panel so that the customer can view it, no matter where, just so that the admin panel is displayed somewhere

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2020-11-23
@Fqwd123

You can add this information not even to the admin panel, but directly to the front on any hook before / after the goods. Just wrap the function in current_user_can( 'manage_options' )so that this text can be seen by someone who has administrator rights

function goods_value() {
  if ( current_user_can( 'manage_options' ) ) {
    echo '<p>Стоимость товаров на этой странице: ' . $p . '</p>';
    echo '<p>Стоимость товаров в категории: ' . $c . '</p>';
    echo '<p>Стоимость всех товаров на сайте: ' . $s . '</p>';
  }
}

I
Ivan, 2020-11-23
@vvvpolimentor

The add_menu_page() function will help you . This will display the item in the admin menu.
This article will also help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question