Programmatically add a custom page/path/url/route to WordPress

The idea is just to programmatically create a path/url in a plugin for a WordPress site (like, “[mysite]/mypath”), and then load an arbitrary html or php file. In case anyone else is looking for something similar, this works for me (in my main plugin function file): register_activation_hook(__FILE__, ‘myplugin_activate’); function myplugin_activate () { create_custom_page(‘mytestpath’); } function … Read more

Virtual Pages plugins

I’m the author of that plugin and I can confirm there was an issue. It was in the GM\VirtualPages\TemplateLoader::init(); method. Issue was caused by an untested switch from array_merge to wp_parse_args. They are similar, but I would have to inverse order of arguments moving from one to the other. Shame on me. I fixed that … Read more

trying to modify colormag-fr_FR.po

Just modifying the .po file doesn’t do anything. The .po is the template. To be displayed, the .po must be compiled into an .mo file and it is the compiled .mo that makes the translations. If you’re just editing the .po in a text editor, you’re not changing anything. You’ll need a compiler. A good … Read more

WordPress Network Feature

What you describe it pretty much exactly the use-case for WordPress Multisite (formerly WPMU.) The downsides are of course that all sites are dependent on the same code and the same database so if you break one you break them all (though most of the tables are different for each site.) Of course the upside … Read more

Error upgrading from 2.9.2 to 3.0.1

I also used SVN before to update my wordpress installation. Up the working copied will get messed up very quickly with all the manual updates or files created by plugins. I would always recommend to use the update functionality of wordpress if you only want to step from one tagged version to another one. Although, … Read more

Schedule cron event from widget

wp_schedule_event takes a hook as parameter, not a function. Try: wp_schedule_event(time(), ‘daily’, ‘my_daily_event’); add_action(‘my_daily_event’, array(&$this, ‘my_widget_cron’)); if ( !wp_next_scheduled( ‘my_daily_event’ ) ) { wp_schedule_event(time(), ‘hourly’, ‘my_daily_event’) } If you remove the widget from the sidebar, the cron will still continue to run. You can run the following code (outside of the widget class) to clear … Read more

Best way to pass arguments to another page in WordPress

Use add_query_arg() to do this. Here’s a useful function if you need to get the current page URL (when get_permalink is inaccesible, like on Archives): function get_current_page_url() { $request = esc_url($_SERVER[“REQUEST_URI”]); $pageURL = (is_ssl() ? ‘https’ : ‘http’).’://’; if ($_SERVER[“SERVER_PORT”] != “80”) $pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$request; else $pageURL .= $_SERVER[“SERVER_NAME”].$request; if (false === strpos(get_option(‘home’), ‘://www.’)) $pageURL … Read more

sanitize attachment filename

Following on from question comments. You can run a filter on sanitize_file_name_chars and add the degree symbol to the array of invalid chars, but it won’t halt the upload it will simply strip the file extension. However you can add another filter stop the upload, in a hacky kind of way by additionally hooking on … Read more