/** * Can markdown via Jetpack? * * @since 160720 Jetpack utils. * * @return bool Can markdown via Jetpack? */ public function canMarkdown() : bool { if (!isset($this->WPCom_Markdown)) { $this->WPCom_Markdown = $this->Wp->is_jetpack_active && class_exists('WPCom_Markdown') ? \WPCom_Markdown::get_instance() : false; } return (bool) $this->WPCom_Markdown; }
function ubik_markdown_transform($content) { if (class_exists('WPCom_Markdown')) { $markdown = WPCom_Markdown::get_instance(); $content = $markdown->transform($content, array('unslash' => false)); } return $content; }
function transform($content) { if (class_exists('WPCom_Markdown')) { $markdown = \WPCom_Markdown::get_instance(); $content = $markdown->transform($content, ['unslash' => false]); } return $content; }
/** * We munge the post cache to serve proper markdown content to XML-RPC clients. * Uncache these after the XML-RPC session ends. * @return null */ public function uncache_munged_posts() { // $this context gets lost in testing sometimes. Weird. foreach (WPCom_Markdown::get_instance()->posts_to_uncache as $post_id) { wp_cache_delete($post_id, 'posts'); } }
/** * Format product short description. * Adds support for Jetpack Markdown. * * @since 2.4.0 * @param string $content * @return string */ function wc_format_product_short_description($content) { // Add support for Jetpack Markdown if (class_exists('WPCom_Markdown')) { $markdown = WPCom_Markdown::get_instance(); return wpautop($markdown->transform($content, array('unslash' => false))); } return $content; }
/** * Prevent WP from stripping Jetpack markdown */ public function preserve_markdown() { if (class_exists('Jetpack') && Jetpack::is_module_active('markdown')) { require_once ABSPATH . 'wp-content/plugins/jetpack/modules/markdown/easy-markdown.php'; if (class_exists('WPCom_Markdown')) { WPCom_Markdown::get_instance()->unload_markdown_for_posts(); } } }
/** * Returns the post_content * * Markdownify's the content if applicable */ public function post_content() { $content = $this->post->post_content; if (function_exists('wpmarkdown_html_to_markdown')) { $content = wpmarkdown_html_to_markdown($content); } else { if (class_exists('WPCom_Markdown')) { $wpcomMd = WPCom_Markdown::get_instance(); if ($wpcomMd->is_markdown($this->post->ID)) { $content = $this->post->post_content_filtered; } } } return $content; }
/** * Returns the post_content * * Markdownify's the content if applicable */ public function post_content() { $content = $this->post->post_content; if (function_exists('wpmarkdown_html_to_markdown')) { $content = wpmarkdown_html_to_markdown($content); } else { if (class_exists('WPCom_Markdown')) { if (WPCom_Markdown::get_instance()->is_markdown($this->post->ID)) { $content = $this->post->post_content_filtered; } } } return apply_filters('wpghs_content_export', $content, $this); }
/** * Format excerpt * Adds support for Jetpack Markdown * * @since 2.4.0 * @param string $content * @return string */ function documentate_format_document_excerpt($content) { // Add support for Jetpack Markdown if (class_exists('WPCom_Markdown')) { $markdown = WPCom_Markdown::get_instance(); return wpautop($markdown->transform($content, array('unslash' => false))); } return $content; }
<?php if (have_posts()) { while (have_posts()) { the_post(); $path = dirname(ABSPATH); $file = get_post_meta(get_the_ID(), 'include-markdown', true); $cachekey = "cached_include_" . $file; if (is_super_cache_enabled() || false === ($content = get_transient($cachekey))) { ob_start(); include $path . '/' . $file; $content = ob_get_clean(); // Handle sub-section anchors $content = preg_replace('/\\[]\\(\\#([^\\)]+)\\)\\s+?/', '<a href="#$1" name="$1"></a>', $content); // Transform Markdown $Markdown = WPCom_Markdown::get_instance(); $content = wp_unslash($Markdown->transform($content)); // Index table of contents $content = table_of_contents_index($content, get_the_ID()); set_transient($cachekey, $content, DAY_IN_SECONDS); } ?> <article class="page<?php if (has_table_of_contents()) { echo ' with-toc'; } ?> " id="post-<?php the_ID(); ?>