/** * Prints the widget JS stuff (mostly, the array of latest comments items). * * @return void * @author Paul Hughes * @since 3.0.2 */ public function printWidgetJs() { global $post; if (is_active_widget(false, false, $this->id_base, true) && !is_admin() && isset($post)) { $poll_time = apply_filters('muut_latest_comments_poll_updates', '0'); $json = $content = json_encode(array('latest_comments_posts' => $this->getLatestCommentsData())); echo '<script type="text/javascript">'; echo 'var muut_latest_comments_poll_time = "' . $poll_time . '";'; echo 'var muut_latest_comments_json = ' . $json . ';'; echo 'var muut_latest_comments_request_endpoint = "' . trailingslashit(Muut_Files_Utility::getUploadsUrl()) . 'cache/' . self::LATEST_COMMENTS_JSON_FILE_NAME . '";'; $user_obj = new stdClass(); $user_obj->path = '%USER_PATH%'; $user_obj->displayname = '%USER_DISPLAYNAME%'; $user_obj->img = '%USER_IMAGEURL%'; echo 'var muut_latest_comments_row_template = \'' . $this->getRowMarkup('%POSTID%', '%TIMESTAMP%', $user_obj) . '\';'; echo '</script>'; } }
/** * Return the Muut uploads directory URL. * * @return string the Uploads directory URL. * @author Paul Hughes * @since 3.0.2 */ public function getUploadsUrl() { if (class_exists('Muut_Files_Utility')) { return Muut_Files_Utility::getUploadsUrl(); } else { return false; } }