{ ?> <div id="discourse-message"></div> <div class="loading"></div> <label for="discourse-url">URL:</label> <input type="text" id="discourse-url" name="discourse-url"/> <button id="get-topic">Fetch Discourse Topic</button> <div class="topic-posts"></div> <?php } function get_json() { $url = $_GET['url']; $topic_json = file_get_contents($url); echo $topic_json; wp_die(); } // Handle the ajax request from discourse-content.js function create_post() { $post_data = array('post_content' => $_POST['content'], 'post_name' => $_POST['slug'], 'post_title' => $_POST['title'], 'post_status' => $_POST['post_status'], 'post_type' => $_POST['post_type']); if (array_key_exists('category', $_POST)) { $post_data['post_category'] = $_POST['category']; } $new_post_ID = wp_insert_post($post_data); add_metadata('post', $new_post_ID, 'discourse_order', $_POST['order']); wp_die(); } } WP_Discourse_Topic::get_instance();