Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action("breakdance_register_template_types_and_conditions", function () {
- \Breakdance\ConditionsAPI\register([
- "supports" => ["element_display", "templating"],
- "slug" => "is-404-condition", // Ensure this slug is unique
- "label" => "404 Page",
- "category" => "WordPress",
- "operands" => ["is", "is not"],
- "values" => function () {
- // Provide only the relevant, functional option
- return [
- [
- "label" => "Page Status",
- "items" => [
- // This single option indicates the condition of being a 404 page
- ["text" => "404", "value" => "true"],
- ],
- ],
- ];
- },
- "allowMultiselect" => false, // Multiselect doesn't apply to this boolean condition
- "callback" => function (string $operand, $value) {
- $is_404 = is_404(); // Determine if the current page is a 404
- if ($operand === "is") {
- return $is_404 === ($value === "true");
- } elseif ($operand === "is not") {
- return !$is_404 === ($value === "true");
- }
- return false;
- },
- ]);
- });
Advertisement
Add Comment
Please, Sign In to add comment