Wordpress Theme Core¶
The Wordpress theme for Capitularia.
PHP¶
themes/Capitularia/404.php¶
Template for 404 Page not found.
themes/Capitularia/class-cap-query.php¶
The template for displaying Search Results pages.
- class CapQuery¶
- parse_search(q)¶
Generates SQL for the WHERE clause based on passed search terms.
Copied from class-wp-query.php and doctored to accept any amount of whitespace between each word in phrase searches.
Prerequisite:
mysql> create fulltext index post_content on wp_posts(post_content); mysql> create fulltext index post_title on wp_posts(post_title); mysql> create fulltext index post_excerpt on wp_posts(post_excerpt);
Since: 3.7.0
- Parameters:
q (
array
) – Query variables.
- Returns:
WHERE clause.
- Return type:
string
themes/Capitularia/front-page.php¶
Capitularia Theme front-page.php file
themes/Capitularia/functions-include.php¶
Capitularia Theme functions-include.php file
This file only declares symbols (classes, functions, constants) in accordance with PSR-2.
- constant \cceh\capitularia\theme\CapQuery::MAGIC_LOGIN¶
‘#cap_login_menu#’
- ns(function_name)¶
Add current namespace
- Parameters:
function_name (
string
) – The class or function name without namespace
- Returns:
Name with namespace
- Return type:
string
- get_slug_root(page_id)¶
Get the first path component of the slug.
If a page has a slug of: “top/sub/current” this function returns “top”.
- Parameters:
page_id (
int
) – Wordpress Page ID.
- Returns:
The slug root.
- Return type:
string
- get_parent_path(path)¶
Get the path of the parent page.
- Parameters:
path (
string
) – The path of the page.
- Returns:
The path of the parent page.
- Return type:
string
- echo_attribute(name, value)¶
Echo a name=”value” pair.
- Parameters:
name (
string
) – The name of the attribute.value (
string
) – The value of the attribute.
- Return type:
void
- get_permalink_a()¶
Returns an opening <a> containing a permalink to the current page.
It is the responsibilty of the caller to close the <a> tag.
- Returns:
An opening <a> tag.
- Return type:
string
- get_main_start(class)¶
Echo the tag to start the main section.
- Parameters:
class (
string
) – CSS classes to add to the tag.
- Return type:
void
- get_main_end()¶
Echo the tag to end the main section.
- Return type:
void
- get_sidebar_start()¶
Echo the tag to start the sideabr section.
- Return type:
void
- get_sidebar_end()¶
Echo the tag to end the sidebar section.
- Return type:
void
- get_content_start()¶
Echo the tag to start the content section.
- Return type:
void
- get_content_end()¶
Echo the tag to end the content section.
- Return type:
void
- on_enqueue_scripts()¶
Enqueue scripts and CSS
Add JS and CSS the wordpress way.
N.B. We use our own copy of jquery and bootstrap on the front.
- Return type:
void
- on_admin_enqueue_scripts()¶
Enqueue admin scripts and CSS
Add JS and CSS the wordpress way.
N.B. We use wordpress’ copy of jquery and jquery-ui on the admin pages, and no bootstrap because it breaks too many things.
- Return type:
void
- on_wp_title(title, sep)¶
Customize <head> <title>
Customize the title displayed in the browser window caption and used if you bookmark the page.
if root: “Capitularia | Edition der fränkischen Herrschererlasse” else: “[Name of page] | Capitularia”
- Parameters:
title (
string
) – Default title text for current view.sep (
string
) – Optional separator.
- Returns:
The customized title.
- Return type:
string
- on_the_title(title, post_ID)¶
Mark wiki post titles with “Wiki:”
- Parameters:
title (
string
) – The post titlepost_ID (
int
) – The post ID
- Returns:
The edited post title
- Return type:
string
- on_body_class(classes)¶
Add a <body> class.
Add a class to the HTML <body> tag depending on which section of the website we are in. Eg.: adds class=”cap-slug-mss” in the /mss/ section of the site.
- Parameters:
classes (
array
) – Old classes added by Wordpress or other plugins.
- Returns:
New classes
- Return type:
array
- on_init()¶
Initialize the theme.
- Return type:
void
- on_dropdown_pages_args(dropdown_args, dummy_post)¶
Add private/draft/future/pending pages to page parent dropdown.
Only public pages are eligible for parenting in vanilla Wordpress. We want other pages also.
- Parameters:
dropdown_args (
array
) – The previous args.dummy_post (
int
) – (unused) The post ID.
- Returns:
The new args.
- Return type:
array
- translate_month_year(month_year)¶
Translate the archive widget month names
- Parameters:
month_year (
string
) – Link containing untranslated MMMMMMM YYYY
- Returns:
Link containing translated MMMMMMM YYYY
- Return type:
string
- fix_bk_nr(corresp)¶
Canonicalize the innumerable different ways the editors write a BK or Mordek no.
Accepts (not exhaustive list of examples found in the wild):
BK.42 BK.042 BK_42 BK_042 bk-nr-42 bk-nr-042 Mordek.27 Mordek_27 mordek-nr-27 ldf/all-of-the-above
Returns:
bk-nr-042 mordek-nr-27
- Parameters:
corresp (
string
) – eg. “BK.42a” or “Mordek_15”
- Returns:
The canonical BK no.
- Return type:
string
- bk_to_permalink(corresp)¶
Get the Capitular page url corresponding to a BK or Mordek No.
This function figures out which subdirectory the Capitular page is in, eg. pre814/ or ldf/ or post840/ …
- Parameters:
corresp (
string
) – eg. “BK.42a” or “Mordek_15”
- Returns:
The url to the page, eg. “http://…/capit/pre814/bk-nr-042a” or null
- Return type:
string
- siglum_to_permalink(siglum)¶
Get the manuscript page url corresponding to a manuscript siglum.
Note: If the siglum is not unique, a random manuscript with that siglum will be returned.
- Parameters:
siglum (
string
) – eg. “Ba2”
- Returns:
The path to the page, eg. “/mss/bamberg-sb-can-7” or null
- Return type:
string
- on_do_parse_request(do_parse, wp, extra_query_vars)¶
Implements URL-Redirects
Examples of implemented redirects:
/capit/BK.42a => /capit/<subdir>/bk-nr-042a/ /capit/Mordek_27 => /capit/<subdir>/mordek-nr-27/ /bk/42a => /capit/<subdir>/bk-nr-042a/ /mordek/27 => /capit/<subdir>/mordek-nr-27/ /siglum/Ba2 => /mss/bamberg-sb-can-7
See: https://developer.wordpress.org/reference/hooks/do_parse_request/
- Parameters:
do_parse (
bool
) – (unused) Whether or not to parse the request.wp (
WP
) – (unused) The current WordPress environment instance.extra_query_vars (
array|string
) – (unused) Extra passed query variables.
- Returns:
The $do_parse parameter unchanged.
- Return type:
bool
Removes the login menu if already logged in.
This assumes the menu entry is a top-level one with an URL of: #cap_login_menu#
- Parameters:
items (
array
) – An array of menu item post objects.menu (
object
) – The menu object.args (
array
) – An array of arguments used to retrieve menu item objects.
- Returns:
The modified array of menu item post objects.
- Return type:
array
Add dynamic url to login menu. Remove text from twitter and fb logos.
- Parameters:
atts (
array
) – The old HTML attributes.item (
WP_Post
) – The current menu item.args (
stdClass
) – An object of wp_nav_menu() arguments.depth (
int
) – Depth of menu item. Used for padding.
- Returns:
The updated HTML attributes.
- Return type:
array
- on_upload_mimes(mimes)¶
Allow upload of SVG files.
- Parameters:
mimes (
array
) – The old list of allowed mime types.
- Returns:
The updated list of allowed mime types.
- Return type:
array
- on_login_redirect(redirect_to, requested_redirect_to, user)¶
Redirect the user to the current page after login
See: https://developer.wordpress.org/reference/hooks/login_redirect/
- Parameters:
redirect_to (
string
) – The redirect destination URL.requested_redirect_to (
string
) – The requested redirect destination URL passed as a parameter.user (
WP_User|\WP_Error
) – WP_User object if login was successful, WP_Error object otherwise.
- Returns:
The target URL of the redirection.
- Return type:
string
- on_registered_post_type(post_type, post_type_object)¶
HACK! make the “WP Help” wiki plugin’s post type searchable
- Parameters:
post_type (
string
) – The post typepost_type_object (
WP_Post_Type
) – The post object
- Return type:
void
- on_pre_get_posts(query)¶
Search only wiki pages if search string contains ‘wiki:’
- Parameters:
query (
WP_Query
) – The query
- Return type:
void
- cap_rest_user_info(request)¶
REST endpoint to get user information from auth cookie
- Parameters:
request (
WP_REST_Request
) – The request
- Return type:
void
- on_after_setup_theme()¶
Remove widget-block-editor
- Return type:
void
themes/Capitularia/functions.php¶
Capitularia Theme functions.php file
Loads the text domain and adds all actions, filters and shortcodes.
This file executes only logic with side-effects in accordance with PSR-2.
The functions are defined in
function-includes.php
.
- constant \cceh\capitularia\theme\CapQuery::IMAGE_SERVER_URL¶
‘http://images.cceh.uni-koeln.de/capitularia/’
The URL to the Capitularia image server.
themes/Capitularia/header.php¶
The HTML header.
This is the HTML header that is output on every page.
themes/Capitularia/index.php¶
Template for single posts or multiple excerpts.
themes/Capitularia/page.php¶
Capitularia Theme page.php file
themes/Capitularia/page_blank.php¶
Template Name: Blank Page (only header and footer)
Capitularia Theme page_blank.php file
themes/Capitularia/phpinfo.php¶
Print server info (for debug use only).
themes/Capitularia/search.php¶
The template for displaying Search Results pages.
themes/Capitularia/shortcodes.php¶
Capitularia Theme shortcodes.php file
Define actions for various shortcodes.
- on_shortcode_logged_in(dummy_atts, content)¶
Add the logged_in shortcode.
This shortcode outputs its content only to logged-in users.
[logged_in]You are logged in![/logged_in]
- Parameters:
dummy_atts (
array
) – (unused) The shortocde attributes.content (
string
) – The shortcode content.
- Returns:
The shortcode content if logged in else the empty string.
- Return type:
string
- on_shortcode_logged_out(dummy_atts, content)¶
Add the logged_out shortcode.
This shortcode outputs its content only to logged-out users.
[logged_out]Please log in![/logged_out]
- Parameters:
dummy_atts (
array
) – (unused) The shortocde attributes.content (
string
) – The shortcode content.
- Returns:
The shortcode content if logged out else the empty string.
- Return type:
string
- on_shortcode_cap_image_server(atts, content)¶
Add the cap_image_server shortcode.
This shortcode wraps the content in a link to the image server if the user is logged in.
- Parameters:
atts (
array
) – The shortocde attributes.content (
string
) – The shortcode content.
- Returns:
The shortcode content wrapped in a link.
- Return type:
string
- get_page_status_in_cache(path)¶
Make sure the status of a page is in the cache.
Some pages with long lists must check the status of hundreds of other pages. Wordpress turns each status check into one SQL query. This function reads the statuses of all children of a parent page in one SQL query, potentially saving hundreds of queries.
- Parameters:
path (
string
) – The path of the page without leading or trailing slashes.
- Returns:
A dictionary of path => status which is guaranteed to contain the page’s status if the page exists.
- Return type:
array
- if_status(atts)¶
Find out the status of a page.
- Parameters:
atts (
array
) – The shortocde attributes. status = status, path = path of page
- Returns:
if page has that status.
- Return type:
true
- get_transcribed_in_cache(cap_id)¶
Cache a list of all manuscripts with a transcription of capitular cap_id
- Parameters:
cap_id (
array
) – The BK-no of the capitular.
- Returns:
List of manuscripts.
- Return type:
array
- on_shortcode_if_status(atts, content)¶
Add the if_status shortcode.
This shortcode outputs its content if the ms. has that status.
[if_status path="/mss/wien" status="publish"] <p>Wien is published!</p> [/if_status]
- Parameters:
atts (
array
) – The shortocde attributes. status = status, path = path of pagecontent (
string
) – The shortcode content.
- Returns:
The shortcode content if the ms. has that status else the empty string.
- Return type:
string
- on_shortcode_if_not_status(atts, content)¶
Add the if_not_status shortcode.
This shortcode outputs its content if the ms. doesn’t have that status.
[if_not_status path="/mss/wien" status="publish"] <p>Wien is not published!</p> [/if_not_status]
- Parameters:
atts (
array
) – The shortocde attributes. status = status, path = path of pagecontent (
string
) – The shortcode content.
- Returns:
The shortcode content if the ms. doesn’t have that status else the empty string.
- Return type:
string
- if_visible(path)¶
Check if the current user can see a page.
Check if the user’s permissions are sufficient to see a particular page.
- Parameters:
path (
string
) – The path of the page.
- Returns:
if the current user can see the page.
- Return type:
true
- on_shortcode_if_visible(atts, content)¶
Add the if_visible shortcode.
This shortcode outputs its content if the current user can see any one of the pages in the path attribute.
[if_visible path="/mss/secret.html"] <div>The secret manuscript.</div> [/if_visible]
Use this with multiple pages to find out when to print headers, etc.
[if_any_visible path="/mss/leo1.html /mss/leo2.html"] <h2>Hic sunt leones</h2> [/if_any_visible]
- Parameters:
atts (
array
) – The shortocde attributes. path = space separated paths of pagescontent (
string
) – The shortcode content.
- Returns:
The shortcode content if the user can see the page in path or else the empty string.
- Return type:
string
- on_shortcode_if_not_visible(atts, content)¶
Add the if_not_visible shortcode.
This shortcode outputs its content if the current user cannot see any one of the pages in the path attribute.
[if_not_visible path="/premium.html"] <p>Pay to see our boring premium content!</p> [/if_not_visible]
- Parameters:
atts (
array
) – The shortocde attributes. path = space separated paths of pagescontent (
string
) – The shortcode content.
- Returns:
The shortcode content if the current user cannot see the page in path else the empty string.
- Return type:
string
- on_shortcode_if_transcribed(atts, content)¶
Add the if_transcribed shortcode.
This shortcode outputs its content if the capitular was already transcribed in the manuscript with the xml:id.
[if_transcribed ms_id="barcelona-aca-ripoll" cap_id="BK.42"] and <a>here</a>[/if_transcribed]
- Parameters:
atts (
array
) – The shortocde attributes.content (
string
) – The shortcode content.
- Returns:
The shortcode content if the corresp is transcribed, else the empty string.
- Return type:
string
- on_shortcode_current_date(atts, dummy_content)¶
Add the current_date shortcode.
This shortcode outputs the current date using the preferred date representation for the current locale without the time.
<p>Accessed on: [current_date]</p>
yields:
<p>Accessed on: Jan 1, 1970</p>
- Parameters:
atts (
array
) – The shortocde attributes.dummy_content (
string
) – The shortcode content. (empty)
- Returns:
The current date.
- Return type:
string
- on_shortcode_permalink(dummy_atts, dummy_content)¶
Add the permalink shortcode.
This shortcode outputs the permalink for the current page.
<p>URL: [permalink]</p>
yields:
<p>URL: https://example.org/post/123</p>
- Parameters:
dummy_atts (
array
) – (unused) The shortocde attributes.dummy_content (
string
) – (unused) The shortcode content.
- Returns:
The page permalink.
- Return type:
string
- on_shortcode_cite_as(atts, dummy_content)¶
Add the cite_as shortcode.
This shortcode outputs a short description of how to cite the post.
<p>[cite_as]</p>
- Parameters:
atts (
array
) – The shortocde attributes.dummy_content (
string
) – The shortcode content. (empty)
- Returns:
A description of how to cite.
- Return type:
string
Javascript¶
themes/Capitularia/src/js/admin.js¶
A dummy file to make webpack happy.
themes/Capitularia/src/js/front.js¶
This module contains the Javascript for the Capitularia theme.
- themes/Capitularia/front.initResetForm()¶
Initialize reset buttons to reset input and select controls on the parent form.
- themes/Capitularia/front.initFootnoteTooltips()¶
Initialize the footnote refs, ie. the ‘*’, to open a popup on mouse hover. The popup contains the footnote text. The popup shall also stay open while the user hovers over the content, so that the user may click on links in the content. Footnotes are done with bootstrap 5.
- themes/Capitularia/front.initLegend()¶
Initialize the legend slide-out. Make the legend slide out (and back in) if the user clicks on the respective tab.