'aa_pdf_reader_sanitize_options', ]); }); /** * Sanitize settings */ function aa_pdf_reader_sanitize_options($input) { $output = []; $output['theme'] = in_array($input['theme'] ?? '', ['light', 'dark']) ? $input['theme'] : 'light'; $output['default_height'] = absint($input['default_height'] ?? 800); $output['show_download'] = !empty($input['show_download']) ? 1 : 0; $output['show_share'] = !empty($input['show_share']) ? 1 : 0; $output['show_email'] = !empty($input['show_email']) ? 1 : 0; return $output; } /** * Admin Settings Page */ function aa_pdf_reader_settings_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.', 'aa-pdf-reader')); } $options = get_option('aa_pdf_reader_options'); $defaults = [ 'theme' => 'light', 'default_height' => 800, 'show_download' => 1, 'show_share' => 1, 'show_email' => 1, ]; $options = wp_parse_args($options, $defaults); ?>
[aa_pdf_reader link="https://example.com/file.pdf" height="800" theme="dark" download="yes" share="yes" email="yes" lazy="yes" password="1234" expire="2025-07-01"]
' . esc_html__('No PDF link provided.', 'aa-pdf-reader') . '
'; } if (!empty($a['password'])) { if ( !isset($_POST['aa_pdf_pass_nonce']) || !wp_verify_nonce($_POST['aa_pdf_pass_nonce'], 'aa_pdf_pass_action') || !isset($_POST['aa_pdf_pass']) || $_POST['aa_pdf_pass'] !== $a['password'] ) { ob_start(); ?> ' . esc_html__('This PDF is no longer available.', 'aa-pdf-reader') . ''; } $pdf_url = ($a['viewer'] === 'google') ? 'https://docs.google.com/gview?embedded=true&url=' . urlencode($a['link']) : $a['link']; ob_start(); ?>