Permalink
Browse files

added ajax_function_exists method

  • Loading branch information...
Nomafin committed Oct 10, 2017
1 parent f68a597 commit 231afbf7107b095d74789c375c3cdbe835e8a361
Showing with 29 additions and 1 deletion.
  1. +25 −1 dustpress.php
  2. +4 −0 helpers/content.php
View
@@ -6,7 +6,7 @@
Author: Miika Arponen & Ville Siltala / Geniem Oy
Author URI: http://www.geniem.com
License: GPLv3
Version: 1.6.5
Version: 1.6.9
*/
final class DustPress {
@@ -897,11 +897,35 @@ private function is_dustpress_ajax() {
}
/**
* Register a function to be run with a keyword from DustPress.js.
*
* @type function
* @date 25/11/2016
* @since 1.3.2
*
* @param $key (string)
* @param $callable (mixed)
*
* @return void
*/
public function register_ajax_function( $key, $callable ) {
$this->ajax_functions[ $key ] = $callable;
}
/**
* A function to determine if a keyword has already been registered for an ajax function.
*
* @type function
* @date 10/10/2017
* @since 1.6.9
*
* @param string $key
* @return (boolean)
*/
public function ajax_function_exists( $key ) {
return isset( $this->ajax_functions[ $key ] );
}
/**
* This function does lots of AJAX stuff with the parameters from the JS side.
*
View
@@ -8,6 +8,10 @@ public function output() {
if ( isset( $this->params->data ) ) {
return apply_filters( 'the_content', $this->params->data );
} else {
if ( isset( $this->params->id ) ) {
$post = get_post( $this->params->id );
}
ob_start();
setup_postdata( $post );
the_content();

0 comments on commit 231afbf

Please sign in to comment.