This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Function to import image from URL to WordPress media library and assign to a post | |
@params | |
$post_id - The post ID for which you need to assign the uploaded image as featured image | |
$image_url - The external image URL which needs to be imported to WordPress media library | |
*/ | |
function import_featured_image_from_url( $post_id = '', $image_url ='' ) { | |
//Check both post_id and image_url is not empty | |
if($post_id == '' || $image_url == '') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Formidable forms hook to validate form entries dynamically */ | |
add_filter('frm_validate_field_entry', 'validate_user_credentials', 10, 3); | |
function validate_user_credentials( $errors, $field, $posted_value ){ | |
if ( $field->id == 11 ) { | |
/* Check if user entered username already exists. If yes then we show an error message */ | |
if ( username_exists( $posted_value ) ) { | |
//Error message if username already exists | |
$errors['field' . $field->id] = 'Username "'.$posted_value.'" already exists. Please try a different username.'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Google2FA { | |
const keyRegeneration = 30; // Interval between key regeneration | |
const otpLength = 6; // Length of the Token generated | |
private static $lut = array( // Lookup needed for Base32 encoding | |
"A" => 0, "B" => 1, | |
"C" => 2, "D" => 3, | |
"E" => 4, "F" => 5, | |
"G" => 6, "H" => 7, |