/** * Tests Cookie Name * * Verifies data-cookiename attribute is being populated with correct cookie name */ public function test_cookie_name() { $this->overlay_title = 'Cookie Test'; $overlay_post = $this->create_overlay(true); $cookie_name = Fm_Overlays::instance()->get_overlay_cookie_name($overlay_post->ID); $this->go_to('/'); $footer = $this->get_wp_footer(); $this->assertContains('<div class="fm-overlay-wrapper">', $footer); $this->assertContains('data-cookiename="' . $cookie_name . '"', $footer); }
*/ if (empty($overlay)) { return; } $fm_overlay_classes = Fm_Overlays_Helpers::instance()->get_overlay_classes($overlay); $targeted_conditions = Fm_Overlays::instance()->targeted_conditions; ?> <div id="fm-overlay" class="<?php echo esc_attr($fm_overlay_classes); ?> " data-cookiename="<?php echo esc_attr(Fm_Overlays::instance()->get_overlay_cookie_name($overlay->ID)); ?> " data-condition="<?php echo esc_attr(implode(' ', Fm_Overlays_Helpers::instance()->namespace_classes($targeted_conditions))); ?> "> <div class="fm-overlay-wrapper"> <!-- @TODO: classes can be `.icon`, `.text`, or `.icon.text` --> <button aria-label="Close Overlay" class="fm-overlay-close icon"> <span class="close-text"><?php esc_html_e('Close', 'fm-overlays'); ?> </span> <svg> <g transform="scale(0.02 0.02)">
{ if (empty($overlay_id)) { $overlay = $this->get_targeted_overlay(); } elseif (null !== $overlay_id) { $overlay = get_post(absint($overlay_id)); } /** * make sure we were able to populate $overlay before trying * to find a cookie using its ID */ if (!empty($overlay)) { /** * we don't want to display same overlay more than once in a day * so we set a cookie on the client for 20 hours after initial * render of each overlay. */ $overlay_cookie_name = $this->get_overlay_cookie_name($overlay->ID); if (empty($_COOKIE[$overlay_cookie_name])) { /** * Enhance overlay post object with additional post meta * to be used in templating. */ $overlay->overlay_content = get_post_meta($overlay->ID, 'fm_overlays_content', true); // include overlay-basic in site footer include FM_OVERLAYS_PATH . 'templates/fm-overlay-basic.php'; } } } } Fm_Overlays::instance();