/home/techb158/balacoffee.com/wp-content/plugins/polylang/src/admin
Edit: /home/techb158/balacoffee.com/wp-content/plugins/polylang/src/admin/admin-notices.php (7776B)
options = $polylang->options;
add_action( 'admin_init', array( $this, 'hide_notice' ) );
add_action( 'admin_notices', array( $this, 'display_notices' ) );
}
/**
* Add a custom notice
*
* @since 2.3.9
*
* @param string $name Notice name
* @param string $html Content of the notice
* @return void
*/
public static function add_notice( $name, $html ) {
self::$notices[ $name ] = $html;
}
/**
* Get custom notices.
*
* @since 2.3.9
*
* @return string[]
*/
public static function get_notices() {
return self::$notices;
}
/**
* Has a notice been dismissed?
*
* @since 2.3.9
*
* @param string $notice Notice name
* @return bool
*/
public static function is_dismissed( $notice ) {
$dismissed = get_option( 'pll_dismissed_notices', array() );
// Handle legacy user meta
$dismissed_meta = get_user_meta( get_current_user_id(), 'pll_dismissed_notices', true );
if ( is_array( $dismissed_meta ) ) {
if ( array_diff( $dismissed_meta, $dismissed ) ) {
$dismissed = array_merge( $dismissed, $dismissed_meta );
update_option( 'pll_dismissed_notices', $dismissed );
}
if ( ! is_multisite() ) {
// Don't delete on multisite to avoid the notices to appear in other sites.
delete_user_meta( get_current_user_id(), 'pll_dismissed_notices' );
}
}
return in_array( $notice, $dismissed );
}
/**
* Should we display notices on this screen?
*
* @since 2.3.9
*
* @param string $notice The notice name.
* @param array $allowed_screens The screens allowed to display the notice.
* If empty, default screens are used, i.e. dashboard, plugins, languages, strings and settings.
*
* @return bool
*/
protected function can_display_notice( string $notice, array $allowed_screens = array() ) {
$screen = get_current_screen();
if ( empty( $screen ) ) {
return false;
}
if ( empty( $allowed_screens ) ) {
$allowed_screens = array(
'dashboard',
'plugins',
PLL_Admin_Base::get_screen_id( 'lang' ),
PLL_Admin_Base::get_screen_id( 'strings' ),
PLL_Admin_Base::get_screen_id( 'settings' ),
);
}
/**
* Filters admin notices which can be displayed.
*
* @since 2.7.0
*
* @param bool $display Whether the notice should be displayed or not.
* @param string $notice The notice name.
*/
return apply_filters( 'pll_can_display_notice', in_array( $screen->id, $allowed_screens, true ), $notice );
}
/**
* Stores a dismissed notice in the database.
*
* @since 2.3.9
*
* @param string $notice Notice name.
* @return void
*/
public static function dismiss( $notice ) {
$dismissed = get_option( 'pll_dismissed_notices', array() );
if ( ! in_array( $notice, $dismissed ) ) {
$dismissed[] = $notice;
update_option( 'pll_dismissed_notices', array_unique( $dismissed ) );
}
}
/**
* Handle a click on the dismiss button
*
* @since 2.3.9
*
* @return void
*/
public function hide_notice() {
if ( isset( $_GET['pll-hide-notice'], $_GET['_pll_notice_nonce'] ) ) {
$notice = sanitize_key( $_GET['pll-hide-notice'] );
check_admin_referer( $notice, '_pll_notice_nonce' );
self::dismiss( $notice );
wp_safe_redirect( remove_query_arg( array( 'pll-hide-notice', '_pll_notice_nonce' ), wp_get_referer() ) );
exit;
}
}
/**
* Displays notices
*
* @since 2.3.9
*
* @return void
*/
public function display_notices() {
if ( current_user_can( 'manage_options' ) ) {
// Core notices
if ( defined( 'WOOCOMMERCE_VERSION' ) && ! defined( 'PLLWC_VERSION' ) && $this->can_display_notice( 'pllwc' ) && ! static::is_dismissed( 'pllwc' ) ) {
$this->pllwc_notice();
}
if ( ! defined( 'POLYLANG_PRO' ) && $this->can_display_notice( 'review' ) && ! static::is_dismissed( 'review' ) && ! empty( $this->options['first_activation'] ) && time() > $this->options['first_activation'] + 15 * DAY_IN_SECONDS ) {
$this->review_notice();
}
$allowed_screen = PLL_Admin_Base::get_screen_id( 'strings' );
if (
( ! empty( $this->options['previous_version'] ) && version_compare( $this->options['previous_version'], '3.7.0', '<' ) )
&& $this->can_display_notice( 'empty-strings-translations', (array) $allowed_screen )
&& ! static::is_dismissed( 'empty-strings-translations' )
) {
$this->empty_strings_translations_notice();
}
// Custom notices
foreach ( static::get_notices() as $notice => $html ) {
if ( $this->can_display_notice( $notice ) && ! static::is_dismissed( $notice ) ) {
?>
dismiss_button( $notice );
echo wp_kses_post( $html );
?>
%s',
esc_url( wp_nonce_url( add_query_arg( 'pll-hide-notice', $name ), $name, '_pll_notice_nonce' ) ),
/* translators: accessibility text */
esc_html__( 'Dismiss this notice.', 'polylang' )
);
}
/**
* Displays a notice if WooCommerce is activated without Polylang for WooCommerce
*
* @since 2.3.9
*
* @return void
*/
private function pllwc_notice() {
?>
dismiss_button( 'pllwc' ); ?>
',
''
);
?>
dismiss_button( 'review' ); ?>
',
''
);
?>
dismiss_button( 'empty-strings-translations' ); ?>