Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
#WordPress

Matthias Pfefferle pfefferle

👨‍💻
#WordPress
View GitHub Profile
View rss.gs
function doGet() {
// What is the original language of the RSS Feed
var fromLang = "de";
// What is the destination language
var toLang = "en";
// Enter the full URL of the RSS feed
var rssFeed = "https://notiz.blog/feed/";
View tw.txt
# | |___ _| |___ _| |_
# | __\ \ /\ / / __\ \/ / __|
# | |_ \ V V /| |_ > <| |_
# \__| \_/\_/ \__/_/\_\\__|
#
# Twtxt is an open, distributed
# microblogging platform that
# uses human-readable text files,
# common transport protocols, and
# free software.
View result.json
{
"tests": "10825",
"failures": "0",
"errors": "3",
"time": "164.350793",
"testsuites": {
"WP_REST_Plugins_Controller_Test": {
"name": "WP_REST_Plugins_Controller_Test",
"tests": "36",
"failures": "0",
View webmention.php
function webmention_url_to_postid( $url ) {
$id = wp_cache_get( base64_encode( $url ), 'webmention_url_to_postid' );
if ( $id ) {
return apply_filters( 'webmention_post_id', $id, $url );
}
if ( '/' === wp_make_link_relative( trailingslashit( $url ) ) ) {
return apply_filters( 'webmention_post_id', get_option( 'webmention_home_mentions' ), $url );
}
View wordpress.php
<?php
// get private key
$key = get_user_meta( 1, 'magic_sig_private_key', true );
$date = gmdate('D, d M Y H:i:s T');
$signed_string = "(request-target): post /inbox\nhost: mastodon.social\ndate: $date";
$signature = null;
openssl_sign( $signed_string, $signature, $key, OPENSSL_ALGO_SHA256 );
$signature = 'keyId="https://pfefferle.org/author/pfefferle/#main-key",algorithm="rsa-sha256",headers="(request-target) host date",signature="' . base64_encode( $signature ) . '"';
View feed.json
{
"items": [
{
"type": [
"h-feed"
],
"properties": {
"name": [
"test"
],
View mf2.json
{
"items": [
{
"type": [
"h-entry"
],
"properties": {
"in-reply-to": {
"type": [
"h-cite"
View is_valid_mf2_json.php
<?php
function is_valid_mf2_json($input) {
// Input to this function must be an array
if(!is_array($input))
return false;
// Keys type and properties are required at a minimum and must be arrays
if(!isset($input['type']) || !is_array($input['type']))
return false;
View functions.php
<?php
function zenpress_child_setup() {
// This theme supports a custom header
$custom_header_args = array(
'width' => 1250,
'height' => 600,
'header-text' => true,
);
add_theme_support( 'custom-header', $custom_header_args );
}
View screengui.html
<style type="text/css">
article { width: 100%; }
article p { width: 800px; margin: 0 auto; }
article figure { width: 2500px; margin: 0 auto; }
</style>
<article>
<p>Lorem Ipsum...</p>
<figure>
<img src="/img.png" alt="demo image" />