\O3PO_PublicationType

Base class for types of publications.

Abstract base class for representing different publication types as custom WordPress post types.

Summary

Methods
Properties
Constants
get_journal_property()
get_publication_type_name()
get_publication_type_name_plural()
get_default_number_authors()
__construct()
get_active_publication_types()
get_active_publication_type_names()
register_as_custom_post_type()
init_metabox()
add_metabox()
render_metabox()
render_maintenance_mode_warning()
save_metabox()
on_transition_post_status()
add_custom_post_types_to_query()
add_custom_post_types_to_rss_feed()
the_author_feed()
add_dublin_core_and_highwire_press_meta_tags()
get_doi()
get_volume()
get_page()
get_formated_citation()
generate_crossref_xml_doi_batch_id()
generate_crossref_xml()
generate_clockss_xml()
generate_doaj_json()
the_java_script_single_page()
get_formated_volume_html()
get_formated_bibliography_html()
get_formated_bibliography_entry_html()
get_bibliography_html()
get_formated_cited_by_html()
get_cited_by_data()
get_cited_by()
generate_bibtex()
get_bibtex_html()
get_popular_summary()
get_formated_authors()
get_formated_authors_bibtex()
get_license_information()
get_formated_authors_html()
get_formated_affiliations_html()
get_formated_date_published()
admin_page_extra_css()
get_post_meta_field_containing_array()
get_fulltext_pdf_path()
get_pdf_pretty_permalink()
get_the_author()
get_the_author_posts_link()
use_page_template()
get_corresponding_author_email()
get_number_authors()
get_title()
get_post_meta()
get_date_published()
get_all_citation_counts()
get_basis_for_excerpt()
get_the_excerpt()
html_latex_excerpt()
get_social_media_thumbnail_src()
No public properties found
No constants found
save_meta_data()
validate_and_process_data()
on_post_actually_published()
the_admin_panel_intro_text()
the_admin_panel_validation_result()
the_admin_panel_corresponding_author_email()
the_admin_panel_buffer()
the_admin_panel_title()
the_admin_panel_authors()
the_admin_panel_affiliations()
the_admin_panel_date_volume_pages()
the_admin_panel_doi()
the_admin_panel_bibliography()
the_admin_panel_crossref()
the_admin_panel_doaj()
the_admin_panel_clockss()
the_admin_panel_funder_information()
$environment
N/A
post_update_on_buffer_com_if_not_already_done()
upload_meta_data_to_crossref()
upload_meta_data_to_doaj()
upload_meta_data_and_pdf_to_clockss()
$active_publication_types
$journal
$publication_type_name
$publication_type_name_plural
$default_number_authors
N/A

Properties

$environment

$environment : \O3PO_Environment

The envrironment in which this publication type exists.

Type

\O3PO_Environment — The envrironment in which this publication type exists.

$active_publication_types

$active_publication_types : array

Array of all activated publication types derived from this class.

Type

array — Array of all activated publication types derived from this class.

$journal

$journal : \O3PO_Journal

The array holding the properties of the journal this post type is associated with.

Type

\O3PO_Journal — A the journal this publication type is published in.

$publication_type_name

$publication_type_name : string

Name of this publication type.

Type

string — Name of this publication type.

$publication_type_name_plural

$publication_type_name_plural : string

Plural of the name of this publication type.

Type

string — Plural of the name of this publication type.

$default_number_authors

$default_number_authors : integer

Default number of authors for this publication type.

Type

integer — Default number of authors for this publication type.

Methods

get_journal_property()

get_journal_property(string  $id) 

Get a property of the associated journal.

Parameters

string $id

If of the property.

get_publication_type_name()

get_publication_type_name() 

Get the name of this publication type.

get_publication_type_name_plural()

get_publication_type_name_plural() 

Get the plural name of this publication type.

get_default_number_authors()

get_default_number_authors() 

Get the default number of authors for this publication type.

__construct()

__construct(object  $journal, integer  $default_number_authors, \O3PO_Environment  $environment) 

Construct this publication type.

Constructs and registers this publication type in the array $active_publication_types. Throws an error in case a publication type with the same $publication_type_name is alreay registered.

Parameters

object $journal

The journal this publication type is associated with.

integer $default_number_authors

The default number of authors.

\O3PO_Environment $environment

The evironment in which this post type is to be created.

get_active_publication_types()

get_active_publication_types(string  $name = Null) 

Get all registered publication types.

