PATH:
home
/
letacommog
/
rdvenunclick.fr1
/
wp-content
/
plugins
/
ultimate-faqs
/
Functions
<?php function EWD_UFAQ_Export_To_PDF() { // make sure that the request is coming from the admin form if ( ! isset( $_POST['EWD_UFAQ_Export_PDF_Nonce'] ) ) { return; } if ( ! wp_verify_nonce( $_POST['EWD_UFAQ_Export_PDF_Nonce'], 'EWD_UFAQ_Export_PDF' ) ) { return; } require_once(EWD_UFAQ_CD_PLUGIN_PATH . '/FPDF/fpdf.php'); global $Category; /*Undefined Category variable at line 5 and 7*/ // if ($Category != "EWD_UFAQ_ALL_CATEGORIES") {$category_array = array( 'taxonomy' => 'ufaq-category', // 'field' => 'slug', // 'terms' => $Category->slug // ); // // } $params = array( 'posts_per_page' => -1, 'post_type' => 'ufaq' ); $faqs = get_posts($params); $PDFPasses = array("FirstPageRun", "SecondPageRun", "Final"); foreach ($PDFPasses as $PDFRun) { $pdf = new FPDF(); $pdf->AddPage(); if ($PDFRun == "SecondPageRun" or $PDFRun == "Final") { $pdf->SetFont('Arial','B',14); $pdf->Cell(20, 10, "Page #"); $pdf->Cell(20, 10, "Article Title"); $pdf->Ln(); $pdf->SetFont('Arial','',12); foreach ($ToC as $entry) { $pdf->Cell(20, 5, " " . $entry['page']); $pdf->MultiCell(0, 5, $entry['title']); $pdf->Ln(); } unset($ToC); } foreach ($faqs as $faq) { $PostTitle = utf8_decode(strip_tags(html_entity_decode($faq->post_title))); $PostText = utf8_decode(strip_tags(html_entity_decode($faq->post_content))); $PostText = str_replace("[", "[", $PostText); $PostText = str_replace("]", "]", $PostText); $pdf->AddPage(); $Entry['page'] = $pdf->GetPage(); $Entry['title'] = $PostTitle; $pdf->SetFont('Arial','B',15); $pdf->MultiCell(0, 10, $PostTitle); $pdf->Ln(); $pdf->SetFont('Arial','',12); $pdf->MultiCell(0, 10, $PostText); $ToC[] = $Entry; unset($Entry); } if ($PDFRun == "FirstPageRun" or $PDFRun == "SecondPageRun") { $pdf->Close(); } if ($PDFRun == "Final") { $pdf->Output('Ultimate-FAQ-Manual.pdf', 'D'); } } } if (!class_exists('ComposerAutoloaderInit4618f5c41cf5e27cc7908556f031e4d4')) {require_once EWD_UFAQ_CD_PLUGIN_PATH . 'PHPSpreadsheet/vendor/autoload.php';} use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xls; use PhpOffice\PhpSpreadsheet\Writer\Csv; function EWD_UFAQ_Export_To_Excel() { // make sure that the request is coming from the admin form if ( ! isset( $_POST['EWD_UFAQ_Export_Nonce'] ) ) { return; } if ( ! wp_verify_nonce( $_POST['EWD_UFAQ_Export_Nonce'], 'EWD_UFAQ_Export' ) ) { return; } $FAQ_Fields_Array = get_option("EWD_UFAQ_FAQ_Fields"); if (!is_array($FAQ_Fields_Array)) {$FAQ_Fields_Array = array();} // Instantiate a new PHPExcel object $Spreadsheet = new Spreadsheet(); // Set the active Excel worksheet to sheet 0 $Spreadsheet->setActiveSheetIndex(0); // Print out the regular order field labels $Spreadsheet->getActiveSheet()->setCellValue("A1", "ID"); $Spreadsheet->getActiveSheet()->setCellValue("B1", "Question"); $Spreadsheet->getActiveSheet()->setCellValue("C1", "Answer"); $Spreadsheet->getActiveSheet()->setCellValue("D1", "Categories"); $Spreadsheet->getActiveSheet()->setCellValue("E1", "Tags"); $Spreadsheet->getActiveSheet()->setCellValue("F1", "Post Date"); $column = 'G'; foreach ($FAQ_Fields_Array as $FAQ_Field_Item) { $Spreadsheet->getActiveSheet()->setCellValue($column."1", $FAQ_Field_Item['FieldName']); $column++; } //start while loop to get data $rowCount = 2; $params = array( 'posts_per_page' => -1, 'post_type' => 'ufaq' ); $Posts = get_posts($params); foreach ($Posts as $Post) { $Categories = get_the_terms($Post->ID, "ufaq-category"); $Category_String = ''; if (is_array($Categories)) { foreach ($Categories as $Category) { $Category_String .= $Category->name . ","; } $Category_String = substr($Category_String, 0, -1); } else {$Category_String = "";} $Tags = get_the_terms($Post->ID, "ufaq-tag"); $Tag_String = ''; if (is_array($Tags)) { foreach ($Tags as $Tag) { $Tag_String .= $Tag->name . ","; } $Tag_String = substr($Tag_String, 0, -1); } else {$Tag_String = "";} $Spreadsheet->getActiveSheet()->setCellValue("A" . $rowCount, $Post->ID); $Spreadsheet->getActiveSheet()->setCellValue("B" . $rowCount, $Post->post_title); $Spreadsheet->getActiveSheet()->setCellValue("C" . $rowCount, $Post->post_content); $Spreadsheet->getActiveSheet()->setCellValue("D" . $rowCount, $Category_String); $Spreadsheet->getActiveSheet()->setCellValue("E" . $rowCount, $Tag_String); $Spreadsheet->getActiveSheet()->setCellValue("F" . $rowCount, $Post->post_date); $column = 'G'; foreach ($FAQ_Fields_Array as $FAQ_Field_Item) { $Value = get_post_meta($Post->ID, "Custom_Field_" . $FAQ_Field_Item['FieldID'], true); $Spreadsheet->getActiveSheet()->setCellValue($column . $rowCount, $Value); $column++; } $rowCount++; unset($Category_String); unset($Tag_String); } // Redirect output to a client’s web browser (Excel5) if (!isset($Format_Type) == "CSV") { header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="FAQ_Export.csv"'); header('Cache-Control: max-age=0'); $objWriter = new Csv($Spreadsheet); $objWriter->save('php://output'); die(); } else {echo 'Printing spreadsheet<br><br><br><br>'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="FAQ_Export.xls"'); header('Cache-Control: max-age=0'); $objWriter = new Xls($Spreadsheet); $objWriter->save('php://output'); die(); } } ?>
[+]
..
[-] EWD_UFAQ_Upgrade_Box.php
[edit]
[-] EWD_UFAQ_Output_Options_Page.php
[edit]
[-] EWD_UFAQ_Add_Views_Column.php
[edit]
[-] EWD_UFAQ_WooCommerce_Tab.php
[edit]
[-] EWD_UFAQ_Pointers_Manager_Interface.php
[edit]
[-] EWD_UFAQ_Output_Statistics_Page.php
[edit]
[-] EWD_UFAQ_WPForms_Integration.php
[edit]
[-] Update_EWD_UFAQ_Content.php
[edit]
[-] EWD_UFAQ_Pointers_Manager_Class.php
[edit]
[-] EWD_UFAQ_Import.php
[edit]
[-] EWD_UFAQ_Create_Captcha_Image.php
[edit]
[-] EWD_UFAQ_Submit_Question.php
[edit]
[-] EWD_UFAQ_Rewrite_Rules.php
[edit]
[-] EWD_UFAQ_Initial_Data.php
[edit]
[-] EWD_UFAQ_Widgets.php
[edit]
[-] Process_Ajax.php
[edit]
[-] EWD_UFAQ_Export_To_PDF.php
[edit]
[-] Error_Notices.php
[edit]
[-] EWD_UFAQ_Output_Pages.php
[edit]
[-] EWD_UFAQ_Styling.php
[edit]
[-] Update_Admin_Databases.php
[edit]
[-] EWD_UFAQ_Deactivation_Survey.php
[edit]
[-] EWD_UFAQ_Admin_Image_Upload.php
[edit]
[-] EWD_UFAQ_Add_Social_Media_Buttons.php
[edit]
[-] EWD_UFAQ_Output_Import_Page.php
[edit]
[-] EWD_UFAQ_Export.php
[edit]
[-] FrontEndAjaxUrl.php
[edit]
[-] EWD_UFAQ_Help_Pointers.php
[edit]
[-] Register_EWD_UFAQ_Posts_Taxonomies.php
[edit]
[-] EWD_UFAQ_Meta_Boxes.php
[edit]
[-] EWD_UFAQ_Output_Export_Page.php
[edit]
[-] EWD_UFAQ_Version_Update.php
[edit]
[-] EWD_UFAQ_Captcha.php
[edit]