Ejemplo n.º 1
1
 /**
  * Get comments
  *
  * @since 0.0.1
  *
  * @param array $data Sanitized data from request
  *
  * @return array
  */
 public static function get_comments($data)
 {
     $args = api_helper::get_comment_args($data['postID']);
     $options = options::get_display_options();
     $comments = get_comments($args);
     if ('ASC' == $options['order']) {
         $parents = array_combine(wp_list_pluck($comments, 'comment_ID'), wp_list_pluck($comments, 'comment_parent'));
         asort($parents);
         $comments = (array) $comments;
         $comments = array_combine(wp_list_pluck($comments, 'comment_ID'), $comments);
         $i = 0;
         foreach ($comments as $id => $parent) {
             $_comments[$i] = $comments[$id];
             $i++;
         }
         rsort($_comments);
         $comments = $_comments;
     }
     if (!empty($comments) && is_array($comments)) {
         $comments = api_helper::improve_comment_response($comments, !api_helper::thread());
         $comments = wp_json_encode($comments);
     } else {
         return false;
     }
     return array('comments' => $comments);
 }
Ejemplo n.º 2
0
 /**
  * Construct comment query args
  *
  * @since 0.0.11
  *
  * @param int $post_id The post ID to fetch from
  *
  * @return array
  */
 public static function get_comment_args($post_id)
 {
     $options = options::get_display_options();
     $args = array('post_id' => $post_id, 'order' => $options['order'], 'status' => 'approve');
     return $args;
 }
Ejemplo n.º 3
0
 /**
  * Gets Epoch's saved options and prepares them to be localized into the script.
  *
  * @since 0.0.1
  *
  * @access protected
  *
  * @return array
  */
 protected function prepare_epoch_options()
 {
     $options = options::get_display_options();
     $_interval = absint($options['interval']) * 1000;
     if (15000 > $_interval) {
         $options['interval'] = 15000;
     } else {
         $options['interval'] = $_interval;
     }
     return $options;
 }
Ejemplo n.º 4
0
<?php

/**
 * Template for what is outputted on initial page load
 *
 * @package   Epoch
 * @author    Postmatic
 * @license   GPL-2.0+
 * @link
 * Copyright 2015 Transitive, Inc.
 */
$options = \postmatic\epoch\options::get_display_options();
global $post;
$comment_count = get_comment_count($post->ID);
if ($comment_count['approved'] == 0 and !comments_open($post)) {
    return;
}
$form = sprintf('<div id="%1s">%2s</div>', esc_attr(\postmatic\epoch\front\vars::$form_wrap), \postmatic\epoch\front\layout::get_form($post->ID));
$comment_area = sprintf('<div id="%1s"></div>', esc_attr(\postmatic\epoch\front\vars::$comments_wrap));
if ('none' == $options['theme']) {
    $comment_count_area = '';
} else {
    if ($comment_count['approved'] == 0) {
        $comment_count_message = __('There are no comments', 'epoch');
    } else {
        $comment_count_message = sprintf(_n('There is one comment', 'There are %s comments', $comment_count['approved'], 'epoch'), '<span id="' . \postmatic\epoch\front\vars::$count_id . '">' . $comment_count['approved'] . '</span>');
    }
    if ('ASC' == $options['order'] && $comment_count['approved'] > 3) {
        $comment_count_area = sprintf('<h3 class="comment-count-area">%1s <a href="#reply-title">%2s</a></h3>', $comment_count_message, $options['before_text']);
    } else {
        $comment_count_area = sprintf('<h3 class="comment-count-area">%1s</h3>', $comment_count_message);
Ejemplo n.º 5
0
<?php

/**
 * Load the admin UI
 *
 * @package   Epoch
 * @author    Postmatic
 * @license   GPL-2.0+
 * @link
 * Copyright 2015 Transitive, Inc.
 */
$epoch = \postmatic\epoch\options::get();
?>
<div class="wrap" id="epoch-main-canvas">
	<span class="wp-baldrick spinner" style="float: none; display: block;" data-target="#epoch-main-canvas" data-callback="epoch_canvas_init" data-type="json" data-request="#epoch-live-config" data-event="click" data-template="#main-ui-template" data-autoload="true"></span>
</div>

<div class="clear"></div>

<input type="hidden" class="clear" autocomplete="off" id="epoch-live-config" style="width:100%;" value="<?php 
echo esc_attr(json_encode($epoch));
?>
">

<script type="text/html" id="main-ui-template">
	<?php 
// pull in the rest of the admin
include EPOCH_PATH . 'includes/templates/main-ui.php';
?>
	
</script>
Ejemplo n.º 6
0
 /**
  * Get comment form HTML
  *
  * @since 0.0.9
  *
  * @param int $post_id Post ID for this comment form
  *
  * @return string
  */
 public static function get_form($post_id)
 {
     if (0 < absint($post_id) && comments_open($post_id)) {
         $options = options::get_display_options();
         $args = array('id_form' => vars::$form_id, 'id_submit ' => vars::$submit_id, 'comment_notes_after' => '');
         $args['title_reply'] = $options['before_text'];
         ob_start();
         comment_form($args, $post_id);
         $html = ob_get_clean();
     } else {
         if (!comments_open($post_id)) {
             $html = __('Comments are closed.', 'epoch');
         } else {
             $html = '';
         }
     }
     return $html;
 }