/** * Instance. * * @static * * @return LivePress_Themes_Helper */ public static function instance() { if (self::$instance == null) { self::$instance = new LivePress_Themes_Helper(); } return self::$instance; }
/** * Add a div tag surrounding the post text so oortle dom manipulator * can find where it should do the changes. * * @param string $content Content. * @param mixed $post_modified_gmt Post modified GMT. */ function add_global_post_content_tag($content, $post_modified_gmt = null, $livetags = array()) { global $post; $div_id = null; if (is_page() || is_single()) { $div_id = 'post_content_livepress'; } if (is_home()) { $div_id = 'post_content_livepress_' . $post->ID; } // Add the live tag data to the div $live_tag_data = ''; if (!empty($livetags)) { foreach ($livetags as $a_tag) { $live_tag_data .= $a_tag . ','; } } if ($div_id) { $content = '<div id="' . esc_attr($div_id) . '" class="livepress_content" data-livetags="' . trim($live_tag_data, ',') . '">' . $content . '</div>'; } if ($this->inject) { if ($post_modified_gmt === null) { $post_modified_gmt = $post->post_modified_gmt; } $modified = new DateTime($post_modified_gmt, new DateTimeZone('UTC')); if (true && method_exists($modified, 'diff')) { $since = $modified->diff(new DateTime()); // If an update is more than an hour old, we don't care how old it is ... it's out-of-date. // Calculate number of seconds that have elapsed $last_update = $since->days * 24 * 60 * 60; // Days in seconds $last_update += $since->h * 60 * 60; // Hours in seconds $last_update += $since->i * 60; // Minutes in seconds $last_update += $since->s; // Seconds } else { $modified = new DateTime($post_modified_gmt, new DateTimeZone('UTC')); $now = new DateTime(); $since = abs($modified->format('U') - $now->format('U')); // If an update is more than an hour old, we don't care how old it is ... it's out-of-date. $last_update = $since; } $content = LivePress_Themes_Helper::instance()->inject_widget($content, $last_update); } return $content; }