load_dependencies(); $this->check_database_version(); $this->define_admin_hooks(); $this->define_event_hooks(); } /** * Load the required dependencies for this plugin. * * @since 1.0.0 * @access private */ private function load_dependencies() { // Include the severity constants class (must load before logger and events) require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-severity.php'; // Include the logger class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-logger.php'; // Include the database class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-database.php'; // Include the events class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-events.php'; // Include the comment logger class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-comment-logger.php'; // Include the help system class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-help.php'; // Include the admin class require_once ACTLOGPRO_PLUGIN_DIR . 'admin/class-alp-admin.php'; // Include the feed class require_once ACTLOGPRO_PLUGIN_DIR . 'includes/class-alp-feed-rss.php'; } /** * Load text domain for internationalization. * * @since 1.0.0 * @access private */ private function set_locale() { // Text domain is now loaded directly in constructor // This method is kept for backward compatibility } /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_admin_hooks() { $admin = new ACTLOGPRO_Admin(); } /** * Register all of the hooks related to tracking events * of the plugin. * * @since 1.0.0 * @access private */ private function define_event_hooks() { $events = new ACTLOGPRO_Events(); } /** * Run the plugin. * * @since 1.0.0 */ public function run() { // Initialize the RSS feed functionality (JSON feeds are handled by premium plugin) // Create an instance of the RSS feed class to register feed endpoints $rss_feed = new ACTLOGPRO_Feed_RSS(); // Initialize the login notification functionality require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-alp-login-notification.php'; $login_notification = new ACTLOGPRO_Login_Notification(); // Initialize the help system $help = new ACTLOGPRO_Help(); // Plugin is now running } /** * Get plugin image HTML using WordPress standards. * * @since 1.0.0 * @param string $image_name Image filename in assets/images/ * @param string $alt_text Alt text for the image * @param string $css_class CSS class for the image * @return string HTML for the image */ public static function get_plugin_image($image_name, $alt_text = '', $css_class = '') { // Use the main plugin file as reference point $plugin_dir = plugin_dir_path(dirname(__FILE__)); $plugin_url = plugin_dir_url(dirname(__FILE__)); $image_url = $plugin_url . 'assets/images/' . $image_name; // Check if image is in media library $attachment_id = attachment_url_to_postid($image_url); if ($attachment_id) { return wp_get_attachment_image($attachment_id, 'medium', false, array( 'alt' => $alt_text, 'class' => $css_class )); } // Fallback for plugin assets $image_path = $plugin_dir . 'assets/images/' . $image_name; if (!file_exists($image_path)) { return ''; } $image_size = @getimagesize($image_path); $width = $image_size ? $image_size[0] : 250; $height = $image_size ? $image_size[1] : 80; $attrs = array( 'src' => esc_url($image_url), 'alt' => esc_attr($alt_text), 'class' => esc_attr($css_class), 'width' => $width, 'height' => $height, 'loading' => 'lazy' ); $attr_string = ''; foreach ($attrs as $key => $value) { if (!empty($value)) { $attr_string .= sprintf(' %s="%s"', $key, $value); } } $allowed_html = array( 'img' => array( 'src' => true, 'alt' => true, 'class' => true, 'width' => true, 'height' => true, 'loading' => true, ), ); return wp_kses(sprintf('', $attr_string), $allowed_html); } /** * Check database version and create/update tables if needed (UPGRADE-SAFE). * Uses database abstraction layer to prevent data loss during upgrades. * * @since 1.0.0 * @access private */ private function check_database_version() { // Use secure database abstraction method to prevent data loss during upgrades // This method will NEVER recreate existing tables with data ACTLOGPRO_Database::check_and_initialize_database(); } }