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
//defining a normal property o.x using getters and setters | |
var o = { | |
c: 1, | |
get x() { return this.c; }, | |
set x(y) { this.c = y; } | |
} | |
o.x; //1 | |
o.x = 3; | |
o.x; //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
//Defining a restricted access property o.x using getters and setters | |
var o = { | |
c: 0, | |
get x() { return this.c; }, | |
set x(y) { this.c = Math.max(y,0); } | |
} | |
o.x = 3; | |
o.x; //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
//defining a pseudo-private property o.x using getters and setters | |
var o = { | |
__c: 1, | |
get x() { return this.__c; }, | |
set x(y) { this.__c = y; } | |
} | |
//Make the property o.__c non-enumerable | |
Object.defineProperty(o, '__c', { enumerable: 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
lowercase_letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | |
uppercase_letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | |
letter = lowercase_letter | uppercase_letter | |
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | |
alphanumeric = letter | digit | |
lowercase_alphanumeric = lowercase_letter | digit | |
hyphen = "-" | "_" | |
lowercase_word = lowercase_alphanumeric { lowercase_alphanumeric } |
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 | |
echo "Running full GET requests... \n"; | |
$sum = 0; | |
for( $i = 1; $i <= 100; ++$i ) { | |
$start = microtime(true); |
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 get_remote_data( $slug ) { | |
$key = 'some-key-string'; | |
if( !wp_cache_get( $key ) ) { | |
$response = wp_remote_get( $url ); | |
//error handling |
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 | |
is_numeric( $var ); //http://php.net/manual/de/function.is-numeric.php | |
is_array( $var ); //http://php.net/manual/de/function.is-array.php | |
is_object( $var ); //http://php.net/manual/de/function.is-object.php | |
is_string( $var ); //http://php.net/manual/de/function.is-string.php | |
isset( $data['key'] ); //http://php.net/manual/de/function.isset.php | |
in_array( $var, $arr ); //http://php.net/manual/de/function.is-array.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
<?php | |
sanitize_text_field( $str ); //https://developer.wordpress.org/reference/functions/sanitize_text_field/ | |
sanitize_title( $str ); //https://developer.wordpress.org/reference/functions/sanitize_title/ | |
sanitize_email( $str ); //https://developer.wordpress.org/reference/functions/sanitize_email/ | |
sanitize_file_name( $str ); //https://developer.wordpress.org/reference/functions/sanitize_file_name/ |
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 | |
esc_html( $str ); //https://developer.wordpress.org/reference/functions/esc_html/ | |
esc_attr( $str ); //https://developer.wordpress.org/reference/functions/esc_attr/ | |
esc_url( $str ); //https://developer.wordpress.org/reference/functions/esc_url/ | |
esc_js( $str ); //https://developer.wordpress.org/reference/functions/esc_js/ | |
esc_textarea( $str ); //https://developer.wordpress.org/reference/functions/esc_textarea/ |
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: Singleton Example | |
* Plugin URI: https://github.com/maurobringolf/wordpress-plugin-singleton | |
* Description: An empty illustration of a WordPress plugin implemented as singleton | |
* Author: Mauro Bringolf | |
* Author URI: https://maurobringolf.ch | |
* Version: 1.0 | |
* Text Domain: singleton | |
* Domain Path: languages |
OlderNewer