Empty Pdf file generated with FPDF library in WordPress plugin [closed]

This might not solve the problem, but what you’re currently doing looks unnecessarily convoluted (ajax request, fake link, serve PDF via link click etc.) Why not just a link styled as a button… <a class=”button” href=”<?= admin_url( ‘admin-post.php?action=wpse_212972_pdf’ ) ?>”>Download</a> …and then serve the PDF as a download directly from the server (using WP’s generic … Read more

Translate javascript with WordPress built-in localization API for static strings

wp_localize_script() defines a variable in the global JS scope – in the case of your code, the object is placed in a globally-scoped variable with the identifier MediaFolders. In your load event callback you are also defining a variable with the identifier MediaFolders scoped to it’s encapsulating function body – so when you use the … Read more

Using Product variations as product addons

Discussions on WooCommerce is off-topic here, but can’t resist myself answering. I faced a similar issue couple of months back and my solution was something like this. Remove the default add to cart form and variation choices in single variable product page. You can use JS or modify the template. Add custom form with checkboxes … Read more

Is there a plugin for automatically adding a word or symbol after a trigger word? I.e. Like a search and replace but more like search and add? [closed]

This would run a find-and-replace on displaying the title and content field: function wpse_406537_search_replace( $content ) { $company_name=”The Company”; $company_name_regex = preg_quote( $company_name, “https://wordpress.stackexchange.com/” ); // Best-guess attempt at replacing company name that doesn’t yet have ™️ // e.g. The Company[space] // e.g. The Company. // e.g. The Company, // e.g. The Company[end of string] … Read more

Create page (not the post type) dynamically

You need to register a ‘rewrite endpoint’ using add_rewrite_endpoint(): <?php add_action( ‘init’, function() { add_rewrite_endpoint( ‘play’, EP_PERMALINK ); } ); Now, after flushing permalinks, in whatever template or code you’re using for your products you can check this to determine whether the /play version of the URL is being accessed: <?php if ( false !== … Read more