Parameters

string $name

Name of a publication type. If provided returns only that publication type (if it is acitve).

get_active_publication_type_names()

get_active_publication_type_names() : array

Get the names of all registered publication types.

Returns

array —

Array of names of all active publication types.

register_as_custom_post_type()

register_as_custom_post_type() 

Registers this publication type as a custom post type with WordPress.

To be added to the 'init' action.

init_metabox()

init_metabox() 

Init the meta box for all publication types and add hooks for its save action.

Normally all hooks should be added in class-o3po.php. This method is special in that it adds two extra hooks. We do this, because we need to unhook one of them during save_metabox() (see below), so that it is better to keep this all contained in the same file

add_metabox()

add_metabox() 

Adds the meta box for the meta-data of posts of this publication type to the create new/update post page in the admin area.

render_metabox()

render_metabox(\WP_Post  $post) 

Render the meta box.

This function should be overwritten in any child class and but the parent implementation should be called through.

Parameters

\WP_Post $post

The post for which to render the metabox.

render_maintenance_mode_warning()

render_maintenance_mode_warning(\WP_Post  $post) 

Render the maintenance_mode warning if appropriate.

Parameters

\WP_Post $post

The post for which to render the metabox.

save_metabox()

save_metabox(integer  $post_id, \WP_Post  $post) 

Callback function for handling the data enterd into the meta-box when a correspnding post is saved.

Calls save_meta_data() and validate_and_process_data() as well as a bunch of other methods such as on_post_actually_published() when appropriate to actually do the processing. Also ensures that the post is forced to private as long as there are still validation ERRORs or REVIEW requests.

Warning: This is already called when a New Post is created and not only when the "Publish" or "Update" button is pressed!

Parameters

integer $post_id

The id of the post for which to save the metabox.

\WP_Post $post

The post for which to save the metabox.

on_transition_post_status()

on_transition_post_status(string  $new, string  $old, integer  $post) 

Handle post status transitions

To be added to the 'transition_post_status' hook.

Parameters

string $new

The new post status after this transition.

string $old

The old post status before this transition.

integer $post

The post that is undergoing the transitions.

add_custom_post_types_to_query()

add_custom_post_types_to_query(\WP_query  $query) 

Add the custom post type of this publication type to the main query.

To be added to the 'pre_get_posts' action.

Parameters

\WP_query $query

The current query to which the post type is potentially to be added.

add_custom_post_types_to_rss_feed()

add_custom_post_types_to_rss_feed(array  $request) 

Add the custom post type of this publication to the rss feed.

To be added to the 'request' filter.

Parameters

array $request

The request to which this post type is maybe to be added.

the_author_feed()

the_author_feed(string  $display_name) 

Modify the author reported on the feed for publication posts.

To be added to the 'the_author' filter.

Parameters

string $display_name

Original author name.

get_doi()

get_doi(integer  $post_id) 

Get the DOI of the post with id $post_id.

Parameters

integer $post_id

The id of the post for which to get the doi.

get_volume()

get_volume(integer  $post_id) 

Get the volume of the post with id $post_id.

Parameters

integer $post_id

The id of the post for which to get the volume.

get_page()

get_page(integer  $post_id) 

Get the page of the post with id $post_id.

Parameters

integer $post_id

The id of the post for which to get the page.

get_formated_citation()

get_formated_citation(integer  $post_id) 

Get how this $post_id should be cited.

Parameters

integer $post_id

Id of the post for which the formated citation is to be returned

generate_crossref_xml_doi_batch_id()

generate_crossref_xml_doi_batch_id(integer  $post_id, string  $timestamp) 

Generate a doi batch id for coressref

Cossref requires us to generate a unique id for each doi batch submission. Here we do this by adding a timestamp to the doi of the post we want to register.

Parameters

integer $post_id

Id of the post for which to generate the doi batch id.

string $timestamp

Timestamp of the submission for which the requested batch id is to be used.

generate_crossref_xml()

generate_crossref_xml(integer  $post_id, string  $doi_batch_id,   $timestamp) 

Generate an xml representation of the meta-data of that post suitable for crossref.

This function return a string containing xml formated meta-data about the given $post_id that can be uploaded to and then processed by Crossref.

See https://www.crossref.org/education/content-registration/crossrefs-metadata-deposit-schema/crossref-xsd-schema-quick-reference/ for the documentation of the Corssref XML scheme.

Parameters

integer $post_id

Id of the post for which the crossref xml is to be generated.

string $doi_batch_id

Batch id of the submission for which the crossref xml is to be generated.

$timestamp

generate_clockss_xml()

generate_clockss_xml(integer  $post_id) 

Generate xml suitable for the submission to CLOCKSS

This function returns a string containing xml formated according to the JATS scheme suitable for CLOCKSS.

Parameters

integer $post_id

Id of the post for which to generate the clockss xml.

generate_doaj_json()

generate_doaj_json(integer  $post_id) 

Generate json suitable for the submission to DOAJ

This function returns a json encoded string containing the meta-data in a format suitable for DOAJ.

TODO: Clean this up once we got some feedback from DOAJ

Parameters

integer $post_id

Id of the post for which to generate the the json encoded meta-data.

the_java_script_single_page()

the_java_script_single_page() 

Outputs some java script for the single page of this publication type.

To be added to the 'wp_head' action.

get_formated_volume_html()

get_formated_volume_html(integer  $post_id) 

Outptus the html formated volume of this publication type.

Parameters

integer $post_id

Id of the post.

get_formated_bibliography_html()

get_formated_bibliography_html(integer  $post_id) 

Echo the html formated bibliography.

Parameters

integer $post_id

Id of the post.

get_formated_bibliography_entry_html()

get_formated_bibliography_entry_html(array  $entry) 

Get a formated bibliography entry.

Expects a entry of a bibliography such as those that can be obtained via O3PO_Latex::parse_bbl() from bbl code.

Parameters

array $entry

Array describing the bibliography entry.

get_bibliography_html()

get_bibliography_html(integer  $post_id) 

Get the thml formated bibliography.

Includes a heading for use in the single templates and the like.

Parameters

integer $post_id

Id of the post.

get_formated_cited_by_html()

get_formated_cited_by_html(integer  $post_id) 

Get the html formated cited information.

Parameters

integer $post_id

Id of the post.

get_cited_by_data()

get_cited_by_data(integer  $post_id, boolean  $fetch_if_outdated = true) : array

Get cited-by data.

Parameters

integer $post_id

Id of the post.

boolean $fetch_if_outdated

Whether to fetch new data from remote services if the cached data is considered outdated (default true).

Returns

array —

Array containing cited-by data in various formats.

get_cited_by()

get_cited_by(integer  $post_id) 

Get the html formated cited by information.

Echos the cited-by date including a heading for use in the single templates and the like.

Parameters

integer $post_id

Id of the post.

generate_bibtex()

generate_bibtex(integer  $post_id) 

Generate a BibTeX representation of the meta-data of $post_id

Parameters

integer $post_id

Id of the post.

get_bibtex_html()

get_bibtex_html(integer  $post_id) 

Get the html formated bibtex data.

Gets the bibtex data and a suitable caption. To be used in the single templates.

Parameters

integer $post_id

Id of the post.

get_popular_summary()

get_popular_summary(integer  $post_id) 

Get the polupar summary.

Get the popular summary if available. To be used in the single templates.

Parameters

integer $post_id

Id of the post.

get_formated_authors()

get_formated_authors(integer  $post_id) 

Get the formatted authors.

Return the list of authors in first name last name format, seperated by commas and the word 'and' including an oxford comma.

Parameters

integer $post_id

Id of the post.

get_formated_authors_bibtex()

get_formated_authors_bibtex(integer  $post_id) 

Get the authors BibTeX formatted.

Parameters

integer $post_id

Id of the post.

get_license_information()

get_license_information(integer  $post_id) 

Get the license_information.

Parameters

integer $post_id

Id of the post.

get_formated_authors_html()

get_formated_authors_html(integer  $post_id) 

Get the authors html formated.

Returns html formated authors with affiliations indicated as superscripts.

Parameters

integer $post_id

Id of the post.

get_formated_affiliations_html()

get_formated_affiliations_html(integer  $post_id) 

Echo the afiliations html formated.

Html formated list of affiliations with superscript number consistent with those of get_formated_authors_html().

Parameters

integer $post_id

Id of the post.

get_formated_date_published()

get_formated_date_published(integer  $post_id) 

Get publication date formated.

Returns a nicely formted version of the publication date. Currently this is set to the initernational format YYYY-MM-DD.

Parameters

integer $post_id

Id of the post.

admin_page_extra_css()

admin_page_extra_css(integer  $post_id = null) 

Adds css to the amin area to hide the WordPress title field for the associated post type to avoid confusion.

To be added to the 'admin_head' action.

Parameters

integer $post_id

The Id of the post that is views (defaults to null). If left empty global $post is used.

get_post_meta_field_containing_array()

get_post_meta_field_containing_array(integer  $post_id, string  $key) 

Get a post meta field that is expected to contain an array.

Contrary to get_post_meta($post_id, $key, true ) this returns an emty array() if the key is unset. This allows to directly add to the array with the [] notation even on php >= 7.1, wich no longer allows this notation on strings.

Parameters

integer $post_id

The Id of the post whose meta field is to be retreived.

string $key

The key that is to be retreived.

get_fulltext_pdf_path()

get_fulltext_pdf_path(integer  $post_id) 

Get the path of the fulltext pdf.

To be overwerites in subclasses. May return null if the subclass has no fulltext pdf.

Parameters

integer $post_id

Id of the post.

get_pdf_pretty_permalink()

get_pdf_pretty_permalink(integer  $post_id) 

Get the pretty permalink of the pdf associated with a post.

To be overwerites in subclasses. May return null if the subclass has no fulltext pdf.

Parameters

integer $post_id

Id of the post.

get_the_author()

get_the_author(string  $display_name) 

Fake the author.

To be added to the 'the_author' filter.

Parameters

string $display_name

Display name to be filtered.

get_the_author_posts_link()

get_the_author_posts_link(string  $link) 

Fake the author post link.

To be added to the 'the_author_posts_link' filter.

Parameters

string $link

Link to be filtered.

use_page_template()

use_page_template(string  $template) : string

Force the usage of the page template for publication posts.

To be added to the 'template_include' action.

Parameters

string $template

The template that would be used.

Returns

string —

Template that should be used.

get_corresponding_author_email()

get_corresponding_author_email(integer  $post_id) 

Get the email of the corresponding author.

Parameters

integer $post_id

Id of the post.

get_number_authors()

get_number_authors(integer  $post_id) 

Get the number of authors.

Parameters

integer $post_id

Id of the post.

get_title()

get_title(integer  $post_id) 

Get the title.

Parameters

integer $post_id

Id of the post.

get_post_meta()

get_post_meta(integer  $post_id, string  $field) 

Get a meta data field.

Parameters

integer $post_id

Id of the post.

string $field

The field to get.

get_date_published()

get_date_published(integer  $post_id) 

Get date published.

Parameters

integer $post_id

Id of the post.

get_all_citation_counts()

get_all_citation_counts(boolean  $fetch_if_outdated = false) : array

Get the citation counts for all publications of the given type.

Parameters

boolean $fetch_if_outdated

Whether to fetch new data if the currently cached one is considered outdated.

Returns

array —

Array with information about citation counts.

get_basis_for_excerpt()

get_basis_for_excerpt(integer  $post_id) : \The

Get the text basis for the text part of the excerpt

To be overwritten in any sub-class.

Parameters

integer $post_id

The ID of the post.

Returns

\The —

basis for the text of the excerpt.

get_the_excerpt()

get_the_excerpt(string  $content) 

Get the excerpt of a this publication type.

As we modify the content in get_the_content() we construct the excerpt from scratch,

To be added to the 'get_the_excerpt' filter.

Parameters

string $content

Content to be filtered.

html_latex_excerpt()

html_latex_excerpt(string  $str, integer  $count, string  $more = null) : string

Excerpt from a string with html and LaTeX

Safely extracts not more than the first $count characters from a string containing html and LaTeX code (including mathematical formulas).

Parameters

string $str

String to get the excerpt from.

integer $count

Maximum number of characters to take.

string $more

(Optional) What to append if $str needs to be trimmed. Defaults to empty string. Default value: null

Returns

string —

The excerpt.

get_social_media_thumbnail_src()

get_social_media_thumbnail_src(integer|\WP_Post  $post_id) : string

Get the src of the feature image.

Parameters

integer|\WP_Post $post_id

Id of the post for which to get the social media thumbnail src.

Returns

string —

Src of the social media thumbnail.

save_meta_data()

save_meta_data(integer  $post_id) 

Obtain the data entered into the meta-data metabox from the $_POST, sanitize it, set defauls, and save it.

Parameters

integer $post_id

The id of the post.

validate_and_process_data()

validate_and_process_data(integer  $post_id) 

Validate and process the meta-data that was saved in save_meta_data().

