'', 'user_id' => get_current_user_id(), 'value' => true, 'life' => 0, 'global' => true, ) ); } /** * Check that required arguments exist. * * @since 1.0.0 * @param array $args See parse_args(). * @return bool True on success, false on failure. */ private static function check_args( $args = array() ) { return ! empty( $args['id'] ) && ! empty( $args['user_id'] ); } /** * Get the string used to prefix user meta for non-global dismissibles. * * @since 1.0.0 * @global WPDB $wpdb * @param array $args See parse_args(). * @return string Maybe includes the blog prefix. */ private static function get_prefix( $args = array() ) { global $wpdb; // Default value $retval = ''; // Maybe append the blog prefix for non-global dismissibles if ( empty( $args['global'] ) ) { $retval = $wpdb->get_blog_prefix(); } // Return return $retval; } /** * Get the lifespan for a persistent dismissible. * * @since 1.0.0 * @param array $args See parse_args(). * @return int */ private static function get_lifespan( $args = array() ) { return ! empty( $args['life'] ) && is_numeric( $args['life'] ) ? time() + absint( $args['life'] ) : 0; } /** * Get the string used to identify the ID for storing the end-of-life. * * @since 1.0.0 * @param array $args See parse_args(). * @return string '_eol' appended to the ID (for its end-of-life timestamp). */ private static function get_eol_id( $args = array() ) { return sanitize_key( $args['id'] ) . '_eol'; } /** * Check whether a timestamp is beyond the current time. * * @since 1.0.0 * @param int $timestamp A Unix timestamp. Default 0. * @return bool True if end-of-life, false if not. */ private static function is_eol( $timestamp = 0 ) { return is_numeric( $timestamp ) && ( $timestamp < time() ); } } endif;