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 | |
add_action('frm_after_create_entry', 'add_translation', 30, 2); | |
function add_translation($entry_id, $form_id) { | |
$forms = array( 64 ); // <---- change or add form ids here, comma separated, e.g. (24, 53, 64) | |
// check if form id is in array, if so run code | |
if( in_array($form_id, $forms) ) { | |
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 | |
/** | |
* Duplicates a post & its meta and it returns the new duplicated Post ID | |
* @param [int] $post_id The Post you want to clone | |
* @return [int] The duplicated Post ID | |
*/ | |
function duplicate($post_id) { | |
$title = get_the_title($post_id); | |
$oldpost = get_post($post_id); |
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
let sampleWord = "astronaut"; | |
let pwRegex = /(?=\w{5,})(?=\w+\d{2})/; // Change this line | |
let result = pwRegex.test(sampleWord); | |
// Your regex should use two positive lookaheads. | |
// Your regex should not match "astronaut" | |
// Your regex should not match "airplanes" | |
// Your regex should not match "banan1" | |
// Your regex should match "bana12" | |
// Your regex should match "abc123" |
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
let username = "JackOfAllTrades"; | |
let userCheck = /^[a-z][a-z]+\d*$/i; // Change this line | |
let result = userCheck.test(username); | |
// Your regex should match JACK | |
// Your regex should not match J | |
// Your regex should match Oceans11 | |
// Your regex should match RegexGuru | |
// Your regex should not match 007 | |
// Your regex should not match 9 |
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
//'foo_gallery_description' is the slug of the custom field. Second parameter is the current foogallery id. | |
<?php if(get_field('foo_gallery_description', $current_foogallery->ID)){ ?> | |
<div class="gallery-desc"> | |
<p><?php the_field('foo_gallery_description', $current_foogallery->ID); ?></p> | |
</div> | |
<?php } ?> |
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
function pairwise(arr, arg) { | |
//if its an empty array return 0 | |
if(arr.length === 0){ | |
return 0; | |
} | |
//reduce the array by looping over the array and checking if the | |
//sum of the current element and another element = the argument. | |
//if they match and the indexes of both are different, add the indexes to | |
//the output array. | |
var pairs = arr.reduce(function(accum, curr, index, array){ |
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
function orbitalPeriod(arr) { | |
var GM = 398600.4418; | |
var earthRadius = 6367.4447; | |
//create a function to calculate orbital period | |
function calcPeriod(avgAlt){ | |
var orbitalRadius = earthRadius + avgAlt; | |
//calculation is 2 multiplied by pi multiplied by the square root of the | |
//orbital radius to the power of 3 divided by the GM | |
var period = Math.round(2*Math.PI*(Math.sqrt(Math.pow(orbitalRadius,3)/GM))); | |
return period; |
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
var Person = function(firstAndLast) { | |
var arr = firstAndLast.split(' '); | |
var firstName = arr[0]; | |
var lastName = arr[1]; | |
// Complete the method below and implement the others similarly | |
this.getFullName = function() { | |
return firstName + ' ' + lastName; | |
}; | |
this.getFirstName = function() { |
NewerOlder