WP REST API V2 – Add user data to response

Solution A – Prepare User Response You can filter the response for a user to include any property you want with rest_prepare_user. add_filter( ‘rest_prepare_user’, function( $response, $user, $request ) { $response->data[ ‘first_name’ ] = get_user_meta( $user->ID, ‘first_name’, true ); $response->data[ ‘last_name’ ] = get_user_meta( $user->ID, ‘last_name’, true ); return $response; }, 10, 3 ); Solution … Read more

Plugin not appearing after uploading it via FTP

Does the Plugin work on localhost? Was it corrected created? The main PHP file of the plugin must have the same name of the folder and the main PHP file must have the following before everything: <?php /* Plugin Name: WordPress.org Plugin Plugin URI: https://developer.wordpress.org/plugins/the-basics/ Description: Basic WordPress Plugin Header Comment Version: 20160911 Author: WordPress.org … Read more

Global matrix for shortcodes/content for every page

You should insert the following code in functions.php of your theme. /* Global matrix for shortcodes/content for every page */ $locations = array( array( ‘location’ => ‘location 1’, ‘telephone’ => ‘0121 34838383′, ’email’ => ‘[email protected]’ ), array( ‘location’ => ‘location 2’, ‘telephone’ => ‘92939393’, ’email’ => ‘[email protected]’ ), array( ‘location’ => ‘location 3’, ‘telephone’ => … Read more

How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)

There are several ways to achieve this. Using get_the_terms: $args = array( ‘post_type’ => ‘movies’, ‘posts_per_page’ => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title(); $terms = get_the_terms( get_the_ID(), ‘genre’ ); if ( is_array( $terms ) ) { //Manipulate array of WP_Term objects } ?> <div … Read more

WordPress not working on localhost

1) Make sure the wp-config.php doesn’t have multisite reference settings such as define(“DOMAIN_CURRENT_SITE”, “somesite.com” );. If it does, delete these settings 2) If you have updated siteurl and home settings in the *_options table to use local settings and it still doesn’t work, then 3) Delete all themes but a basic one (twentytwelve, twentythirteen,…) and … Read more

How plugins_loaded works?

Use your class definition in a separate file, say in /your-plugin-dir/classes/my-gateway.php like usual: <?php class my_gateway extends WC_Payment_Gateways { //code } ?> Then use this CODE to include the file on plugins_loaded action from your main plugin file: add_action(‘plugins_loaded’, ‘WC_test_gateway_plugin’); function WC_test_gateway_plugin() { require_once plugin_dir_path( __FILE__ ) . ‘classes/my-gateway.php’; // instantiate your class here or … Read more

Customizer: widget-synced triggers twice

The reason for this is that the widget will run its update logic on keydown and also on change for a given input element. See https://github.com/WordPress/wordpress-develop/blob/4.7.2/src/wp-admin/js/customize-widgets.js#L891-L907 There are some tradeoffs made when widgets were added to the customizer to bring these PHP-driven interfaces into a JS-driven context. It wasn’t perfect and so this is part … Read more

Using the default wordpress uploader inside plugin

have you search in other question? this is the jquery script to call media uploader if u click a element media button var $j = jQuery.noConflict(); function call_media_library() { var media_uploader; $j(document).on(‘click’, ‘.video_media_btn’, function(e){ e.preventDefault(); var btn_uploader = $j(this); if (media_uploader) { media_uploader.open(); return; } media_uploader = wp.media({ title: ‘Upload media’, //you can change type … Read more