Appears in the admin area at the top of the page. Thank you for downloading the theme. Buy premium =)

enter image description here

enter image description here

I turned it off in styles

.notice.notice-success.is-dismissible { background-color: #31a3dd; color: #fff; display: none; } 

But I would like to disable PHP in general so that it does not load at all. And now I have it just hidden. Which folder to go to. Where to dig? Or how to find the function that is responsible for displaying such a message is to remove or disable it ..

    2 answers 2

    What you did - you killed all admin notices. From any plugins, themes and kernels.

    You need to download the site to a local computer and search all the theme files for the text "Thank you for installing". It is better to use modern IDE type PhpStorm for this - there is file indexing, and any search is done instantly. Next, examine the code for the presence of hooks and cancel the output via hooks in the child theme. It is better not to edit the main theme, because when you update your edits will fly.

      After the board, KAGG Design did the following.

      1. Found the code that is responsible for the output of this biliberdy.
      2. Changed the code in the child theme so that when the theme is updated, the code does not change.

      So, I tell in order.

      We download the whole topic (original, not a child to the local computer). I have a program Sublime Text (free). With it, open the folder with the theme:

      enter image description here

      When we have a project open, press the key combination ctrl + shift + f to search for text in the entire project. Previously, I did not know this and went through all the files, and it took a lot of time.

      The system finds the location of lines.

      enter image description here

      Now we see where the lines are and in which file.

      I found out that this is a separate function that needs to be overridden. Of course, we can delete, but when you update the topic, everything will return to its place.

      Here is my function along with the hook:

       add_action( 'admin_notices', 'guardian_activation_notice' ); function guardian_activation_notice(){ //wp_register_style( 'custom_admin_css', get_template_directory_uri() . '/core/admin/admin-banner.css'); wp_enqueue_style( 'custom_admin_css' ); wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome-4.7.0/css/font-awesome.css'); wp_enqueue_style('admin', get_template_directory_uri() .'/core/admin/admin-themes.css'); ?> <div class="notice notice-success is-dismissible"> <p class="notice-text"><?php $theme_info = wp_get_theme(); printf( esc_html__('Thank you for installing %1$s - Version %2$s, ', 'guardian'), esc_html( $theme_info->Name ), esc_html( $theme_info->Version ) ); echo esc_html__( 'For More info about Premium Products & offers, Do visit our welcome page.', 'guardian' ); ?></p> <p class="notic-gif"><a class="pro" target="_self" href="<?php echo admin_url('/themes.php?page=guardian') ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/theme-gif02.gif"></a></p> </div> <?php } ?> 

      I redefined the function in this way.

      1. Unlinked the function from the hook by creating a new function.
      2. I hung up an alternative function on the new hook, in which I deleted the whole div, which disturbed me.

      Here is the code in the child thread.

       //Переопределяем родительскую функцию function remove_guardian_activation_notice(){ remove_action( 'admin_notices', 'guardian_activation_notice' ); } add_action( 'admin_notices', 'remove_guardian_activation_notice', 0 ); add_action( 'admin_notices', 'guardian_activation_notice_alternate' ); function guardian_activation_notice_alternate(){ //wp_register_style( 'custom_admin_css', get_template_directory_uri() . '/core/admin/admin-banner.css'); wp_enqueue_style( 'custom_admin_css' ); wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/font-awesome-4.7.0/css/font-awesome.css'); wp_enqueue_style('admin', get_template_directory_uri() .'/core/admin/admin-themes.css'); } ?> 

      That's how I did it.

      Since I do not fully understand the topic of hooks in WordPress, then if someone can explain what could be shortened in the code to make it more understandable, it would be good.

      • I would have done wrong. You cancel guardian_activation_notice at wp_loaded . Not the fact that at this moment the hook is already defined. If it is not defined, then cancellation will not work. Use the lower priority in the admin_notices action admin_notices to cancel the hook. Then it works exactly: add_action( 'admin_notices', 'remove_guardian_activation_notice', 0 ); - KAGG Design
      • In general, I corrected the answer and plied it. - KAGG Design 2:07 pm
      • one
        I advise you to accept your answer (tick the box below) when the system allows - i.e. two days later. The answer is correct and detailed, it will help users who are looking for the answer to a similar question. - KAGG Design 2:26 pm
      • add_action ('admin_notices', 'remove_guardian_activation_notice', 0); And what does 0 mean at the end? The fact is that when I didn’t enter zero, then nothing works .. - Dima
      • 0 - priority of the action. the default is 10. The lower the priority, the earlier the function will work. If you specify a priority below 10, WordPress calls your remove_guardian_activation_notice function before guardian_activation_notice , which allows your function to override the standard one. Read the documentation about hooks here: wp-kama.ru/hooks - KAGG Design