How to pass custom options from widget form to widget update callback?

Not sure if you’re still struggling with this, but for anyone that is, here’s the solution: Add the following arguments to wse_widget_context_form(): $widget, $return and $instance Then use the following to get field IDs and field names: <?php echo $widget->get_field_id(‘field_name’); ?> and <?php echo $widget->get_field_name(‘field_name’); ?> respectively. e.g. <li><label><input value=”on” type=”checkbox” name=”<?php echo $widget->get_field_name(‘noHome’); ?>” … Read more

How can I find the ‘public absolute’ path of a file?

Assuming your resource is included in your Plugin: plugins_url() is the URL to \wp-content\plugins\ (Codex ref) So if you have a .js file in \wp-content\plugins\plugin-slug\file.js: <?php echo plugins_url() . ‘\plugin-slug\file.js’; ?> BUT WAIT!! If your purpose is actually to load a javascript file, you actually want to enqueue that file, using wp_enqueue_script(), hooked into the … Read more

Why is the reset password key missing in the reset password email?

The site’s original developer was using the reset_password_message filter and had either done it incorrectly or the core code has changed. The following function now works: function reset_password_message( $message, $key ) { if ( strpos($_POST[‘user_login’], ‘@’) ) { $user_data = get_user_by(’email’, trim($_POST[‘user_login’])); } else { $login = trim($_POST[‘user_login’]); $user_data = get_user_by(‘login’, $login); } $user_login = … Read more

Create a new page in a plugin

I managed to do it, not perfect but it works… add_action(‘template_redirect’, ‘my_template’); function my_template(){ global $post; if( get_post_type($post->ID) == ‘courses’){ include(ABSPATH. ‘wp-content/plugins/courses/single-course.php’); } And the file the include points to is my new template file in the plugin.