diff --git a/citations-tools.php b/citations-tools.php new file mode 100644 index 0000000..bfc84ab --- /dev/null +++ b/citations-tools.php @@ -0,0 +1,74 @@ + null + ), + $atts + ) + ); + + $link = ''.$content.''; + + return $link; +} + +# doi resolve +add_shortcode('doiresolve', 'doiresolve'); + + function doiresolve ($atts, $content = null) { + + extract( + shortcode_atts( + array( + 'code' => null, + 'arxiv' => null, + 'pdfurl' => null + ), + $atts + ) + ); + + $fullCitation = null; + $getfile = 'https://search.crossref.org/dois?sort=score&page=1&rows=1&q='.$code; + $jsondata = file_get_contents($getfile); + $array = json_decode($jsondata,true); + $item=$array[0]; + $doi = $item['doi']; + $coins = $item['coins']; + $fullCitation =$item['fullCitation']; + + $citation = '

'.$fullCitation.' doi:'.$code.''; + + if ( $arxiv <> null ) + {$citation = $citation.' (arXiv)';} + else + {$citation = $citation;} + + if ( $pdfurl <> null ) + {$citation = $citation.' (pdf)';} + else + {$citation = $citation;} + + $results = $citation.'

'; + + return $results; +} +/* ------------------------------------------------------ */ diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..502a565 --- /dev/null +++ b/readme.txt @@ -0,0 +1,44 @@ +=== Citations tools === +Contributors: ulaulaman +Tags: doi, citations, research +Requires at least: 4.8.5 +Tested up to: 4.9.2 +Requires PHP: 7.0.18 +Stable tag: trunk +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +The plugin add some shortcodes add a link to a paper using the doi code or to resolve doi code and publish a full citation apa formatted. + +== Description == +Using the standard for doi link, the plugin introduce a shortcode in order to create a link to a paper provided by doi. +How to use the shortcode: + +[doi code="..."]Title of the paper[/doi] + +Using the [crossref.org](https://www.crossref.org/) api, the plugin add also a shortcode that resolve a doi code and publish a full citation formatted using the apa standard. +How to use the shortcode: + +[doiresolve code="..."] + +There are also two optional parameters: + +[doiresolve code="..." arxiv="..."] + +if the paper has an arXiv version + +[doiresolve code="..." pdfurl="..."] + +if the paper has a free pdf version + +== Installation == +1. Extract the citations-tools.zip file and upload its contents to the /wp-content/plugins/ directory. Alternately, you can install directly from the Plugin directory within your WordPress Install. +2. Activate the plugin through the "Plugins" menu in WordPress. +3. Use the shortcode into your posts or pages. + +== Changelog == +0.2.3 add pdf link in doi resolver as ahortcode's parameter +0.2.2 add arXiv link in doi resolver as shortcode's parameter +0.2.1 add doi link in doi resolver +0.2 add shortcode to resolve doi using code +0.1 shortcode for doi link