This article is inspired by Brad Cypert's blog post: http://www.bradcypert.com/building-a-simple-api-in-php-using-lumen/.
Why should we build a API with Vanilla PHP? Because you can, and it makes fun.
- Create a directory /src
<?php | |
/** | |
* Register custom rest fields | |
*/ | |
add_action( 'rest_api_init', 'register_custom_fields' ); | |
/** | |
* Register rest fields and endpoint | |
* |
"{"videos":[{"id":1,"name":"ES2015 Arrow Functions","description":"<p>ES2015 (aka ES6) has some great ways to make your code easier to write and understand. In this episode, we cover two different ways that you can make your code clearer by removing the 'function' keyword.</p>","thumbnail":"https://vue-screencasts.s3.us-east-2.amazonaws.com/images/video-thumbnails/Thumbnail+-+Arrow+Function.png","videoUrl":"https://vue-screencasts.s3.us-east-2.amazonaws.com/video-files/38-+es2015-+functions+minus+'function'.mp4"},{"id":2,"name":"ES2015 Template Strings","description":"<p>Template strings are an incredibly useful new feature in ES2015... and you can use them in your Ember apps today!</p>\n <p>Here are 3 cool things that template strings enable.</p>","thumbnail":"https://vue-screencasts.s3.us-east-2.amazonaws.com/images/video-thumbnails/Thumbnail+-+Template+Strings.png"},{"id":3,"name":"ES2015 Modules","description":"<p>Before modules, javascript code loading was a mess. Now it's pretty a |
<div>Coming Soon</div> |
// set a value | |
let a = "Earth is round"; | |
let x = 18; | |
// get a value | |
alert(a); // "Earth is round" | |
alert(x); // 18 |
if ( condition is true ) { | |
// do something | |
} else { | |
// do something else | |
} |
function print_my_name() { | |
// code to execure | |
console.log("Mahade"); | |
} | |
function multiply_by_two(your_number) { | |
// code to execure | |
console.log( your_number * 2 ); // multiply given number with two, then print in console | |
} |
let a = 10; // save 10 inside varialbe 'a' | |
let x = 0; // // save 0 inside varialbe 'x' | |
while(x < a) { // condition is - as long as value of 'x' is less than value of 'a', we will run the following code | |
console.log( x ); // print current value of 'x' to the console | |
x = x + 1 // then, add 1 to current value of 'x' | |
} | |
/* | |
That loop will run 11 times and print - |
add_action('woocommerce_process_registration_errors', 'validatePasswordReg', 10, 2 ); | |
function validatePasswordReg( $errors, $user ) { | |
// change value here to set minimum required password chars | |
if(strlen($_POST['password']) < 15 ) { | |
$errors->add( 'woocommerce_password_error', __( 'Password must be at least 15 characters long.' ) ); | |
} | |
// adding ability to set maximum allowed password chars -- uncomment the following two (2) lines to enable that | |
//elseif (strlen($_POST['password']) > 16 ) | |
//$errors->add( 'woocommerce_password_error', __( 'Password must be shorter than 16 characters.' ) ); |
This article is inspired by Brad Cypert's blog post: http://www.bradcypert.com/building-a-simple-api-in-php-using-lumen/.
Why should we build a API with Vanilla PHP? Because you can, and it makes fun.
"workbench.colorCustomizations": { | |
"badge.background": "#0c0c0c", | |
"menu.background": "#0c0c0c", | |
"sideBar.dropBackground": "#0c0c0c", | |
"sideBar.background": "#0c0c0c", | |
"sideBar.border": "#2a2a2a", | |
"editorGroupHeader.tabsBackground": "#0c0c0c", | |
"editorGroupHeader.noTabsBackground": "#0c0c0c", | |
"editor.background": "#0c0c0c", | |
"editorGroup.background": "#0c0c0c", |