Skip to content

Instantly share code, notes, and snippets.

@malcalevak
malcalevak / accessible-login-screen.markdown
Created February 16, 2018 18:49
Accessible Login Screen

Accessible Login Screen

This is literally just an incredibly basic login form, designed to be WCAG 2.0 AA compliant.

A Pen by Greg on CodePen.

License.

@malcalevak
malcalevak / set-default-post-category.php
Created September 5, 2017 20:40
WordPress: Set default category for a new post using links
function set_category () {
global $post;
//Check for a category parameter in our URL, and sanitize it as a string
$category_slug = filter_input(INPUT_GET, 'category', FILTER_SANITIZE_STRING, array("options" => array("default" => 0)));
//If we've got a category by that name, set the post terms for it
if ( $category = get_category_by_slug($category_slug) ) {
wp_set_post_terms( $post->ID, array($category->term_id), 'category' );
}
<?php
/*
Plugin Name: MailPoet wp_mail() Enabler
Plugin URI: https://gist.github.com/malcalevak/5ac02aa144fa1837d55bc8aeea39aeef/
Description: Enables the ability to use wp_mail() in the MailPoet plugin. Notes: Requires MailPoet v2.6.14+, which added the mailpoet_pre_config_screen action hook. It also appears this is likely to break after the release of v3. Lastly, the MailPoet code doesn't set $header, which is passed to wp_mail; as a result, you'll need to set your 'Content-type:text/html' in your header some other way (Postman SMTP has a Custom Headers field for this purpose, alternatively, you can do it more universally via the answer here: https://wordpress.stackexchange.com/questions/27856/is-there-a-way-to-send-html-formatted-emails-with-wordpress-wp-mail-function)
Version: 1.0
License: GPL-2.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/