if (!is_singular()) { if (strpos($content, 'class="more-link') && strpos($content, 'href="#fn')) { global $post; $content = str_replace('href="#fn', 'href="' . get_permalink() . '#fn', $content); } } return $content; } // == TRANSFORM == // // A simple hack for using Markdown in term descriptions, widgets, and any other place you wish to transform on demand // Requires: Jetpack or JP Markdown // Warning 1: Markdown is left as raw text in the database; conversion only happens when filter runs so you're effectively locked in once you start using this! // Warning 2: this is also a security risk on multi-user blogs! function transform($content) { if (class_exists('WPCom_Markdown')) { $markdown = \WPCom_Markdown::get_instance(); $content = $markdown->transform($content, ['unslash' => false]); } return $content; } // Additional Markdown transforms in various places; requires JP Markdown or equivalent if ($options['transform']) { \Ubik\add_filters(array_merge($options['transform'], $options['transform_more']), __NAMESPACE__ . '\\transform'); } // == VARIOUS == // // Check whether Markdown is enabled in comments (set by Jetpack and JP Markdown plugins among others) function comments_enabled() { return (bool) get_option('wpcom_publish_comments_with_markdown'); }
{ return '%s'; } if ($options['clean_post_title_private']) { add_filter('private_title_format', __NAMESPACE__ . '\\clean_post_title_format'); } if ($options['clean_post_title_protected']) { add_filter('protected_title_format', __NAMESPACE__ . '\\clean_post_title_format'); } // Clean unnecessary self-closing tags; originally via Soil: https://github.com/roots/soil/ function clean_self_closing_tags($input) { return str_replace(' />', '>', $input); } if ($options['clean_self_closing_tags']) { \Ubik\add_filters(['comment_id_fields', 'get_avatar', 'post_thumbnail_html'], __NAMESPACE__ . '\\clean_self_closing_tags'); } // Clean up output of stylesheet <link> tags; via Soil: https://github.com/roots/soil/ function clean_style_tag($input) { preg_match_all("!<link rel='stylesheet'\\s?(id='[^']+')?\\s+href='(.*)' type='text/css' media='(.*)' />!", $input, $matches); if (empty($matches[2])) { return $input; } $media = $matches[3][0] !== '' && $matches[3][0] !== 'all' ? ' media="' . $matches[3][0] . '"' : ''; // Only display media if it is meaningful return '<link rel="stylesheet" href="' . $matches[2][0] . '"' . $media . '>' . "\n"; } if ($options['clean_style_tag']) { add_filter('style_loader_tag', __NAMESPACE__ . '\\clean_style_tag'); }