About LearnWithWaqas

Welcome to LearnWithWaqas, your ultimate destination for mastering WordPress development! Whether you’re a beginner looking to take your first steps into the world of WordPress or an experienced developer seeking to enhance your skills, you’ve come to the right place.

At LearnWithWaqas, we understand the challenges that WordPress developers face. With the ever-evolving nature of technology, staying ahead of the curve can seem daunting. That’s why we’re here to simplify the learning process for you.

Our mission is to provide you with comprehensive, easy-to-follow guides that cover a wide range of WordPress topics. From setting up your first WordPress website to tackling advanced development techniques, we’ve got you covered every step of the way.

What sets LearnWithWaqas apart is our commitment to clarity and simplicity. We believe that learning should be accessible to everyone, regardless of their level of experience. That’s why our blog posts are crafted with the utmost care to ensure that even the most complex concepts are explained in a clear and straightforward manner.

Whether you prefer to learn through written tutorials, video guides, or interactive exercises, LearnWithWaqas has something for everyone. Our diverse range of content caters to various learning styles, ensuring that you can find the resources that work best for you.

As the founder of LearnWithWaqas, I bring years of experience in WordPress development to the table. Having faced my fair share of challenges and obstacles along the way, I understand the importance of having reliable resources at your disposal. That’s why I created LearnWithWaqas – to share my knowledge and expertise with fellow developers like you.

But LearnWithWaqas is more than just a website – it’s a community. A place where developers from all walks of life can come together to learn, grow, and support each other on their WordPress journey. Whether you’re looking for advice, inspiration, or just a friendly chat, you’ll find it here.

So, whether you’re a total beginner or a seasoned pro, I invite you to join us at LearnWithWaqas and take your WordPress skills to the next level. Together, we’ll unlock the full potential of WordPress and empower you to build the websites of your dreams. Let’s learn, grow, and succeed together!

Happy coding,

Waqas Munawer
Founder, LearnWithWaqas

function uploadTasks(tasksList) { // // Example tasks list to pass to the PHP function // const tasksList = [ // { // title: "Task 1", // priority: "high", // status: "open", // description: "Description for Task 1", // started_at: "2024-12-21 10:00:00", // due_at: "2024-12-23 18:00:00", // stage: "open" // }, // { // title: "Task 2", // priority: "low", // status: "open", // description: "Description for Task 2", // started_at: "2024-12-22 08:00:00", // due_at: "2024-12-25 17:00:00", // stage: "open" // } // ]; console.log("jSON data is " +JSON.stringify(tasksList)); // Prepare the form data for the AJAX request const formData = new FormData(); formData.append('action', 'create_tasks_in_fluentboard'); // Action name must match the PHP function's hook formData.append('tasks', JSON.stringify(tasksList)); // Pass tasks list as a JSON string // Send the AJAX request to the server fetch('/wp-admin/admin-ajax.php', { method: 'POST', body: formData }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log('Response:', data); // Log the response if (data.success) { console.log('Response success:' + data.data.message); // Display success message } else { console.log('Response error:' + data.data.message); // Display error message } }) .catch(error => { console.error('Fetch Error:', error); // Log fetch error }) .finally(() => { console.log('finally block is executed'); // Log fetch error }); } function pickFile() { const fileInput = document.createElement("input"); fileInput.type = "file"; // Trigger the file input click event fileInput.click(); // Listen for file selection fileInput.addEventListener("change", async () => { if (!fileInput.files || fileInput.files.length === 0) { window.alert("No file selected."); return; } const file = fileInput.files[0]; // Check if the file size is within the allowed limit (10MB) if (file.size > MAX_FILE_SIZE) { alert("File is too large. Maximum allowed size is 10MB."); return; } const fileType = file.type; if (fileType === "application/pdf") { extractedText = await processPDF(file); //window.alert("pdf file selected."); } else if ( fileType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { extractedText = await processDOCX(file); //window.alert("doc file selected."); } else if (fileType.startsWith("image/")) { extractedText = await processImage(file); //window.alert("image file selected."); } else { window.alert("Unsupported file type!"); } // You can now use extractedText for further processing console.log("Extracted Text is " + extractedText); }); } // Process PDF and return text as string async function processPDF(file) { const pdfjsLib = window["pdfjs-dist/build/pdf"]; const reader = new FileReader(); return new Promise((resolve, reject) => { reader.onload = async function (e) { try { const pdfData = new Uint8Array(e.target.result); const pdf = await pdfjsLib.getDocument({ data: pdfData }).promise; let extractedText = ""; for (let i = 1; i <= pdf.numPages; i++) { const page = await pdf.getPage(i); const textContent = await page.getTextContent(); const pageText = textContent.items.map((item) => item.str).join(" "); extractedText += `${pageText}\n`; } // Clean the extracted text const cleanedText = cleanPDFText(extractedText); resolve(cleanedText); } catch (error) { console.error("Error processing PDF:", error); reject("Failed to extract text from the PDF."); } }; reader.readAsArrayBuffer(file); }); } // Function to clean extracted PDF text function cleanPDFText(text) { // Remove unnecessary line breaks and normalize spaces let cleanedText = text .replace(/Page \d+ of \d+/g, "") // Remove page numbers .replace(/© \d{4} − \d{4}[\s\S]*?Save My Exams, Ltd\./g, "") // Remove copyright footer .replace(/\s+/g, " ") // Replace multiple spaces with a single space .trim(); // Trim leading and trailing spaces // Additional cleaning logic (e.g., remove headers/footers, adjust formatting) can go here return cleanedText; } // Process DOCX and return text as string async function processDOCX(file) { const reader = new FileReader(); return new Promise((resolve, reject) => { reader.onload = async function (e) { const arrayBuffer = e.target.result; const result = await window.mammoth.extractRawText({ arrayBuffer }); resolve(result.value); // Return the extracted text }; reader.readAsArrayBuffer(file); }); } // Process Image using Tesseract.js and return extracted text as string async function processImage(file) { const reader = new FileReader(); return new Promise((resolve, reject) => { reader.onload = async function (e) { const imgDataURL = e.target.result; // Run OCR using Tesseract.js to extract text try { const { data: { text } } = await Tesseract.recognize( imgDataURL, // Image data 'eng' // Language code for English // { // logger: (info) => console.log(info), // Log progress // } ); resolve(text); // Return the extracted text } catch (error) { console.error("Error during OCR:", error); reject("Failed to extract text from the image."); } }; reader.readAsDataURL(file); }); }