‘str_replace’ and ‘strtr’ not working inside plugin

Mark was correct that it was some other code causing the issue. I tracked it down to a plugin I use during testing: Insert PHP; https://wordpress.org/plugins/insert-php/ There’s a line in the plugin’s code that’s replacing forward slashes. Anyhow, I ran the same code I was trying yesterday via a shortcode, and everything works as expected.

How do I display entries in the top menu based on conditions selected in the sidebar menu?

If you have 3 templates, you can use the conditional check is_page_template to check which one is currently in use. See https://developer.wordpress.org/reference/functions/is_page_template/ Or if you weren’t talking about page templates, but rather a specific archive template, you can get the current term id with get_queried_object_id. See https://developer.wordpress.org/reference/functions/get_queried_object_id/ Then, you could register 3 different menu locations … Read more

Show Header When Not In Iframe

I solved this by adding the header php code, and the setting it with display none as below: #main-header { display:none; } Then using JQuery I added the following: <script> if(self==window.top) { $( “header#main-header” ).css( “display”, “inherit” ); $( “div#mce_height” ).css( “margin-top”, “100px” ); } </script> This detects if it is in an iframe, and … Read more

Build custom pdf from users choices

If you are looking for an industrial strength solution, you might consider AppendPDF by Appligent (and/or other products from them). As a command line application, it is very easy to integrate and to run. Alternatively, there are several libraries (such as iText, pdflib, etc.) which could be used to create such customized documents. Ah, yeah, … Read more

DOM reference to TinyMCE editor element (button)

Try adding an id attribute in your button definition: ed.addButton(‘solution’, { disabled: 0,//count_problems(ed).length == 0, id: ‘my_button’, title : ‘Add problem solution’, //cmd: ‘solution_fun’, image : url + ‘/images/wspringer.png’, type: ‘menubutton’, menu: [{text: ‘problem id = ‘ + 1, value: 1}], onselect: function(v1) { ed.windowManager.open({ title: ‘Insert solution in popeye output format’, body: [{type: ‘textbox’, … Read more

A delete/trash all function?

So I couldn’t find anything so I created this. The only drawback is that it will delete the ‘Uncategorized’ term in the Posts, but I can live with this since it’s just for development purpose. function delete_all(){ global $wpdb; $menus = get_terms( ‘nav_menu’, array( ‘hide_empty’ => false ) ); $all_post_types = get_post_types(); $all_taxonomies = get_taxonomies(); … Read more