get_logger()->notice( 'UIDashboard parent constructor called with a position of 0.', [ 'plugin' => $domain, ] ); } public function getSettings($settings) { $this->get_logger()->info( 'getSettings method called. Returning the provided settings array without modification.', [ 'plugin' => $this->domain, 'page_slug' => $this->slug, 'settings_keys' => is_array($settings) ? array_keys($settings) : 'not an array', ] ); return $settings; } protected function onSave($settings) { $this->get_logger()->info( 'onSave method for the dashboard UI page called. No modifications to settings are performed.', [ 'plugin' => $this->domain, ] ); // This method is a placeholder and intentionally does not modify the settings. // The dashboard UI page is typically for viewing information, not for saving settings. return $settings; } /** * Maybe delete an given entry. */ private function maybeDelete() { $this->get_logger()->info('Attempting to handle a delete or status-based message display.', [ 'plugin' => $this->domain, ]); // Handle delete request if (isset($_GET['option']) && $_GET['option'] == 'delete' && isset($_GET['hash']) && !empty($_GET['hash']) && current_user_can('manage_options')) { $hash = esc_attr($_GET['hash']); $this->get_logger()->debug('Delete request received for hash: ' . $hash, [ 'plugin' => $this->domain, 'hash' => $hash, ]); $CleanUp = new CleanUp($this->get_logger()); if ($CleanUp->deleteByHash($hash)) { $this->get_logger()->notice('Successfully deleted DOI with hash: ' . $hash . '. Redirecting.', [ 'plugin' => $this->domain, ]); wp_redirect('admin.php?page=f12-cf7-doubleoptin&status=deleted'); wp_die(); } else { $this->get_logger()->error('Failed to delete DOI with hash: ' . $hash . '. Redirecting.', [ 'plugin' => $this->domain, ]); wp_redirect('admin.php?page=f12-cf7-doubleoptin&status=error'); wp_die(); } // Handle status message display after a redirect } else if (isset($_GET['status'])) { $status = sanitize_text_field($_GET['status']); $this->get_logger()->info('Processing status message from URL: ' . $status, [ 'plugin' => $this->domain, ]); if ($status == 'deleted') { Messages::getInstance()->add(__('The given DOI has been removed.', 'double-opt-in'), 'success'); $this->get_logger()->notice('Added "DOI deleted" success message.', [ 'plugin' => $this->domain, ]); } if ($status == 'error') { Messages::getInstance()->add(__('Couldn\'t delete the DOI, please try again later.', 'double-opt-in'), 'error'); $this->get_logger()->error('Added "DOI deletion failed" error message.', [ 'plugin' => $this->domain, ]); } } } public function theContent($slug, $page, $settings) { $this->get_logger()->info('Rendering the main content for the Dashboard UI page.', [ 'plugin' => $this->domain, 'page_slug' => $page, ]); // Check for and handle a deletion request. // The maybeDelete() method will handle logging, nonce checks, and redirection on its own. $this->maybeDelete(); // Render the latest Opt-Ins table. // The renderLatestOptIns() method is responsible for fetching data and rendering the HTML table. $this->get_logger()->info('Calling renderLatestOptIns() to display the latest entries.', [ 'plugin' => $this->domain, ]); $this->renderLatestOptIns($slug, $page); $this->get_logger()->notice('Dashboard content rendering completed successfully.', [ 'plugin' => $this->domain, ]); } private function renderLatestOptins($slug, $page) { $this->get_logger()->info('Rendering the latest Opt-Ins table for the Dashboard UI page.', [ 'plugin' => $this->domain, 'page_slug' => $page, ]); $atts = array( 'perPage' => 10, 'page' => 1, 'order' => 'DESC', 'keyword' => '' ); // Set pagination and search attributes from URL parameters. if(isset($_GET['perPage'])){ $atts['perPage'] = (int)$_GET['perPage']; $this->get_logger()->debug('perPage attribute set from URL: ' . $atts['perPage'], [ 'plugin' => $this->domain, ]); } if (isset($_GET['pageNum'])) { $atts['page'] = (int)$_GET['pageNum']; $this->get_logger()->debug('pageNum attribute set from URL: ' . $atts['page'], [ 'plugin' => $this->domain, ]); } if(isset($_GET['keyword'])){ $atts['keyword'] = sanitize_text_field($_GET['keyword']); $this->get_logger()->debug('keyword attribute set from URL: ' . $atts['keyword'], [ 'plugin' => $this->domain, ]); } if(isset($_GET['cf_form_id'])){ $atts['cf_form_id'] = (int)$_GET['cf_form_id']; $this->get_logger()->debug('cf_form_id attribute set from URL: ' . $atts['cf_form_id'], [ 'plugin' => $this->domain, ]); } $numberOfPages = 0; $this->get_logger()->info('Fetching a list of Opt-Ins from the database.', [ 'plugin' => $this->domain, 'query_atts' => $atts, ]); // Fetch the list of opt-ins based on the attributes. $listOfOptIns = OptIn::get_list($atts, $numberOfPages); $this->get_logger()->notice('Found ' . count($listOfOptIns) . ' Opt-Ins across ' . $numberOfPages . ' pages.', [ 'plugin' => $this->domain, ]); /* * Render the Template */ ?>

get_logger()->info('Rendering the "list-optins" template.', [ 'plugin' => $this->domain, ]); // Render the list-optins template with the fetched data. $this->TemplateHandler->renderTemplate('list-optins', array( 'domain' => $this->domain, 'listOfOptIns' => $listOfOptIns, 'numberOfPages' => $numberOfPages, 'currentPage' => $atts['page'], 'slug' => $slug )); $this->get_logger()->notice('Finished rendering the latest Opt-Ins content.', [ 'plugin' => $this->domain, ]); } public function theSidebar($slug, $page) { $this->get_logger()->info('Rendering the sidebar content for the Dashboard UI page.', [ 'plugin' => $this->domain, 'page_slug' => $page, ]); ?>

add_action('f12_cf7_doubleoptin_already_confirmed', $hash, $OptIn)

add_action('f12_cf7_doubleoptin_before_confirm', $hash, $OptIn)

add_action('f12_cf7_doubleoptin_after_confirm', $hash, $OptIn)

get_logger()->notice('Dashboard sidebar content rendered successfully.', [ 'plugin' => $this->domain, ]); } } }