Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom doi resolver url #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Custom doi resolver url #71

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 7, 2017

We are using teachPress in one of our projects and we had to add the possibility to define a custom doi resolver url (e.g. Google Scholar) which is currently hardcoded in the core/template.php file.

It would be great if this functionality could be officially added to this plugin.

Please note, there are still the following things missing since I didn't know how to implement them properly (any help here would be highly appreciated):

  1. Adding the necessary configuration values holding the default and custom doi resolver url template in the wp_teachpress_settings table during an update of the plugin.

  2. Translation of new labels

  3. Versioning in code comments

Best regards, Matthias

@ghost ghost changed the title Allows to define a custom doi resolver Custom doi resolver url Sep 7, 2017
winkm89 added a commit that referenced this pull request Sep 16, 2017
@ghost
Copy link
Author

ghost commented Sep 17, 2017

Hello,

the solution in ab73d45 is simpler in terms of changes to the codebase and it makes the modification of the DOI resolver base URL easiers since it is not "hidden" away deep down in the source code, however I still see problems with this approach:

(1) The value of the constant can be changed editing the teachpress.php directly. The problem is that these changes will be overriden when the plugin gets updated.

(2) The value of the constant can be changed by re-defining the constant in wp-config.php. However, this requires file access to the server of the Wordpress installation which cannot be guaranteed.

I therefore think that a GUI/DB-based approach in implementing this feature is the better solution.

Regards, Matthias

Matthias Einbrodt added 2 commits September 25, 2017 13:48
Copy link
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added possibility to specifiy a custom, possibly more human-readable label for the DOI link

@@ -825,9 +836,11 @@ private static function change_general_options () {
private static function change_publication_options () {
$checkbox_convert_bibtex = isset( $_POST['convert_bibtex'] ) ? 1 : '';
$checkbox_import_overwrite = isset( $_POST['import_overwrite'] ) ? 1 : '';
$doi_resolver_url_template_custom = isset( $_POST['doi_resolver_url_template_custom'] ) ? esc_url_raw( $_POST['doi_resolver_url_template_custom'] ) : '';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sanitized the custom doi resolver url template using the esc_url_raw function which is build into WP. Is this enough?

See here: https://codex.wordpress.org/Function_Reference/esc_url_raw

* Prepares a doi url
* @param string $doi The DOI number
* @return string
* @since 6.x.x
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version should I put here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants