Properties

$journal_config

$journal_config : array

Array holding the configuration of the journal.

Type

array — Array of properties definig the journal.

$doi_suffix_template

$doi_suffix_template : \O3PO_ShortcodeTemplate

The shortcode template used to construct DOIs.

Type

\O3PO_ShortcodeTemplate — The shortcode template used to construct DOIs.

$required_journal_config_properties

$required_journal_config_properties : array

Required journal config properties

Type

array — Array of all required journal config properties.

Methods

__construct()

__construct(array  $journal_config) 

Initialize the journal.

Parameters

array $journal_config

Array with values for the keys returned by get_journal_config_properties().

get_journal_config_properties()

get_journal_config_properties() 

Get an array of all options the journal expects in its journal config.

get_journal_property()

get_journal_property(string  $id) 

Get a journal property.

Parameters

string $id

Id of the property.

add_volumes_endpoint()

add_volumes_endpoint() 

Adds a rewrite endpoint for the /volumes/, /volumes/1, /volumes/2, .

.. pages.

To be added to the 'init' action.

handle_volumes_endpoint_request()

handle_volumes_endpoint_request(\WP_Query  $wp_query) : \Modified

Handle the requests to the /volume/ endpoint.

We want to display an overview of the available volumes as well as sub-pages with lists for each volume. Here we set up appropriate queries to do that.

We then want that Wordpress and the theme take care of turning these queries into actual pages without the need for further intervention from ours side to the extent possible in order to (i) make this plugin as theme independent as possible and (ii) have the volume page rendered with the global theme the users have chosen for their website.

Unfortunately we run into several complications:

  • For the lists of publications in a given volume it is straight forward to generate the query and a navigation can be nicely added just above the list by hooking into 'loop_start' (see below).

  • For the overview page of all volumes we can add the navigation in the same way, but we don't want to display any entries. We thus set up an empty query and force the usage of the 'page' template (see the function volume_endpoint_template() below). Without any posts to show, however, even the 'page' template does not execute 'loop_start' and (depending on the theme) can fall back to the 'content-none' template. To prevent this we have to add a fake "empty" post. We do this during the 'the_posts' action in add_fake_empty_post_to_volume_overview_page() (see below).

  • Finally, we want the entries in the list to appear more "compressed" than in other archive pages. This again could be solved with a custom theme or template, but we want to stay largely theme independent. We thus instead insert some java script into the page to hide parts of the generated html and reduce the spacing between elements. This will not work with every theme, but at least is unlikely to cause serious unintended side-effects.

The true long-term solution to the problem we are solving here could be taxonomies.

To be added to the 'parse_request' action.

Parameters

\WP_Query $wp_query

Query to act on.

Returns

\Modified —

WP_Query object.

volume_navigation_at_loop_start()

volume_navigation_at_loop_start(\WP_Query  $wp_query) 

Add navigation before the loop to the pages of the volume endpoint.

To be added to 'loop_start'.

Parameters

\WP_Query $wp_query

The current Wordpress query.

volume_endpoint_template()

volume_endpoint_template(string  $template) : string

Force the usage of the page template on the volume overview page

Checks for the presence of a query var ending in '_add_fake_post' to determine when to change the template.

To be added to the 'template_include' action.

Parameters

string $template

The template that would be used.

Returns

string —

Template that should be used.

add_fake_post_to_volume_overview_page()

add_fake_post_to_volume_overview_page(array  $posts) : array

Add a fake "empty" post to make 'loop_start' fire on the volume overview page

For queries that do not return any posts, the loop is never run. As we initiate an empty query for the top level volume endpoint that is supposed to serve the volume overview page, we must add at least a fake "empty" post to the $posts in order to allow us to inject content into the standard page template of the current theme.

To be added to the 'the_posts' action.

Parameters

array $posts

Array of posts that would be returned if we do not intervene.

Returns

array —

Array of posts that are returned if we do intervene.

