admin_url( 'admin-ajax.php' )] ); }); } public function shortCode( $attributes ) { $this->attributes = shortcode_atts( array( 'most_recent' => 1 ), $attributes ); //Article variable used in plugin.php file included after this. $article = Article::getMostRecentArticle(); include(WDWTF_PLUGIN_ABSOLUTE_PATH . "/views/plugin.php"); } /** * Initiates the admin funcitons */ public function initAdmin() { add_action( 'wp_ajax_nopriv_tdwtf_plugin_get_article_by_id', array( $this, 'getArticleById' ) ); add_action( 'wp_ajax_tdwtf_plugin_get_article_by_id', array( $this, 'getArticleById' ) ); } public function getArticleById() { header( 'Content-Type: application/json' ); echo json_encode( Article::getArticleById( $_POST['id'] ) ); exit; } }