One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
export const maskString = ( | |
value: any, | |
mask: string, | |
maskPatterns: Record<string, RegExp | ((char: string) => boolean)> | |
) => { | |
value = value || ''; | |
mask = mask || ''; | |
maskPatterns = maskPatterns || {}; | |
let maskedValue = ''; |
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
<?php | |
/* | |
* Plugin Name: Paulund WP List Table Example | |
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area | |
* Plugin URI: http://www.paulund.co.uk | |
* Author: Paul Underwood | |
* Author URI: http://www.paulund.co.uk | |
* Version: 1.0 | |
* License: GPL2 | |
*/ |
<?php | |
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) { | |
$phpmailer->SMTPOptions = array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
); |
function GetMultiCellHeight($w, $h, $txt, $border=null, $align='J') { | |
// Calculate MultiCell with automatic or explicit line breaks height | |
// $border is un-used, but I kept it in the parameters to keep the call | |
// to this function consistent with MultiCell() | |
$cw = &$this->CurrentFont['cw']; | |
if($w==0) | |
$w = $this->w-$this->rMargin-$this->x; | |
$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; | |
$s = str_replace("\r",'',$txt); | |
$nb = strlen($s); |
<?php | |
//Simple Ajax Login Form | |
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/ | |
?> | |
//html | |
<form id="login" action="login" method="post"> | |
<h1>Site Login</h1> | |
<p class="status"></p> | |
<label for="username">Username</label> |
<?php | |
/** | |
* NOTE: This gist is very old. You might want to check out recent forks | |
* like this one: https://github.com/Alexlytle/Wordpress_custom_route/blob/main/Wordpress_Custom_route.php | |
* (thanks @Alexlytle) If you have an improvement to this gist, please | |
* post a link in a comment for others who might benefit. Thanks! | |
* | |
* A class to create simple custom routes. | |
* |
<?php | |
/** | |
* Automatically login a single WordPress user upon arrival to a specific page. | |
* | |
* Redirect to home page once logged in and prevent viewing of the login page. | |
* Compatible with WordPress 3.9.1+ | |
* Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead." | |
* Updated 2019-07-09 to reformat code, pass 2nd parameter to `do_action()`, and hook into priority 1. | |
* |