How Can We Help?
Dynamic Button for Staff Description Pages
Description
The self changing button at the bottom of each Staff Position description page is controlled by a php snipped that is configured in the XYZ PHP CODE plugin.
If the current datetime is between the opening and closing date entered into the snippet, the button will read “APPLY” and direct the user to the Staff Application Form. If the current date time is not between the opening and closing date (regardless if it is before or after) it will read “Closed – go back” and director the user to the Anime Detour Staff Page.
Create a New Button
To create a new button access the XYZ PHP CODE plugin and click the “Add New PHP Code Snippet” button.
Name the snippet according to the pre-existing naming standard in the “Tracking Name” field:
staff-app-btn-departmentname
Then paste the following code into the “PHP Code” box:
<?php
// THESE VARIABLES SET THE STATE OF THE APPLY/CLOSED BUTTON.
// REPLACE ONLY THE DATETIME VALUE. FORMAT MUST FOLLOW EITHER:
// ('08/20/2022 23:59:59') OR ('08/20/2022 11:59:59 PM')
$opening = strtotime('08/20/2022 23:59:59');
$closing = strtotime('08/21/2022 11:59:59 PM');
// DO NOT EDIT BELOW HERE
$nowU = current_time('timestamp');
if ( $opening < $nowU AND $nowU < $closing ) {
echo '<!-- wp:html -->';
echo '<div class="group-btn" style="padding:10px">';
echo '<a href="https://animedetour.com/get-involved/organization-chart/staff-application/" class="btn btn-primary">APPLY HERE</a>';
echo '</div>';
echo '<!-- /wp:html -->';
} else {
echo '<!-- wp:html -->';
echo '<div class="group-btn" style="padding:10px">';
echo '<a href="https://animedetour.com/get-involved/organization-chart/" class="btn btn-primary"><small>CLOSED - go back</small></a>';
echo '</div>';
echo '<!-- /wp:html -->';
}
?>
On the new Department Head Position Description Page add a shortcode object at the bottom of the page. Then copy and paste in the shortcode listed in the “Snippet Short Code” column in the XYZ PHP CODE plugin for the corresponding snippet you just created.
Configure Open and Close Dates
To configure the application date ranges for the dynamics “apply/closed” button on the Staff Position Description pages, access the XYZ PHP CODE plugin and search for the department name. The click the “Edit Snippet” action button in the “Action” column (this icon looks like a paper and pencil).
Within the PHP Snippet set the $opening and $closing data values to the date and time you want the application button to open (switch from “CLOSED” to “APPLY) and when you want the application to close (switch from “APPLY” to “CLOSED”). These values are listed immediately after the initial comment block
$opening = strtotime('08/20/2022 23:59:59');
$closing = strtotime('08/21/2022 11:59:59 PM');
The dates must be in the mm/dd/yyyy hh:mm:ss format. All dates and times should be in Central Time for that date. All spaces, slashes and single quote marks must be preserved. You may use either 24 hour or 12 hour times as long as the follow the example format.
These are TWO values that need to be changed. These are the only values that need to be changed in the code. DO NOT change any other code in the snippet.
Once you have entered the open and close datetimes and verified your format is correct, click the “update” button, then click the “back” button to return to the XYZ PHP CODE plugin’s main page.