Plugin Directory

Changeset 3813839


Ignore:
Timestamp:
11/20/2026 02:17:58 PM (less than one hour ago)
Author:
vakanssi
Message:

Release 1.3.19: AI assistant abilities for jobs (WordPress Abilities API), richer sample data, careers page contrast on dark and tinted themes, moves into another job's pipeline refused, readme formatting.

Location:
vakanssi
Files:
12 added
24 edited
1 copied

Legend:

Unmodified
Added
Removed
  • vakanssi/tags/1.3.19/assets/css/careers.css

    r3785137 r3813839  
    1717        --vakanssi-ink: #1e2936;
    1818        --vakanssi-text: #3a4552;
    19         --vakanssi-muted: #5f6b7a;
     19        --vakanssi-muted: #525e6c;
    2020        --vakanssi-faint: #98a2b0;
    2121
    … …  
    101101        --vakanssi-invalid-edge: 4px;
    102102        --vakanssi-hover-duration: 0.2s;
     103
     104        /* Dark pages. The palette above is a light one, and most of the careers
     105           list paints its text straight onto the theme's page, so on a dark theme
     106           the titles measured 1.17:1. The theme's own text colour tells us which
     107           kind of page we are on: light text means a dark page. These two are
     108           pieces of a relative colour (`rgb(from currentColor ...)`) and mean
     109           nothing on their own; the "Text on a dark page" block at the end of
     110           this sheet is their only user. The switch is a step on the sRGB luma
     111           (0 to 255) of the inherited text: 0 up to 140, 1 above it. It is a
     112           guess, because CSS cannot read the page's background, and grey text is
     113           where it can guess wrong: #8a8a8a (138) and darker read as a light
     114           page, #999 (153) and lighter as a dark one. Light themes' text sits far
     115           below (#111 to #555), Twenty Twenty-Five's dark variations far above
     116           (203 to 212). The two known misses are a light theme with text greyer
     117           than #8a8a8a (already under 3.4:1 on white) and a dark theme with text
     118           darker than #999. page-text is the inherited text colour, opaque only
     119           when the switch is 1.
     120
     121           Site owners can overrule the guess on any container in Custom CSS:
     122           `--vakanssi-page-text: transparent` keeps the light palette (a white
     123           section on a dark site whose text colour stays light),
     124           `--vakanssi-page-text: currentColor` follows the text (a dark section
     125           whose text is grey).
     126
     127           Known limit: the block rebuilds each token at full opacity (or its set
     128           fade), so a colour token set see-through in Custom CSS (for example
     129           `--vakanssi-border: transparent` to hide the row lines) comes out solid.
     130           Set token overrides as solid colours; to hide a line, set its width. */
     131        --vakanssi-dark-switch: clamp(0, (0.2126 * r + 0.7152 * g + 0.0722 * b - 140) * 100, 1);
     132        --vakanssi-page-text: rgb(from currentColor r g b / var(--vakanssi-dark-switch));
     133}
     134
     135/* The accent as text on the theme's page (team label, Remote/Hybrid,
     136   chevron, outlined Apply, back link, the closed job's action): the accent
     137   with 30% ink mixed in. The accent clears 4.5:1 on white only (Branding
     138   darkens a brand colour to exactly that), and a tinted page took it under:
     139   4.0:1 on Twenty Twenty-Five "Morning" (#dfdcd7). Fills, buttons, rings
     140   and emails keep the accent itself.
     141
     142   Declared on every plugin element, not on :root, so the mix reads the
     143   accent where it is used: a site that sets --vakanssi-accent on a wrapper
     144   recolours this text too (a :root declaration resolved once, at the
     145   root). Guarded: a browser without color-mix() leaves it undefined, and
     146   each use falls back to the accent, as before. */
     147@supports (color: color-mix(in srgb, red 70%, blue)) {
     148        [class*="vakanssi-"] {
     149                --vakanssi-accent-text: color-mix(in srgb, var(--vakanssi-accent, #0f766e) 70%, var(--vakanssi-ink, #1e2936));
     150        }
    103151}
    104152
    … …  
    462510        background: #ffffff;
    463511        background: var(--vakanssi-surface, #ffffff);
     512        /* Its own surface, so its own text colour: on a dark theme the page's
     513           light text must not reach the field (see "Text on a dark page"). */
     514        color: #3a4552;
     515        color: var(--vakanssi-text, #3a4552);
    464516        border: 1px solid #758091;
    465517        border: 1px solid var(--vakanssi-control-border-page, #758091);
    … …  
    650702        font-size: 0.8125em;
    651703        font-size: var(--vakanssi-text-xs, 0.8125em);
    652         color: #5f6b7a;
    653         color: var(--vakanssi-muted, #5f6b7a);
     704        color: #525e6c;
     705        color: var(--vakanssi-muted, #525e6c);
    654706        cursor: pointer;
    655707        -webkit-user-select: none;
    … …  
    806858        font-size: 0.875em;
    807859        font-size: var(--vakanssi-text-sm, 0.875em);
    808         color: #5f6b7a;
    809         color: var(--vakanssi-muted, #5f6b7a);
     860        color: #525e6c;
     861        color: var(--vakanssi-muted, #525e6c);
    810862}
    811863
    … …  
    853905        margin: 0;
    854906        padding: 0;
    855         color: #5f6b7a;
    856         color: var(--vakanssi-muted, #5f6b7a);
     907        color: #525e6c;
     908        color: var(--vakanssi-muted, #525e6c);
    857909        font-size: 0.9375em;
    858910        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    877929.vakanssi-jobs-pagination .vakanssi-jobs-pagination__page {
    878930        margin-inline-end: 0.35em;
    879         color: #5f6b7a;
    880         color: var(--vakanssi-muted, #5f6b7a);
     931        color: #525e6c;
     932        color: var(--vakanssi-muted, #525e6c);
    881933        font-variant-numeric: tabular-nums;
    882934        white-space: nowrap;
    … …  
    11931245        text-transform: uppercase;
    11941246        color: #0f766e;
    1195         color: var(--vakanssi-accent, #0f766e);
     1247        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    11961248        /* 0.3em of the UI base between the team and the title. */
    11971249        margin-block-end: 0.4em;
    … …  
    12291281        /* 0.4em of the UI base between the title and the facts. */
    12301282        margin-block-start: 0.45em;
    1231         color: #5f6b7a;
    1232         color: var(--vakanssi-muted, #5f6b7a);
     1283        color: #525e6c;
     1284        color: var(--vakanssi-muted, #525e6c);
    12331285        font-size: 0.875em;
    12341286        font-size: var(--vakanssi-text-sm, 0.875em);
    … …  
    12651317.vakanssi-job-fact--workplace {
    12661318        color: #0c615a;
    1267         color: var(--vakanssi-accent-strong, #0c615a);
     1319        color: var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a));
    12681320        font-weight: 600;
    12691321}
    … …  
    13081360.vakanssi-job-link:focus-visible .vakanssi-job-go {
    13091361        color: #0f766e;
    1310         color: var(--vakanssi-accent, #0f766e);
     1362        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    13111363        transform: translateX(3px);
    13121364}
    … …  
    13581410        background: transparent;
    13591411        color: #0f766e;
    1360         color: var(--vakanssi-accent, #0f766e);
     1412        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    13611413        font-family: inherit;
    13621414        font-size: 0.8125em;
    … …  
    14031455        padding-inline: 1.6em;
    14041456        text-align: center;
    1405         color: #5f6b7a;
    1406         color: var(--vakanssi-muted, #5f6b7a);
     1457        color: #525e6c;
     1458        color: var(--vakanssi-muted, #525e6c);
    14071459        font-size: 0.9375em;
    14081460        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    14341486        background: #ffffff;
    14351487        background: var(--vakanssi-surface, #ffffff);
     1488        /* A card paints its own surface, so it sets its own text colour too. The
     1489           row rules inside it read the colour they inherit to tell a dark page
     1490           from a light one ("Text on a dark page"); a dark theme's light text
     1491           reaching them here turned them light on this white card. */
     1492        color: #3a4552;
     1493        color: var(--vakanssi-text, #3a4552);
    14361494        border: 1px solid #e2e6eb;
    14371495        border: 1px solid var(--vakanssi-border, #e2e6eb);
    … …  
    14781536        padding-inline: 1.6em;
    14791537        text-align: center;
    1480         color: #5f6b7a;
    1481         color: var(--vakanssi-muted, #5f6b7a);
     1538        color: #525e6c;
     1539        color: var(--vakanssi-muted, #525e6c);
    14821540        font-size: 0.9375em;
    14831541        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    15041562        background: #f6f8fa;
    15051563        background: var(--vakanssi-surface-subtle, #f6f8fa);
     1564        /* Its own surface, so its own text colour (see "Text on a dark page"). */
     1565        color: #3a4552;
     1566        color: var(--vakanssi-text, #3a4552);
    15061567        border: 1px solid #e2e6eb;
    15071568        border: 1px solid var(--vakanssi-border, #e2e6eb);
    … …  
    15341595        letter-spacing: 0.05em;
    15351596        text-transform: uppercase;
    1536         color: #5f6b7a;
    1537         color: var(--vakanssi-muted, #5f6b7a);
     1597        color: #525e6c;
     1598        color: var(--vakanssi-muted, #525e6c);
    15381599}
    15391600
    … …  
    15741635        letter-spacing: 0.05em;
    15751636        text-transform: uppercase;
    1576         color: #5f6b7a;
    1577         color: var(--vakanssi-muted, #5f6b7a);
     1637        color: #525e6c;
     1638        color: var(--vakanssi-muted, #525e6c);
    15781639}
    15791640
    … …  
    16791740        line-height: 1.4;
    16801741        color: #0f766e;
    1681         color: var(--vakanssi-accent, #0f766e);
     1742        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    16821743        text-decoration: none;
    16831744}
    … …  
    17961857
    17971858.vakanssi-apply--soon {
    1798         color: #5f6b7a;
    1799         color: var(--vakanssi-muted, #5f6b7a);
     1859        color: #525e6c;
     1860        color: var(--vakanssi-muted, #525e6c);
    18001861        font-style: italic;
    18011862}
    … …  
    19572018.vakanssi-field ::placeholder,
    19582019.vakanssi-jobs-bar .vakanssi-jobs-searchinput::placeholder {
    1959         color: #5f6b7a;
    1960         color: var(--vakanssi-muted, #5f6b7a);
     2020        color: #525e6c;
     2021        color: var(--vakanssi-muted, #525e6c);
    19612022        opacity: 1;
    19622023}
    … …  
    19812042        border-radius: 6px;
    19822043        border-radius: var(--vakanssi-radius, 6px);
    1983         color: #5f6b7a;
    1984         color: var(--vakanssi-muted, #5f6b7a);
     2044        color: #525e6c;
     2045        color: var(--vakanssi-muted, #525e6c);
    19852046        font-family: inherit;
    19862047        font-size: 0.875em;
    … …  
    21002161        font-weight: 400;
    21012162        line-height: 1.5;
    2102         color: #5f6b7a;
    2103         color: var(--vakanssi-muted, #5f6b7a);
     2163        color: #525e6c;
     2164        color: var(--vakanssi-muted, #525e6c);
    21042165}
    21052166
    … …  
    22242285        letter-spacing: 0.05em;
    22252286        text-transform: uppercase;
    2226         color: #5f6b7a;
    2227         color: var(--vakanssi-muted, #5f6b7a);
     2287        color: #525e6c;
     2288        color: var(--vakanssi-muted, #525e6c);
    22282289}
    22292290
    … …  
    23622423}
    23632424
    2364 /* The link's resting paint, restated for its focused state: a theme's focus
    2365    wash must not replace it. */
     2425/* The link's resting paint, at rest and restated for its focused state: a
     2426   theme's focus wash must not replace it, and a theme's or a block's link
     2427   colour (core prints `.wp-elements-N a` at (0,1,1) for a Group with a link
     2428   colour) must not reach the row. The row's text reads the colour it
     2429   inherits through this link to tell a dark page from a light one ("Text on
     2430   a dark page"); an orange link colour on a light page turned the titles
     2431   orange at 2.51:1. */
     2432.vakanssi-jobs li.vakanssi-job a.vakanssi-job-link,
     2433:root .vakanssi-related li.vakanssi-related-item > a,
    23662434.vakanssi-jobs li.vakanssi-job a.vakanssi-job-link:focus,
    23672435:root .vakanssi-related li.vakanssi-related-item > a:focus {
    … …  
    23912459        background: transparent;
    23922460        color: #0f766e;
    2393         color: var(--vakanssi-accent, #0f766e);
     2461        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    23942462}
    23952463
    … …  
    25222590        box-shadow: none;
    25232591        color: #0f766e;
    2524         color: var(--vakanssi-accent, #0f766e);
     2592        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    25252593        font-size: 0.9375em;
    25262594        font-size: var(--vakanssi-text-md, 0.9375em);
    25272595        font-weight: 600;
    25282596        line-height: 1.3;
    2529         transition: background 0.2s ease, color 0.2s ease;
    2530         transition: background var(--vakanssi-hover-duration, 0.2s) ease, color var(--vakanssi-hover-duration, 0.2s) ease;
     2597        transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
     2598        transition: background var(--vakanssi-hover-duration, 0.2s) ease, color var(--vakanssi-hover-duration, 0.2s) ease, border-color var(--vakanssi-hover-duration, 0.2s) ease;
    25312599}
    25322600
    … …  
    28082876        }
    28092877}
     2878
     2879/* The external-link icon in a focused Apply button: white on the fill. The
     2880   dark-page block keeps the button's `color` on the page for its ring and
     2881   paints the label with -webkit-text-fill-color, which an SVG stroke does
     2882   not read. */
     2883.vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible > svg {
     2884        color: #ffffff;
     2885        color: var(--vakanssi-accent-contrast, #ffffff);
     2886}
     2887
     2888/* Forced colours repaint the focused buttons' fill but not a text fill
     2889   colour, which left the white label on a white Canvas (1:1). */
     2890@media (forced-colors: active) {
     2891        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible,
     2892        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     2893                -webkit-text-fill-color: currentColor;
     2894        }
     2895}
     2896
     2897/* ------------------------------------------------------------------ *
     2898 *  Text on a dark page
     2899 * ------------------------------------------------------------------ */
     2900
     2901/* The list rows, the count and pagination lines, the related roles and the
     2902   back link paint their text straight onto the theme's page, in the light
     2903   palette's dark ink. On a dark theme that measured 1.17:1 for a job title
     2904   (Twenty Twenty-Five "Evening"). The cards, fields and buttons paint their
     2905   own surface and are not here.
     2906
     2907   Each rule below restates one of those colours as a switch on the text
     2908   colour the element inherits from the theme (the tokens at the top of this
     2909   sheet). On a light page the switch is 0 and the result is the token itself,
     2910   to the digit, including a brand accent from Settings or a token set in
     2911   Custom CSS. On a dark page it is the theme's own text colour, which the
     2912   theme already made readable there: as is for titles, salaries and the
     2913   closed notice, at 85% for the muted lines, at 55% for the decorative dots
     2914   and chevron, and mixed with 20% of the accent for the accent text, so the
     2915   brand still shows. The hover band and the hairlines follow the same way.
     2916
     2917   How it works: color-mix() weighs the token at 0.1% against page-text,
     2918   which is fully transparent on a light page (so only the token is left) and
     2919   opaque on a dark one (so the token's 0.1% is lost in it). The outer
     2920   rgb(from ...) then sets the alpha. Its `alpha` is the mix's own, which
     2921   runs from 0.001 (light page) to 1 (dark page); `(alpha - 0.001) / 0.999`
     2922   maps that onto 0 to 1, so the faded roles fade only on a dark page and a
     2923   light page gets an alpha of exactly 1.
     2924
     2925   Browsers without relative colours or color-mix() keep the light palette
     2926   above, unchanged. The guard tests the constructs the block uses (a
     2927   currentColor origin, channel and alpha arithmetic), not just the
     2928   syntax: every value below goes through var(), so a browser that took
     2929   the syntax but not these would drop the declarations to `unset`, not to
     2930   the light palette. Every selector repeats its rule's, so it ties on weight
     2931   and wins by coming last. */
     2932@supports (color: rgb(from currentColor r g b / clamp(0, (0.2126 * r + 0.7152 * g + 0.0722 * b - 140) * 100, 1))) and (color: rgb(from color-mix(in srgb, red 0.1%, blue) r g b / calc(1 - 0.2 * (alpha - 0.001) / 0.999))) {
     2933        .vakanssi-job-title,
     2934        .vakanssi-job-fact--salary,
     2935        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__range strong {
     2936                color: rgb(from color-mix(in srgb, var(--vakanssi-ink, #1e2936) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1);
     2937        }
     2938
     2939        .vakanssi-jobs-count,
     2940        .vakanssi-jobs-remote,
     2941        .vakanssi-job-meta,
     2942        .vakanssi-related-heading,
     2943        .vakanssi-apply--soon,
     2944        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__range,
     2945        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__page {
     2946                color: rgb(from color-mix(in srgb, var(--vakanssi-muted, #525e6c) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.15 * (alpha - 0.001) / 0.999));
     2947        }
     2948
     2949        .vakanssi-job-fact::before,
     2950        .vakanssi-job-go {
     2951                color: rgb(from color-mix(in srgb, var(--vakanssi-faint, #98a2b0) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.45 * (alpha - 0.001) / 0.999));
     2952        }
     2953
     2954        .vakanssi-job-dept,
     2955        .vakanssi-job-link:hover .vakanssi-job-go,
     2956        .vakanssi-job-link:focus-visible .vakanssi-job-go,
     2957        .vakanssi-single-back a:any-link,
     2958        :root p.vakanssi-single-back a:any-link:focus {
     2959                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)));
     2960        }
     2961
     2962        .vakanssi-job-fact--remote,
     2963        .vakanssi-job-fact--workplace {
     2964                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a)));
     2965        }
     2966
     2967        /* "This position is now closed." The words (in bold) carry the meaning, so
     2968           on a dark page it is the page's text, untinted: its "View current
     2969           openings" link takes its colour from this one, and a red tint here
     2970           under the link's own accent tint left the link at 4.06:1 on a purple
     2971           page (Twenty Twenty-Five "Midnight"). */
     2972        .vakanssi-apply--closed {
     2973                color: rgb(from color-mix(in srgb, var(--vakanssi-danger-text, #9f3a38) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1);
     2974        }
     2975
     2976        /* The outlined links: the row's Apply button and the closed job's "View
     2977           current openings". Text and border; hover and focus fill them on their
     2978           own (heavier) rules. */
     2979        .vakanssi-jobs .vakanssi-job-apply,
     2980        :root p.vakanssi-apply--closed a.vakanssi-closed-action {
     2981                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)));
     2982                /* The border is the text: in border-color, currentColor is the link's
     2983                   own colour, the line above. Running the switch again here would
     2984                   read that already tinted colour, and near the step the tint tipped
     2985                   it back to the plain accent, 2.8:1 on a dark page. */
     2986                border-color: currentColor;
     2987        }
     2988
     2989        /* The states that change the text colour keep the accent border they
     2990           had; on a light page this is exactly the border of the rules above. */
     2991        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus,
     2992        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus,
     2993        :root p.vakanssi-apply--closed a.vakanssi-closed-action:hover {
     2994                border-color: var(--vakanssi-accent, #0f766e);
     2995        }
     2996
     2997        /* The keyboard ring of the row's Apply button and the closed job's
     2998           action. Focused, they paint their own fill and label colour, so a ring
     2999           in currentColor followed the label, not the page: the plain accent,
     3000           1.55:1 on a purple page. Here `color` stays the page-following accent
     3001           (the ring is currentColor) and the label is painted with
     3002           -webkit-text-fill-color instead. */
     3003        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible,
     3004        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     3005                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent, #0f766e) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent, #0f766e));
     3006                outline-color: currentColor;
     3007        }
     3008
     3009        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible {
     3010                -webkit-text-fill-color: var(--vakanssi-accent-contrast, #ffffff);
     3011        }
     3012
     3013        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     3014                -webkit-text-fill-color: var(--vakanssi-accent-strong, #0c615a);
     3015        }
     3016
     3017        /* The focus ring of the links that sit on the page. In outline-color,
     3018           currentColor is the link's own colour. The row and related links take
     3019           the page's text (their resting rule sets `color: inherit`), so the
     3020           ring runs the switch on it. The back link's colour is the switched
     3021           accent already, so its ring is simply that colour. */
     3022        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-link:focus-visible,
     3023        :root .vakanssi-related li.vakanssi-related-item > a:focus-visible {
     3024                outline-color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent, #0f766e) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent, #0f766e));
     3025        }
     3026
     3027        :root p.vakanssi-single-back a:any-link:focus-visible {
     3028                outline-color: currentColor;
     3029        }
     3030
     3031        /* The hover and focus band of the list rows and of "Other open roles":
     3032           the light wash on a light page, a faint veil of the page's text colour
     3033           on a dark one (a light wash there put the now light text back on a
     3034           light ground, 1.5:1). 5%, with the muted lines at 85%: at 8% and 80%
     3035           the muted facts on a hovered row fell to 4.29:1 on Twenty Twenty-Five
     3036           "Midnight". */
     3037        .vakanssi-jobs-board .vakanssi-jobs:not(.vakanssi-jobs--grid) .vakanssi-job::before,
     3038        .vakanssi-related .vakanssi-related-item::before {
     3039                background: rgb(from color-mix(in srgb, var(--vakanssi-surface-subtle, #f6f8fa) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.95 * (alpha - 0.001) / 0.999));
     3040        }
     3041
     3042        /* The hairlines between the rows and above the lists: the light palette's
     3043           near-white rule read as a bright stripe on a dark page, louder than on
     3044           white. There they are the page's text colour at 25%. A grid card's own
     3045           border is on a heavier rule and is not affected. */
     3046        .vakanssi-jobs-bar + .vakanssi-jobs-meta,
     3047        .vakanssi-jobs,
     3048        .vakanssi-related .vakanssi-related-list {
     3049                border-block-start-color: rgb(from color-mix(in srgb, var(--vakanssi-border, #e2e6eb) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.75 * (alpha - 0.001) / 0.999));
     3050        }
     3051
     3052        .vakanssi-job,
     3053        .vakanssi-related .vakanssi-related-item {
     3054                border-block-end-color: rgb(from color-mix(in srgb, var(--vakanssi-border, #e2e6eb) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.75 * (alpha - 0.001) / 0.999));
     3055        }
     3056}
  • vakanssi/tags/1.3.19/readme.txt

    r3803675 r3813839  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.3.18
     7Stable tag: 1.3.19
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1515Vakanssi is a recruitment plugin and complete applicant tracking system (ATS) for WordPress. Post your openings on a careers page or job board on your own site and run the whole hiring process there.
    1616
    17 It brings branded job listings with Google-for-Jobs
    18 structured data, a native application form, an applications inbox with a configurable drag-and-drop
    19 pipeline board, templated emails, and tools for handling candidate data (export, erasure and
    20 scheduled retention), all on your own server, with no per-seat SaaS fees.
     17It brings branded job listings with Google-for-Jobs structured data, a native application form, an applications inbox with a configurable drag-and-drop pipeline board, templated emails, and tools for handling candidate data (export, erasure and scheduled retention), all on your own server, with no per-seat SaaS fees.
    2118
    2219**A complete hiring workflow:**
    2320
    24 * **Jobs & careers**: a `vakanssi_job` post type, a branded careers archive (at `/jobs/` by default, or on
    25   your own careers page) and `[vakanssi_jobs]` shortcode, and valid Google-for-Jobs `JobPosting` structured data that is
    26   withheld automatically when a job is not eligible (expired, no location, no apply path, …).
    27 * **Application intake**: a native application form with a secure CV upload (type-verified by magic
    28   bytes, randomised filename, owner-only permissions), spam/honeypot/rate-limiting, and candidate
    29   de-duplication by email.
    30 * **Applications inbox & pipeline board**: a sortable, filterable inbox plus a build-free React
    31   Kanban board with a candidate profile drawer; configurable stages; bulk move/delete.
    32 * **Interviews & calendar invites**: schedule an interview from the candidate's record and send a
    33   real `.ics` invite that Google, Outlook and Apple render as an actionable event, with no OAuth and
    34   no connected account. Reschedule, cancel, and keep internal notes that reach your interviewers'
    35   calendars and never the candidate's.
     21* **Jobs & careers**: a `vakanssi_job` post type, a branded careers archive (at `/jobs/` by default, or on your own careers page) and `[vakanssi_jobs]` shortcode, and valid Google-for-Jobs `JobPosting` structured data that is withheld automatically when a job is not eligible (expired, no location, no apply path, …).
     22
     23* **Application intake**: a native application form with a secure CV upload (type-verified by magic bytes, randomised filename, owner-only permissions), spam/honeypot/rate-limiting, and candidate de-duplication by email.
     24
     25* **Applications inbox & pipeline board**: a sortable, filterable inbox plus a build-free React Kanban board with a candidate profile drawer; configurable stages; bulk move/delete.
     26
     27* **Interviews & calendar invites**: schedule an interview from the candidate's record and send a real `.ics` invite that Google, Outlook and Apple render as an actionable event, with no OAuth and no connected account. Reschedule, cancel, and keep internal notes that reach your interviewers' calendars and never the candidate's.
     28
    3629* **Application data & export**: export applications to CSV, print or save any application as a PDF, and edit application details, right from the inbox.
    37 * **Email**: templated confirmation/recruiter/rejection/offer emails with personalization tags and
    38   an SMTP-compatible sender, logged and de-duplicated.
    39 * **Candidate data controls**: consent capture, WordPress core data export/erase integration (with a
    40   complete cascade across all candidate data), a retention-purge cron, and an audit log. These are
    41   tools you operate; they do not by themselves make a site compliant with any particular law.
    42 * **Blocks, page builders & themes**: a Job Listings block for the block editor, native **Elementor**
    43   widgets for the listing, the application form and the job details (Elementor Pro Theme Builder
    44   archive/single templates are respected too), a **Divi** module, and shortcodes for everywhere else.
    45   Block themes on WordPress 6.7 and later get editable Site Editor templates; classic themes get the
    46   built-in archive.
    47 * **First-run setup wizard**: sender identity and a careers page in a few clicks, with optional
    48   sample content and a prompt to post your first job.
    49 * **Foundations**: scale-ready custom tables (engineered for 10k+ applications), a modular
    50   architecture (disabled modules load no code/assets), capability-based roles (Recruiter, Hiring
    51   Manager, HR/Compliance), and a `vakanssi/v1` REST API with per-route
    52   permission checks.
     30
     31* **Email**: templated confirmation/recruiter/rejection/offer emails with personalization tags and an SMTP-compatible sender, logged and de-duplicated.
     32
     33* **Candidate data controls**: consent capture, WordPress core data export/erase integration (with a complete cascade across all candidate data), a retention-purge cron, and an audit log. These are tools you operate; they do not by themselves make a site compliant with any particular law.
     34
     35* **Blocks, page builders & themes**: a Job Listings block for the block editor, native **Elementor** widgets for the listing, the application form and the job details (Elementor Pro Theme Builder archive/single templates are respected too), a **Divi** module, and shortcodes for everywhere else. Block themes on WordPress 6.7 and later get editable Site Editor templates; classic themes get the built-in archive.
     36
     37* **First-run setup wizard**: sender identity and a careers page in a few clicks, with optional sample content and a prompt to post your first job.
     38
     39* **AI assistants**: on WordPress 6.9 and later, with the free MCP Adapter plugin, an AI assistant such as Claude can list your jobs, read one and draft a new one. It signs in as one of your users and can do only what that user may do, and drafts are never published on their own.
     40
     41* **Foundations**: scale-ready custom tables (engineered for 10k+ applications), a modular architecture (disabled modules load no code/assets), capability-based roles (Recruiter, Hiring Manager, HR/Compliance), and a `vakanssi/v1` REST API with per-route permission checks.
    5342
    5443== Installation ==
    5544
    56451. Upload the `vakanssi` folder to `/wp-content/plugins/`, or install through the Plugins screen.
    57 2. Activate the plugin. Activation creates the database tables, installs roles, provisions protected
    58   file storage, and opens a short setup wizard.
    59 3. Complete **Hiring → Setup** (sender email, careers page), post your first job, then review
    60   **Hiring → Tools → Status** for system status.
     46
     472. Activate the plugin. Activation creates the database tables, installs roles, provisions protected file storage, and opens a short setup wizard.
     48
     493. Complete **Hiring → Setup** (sender email, careers page), post your first job, then review **Hiring → Tools → Status** for system status.
    6150
    6251== Frequently Asked Questions ==
    … …  
    6453= Does removing the plugin delete my candidate data? =
    6554
    66 No. Uninstalling removes roles, capabilities, and plugin settings, but your hiring data is kept
    67 unless you explicitly enable **Hiring → Settings → General → Delete all data on uninstall**.
    68 While another copy of Vakanssi is still installed (for example in a second plugin folder),
    69 deleting a copy removes nothing, so the copy you keep runs with its settings and data.
     55No. Uninstalling removes roles, capabilities, and plugin settings, but your hiring data is kept unless you explicitly enable **Hiring → Settings → General → Delete all data on uninstall**. While another copy of Vakanssi is still installed (for example in a second plugin folder), deleting a copy removes nothing, so the copy you keep runs with its settings and data.
    7056
    7157= Are uploaded CVs protected from direct download? =
    7258
    73 Yes, with defence in depth. Candidate files are stored in a protected `vakanssi` folder in
    74 your uploads directory, under random 128-bit file names, with an Apache deny rule, index guards and a
    75 generated Nginx rule. Vakanssi then **verifies over HTTP** that the folder is not directly reachable,
    76 and shows an admin warning (with the exact Nginx rule to add) if it is. The plugin itself only serves
    77 CVs through an authenticated, permission-checked download link.
    78 To keep them outside your public site entirely, define `VAKANSSI_STORAGE_DIR` as an absolute path in `wp-config.php`; moving your existing CVs is covered at https://docs.vakanssi.com/admin/move-cv-storage/
     59Yes, with defence in depth. Candidate files are stored in a protected `vakanssi` folder in your uploads directory, under random 128-bit file names, with an Apache deny rule, index guards and a generated Nginx rule. Vakanssi then **verifies over HTTP** that the folder is not directly reachable, and shows an admin warning (with the exact Nginx rule to add) if it is. The plugin itself only serves CVs through an authenticated, permission-checked download link. To keep them outside your public site entirely, define `VAKANSSI_STORAGE_DIR` as an absolute path in `wp-config.php`; moving your existing CVs is covered at https://docs.vakanssi.com/admin/move-cv-storage/
    7960
    8061= Who on my team can see candidate applications and CVs? =
    8162
    82 Anyone you grant a hiring role to. Vakanssi ships three roles (Recruiter, Hiring Manager, and HR / Compliance)
    83 plus Administrator, and any user with the "view applications" capability can see **every** candidate
    84 and download **every** CV in the pipeline. In other words, Vakanssi does not restrict staff to only
    85 the jobs or candidates assigned to them: it assumes your hiring team is trusted, which is the right
    86 default for most small teams. Only grant these roles to people who should see all applicants.
     63Anyone you grant a hiring role to. Vakanssi ships three roles (Recruiter, Hiring Manager, and HR / Compliance) plus Administrator, and any user with the "view applications" capability can see **every** candidate and download **every** CV in the pipeline. In other words, Vakanssi does not restrict staff to only the jobs or candidates assigned to them: it assumes your hiring team is trusted, which is the right default for most small teams. Only grant these roles to people who should see all applicants.
    8764
    8865= How do I report a security issue? =
    8966
    90 Email **security@vakanssi.com** rather than posting in the support forum, so a fix can ship before
    91 the details are public. Please include the Vakanssi version, your WordPress and PHP versions, and
    92 steps to reproduce. You will get an acknowledgement within three business days and an initial
    93 assessment within a week, and you will be credited in the changelog for the release that fixes it
    94 unless you would rather not be. Only the most recent release receives security fixes, so updating
    95 is always part of the answer.
     67Email **security@vakanssi.com** rather than posting in the support forum, so a fix can ship before the details are public. Please include the Vakanssi version, your WordPress and PHP versions, and steps to reproduce. You will get an acknowledgement within three business days and an initial assessment within a week, and you will be credited in the changelog for the release that fixes it unless you would rather not be. Only the most recent release receives security fixes, so updating is always part of the answer.
    9668
    9769= What personal data is included in a GDPR data-export request? =
    9870
    99 When you run **Tools → Export Personal Data** for a candidate's email, Vakanssi includes their
    100 profile (name, email, phone, location), every application (position, stage, status, date, and whether
    101 consent was given), the cover letter, their LinkedIn profile, each uploaded CV/attachment (the file itself, with its
    102 filename and upload date), the submission context stored with the application (the page the application was sent from), the
    103 recruiter notes and interview notes written about them, their interviews, and the emails Vakanssi
    104 sent them. Other details stored with an application or the candidate are included too, under
    105 "Additional application data". The export deliberately does **not** name the staff member who wrote a note, gave a
    106 rating, or conducted an interview. That is a third party's personal data, not the candidate's.
     71When you run **Tools → Export Personal Data** for a candidate's email, Vakanssi includes their profile (name, email, phone, location), every application (position, stage, status, date, and whether consent was given), the cover letter, their LinkedIn profile, each uploaded CV/attachment (the file itself, with its filename and upload date), the submission context stored with the application (the page the application was sent from), the recruiter notes and interview notes written about them, their interviews, and the emails Vakanssi sent them. Other details stored with an application or the candidate are included too, under "Additional application data". The export deliberately does **not** name the staff member who wrote a note, gave a rating, or conducted an interview. That is a third party's personal data, not the candidate's.
    10772
    108 The matching **Erase Personal Data** tool removes all of it, including the CV files on disk. Export
    109 and erasure share one list of the tables that hold notes, interviews and emails about a candidate,
    110 so the two stay in step.
     73The matching **Erase Personal Data** tool removes all of it, including the CV files on disk. Export and erasure share one list of the tables that hold notes, interviews and emails about a candidate, so the two stay in step.
    11174
    11275= Does it work on WordPress multisite? =
    11376
    114 Yes, activated per site or network-wide. Each site keeps its own jobs, candidates, CVs and
    115 settings (data is never shared between sites), and each site chooses independently whether
    116 deleting the plugin also deletes its hiring data. There is no network-level configuration screen; settings are per site.
     77Yes, activated per site or network-wide. Each site keeps its own jobs, candidates, CVs and settings (data is never shared between sites), and each site chooses independently whether deleting the plugin also deletes its hiring data. There is no network-level configuration screen; settings are per site.
    11778
    118 Network activation is the recommended setup: deleting a site then removes that site's Vakanssi
    119 data with it, and if some of its CVs cannot be deleted, Vakanssi keeps the list of those files.
    120 With per-site activation, a site deleted where Vakanssi is not active keeps its Vakanssi tables,
    121 and its CVs when they are in a custom storage folder. Since 1.3.0 a super admin sees this data in
    122 Site Health and under **Hiring → Tools → Data**, and removes it there after a confirmation. When
    123 Vakanssi cannot prove a site's CV files are gone (for example a folder it cannot read), it keeps
    124 that site's file list and says why. A single site turned into a network keeps finding the CVs it
    125 stored before, and Site Health names the folder to move them from.
     79Network activation is the recommended setup: deleting a site then removes that site's Vakanssi data with it, and if some of its CVs cannot be deleted, Vakanssi keeps the list of those files. With per-site activation, a site deleted where Vakanssi is not active keeps its Vakanssi tables, and its CVs when they are in a custom storage folder. Since 1.3.0 a super admin sees this data in Site Health and under **Hiring → Tools → Data**, and removes it there after a confirmation. When Vakanssi cannot prove a site's CV files are gone (for example a folder it cannot read), it keeps that site's file list and says why. A single site turned into a network keeps finding the CVs it stored before, and Site Health names the folder to move them from.
    12680
    12781= Does it work on Nginx? =
    12882
    129 Yes. Nginx ignores `.htaccess`, so add the generated `location` block to your server config. The
    130 plugin's screens show the rule, and Site Health flags the folder, when it is reachable.
     83Yes. Nginx ignores `.htaccess`, so add the generated `location` block to your server config. The plugin's screens show the rule, and Site Health flags the folder, when it is reachable.
    13184
    13285= Does it work with my theme and page builder? =
    13386
    134 Yes, and you do not have to fall back to a shortcode. The block editor gets a **Job Listings**
    135 block. **Elementor** gets three native widgets (the listing, the application form, and the job
    136 details) grouped under a Vakanssi section in the panel, and they work with the free Elementor; if
    137 you run Elementor Pro, your Theme Builder archive and single templates for jobs are used instead of
    138 ours. **Divi** gets a Jobs module. Shortcodes (`[vakanssi_jobs]`, `[vakanssi_job_apply]`,
    139 `[vakanssi_job_details]`) still work anywhere else, including builders with no dedicated
    140 integration.
     87Yes, and you do not have to fall back to a shortcode. The block editor gets a **Job Listings** block. **Elementor** gets three native widgets (the listing, the application form, and the job details) grouped under a Vakanssi section in the panel, and they work with the free Elementor; if you run Elementor Pro, your Theme Builder archive and single templates for jobs are used instead of ours. **Divi** gets a Jobs module. Shortcodes (`[vakanssi_jobs]`, `[vakanssi_job_apply]`, `[vakanssi_job_details]`) still work anywhere else, including builders with no dedicated integration.
    14188
    142 Themes need nothing special. Block themes on WordPress 6.7 and later get editable "Jobs archive" (while the archive page is on)
    143 and "Single job" templates in the Site Editor, built from your own header and footer; classic themes get the built-in archive. The
    144 candidate-facing pages are styled so they survive a theme's own CSS reset, so the listing and the
    145 apply button look the same whichever theme you run.
     89Themes need nothing special. Block themes on WordPress 6.7 and later get editable "Jobs archive" (while the archive page is on) and "Single job" templates in the Site Editor, built from your own header and footer; classic themes get the built-in archive. The candidate-facing pages are styled so they survive a theme's own CSS reset, so the listing and the apply button look the same whichever theme you run.
    14690
    14791= Can I restyle the careers/job pages, and will custom CSS slow my site down? =
    14892
    149 Yes. Under **Hiring → Settings → Jobs & Careers → Appearance** you can turn off Vakanssi's front-end stylesheet
    150 entirely, if your theme styles the markup. For your own styling, use WordPress's built-in editor at
    151 **Appearance → Customize → Additional CSS**, which adds no extra request. Vakanssi keeps its own
    152 selectors as light as theme-proofing allows and its class names stable. Match their weight, such as
    153 `.vakanssi-apply-form .vakanssi-apply-button` for the application form's Submit button or
    154 `:root p.vakanssi-apply a.vakanssi-apply-button` for a job's Apply link, and style `:hover`, `:focus` and
    155 `:active` as well, since Vakanssi sets those too. On most pages that is enough without `!important`.
     93Yes. Under **Hiring → Settings → Jobs & Careers → Appearance** you can turn off Vakanssi's front-end stylesheet entirely, if your theme styles the markup. For your own styling, use WordPress's built-in editor at **Appearance → Customize → Additional CSS**, which adds no extra request. Vakanssi keeps its own selectors as light as theme-proofing allows and its class names stable. Match their weight, such as `.vakanssi-apply-form .vakanssi-apply-button` for the application form's Submit button or `:root p.vakanssi-apply a.vakanssi-apply-button` for a job's Apply link, and style `:hover`, `:focus` and `:active` as well, since Vakanssi sets those too. On most pages that is enough without `!important`.
    15694
    157 The same `vakanssi-` class names are on the careers and job pages under block themes and classic
    158 themes alike, so one rule covers both. On a block theme your theme keeps control of the spacing,
    159 and Vakanssi sets only the column the careers page, the jobs archive and a job share: override it with
    160 `.vakanssi-careers-page { --wp--style--global--content-size: 1100px; --wp--style--global--wide-size: 1100px; }`
    161 (the same on `.vakanssi-careers-archive` and `.vakanssi-single-job`). The job list keeps a 960px reading
    162 width inside that column; add `--vakanssi-measure: 1100px;` to the same rule to widen the list too.
     95The same `vakanssi-` class names are on the careers and job pages under block themes and classic themes alike, so one rule covers both. On a block theme your theme keeps control of the spacing, and Vakanssi sets only the column the careers page, the jobs archive and a job share: override it with `.vakanssi-careers-page { --wp--style--global--content-size: 1100px; --wp--style--global--wide-size: 1100px; }` (the same on `.vakanssi-careers-archive` and `.vakanssi-single-job`). The job list keeps a 960px reading width inside that column; add `--vakanssi-measure: 1100px;` to the same rule to widen the list too.
    16396
    16497= Do I need any special server setup for a production site? =
    16598
    166 Two things are worth doing on a live hiring site, and both are standard WordPress production
    167 hygiene rather than Vakanssi requirements. First, switch WordPress to a real cron trigger:
    168 out of the box, WordPress runs scheduled tasks only when someone visits your site, so on a
    169 quiet careers site scheduled work can run late. Vakanssi relies on it to purge candidate data once
    170 its retention period is up. Add `define( 'DISABLE_WP_CRON', true );` to `wp-config.php` and trigger
    171 `wp-cron.php` every few minutes; most managed hosts offer this as a checkbox. Second, if your
    172 host offers a persistent object cache (Redis or Memcached), enable it: Vakanssi uses
    173 transients for its dashboard counters, and an object cache keeps those out of the database
    174 under heavy traffic. Apply-form rate limits always use the database, so they hold either way. Nothing breaks without either step.
     99Two things are worth doing on a live hiring site, and both are standard WordPress production hygiene rather than Vakanssi requirements. First, switch WordPress to a real cron trigger: out of the box, WordPress runs scheduled tasks only when someone visits your site, so on a quiet careers site scheduled work can run late. Vakanssi relies on it to purge candidate data once its retention period is up. Add `define( 'DISABLE_WP_CRON', true );` to `wp-config.php` and trigger `wp-cron.php` every few minutes; most managed hosts offer this as a checkbox. Second, if your host offers a persistent object cache (Redis or Memcached), enable it: Vakanssi uses transients for its dashboard counters, and an object cache keeps those out of the database under heavy traffic. Apply-form rate limits always use the database, so they hold either way. Nothing breaks without either step.
    175100
    176101= Can I disable the /jobs/ archive page? =
    177102
    178 Yes: **Hiring → Settings → Jobs & Careers → Job URLs** → "Archive page". Single job pages stay
    179 live under your job URL base (e.g. /jobs/job-title/); the archive URL becomes available for your own
    180 page, such as a Careers page using the [vakanssi_jobs] shortcode.
     103Yes: **Hiring → Settings → Jobs & Careers → Job URLs** → "Archive page". Single job pages stay live under your job URL base (e.g. /jobs/job-title/); the archive URL becomes available for your own page, such as a Careers page using the [vakanssi_jobs] shortcode.
    181104
    182105= What stops two recruiters overwriting each other on the board? =
    183106
    184 Every save carries the state the screen was showing when you started editing. If someone else
    185 changed that candidate first, the save is refused and you are shown what changed instead of
    186 quietly losing one of the two edits. This runs over ordinary REST requests, so it needs nothing
    187 special on your server and works on any host that runs WordPress normally.
     107Every save carries the state the screen was showing when you started editing. If someone else changed that candidate first, the save is refused and you are shown what changed instead of quietly losing one of the two edits. This runs over ordinary REST requests, so it needs nothing special on your server and works on any host that runs WordPress normally.
    188108
    189109= Can I switch from another job or recruitment plugin? =
    … …  
    195115It is a job board for your own organisation: your openings on a careers page on your own site, with the applications that come in managed in the same place. It is not a multi-employer board where other companies sign up and post their own jobs.
    196116
     117= Can I use Vakanssi with an AI assistant? =
     118
     119Yes, on WordPress 6.9 and later. Install the free MCP Adapter plugin and connect an assistant that supports MCP (such as Claude or Cursor) with an application password. It can then list your jobs, read one and create a draft, with the same permissions as the user it signs in as. Vakanssi itself contacts no AI service: your assistant connects to your site.
     120
     121None of these abilities read applications or CVs.
     122
    197123= Is there a Pro version? =
    198124
    … …  
    202128
    2031291. The hiring pipeline. Drag candidates between your own stages, with a live count on each and ratings, attachments and dates at a glance.
     130
    2041312. A candidate. CV on file with an inline preview, rating, notes, interviews and the full history, without leaving the board.
     132
    2051333. Your careers page. Branded, filterable, and marked up for Google for Jobs.
     134
    2061354. The application form. Secure CV upload, LinkedIn and cover letter, on your own job page.
     136
    2071375. Interviews. Schedule an interview and send a real calendar invite, with internal notes only your interviewers see.
     138
    2081396. Setup. Three short steps. It looks at your site first and offers to connect an existing careers page instead of creating a duplicate.
    209140
    210141== External services ==
    211142
    212 Vakanssi does not contact any external service on its own. Everything it stores stays on
    213 your server. One optional integration talks to a third party, and only after you switch it
    214 on and enter your own credentials:
     143Vakanssi does not contact any external service on its own. Everything it stores stays on your server. One optional integration talks to a third party, and only after you switch it on and enter your own credentials:
    215144
    216145**Cloudflare Turnstile** (optional spam protection for the public application form)
    217146
    218 Turnstile is off by default. It activates only once you enter a Turnstile site key and
    219 secret under Hiring → Settings → Application form. While it is enabled:
     147Turnstile is off by default. It activates only once you enter a Turnstile site key and secret under Hiring → Settings → Application form. While it is enabled:
    220148
    221 * each visitor's browser loads the challenge script from
    222   `https://challenges.cloudflare.com/turnstile/v0/api.js`;
    223 * when someone submits an application, the resulting challenge token, the visitor's IP
    224   address and your secret key are sent to
    225   `https://challenges.cloudflare.com/turnstile/v0/siteverify` so Cloudflare can confirm the
    226   submission is not automated;
    227 * when an administrator uses "Test these keys" on the settings screen, that admin's browser
    228   loads the same challenge script, and the resulting token, the admin's IP address and the
    229   secret key being tested are sent to the same address, so the key pair can be checked
    230   without waiting for a real application.
     149* each visitor's browser loads the challenge script from `https://challenges.cloudflare.com/turnstile/v0/api.js`;
    231150
    232 No application content (no name, email, CV, or answers) is sent to Cloudflare. Turning the
    233 setting off stops all contact with the service.
     151* when someone submits an application, the resulting challenge token, the visitor's IP address and your secret key are sent to `https://challenges.cloudflare.com/turnstile/v0/siteverify` so Cloudflare can confirm the submission is not automated;
     152
     153* when an administrator uses "Test these keys" on the settings screen, that admin's browser loads the same challenge script, and the resulting token, the admin's IP address and the secret key being tested are sent to the same address, so the key pair can be checked without waiting for a real application.
     154
     155No application content (no name, email, CV, or answers) is sent to Cloudflare. Turning the setting off stops all contact with the service.
    234156
    235157Service: https://www.cloudflare.com/products/turnstile/
    … …  
    238160
    239161== Changelog ==
     162= 1.3.19 =
     163* New: AI assistants connected through the WordPress Abilities API (WordPress 6.9+, with the MCP Adapter plugin) can list jobs, read a job and create a job draft. Drafts are never published, and scripts are stripped from the text.
     164* Improved: sample data now includes CVs, ratings, notes, an interview, email history and activity, so the board looks lived in.
     165* Fixed: on dark themes the careers list, job page and their links were nearly invisible (job titles at 1.17:1). Text on the page now follows the theme's own text colour, keyboard focus rings included, and on light themes nothing changes.
     166* Fixed: on light themes with a tinted background, grey and brand-colour text on the careers page now reads at 4.5:1 or better, whatever brand colour is set.
     167* Fixed: moving an application into a stage from another job's pipeline is now refused.
     168
    240169= 1.3.18 =
    241170* Fixed: when someone applied again at the same moment their application, person or data was deleted, erased or purged, the new details or the whole application could be left behind or attached to nobody. Every write onto an existing application or person now waits for, or is refused by, a delete in progress.
    … …  
    255184* Developers: new application meta submitted_details, included in the personal data export and removed by erasure and retention.
    256185
    257 = 1.3.16 =
    258 * New: after an import from WP Job Openings or Simple Job Board, Tools > Import finds the CV files the old plugin still keeps in its uploads folder, which your web server may serve to anyone with the link. Delete the files Vakanssi holds a checked copy of in one click. Files with no copy in Vakanssi are listed and need a second confirmation. Until the folder is clean, a reminder shows on Vakanssi screens, in Site Health and under Tools > Status.
    259 * Changed: the import's finish note no longer says you can deactivate the old plugin while its CV files are still there.
    260 * Developers: new options vakanssi_import_cleanup_* and vakanssi_import_check_*, and user meta vakanssi_legacy_files_snoozed, all removed on uninstall.
    261 
  • vakanssi/tags/1.3.19/src/Admin/SampleContent.php

    r3803675 r3813839  
    88namespace Vakanssi\Admin;
    99
     10use Vakanssi\Database\Repositories\ActivityRepository;
    1011use Vakanssi\Database\Repositories\ApplicationMetaRepository;
    1112use Vakanssi\Database\Repositories\ApplicationRepository;
    1213use Vakanssi\Database\Repositories\CandidateRepository;
     14use Vakanssi\Database\Repositories\FileRepository;
     15use Vakanssi\Database\Repositories\InterviewRepository;
     16use Vakanssi\Database\Repositories\NoteRepository;
     17use Vakanssi\Database\Repositories\StageEventRepository;
     18use Vakanssi\Modules\Email\EmailTemplates;
     19use Vakanssi\Modules\Email\Mailer;
     20use Vakanssi\Modules\Email\Notifications;
     21use Vakanssi\Modules\Import\Sources\AbstractSource;
     22use Vakanssi\Modules\Interviews\InterviewerRoster;
     23use Vakanssi\Modules\Interviews\InterviewService;
    1324use Vakanssi\Modules\Jobs\JobFields;
    1425use Vakanssi\Modules\Jobs\JobPostType;
    … …  
    1728use Vakanssi\Modules\Pipeline\StageService;
    1829use Vakanssi\Security\Capabilities;
     30use Vakanssi\Security\ProtectedStorage;
    1931use Vakanssi\Support\EmailIdentity;
    2032use Vakanssi\Support\Transaction;
    … …  
    3446 * @example.com candidate plus recruiter notifications during setup. Direct
    3547 * inserts also allow staggered `created_at` values so the board looks lived-in.
     48 *
     49 * The applications carry what a worked candidate has, so the drawer's tabs are
     50 * not empty ({@see seed_history()}): a CV in protected storage, ratings, team
     51 * notes, one upcoming interview, the email log and the stage history. The same
     52 * rule holds for each of them: nothing is mailed and no `vakanssi/*` action
     53 * fires, so no calendar invite or notification leaves the site.
    3654 *
    3755 * Everything created is flagged (post meta on jobs, an application_meta row on
    … …  
    5977
    6078        /**
    61          * Option (vakanssi_ prefixed via helpers) recording sample candidate ids.
     79         * Option (vakanssi_ prefixed via helpers) recording sample candidate ids
     80         * (`candidates`) and the activity rows the seed wrote (`activity`,
     81         * application id => row ids).
    6282         */
    6383        const OPTION = 'sample_content';
     84
     85        /**
     86         * Key set to true in the `changes` of every activity row the seed writes.
     87         * Removal deletes only recorded rows that carry it, so a recorded id that
     88         * has come to name a real row (the tables emptied and their ids reused)
     89         * is never deleted. Readers of `changes` ignore keys they do not know.
     90         */
     91        const ACTIVITY_MARK = 'sample_content';
    6492
    6593        /**
    … …  
    160188                $recorded_ids    = array();
    161189                $application_ids = array();
     190                $seeded          = array();
    162191
    163192                foreach ( $this->candidate_definitions() as $definition ) {
    … …  
    183212                        $candidate_ids[] = $candidate_id;
    184213
    185                         $slot    = $slots[ $definition['stage'] ];
    186                         $created = gmdate( 'Y-m-d H:i:s', time() - ( $definition['days_ago'] * DAY_IN_SECONDS ) );
    187                         $job_id  = $job_ids[ $definition['job'] ];
     214                        $slot       = $slots[ $definition['stage'] ];
     215                        $created_ts = time() - ( $definition['days_ago'] * DAY_IN_SECONDS );
     216                        $created    = gmdate( 'Y-m-d H:i:s', $created_ts );
     217                        $job_id     = $job_ids[ $definition['job'] ];
    188218
    189219                        $application_id = (int) $applications->insert(
    … …  
    195225                                        'status'          => $stage_service->status_for_type( $slot['type'] ),
    196226                                        'source'          => $definition['source'],
     227                                        'rating'          => $definition['rating'],
    197228                                        'payload'         => wp_json_encode( array( 'sample' => true ) ),
    198229                                        'consent_given'   => 1,
    … …  
    204235                        );
    205236
     237                        if ( $application_id <= 0 ) {
     238                                // The insert failed. Nothing may hang off application 0: a CV,
     239                                // notes or history written there would be reachable by no
     240                                // removal. The candidate is recorded, and removal deletes it as
     241                                // a candidate with no application.
     242                                continue;
     243                        }
     244
    206245                        $meta_repo->add( $application_id, self::APP_FLAG, '1' );
    207246                        if ( '' !== $definition['cover_letter'] ) {
    … …  
    210249
    211250                        $application_ids[] = $application_id;
     251                        $seeded[]          = array(
     252                                'definition'     => $definition,
     253                                'application_id' => $application_id,
     254                                'candidate_id'   => $candidate_id,
     255                                'job_id'         => $job_id,
     256                                'created'        => $created_ts,
     257                        );
    212258                }
    213259
    214260                // Merge, never rebuild: an option written by an older seed may carry
    215261                // removal-bookkeeping keys that removal still needs, so preserve whatever
    216                 // is already here rather than overwriting it.
     262                // is already here rather than overwriting it. The candidates are
     263                // recorded before the history is written (file copies and all), so a
     264                // seed cut short there still leaves them where removal looks.
    217265                $option = (array) vakanssi_option( self::OPTION, array() );
    218266                vakanssi_update_option(
    … …  
    221269                                $option,
    222270                                array(
    223                                         'candidates' => $recorded_ids,
     271                                        // Added to, never replaced: candidates an earlier seed
     272                                        // recorded may still be on the site (their applications
     273                                        // deleted by hand), and this seed reuses them unrecorded.
     274                                        'candidates' => array_values( array_unique( array_merge( isset( $option['candidates'] ) ? array_map( 'intval', (array) $option['candidates'] ) : array(), $recorded_ids ) ) ),
    224275                                        'seeded_at'  => current_time( 'mysql', true ),
    225276                                )
    226277                        )
    227278                );
     279
     280                $this->seed_history( $seeded, $slots, $stage_service );
    228281
    229282                return array(
    … …  
    232285                        'applications' => $application_ids,
    233286                );
     287        }
     288
     289        /**
     290         * Give the seeded applications the history a worked candidate has, so the
     291         * drawer's tabs show the product instead of empty states: the CV, team
     292         * notes, the upcoming interview, the emails and the moves through the
     293         * pipeline. Ratings are set on the application rows themselves.
     294         *
     295         * Every write goes through a repository, never a service that sends or
     296         * announces: no wp_mail(), no calendar invite, no `vakanssi/*` action, so
     297         * nothing is announced and nothing leaves the site.
     298         * Each part whose module is switched off is skipped, and so are notes and
     299         * the interview when there is nobody to attribute them to.
     300         *
     301         * Times are UTC and follow each application's age: received, moved along
     302         * at even intervals since, notes in between, nothing in the future except
     303         * the interview itself.
     304         *
     305         * @param array<int, array<string, mixed>> $seeded        One entry per application: definition, application_id, candidate_id, job_id, created (Unix time).
     306         * @param array<string, array>             $slots         Stage slots from stage_slots().
     307         * @param StageService                     $stage_service Stage service.
     308         * @return array<int, int[]> Application id => ids of the activity rows written on it. Each
     309         *                           row is also recorded in {@see OPTION} as soon as it is written,
     310         *                           so a seed cut short leaves none unrecorded.
     311         */
     312        private function seed_history( array $seeded, array $slots, StageService $stage_service ) {
     313                $now       = time();
     314                $actor     = $this->acting_user_id();
     315                $activity  = new ActivityRepository();
     316                $notes     = vakanssi_module_active( 'notes' ) && $actor > 0 ? new NoteRepository() : null;
     317                $mail      = Mailer::sending_enabled() ? new Notifications() : null;
     318                $templates = new EmailTemplates();
     319                $written   = array();
     320
     321                foreach ( $seeded as $app ) {
     322                        $definition     = $app['definition'];
     323                        $application_id = (int) $app['application_id'];
     324                        $created        = (int) $app['created'];
     325
     326                        $written[ $application_id ]   = array();
     327                        $written[ $application_id ][] = (int) $activity->insert(
     328                                array(
     329                                        'entity_type' => 'application',
     330                                        'entity_id'   => $application_id,
     331                                        'user_id'     => 0,
     332                                        'action'      => 'application_created',
     333                                        'changes'     => wp_json_encode(
     334                                                array(
     335                                                        'job_id'            => (int) $app['job_id'],
     336                                                        self::ACTIVITY_MARK => true,
     337                                                )
     338                                        ),
     339                                        'ip_address'  => '',
     340                                        'created_at'  => gmdate( 'Y-m-d H:i:s', $created ),
     341                                )
     342                        );
     343                        $this->record_activity( $application_id, $written[ $application_id ] );
     344
     345                        if ( ! empty( $definition['cv'] ) ) {
     346                                $this->attach_sample_cv( $application_id, (int) $app['candidate_id'], $definition, $created );
     347                        }
     348
     349                        // The confirmation goes out as the application lands, when the
     350                        // template is on (a site that turned it off would not have sent it).
     351                        if ( $mail && $templates->is_enabled( 'confirmation' ) ) {
     352                                $mail->log_sample_send( 'confirmation', $application_id, gmdate( 'Y-m-d H:i:s', $created + MINUTE_IN_SECONDS ) );
     353                        }
     354
     355                        $moves = $this->seed_moves( $app, $slots, $stage_service, $actor, $now, $written[ $application_id ] );
     356
     357                        // A rejection follows the move when the template is on; the offer is
     358                        // off by default, so it reads as the recruiter's "Send email & move".
     359                        if ( $mail && isset( $moves['rejected'] ) && $templates->is_enabled( 'reject' ) ) {
     360                                $mail->log_sample_send( 'reject', $application_id, gmdate( 'Y-m-d H:i:s', $moves['rejected'] + MINUTE_IN_SECONDS ), (int) $slots['rejected']['id'] );
     361                        }
     362                        if ( $mail && isset( $moves['hired'] ) ) {
     363                                $mail->log_sample_send( 'offer', $application_id, gmdate( 'Y-m-d H:i:s', $moves['hired'] + MINUTE_IN_SECONDS ), (int) $slots['hired']['id'] );
     364                        }
     365
     366                        if ( $notes ) {
     367                                foreach ( $definition['notes'] as $note ) {
     368                                        // A share of the application's age, never later than half an
     369                                        // hour ago.
     370                                        $at = min( $now - 30 * MINUTE_IN_SECONDS, $created + (int) ( $note[0] * ( $now - $created ) ) );
     371                                        $notes->insert(
     372                                                array(
     373                                                        'application_id' => $application_id,
     374                                                        'user_id'        => $actor,
     375                                                        'body'           => $note[1],
     376                                                        'mentions'       => '[]',
     377                                                        'created_at'     => gmdate( 'Y-m-d H:i:s', $at ),
     378                                                )
     379                                        );
     380                                }
     381                        }
     382
     383                        if ( ! empty( $definition['interview'] ) && isset( $moves['interview'] ) && $actor > 0 && vakanssi_module_active( 'interviews' ) ) {
     384                                $this->seed_interview( $app, $slots['interview'], $actor, $moves['interview'], $now );
     385                        }
     386                }
     387
     388                return array_filter( array_map( 'array_filter', $written ) );
     389        }
     390
     391        /**
     392         * Walk one application from the entry stage to where it sits, writing the
     393         * `stage_changed` audit row each move leaves (the drawer's Activity tab).
     394         *
     395         * On a pipeline with fewer stages a missing slot points at the entry
     396         * stage, so the walk skips a stage already passed and stops at the one the
     397         * application is in: never a move backwards, never one past it.
     398         *
     399         * @param array<string, mixed> $app           Seeded application entry.
     400         * @param array<string, array> $slots         Stage slots.
     401         * @param StageService         $stage_service Stage service.
     402         * @param int                  $actor         User credited with the moves.
     403         * @param int                  $now           Unix time of the seed.
     404         * @param int[]                $written       Activity ids written on this application (appended to).
     405         * @return array<string, int> Slot name => Unix time of the move into it.
     406         */
     407        private function seed_moves( array $app, array $slots, StageService $stage_service, $actor, $now, array &$written ) {
     408                $paths = array(
     409                        'new'       => array(),
     410                        'in_review' => array( 'in_review' ),
     411                        'interview' => array( 'in_review', 'interview' ),
     412                        'offer'     => array( 'in_review', 'interview', 'offer' ),
     413                        'hired'     => array( 'in_review', 'interview', 'offer', 'hired' ),
     414                        'rejected'  => array( 'in_review', 'rejected' ),
     415                );
     416
     417                $stage_key      = (string) $app['definition']['stage'];
     418                $application_id = (int) $app['application_id'];
     419                $created        = (int) $app['created'];
     420                $from           = (int) $slots['new']['id'];
     421                $target         = (int) $slots[ $stage_key ]['id'];
     422                $steps          = $target === $from ? array() : $paths[ $stage_key ];
     423                $count          = count( $steps );
     424                $last           = $created;
     425                $visited        = array( $from => true );
     426                $moves          = array();
     427                $activity       = new ActivityRepository();
     428
     429                foreach ( $steps as $i => $step ) {
     430                        $to = (int) $slots[ $step ]['id'];
     431                        if ( isset( $visited[ $to ] ) ) {
     432                                continue;
     433                        }
     434                        $visited[ $to ] = true;
     435
     436                        // Evenly spaced across the application's age, at least an hour
     437                        // apart, and never later than an hour ago.
     438                        $at   = min( $now - HOUR_IN_SECONDS, max( $last + HOUR_IN_SECONDS, $created + (int) ( ( $i + 1 ) * ( $now - $created ) / ( $count + 1 ) ) ) );
     439                        $last = $at;
     440                        $when = gmdate( 'Y-m-d H:i:s', $at );
     441
     442                        $status    = $stage_service->status_for_type( $slots[ $step ]['type'] );
     443                        $written[] = (int) $activity->insert(
     444                                array(
     445                                        'entity_type' => 'application',
     446                                        'entity_id'   => $application_id,
     447                                        'user_id'     => (int) $actor,
     448                                        'action'      => 'stage_changed',
     449                                        'changes'     => wp_json_encode(
     450                                                array(
     451                                                        'from'              => $from,
     452                                                        'to'                => $to,
     453                                                        'status'            => $status,
     454                                                        self::ACTIVITY_MARK => true,
     455                                                )
     456                                        ),
     457                                        'ip_address'  => '',
     458                                        'created_at'  => $when,
     459                                )
     460                        );
     461                        $this->record_activity( $application_id, $written );
     462
     463                        $moves[ $step ] = $at;
     464                        $from           = $to;
     465                        if ( $to === $target ) {
     466                                break;
     467                        }
     468                }
     469
     470                return $moves;
     471        }
     472
     473        /**
     474         * Book the sample interview: two days out at 14:00 UTC, with the seeding
     475         * user as organizer and, when they are on the hiring roster, interviewer.
     476         *
     477         * Written through the repository in the shape InterviewService::schedule()
     478         * stores, because schedule() mails the calendar invite to the candidate
     479         * and the interviewers and fires `vakanssi/interview/scheduled`. A sample
     480         * candidate has an @example.com address, and a real site must never mail
     481         * one, so there is no send to suppress: none is attempted.
     482         *
     483         * @param array<string, mixed> $app      Seeded application entry.
     484         * @param array<string, mixed> $slot     The Interview stage slot.
     485         * @param int                  $actor    Organizer user id.
     486         * @param int                  $moved_at Unix time of the move into Interview.
     487         * @param int                  $now      Unix time of the seed.
     488         * @return int Interview id, or 0.
     489         */
     490        private function seed_interview( array $app, array $slot, $actor, $moved_at, $now ) {
     491                $definition = $app['definition'];
     492                $day        = $now + 2 * DAY_IN_SECONDS;
     493                $start      = gmmktime( 14, 0, 0, (int) gmdate( 'n', $day ), (int) gmdate( 'j', $day ), (int) gmdate( 'Y', $day ) );
     494
     495                return ( new InterviewRepository() )->insert(
     496                        array(
     497                                'application_id'  => (int) $app['application_id'],
     498                                'candidate_id'    => (int) $app['candidate_id'],
     499                                'job_title'       => get_the_title( (int) $app['job_id'] ),
     500                                'organizer_id'    => (int) $actor,
     501                                'interviewers'    => (string) wp_json_encode( InterviewerRoster::valid_ids( array( (int) $actor ) ) ),
     502                                'title'           => InterviewService::stored_title( $definition['interview']['title'], '' ),
     503                                'stage_id'        => (int) $slot['id'],
     504                                'mode'            => 'video',
     505                                'location'        => '',
     506                                'status'          => 'scheduled',
     507                                'scheduled_at'    => gmdate( 'Y-m-d H:i:s', $start ),
     508                                'duration'        => 60,
     509                                'slots'           => null,
     510                                'token'           => wp_generate_password( 32, false ),
     511                                'candidate_name'  => $definition['first_name'] . ' ' . $definition['last_name'],
     512                                'candidate_email' => $definition['email'],
     513                                'ics_uid'         => InterviewService::new_ics_uid(),
     514                                'sequence'        => 0,
     515                                'notes'           => $definition['interview']['notes'],
     516                                'created_at'      => gmdate( 'Y-m-d H:i:s', min( $now, $moved_at + 30 * MINUTE_IN_SECONDS ) ),
     517                        )
     518                );
     519        }
     520
     521        /**
     522         * Store a generated one-page PDF as the application's CV, through the
     523         * same verified copy into protected storage that imported CVs take
     524         * ({@see AbstractSource::copy_verified_into_storage()}: extension and
     525         * size checks, the PDF signature check, a random file name, 0600). It is
     526         * then served like any CV, by the authenticated download endpoint, and
     527         * deleted with the application.
     528         *
     529         * The PDF is written to the system temp folder for that copy and deleted
     530         * straight after. When storage cannot take it, the application simply has
     531         * no CV.
     532         *
     533         * @param int                  $application_id Application id.
     534         * @param int                  $candidate_id   Candidate id.
     535         * @param array<string, mixed> $definition     Candidate definition.
     536         * @param int                  $created        Unix time the application arrived.
     537         * @return int File row id, or 0.
     538         */
     539        private function attach_sample_cv( $application_id, $candidate_id, array $definition, $created ) {
     540                $storage = new ProtectedStorage();
     541                $tmp     = trailingslashit( get_temp_dir() ) . 'vakanssi-sample-cv-' . wp_generate_password( 12, false ) . '.pdf';
     542                $pdf     = self::sample_cv_pdf( $definition['first_name'] . ' ' . $definition['last_name'], $definition['cv']['headline'], $definition['cv']['lines'] );
     543
     544                if ( false === file_put_contents( $tmp, $pdf ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents -- a generated sample CV written to the system temp folder for the verified copy below and deleted right after; WP_Filesystem may need FTP credentials, which the Playground and the setup wizard cannot supply.
     545                        return 0;
     546                }
     547                $stored = AbstractSource::copy_verified_into_storage( $storage, $tmp );
     548                wp_delete_file( $tmp );
     549                if ( null === $stored ) {
     550                        return 0;
     551                }
     552
     553                $files   = new FileRepository();
     554                $file_id = (int) $files->insert(
     555                        array(
     556                                'application_id' => (int) $application_id,
     557                                'candidate_id'   => (int) $candidate_id,
     558                                'path'           => $stored['path'],
     559                                'filename'       => ProtectedStorage::safe_filename( $definition['first_name'] . '-' . $definition['last_name'] . '-CV.pdf' ),
     560                                'mime'           => $stored['mime'],
     561                                'size'           => $stored['size'],
     562                                'hash'           => $stored['hash'],
     563                                'created_at'     => gmdate( 'Y-m-d H:i:s', (int) $created ),
     564                        )
     565                );
     566                if ( ! $file_id ) {
     567                        // A row that did not land must not leave its bytes behind.
     568                        $storage->delete_stored( $stored['path'] );
     569                }
     570
     571                return $file_id;
     572        }
     573
     574        /**
     575         * A minimal one-page PDF: the name, a headline, three lines and a footer
     576         * saying it is sample data. Standard Helvetica, so nothing is embedded;
     577         * the cross-reference offsets are computed, so viewers open it without a
     578         * repair pass. Text is ASCII by construction (the definitions below).
     579         *
     580         * @param string   $name     Candidate name.
     581         * @param string   $headline One-line headline.
     582         * @param string[] $lines    Body lines.
     583         * @return string PDF bytes.
     584         */
     585        public static function sample_cv_pdf( $name, $headline, array $lines ) {
     586                $text = static function ( $value ) {
     587                        $value = (string) preg_replace( '/[^\x20-\x7E]/', '', (string) $value );
     588
     589                        return '(' . strtr(
     590                                $value,
     591                                array(
     592                                        '\\' => '\\\\',
     593                                        '('  => '\\(',
     594                                        ')'  => '\\)',
     595                                )
     596                        ) . ')';
     597                };
     598
     599                $stream  = 'BT /F1 22 Tf 56 770 Td ' . $text( $name ) . " Tj ET\n";
     600                $stream .= 'BT /F2 13 Tf 56 744 Td ' . $text( $headline ) . " Tj ET\n";
     601                $stream .= "BT /F2 11 Tf 16 TL 56 708 Td\n";
     602                foreach ( array_values( $lines ) as $i => $line ) {
     603                        $stream .= ( $i > 0 ? 'T* ' : '' ) . $text( $line ) . " Tj\n";
     604                }
     605                $stream .= "ET\n";
     606                $stream .= 'BT /F2 9 Tf 56 56 Td ' . $text( 'Sample CV created by Vakanssi to show how CVs look. Not a real person.' ) . " Tj ET\n";
     607
     608                $objects = array(
     609                        '<< /Type /Catalog /Pages 2 0 R >>',
     610                        '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
     611                        '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 4 0 R /F2 5 0 R >> >> /Contents 6 0 R >>',
     612                        '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>',
     613                        '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>',
     614                        '<< /Length ' . strlen( $stream ) . " >>\nstream\n" . $stream . 'endstream',
     615                );
     616
     617                $pdf     = "%PDF-1.4\n";
     618                $offsets = array();
     619                foreach ( $objects as $i => $object ) {
     620                        $offsets[] = strlen( $pdf );
     621                        $pdf      .= ( $i + 1 ) . " 0 obj\n" . $object . "\nendobj\n";
     622                }
     623
     624                $xref = strlen( $pdf );
     625                $pdf .= 'xref' . "\n0 " . ( count( $objects ) + 1 ) . "\n0000000000 65535 f \n";
     626                foreach ( $offsets as $offset ) {
     627                        $pdf .= sprintf( "%010d 00000 n \n", $offset );
     628                }
     629                $pdf .= 'trailer' . "\n<< /Size " . ( count( $objects ) + 1 ) . " /Root 1 0 R >>\nstartxref\n" . $xref . "\n%%EOF\n";
     630
     631                return $pdf;
     632        }
     633
     634        /**
     635         * Record the activity rows written on one sample application, for removal.
     636         * Added to what is recorded, never replacing it: ids from an earlier seed
     637         * whose applications someone deleted by hand are still waiting there.
     638         *
     639         * @param int   $application_id Application id.
     640         * @param int[] $row_ids        Activity row ids.
     641         * @return void
     642         */
     643        private function record_activity( $application_id, array $row_ids ) {
     644                $row_ids = array_values( array_filter( array_map( 'intval', $row_ids ) ) );
     645                if ( array() === $row_ids ) {
     646                        return;
     647                }
     648
     649                $option   = (array) vakanssi_option( self::OPTION, array() );
     650                $recorded = isset( $option['activity'] ) && is_array( $option['activity'] ) ? $option['activity'] : array();
     651
     652                $recorded[ (int) $application_id ] = $row_ids;
     653                $option['activity']                = $recorded;
     654                vakanssi_update_option( self::OPTION, $option );
     655        }
     656
     657        /**
     658         * Who the sample notes, moves and interview are credited to: the user
     659         * running the seed when they can see applications, otherwise the first
     660         * administrator (the Playground blueprint seeds from a script with no
     661         * user, and bin/seed-demo-data.php credits the same person), otherwise
     662         * nobody (0), and those parts are skipped.
     663         *
     664         * @return int
     665         */
     666        private function acting_user_id() {
     667                $user_id = get_current_user_id();
     668                if ( $user_id > 0 && user_can( $user_id, Capabilities::VIEW_APPLICATIONS ) ) {
     669                        return (int) $user_id;
     670                }
     671
     672                $admins = get_users(
     673                        array(
     674                                'role'    => 'administrator',
     675                                'number'  => 1,
     676                                'fields'  => 'ID',
     677                                'orderby' => 'ID',
     678                                'order'   => 'ASC',
     679                        )
     680                );
     681
     682                return $admins ? (int) $admins[0] : 0;
    234683        }
    235684
    … …  
    255704                );
    256705
    257                 // 1. Applications first (full GDPR cascade: files, meta, notes, emails…).
    258                 $service = new ApplicationService();
     706                $option = (array) vakanssi_option( self::OPTION, array() );
     707
     708                // 1. Applications first. ApplicationService::delete() is the full GDPR
     709                // cascade, which covers everything the seed hangs off an application:
     710                // the CV (bytes first, then the row), meta, notes, the email log,
     711                // interviews and evaluations (PersonalDataCategories), the rating (a
     712                // column of the row itself) and, through StageEventLogger's
     713                // `vakanssi/application/deleted` listener, the stage events.
     714                $service      = new ApplicationService();
     715                $applications = new ApplicationRepository();
     716                $failed       = array();
    259717                foreach ( ( new ApplicationMetaRepository() )->application_ids_with( self::APP_FLAG ) as $application_id ) {
    260718                        if ( true === $service->delete( $application_id ) ) {
    261719                                ++$counts['applications'];
     720                        } else {
     721                                $failed[] = (int) $application_id;
     722                        }
     723                }
     724
     725                // The one thing that cascade keeps on purpose is the audit trail. The
     726                // rows the seed wrote there record nothing anyone did, so they go: the
     727                // ids recorded at seed time, per application. Only a sample application
     728                // this removal could not delete keeps its history, recorded for the
     729                // retry. Every other one goes, whether its application is gone (deleted
     730                // now, or by hand before) or still there without its sample flag (the
     731                // retention purge anonymises in place and clears the flag): kept, those
     732                // ids would sit in the option for good, since no removal reaches them.
     733                $history = array();
     734                foreach ( isset( $option['activity'] ) ? (array) $option['activity'] : array() as $application_id => $row_ids ) {
     735                        $application_id = (int) $application_id;
     736                        if ( $application_id <= 0 || ! is_array( $row_ids ) ) {
     737                                continue;
     738                        }
     739                        // Also kept when the delete itself failed, so a retry can find them.
     740                        if ( in_array( $application_id, $failed, true )
     741                                || false === ( new ActivityRepository() )->delete_ids_for_entities( $row_ids, 'application', array( $application_id ), '"' . self::ACTIVITY_MARK . '":true' ) ) {
     742                                $history[ $application_id ] = array_map( 'intval', $row_ids );
    262743                        }
    263744                }
    … …  
    266747                // remaining applications, so a candidate who later applied for a real
    267748                // job is kept.
    268                 $option     = (array) vakanssi_option( self::OPTION, array() );
    269749                $candidates = new CandidateRepository();
    270750                $ids        = isset( $option['candidates'] ) ? array_map( 'intval', (array) $option['candidates'] ) : array();
     751                $left       = array();
    271752                foreach ( $ids as $candidate_id ) {
    272753                        // The row is locked first, as every candidate delete does, and
    … …  
    279760                        if ( ! $removed ) {
    280761                                $tx->rollback();
     762                                $left[] = $candidate_id;
    281763                        } elseif ( $tx->commit() ) {
    282764                                ++$counts['candidates'];
     765                        } else {
     766                                $left[] = $candidate_id;
    283767                        }
    284768                }
    … …  
    287771                // applications are gone by now, so any application still pointing at
    288772                // a job is real: keep that job, as a draft, and unflag it.
     773                //
     774                // Except a job still holding a sample application this removal could
     775                // not delete: that application is not real, so the job stays a sample
     776                // job, flagged and hidden, for the retry to finish. Counted as real, it
     777                // was turned into an ordinary draft the retry could no longer find,
     778                // and the user was told real people had applied to it.
     779                $waiting = array();
     780                foreach ( $failed as $application_id ) {
     781                        $row = $applications->find( $application_id );
     782                        if ( $row ) {
     783                                $waiting[ (int) $row['job_id'] ] = true;
     784                        }
     785                }
    289786                foreach ( $this->sample_job_ids() as $job_id ) {
    290787                        $post = get_post( $job_id );
    … …  
    292789                                continue;
    293790                        }
    294                         if ( '1' !== get_post_meta( $job_id, self::JOB_FLAG, true ) ) {
     791                        if ( '1' !== get_post_meta( $job_id, self::JOB_FLAG, true ) || isset( $waiting[ (int) $job_id ] ) ) {
    295792                                continue;
    296793                        }
    … …  
    310807                }
    311808
    312                 vakanssi_update_option( self::OPTION, false );
    313                 delete_option( 'vakanssi_' . self::OPTION );
     809                if ( array() !== $failed || array() !== $history ) {
     810                        // A sample application could not be deleted (most often a CV whose
     811                        // bytes could not be removed), or its recorded history could not,
     812                        // so the removal is not finished. Keep what a retry needs to finish
     813                        // it: the candidates not removed yet and the history ids. Forgotten
     814                        // here, a retry would leave those candidates and rows behind for good.
     815                        vakanssi_update_option(
     816                                self::OPTION,
     817                                array(
     818                                        'candidates' => $left,
     819                                        'activity'   => $history,
     820                                )
     821                        );
     822                } else {
     823                        vakanssi_update_option( self::OPTION, false );
     824                        delete_option( 'vakanssi_' . self::OPTION );
     825                }
    314826                delete_option( 'vakanssi_' . SampleJobs::HIDDEN_OPTION );
    315827
    … …  
    5731085         * The seven sample candidates: every stage type covered, staggered ages.
    5741086         * Names/emails are intentionally fake (@example.com) and stay English —
    575          * this is throwaway demo data.
     1087         * this is throwaway demo data. So do the notes, CV lines and interview
     1088         * details: they stand for what a team and a candidate wrote, which is in
     1089         * their own language, not the site's.
     1090         *
     1091         * Each entry also carries its depth: `rating` (0 to 4, 0 is unrated),
     1092         * `notes` (share of the application's age at which each was written, and
     1093         * its text), `cv` (headline and three lines of a generated PDF, or empty)
     1094         * and `interview` (title and staff notes of an upcoming interview, or
     1095         * empty). Reviewed candidates (In Review and later) are rated.
    5761096         *
    5771097         * @return array<int, array<string, mixed>>
    … …  
    5881108                                'days_ago'     => 1,
    5891109                                'cover_letter' => '',
     1110                                'rating'       => 0,
     1111                                'notes'        => array(),
     1112                                'cv'           => array(),
     1113                                'interview'    => array(),
    5901114                        ),
    5911115                        array(
    … …  
    5981122                                'days_ago'     => 2,
    5991123                                'cover_letter' => '',
     1124                                'rating'       => 0,
     1125                                'notes'        => array(),
     1126                                'cv'           => array(),
     1127                                'interview'    => array(),
    6001128                        ),
    6011129                        array(
    … …  
    6081136                                'days_ago'     => 4,
    6091137                                'cover_letter' => 'I have led design systems at two B2B SaaS companies and would love to bring that experience to your hiring platform.',
     1138                                'rating'       => 3,
     1139                                'notes'        => array(
     1140                                        array( 0.6, 'Strong portfolio. The design system case study is exactly the work this role needs.' ),
     1141                                        array( 0.85, 'Referred by Ana on the platform team. Worth a first call this week.' ),
     1142                                ),
     1143                                'cv'           => array(
     1144                                        'headline' => 'Senior product designer',
     1145                                        'lines'    => array(
     1146                                                'Eight years designing B2B SaaS products, the last four leading a design system.',
     1147                                                'Runs discovery, prototyping and usability testing end to end.',
     1148                                                'Based in London. Portfolio and references on request.',
     1149                                        ),
     1150                                ),
     1151                                'interview'    => array(),
    6101152                        ),
    6111153                        array(
    … …  
    6181160                                'days_ago'     => 6,
    6191161                                'cover_letter' => '',
     1162                                'rating'       => 3,
     1163                                'notes'        => array(
     1164                                        array( 0.6, 'Phone screen went well: clear on API design and testing. Moving him to a technical interview.' ),
     1165                                        array( 0.8, 'Ask about his on-call experience in the technical round.' ),
     1166                                ),
     1167                                'cv'           => array(
     1168                                        'headline' => 'Backend engineer',
     1169                                        'lines'    => array(
     1170                                                'Six years building APIs and data pipelines in PHP and Go.',
     1171                                                'Owns code review and testing practice on a team of five.',
     1172                                                'Remote from Manchester, UK.',
     1173                                        ),
     1174                                ),
     1175                                'interview'    => array(
     1176                                        'title' => 'Technical interview',
     1177                                        'notes' => 'Focus on API design and how he tests his code.',
     1178                                ),
    6201179                        ),
    6211180                        array(
    … …  
    6281187                                'days_ago'     => 9,
    6291188                                'cover_letter' => 'Eight years of PHP and Go, currently maintaining a queue system that processes forty million jobs a day.',
     1189                                'rating'       => 4,
     1190                                'notes'        => array(
     1191                                        array( 0.55, 'Excellent technical interview. Strongest backend candidate so far.' ),
     1192                                        array( 0.8, 'Offer drafted at the top of the range. Waiting on her reply.' ),
     1193                                ),
     1194                                'cv'           => array(
     1195                                        'headline' => 'Senior backend engineer',
     1196                                        'lines'    => array(
     1197                                                'Eight years of PHP and Go. Maintains a queue system that runs forty million jobs a day.',
     1198                                                'Led the move from a monolith to services with no downtime.',
     1199                                                'Remote from Toronto, Canada.',
     1200                                        ),
     1201                                ),
     1202                                'interview'    => array(),
    6301203                        ),
    6311204                        array(
    … …  
    6381211                                'days_ago'     => 12,
    6391212                                'cover_letter' => '',
     1213                                'rating'       => 4,
     1214                                'notes'        => array(
     1215                                        array( 0.5, 'Great with customers in the role play, and happy with the part-time schedule.' ),
     1216                                        array( 0.85, 'Accepted the offer. Start date confirmed for the first of next month.' ),
     1217                                ),
     1218                                'cv'           => array(
     1219                                        'headline' => 'Customer support specialist',
     1220                                        'lines'    => array(
     1221                                                'Three years in customer support for a software company.',
     1222                                                'Writes help-center articles and triages bugs with engineering.',
     1223                                                'Lives in Austin and is free for part-time shifts.',
     1224                                        ),
     1225                                ),
     1226                                'interview'    => array(),
    6401227                        ),
    6411228                        array(
    … …  
    6481235                                'days_ago'     => 14,
    6491236                                'cover_letter' => '',
     1237                                'rating'       => 2,
     1238                                'notes'        => array(
     1239                                        array( 0.6, 'Friendly and clear, but looking for full-time hours, and this role is part time.' ),
     1240                                ),
     1241                                'cv'           => array(),
     1242                                'interview'    => array(),
    6501243                        ),
    6511244                );
  • vakanssi/tags/1.3.19/src/Core/Uninstall/Inventory.php

    r3797582 r3813839  
    110110                        'vakanssi_email_automation_rules',
    111111                        'vakanssi_webhooks',
     112                        // Whether AI assistants may read candidate details.
     113                        'vakanssi_abilities',
    112114                        'vakanssi_antispam',
    113115                        // The per-provider "these keys were verified" cache written beside
    … …  
    118120                        'vakanssi_scheduling',
    119121                        'vakanssi_scorecards',
     122                        // Saved only through options.php, so the uninstall test's source
     123                        // scan missed it until it read register_setting() too.
     124                        'vakanssi_scorecards_blind',
    120125                        'vakanssi_screening_default',
    121126
  • vakanssi/tags/1.3.19/src/Database/Repositories/ActivityRepository.php

    r3792652 r3813839  
    193193
    194194                return $row ? $row : null;
     195        }
     196
     197        /**
     198         * Delete specific activity rows, and only those that still belong to one of
     199         * the given entities.
     200         *
     201         * The audit trail is otherwise never deleted. This exists for sample
     202         * content, whose seed writes the history a real application would have
     203         * (received, moved) so the drawer's Activity tab is not empty, and whose
     204         * removal must take exactly those rows away again: they record nothing
     205         * anyone did. The caller passes the ids it wrote; the entity condition is a
     206         * second key, and `$marker`, text the caller put in each row's `changes`,
     207         * a third. Ids and entity ids both come back when the tables are emptied
     208         * and their counters restart, so only the marker tells a recorded row from
     209         * a real one that later took its id; a row without it is left alone.
     210         *
     211         * @param int[]  $ids         Row ids.
     212         * @param string $entity_type Entity type the rows must carry.
     213         * @param int[]  $entity_ids  Entity ids one of which each row must carry.
     214         * @param string $marker      Text each row's `changes` must contain. Required:
     215         *                            an empty marker deletes nothing.
     216         * @return int|false Rows deleted, or false on a database error.
     217         */
     218        public function delete_ids_for_entities( array $ids, $entity_type, array $entity_ids, $marker ) {
     219                global $wpdb;
     220
     221                $ids        = array_values( array_unique( array_filter( array_map( 'intval', $ids ) ) ) );
     222                $entity_ids = array_values( array_unique( array_filter( array_map( 'intval', $entity_ids ) ) ) );
     223                if ( ! $ids || ! $entity_ids || '' === (string) $marker ) {
     224                        return 0;
     225                }
     226
     227                return $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom table vakanssi_activity; no WordPress API reads or writes plugin tables, and a write has nothing to cache.
     228                        $wpdb->prepare(
     229                                'DELETE FROM %i WHERE entity_type = %s AND id IN (' . implode( ', ', array_fill( 0, count( $ids ), '%d' ) ) . ') AND entity_id IN (' . implode( ', ', array_fill( 0, count( $entity_ids ), '%d' ) ) . ') AND changes LIKE %s',
     230                                array_merge( array( $this->full_table(), (string) $entity_type ), $ids, $entity_ids, array( '%' . $wpdb->esc_like( (string) $marker ) . '%' ) )
     231                        )
     232                );
    195233        }
    196234
  • vakanssi/tags/1.3.19/src/Database/Repositories/EmailRepository.php

    r3749092 r3813839  
    339339         * site that had never sent an email as one whose email was working.
    340340         *
     341         * Rows of sample applications are not counted. Sample content records the
     342         * emails a real application would have produced without mailing anything
     343         * ({@see \Vakanssi\Modules\Email\Notifications::log_sample_send()}), so
     344         * counting them would hand a fresh install that has never sent a message
     345         * the same green tick this denominator exists to withhold.
     346         *
    341347         * @param string $since MySQL datetime (GMT).
    342348         * @return int
    … …  
    347353                $table = $this->full_table();
    348354
    349                 $count = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom table vakanssi_emails; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    350                         $wpdb->prepare(
    351                                 "SELECT COUNT(*) FROM %i WHERE status = 'sent' AND created_at >= %s",
    352                                 array( $table, $since )
     355                $count = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_emails and vakanssi_application_meta; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
     356                        $wpdb->prepare(
     357                                "SELECT COUNT(*) FROM %i e WHERE e.status = 'sent' AND e.created_at >= %s AND NOT EXISTS ( SELECT 1 FROM %i m WHERE m.application_id = e.application_id AND m.meta_key = %s )",
     358                                array( $table, $since, vakanssi_table( 'application_meta' ), \Vakanssi\Admin\SampleContent::APP_FLAG )
    353359                        )
    354360                );
  • vakanssi/tags/1.3.19/src/Modules/Email/Mailer.php

    r3785137 r3813839  
    4949                $this->templates = $templates ? $templates : new EmailTemplates();
    5050                $this->log       = $log ? $log : new EmailRepository();
     51        }
     52
     53        /**
     54         * The once-only dedupe key of a templated send to one application.
     55         *
     56         * One definition, because two writers put it on a log row: {@see send()}
     57         * when it claims a send, and {@see Notifications::log_sample_send()} when
     58         * sample content records a send that never happened. Both must write the
     59         * same key, or the duplicate guard would not recognise a sample row and a
     60         * later automatic send of the same template would go out a second time.
     61         *
     62         * @param int    $application_id Application id.
     63         * @param string $key            Template id.
     64         * @return string
     65         */
     66        public static function dedupe_key( $application_id, $key ) {
     67                return sprintf( 'app:%d:tpl:%s', (int) $application_id, (string) $key );
    5168        }
    5269
    … …  
    108125                // of times (MySQL permits multiple NULLs in a UNIQUE index).
    109126                $dedupe_key = ( ! $allow_resend && $application_id > 0 )
    110                         ? sprintf( 'app:%d:tpl:%s', (int) $application_id, $key )
     127                        ? self::dedupe_key( $application_id, $key )
    111128                        : null;
    112129
  • vakanssi/tags/1.3.19/src/Modules/Email/Notifications.php

    r3785137 r3813839  
    798798                        $wpdb->query( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', $lock ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- releases the MySQL named lock taken above with GET_LOCK; no WordPress API releases a named lock.
    799799                }
     800        }
     801
     802        /**
     803         * Record a candidate email as sent without sending anything.
     804         *
     805         * For sample content only ({@see \Vakanssi\Admin\SampleContent::seed()}):
     806         * a sample application's email history should hold the messages a real one
     807         * would have, but sample candidates have @example.com addresses and nothing
     808         * may be mailed, so this never reaches wp_mail() and fires no `vakanssi/*`
     809         * action. (The merge context runs the same filters a real send runs.)
     810         *
     811         * The row is the one {@see Mailer::send()} leaves after a successful send,
     812         * so every reader of the log treats it as one: a real template key (never
     813         * a label, see the `template` hazard in {@see is_resendable()}), the subject
     814         * that template renders from the same merge context, in the site's
     815         * language, the candidate's address, status `sent`, and the once-only
     816         * dedupe key, so a later automatic send of the same template is not sent a
     817         * second time. A Resend from the drawer then rebuilds the body from the
     818         * template, exactly as for a real row.
     819         *
     820         * Only candidate-facing templates are accepted: a staff template's row would
     821         * name a staff address this method has no business inventing.
     822         *
     823         * @param string $key            Template id: `confirmation`, `reject` or `offer`.
     824         * @param int    $application_id Application id.
     825         * @param string $at             When it was "sent", UTC `Y-m-d H:i:s`.
     826         * @param int    $stage_id       The stage the real send would have named in
     827         *                               `{stage}`: the destination of the move for a
     828         *                               rejection or offer, 0 (no stage, as
     829         *                               {@see on_created()} sends it) for a
     830         *                               confirmation. Never the stage the application
     831         *                               sits in now, which is later than the email.
     832         * @return int The log row id, or 0 when nothing was recorded.
     833         */
     834        public function log_sample_send( $key, $application_id, $at, $stage_id = 0 ) {
     835                $key = (string) $key;
     836                if ( ! Mailer::sending_enabled()
     837                        || null === ( new EmailTemplates() )->get( $key )
     838                        || EmailTemplates::AUDIENCE_CANDIDATE !== EmailTemplates::audience( $key )
     839                        || EmailTemplates::is_staff_template( $key ) ) {
     840                        return 0;
     841                }
     842
     843                $application = $this->applications->find( (int) $application_id );
     844                $candidate   = $application && ! empty( $application['candidate_id'] ) ? $this->candidates->find( (int) $application['candidate_id'] ) : null;
     845                $recipient   = $candidate ? sanitize_email( (string) ( $candidate['email'] ?? '' ) ) : '';
     846                if ( ! $application || ! is_email( $recipient ) ) {
     847                        return 0;
     848                }
     849
     850                $context   = $this->context_from_records( $application, $candidate, (int) $stage_id, (int) $application_id, $key );
     851                $templates = new EmailTemplates();
     852                $subject   = Mailer::in_site_locale(
     853                        static function () use ( $templates, $key, $context ) {
     854                                return $templates->subject( $key, $context );
     855                        }
     856                );
     857
     858                return ( new EmailRepository() )->insert_if_application_exists(
     859                        array(
     860                                'application_id' => (int) $application_id,
     861                                'template'       => $key,
     862                                'dedupe_key'     => Mailer::dedupe_key( $application_id, $key ),
     863                                'recipient'      => $recipient,
     864                                'subject'        => Mailer::plain_subject( (string) $subject ),
     865                                'status'         => 'sent',
     866                                'sent_at'        => (string) $at,
     867                                'created_at'     => (string) $at,
     868                        )
     869                );
    800870        }
    801871
  • vakanssi/tags/1.3.19/src/Modules/Jobs/JobsModule.php

    r3783327 r3813839  
    88namespace Vakanssi\Modules\Jobs;
    99
     10use Vakanssi\Abilities\AbilitiesBootstrap;
     11use Vakanssi\Abilities\JobAbilities;
    1012use Vakanssi\Core\Container;
    1113use Vakanssi\Core\Modules\AbstractModule;
    … …  
    111113                ( new LegacyBlockThemeArchive() )->register();
    112114
     115                // AI assistants (WordPress 6.9+ Abilities API): list, read and draft
     116                // jobs, with the same permissions as the REST API for jobs. On an
     117                // older WordPress this hooks nothing.
     118                ( new AbilitiesBootstrap() )->add( array( new JobAbilities(), 'register' ) );
     119
    113120                // Flush rewrite rules once, after the CPT/taxonomies have registered.
    114121                add_action( 'init', array( $this, 'maybe_flush_rewrites' ), 99 );
  • vakanssi/tags/1.3.19/src/Modules/Pipeline/PipelineService.php

    r3749092 r3813839  
    9595         * never double-logs or double-emails.
    9696         *
     97         * The destination must be a stage of the pipeline the application's job
     98         * uses ({@see StageService::for_job()}); any other stage is refused with
     99         * `vakanssi_stage_not_in_pipeline` before anything is written, unless it is
     100         * the stage the application sits in when the write is attempted. A stale
     101         * `$expected_from_stage_id` is reported as the conflict first. The origin
     102         * is not checked, so an application left in a stage its job no longer uses
     103         * can still be moved into the job's current pipeline.
     104         *
    97105         * @param int      $application_id         Application id.
    98106         * @param int      $stage_id               Destination stage id.
    … …  
    116124                        return new \WP_Error( 'vakanssi_bad_stage', __( 'Unknown pipeline stage.', 'vakanssi' ) );
    117125                }
     126
     127                // Only a stage of the pipeline this application's job uses: the same
     128                // list the board draws its columns from (GET /stages?job=), i.e. the
     129                // job's own stages, else the shared template. Checking only that the
     130                // stage exists let any job's stage id through, and the application then
     131                // sat in a column no board for its job shows. Checked inside the loop,
     132                // against the row each attempt reads.
     133                $pipeline = $this->stages->map_for_job( (int) $application['job_id'] );
    118134
    119135                for ( $attempt = 0; $attempt < 3; $attempt++ ) {
    … …  
    148164                        }
    149165
     166                        // The stage this attempt read the application in is exempt, so a card
     167                        // re-dropped on its own (retired) column is not refused for that
     168                        // reason. Checked per attempt: exempting it from the first read let a
     169                        // retry write the retired stage after a concurrent move took the
     170                        // application out of it. After the precondition, so a stale client
     171                        // still gets the conflict and the live row.
     172                        if ( $from !== $stage_id && ! isset( $pipeline[ $stage_id ] ) ) {
     173                                return new \WP_Error( 'vakanssi_stage_not_in_pipeline', __( 'That stage is not in this job\'s pipeline.', 'vakanssi' ), array( 'status' => 400 ) );
     174                        }
     175
    150176                        // Already in the desired end state — either because the caller
    151177                        // re-dropped a card on its own column, or because another request
  • vakanssi/tags/1.3.19/src/Rest/Routes/ApplicationsController.php

    r3802833 r3813839  
    2020use Vakanssi\Modules\Jobs\JobFields;
    2121use Vakanssi\Modules\Pipeline\ApplicationDetailsService;
    22 use Vakanssi\Modules\Pipeline\ApplicationsQuery;
     22use Vakanssi\Modules\Pipeline\ApplicationsListing;
    2323use Vakanssi\Modules\Pipeline\ApplicationService;
    2424use Vakanssi\Modules\Pipeline\ApplicationShape;
    2525use Vakanssi\Modules\Pipeline\CandidateContextService;
    2626use Vakanssi\Modules\Pipeline\PersonEnrichment;
    27 use Vakanssi\Modules\Pipeline\PipelineService;
     27use Vakanssi\Modules\Pipeline\StageMove;
    2828use Vakanssi\Modules\Pipeline\StageService;
    2929use Vakanssi\Modules\Pipeline\ViewTracker;
    … …  
    346346                $offset   = ( $page - 1 ) * $per_page;
    347347
    348                 list( $total, $rows ) = $this->index_page( $request, $per_page, $offset );
     348                list( $total, $rows ) = ( new ApplicationsListing() )->page(
     349                        array(
     350                                'job'    => (int) $request['job'],
     351                                'stage'  => (int) $request['stage'],
     352                                'search' => empty( $request['search'] ) ? '' : (string) $request['search'],
     353                        ),
     354                        $per_page,
     355                        $offset
     356                );
    349357
    350358                $items = array_map( array( $this, 'shape_row' ), (array) $rows );
    … …  
    379387
    380388        /**
    381          * One page of the board's applications under the request's job, stage and
    382          * search, and how many match in all.
    383          *
    384          * Same search semantics as the list and export (full name in either order
    385          * included), so the board and the List view never disagree about what a
    386          * search finds: the filter predicates are the ones {@see ApplicationsQuery}
    387          * documents, each always present and switched off by its own value. The
    388          * board has no person filter, so `candidate` is always 0.
    389          *
    390          * @param \WP_REST_Request $request  Request.
    391          * @param int              $per_page Rows per page.
    392          * @param int              $offset   Rows to skip.
    393          * @return array{0: int, 1: array<int, array<string, mixed>>}
    394          */
    395         private function index_page( \WP_REST_Request $request, $per_page, $offset ) {
    396                 global $wpdb;
    397 
    398                 $apps       = vakanssi_table( 'applications' );
    399                 $candidates = vakanssi_table( 'candidates' );
    400                 $files      = vakanssi_table( 'files' );
    401                 $meta       = vakanssi_table( 'application_meta' );
    402                 $key        = ViewTracker::META_KEY;
    403 
    404                 $f = ApplicationsQuery::filters(
    405                         array(
    406                                 'job'    => (int) $request['job'],
    407                                 'stage'  => (int) $request['stage'],
    408                                 'search' => empty( $request['search'] ) ? '' : (string) $request['search'],
    409                         )
    410                 );
    411 
    412                 // Three shapes, so each keeps the plan its clause-by-clause statement
    413                 // had. A statement that names a.job_id or a.stage_id cannot count off
    414                 // the candidate_id index even when those predicates fold away, and
    415                 // with no application filter that index scan is the cheapest count
    416                 // (EXPLAIN on a 30,000-application site: index scan before, table scan
    417                 // with the full predicate set).
    418                 if ( ! $f['job'] && ! $f['stage'] && '' === $f['search'] ) {
    419                         $total = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id', $apps, $candidates ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    420                 } elseif ( ! $f['job'] && ! $f['stage'] ) {
    421                         $total = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    422                                 $wpdb->prepare(
    423                                         "SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    424                                         WHERE ( %s = '' OR c.email LIKE %s
    425                                                 OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    426                                                 OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )",
    427                                         array( $apps, $candidates, $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'] )
    428                                 )
    429                         );
    430                 } else {
    431                         $total = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    432                                 $wpdb->prepare(
    433                                         "SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    434                                         WHERE ( %d = 0 OR a.job_id = %d )
    435                                                 AND ( %d = 0 OR a.candidate_id = %d )
    436                                                 AND ( %d = 0 OR a.stage_id = %d )
    437                                                 AND ( %s = '' OR c.email LIKE %s
    438                                                         OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    439                                                         OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )",
    440                                         array( $apps, $candidates, $f['job'], $f['job'], $f['candidate'], $f['candidate'], $f['stage'], $f['stage'], $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'] )
    441                                 )
    442                         );
    443                 }
    444 
    445                 $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_files, vakanssi_application_meta, vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    446                         $wpdb->prepare(
    447                                 "SELECT a.id, a.job_id, a.job_title, a.candidate_id, a.stage_id, a.status, a.rating, a.source, a.created_at, a.updated_at, a.stage_version, a.details_version, c.details_version AS candidate_details_version, c.first_name, c.last_name, c.email, EXISTS(SELECT 1 FROM %i f WHERE f.application_id = a.id) AS has_cv, (a.status = 'active' AND NOT EXISTS(SELECT 1 FROM %i m WHERE m.application_id = a.id AND m.meta_key = %s)) AS is_new, (SELECT COUNT(*) FROM %i a2 WHERE a2.candidate_id = a.candidate_id AND a.candidate_id > 0 AND a2.id <> a.id) AS related_count FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    448                                 WHERE ( %d = 0 OR a.job_id = %d )
    449                                         AND ( %d = 0 OR a.candidate_id = %d )
    450                                         AND ( %d = 0 OR a.stage_id = %d )
    451                                         AND ( %s = '' OR c.email LIKE %s
    452                                                 OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    453                                                 OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )
    454                                 ORDER BY a.created_at DESC, a.id DESC LIMIT %d OFFSET %d",
    455                                 array( $files, $meta, $key, $apps, $apps, $candidates, $f['job'], $f['job'], $f['candidate'], $f['candidate'], $f['stage'], $f['stage'], $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'], $per_page, $offset )
    456                         ),
    457                         ARRAY_A
    458                 );
    459 
    460                 return array( $total, (array) $rows );
    461         }
    462 
    463         /**
    464389         * GET /applications/{id} — single application for the profile drawer.
    465390         *
    … …  
    628553                $id = absint( $request['id'] );
    629554
    630                 $notify   = $request->get_param( 'notify' );
    631                 $suppress = null !== $notify && false === rest_sanitize_boolean( $notify );
    632                 $force    = null !== $notify && true === rest_sanitize_boolean( $notify );
     555                // Absent means the template's automatic-send flag decides (null);
     556                // otherwise the mover's explicit choice: true sends, false does not.
     557                $notify = $request->get_param( 'notify' );
     558                $notify = null !== $notify ? rest_sanitize_boolean( $notify ) : null;
    633559
    634560                // No default on the route arg: absent means no precondition (legacy
    … …  
    637563                $expected_from_stage_id = null !== $expected_from_stage_id ? (int) $expected_from_stage_id : null;
    638564
    639                 if ( $suppress ) {
    640                         add_filter( 'vakanssi/email/stage_notification', '__return_false', 100 );
    641                 }
    642                 if ( $force ) {
    643                         // "Send email & move": the user chose to email, so the template's
    644                         // automatic-send flag is bypassed for this one transition.
    645                         add_filter( 'vakanssi/email/force_stage_notification', '__return_true', 100 );
    646                 }
    647                 try {
    648                         $result = ( new PipelineService() )->move( $id, absint( $request['stage_id'] ), $expected_from_stage_id );
    649                 } finally {
    650                         if ( $suppress ) {
    651                                 remove_filter( 'vakanssi/email/stage_notification', '__return_false', 100 );
    652                         }
    653                         if ( $force ) {
    654                                 remove_filter( 'vakanssi/email/force_stage_notification', '__return_true', 100 );
    655                         }
    656                 }
     565                $result = StageMove::run( $id, absint( $request['stage_id'] ), $expected_from_stage_id, $notify );
    657566
    658567                if ( is_wp_error( $result ) ) {
  • vakanssi/tags/1.3.19/vakanssi.php

    r3803675 r3813839  
    44 * Plugin URI:        https://vakanssi.com/
    55 * Description:       All-in-one Hiring & ATS for WordPress: job listings, a careers page with Google-for-Jobs schema, applicant tracking with a drag-and-drop pipeline, confirmation and notification emails, and privacy tools.
    6  * Version:           1.3.18
     6 * Version:           1.3.19
    77 * Requires at least: 6.6
    88 * Requires PHP:      7.4
    … …  
    3333 * ---------------------------------------------------------------------------
    3434 */
    35 define( 'VAKANSSI_VERSION', '1.3.18' );
     35define( 'VAKANSSI_VERSION', '1.3.19' );
    3636define( 'VAKANSSI_PLUGIN_FILE', __FILE__ );
    3737define( 'VAKANSSI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
  • vakanssi/trunk/assets/css/careers.css

    r3785137 r3813839  
    1717        --vakanssi-ink: #1e2936;
    1818        --vakanssi-text: #3a4552;
    19         --vakanssi-muted: #5f6b7a;
     19        --vakanssi-muted: #525e6c;
    2020        --vakanssi-faint: #98a2b0;
    2121
    … …  
    101101        --vakanssi-invalid-edge: 4px;
    102102        --vakanssi-hover-duration: 0.2s;
     103
     104        /* Dark pages. The palette above is a light one, and most of the careers
     105           list paints its text straight onto the theme's page, so on a dark theme
     106           the titles measured 1.17:1. The theme's own text colour tells us which
     107           kind of page we are on: light text means a dark page. These two are
     108           pieces of a relative colour (`rgb(from currentColor ...)`) and mean
     109           nothing on their own; the "Text on a dark page" block at the end of
     110           this sheet is their only user. The switch is a step on the sRGB luma
     111           (0 to 255) of the inherited text: 0 up to 140, 1 above it. It is a
     112           guess, because CSS cannot read the page's background, and grey text is
     113           where it can guess wrong: #8a8a8a (138) and darker read as a light
     114           page, #999 (153) and lighter as a dark one. Light themes' text sits far
     115           below (#111 to #555), Twenty Twenty-Five's dark variations far above
     116           (203 to 212). The two known misses are a light theme with text greyer
     117           than #8a8a8a (already under 3.4:1 on white) and a dark theme with text
     118           darker than #999. page-text is the inherited text colour, opaque only
     119           when the switch is 1.
     120
     121           Site owners can overrule the guess on any container in Custom CSS:
     122           `--vakanssi-page-text: transparent` keeps the light palette (a white
     123           section on a dark site whose text colour stays light),
     124           `--vakanssi-page-text: currentColor` follows the text (a dark section
     125           whose text is grey).
     126
     127           Known limit: the block rebuilds each token at full opacity (or its set
     128           fade), so a colour token set see-through in Custom CSS (for example
     129           `--vakanssi-border: transparent` to hide the row lines) comes out solid.
     130           Set token overrides as solid colours; to hide a line, set its width. */
     131        --vakanssi-dark-switch: clamp(0, (0.2126 * r + 0.7152 * g + 0.0722 * b - 140) * 100, 1);
     132        --vakanssi-page-text: rgb(from currentColor r g b / var(--vakanssi-dark-switch));
     133}
     134
     135/* The accent as text on the theme's page (team label, Remote/Hybrid,
     136   chevron, outlined Apply, back link, the closed job's action): the accent
     137   with 30% ink mixed in. The accent clears 4.5:1 on white only (Branding
     138   darkens a brand colour to exactly that), and a tinted page took it under:
     139   4.0:1 on Twenty Twenty-Five "Morning" (#dfdcd7). Fills, buttons, rings
     140   and emails keep the accent itself.
     141
     142   Declared on every plugin element, not on :root, so the mix reads the
     143   accent where it is used: a site that sets --vakanssi-accent on a wrapper
     144   recolours this text too (a :root declaration resolved once, at the
     145   root). Guarded: a browser without color-mix() leaves it undefined, and
     146   each use falls back to the accent, as before. */
     147@supports (color: color-mix(in srgb, red 70%, blue)) {
     148        [class*="vakanssi-"] {
     149                --vakanssi-accent-text: color-mix(in srgb, var(--vakanssi-accent, #0f766e) 70%, var(--vakanssi-ink, #1e2936));
     150        }
    103151}
    104152
    … …  
    462510        background: #ffffff;
    463511        background: var(--vakanssi-surface, #ffffff);
     512        /* Its own surface, so its own text colour: on a dark theme the page's
     513           light text must not reach the field (see "Text on a dark page"). */
     514        color: #3a4552;
     515        color: var(--vakanssi-text, #3a4552);
    464516        border: 1px solid #758091;
    465517        border: 1px solid var(--vakanssi-control-border-page, #758091);
    … …  
    650702        font-size: 0.8125em;
    651703        font-size: var(--vakanssi-text-xs, 0.8125em);
    652         color: #5f6b7a;
    653         color: var(--vakanssi-muted, #5f6b7a);
     704        color: #525e6c;
     705        color: var(--vakanssi-muted, #525e6c);
    654706        cursor: pointer;
    655707        -webkit-user-select: none;
    … …  
    806858        font-size: 0.875em;
    807859        font-size: var(--vakanssi-text-sm, 0.875em);
    808         color: #5f6b7a;
    809         color: var(--vakanssi-muted, #5f6b7a);
     860        color: #525e6c;
     861        color: var(--vakanssi-muted, #525e6c);
    810862}
    811863
    … …  
    853905        margin: 0;
    854906        padding: 0;
    855         color: #5f6b7a;
    856         color: var(--vakanssi-muted, #5f6b7a);
     907        color: #525e6c;
     908        color: var(--vakanssi-muted, #525e6c);
    857909        font-size: 0.9375em;
    858910        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    877929.vakanssi-jobs-pagination .vakanssi-jobs-pagination__page {
    878930        margin-inline-end: 0.35em;
    879         color: #5f6b7a;
    880         color: var(--vakanssi-muted, #5f6b7a);
     931        color: #525e6c;
     932        color: var(--vakanssi-muted, #525e6c);
    881933        font-variant-numeric: tabular-nums;
    882934        white-space: nowrap;
    … …  
    11931245        text-transform: uppercase;
    11941246        color: #0f766e;
    1195         color: var(--vakanssi-accent, #0f766e);
     1247        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    11961248        /* 0.3em of the UI base between the team and the title. */
    11971249        margin-block-end: 0.4em;
    … …  
    12291281        /* 0.4em of the UI base between the title and the facts. */
    12301282        margin-block-start: 0.45em;
    1231         color: #5f6b7a;
    1232         color: var(--vakanssi-muted, #5f6b7a);
     1283        color: #525e6c;
     1284        color: var(--vakanssi-muted, #525e6c);
    12331285        font-size: 0.875em;
    12341286        font-size: var(--vakanssi-text-sm, 0.875em);
    … …  
    12651317.vakanssi-job-fact--workplace {
    12661318        color: #0c615a;
    1267         color: var(--vakanssi-accent-strong, #0c615a);
     1319        color: var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a));
    12681320        font-weight: 600;
    12691321}
    … …  
    13081360.vakanssi-job-link:focus-visible .vakanssi-job-go {
    13091361        color: #0f766e;
    1310         color: var(--vakanssi-accent, #0f766e);
     1362        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    13111363        transform: translateX(3px);
    13121364}
    … …  
    13581410        background: transparent;
    13591411        color: #0f766e;
    1360         color: var(--vakanssi-accent, #0f766e);
     1412        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    13611413        font-family: inherit;
    13621414        font-size: 0.8125em;
    … …  
    14031455        padding-inline: 1.6em;
    14041456        text-align: center;
    1405         color: #5f6b7a;
    1406         color: var(--vakanssi-muted, #5f6b7a);
     1457        color: #525e6c;
     1458        color: var(--vakanssi-muted, #525e6c);
    14071459        font-size: 0.9375em;
    14081460        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    14341486        background: #ffffff;
    14351487        background: var(--vakanssi-surface, #ffffff);
     1488        /* A card paints its own surface, so it sets its own text colour too. The
     1489           row rules inside it read the colour they inherit to tell a dark page
     1490           from a light one ("Text on a dark page"); a dark theme's light text
     1491           reaching them here turned them light on this white card. */
     1492        color: #3a4552;
     1493        color: var(--vakanssi-text, #3a4552);
    14361494        border: 1px solid #e2e6eb;
    14371495        border: 1px solid var(--vakanssi-border, #e2e6eb);
    … …  
    14781536        padding-inline: 1.6em;
    14791537        text-align: center;
    1480         color: #5f6b7a;
    1481         color: var(--vakanssi-muted, #5f6b7a);
     1538        color: #525e6c;
     1539        color: var(--vakanssi-muted, #525e6c);
    14821540        font-size: 0.9375em;
    14831541        font-size: var(--vakanssi-text-md, 0.9375em);
    … …  
    15041562        background: #f6f8fa;
    15051563        background: var(--vakanssi-surface-subtle, #f6f8fa);
     1564        /* Its own surface, so its own text colour (see "Text on a dark page"). */
     1565        color: #3a4552;
     1566        color: var(--vakanssi-text, #3a4552);
    15061567        border: 1px solid #e2e6eb;
    15071568        border: 1px solid var(--vakanssi-border, #e2e6eb);
    … …  
    15341595        letter-spacing: 0.05em;
    15351596        text-transform: uppercase;
    1536         color: #5f6b7a;
    1537         color: var(--vakanssi-muted, #5f6b7a);
     1597        color: #525e6c;
     1598        color: var(--vakanssi-muted, #525e6c);
    15381599}
    15391600
    … …  
    15741635        letter-spacing: 0.05em;
    15751636        text-transform: uppercase;
    1576         color: #5f6b7a;
    1577         color: var(--vakanssi-muted, #5f6b7a);
     1637        color: #525e6c;
     1638        color: var(--vakanssi-muted, #525e6c);
    15781639}
    15791640
    … …  
    16791740        line-height: 1.4;
    16801741        color: #0f766e;
    1681         color: var(--vakanssi-accent, #0f766e);
     1742        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    16821743        text-decoration: none;
    16831744}
    … …  
    17961857
    17971858.vakanssi-apply--soon {
    1798         color: #5f6b7a;
    1799         color: var(--vakanssi-muted, #5f6b7a);
     1859        color: #525e6c;
     1860        color: var(--vakanssi-muted, #525e6c);
    18001861        font-style: italic;
    18011862}
    … …  
    19572018.vakanssi-field ::placeholder,
    19582019.vakanssi-jobs-bar .vakanssi-jobs-searchinput::placeholder {
    1959         color: #5f6b7a;
    1960         color: var(--vakanssi-muted, #5f6b7a);
     2020        color: #525e6c;
     2021        color: var(--vakanssi-muted, #525e6c);
    19612022        opacity: 1;
    19622023}
    … …  
    19812042        border-radius: 6px;
    19822043        border-radius: var(--vakanssi-radius, 6px);
    1983         color: #5f6b7a;
    1984         color: var(--vakanssi-muted, #5f6b7a);
     2044        color: #525e6c;
     2045        color: var(--vakanssi-muted, #525e6c);
    19852046        font-family: inherit;
    19862047        font-size: 0.875em;
    … …  
    21002161        font-weight: 400;
    21012162        line-height: 1.5;
    2102         color: #5f6b7a;
    2103         color: var(--vakanssi-muted, #5f6b7a);
     2163        color: #525e6c;
     2164        color: var(--vakanssi-muted, #525e6c);
    21042165}
    21052166
    … …  
    22242285        letter-spacing: 0.05em;
    22252286        text-transform: uppercase;
    2226         color: #5f6b7a;
    2227         color: var(--vakanssi-muted, #5f6b7a);
     2287        color: #525e6c;
     2288        color: var(--vakanssi-muted, #525e6c);
    22282289}
    22292290
    … …  
    23622423}
    23632424
    2364 /* The link's resting paint, restated for its focused state: a theme's focus
    2365    wash must not replace it. */
     2425/* The link's resting paint, at rest and restated for its focused state: a
     2426   theme's focus wash must not replace it, and a theme's or a block's link
     2427   colour (core prints `.wp-elements-N a` at (0,1,1) for a Group with a link
     2428   colour) must not reach the row. The row's text reads the colour it
     2429   inherits through this link to tell a dark page from a light one ("Text on
     2430   a dark page"); an orange link colour on a light page turned the titles
     2431   orange at 2.51:1. */
     2432.vakanssi-jobs li.vakanssi-job a.vakanssi-job-link,
     2433:root .vakanssi-related li.vakanssi-related-item > a,
    23662434.vakanssi-jobs li.vakanssi-job a.vakanssi-job-link:focus,
    23672435:root .vakanssi-related li.vakanssi-related-item > a:focus {
    … …  
    23912459        background: transparent;
    23922460        color: #0f766e;
    2393         color: var(--vakanssi-accent, #0f766e);
     2461        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    23942462}
    23952463
    … …  
    25222590        box-shadow: none;
    25232591        color: #0f766e;
    2524         color: var(--vakanssi-accent, #0f766e);
     2592        color: var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e));
    25252593        font-size: 0.9375em;
    25262594        font-size: var(--vakanssi-text-md, 0.9375em);
    25272595        font-weight: 600;
    25282596        line-height: 1.3;
    2529         transition: background 0.2s ease, color 0.2s ease;
    2530         transition: background var(--vakanssi-hover-duration, 0.2s) ease, color var(--vakanssi-hover-duration, 0.2s) ease;
     2597        transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
     2598        transition: background var(--vakanssi-hover-duration, 0.2s) ease, color var(--vakanssi-hover-duration, 0.2s) ease, border-color var(--vakanssi-hover-duration, 0.2s) ease;
    25312599}
    25322600
    … …  
    28082876        }
    28092877}
     2878
     2879/* The external-link icon in a focused Apply button: white on the fill. The
     2880   dark-page block keeps the button's `color` on the page for its ring and
     2881   paints the label with -webkit-text-fill-color, which an SVG stroke does
     2882   not read. */
     2883.vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible > svg {
     2884        color: #ffffff;
     2885        color: var(--vakanssi-accent-contrast, #ffffff);
     2886}
     2887
     2888/* Forced colours repaint the focused buttons' fill but not a text fill
     2889   colour, which left the white label on a white Canvas (1:1). */
     2890@media (forced-colors: active) {
     2891        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible,
     2892        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     2893                -webkit-text-fill-color: currentColor;
     2894        }
     2895}
     2896
     2897/* ------------------------------------------------------------------ *
     2898 *  Text on a dark page
     2899 * ------------------------------------------------------------------ */
     2900
     2901/* The list rows, the count and pagination lines, the related roles and the
     2902   back link paint their text straight onto the theme's page, in the light
     2903   palette's dark ink. On a dark theme that measured 1.17:1 for a job title
     2904   (Twenty Twenty-Five "Evening"). The cards, fields and buttons paint their
     2905   own surface and are not here.
     2906
     2907   Each rule below restates one of those colours as a switch on the text
     2908   colour the element inherits from the theme (the tokens at the top of this
     2909   sheet). On a light page the switch is 0 and the result is the token itself,
     2910   to the digit, including a brand accent from Settings or a token set in
     2911   Custom CSS. On a dark page it is the theme's own text colour, which the
     2912   theme already made readable there: as is for titles, salaries and the
     2913   closed notice, at 85% for the muted lines, at 55% for the decorative dots
     2914   and chevron, and mixed with 20% of the accent for the accent text, so the
     2915   brand still shows. The hover band and the hairlines follow the same way.
     2916
     2917   How it works: color-mix() weighs the token at 0.1% against page-text,
     2918   which is fully transparent on a light page (so only the token is left) and
     2919   opaque on a dark one (so the token's 0.1% is lost in it). The outer
     2920   rgb(from ...) then sets the alpha. Its `alpha` is the mix's own, which
     2921   runs from 0.001 (light page) to 1 (dark page); `(alpha - 0.001) / 0.999`
     2922   maps that onto 0 to 1, so the faded roles fade only on a dark page and a
     2923   light page gets an alpha of exactly 1.
     2924
     2925   Browsers without relative colours or color-mix() keep the light palette
     2926   above, unchanged. The guard tests the constructs the block uses (a
     2927   currentColor origin, channel and alpha arithmetic), not just the
     2928   syntax: every value below goes through var(), so a browser that took
     2929   the syntax but not these would drop the declarations to `unset`, not to
     2930   the light palette. Every selector repeats its rule's, so it ties on weight
     2931   and wins by coming last. */
     2932@supports (color: rgb(from currentColor r g b / clamp(0, (0.2126 * r + 0.7152 * g + 0.0722 * b - 140) * 100, 1))) and (color: rgb(from color-mix(in srgb, red 0.1%, blue) r g b / calc(1 - 0.2 * (alpha - 0.001) / 0.999))) {
     2933        .vakanssi-job-title,
     2934        .vakanssi-job-fact--salary,
     2935        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__range strong {
     2936                color: rgb(from color-mix(in srgb, var(--vakanssi-ink, #1e2936) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1);
     2937        }
     2938
     2939        .vakanssi-jobs-count,
     2940        .vakanssi-jobs-remote,
     2941        .vakanssi-job-meta,
     2942        .vakanssi-related-heading,
     2943        .vakanssi-apply--soon,
     2944        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__range,
     2945        .vakanssi-jobs-pagination .vakanssi-jobs-pagination__page {
     2946                color: rgb(from color-mix(in srgb, var(--vakanssi-muted, #525e6c) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.15 * (alpha - 0.001) / 0.999));
     2947        }
     2948
     2949        .vakanssi-job-fact::before,
     2950        .vakanssi-job-go {
     2951                color: rgb(from color-mix(in srgb, var(--vakanssi-faint, #98a2b0) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.45 * (alpha - 0.001) / 0.999));
     2952        }
     2953
     2954        .vakanssi-job-dept,
     2955        .vakanssi-job-link:hover .vakanssi-job-go,
     2956        .vakanssi-job-link:focus-visible .vakanssi-job-go,
     2957        .vakanssi-single-back a:any-link,
     2958        :root p.vakanssi-single-back a:any-link:focus {
     2959                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)));
     2960        }
     2961
     2962        .vakanssi-job-fact--remote,
     2963        .vakanssi-job-fact--workplace {
     2964                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent-strong, #0c615a)));
     2965        }
     2966
     2967        /* "This position is now closed." The words (in bold) carry the meaning, so
     2968           on a dark page it is the page's text, untinted: its "View current
     2969           openings" link takes its colour from this one, and a red tint here
     2970           under the link's own accent tint left the link at 4.06:1 on a purple
     2971           page (Twenty Twenty-Five "Midnight"). */
     2972        .vakanssi-apply--closed {
     2973                color: rgb(from color-mix(in srgb, var(--vakanssi-danger-text, #9f3a38) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1);
     2974        }
     2975
     2976        /* The outlined links: the row's Apply button and the closed job's "View
     2977           current openings". Text and border; hover and focus fill them on their
     2978           own (heavier) rules. */
     2979        .vakanssi-jobs .vakanssi-job-apply,
     2980        :root p.vakanssi-apply--closed a.vakanssi-closed-action {
     2981                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent-text, var(--vakanssi-accent, #0f766e)));
     2982                /* The border is the text: in border-color, currentColor is the link's
     2983                   own colour, the line above. Running the switch again here would
     2984                   read that already tinted colour, and near the step the tint tipped
     2985                   it back to the plain accent, 2.8:1 on a dark page. */
     2986                border-color: currentColor;
     2987        }
     2988
     2989        /* The states that change the text colour keep the accent border they
     2990           had; on a light page this is exactly the border of the rules above. */
     2991        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus,
     2992        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus,
     2993        :root p.vakanssi-apply--closed a.vakanssi-closed-action:hover {
     2994                border-color: var(--vakanssi-accent, #0f766e);
     2995        }
     2996
     2997        /* The keyboard ring of the row's Apply button and the closed job's
     2998           action. Focused, they paint their own fill and label colour, so a ring
     2999           in currentColor followed the label, not the page: the plain accent,
     3000           1.55:1 on a purple page. Here `color` stays the page-following accent
     3001           (the ring is currentColor) and the label is painted with
     3002           -webkit-text-fill-color instead. */
     3003        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible,
     3004        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     3005                color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent, #0f766e) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent, #0f766e));
     3006                outline-color: currentColor;
     3007        }
     3008
     3009        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-apply:focus-visible {
     3010                -webkit-text-fill-color: var(--vakanssi-accent-contrast, #ffffff);
     3011        }
     3012
     3013        :root p.vakanssi-apply--closed a.vakanssi-closed-action:focus-visible {
     3014                -webkit-text-fill-color: var(--vakanssi-accent-strong, #0c615a);
     3015        }
     3016
     3017        /* The focus ring of the links that sit on the page. In outline-color,
     3018           currentColor is the link's own colour. The row and related links take
     3019           the page's text (their resting rule sets `color: inherit`), so the
     3020           ring runs the switch on it. The back link's colour is the switched
     3021           accent already, so its ring is simply that colour. */
     3022        .vakanssi-jobs li.vakanssi-job a.vakanssi-job-link:focus-visible,
     3023        :root .vakanssi-related li.vakanssi-related-item > a:focus-visible {
     3024                outline-color: color-mix(in srgb, rgb(from color-mix(in srgb, var(--vakanssi-accent, #0f766e) 0.1%, var(--vakanssi-page-text, transparent)) r g b / 1) 80%, var(--vakanssi-accent, #0f766e));
     3025        }
     3026
     3027        :root p.vakanssi-single-back a:any-link:focus-visible {
     3028                outline-color: currentColor;
     3029        }
     3030
     3031        /* The hover and focus band of the list rows and of "Other open roles":
     3032           the light wash on a light page, a faint veil of the page's text colour
     3033           on a dark one (a light wash there put the now light text back on a
     3034           light ground, 1.5:1). 5%, with the muted lines at 85%: at 8% and 80%
     3035           the muted facts on a hovered row fell to 4.29:1 on Twenty Twenty-Five
     3036           "Midnight". */
     3037        .vakanssi-jobs-board .vakanssi-jobs:not(.vakanssi-jobs--grid) .vakanssi-job::before,
     3038        .vakanssi-related .vakanssi-related-item::before {
     3039                background: rgb(from color-mix(in srgb, var(--vakanssi-surface-subtle, #f6f8fa) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.95 * (alpha - 0.001) / 0.999));
     3040        }
     3041
     3042        /* The hairlines between the rows and above the lists: the light palette's
     3043           near-white rule read as a bright stripe on a dark page, louder than on
     3044           white. There they are the page's text colour at 25%. A grid card's own
     3045           border is on a heavier rule and is not affected. */
     3046        .vakanssi-jobs-bar + .vakanssi-jobs-meta,
     3047        .vakanssi-jobs,
     3048        .vakanssi-related .vakanssi-related-list {
     3049                border-block-start-color: rgb(from color-mix(in srgb, var(--vakanssi-border, #e2e6eb) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.75 * (alpha - 0.001) / 0.999));
     3050        }
     3051
     3052        .vakanssi-job,
     3053        .vakanssi-related .vakanssi-related-item {
     3054                border-block-end-color: rgb(from color-mix(in srgb, var(--vakanssi-border, #e2e6eb) 0.1%, var(--vakanssi-page-text, transparent)) r g b / calc(1 - 0.75 * (alpha - 0.001) / 0.999));
     3055        }
     3056}
  • vakanssi/trunk/readme.txt

    r3803675 r3813839  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.3.18
     7Stable tag: 1.3.19
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1515Vakanssi is a recruitment plugin and complete applicant tracking system (ATS) for WordPress. Post your openings on a careers page or job board on your own site and run the whole hiring process there.
    1616
    17 It brings branded job listings with Google-for-Jobs
    18 structured data, a native application form, an applications inbox with a configurable drag-and-drop
    19 pipeline board, templated emails, and tools for handling candidate data (export, erasure and
    20 scheduled retention), all on your own server, with no per-seat SaaS fees.
     17It brings branded job listings with Google-for-Jobs structured data, a native application form, an applications inbox with a configurable drag-and-drop pipeline board, templated emails, and tools for handling candidate data (export, erasure and scheduled retention), all on your own server, with no per-seat SaaS fees.
    2118
    2219**A complete hiring workflow:**
    2320
    24 * **Jobs & careers**: a `vakanssi_job` post type, a branded careers archive (at `/jobs/` by default, or on
    25   your own careers page) and `[vakanssi_jobs]` shortcode, and valid Google-for-Jobs `JobPosting` structured data that is
    26   withheld automatically when a job is not eligible (expired, no location, no apply path, …).
    27 * **Application intake**: a native application form with a secure CV upload (type-verified by magic
    28   bytes, randomised filename, owner-only permissions), spam/honeypot/rate-limiting, and candidate
    29   de-duplication by email.
    30 * **Applications inbox & pipeline board**: a sortable, filterable inbox plus a build-free React
    31   Kanban board with a candidate profile drawer; configurable stages; bulk move/delete.
    32 * **Interviews & calendar invites**: schedule an interview from the candidate's record and send a
    33   real `.ics` invite that Google, Outlook and Apple render as an actionable event, with no OAuth and
    34   no connected account. Reschedule, cancel, and keep internal notes that reach your interviewers'
    35   calendars and never the candidate's.
     21* **Jobs & careers**: a `vakanssi_job` post type, a branded careers archive (at `/jobs/` by default, or on your own careers page) and `[vakanssi_jobs]` shortcode, and valid Google-for-Jobs `JobPosting` structured data that is withheld automatically when a job is not eligible (expired, no location, no apply path, …).
     22
     23* **Application intake**: a native application form with a secure CV upload (type-verified by magic bytes, randomised filename, owner-only permissions), spam/honeypot/rate-limiting, and candidate de-duplication by email.
     24
     25* **Applications inbox & pipeline board**: a sortable, filterable inbox plus a build-free React Kanban board with a candidate profile drawer; configurable stages; bulk move/delete.
     26
     27* **Interviews & calendar invites**: schedule an interview from the candidate's record and send a real `.ics` invite that Google, Outlook and Apple render as an actionable event, with no OAuth and no connected account. Reschedule, cancel, and keep internal notes that reach your interviewers' calendars and never the candidate's.
     28
    3629* **Application data & export**: export applications to CSV, print or save any application as a PDF, and edit application details, right from the inbox.
    37 * **Email**: templated confirmation/recruiter/rejection/offer emails with personalization tags and
    38   an SMTP-compatible sender, logged and de-duplicated.
    39 * **Candidate data controls**: consent capture, WordPress core data export/erase integration (with a
    40   complete cascade across all candidate data), a retention-purge cron, and an audit log. These are
    41   tools you operate; they do not by themselves make a site compliant with any particular law.
    42 * **Blocks, page builders & themes**: a Job Listings block for the block editor, native **Elementor**
    43   widgets for the listing, the application form and the job details (Elementor Pro Theme Builder
    44   archive/single templates are respected too), a **Divi** module, and shortcodes for everywhere else.
    45   Block themes on WordPress 6.7 and later get editable Site Editor templates; classic themes get the
    46   built-in archive.
    47 * **First-run setup wizard**: sender identity and a careers page in a few clicks, with optional
    48   sample content and a prompt to post your first job.
    49 * **Foundations**: scale-ready custom tables (engineered for 10k+ applications), a modular
    50   architecture (disabled modules load no code/assets), capability-based roles (Recruiter, Hiring
    51   Manager, HR/Compliance), and a `vakanssi/v1` REST API with per-route
    52   permission checks.
     30
     31* **Email**: templated confirmation/recruiter/rejection/offer emails with personalization tags and an SMTP-compatible sender, logged and de-duplicated.
     32
     33* **Candidate data controls**: consent capture, WordPress core data export/erase integration (with a complete cascade across all candidate data), a retention-purge cron, and an audit log. These are tools you operate; they do not by themselves make a site compliant with any particular law.
     34
     35* **Blocks, page builders & themes**: a Job Listings block for the block editor, native **Elementor** widgets for the listing, the application form and the job details (Elementor Pro Theme Builder archive/single templates are respected too), a **Divi** module, and shortcodes for everywhere else. Block themes on WordPress 6.7 and later get editable Site Editor templates; classic themes get the built-in archive.
     36
     37* **First-run setup wizard**: sender identity and a careers page in a few clicks, with optional sample content and a prompt to post your first job.
     38
     39* **AI assistants**: on WordPress 6.9 and later, with the free MCP Adapter plugin, an AI assistant such as Claude can list your jobs, read one and draft a new one. It signs in as one of your users and can do only what that user may do, and drafts are never published on their own.
     40
     41* **Foundations**: scale-ready custom tables (engineered for 10k+ applications), a modular architecture (disabled modules load no code/assets), capability-based roles (Recruiter, Hiring Manager, HR/Compliance), and a `vakanssi/v1` REST API with per-route permission checks.
    5342
    5443== Installation ==
    5544
    56451. Upload the `vakanssi` folder to `/wp-content/plugins/`, or install through the Plugins screen.
    57 2. Activate the plugin. Activation creates the database tables, installs roles, provisions protected
    58   file storage, and opens a short setup wizard.
    59 3. Complete **Hiring → Setup** (sender email, careers page), post your first job, then review
    60   **Hiring → Tools → Status** for system status.
     46
     472. Activate the plugin. Activation creates the database tables, installs roles, provisions protected file storage, and opens a short setup wizard.
     48
     493. Complete **Hiring → Setup** (sender email, careers page), post your first job, then review **Hiring → Tools → Status** for system status.
    6150
    6251== Frequently Asked Questions ==
    … …  
    6453= Does removing the plugin delete my candidate data? =
    6554
    66 No. Uninstalling removes roles, capabilities, and plugin settings, but your hiring data is kept
    67 unless you explicitly enable **Hiring → Settings → General → Delete all data on uninstall**.
    68 While another copy of Vakanssi is still installed (for example in a second plugin folder),
    69 deleting a copy removes nothing, so the copy you keep runs with its settings and data.
     55No. Uninstalling removes roles, capabilities, and plugin settings, but your hiring data is kept unless you explicitly enable **Hiring → Settings → General → Delete all data on uninstall**. While another copy of Vakanssi is still installed (for example in a second plugin folder), deleting a copy removes nothing, so the copy you keep runs with its settings and data.
    7056
    7157= Are uploaded CVs protected from direct download? =
    7258
    73 Yes, with defence in depth. Candidate files are stored in a protected `vakanssi` folder in
    74 your uploads directory, under random 128-bit file names, with an Apache deny rule, index guards and a
    75 generated Nginx rule. Vakanssi then **verifies over HTTP** that the folder is not directly reachable,
    76 and shows an admin warning (with the exact Nginx rule to add) if it is. The plugin itself only serves
    77 CVs through an authenticated, permission-checked download link.
    78 To keep them outside your public site entirely, define `VAKANSSI_STORAGE_DIR` as an absolute path in `wp-config.php`; moving your existing CVs is covered at https://docs.vakanssi.com/admin/move-cv-storage/
     59Yes, with defence in depth. Candidate files are stored in a protected `vakanssi` folder in your uploads directory, under random 128-bit file names, with an Apache deny rule, index guards and a generated Nginx rule. Vakanssi then **verifies over HTTP** that the folder is not directly reachable, and shows an admin warning (with the exact Nginx rule to add) if it is. The plugin itself only serves CVs through an authenticated, permission-checked download link. To keep them outside your public site entirely, define `VAKANSSI_STORAGE_DIR` as an absolute path in `wp-config.php`; moving your existing CVs is covered at https://docs.vakanssi.com/admin/move-cv-storage/
    7960
    8061= Who on my team can see candidate applications and CVs? =
    8162
    82 Anyone you grant a hiring role to. Vakanssi ships three roles (Recruiter, Hiring Manager, and HR / Compliance)
    83 plus Administrator, and any user with the "view applications" capability can see **every** candidate
    84 and download **every** CV in the pipeline. In other words, Vakanssi does not restrict staff to only
    85 the jobs or candidates assigned to them: it assumes your hiring team is trusted, which is the right
    86 default for most small teams. Only grant these roles to people who should see all applicants.
     63Anyone you grant a hiring role to. Vakanssi ships three roles (Recruiter, Hiring Manager, and HR / Compliance) plus Administrator, and any user with the "view applications" capability can see **every** candidate and download **every** CV in the pipeline. In other words, Vakanssi does not restrict staff to only the jobs or candidates assigned to them: it assumes your hiring team is trusted, which is the right default for most small teams. Only grant these roles to people who should see all applicants.
    8764
    8865= How do I report a security issue? =
    8966
    90 Email **security@vakanssi.com** rather than posting in the support forum, so a fix can ship before
    91 the details are public. Please include the Vakanssi version, your WordPress and PHP versions, and
    92 steps to reproduce. You will get an acknowledgement within three business days and an initial
    93 assessment within a week, and you will be credited in the changelog for the release that fixes it
    94 unless you would rather not be. Only the most recent release receives security fixes, so updating
    95 is always part of the answer.
     67Email **security@vakanssi.com** rather than posting in the support forum, so a fix can ship before the details are public. Please include the Vakanssi version, your WordPress and PHP versions, and steps to reproduce. You will get an acknowledgement within three business days and an initial assessment within a week, and you will be credited in the changelog for the release that fixes it unless you would rather not be. Only the most recent release receives security fixes, so updating is always part of the answer.
    9668
    9769= What personal data is included in a GDPR data-export request? =
    9870
    99 When you run **Tools → Export Personal Data** for a candidate's email, Vakanssi includes their
    100 profile (name, email, phone, location), every application (position, stage, status, date, and whether
    101 consent was given), the cover letter, their LinkedIn profile, each uploaded CV/attachment (the file itself, with its
    102 filename and upload date), the submission context stored with the application (the page the application was sent from), the
    103 recruiter notes and interview notes written about them, their interviews, and the emails Vakanssi
    104 sent them. Other details stored with an application or the candidate are included too, under
    105 "Additional application data". The export deliberately does **not** name the staff member who wrote a note, gave a
    106 rating, or conducted an interview. That is a third party's personal data, not the candidate's.
     71When you run **Tools → Export Personal Data** for a candidate's email, Vakanssi includes their profile (name, email, phone, location), every application (position, stage, status, date, and whether consent was given), the cover letter, their LinkedIn profile, each uploaded CV/attachment (the file itself, with its filename and upload date), the submission context stored with the application (the page the application was sent from), the recruiter notes and interview notes written about them, their interviews, and the emails Vakanssi sent them. Other details stored with an application or the candidate are included too, under "Additional application data". The export deliberately does **not** name the staff member who wrote a note, gave a rating, or conducted an interview. That is a third party's personal data, not the candidate's.
    10772
    108 The matching **Erase Personal Data** tool removes all of it, including the CV files on disk. Export
    109 and erasure share one list of the tables that hold notes, interviews and emails about a candidate,
    110 so the two stay in step.
     73The matching **Erase Personal Data** tool removes all of it, including the CV files on disk. Export and erasure share one list of the tables that hold notes, interviews and emails about a candidate, so the two stay in step.
    11174
    11275= Does it work on WordPress multisite? =
    11376
    114 Yes, activated per site or network-wide. Each site keeps its own jobs, candidates, CVs and
    115 settings (data is never shared between sites), and each site chooses independently whether
    116 deleting the plugin also deletes its hiring data. There is no network-level configuration screen; settings are per site.
     77Yes, activated per site or network-wide. Each site keeps its own jobs, candidates, CVs and settings (data is never shared between sites), and each site chooses independently whether deleting the plugin also deletes its hiring data. There is no network-level configuration screen; settings are per site.
    11778
    118 Network activation is the recommended setup: deleting a site then removes that site's Vakanssi
    119 data with it, and if some of its CVs cannot be deleted, Vakanssi keeps the list of those files.
    120 With per-site activation, a site deleted where Vakanssi is not active keeps its Vakanssi tables,
    121 and its CVs when they are in a custom storage folder. Since 1.3.0 a super admin sees this data in
    122 Site Health and under **Hiring → Tools → Data**, and removes it there after a confirmation. When
    123 Vakanssi cannot prove a site's CV files are gone (for example a folder it cannot read), it keeps
    124 that site's file list and says why. A single site turned into a network keeps finding the CVs it
    125 stored before, and Site Health names the folder to move them from.
     79Network activation is the recommended setup: deleting a site then removes that site's Vakanssi data with it, and if some of its CVs cannot be deleted, Vakanssi keeps the list of those files. With per-site activation, a site deleted where Vakanssi is not active keeps its Vakanssi tables, and its CVs when they are in a custom storage folder. Since 1.3.0 a super admin sees this data in Site Health and under **Hiring → Tools → Data**, and removes it there after a confirmation. When Vakanssi cannot prove a site's CV files are gone (for example a folder it cannot read), it keeps that site's file list and says why. A single site turned into a network keeps finding the CVs it stored before, and Site Health names the folder to move them from.
    12680
    12781= Does it work on Nginx? =
    12882
    129 Yes. Nginx ignores `.htaccess`, so add the generated `location` block to your server config. The
    130 plugin's screens show the rule, and Site Health flags the folder, when it is reachable.
     83Yes. Nginx ignores `.htaccess`, so add the generated `location` block to your server config. The plugin's screens show the rule, and Site Health flags the folder, when it is reachable.
    13184
    13285= Does it work with my theme and page builder? =
    13386
    134 Yes, and you do not have to fall back to a shortcode. The block editor gets a **Job Listings**
    135 block. **Elementor** gets three native widgets (the listing, the application form, and the job
    136 details) grouped under a Vakanssi section in the panel, and they work with the free Elementor; if
    137 you run Elementor Pro, your Theme Builder archive and single templates for jobs are used instead of
    138 ours. **Divi** gets a Jobs module. Shortcodes (`[vakanssi_jobs]`, `[vakanssi_job_apply]`,
    139 `[vakanssi_job_details]`) still work anywhere else, including builders with no dedicated
    140 integration.
     87Yes, and you do not have to fall back to a shortcode. The block editor gets a **Job Listings** block. **Elementor** gets three native widgets (the listing, the application form, and the job details) grouped under a Vakanssi section in the panel, and they work with the free Elementor; if you run Elementor Pro, your Theme Builder archive and single templates for jobs are used instead of ours. **Divi** gets a Jobs module. Shortcodes (`[vakanssi_jobs]`, `[vakanssi_job_apply]`, `[vakanssi_job_details]`) still work anywhere else, including builders with no dedicated integration.
    14188
    142 Themes need nothing special. Block themes on WordPress 6.7 and later get editable "Jobs archive" (while the archive page is on)
    143 and "Single job" templates in the Site Editor, built from your own header and footer; classic themes get the built-in archive. The
    144 candidate-facing pages are styled so they survive a theme's own CSS reset, so the listing and the
    145 apply button look the same whichever theme you run.
     89Themes need nothing special. Block themes on WordPress 6.7 and later get editable "Jobs archive" (while the archive page is on) and "Single job" templates in the Site Editor, built from your own header and footer; classic themes get the built-in archive. The candidate-facing pages are styled so they survive a theme's own CSS reset, so the listing and the apply button look the same whichever theme you run.
    14690
    14791= Can I restyle the careers/job pages, and will custom CSS slow my site down? =
    14892
    149 Yes. Under **Hiring → Settings → Jobs & Careers → Appearance** you can turn off Vakanssi's front-end stylesheet
    150 entirely, if your theme styles the markup. For your own styling, use WordPress's built-in editor at
    151 **Appearance → Customize → Additional CSS**, which adds no extra request. Vakanssi keeps its own
    152 selectors as light as theme-proofing allows and its class names stable. Match their weight, such as
    153 `.vakanssi-apply-form .vakanssi-apply-button` for the application form's Submit button or
    154 `:root p.vakanssi-apply a.vakanssi-apply-button` for a job's Apply link, and style `:hover`, `:focus` and
    155 `:active` as well, since Vakanssi sets those too. On most pages that is enough without `!important`.
     93Yes. Under **Hiring → Settings → Jobs & Careers → Appearance** you can turn off Vakanssi's front-end stylesheet entirely, if your theme styles the markup. For your own styling, use WordPress's built-in editor at **Appearance → Customize → Additional CSS**, which adds no extra request. Vakanssi keeps its own selectors as light as theme-proofing allows and its class names stable. Match their weight, such as `.vakanssi-apply-form .vakanssi-apply-button` for the application form's Submit button or `:root p.vakanssi-apply a.vakanssi-apply-button` for a job's Apply link, and style `:hover`, `:focus` and `:active` as well, since Vakanssi sets those too. On most pages that is enough without `!important`.
    15694
    157 The same `vakanssi-` class names are on the careers and job pages under block themes and classic
    158 themes alike, so one rule covers both. On a block theme your theme keeps control of the spacing,
    159 and Vakanssi sets only the column the careers page, the jobs archive and a job share: override it with
    160 `.vakanssi-careers-page { --wp--style--global--content-size: 1100px; --wp--style--global--wide-size: 1100px; }`
    161 (the same on `.vakanssi-careers-archive` and `.vakanssi-single-job`). The job list keeps a 960px reading
    162 width inside that column; add `--vakanssi-measure: 1100px;` to the same rule to widen the list too.
     95The same `vakanssi-` class names are on the careers and job pages under block themes and classic themes alike, so one rule covers both. On a block theme your theme keeps control of the spacing, and Vakanssi sets only the column the careers page, the jobs archive and a job share: override it with `.vakanssi-careers-page { --wp--style--global--content-size: 1100px; --wp--style--global--wide-size: 1100px; }` (the same on `.vakanssi-careers-archive` and `.vakanssi-single-job`). The job list keeps a 960px reading width inside that column; add `--vakanssi-measure: 1100px;` to the same rule to widen the list too.
    16396
    16497= Do I need any special server setup for a production site? =
    16598
    166 Two things are worth doing on a live hiring site, and both are standard WordPress production
    167 hygiene rather than Vakanssi requirements. First, switch WordPress to a real cron trigger:
    168 out of the box, WordPress runs scheduled tasks only when someone visits your site, so on a
    169 quiet careers site scheduled work can run late. Vakanssi relies on it to purge candidate data once
    170 its retention period is up. Add `define( 'DISABLE_WP_CRON', true );` to `wp-config.php` and trigger
    171 `wp-cron.php` every few minutes; most managed hosts offer this as a checkbox. Second, if your
    172 host offers a persistent object cache (Redis or Memcached), enable it: Vakanssi uses
    173 transients for its dashboard counters, and an object cache keeps those out of the database
    174 under heavy traffic. Apply-form rate limits always use the database, so they hold either way. Nothing breaks without either step.
     99Two things are worth doing on a live hiring site, and both are standard WordPress production hygiene rather than Vakanssi requirements. First, switch WordPress to a real cron trigger: out of the box, WordPress runs scheduled tasks only when someone visits your site, so on a quiet careers site scheduled work can run late. Vakanssi relies on it to purge candidate data once its retention period is up. Add `define( 'DISABLE_WP_CRON', true );` to `wp-config.php` and trigger `wp-cron.php` every few minutes; most managed hosts offer this as a checkbox. Second, if your host offers a persistent object cache (Redis or Memcached), enable it: Vakanssi uses transients for its dashboard counters, and an object cache keeps those out of the database under heavy traffic. Apply-form rate limits always use the database, so they hold either way. Nothing breaks without either step.
    175100
    176101= Can I disable the /jobs/ archive page? =
    177102
    178 Yes: **Hiring → Settings → Jobs & Careers → Job URLs** → "Archive page". Single job pages stay
    179 live under your job URL base (e.g. /jobs/job-title/); the archive URL becomes available for your own
    180 page, such as a Careers page using the [vakanssi_jobs] shortcode.
     103Yes: **Hiring → Settings → Jobs & Careers → Job URLs** → "Archive page". Single job pages stay live under your job URL base (e.g. /jobs/job-title/); the archive URL becomes available for your own page, such as a Careers page using the [vakanssi_jobs] shortcode.
    181104
    182105= What stops two recruiters overwriting each other on the board? =
    183106
    184 Every save carries the state the screen was showing when you started editing. If someone else
    185 changed that candidate first, the save is refused and you are shown what changed instead of
    186 quietly losing one of the two edits. This runs over ordinary REST requests, so it needs nothing
    187 special on your server and works on any host that runs WordPress normally.
     107Every save carries the state the screen was showing when you started editing. If someone else changed that candidate first, the save is refused and you are shown what changed instead of quietly losing one of the two edits. This runs over ordinary REST requests, so it needs nothing special on your server and works on any host that runs WordPress normally.
    188108
    189109= Can I switch from another job or recruitment plugin? =
    … …  
    195115It is a job board for your own organisation: your openings on a careers page on your own site, with the applications that come in managed in the same place. It is not a multi-employer board where other companies sign up and post their own jobs.
    196116
     117= Can I use Vakanssi with an AI assistant? =
     118
     119Yes, on WordPress 6.9 and later. Install the free MCP Adapter plugin and connect an assistant that supports MCP (such as Claude or Cursor) with an application password. It can then list your jobs, read one and create a draft, with the same permissions as the user it signs in as. Vakanssi itself contacts no AI service: your assistant connects to your site.
     120
     121None of these abilities read applications or CVs.
     122
    197123= Is there a Pro version? =
    198124
    … …  
    202128
    2031291. The hiring pipeline. Drag candidates between your own stages, with a live count on each and ratings, attachments and dates at a glance.
     130
    2041312. A candidate. CV on file with an inline preview, rating, notes, interviews and the full history, without leaving the board.
     132
    2051333. Your careers page. Branded, filterable, and marked up for Google for Jobs.
     134
    2061354. The application form. Secure CV upload, LinkedIn and cover letter, on your own job page.
     136
    2071375. Interviews. Schedule an interview and send a real calendar invite, with internal notes only your interviewers see.
     138
    2081396. Setup. Three short steps. It looks at your site first and offers to connect an existing careers page instead of creating a duplicate.
    209140
    210141== External services ==
    211142
    212 Vakanssi does not contact any external service on its own. Everything it stores stays on
    213 your server. One optional integration talks to a third party, and only after you switch it
    214 on and enter your own credentials:
     143Vakanssi does not contact any external service on its own. Everything it stores stays on your server. One optional integration talks to a third party, and only after you switch it on and enter your own credentials:
    215144
    216145**Cloudflare Turnstile** (optional spam protection for the public application form)
    217146
    218 Turnstile is off by default. It activates only once you enter a Turnstile site key and
    219 secret under Hiring → Settings → Application form. While it is enabled:
     147Turnstile is off by default. It activates only once you enter a Turnstile site key and secret under Hiring → Settings → Application form. While it is enabled:
    220148
    221 * each visitor's browser loads the challenge script from
    222   `https://challenges.cloudflare.com/turnstile/v0/api.js`;
    223 * when someone submits an application, the resulting challenge token, the visitor's IP
    224   address and your secret key are sent to
    225   `https://challenges.cloudflare.com/turnstile/v0/siteverify` so Cloudflare can confirm the
    226   submission is not automated;
    227 * when an administrator uses "Test these keys" on the settings screen, that admin's browser
    228   loads the same challenge script, and the resulting token, the admin's IP address and the
    229   secret key being tested are sent to the same address, so the key pair can be checked
    230   without waiting for a real application.
     149* each visitor's browser loads the challenge script from `https://challenges.cloudflare.com/turnstile/v0/api.js`;
    231150
    232 No application content (no name, email, CV, or answers) is sent to Cloudflare. Turning the
    233 setting off stops all contact with the service.
     151* when someone submits an application, the resulting challenge token, the visitor's IP address and your secret key are sent to `https://challenges.cloudflare.com/turnstile/v0/siteverify` so Cloudflare can confirm the submission is not automated;
     152
     153* when an administrator uses "Test these keys" on the settings screen, that admin's browser loads the same challenge script, and the resulting token, the admin's IP address and the secret key being tested are sent to the same address, so the key pair can be checked without waiting for a real application.
     154
     155No application content (no name, email, CV, or answers) is sent to Cloudflare. Turning the setting off stops all contact with the service.
    234156
    235157Service: https://www.cloudflare.com/products/turnstile/
    … …  
    238160
    239161== Changelog ==
     162= 1.3.19 =
     163* New: AI assistants connected through the WordPress Abilities API (WordPress 6.9+, with the MCP Adapter plugin) can list jobs, read a job and create a job draft. Drafts are never published, and scripts are stripped from the text.
     164* Improved: sample data now includes CVs, ratings, notes, an interview, email history and activity, so the board looks lived in.
     165* Fixed: on dark themes the careers list, job page and their links were nearly invisible (job titles at 1.17:1). Text on the page now follows the theme's own text colour, keyboard focus rings included, and on light themes nothing changes.
     166* Fixed: on light themes with a tinted background, grey and brand-colour text on the careers page now reads at 4.5:1 or better, whatever brand colour is set.
     167* Fixed: moving an application into a stage from another job's pipeline is now refused.
     168
    240169= 1.3.18 =
    241170* Fixed: when someone applied again at the same moment their application, person or data was deleted, erased or purged, the new details or the whole application could be left behind or attached to nobody. Every write onto an existing application or person now waits for, or is refused by, a delete in progress.
    … …  
    255184* Developers: new application meta submitted_details, included in the personal data export and removed by erasure and retention.
    256185
    257 = 1.3.16 =
    258 * New: after an import from WP Job Openings or Simple Job Board, Tools > Import finds the CV files the old plugin still keeps in its uploads folder, which your web server may serve to anyone with the link. Delete the files Vakanssi holds a checked copy of in one click. Files with no copy in Vakanssi are listed and need a second confirmation. Until the folder is clean, a reminder shows on Vakanssi screens, in Site Health and under Tools > Status.
    259 * Changed: the import's finish note no longer says you can deactivate the old plugin while its CV files are still there.
    260 * Developers: new options vakanssi_import_cleanup_* and vakanssi_import_check_*, and user meta vakanssi_legacy_files_snoozed, all removed on uninstall.
    261 
  • vakanssi/trunk/src/Admin/SampleContent.php

    r3803675 r3813839  
    88namespace Vakanssi\Admin;
    99
     10use Vakanssi\Database\Repositories\ActivityRepository;
    1011use Vakanssi\Database\Repositories\ApplicationMetaRepository;
    1112use Vakanssi\Database\Repositories\ApplicationRepository;
    1213use Vakanssi\Database\Repositories\CandidateRepository;
     14use Vakanssi\Database\Repositories\FileRepository;
     15use Vakanssi\Database\Repositories\InterviewRepository;
     16use Vakanssi\Database\Repositories\NoteRepository;
     17use Vakanssi\Database\Repositories\StageEventRepository;
     18use Vakanssi\Modules\Email\EmailTemplates;
     19use Vakanssi\Modules\Email\Mailer;
     20use Vakanssi\Modules\Email\Notifications;
     21use Vakanssi\Modules\Import\Sources\AbstractSource;
     22use Vakanssi\Modules\Interviews\InterviewerRoster;
     23use Vakanssi\Modules\Interviews\InterviewService;
    1324use Vakanssi\Modules\Jobs\JobFields;
    1425use Vakanssi\Modules\Jobs\JobPostType;
    … …  
    1728use Vakanssi\Modules\Pipeline\StageService;
    1829use Vakanssi\Security\Capabilities;
     30use Vakanssi\Security\ProtectedStorage;
    1931use Vakanssi\Support\EmailIdentity;
    2032use Vakanssi\Support\Transaction;
    … …  
    3446 * @example.com candidate plus recruiter notifications during setup. Direct
    3547 * inserts also allow staggered `created_at` values so the board looks lived-in.
     48 *
     49 * The applications carry what a worked candidate has, so the drawer's tabs are
     50 * not empty ({@see seed_history()}): a CV in protected storage, ratings, team
     51 * notes, one upcoming interview, the email log and the stage history. The same
     52 * rule holds for each of them: nothing is mailed and no `vakanssi/*` action
     53 * fires, so no calendar invite or notification leaves the site.
    3654 *
    3755 * Everything created is flagged (post meta on jobs, an application_meta row on
    … …  
    5977
    6078        /**
    61          * Option (vakanssi_ prefixed via helpers) recording sample candidate ids.
     79         * Option (vakanssi_ prefixed via helpers) recording sample candidate ids
     80         * (`candidates`) and the activity rows the seed wrote (`activity`,
     81         * application id => row ids).
    6282         */
    6383        const OPTION = 'sample_content';
     84
     85        /**
     86         * Key set to true in the `changes` of every activity row the seed writes.
     87         * Removal deletes only recorded rows that carry it, so a recorded id that
     88         * has come to name a real row (the tables emptied and their ids reused)
     89         * is never deleted. Readers of `changes` ignore keys they do not know.
     90         */
     91        const ACTIVITY_MARK = 'sample_content';
    6492
    6593        /**
    … …  
    160188                $recorded_ids    = array();
    161189                $application_ids = array();
     190                $seeded          = array();
    162191
    163192                foreach ( $this->candidate_definitions() as $definition ) {
    … …  
    183212                        $candidate_ids[] = $candidate_id;
    184213
    185                         $slot    = $slots[ $definition['stage'] ];
    186                         $created = gmdate( 'Y-m-d H:i:s', time() - ( $definition['days_ago'] * DAY_IN_SECONDS ) );
    187                         $job_id  = $job_ids[ $definition['job'] ];
     214                        $slot       = $slots[ $definition['stage'] ];
     215                        $created_ts = time() - ( $definition['days_ago'] * DAY_IN_SECONDS );
     216                        $created    = gmdate( 'Y-m-d H:i:s', $created_ts );
     217                        $job_id     = $job_ids[ $definition['job'] ];
    188218
    189219                        $application_id = (int) $applications->insert(
    … …  
    195225                                        'status'          => $stage_service->status_for_type( $slot['type'] ),
    196226                                        'source'          => $definition['source'],
     227                                        'rating'          => $definition['rating'],
    197228                                        'payload'         => wp_json_encode( array( 'sample' => true ) ),
    198229                                        'consent_given'   => 1,
    … …  
    204235                        );
    205236
     237                        if ( $application_id <= 0 ) {
     238                                // The insert failed. Nothing may hang off application 0: a CV,
     239                                // notes or history written there would be reachable by no
     240                                // removal. The candidate is recorded, and removal deletes it as
     241                                // a candidate with no application.
     242                                continue;
     243                        }
     244
    206245                        $meta_repo->add( $application_id, self::APP_FLAG, '1' );
    207246                        if ( '' !== $definition['cover_letter'] ) {
    … …  
    210249
    211250                        $application_ids[] = $application_id;
     251                        $seeded[]          = array(
     252                                'definition'     => $definition,
     253                                'application_id' => $application_id,
     254                                'candidate_id'   => $candidate_id,
     255                                'job_id'         => $job_id,
     256                                'created'        => $created_ts,
     257                        );
    212258                }
    213259
    214260                // Merge, never rebuild: an option written by an older seed may carry
    215261                // removal-bookkeeping keys that removal still needs, so preserve whatever
    216                 // is already here rather than overwriting it.
     262                // is already here rather than overwriting it. The candidates are
     263                // recorded before the history is written (file copies and all), so a
     264                // seed cut short there still leaves them where removal looks.
    217265                $option = (array) vakanssi_option( self::OPTION, array() );
    218266                vakanssi_update_option(
    … …  
    221269                                $option,
    222270                                array(
    223                                         'candidates' => $recorded_ids,
     271                                        // Added to, never replaced: candidates an earlier seed
     272                                        // recorded may still be on the site (their applications
     273                                        // deleted by hand), and this seed reuses them unrecorded.
     274                                        'candidates' => array_values( array_unique( array_merge( isset( $option['candidates'] ) ? array_map( 'intval', (array) $option['candidates'] ) : array(), $recorded_ids ) ) ),
    224275                                        'seeded_at'  => current_time( 'mysql', true ),
    225276                                )
    226277                        )
    227278                );
     279
     280                $this->seed_history( $seeded, $slots, $stage_service );
    228281
    229282                return array(
    … …  
    232285                        'applications' => $application_ids,
    233286                );
     287        }
     288
     289        /**
     290         * Give the seeded applications the history a worked candidate has, so the
     291         * drawer's tabs show the product instead of empty states: the CV, team
     292         * notes, the upcoming interview, the emails and the moves through the
     293         * pipeline. Ratings are set on the application rows themselves.
     294         *
     295         * Every write goes through a repository, never a service that sends or
     296         * announces: no wp_mail(), no calendar invite, no `vakanssi/*` action, so
     297         * nothing is announced and nothing leaves the site.
     298         * Each part whose module is switched off is skipped, and so are notes and
     299         * the interview when there is nobody to attribute them to.
     300         *
     301         * Times are UTC and follow each application's age: received, moved along
     302         * at even intervals since, notes in between, nothing in the future except
     303         * the interview itself.
     304         *
     305         * @param array<int, array<string, mixed>> $seeded        One entry per application: definition, application_id, candidate_id, job_id, created (Unix time).
     306         * @param array<string, array>             $slots         Stage slots from stage_slots().
     307         * @param StageService                     $stage_service Stage service.
     308         * @return array<int, int[]> Application id => ids of the activity rows written on it. Each
     309         *                           row is also recorded in {@see OPTION} as soon as it is written,
     310         *                           so a seed cut short leaves none unrecorded.
     311         */
     312        private function seed_history( array $seeded, array $slots, StageService $stage_service ) {
     313                $now       = time();
     314                $actor     = $this->acting_user_id();
     315                $activity  = new ActivityRepository();
     316                $notes     = vakanssi_module_active( 'notes' ) && $actor > 0 ? new NoteRepository() : null;
     317                $mail      = Mailer::sending_enabled() ? new Notifications() : null;
     318                $templates = new EmailTemplates();
     319                $written   = array();
     320
     321                foreach ( $seeded as $app ) {
     322                        $definition     = $app['definition'];
     323                        $application_id = (int) $app['application_id'];
     324                        $created        = (int) $app['created'];
     325
     326                        $written[ $application_id ]   = array();
     327                        $written[ $application_id ][] = (int) $activity->insert(
     328                                array(
     329                                        'entity_type' => 'application',
     330                                        'entity_id'   => $application_id,
     331                                        'user_id'     => 0,
     332                                        'action'      => 'application_created',
     333                                        'changes'     => wp_json_encode(
     334                                                array(
     335                                                        'job_id'            => (int) $app['job_id'],
     336                                                        self::ACTIVITY_MARK => true,
     337                                                )
     338                                        ),
     339                                        'ip_address'  => '',
     340                                        'created_at'  => gmdate( 'Y-m-d H:i:s', $created ),
     341                                )
     342                        );
     343                        $this->record_activity( $application_id, $written[ $application_id ] );
     344
     345                        if ( ! empty( $definition['cv'] ) ) {
     346                                $this->attach_sample_cv( $application_id, (int) $app['candidate_id'], $definition, $created );
     347                        }
     348
     349                        // The confirmation goes out as the application lands, when the
     350                        // template is on (a site that turned it off would not have sent it).
     351                        if ( $mail && $templates->is_enabled( 'confirmation' ) ) {
     352                                $mail->log_sample_send( 'confirmation', $application_id, gmdate( 'Y-m-d H:i:s', $created + MINUTE_IN_SECONDS ) );
     353                        }
     354
     355                        $moves = $this->seed_moves( $app, $slots, $stage_service, $actor, $now, $written[ $application_id ] );
     356
     357                        // A rejection follows the move when the template is on; the offer is
     358                        // off by default, so it reads as the recruiter's "Send email & move".
     359                        if ( $mail && isset( $moves['rejected'] ) && $templates->is_enabled( 'reject' ) ) {
     360                                $mail->log_sample_send( 'reject', $application_id, gmdate( 'Y-m-d H:i:s', $moves['rejected'] + MINUTE_IN_SECONDS ), (int) $slots['rejected']['id'] );
     361                        }
     362                        if ( $mail && isset( $moves['hired'] ) ) {
     363                                $mail->log_sample_send( 'offer', $application_id, gmdate( 'Y-m-d H:i:s', $moves['hired'] + MINUTE_IN_SECONDS ), (int) $slots['hired']['id'] );
     364                        }
     365
     366                        if ( $notes ) {
     367                                foreach ( $definition['notes'] as $note ) {
     368                                        // A share of the application's age, never later than half an
     369                                        // hour ago.
     370                                        $at = min( $now - 30 * MINUTE_IN_SECONDS, $created + (int) ( $note[0] * ( $now - $created ) ) );
     371                                        $notes->insert(
     372                                                array(
     373                                                        'application_id' => $application_id,
     374                                                        'user_id'        => $actor,
     375                                                        'body'           => $note[1],
     376                                                        'mentions'       => '[]',
     377                                                        'created_at'     => gmdate( 'Y-m-d H:i:s', $at ),
     378                                                )
     379                                        );
     380                                }
     381                        }
     382
     383                        if ( ! empty( $definition['interview'] ) && isset( $moves['interview'] ) && $actor > 0 && vakanssi_module_active( 'interviews' ) ) {
     384                                $this->seed_interview( $app, $slots['interview'], $actor, $moves['interview'], $now );
     385                        }
     386                }
     387
     388                return array_filter( array_map( 'array_filter', $written ) );
     389        }
     390
     391        /**
     392         * Walk one application from the entry stage to where it sits, writing the
     393         * `stage_changed` audit row each move leaves (the drawer's Activity tab).
     394         *
     395         * On a pipeline with fewer stages a missing slot points at the entry
     396         * stage, so the walk skips a stage already passed and stops at the one the
     397         * application is in: never a move backwards, never one past it.
     398         *
     399         * @param array<string, mixed> $app           Seeded application entry.
     400         * @param array<string, array> $slots         Stage slots.
     401         * @param StageService         $stage_service Stage service.
     402         * @param int                  $actor         User credited with the moves.
     403         * @param int                  $now           Unix time of the seed.
     404         * @param int[]                $written       Activity ids written on this application (appended to).
     405         * @return array<string, int> Slot name => Unix time of the move into it.
     406         */
     407        private function seed_moves( array $app, array $slots, StageService $stage_service, $actor, $now, array &$written ) {
     408                $paths = array(
     409                        'new'       => array(),
     410                        'in_review' => array( 'in_review' ),
     411                        'interview' => array( 'in_review', 'interview' ),
     412                        'offer'     => array( 'in_review', 'interview', 'offer' ),
     413                        'hired'     => array( 'in_review', 'interview', 'offer', 'hired' ),
     414                        'rejected'  => array( 'in_review', 'rejected' ),
     415                );
     416
     417                $stage_key      = (string) $app['definition']['stage'];
     418                $application_id = (int) $app['application_id'];
     419                $created        = (int) $app['created'];
     420                $from           = (int) $slots['new']['id'];
     421                $target         = (int) $slots[ $stage_key ]['id'];
     422                $steps          = $target === $from ? array() : $paths[ $stage_key ];
     423                $count          = count( $steps );
     424                $last           = $created;
     425                $visited        = array( $from => true );
     426                $moves          = array();
     427                $activity       = new ActivityRepository();
     428
     429                foreach ( $steps as $i => $step ) {
     430                        $to = (int) $slots[ $step ]['id'];
     431                        if ( isset( $visited[ $to ] ) ) {
     432                                continue;
     433                        }
     434                        $visited[ $to ] = true;
     435
     436                        // Evenly spaced across the application's age, at least an hour
     437                        // apart, and never later than an hour ago.
     438                        $at   = min( $now - HOUR_IN_SECONDS, max( $last + HOUR_IN_SECONDS, $created + (int) ( ( $i + 1 ) * ( $now - $created ) / ( $count + 1 ) ) ) );
     439                        $last = $at;
     440                        $when = gmdate( 'Y-m-d H:i:s', $at );
     441
     442                        $status    = $stage_service->status_for_type( $slots[ $step ]['type'] );
     443                        $written[] = (int) $activity->insert(
     444                                array(
     445                                        'entity_type' => 'application',
     446                                        'entity_id'   => $application_id,
     447                                        'user_id'     => (int) $actor,
     448                                        'action'      => 'stage_changed',
     449                                        'changes'     => wp_json_encode(
     450                                                array(
     451                                                        'from'              => $from,
     452                                                        'to'                => $to,
     453                                                        'status'            => $status,
     454                                                        self::ACTIVITY_MARK => true,
     455                                                )
     456                                        ),
     457                                        'ip_address'  => '',
     458                                        'created_at'  => $when,
     459                                )
     460                        );
     461                        $this->record_activity( $application_id, $written );
     462
     463                        $moves[ $step ] = $at;
     464                        $from           = $to;
     465                        if ( $to === $target ) {
     466                                break;
     467                        }
     468                }
     469
     470                return $moves;
     471        }
     472
     473        /**
     474         * Book the sample interview: two days out at 14:00 UTC, with the seeding
     475         * user as organizer and, when they are on the hiring roster, interviewer.
     476         *
     477         * Written through the repository in the shape InterviewService::schedule()
     478         * stores, because schedule() mails the calendar invite to the candidate
     479         * and the interviewers and fires `vakanssi/interview/scheduled`. A sample
     480         * candidate has an @example.com address, and a real site must never mail
     481         * one, so there is no send to suppress: none is attempted.
     482         *
     483         * @param array<string, mixed> $app      Seeded application entry.
     484         * @param array<string, mixed> $slot     The Interview stage slot.
     485         * @param int                  $actor    Organizer user id.
     486         * @param int                  $moved_at Unix time of the move into Interview.
     487         * @param int                  $now      Unix time of the seed.
     488         * @return int Interview id, or 0.
     489         */
     490        private function seed_interview( array $app, array $slot, $actor, $moved_at, $now ) {
     491                $definition = $app['definition'];
     492                $day        = $now + 2 * DAY_IN_SECONDS;
     493                $start      = gmmktime( 14, 0, 0, (int) gmdate( 'n', $day ), (int) gmdate( 'j', $day ), (int) gmdate( 'Y', $day ) );
     494
     495                return ( new InterviewRepository() )->insert(
     496                        array(
     497                                'application_id'  => (int) $app['application_id'],
     498                                'candidate_id'    => (int) $app['candidate_id'],
     499                                'job_title'       => get_the_title( (int) $app['job_id'] ),
     500                                'organizer_id'    => (int) $actor,
     501                                'interviewers'    => (string) wp_json_encode( InterviewerRoster::valid_ids( array( (int) $actor ) ) ),
     502                                'title'           => InterviewService::stored_title( $definition['interview']['title'], '' ),
     503                                'stage_id'        => (int) $slot['id'],
     504                                'mode'            => 'video',
     505                                'location'        => '',
     506                                'status'          => 'scheduled',
     507                                'scheduled_at'    => gmdate( 'Y-m-d H:i:s', $start ),
     508                                'duration'        => 60,
     509                                'slots'           => null,
     510                                'token'           => wp_generate_password( 32, false ),
     511                                'candidate_name'  => $definition['first_name'] . ' ' . $definition['last_name'],
     512                                'candidate_email' => $definition['email'],
     513                                'ics_uid'         => InterviewService::new_ics_uid(),
     514                                'sequence'        => 0,
     515                                'notes'           => $definition['interview']['notes'],
     516                                'created_at'      => gmdate( 'Y-m-d H:i:s', min( $now, $moved_at + 30 * MINUTE_IN_SECONDS ) ),
     517                        )
     518                );
     519        }
     520
     521        /**
     522         * Store a generated one-page PDF as the application's CV, through the
     523         * same verified copy into protected storage that imported CVs take
     524         * ({@see AbstractSource::copy_verified_into_storage()}: extension and
     525         * size checks, the PDF signature check, a random file name, 0600). It is
     526         * then served like any CV, by the authenticated download endpoint, and
     527         * deleted with the application.
     528         *
     529         * The PDF is written to the system temp folder for that copy and deleted
     530         * straight after. When storage cannot take it, the application simply has
     531         * no CV.
     532         *
     533         * @param int                  $application_id Application id.
     534         * @param int                  $candidate_id   Candidate id.
     535         * @param array<string, mixed> $definition     Candidate definition.
     536         * @param int                  $created        Unix time the application arrived.
     537         * @return int File row id, or 0.
     538         */
     539        private function attach_sample_cv( $application_id, $candidate_id, array $definition, $created ) {
     540                $storage = new ProtectedStorage();
     541                $tmp     = trailingslashit( get_temp_dir() ) . 'vakanssi-sample-cv-' . wp_generate_password( 12, false ) . '.pdf';
     542                $pdf     = self::sample_cv_pdf( $definition['first_name'] . ' ' . $definition['last_name'], $definition['cv']['headline'], $definition['cv']['lines'] );
     543
     544                if ( false === file_put_contents( $tmp, $pdf ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents -- a generated sample CV written to the system temp folder for the verified copy below and deleted right after; WP_Filesystem may need FTP credentials, which the Playground and the setup wizard cannot supply.
     545                        return 0;
     546                }
     547                $stored = AbstractSource::copy_verified_into_storage( $storage, $tmp );
     548                wp_delete_file( $tmp );
     549                if ( null === $stored ) {
     550                        return 0;
     551                }
     552
     553                $files   = new FileRepository();
     554                $file_id = (int) $files->insert(
     555                        array(
     556                                'application_id' => (int) $application_id,
     557                                'candidate_id'   => (int) $candidate_id,
     558                                'path'           => $stored['path'],
     559                                'filename'       => ProtectedStorage::safe_filename( $definition['first_name'] . '-' . $definition['last_name'] . '-CV.pdf' ),
     560                                'mime'           => $stored['mime'],
     561                                'size'           => $stored['size'],
     562                                'hash'           => $stored['hash'],
     563                                'created_at'     => gmdate( 'Y-m-d H:i:s', (int) $created ),
     564                        )
     565                );
     566                if ( ! $file_id ) {
     567                        // A row that did not land must not leave its bytes behind.
     568                        $storage->delete_stored( $stored['path'] );
     569                }
     570
     571                return $file_id;
     572        }
     573
     574        /**
     575         * A minimal one-page PDF: the name, a headline, three lines and a footer
     576         * saying it is sample data. Standard Helvetica, so nothing is embedded;
     577         * the cross-reference offsets are computed, so viewers open it without a
     578         * repair pass. Text is ASCII by construction (the definitions below).
     579         *
     580         * @param string   $name     Candidate name.
     581         * @param string   $headline One-line headline.
     582         * @param string[] $lines    Body lines.
     583         * @return string PDF bytes.
     584         */
     585        public static function sample_cv_pdf( $name, $headline, array $lines ) {
     586                $text = static function ( $value ) {
     587                        $value = (string) preg_replace( '/[^\x20-\x7E]/', '', (string) $value );
     588
     589                        return '(' . strtr(
     590                                $value,
     591                                array(
     592                                        '\\' => '\\\\',
     593                                        '('  => '\\(',
     594                                        ')'  => '\\)',
     595                                )
     596                        ) . ')';
     597                };
     598
     599                $stream  = 'BT /F1 22 Tf 56 770 Td ' . $text( $name ) . " Tj ET\n";
     600                $stream .= 'BT /F2 13 Tf 56 744 Td ' . $text( $headline ) . " Tj ET\n";
     601                $stream .= "BT /F2 11 Tf 16 TL 56 708 Td\n";
     602                foreach ( array_values( $lines ) as $i => $line ) {
     603                        $stream .= ( $i > 0 ? 'T* ' : '' ) . $text( $line ) . " Tj\n";
     604                }
     605                $stream .= "ET\n";
     606                $stream .= 'BT /F2 9 Tf 56 56 Td ' . $text( 'Sample CV created by Vakanssi to show how CVs look. Not a real person.' ) . " Tj ET\n";
     607
     608                $objects = array(
     609                        '<< /Type /Catalog /Pages 2 0 R >>',
     610                        '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
     611                        '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 4 0 R /F2 5 0 R >> >> /Contents 6 0 R >>',
     612                        '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>',
     613                        '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>',
     614                        '<< /Length ' . strlen( $stream ) . " >>\nstream\n" . $stream . 'endstream',
     615                );
     616
     617                $pdf     = "%PDF-1.4\n";
     618                $offsets = array();
     619                foreach ( $objects as $i => $object ) {
     620                        $offsets[] = strlen( $pdf );
     621                        $pdf      .= ( $i + 1 ) . " 0 obj\n" . $object . "\nendobj\n";
     622                }
     623
     624                $xref = strlen( $pdf );
     625                $pdf .= 'xref' . "\n0 " . ( count( $objects ) + 1 ) . "\n0000000000 65535 f \n";
     626                foreach ( $offsets as $offset ) {
     627                        $pdf .= sprintf( "%010d 00000 n \n", $offset );
     628                }
     629                $pdf .= 'trailer' . "\n<< /Size " . ( count( $objects ) + 1 ) . " /Root 1 0 R >>\nstartxref\n" . $xref . "\n%%EOF\n";
     630
     631                return $pdf;
     632        }
     633
     634        /**
     635         * Record the activity rows written on one sample application, for removal.
     636         * Added to what is recorded, never replacing it: ids from an earlier seed
     637         * whose applications someone deleted by hand are still waiting there.
     638         *
     639         * @param int   $application_id Application id.
     640         * @param int[] $row_ids        Activity row ids.
     641         * @return void
     642         */
     643        private function record_activity( $application_id, array $row_ids ) {
     644                $row_ids = array_values( array_filter( array_map( 'intval', $row_ids ) ) );
     645                if ( array() === $row_ids ) {
     646                        return;
     647                }
     648
     649                $option   = (array) vakanssi_option( self::OPTION, array() );
     650                $recorded = isset( $option['activity'] ) && is_array( $option['activity'] ) ? $option['activity'] : array();
     651
     652                $recorded[ (int) $application_id ] = $row_ids;
     653                $option['activity']                = $recorded;
     654                vakanssi_update_option( self::OPTION, $option );
     655        }
     656
     657        /**
     658         * Who the sample notes, moves and interview are credited to: the user
     659         * running the seed when they can see applications, otherwise the first
     660         * administrator (the Playground blueprint seeds from a script with no
     661         * user, and bin/seed-demo-data.php credits the same person), otherwise
     662         * nobody (0), and those parts are skipped.
     663         *
     664         * @return int
     665         */
     666        private function acting_user_id() {
     667                $user_id = get_current_user_id();
     668                if ( $user_id > 0 && user_can( $user_id, Capabilities::VIEW_APPLICATIONS ) ) {
     669                        return (int) $user_id;
     670                }
     671
     672                $admins = get_users(
     673                        array(
     674                                'role'    => 'administrator',
     675                                'number'  => 1,
     676                                'fields'  => 'ID',
     677                                'orderby' => 'ID',
     678                                'order'   => 'ASC',
     679                        )
     680                );
     681
     682                return $admins ? (int) $admins[0] : 0;
    234683        }
    235684
    … …  
    255704                );
    256705
    257                 // 1. Applications first (full GDPR cascade: files, meta, notes, emails…).
    258                 $service = new ApplicationService();
     706                $option = (array) vakanssi_option( self::OPTION, array() );
     707
     708                // 1. Applications first. ApplicationService::delete() is the full GDPR
     709                // cascade, which covers everything the seed hangs off an application:
     710                // the CV (bytes first, then the row), meta, notes, the email log,
     711                // interviews and evaluations (PersonalDataCategories), the rating (a
     712                // column of the row itself) and, through StageEventLogger's
     713                // `vakanssi/application/deleted` listener, the stage events.
     714                $service      = new ApplicationService();
     715                $applications = new ApplicationRepository();
     716                $failed       = array();
    259717                foreach ( ( new ApplicationMetaRepository() )->application_ids_with( self::APP_FLAG ) as $application_id ) {
    260718                        if ( true === $service->delete( $application_id ) ) {
    261719                                ++$counts['applications'];
     720                        } else {
     721                                $failed[] = (int) $application_id;
     722                        }
     723                }
     724
     725                // The one thing that cascade keeps on purpose is the audit trail. The
     726                // rows the seed wrote there record nothing anyone did, so they go: the
     727                // ids recorded at seed time, per application. Only a sample application
     728                // this removal could not delete keeps its history, recorded for the
     729                // retry. Every other one goes, whether its application is gone (deleted
     730                // now, or by hand before) or still there without its sample flag (the
     731                // retention purge anonymises in place and clears the flag): kept, those
     732                // ids would sit in the option for good, since no removal reaches them.
     733                $history = array();
     734                foreach ( isset( $option['activity'] ) ? (array) $option['activity'] : array() as $application_id => $row_ids ) {
     735                        $application_id = (int) $application_id;
     736                        if ( $application_id <= 0 || ! is_array( $row_ids ) ) {
     737                                continue;
     738                        }
     739                        // Also kept when the delete itself failed, so a retry can find them.
     740                        if ( in_array( $application_id, $failed, true )
     741                                || false === ( new ActivityRepository() )->delete_ids_for_entities( $row_ids, 'application', array( $application_id ), '"' . self::ACTIVITY_MARK . '":true' ) ) {
     742                                $history[ $application_id ] = array_map( 'intval', $row_ids );
    262743                        }
    263744                }
    … …  
    266747                // remaining applications, so a candidate who later applied for a real
    267748                // job is kept.
    268                 $option     = (array) vakanssi_option( self::OPTION, array() );
    269749                $candidates = new CandidateRepository();
    270750                $ids        = isset( $option['candidates'] ) ? array_map( 'intval', (array) $option['candidates'] ) : array();
     751                $left       = array();
    271752                foreach ( $ids as $candidate_id ) {
    272753                        // The row is locked first, as every candidate delete does, and
    … …  
    279760                        if ( ! $removed ) {
    280761                                $tx->rollback();
     762                                $left[] = $candidate_id;
    281763                        } elseif ( $tx->commit() ) {
    282764                                ++$counts['candidates'];
     765                        } else {
     766                                $left[] = $candidate_id;
    283767                        }
    284768                }
    … …  
    287771                // applications are gone by now, so any application still pointing at
    288772                // a job is real: keep that job, as a draft, and unflag it.
     773                //
     774                // Except a job still holding a sample application this removal could
     775                // not delete: that application is not real, so the job stays a sample
     776                // job, flagged and hidden, for the retry to finish. Counted as real, it
     777                // was turned into an ordinary draft the retry could no longer find,
     778                // and the user was told real people had applied to it.
     779                $waiting = array();
     780                foreach ( $failed as $application_id ) {
     781                        $row = $applications->find( $application_id );
     782                        if ( $row ) {
     783                                $waiting[ (int) $row['job_id'] ] = true;
     784                        }
     785                }
    289786                foreach ( $this->sample_job_ids() as $job_id ) {
    290787                        $post = get_post( $job_id );
    … …  
    292789                                continue;
    293790                        }
    294                         if ( '1' !== get_post_meta( $job_id, self::JOB_FLAG, true ) ) {
     791                        if ( '1' !== get_post_meta( $job_id, self::JOB_FLAG, true ) || isset( $waiting[ (int) $job_id ] ) ) {
    295792                                continue;
    296793                        }
    … …  
    310807                }
    311808
    312                 vakanssi_update_option( self::OPTION, false );
    313                 delete_option( 'vakanssi_' . self::OPTION );
     809                if ( array() !== $failed || array() !== $history ) {
     810                        // A sample application could not be deleted (most often a CV whose
     811                        // bytes could not be removed), or its recorded history could not,
     812                        // so the removal is not finished. Keep what a retry needs to finish
     813                        // it: the candidates not removed yet and the history ids. Forgotten
     814                        // here, a retry would leave those candidates and rows behind for good.
     815                        vakanssi_update_option(
     816                                self::OPTION,
     817                                array(
     818                                        'candidates' => $left,
     819                                        'activity'   => $history,
     820                                )
     821                        );
     822                } else {
     823                        vakanssi_update_option( self::OPTION, false );
     824                        delete_option( 'vakanssi_' . self::OPTION );
     825                }
    314826                delete_option( 'vakanssi_' . SampleJobs::HIDDEN_OPTION );
    315827
    … …  
    5731085         * The seven sample candidates: every stage type covered, staggered ages.
    5741086         * Names/emails are intentionally fake (@example.com) and stay English —
    575          * this is throwaway demo data.
     1087         * this is throwaway demo data. So do the notes, CV lines and interview
     1088         * details: they stand for what a team and a candidate wrote, which is in
     1089         * their own language, not the site's.
     1090         *
     1091         * Each entry also carries its depth: `rating` (0 to 4, 0 is unrated),
     1092         * `notes` (share of the application's age at which each was written, and
     1093         * its text), `cv` (headline and three lines of a generated PDF, or empty)
     1094         * and `interview` (title and staff notes of an upcoming interview, or
     1095         * empty). Reviewed candidates (In Review and later) are rated.
    5761096         *
    5771097         * @return array<int, array<string, mixed>>
    … …  
    5881108                                'days_ago'     => 1,
    5891109                                'cover_letter' => '',
     1110                                'rating'       => 0,
     1111                                'notes'        => array(),
     1112                                'cv'           => array(),
     1113                                'interview'    => array(),
    5901114                        ),
    5911115                        array(
    … …  
    5981122                                'days_ago'     => 2,
    5991123                                'cover_letter' => '',
     1124                                'rating'       => 0,
     1125                                'notes'        => array(),
     1126                                'cv'           => array(),
     1127                                'interview'    => array(),
    6001128                        ),
    6011129                        array(
    … …  
    6081136                                'days_ago'     => 4,
    6091137                                'cover_letter' => 'I have led design systems at two B2B SaaS companies and would love to bring that experience to your hiring platform.',
     1138                                'rating'       => 3,
     1139                                'notes'        => array(
     1140                                        array( 0.6, 'Strong portfolio. The design system case study is exactly the work this role needs.' ),
     1141                                        array( 0.85, 'Referred by Ana on the platform team. Worth a first call this week.' ),
     1142                                ),
     1143                                'cv'           => array(
     1144                                        'headline' => 'Senior product designer',
     1145                                        'lines'    => array(
     1146                                                'Eight years designing B2B SaaS products, the last four leading a design system.',
     1147                                                'Runs discovery, prototyping and usability testing end to end.',
     1148                                                'Based in London. Portfolio and references on request.',
     1149                                        ),
     1150                                ),
     1151                                'interview'    => array(),
    6101152                        ),
    6111153                        array(
    … …  
    6181160                                'days_ago'     => 6,
    6191161                                'cover_letter' => '',
     1162                                'rating'       => 3,
     1163                                'notes'        => array(
     1164                                        array( 0.6, 'Phone screen went well: clear on API design and testing. Moving him to a technical interview.' ),
     1165                                        array( 0.8, 'Ask about his on-call experience in the technical round.' ),
     1166                                ),
     1167                                'cv'           => array(
     1168                                        'headline' => 'Backend engineer',
     1169                                        'lines'    => array(
     1170                                                'Six years building APIs and data pipelines in PHP and Go.',
     1171                                                'Owns code review and testing practice on a team of five.',
     1172                                                'Remote from Manchester, UK.',
     1173                                        ),
     1174                                ),
     1175                                'interview'    => array(
     1176                                        'title' => 'Technical interview',
     1177                                        'notes' => 'Focus on API design and how he tests his code.',
     1178                                ),
    6201179                        ),
    6211180                        array(
    … …  
    6281187                                'days_ago'     => 9,
    6291188                                'cover_letter' => 'Eight years of PHP and Go, currently maintaining a queue system that processes forty million jobs a day.',
     1189                                'rating'       => 4,
     1190                                'notes'        => array(
     1191                                        array( 0.55, 'Excellent technical interview. Strongest backend candidate so far.' ),
     1192                                        array( 0.8, 'Offer drafted at the top of the range. Waiting on her reply.' ),
     1193                                ),
     1194                                'cv'           => array(
     1195                                        'headline' => 'Senior backend engineer',
     1196                                        'lines'    => array(
     1197                                                'Eight years of PHP and Go. Maintains a queue system that runs forty million jobs a day.',
     1198                                                'Led the move from a monolith to services with no downtime.',
     1199                                                'Remote from Toronto, Canada.',
     1200                                        ),
     1201                                ),
     1202                                'interview'    => array(),
    6301203                        ),
    6311204                        array(
    … …  
    6381211                                'days_ago'     => 12,
    6391212                                'cover_letter' => '',
     1213                                'rating'       => 4,
     1214                                'notes'        => array(
     1215                                        array( 0.5, 'Great with customers in the role play, and happy with the part-time schedule.' ),
     1216                                        array( 0.85, 'Accepted the offer. Start date confirmed for the first of next month.' ),
     1217                                ),
     1218                                'cv'           => array(
     1219                                        'headline' => 'Customer support specialist',
     1220                                        'lines'    => array(
     1221                                                'Three years in customer support for a software company.',
     1222                                                'Writes help-center articles and triages bugs with engineering.',
     1223                                                'Lives in Austin and is free for part-time shifts.',
     1224                                        ),
     1225                                ),
     1226                                'interview'    => array(),
    6401227                        ),
    6411228                        array(
    … …  
    6481235                                'days_ago'     => 14,
    6491236                                'cover_letter' => '',
     1237                                'rating'       => 2,
     1238                                'notes'        => array(
     1239                                        array( 0.6, 'Friendly and clear, but looking for full-time hours, and this role is part time.' ),
     1240                                ),
     1241                                'cv'           => array(),
     1242                                'interview'    => array(),
    6501243                        ),
    6511244                );
  • vakanssi/trunk/src/Core/Uninstall/Inventory.php

    r3797582 r3813839  
    110110                        'vakanssi_email_automation_rules',
    111111                        'vakanssi_webhooks',
     112                        // Whether AI assistants may read candidate details.
     113                        'vakanssi_abilities',
    112114                        'vakanssi_antispam',
    113115                        // The per-provider "these keys were verified" cache written beside
    … …  
    118120                        'vakanssi_scheduling',
    119121                        'vakanssi_scorecards',
     122                        // Saved only through options.php, so the uninstall test's source
     123                        // scan missed it until it read register_setting() too.
     124                        'vakanssi_scorecards_blind',
    120125                        'vakanssi_screening_default',
    121126
  • vakanssi/trunk/src/Database/Repositories/ActivityRepository.php

    r3792652 r3813839  
    193193
    194194                return $row ? $row : null;
     195        }
     196
     197        /**
     198         * Delete specific activity rows, and only those that still belong to one of
     199         * the given entities.
     200         *
     201         * The audit trail is otherwise never deleted. This exists for sample
     202         * content, whose seed writes the history a real application would have
     203         * (received, moved) so the drawer's Activity tab is not empty, and whose
     204         * removal must take exactly those rows away again: they record nothing
     205         * anyone did. The caller passes the ids it wrote; the entity condition is a
     206         * second key, and `$marker`, text the caller put in each row's `changes`,
     207         * a third. Ids and entity ids both come back when the tables are emptied
     208         * and their counters restart, so only the marker tells a recorded row from
     209         * a real one that later took its id; a row without it is left alone.
     210         *
     211         * @param int[]  $ids         Row ids.
     212         * @param string $entity_type Entity type the rows must carry.
     213         * @param int[]  $entity_ids  Entity ids one of which each row must carry.
     214         * @param string $marker      Text each row's `changes` must contain. Required:
     215         *                            an empty marker deletes nothing.
     216         * @return int|false Rows deleted, or false on a database error.
     217         */
     218        public function delete_ids_for_entities( array $ids, $entity_type, array $entity_ids, $marker ) {
     219                global $wpdb;
     220
     221                $ids        = array_values( array_unique( array_filter( array_map( 'intval', $ids ) ) ) );
     222                $entity_ids = array_values( array_unique( array_filter( array_map( 'intval', $entity_ids ) ) ) );
     223                if ( ! $ids || ! $entity_ids || '' === (string) $marker ) {
     224                        return 0;
     225                }
     226
     227                return $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom table vakanssi_activity; no WordPress API reads or writes plugin tables, and a write has nothing to cache.
     228                        $wpdb->prepare(
     229                                'DELETE FROM %i WHERE entity_type = %s AND id IN (' . implode( ', ', array_fill( 0, count( $ids ), '%d' ) ) . ') AND entity_id IN (' . implode( ', ', array_fill( 0, count( $entity_ids ), '%d' ) ) . ') AND changes LIKE %s',
     230                                array_merge( array( $this->full_table(), (string) $entity_type ), $ids, $entity_ids, array( '%' . $wpdb->esc_like( (string) $marker ) . '%' ) )
     231                        )
     232                );
    195233        }
    196234
  • vakanssi/trunk/src/Database/Repositories/EmailRepository.php

    r3749092 r3813839  
    339339         * site that had never sent an email as one whose email was working.
    340340         *
     341         * Rows of sample applications are not counted. Sample content records the
     342         * emails a real application would have produced without mailing anything
     343         * ({@see \Vakanssi\Modules\Email\Notifications::log_sample_send()}), so
     344         * counting them would hand a fresh install that has never sent a message
     345         * the same green tick this denominator exists to withhold.
     346         *
    341347         * @param string $since MySQL datetime (GMT).
    342348         * @return int
    … …  
    347353                $table = $this->full_table();
    348354
    349                 $count = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom table vakanssi_emails; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    350                         $wpdb->prepare(
    351                                 "SELECT COUNT(*) FROM %i WHERE status = 'sent' AND created_at >= %s",
    352                                 array( $table, $since )
     355                $count = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_emails and vakanssi_application_meta; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
     356                        $wpdb->prepare(
     357                                "SELECT COUNT(*) FROM %i e WHERE e.status = 'sent' AND e.created_at >= %s AND NOT EXISTS ( SELECT 1 FROM %i m WHERE m.application_id = e.application_id AND m.meta_key = %s )",
     358                                array( $table, $since, vakanssi_table( 'application_meta' ), \Vakanssi\Admin\SampleContent::APP_FLAG )
    353359                        )
    354360                );
  • vakanssi/trunk/src/Modules/Email/Mailer.php

    r3785137 r3813839  
    4949                $this->templates = $templates ? $templates : new EmailTemplates();
    5050                $this->log       = $log ? $log : new EmailRepository();
     51        }
     52
     53        /**
     54         * The once-only dedupe key of a templated send to one application.
     55         *
     56         * One definition, because two writers put it on a log row: {@see send()}
     57         * when it claims a send, and {@see Notifications::log_sample_send()} when
     58         * sample content records a send that never happened. Both must write the
     59         * same key, or the duplicate guard would not recognise a sample row and a
     60         * later automatic send of the same template would go out a second time.
     61         *
     62         * @param int    $application_id Application id.
     63         * @param string $key            Template id.
     64         * @return string
     65         */
     66        public static function dedupe_key( $application_id, $key ) {
     67                return sprintf( 'app:%d:tpl:%s', (int) $application_id, (string) $key );
    5168        }
    5269
    … …  
    108125                // of times (MySQL permits multiple NULLs in a UNIQUE index).
    109126                $dedupe_key = ( ! $allow_resend && $application_id > 0 )
    110                         ? sprintf( 'app:%d:tpl:%s', (int) $application_id, $key )
     127                        ? self::dedupe_key( $application_id, $key )
    111128                        : null;
    112129
  • vakanssi/trunk/src/Modules/Email/Notifications.php

    r3785137 r3813839  
    798798                        $wpdb->query( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', $lock ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- releases the MySQL named lock taken above with GET_LOCK; no WordPress API releases a named lock.
    799799                }
     800        }
     801
     802        /**
     803         * Record a candidate email as sent without sending anything.
     804         *
     805         * For sample content only ({@see \Vakanssi\Admin\SampleContent::seed()}):
     806         * a sample application's email history should hold the messages a real one
     807         * would have, but sample candidates have @example.com addresses and nothing
     808         * may be mailed, so this never reaches wp_mail() and fires no `vakanssi/*`
     809         * action. (The merge context runs the same filters a real send runs.)
     810         *
     811         * The row is the one {@see Mailer::send()} leaves after a successful send,
     812         * so every reader of the log treats it as one: a real template key (never
     813         * a label, see the `template` hazard in {@see is_resendable()}), the subject
     814         * that template renders from the same merge context, in the site's
     815         * language, the candidate's address, status `sent`, and the once-only
     816         * dedupe key, so a later automatic send of the same template is not sent a
     817         * second time. A Resend from the drawer then rebuilds the body from the
     818         * template, exactly as for a real row.
     819         *
     820         * Only candidate-facing templates are accepted: a staff template's row would
     821         * name a staff address this method has no business inventing.
     822         *
     823         * @param string $key            Template id: `confirmation`, `reject` or `offer`.
     824         * @param int    $application_id Application id.
     825         * @param string $at             When it was "sent", UTC `Y-m-d H:i:s`.
     826         * @param int    $stage_id       The stage the real send would have named in
     827         *                               `{stage}`: the destination of the move for a
     828         *                               rejection or offer, 0 (no stage, as
     829         *                               {@see on_created()} sends it) for a
     830         *                               confirmation. Never the stage the application
     831         *                               sits in now, which is later than the email.
     832         * @return int The log row id, or 0 when nothing was recorded.
     833         */
     834        public function log_sample_send( $key, $application_id, $at, $stage_id = 0 ) {
     835                $key = (string) $key;
     836                if ( ! Mailer::sending_enabled()
     837                        || null === ( new EmailTemplates() )->get( $key )
     838                        || EmailTemplates::AUDIENCE_CANDIDATE !== EmailTemplates::audience( $key )
     839                        || EmailTemplates::is_staff_template( $key ) ) {
     840                        return 0;
     841                }
     842
     843                $application = $this->applications->find( (int) $application_id );
     844                $candidate   = $application && ! empty( $application['candidate_id'] ) ? $this->candidates->find( (int) $application['candidate_id'] ) : null;
     845                $recipient   = $candidate ? sanitize_email( (string) ( $candidate['email'] ?? '' ) ) : '';
     846                if ( ! $application || ! is_email( $recipient ) ) {
     847                        return 0;
     848                }
     849
     850                $context   = $this->context_from_records( $application, $candidate, (int) $stage_id, (int) $application_id, $key );
     851                $templates = new EmailTemplates();
     852                $subject   = Mailer::in_site_locale(
     853                        static function () use ( $templates, $key, $context ) {
     854                                return $templates->subject( $key, $context );
     855                        }
     856                );
     857
     858                return ( new EmailRepository() )->insert_if_application_exists(
     859                        array(
     860                                'application_id' => (int) $application_id,
     861                                'template'       => $key,
     862                                'dedupe_key'     => Mailer::dedupe_key( $application_id, $key ),
     863                                'recipient'      => $recipient,
     864                                'subject'        => Mailer::plain_subject( (string) $subject ),
     865                                'status'         => 'sent',
     866                                'sent_at'        => (string) $at,
     867                                'created_at'     => (string) $at,
     868                        )
     869                );
    800870        }
    801871
  • vakanssi/trunk/src/Modules/Jobs/JobsModule.php

    r3783327 r3813839  
    88namespace Vakanssi\Modules\Jobs;
    99
     10use Vakanssi\Abilities\AbilitiesBootstrap;
     11use Vakanssi\Abilities\JobAbilities;
    1012use Vakanssi\Core\Container;
    1113use Vakanssi\Core\Modules\AbstractModule;
    … …  
    111113                ( new LegacyBlockThemeArchive() )->register();
    112114
     115                // AI assistants (WordPress 6.9+ Abilities API): list, read and draft
     116                // jobs, with the same permissions as the REST API for jobs. On an
     117                // older WordPress this hooks nothing.
     118                ( new AbilitiesBootstrap() )->add( array( new JobAbilities(), 'register' ) );
     119
    113120                // Flush rewrite rules once, after the CPT/taxonomies have registered.
    114121                add_action( 'init', array( $this, 'maybe_flush_rewrites' ), 99 );
  • vakanssi/trunk/src/Modules/Pipeline/PipelineService.php

    r3749092 r3813839  
    9595         * never double-logs or double-emails.
    9696         *
     97         * The destination must be a stage of the pipeline the application's job
     98         * uses ({@see StageService::for_job()}); any other stage is refused with
     99         * `vakanssi_stage_not_in_pipeline` before anything is written, unless it is
     100         * the stage the application sits in when the write is attempted. A stale
     101         * `$expected_from_stage_id` is reported as the conflict first. The origin
     102         * is not checked, so an application left in a stage its job no longer uses
     103         * can still be moved into the job's current pipeline.
     104         *
    97105         * @param int      $application_id         Application id.
    98106         * @param int      $stage_id               Destination stage id.
    … …  
    116124                        return new \WP_Error( 'vakanssi_bad_stage', __( 'Unknown pipeline stage.', 'vakanssi' ) );
    117125                }
     126
     127                // Only a stage of the pipeline this application's job uses: the same
     128                // list the board draws its columns from (GET /stages?job=), i.e. the
     129                // job's own stages, else the shared template. Checking only that the
     130                // stage exists let any job's stage id through, and the application then
     131                // sat in a column no board for its job shows. Checked inside the loop,
     132                // against the row each attempt reads.
     133                $pipeline = $this->stages->map_for_job( (int) $application['job_id'] );
    118134
    119135                for ( $attempt = 0; $attempt < 3; $attempt++ ) {
    … …  
    148164                        }
    149165
     166                        // The stage this attempt read the application in is exempt, so a card
     167                        // re-dropped on its own (retired) column is not refused for that
     168                        // reason. Checked per attempt: exempting it from the first read let a
     169                        // retry write the retired stage after a concurrent move took the
     170                        // application out of it. After the precondition, so a stale client
     171                        // still gets the conflict and the live row.
     172                        if ( $from !== $stage_id && ! isset( $pipeline[ $stage_id ] ) ) {
     173                                return new \WP_Error( 'vakanssi_stage_not_in_pipeline', __( 'That stage is not in this job\'s pipeline.', 'vakanssi' ), array( 'status' => 400 ) );
     174                        }
     175
    150176                        // Already in the desired end state — either because the caller
    151177                        // re-dropped a card on its own column, or because another request
  • vakanssi/trunk/src/Rest/Routes/ApplicationsController.php

    r3802833 r3813839  
    2020use Vakanssi\Modules\Jobs\JobFields;
    2121use Vakanssi\Modules\Pipeline\ApplicationDetailsService;
    22 use Vakanssi\Modules\Pipeline\ApplicationsQuery;
     22use Vakanssi\Modules\Pipeline\ApplicationsListing;
    2323use Vakanssi\Modules\Pipeline\ApplicationService;
    2424use Vakanssi\Modules\Pipeline\ApplicationShape;
    2525use Vakanssi\Modules\Pipeline\CandidateContextService;
    2626use Vakanssi\Modules\Pipeline\PersonEnrichment;
    27 use Vakanssi\Modules\Pipeline\PipelineService;
     27use Vakanssi\Modules\Pipeline\StageMove;
    2828use Vakanssi\Modules\Pipeline\StageService;
    2929use Vakanssi\Modules\Pipeline\ViewTracker;
    … …  
    346346                $offset   = ( $page - 1 ) * $per_page;
    347347
    348                 list( $total, $rows ) = $this->index_page( $request, $per_page, $offset );
     348                list( $total, $rows ) = ( new ApplicationsListing() )->page(
     349                        array(
     350                                'job'    => (int) $request['job'],
     351                                'stage'  => (int) $request['stage'],
     352                                'search' => empty( $request['search'] ) ? '' : (string) $request['search'],
     353                        ),
     354                        $per_page,
     355                        $offset
     356                );
    349357
    350358                $items = array_map( array( $this, 'shape_row' ), (array) $rows );
    … …  
    379387
    380388        /**
    381          * One page of the board's applications under the request's job, stage and
    382          * search, and how many match in all.
    383          *
    384          * Same search semantics as the list and export (full name in either order
    385          * included), so the board and the List view never disagree about what a
    386          * search finds: the filter predicates are the ones {@see ApplicationsQuery}
    387          * documents, each always present and switched off by its own value. The
    388          * board has no person filter, so `candidate` is always 0.
    389          *
    390          * @param \WP_REST_Request $request  Request.
    391          * @param int              $per_page Rows per page.
    392          * @param int              $offset   Rows to skip.
    393          * @return array{0: int, 1: array<int, array<string, mixed>>}
    394          */
    395         private function index_page( \WP_REST_Request $request, $per_page, $offset ) {
    396                 global $wpdb;
    397 
    398                 $apps       = vakanssi_table( 'applications' );
    399                 $candidates = vakanssi_table( 'candidates' );
    400                 $files      = vakanssi_table( 'files' );
    401                 $meta       = vakanssi_table( 'application_meta' );
    402                 $key        = ViewTracker::META_KEY;
    403 
    404                 $f = ApplicationsQuery::filters(
    405                         array(
    406                                 'job'    => (int) $request['job'],
    407                                 'stage'  => (int) $request['stage'],
    408                                 'search' => empty( $request['search'] ) ? '' : (string) $request['search'],
    409                         )
    410                 );
    411 
    412                 // Three shapes, so each keeps the plan its clause-by-clause statement
    413                 // had. A statement that names a.job_id or a.stage_id cannot count off
    414                 // the candidate_id index even when those predicates fold away, and
    415                 // with no application filter that index scan is the cheapest count
    416                 // (EXPLAIN on a 30,000-application site: index scan before, table scan
    417                 // with the full predicate set).
    418                 if ( ! $f['job'] && ! $f['stage'] && '' === $f['search'] ) {
    419                         $total = (int) $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id', $apps, $candidates ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    420                 } elseif ( ! $f['job'] && ! $f['stage'] ) {
    421                         $total = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    422                                 $wpdb->prepare(
    423                                         "SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    424                                         WHERE ( %s = '' OR c.email LIKE %s
    425                                                 OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    426                                                 OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )",
    427                                         array( $apps, $candidates, $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'] )
    428                                 )
    429                         );
    430                 } else {
    431                         $total = (int) $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    432                                 $wpdb->prepare(
    433                                         "SELECT COUNT(*) FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    434                                         WHERE ( %d = 0 OR a.job_id = %d )
    435                                                 AND ( %d = 0 OR a.candidate_id = %d )
    436                                                 AND ( %d = 0 OR a.stage_id = %d )
    437                                                 AND ( %s = '' OR c.email LIKE %s
    438                                                         OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    439                                                         OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )",
    440                                         array( $apps, $candidates, $f['job'], $f['job'], $f['candidate'], $f['candidate'], $f['stage'], $f['stage'], $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'] )
    441                                 )
    442                         );
    443                 }
    444 
    445                 $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- custom tables vakanssi_files, vakanssi_application_meta, vakanssi_applications and vakanssi_candidates; no WordPress API reads or writes plugin tables, and this result is not cached because it must be fresh for this request.
    446                         $wpdb->prepare(
    447                                 "SELECT a.id, a.job_id, a.job_title, a.candidate_id, a.stage_id, a.status, a.rating, a.source, a.created_at, a.updated_at, a.stage_version, a.details_version, c.details_version AS candidate_details_version, c.first_name, c.last_name, c.email, EXISTS(SELECT 1 FROM %i f WHERE f.application_id = a.id) AS has_cv, (a.status = 'active' AND NOT EXISTS(SELECT 1 FROM %i m WHERE m.application_id = a.id AND m.meta_key = %s)) AS is_new, (SELECT COUNT(*) FROM %i a2 WHERE a2.candidate_id = a.candidate_id AND a.candidate_id > 0 AND a2.id <> a.id) AS related_count FROM %i a LEFT JOIN %i c ON a.candidate_id = c.id
    448                                 WHERE ( %d = 0 OR a.job_id = %d )
    449                                         AND ( %d = 0 OR a.candidate_id = %d )
    450                                         AND ( %d = 0 OR a.stage_id = %d )
    451                                         AND ( %s = '' OR c.email LIKE %s
    452                                                 OR ( %d = 0 AND ( c.first_name LIKE %s OR c.last_name LIKE %s ) )
    453                                                 OR ( %d = 1 AND ( CONCAT_WS(' ', c.first_name, c.last_name) LIKE %s OR CONCAT_WS(' ', c.last_name, c.first_name) LIKE %s ) ) )
    454                                 ORDER BY a.created_at DESC, a.id DESC LIMIT %d OFFSET %d",
    455                                 array( $files, $meta, $key, $apps, $apps, $candidates, $f['job'], $f['job'], $f['candidate'], $f['candidate'], $f['stage'], $f['stage'], $f['search'], $f['like'], $f['spaced'], $f['like'], $f['like'], $f['spaced'], $f['like'], $f['like'], $per_page, $offset )
    456                         ),
    457                         ARRAY_A
    458                 );
    459 
    460                 return array( $total, (array) $rows );
    461         }
    462 
    463         /**
    464389         * GET /applications/{id} — single application for the profile drawer.
    465390         *
    … …  
    628553                $id = absint( $request['id'] );
    629554
    630                 $notify   = $request->get_param( 'notify' );
    631                 $suppress = null !== $notify && false === rest_sanitize_boolean( $notify );
    632                 $force    = null !== $notify && true === rest_sanitize_boolean( $notify );
     555                // Absent means the template's automatic-send flag decides (null);
     556                // otherwise the mover's explicit choice: true sends, false does not.
     557                $notify = $request->get_param( 'notify' );
     558                $notify = null !== $notify ? rest_sanitize_boolean( $notify ) : null;
    633559
    634560                // No default on the route arg: absent means no precondition (legacy
    … …  
    637563                $expected_from_stage_id = null !== $expected_from_stage_id ? (int) $expected_from_stage_id : null;
    638564
    639                 if ( $suppress ) {
    640                         add_filter( 'vakanssi/email/stage_notification', '__return_false', 100 );
    641                 }
    642                 if ( $force ) {
    643                         // "Send email & move": the user chose to email, so the template's
    644                         // automatic-send flag is bypassed for this one transition.
    645                         add_filter( 'vakanssi/email/force_stage_notification', '__return_true', 100 );
    646                 }
    647                 try {
    648                         $result = ( new PipelineService() )->move( $id, absint( $request['stage_id'] ), $expected_from_stage_id );
    649                 } finally {
    650                         if ( $suppress ) {
    651                                 remove_filter( 'vakanssi/email/stage_notification', '__return_false', 100 );
    652                         }
    653                         if ( $force ) {
    654                                 remove_filter( 'vakanssi/email/force_stage_notification', '__return_true', 100 );
    655                         }
    656                 }
     565                $result = StageMove::run( $id, absint( $request['stage_id'] ), $expected_from_stage_id, $notify );
    657566
    658567                if ( is_wp_error( $result ) ) {
  • vakanssi/trunk/vakanssi.php

    r3803675 r3813839  
    44 * Plugin URI:        https://vakanssi.com/
    55 * Description:       All-in-one Hiring & ATS for WordPress: job listings, a careers page with Google-for-Jobs schema, applicant tracking with a drag-and-drop pipeline, confirmation and notification emails, and privacy tools.
    6  * Version:           1.3.18
     6 * Version:           1.3.19
    77 * Requires at least: 6.6
    88 * Requires PHP:      7.4
    … …  
    3333 * ---------------------------------------------------------------------------
    3434 */
    35 define( 'VAKANSSI_VERSION', '1.3.18' );
     35define( 'VAKANSSI_VERSION', '1.3.19' );
    3636define( 'VAKANSSI_PLUGIN_FILE', __FILE__ );
    3737define( 'VAKANSSI_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.