/**
* Plugin Name: Ever After Daily — Experience
* Description: Phase 1 of the 2.0 "Living Relationship Magazine" experience: design tokens, the Start Where You Are module ([ead_start_here]) with a private browser memory layer, interactive tool tiles ([ead_tools_tiles]), the Tonight's Small Thing streak ritual ([ead_small_thing]), and the Between the Lines signature phrase card ([ead_between_lines]). Lightweight, privacy-safe, no accounts, no free-text collection.
* Version: 1.1.0
* Author: Ever After Daily
* Text Domain: ead-experience
* Requires at least: 6.0
* Requires PHP: 7.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'EAD_EXP_VERSION', '1.1.0' );
define( 'EAD_EXP_PATH', plugin_dir_path( __FILE__ ) );
define( 'EAD_EXP_URL', plugin_dir_url( __FILE__ ) );
require_once EAD_EXP_PATH . 'includes/class-ead-data.php';
require_once EAD_EXP_PATH . 'includes/shortcode-start-here.php';
require_once EAD_EXP_PATH . 'includes/shortcode-tools-tiles.php';
require_once EAD_EXP_PATH . 'includes/shortcode-small-thing.php';
require_once EAD_EXP_PATH . 'includes/shortcode-between-lines.php';
/**
* Register assets. They are enqueued ONLY on pages that actually render one of
* this plugin's shortcodes (checked in ead_exp_maybe_enqueue()).
*/
function ead_exp_register_assets() {
$ver = EAD_EXP_VERSION;
wp_register_style(
'ead-exp-fonts',
'https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&family=Inter:wght@400;500;600;700&display=swap',
array(),
null
);
wp_register_style(
'ead-exp',
EAD_EXP_URL . 'assets/css/ead-experience.css',
array( 'ead-exp-fonts' ),
$ver
);
wp_register_script(
'ead-exp-start-here',
EAD_EXP_URL . 'assets/js/ead-start-here.js',
array(),
$ver,
true
);
wp_register_script(
'ead-exp-small-thing',
EAD_EXP_URL . 'assets/js/ead-small-thing.js',
array(),
$ver,
true
);
wp_register_script(
'ead-exp-between-lines',
EAD_EXP_URL . 'assets/js/ead-between-lines.js',
array(),
$ver,
true
);
}
add_action( 'wp_enqueue_scripts', 'ead_exp_register_assets', 5 );
/**
* Track whether any shortcode rendered on this request.
*/
function ead_exp_flag_shortcode( $tag ) {
$GLOBALS['ead_exp_shortcodes_used'][ $tag ] = true;
}
/**
* Conditionally enqueue assets. Runs on the_posts (early enough) and, as a
* safety net, on wp_footer via the shortcode flag.
*/
function ead_exp_maybe_enqueue( $posts ) {
if ( empty( $posts ) ) {
return $posts;
}
$needs_css = false;
$js_handles = array();
foreach ( $posts as $post ) {
$content = $post->post_content ?? '';
if ( has_shortcode( $content, 'ead_start_here' ) ) {
$needs_css = true;
$js_handles['ead-exp-start-here'] = true;
}
if ( has_shortcode( $content, 'ead_tools_tiles' ) ) {
$needs_css = true;
}
if ( has_shortcode( $content, 'ead_small_thing' ) ) {
$needs_css = true;
$js_handles['ead-exp-small-thing'] = true;
}
if ( has_shortcode( $content, 'ead_between_lines' ) ) {
$needs_css = true;
$js_handles['ead-exp-between-lines'] = true;
}
}
if ( $needs_css ) {
ead_exp_flag_shortcode( 'css' );
wp_enqueue_style( 'ead-exp' );
}
foreach ( array_keys( $js_handles ) as $handle ) {
ead_exp_flag_shortcode( $handle );
wp_enqueue_script( $handle );
}
return $posts;
}
add_filter( 'the_posts', 'ead_exp_maybe_enqueue' );
/**
* Safety net: if a shortcode rendered but the_posts detection missed it
* (e.g. shortcode inside a widget or block pattern rendered later), enqueue
* in the footer. CSS in footer is not ideal but keeps the module functional.
*/
function ead_exp_footer_safety_net() {
if ( empty( $GLOBALS['ead_exp_shortcodes_used'] ) ) {
return;
}
$used = $GLOBALS['ead_exp_shortcodes_used'];
if ( ! wp_style_is( 'ead-exp', 'enqueued' ) ) {
wp_print_styles( 'ead-exp' );
}
foreach ( array( 'ead-exp-start-here', 'ead-exp-small-thing', 'ead-exp-between-lines' ) as $handle ) {
if ( ! empty( $used[ $handle ] ) && ! wp_script_is( $handle, 'enqueued' ) ) {
wp_print_scripts( $handle );
}
}
}
add_action( 'wp_footer', 'ead_exp_footer_safety_net', 1 );
/**
* dataLayer helper. Emits a small inline script pushing a privacy-safe event.
* Only predefined IDs are ever sent — never free text, never PII.
*
* @param string $event Event name, e.g. start_here_select.
* @param array $params String-keyed scalar params (predefined IDs only).
*/
function ead_exp_datalayer_event( $event, $params = array() ) {
$payload = array_merge( array( 'event' => $event ), $params );
printf(
"\n",
wp_json_encode( $payload )
);
}
https://everafterdaily.com/post-sitemap.xml
2026-09-29T19:30:00+00:00
https://everafterdaily.com/page-sitemap.xml
2026-09-29T09:30:36+00:00
https://everafterdaily.com/category-sitemap.xml
2026-09-29T16:16:31+00:00