mirror of https://github.com/freeCodeCamp/devdocs
Add WordPress documentation (#773)
Add WordPress documentation Co-authored-by: Jasper van Merle <jaspervmerle@gmail.com>pull/1053/head
commit
b9b454a272
@ -0,0 +1,15 @@
|
||||
._wordpress {
|
||||
@extend %simple;
|
||||
|
||||
.breadcrumbs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.callout-warning {
|
||||
@extend %note, %note-red;
|
||||
}
|
||||
|
||||
.callout-alert {
|
||||
@extend %note, %note-orange;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
module Docs
|
||||
class Wordpress
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
doc.inner_html = '<h1>WordPress</h1>'
|
||||
return doc
|
||||
end
|
||||
|
||||
article = at_css('article[id^="post-"]')
|
||||
@doc = at_css('article[id^="post-"]') unless article.nil?
|
||||
|
||||
css('hr', '.screen-reader-text', '.table-of-contents',
|
||||
'.anchor', '.toc-jump', '.source-code-links', '.user-notes',
|
||||
'.show-more', '.hide-more').remove
|
||||
|
||||
br = /<br\s?\/?>/i
|
||||
|
||||
header = at_css('h1')
|
||||
header.content = header.content.strip
|
||||
doc.prepend_child header
|
||||
|
||||
# Add PHP code highlighting
|
||||
css('pre').each do |node|
|
||||
node['data-language'] = 'php'
|
||||
end
|
||||
|
||||
css('.source-code-container').each do |node|
|
||||
node.name = 'pre'
|
||||
node.inner_html = node.inner_html.gsub(br, "\n")
|
||||
node.content = node.content.strip
|
||||
node['data-language'] = 'php'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,19 @@
|
||||
module Docs
|
||||
class Wordpress
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('.breadcrumbs .trail-end').content
|
||||
end
|
||||
|
||||
def get_type
|
||||
if subpath.starts_with?('classes')
|
||||
'Classes'
|
||||
elsif subpath.starts_with?('hooks')
|
||||
'Hooks'
|
||||
elsif subpath.starts_with?('functions')
|
||||
'Functions'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,39 @@
|
||||
module Docs
|
||||
class Wordpress < UrlScraper
|
||||
self.name = 'WordPress'
|
||||
self.type = 'wordpress'
|
||||
self.release = '5.2.2'
|
||||
self.base_url = 'https://developer.wordpress.org/reference/'
|
||||
self.initial_paths = %w(
|
||||
functions/
|
||||
hooks/
|
||||
classes/
|
||||
)
|
||||
|
||||
self.links = {
|
||||
home: 'https://wordpress.org/',
|
||||
code: 'https://github.com/WordPress/WordPress'
|
||||
}
|
||||
|
||||
html_filters.push 'wordpress/entries', 'wordpress/clean_html'
|
||||
|
||||
options[:container] = '#content-area'
|
||||
options[:trailing_slash] = false
|
||||
options[:only_patterns] = [
|
||||
/\Afunctions\//,
|
||||
/\Ahooks\//,
|
||||
/\Aclasses\//
|
||||
]
|
||||
|
||||
options[:skip_patterns] = [
|
||||
/\Afunctions\/page\/\d+/,
|
||||
/\Ahooks\/page\/\d+/,
|
||||
/\Aclasses\/page\/\d+/
|
||||
]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2003–2019 WordPress Foundation<br>
|
||||
Licensed under the GNU GPLv2+ License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1 @@
|
||||
https://wordpress.org/about/logos/
|
Loading…
Reference in new issue