We also trigger interactions with external services (Crossref, DOAJ, CLOCKSS) here.

Parameters

integer $post_id

The id of the post.

on_post_actually_published()

on_post_actually_published(integer  $post_id) 

Do things when the post is finally published.

Is called from validate_and_process_data().

Parameters

integer $post_id

Id of the post that is actually beeing finally published publicly.

the_admin_panel_intro_text()

the_admin_panel_intro_text(integer  $post_id) 

Echo an intro text for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_validation_result()

the_admin_panel_validation_result(integer  $post_id) 

Echo the validation results for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_corresponding_author_email()

the_admin_panel_corresponding_author_email(integer  $post_id) 

Echo the corresponding author emial for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_buffer()

the_admin_panel_buffer(integer  $post_id) 

Echo an intro text for buffer functionality on the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_title()

the_admin_panel_title(integer  $post_id) 

Echo the title for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_authors()

the_admin_panel_authors(integer  $post_id) 

Echo the authors for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_affiliations()

the_admin_panel_affiliations(integer  $post_id) 

Echo the affiliations for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_date_volume_pages()

the_admin_panel_date_volume_pages(integer  $post_id) 

Echo the data, volume and pages information for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_doi()

the_admin_panel_doi(integer  $post_id) 

Echo the DOI for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_bibliography()

the_admin_panel_bibliography(integer  $post_id) 

Echo the bibliography for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_crossref()

the_admin_panel_crossref(integer  $post_id) 

Echo crossref information for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_doaj()

the_admin_panel_doaj(integer  $post_id) 

Echo the DOAJ information for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_clockss()

the_admin_panel_clockss(integer  $post_id) 

Echo the CLOCKSS information for the admin panel.

Parameters

integer $post_id

Id of the post.

the_admin_panel_funder_information()

the_admin_panel_funder_information(integer  $post_id) 

Echo the funder information for the admin panel.

Parameters

integer $post_id

Id of the post.

post_update_on_buffer_com_if_not_already_done()

post_update_on_buffer_com_if_not_already_done(integer  $post_id) : string

Put an update about the given publication post in the queue of buffer.com.

Parameters

integer $post_id

Id of the post.

Returns

string —

The validation_result of the upload.

upload_meta_data_to_crossref()

upload_meta_data_to_crossref(string  $doi_batch_id, string  $crossref_xml, string  $crossref_id, string  $crossref_pw, string  $crossref_url) 

Submit meta-data to Crossref.

This function must be private since we do no longer check internally whether we are running on the test system.

Parameters

string $doi_batch_id

Batch id of this upload.

string $crossref_xml

The xml to upload.

string $crossref_id

The id for which to submit this upload.

string $crossref_pw

The password corresponding to the crossref_id.

string $crossref_url

The url of the crossref server to upload to.

upload_meta_data_to_doaj()

upload_meta_data_to_doaj(string  $doaj_json, string  $doaj_api_url, string  $doaj_api_key) 

Submit meta-data to DOAJ.

From the command line you could do rouhgly the smame via:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "[json goes here]" "https://doaj.org/api/v1/articles?api_key=XXX" see https://doaj.org/api/v1/docs#/ for more infomation.

DOAJ has no test system, so that we can only get a response from the real system once we publish the final and actual record.

This function must be private since we do no longer check internally whether we are running on the test system.

Parameters

string $doaj_json

The JSON encoded meta-data to upload.

string $doaj_api_url

The url of the DOAJ api to upload to.

string $doaj_api_key

The API key with DOAJ

upload_meta_data_and_pdf_to_clockss()

upload_meta_data_and_pdf_to_clockss(string  $clockss_xml, string  $pdf_path, string  $remote_filename_without_extension, string  $clockss_ftp_url, string  $clockss_username, string  $clockss_password) 

Submit meta-data and full text to CLOCKSS.

Upload an xml file with the meta-data and the full text pdf to CLOCKSS.

CLOCKSS has no test system, so that we can only get a response from the real system once we publish the final and actual record.

This function must be private since we do no longer check internally whether we are running on the test system.

Parameters

string $clockss_xml

The xml encoded meta-data to upload.

string $pdf_path

Path to the local fulltext pdf

string $remote_filename_without_extension

Filename without extension under which the files are to be deposited on the remore server

string $clockss_ftp_url

The url of the CLOCKSS ftp server.

string $clockss_username

The CLOCKSS username

string $clockss_password

The CLOCKSS password