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
if(window.TouchEvent) { | |
document.addEventListener('touchmove', (event) => { | |
if(event.scale !== 1) { | |
event.preventDefault(); | |
} | |
}, false); | |
} |
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
//Given this HTML, here are the ways to add click events | |
<button id="specialButton">Click Here</button> | |
//traditional plain JS way | |
document.getElementById('specialButton').addEventListener('click', function(){ | |
alert('button clicked!'); | |
}); | |
//-------------------------------------- |
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 | |
######################################################## | |
### CONFIG ### | |
######################################################## | |
const YOUR_EMAIL = '[email protected]'; | |
//define a math problem as a field in your form to prevent spam; | |
//or use a word problem with a string as the answer, but be careful since the case and spelling of the user's answer will need to be exact | |
const ANSWER = 5; | |
######################################################## |
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 | |
/** | |
* Plugin Name: Name | |
* Plugin URI: http:// | |
* Description: Description | |
* Version: 1.0.0 | |
* Author: Name | |
* Author URI: http:// | |
* License: GPL-2.0+ | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
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
sudo chown -R www-data:www-data . | |
sudo find . -type f -exec chmod 664 {} + | |
sudo find . -type d -exec chmod 775 {} + | |
sudo chmod 660 wp-config.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
//Note: requires the Basic Auth plugin | |
$username = 'username'; | |
$password = 'password'; | |
$args = array( | |
'headers' => array( | |
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password ), | |
), | |
); | |
$queryFilters = 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
//requires authentication | |
add_filter('json_query_vars','accept_new_queries'); | |
add_filter('json_query_var-tax_query', 'filter_by_taxonomy'); | |
function accept_new_queries($filters){ | |
return array_merge($filters,array('tax_query')); | |
} | |
function filter_by_taxonomy($val){ |
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 wp_api_encode_acf($data,$post,$context){ | |
$data['meta'] = array_merge($data['meta'],get_fields($post['ID'])); | |
return $data; | |
} | |
if( function_exists('get_fields') ){ | |
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3); | |
} |
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 random_lipsum($amount = 1, $what = 'paras') { | |
$start = rand(0,30); | |
return simplexml_load_file("http://www.lipsum.com/feed/xml?amount=$amount&what=$what&start=$start")->lipsum; | |
} |
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
String.prototype.capitalize = function() { | |
return this.charAt(0).toUpperCase() + this.slice(1); | |
} |
NewerOlder