upskill-event-manager/includes/certificates/class-certificate-settings.php
bengizmo 37f4180e1c feat: Add massive missing plugin infrastructure to repository
🚨 CRITICAL: Fixed deployment blockers by adding missing core directories:

**Community System (CRITICAL)**
- includes/community/ - Login_Handler and all community classes
- templates/community/ - Community login forms

**Certificate System (CRITICAL)**
- includes/certificates/ - 8+ certificate classes and handlers
- templates/certificates/ - Certificate reports and generation templates

**Core Individual Classes (CRITICAL)**
- includes/class-hvac-event-summary.php
- includes/class-hvac-trainer-profile-manager.php
- includes/class-hvac-master-dashboard-data.php
- Plus 40+ other individual HVAC classes

**Major Feature Systems (HIGH)**
- includes/database/ - Training leads database tables
- includes/find-trainer/ - Find trainer directory and MapGeo integration
- includes/google-sheets/ - Google Sheets integration system
- includes/zoho/ - Complete Zoho CRM integration
- includes/communication/ - Communication templates system

**Template Infrastructure**
- templates/attendee/, templates/email-attendees/
- templates/event-summary/, templates/status/
- templates/template-parts/ - Shared template components

**Impact:**
- 70+ files added covering 10+ missing directories
- Resolves ALL deployment blockers and feature breakdowns
- Plugin activation should now work correctly
- Multi-machine deployment fully supported

🔧 Generated with Claude Code

Co-Authored-By: Ben Reed <ben@tealmaker.com>
2025-08-11 13:30:11 -03:00

200 lines
No EOL
6.8 KiB
PHP

<?php
/**
* Certificate Settings Class
*
* Handles the settings for certificate generation.
*
* @package HVAC_Community_Events
* @subpackage Certificates
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
/**
* Certificate Settings class.
*
* Provides settings for customizing certificates.
*
* @since 1.0.0
*/
class HVAC_Certificate_Settings {
/**
* The single instance of the class.
*
* @var HVAC_Certificate_Settings
*/
protected static $_instance = null;
/**
* Main HVAC_Certificate_Settings Instance.
*
* Ensures only one instance of HVAC_Certificate_Settings is loaded or can be loaded.
*
* @return HVAC_Certificate_Settings - Main instance.
*/
public static function instance() {
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Constructor.
*/
public function __construct() {
// Initialize default settings if not already set
$this->maybe_initialize_settings();
}
/**
* Initialize default certificate settings if they don't exist.
*/
public function maybe_initialize_settings() {
// Certificate counter for unique numbers
if (false === get_option('hvac_certificate_counter')) {
add_option('hvac_certificate_counter', 0);
}
// Certificate number prefix
if (false === get_option('hvac_certificate_prefix')) {
add_option('hvac_certificate_prefix', 'HVAC-');
}
// Certificate storage path (relative to wp-content/uploads/)
if (false === get_option('hvac_certificate_storage_path')) {
add_option('hvac_certificate_storage_path', 'hvac-certificates');
}
// Certificate paper size
if (false === get_option('hvac_certificate_paper_size')) {
add_option('hvac_certificate_paper_size', 'LETTER'); // LETTER, A4, etc.
}
// Certificate orientation
if (false === get_option('hvac_certificate_orientation')) {
add_option('hvac_certificate_orientation', 'L'); // L for landscape, P for portrait
}
// Certificate background color
if (false === get_option('hvac_certificate_bg_color')) {
add_option('hvac_certificate_bg_color', '#ffffff');
}
// Certificate border color
if (false === get_option('hvac_certificate_border_color')) {
add_option('hvac_certificate_border_color', '#0074be');
}
// Certificate title text
if (false === get_option('hvac_certificate_title_text')) {
add_option('hvac_certificate_title_text', 'CERTIFICATE OF COMPLETION');
}
// Certificate title color
if (false === get_option('hvac_certificate_title_color')) {
add_option('hvac_certificate_title_color', '#0074be');
}
// Certificate body text color
if (false === get_option('hvac_certificate_text_color')) {
add_option('hvac_certificate_text_color', '#333333');
}
// Certificate completion text
if (false === get_option('hvac_certificate_completion_text')) {
add_option('hvac_certificate_completion_text', 'This certificate is awarded to {attendee_name} for successfully completing {event_name} on {event_date}.');
}
}
/**
* Get all certificate settings.
*
* @return array All certificate settings.
*/
public function get_all_settings() {
return array(
'counter' => get_option('hvac_certificate_counter', 0),
'prefix' => get_option('hvac_certificate_prefix', 'HVAC-'),
'storage_path' => get_option('hvac_certificate_storage_path', 'hvac-certificates'),
'paper_size' => get_option('hvac_certificate_paper_size', 'LETTER'),
'orientation' => get_option('hvac_certificate_orientation', 'L'),
'bg_color' => get_option('hvac_certificate_bg_color', '#ffffff'),
'border_color' => get_option('hvac_certificate_border_color', '#0074be'),
'title_text' => get_option('hvac_certificate_title_text', 'CERTIFICATE OF COMPLETION'),
'title_color' => get_option('hvac_certificate_title_color', '#0074be'),
'text_color' => get_option('hvac_certificate_text_color', '#333333'),
'completion_text' => get_option('hvac_certificate_completion_text', 'This certificate is awarded to {attendee_name} for successfully completing {event_name} on {event_date}.')
);
}
/**
* Update a certificate setting.
*
* @param string $setting The setting key.
* @param mixed $value The setting value.
*
* @return bool True if successful, false otherwise.
*/
public function update_setting($setting, $value) {
$option_name = 'hvac_certificate_' . $setting;
return update_option($option_name, $value);
}
/**
* Get a certificate setting.
*
* @param string $setting The setting key.
* @param mixed $default Optional default value.
*
* @return mixed The setting value or default.
*/
public function get_setting($setting, $default = '') {
$option_name = 'hvac_certificate_' . $setting;
return get_option($option_name, $default);
}
/**
* Get available certificate placeholders.
*
* @return array Placeholders and their descriptions.
*/
public function get_placeholders() {
return array(
'{attendee_name}' => 'The full name of the attendee',
'{event_name}' => 'The name of the event',
'{event_date}' => 'The date when the event occurred',
'{organization_name}' => 'The name of the training organization',
'{instructor_name}' => 'The name of the instructor',
'{venue_name}' => 'The name of the venue',
'{certificate_number}' => 'The unique certificate number',
'{issue_date}' => 'The date when the certificate was issued'
);
}
/**
* Replace placeholders in text with actual values.
*
* @param string $text The text with placeholders.
* @param array $data The data to replace placeholders with.
*
* @return string The text with placeholders replaced.
*/
public function replace_placeholders($text, $data) {
$placeholders = array_keys($this->get_placeholders());
$replacements = array();
foreach ($placeholders as $placeholder) {
$key = str_replace(array('{', '}'), '', $placeholder);
$replacements[] = isset($data[$key]) ? $data[$key] : '';
}
return str_replace($placeholders, $replacements, $text);
}
}