WC_Admin::admin_footer_text
Change the admin footer text on WooCommerce admin pages.
Метод класса: WC_Admin{}
Хуки из метода
Возвращает
Строку.
Использование
$WC_Admin = new WC_Admin(); $WC_Admin->admin_footer_text( $footer_text );
- $footer_text(строка) (обязательный)
- Footer text to be rendered.
Список изменений
| С версии 2.3 | Введена. |
Код WC_Admin::admin_footer_text() WC Admin::admin footer text WC 10.4.0
public function admin_footer_text( $footer_text ) {
if ( ! current_user_can( 'manage_woocommerce' ) || ! function_exists( 'wc_get_screen_ids' ) ) {
return $footer_text;
}
$current_screen = get_current_screen();
$wc_pages = array_merge( wc_get_screen_ids(), array( 'woocommerce_page_wc-admin' ) );
// Set only WC pages.
$wc_pages = array_diff( $wc_pages, array( 'profile', 'user-edit' ) );
/**
* Filter to determine if admin footer text should be displayed.
*
* @since 2.3
*/
if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages, true ) ) ) {
// Change the footer text.
if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
$footer_text = sprintf(
/* translators: 1: WooCommerce 2:: five stars */
__( 'If you like %1$s please leave us a %2$s rating. A huge thanks in advance!', 'woocommerce' ),
sprintf( '<strong>%s</strong>', esc_html__( 'WooCommerce', 'woocommerce' ) ),
'<a href="https://wordpress.org/support/plugin/woocommerce/reviews?rate=5#new-post" target="_blank" class="wc-rating-link" aria-label="' . esc_attr__( 'five star', 'woocommerce' ) . '" data-rated="' . esc_attr__( 'Thanks :)', 'woocommerce' ) . '">★★★★★</a>'
);
$script = "
(function() {
'use strict';
var ratingLink = document.querySelector('a.wc-rating-link');
if (ratingLink) {
ratingLink.addEventListener('click', function(e) {
var link = e.currentTarget;
var formData = new FormData();
formData.append('action', 'woocommerce_rated');
fetch('" . esc_js( WC()->ajax_url() ) . "', {
method: 'POST',
body: formData,
credentials: 'same-origin'
});
var parent = link.parentElement;
if (parent) {
parent.textContent = link.getAttribute('data-rated');
}
});
}
})();
";
$handle = 'wc-admin-footer-rating';
wp_register_script( $handle, '', array(), WC_VERSION, true );
wp_enqueue_script( $handle );
wp_add_inline_script( $handle, $script );
} else {
$footer_text = __( 'Thank you for selling with WooCommerce.', 'woocommerce' );
}
}
return '<span id="footer-thankyou">' . $footer_text . '</span>';
}