Skip to content

Instantly share code, notes, and snippets.

View tommusrhodus's full-sized avatar
🍕

Tom Rhodes tommusrhodus

🍕
View GitHub Profile
@tommusrhodus
tommusrhodus / functions.php
Created February 14, 2019 15:45
ORCID Data Scraping From WordPress
<?php
/**
* This function has zero error handling and is currently a proof of concept.
* Don't use this in a live project unless you plan on creating issues for yourself.
*/
function scholar_vitae_get_orc_id_values( $id ){
$response = wp_remote_get( 'https://pub.orcid.org/v2.1/'. $id .'/record' );
$response = preg_replace( "/(<\/?)(\w+):([^>]*>)/", "$1$2$3", wp_remote_retrieve_body( $response ) );
@tommusrhodus
tommusrhodus / functions.php
Created November 4, 2023 20:40
Converting external links to open in a new window automagically.
<?php
/**
* Filters given content to add target="_blank" to external links.
*
* @see https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-tag-processor.php/
* @see https://adamadam.blog/2023/02/16/how-to-modify-html-in-a-php-wordpress-plugin-using-the-new-tag-processor-api/
* @param string $content Content of the post.
* @return string
*/