function dacdb_newsletter($atts)
{
global $fDebug, $data_path, $file_path, $options, $wp;
$documents = '';
$folder = isset($_GET["folder"]) ? $_GET["folder"] : '';
$date = isset($atts['date']) ? $atts['date'] : '0';
$icon = isset($atts['icon']) ? $atts['icon'] : '0';
$location = ($options['dacdb_club'] == 0) ? 'newsletters' : 'bulletins';
$size = isset($atts['size']) ? $atts['size'] : '0';
$url = $data_path . 'wp_newsletters.cfm?AccountID=' . $options['dacdb_district'] . '&ClubID=' . $options['dacdb_club'] . '&type=' . $location . '&Weeks=' . $options['newsletters_weeks_page'];
$xml = simplexml_load_file($url . '&R=' . rand());
if ($fDebug) {
$documents .= '
function dacdb_newsletter called:
Shortcode Settings
- $options[\'newsletters_weeks_page\']
- ' . $options['newsletters_weeks_page'] . '
- $options[\'newsletters_show_folders_page\']
- ' . $options['newsletters_show_folders_page'] . '
- $options[\'newsletters_order_folders_page\']
- ' . $options['newsletters_order_folders_page'] . '
- $options[\'newsletters_weeks_widget\']
- ' . $options['newsletters_weeks_widget'] . '
';
// Show shortcode attributes if there are any
if (count($atts) > 1) {
$documents .= 'Shortcode Attributes
';
foreach ($atts as $key => $value) {
$documents .= ' - $_[\'' . $key . '\']
- ' . $value . '
';
}
$documents .= '
'; // Close the drawer
}
// show URL parameters if there are any (Except Debug)
if (count($_GET) > 1 || (count($_GET) == 1 && !array_key_exists("debug", $_GET))) {
$documents .= 'URL Parameters
';
foreach ($_GET as $key => $value) {
if ($key == "debug") {
continue; // Skip the rest of the loop for this iteration
}
$documents .= ' - $_[\'' . $key . '\']
- ' . $value . '
';
}
$documents .= '
'; // Close the drawer
}
$documents .= '
Named Variables
- $folder
- ' . (isset($folder) && $folder !== '' ? $folder : 'Not set') . '
- $date
- ' . (isset($date) ? $date : 'Not set') . '
- $icon
- ' . (isset($icon) ? $icon : 'Not set') . '
- $location
- ' . (isset($location) ? $location : 'Not set') . '
- $size
- ' . (isset($size) ? $size : 'Not set') . '
URLs
- $file_path
- ' . $file_path . '
- $url
- ' . $url . '
';
// Debugging output for $xml->newsletter
$documents .= '
XML Output
';
foreach ($xml->newsletter as $document) {
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false; // Don't preserve whitespaces
$dom->formatOutput = true; // Format output with indentation and line breaks
$dom->loadXML($document->asXML()); // Load the XML string from SimpleXMLElement
$formattedXml = $dom->saveXML(); // Save the formatted XML to a string
$documents .= '
' . htmlspecialchars($formattedXml) . '
';
}
$documents .= '
'; // Close the drawer and panel
}
if (strlen($xml) == 0) {
$documents .= 'There are no newsletters to display at this time.';
return $documents;
}
$documents .= '
';
return $documents;
}