Soundcloud Smart Player

If a shortcode isn’t too much effort you can use it to construct the soundcloud url for embedding. add_shortcode(‘soundcloud_auto’, ‘soundcloud_auto_shortcode’); function soundcloud_auto_shortcode($atts) { global $post; $title = str_replace(” “, “”, $post->post_title); $title = str_replace(“-“, “”, $title); $title = str_replace(“_”, “”, $title); $slug = sanitize_title($title, str_replace(“-“, “”, $post->post_name)); return wp_oembed_get(esc_url(“http://soundcloud.com/$slug”)); } Or do something similar using … Read more

Where to put API Code?

You can create a plugin to contain your code. The admin_post_ action can be used to trigger a request handler. WordPress core will be loaded, and the API will work. <?php /* Plugin Name: Ben’s GF Plugin */ // for logged-in users add_action( ‘admin_post_ben_gf’, ‘ben_gf_handle_request’ ); // for non logged-in users add_action( ‘admin_post_nopriv_ben_gf’, ‘ben_gf_handle_request’ ); … Read more

How to create post comment from different domain

This quite rare setup so it is hard to recommend one way or another. Having worked with comments before I would recommend to stick with WordPress API functions (wp_insert_comment() and so on) for manipulating them. While DB structure is indeed simple you don’t account for all the hooks firing and other things that might be … Read more

How to get the post_id after you successfully create new post using xmlrpc api wp newPost?

Note: The WP REST API might be a better alternative. Client Let’s assume we use the built-in WP_HTTP_IXR_CLIENT (see e.g. my previous answer): include_once( ABSPATH . WPINC . ‘/class-IXR.php’ ); include_once( ABSPATH . WPINC . ‘/class-wp-http-ixr-client.php’ ); $client = new WP_HTTP_IXR_CLIENT( ‘https://example.tld/xmlrpc.php’ ); $result = $client->query( ‘wp.newPost’, [ $blog_id = 0, $user = “user”, // … Read more

JSON API and notification about registration

Set your query var notify to user (if you want to send an email to the user only) or both (if you want to send it to the user and the admin). Within the plugin controller/User.php:165 calls wp_new_user_notification with $_REQUEST[‘notify’]. wp_new_user_notification is (lucky you) a pluggable function. If you have your activation logic ready to … Read more

How to convert and use JSON data from a remote WordPress server?

On server B: $result = wp_remote_post(‘http://serverA.com/?api=json’, array( ‘method’ => ‘POST’, ‘redirection’ => 1, ‘httpversion’ => ‘1.0’, ‘blocking’ => true, ‘headers’ => array(), ‘body’ => array(), ‘cookies’ => array() )); if ( is_wp_error( $result ) ) { return ‘bad connection!’; } $json = $result[‘body’]; $posts = json_decode($json); Now you have $posts as usual php array. var_dump($posts) … Read more

WP Customizer API loaded into functions.php

Yes. You can load the code in the customize_register action. One example: <?php // File: functions.php add_action( ‘customize_register’, function( $wp_customize ) { require_once dirname( __FILE__ ) . ‘/inc/customize.php’; wpse256532_customize_register( $wp_customize ); } ); And the inc/customize.php file: <?php // File: customize.php function wpse256532_customize_register( $wp_customize ) { $wp_customize->add_setting( /* … */ ); $wp_customize->add_control( /* … */ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)