Register/login user with WordPress JSON API

1.Paste Following code in your themes function.php file. 2.Make sure that WP-REST-API plugin Should be installed on wordpress site add_action( ‘rest_api_init’, ‘register_api_hooks’ ); function register_api_hooks() { register_rest_route( ‘custom-plugin’, ‘/login/’, array( ‘methods’ => ‘POST’, ‘callback’ => ‘login’, ) ); } function login($request){ $creds = array(); $creds[‘user_login’] = $request[“username”]; $creds[‘user_password’] = $request[“password”]; $creds[‘remember’] = true; $user = … Read more

Woocommerce get variation product price

Here is the code you are looking for add_filter( ‘woocommerce_variation_option_name’, ‘display_price_in_variation_option_name’ ); function display_price_in_variation_option_name( $term ) { global $wpdb, $product; if ( empty( $term ) ) return $term; if ( empty( $product->id ) ) return $term; $id = $product->get_id(); $result = $wpdb->get_col( “SELECT slug FROM {$wpdb->prefix}terms WHERE name=”$term”” ); $term_slug = ( !empty( $result ) … Read more

dynamic class names in php

This should work to instantiate a class with a string variable value: $type=”Checkbox”; $field = new $type(); echo get_class($field); // Output: Checkbox So your code should work I’d imagine. What is your question again? If you want to make a class that includes all extended classes then that is not possible. That’s not how classes … Read more