add_notice_to_search_form()

add_notice_to_search_form(string  $form) : string

Add a notice to the search form if there are no results.

To be added to the 'get_search_form' filter.

Parameters

string $form

The normal search form,

Returns

string —

Modified search form.

add_notice_to_search_results_at_loop_start()

add_notice_to_search_results_at_loop_start(\WP_Query  $wp_query) 

Add a notice to the search results.

To be added to the 'loop_start' filter.

Parameters

\WP_Query $wp_query

The current Wordpress query.

get_search_notice()

get_search_notice() 

Generate the notice for the search page.

create_fake_post()

create_fake_post(string  $post_content = '') : \stdClass

Create and return a fake empty post.

Parameters

string $post_content

The content of the post to create.

Returns

\stdClass —

A WP_Post compatible object representing a fake post that is empty apart from the given cont.

compress_entries_in_volume_view()

compress_entries_in_volume_view(\WP_Query  $wp_query) 

Inject java script to compress the entries in the volume listings

Inject some java script to change how the entries of individual publications are displayed in the list of a volume.

To be added to the 'loop_end' filter.

Parameters

\WP_Query $wp_query

The current Wordpress query.

get_post_type_highest_pages_info()

get_post_type_highest_pages_info(integer  $post_id_to_exclude, array  $post_types) 

Returns information about the post with the highest page number.

We have an aricle/fake page number that counts up 1,2,3,... This function determines the highes such number among all posts of the given publication types as well as the publication date of that post. Only published and future posts (i.e. such scheduled for publication) apart from the excluded post are taken into account.

Parameters

integer $post_id_to_exclude

Id of a post to exclude in the calculation

array $post_types

Array of post types to take into account.

pages_still_free_info()

pages_still_free_info(integer  $post_id_to_exclude, integer  $pages, array  $post_types) 

Determines whether a given page number is still free.

We have an aricle/fake page number that counts up 1,2,3,... This function determines whether $pages is still free, in the sense that no post with a type in $post_types other than that with id $post_id already has page number $pages.

Parameters

integer $post_id_to_exclude

Id of a post to exclude.

integer $pages

Page number to be checked for whether it is still free or not.

array $post_types

Post types to take into account.

doi_suffix_still_free()

doi_suffix_still_free(string  $doi_suffix, array  $post_types) 

Determines whether a given page number is still free.

This function can be used to check whether a given $doi_suffix is sitll free or already taken by a registered post type.

Parameters

string $doi_suffix

Doi suffix to be checked.

array $post_types

Post types to take into accoun.

get_count_of_volume()

get_count_of_volume(integer  $vol_num, string  $publication_type) 

Get number of posts of the given type in the given volume.

If $vol_num is empty, the total number over all volumes is returned.

Parameters

integer $vol_num

Volume number to count or all volumes if empty.

string $publication_type

Publication type to count.

specify_settings()

specify_settings(\O3PO_Settings  $settings) 

Specifies class specific settings sections and fields.

To be called during during O3PO_Settings::configure().

Parameters

\O3PO_Settings $settings

Settings object.

render_doi_suffix_template_setting()

render_doi_suffix_template_setting() 

Render the setting for the DOI suffix template.

validate_doi_suffix_template()

validate_doi_suffix_template(string  $field, string  $input) : string

Clean user input to the doi_suffix_template setting.

Parameters

string $field

The field this was input to.

string $input

User input.

Returns

string —

Validated doi suffix.

construct_doi_suffix()

construct_doi_suffix(string  $date_published, string|integer  $volume, string|integer  $pages) : string

Construct the doi suffix for publications.

Returns the doi suffix according to the template specified in settings.

Parameters

string $date_published

A date in ISO_8601 format.

string|integer $volume

The volume for which to construct the DOI.

string|integer $pages

The page/article number for which to construct the DOI.

Returns

string —

The doi suffix constructed according to the template of this publication type.