/**
 * Check if a notice has been dismissed
 *
 * @since 1.0
 *
 * @param string $id ID of the notice to check
 *
 * @return bool
 */
function dnh_is_dismissed($id)
{
    if (!function_exists('DNH')) {
        return false;
    }
    return DNH()->is_dismissed($id);
}
Esempio n. 2
0
 /**
  * Dismiss the notice when the review link is clicked
  *
  * @since 1.0
  * @return void
  */
 public function dismiss_notice()
 {
     if (empty($_POST)) {
         echo 'missing POST';
         die;
     }
     if (!isset($_POST['id'])) {
         echo 'missing ID';
         die;
     }
     $id = sanitize_text_field($_POST['id']);
     if ($id !== $this->link_id) {
         echo "not this instance's job";
         die;
     }
     // Get the DNH notice ID ready
     $notice_id = DNH()->get_id(str_replace('wrm-review-link-', '', $id));
     $dismissed = DNH()->dismiss_notice($notice_id);
     echo $dismissed;
     /**
      * Fires right after the notice has been dismissed. This allows for various integrations to perform additional tasks.
      *
      * @since 1.0
      *
      * @param string $id        The notice ID
      * @param string $notice_id The notice ID as defined by the DNH class
      */
     do_action('wrm_after_notice_dismissed', $id, $notice_id);
     // Stop execution here
     die;
 }
         * @param string $id Notice ID
         *
         * @return array|false
         */
        public function get_notice($id)
        {
            $id = self::$instance->get_id($id);
            if (!is_array(self::$instance->notices) || !array_key_exists($id, self::$instance->notices)) {
                return false;
            }
            return self::$instance->notices[$id];
        }
    }
    /**
     * The main function responsible for returning the unique Dismissible Notices Handler instance
     *
     * Use this function like you would a global variable, except without needing
     * to declare the global.
     *
     * @since 1.0
     * @return object Dismissible_Notices_Handler
     */
    function DNH()
    {
        return Dismissible_Notices_Handler::instance();
    }
    /**
     * Get the library running
     */
    DNH();
}