Unified · Split
| @@ -98,5 +98,6 @@ · 97 unmodified lines | ||
| 98 | 98 | 'pages/underscore', |
| 99 | 99 | 'pages/vue', |
| 100 | 100 | 'pages/webpack', |
| 101 | + 'pages/wordpress', | |
| 101 | 102 | 'pages/yard', |
| 102 | 103 | 'pages/yii'; |
| @@ -98,5 +98,6 @@ · 97 unmodified lines | ||
| 98 | 98 | 'pages/underscore', |
| 99 | 99 | 'pages/vue', |
| 100 | 100 | 'pages/webpack', |
| 101 | + 'pages/wordpress', | |
| 101 | 102 | 'pages/yard', |
| 102 | 103 | 'pages/yii'; |
| @@ -0,0 +1,11 @@ | ||
| 1 | +._wordpress { | |
| 2 | + @extend %simple; | |
| 3 | + | |
| 4 | + .breadcrumbs { | |
| 5 | + display: none; | |
| 6 | + } | |
| 7 | + | |
| 8 | + .callout-warning { | |
| 9 | + @extend %note, %note-red; | |
| 10 | + } | |
| 11 | +} | |
| @@ -0,0 +1,27 @@ | ||
| 1 | +module Docs | |
| 2 | + class Wordpress | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + if root_page? | |
| 6 | + doc.inner_html = '<h1>WordPress</h1>' | |
| 7 | + return doc | |
| 8 | + end | |
| 9 | + | |
| 10 | + css('hr', '.screen-reader-text', '.table-of-contents', | |
| 11 | + '.anchor', '.toc-jump', '.source-code-links', '.related', | |
| 12 | + '.user-notes').remove | |
| 13 | + | |
| 14 | + # Add PHP code highlighting | |
| 15 | + br = /<br\s?\/?>/i | |
| 16 | + css('.source-code-container', '.syntaxhighlighter').each do |node| | |
| 17 | + node.name = 'pre' | |
| 18 | + node.inner_html = node.inner_html.gsub(br, "\n") | |
| 19 | + node.content = node.content.strip | |
| 20 | + node['data-language'] = 'php' | |
| 21 | + end | |
| 22 | + | |
| 23 | + doc | |
| 24 | + end | |
| 25 | + end | |
| 26 | + end | |
| 27 | +end | |
| @@ -0,0 +1,23 @@ | ||
| 1 | +module Docs | |
| 2 | + class Wordpress | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def breadcrumbs | |
| 5 | + @breadcrumbs ||= css('.breadcrumbs .trail-inner a') | |
| 6 | + .map(&:content) | |
| 7 | + .map(&:strip) | |
| 8 | + end | |
| 9 | + | |
| 10 | + def get_name | |
| 11 | + at_css('.breadcrumbs .trail-end').content | |
| 12 | + end | |
| 13 | + | |
| 14 | + def get_type | |
| 15 | + if breadcrumbs.size > 1 | |
| 16 | + breadcrumbs.drop(1).join(': ') | |
| 17 | + else | |
| 18 | + at_css('.breadcrumbs .trail-end').content | |
| 19 | + end | |
| 20 | + end | |
| 21 | + end | |
| 22 | + end | |
| 23 | +end | |
| @@ -0,0 +1,39 @@ | ||
| 1 | +module Docs | |
| 2 | + class Wordpress < UrlScraper | |
| 3 | + self.name = 'WordPress' | |
| 4 | + self.type = 'wordpress' | |
| 5 | + self.release = '4.9.4' | |
| 6 | + self.base_url = 'https://developer.wordpress.org/reference/' | |
| 7 | + self.initial_paths = %w( | |
| 8 | + functions/ | |
| 9 | + hooks/ | |
| 10 | + classes/ | |
| 11 | + ) | |
| 12 | + | |
| 13 | + self.links = { | |
| 14 | + home: 'https://wordpress.org/', | |
| 15 | + code: 'https://github.com/WordPress/WordPress' | |
| 16 | + } | |
| 17 | + | |
| 18 | + html_filters.push 'wordpress/clean_html', 'wordpress/entries' | |
| 19 | + | |
| 20 | + options[:container] = '#content-area' | |
| 21 | + options[:trailing_slash] = true | |
| 22 | + options[:only_patterns] = [ | |
| 23 | + /\Afunctions\//, | |
| 24 | + /\Ahooks\//, | |
| 25 | + /\Aclasses\// | |
| 26 | + ] | |
| 27 | + | |
| 28 | + options[:skip_patterns] = [ | |
| 29 | + /\Afunctions\/page\/\d+/, | |
| 30 | + /\Ahooks\/page\/\d+/, | |
| 31 | + /\Aclasses\/page\/\d+/ | |
| 32 | + ] | |
| 33 | + | |
| 34 | + options[:attribution] = <<-HTML | |
| 35 | + © 2003–2018 WordPress Foundation<br> | |
| 36 | + Licensed under the GNU GPLv2+ License. | |
| 37 | + HTML | |
| 38 | + end | |
| 39 | +end | |
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | ||
| 1 | +https://wordpress.org/about/logos/ | |