This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: application/json'); | |
if(!empty($_POST)) { | |
$post = $_POST; | |
$post = json_decode($post, true); | |
$data = file_get_contents('https://api.instagram.com/oembed/?url=' . $post['url']); | |
$data = json_decode($data, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// remove some meta tags from WordPress | |
remove_action('wp_head', 'wp_generator'); | |
function remove_dns_prefetch( $hints, $relation_type ) { | |
if ( 'dns-prefetch' === $relation_type ) { | |
return array_diff( wp_dependencies_unique_hosts(), $hints ); | |
} | |
return $hints; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function degreesToCardinal($degrees) { | |
$directions = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']; | |
$index = ($degrees + 11.25) / 22.5; | |
return $directions[$index % 16]; | |
} |
This is just a proof of concept for PHP-enabled HTML files. Instead of <?php
and ?>
tags in a PHP file, you could use {}
in an HTML file. This would allow you to create static HTML templates that use PHP functions. I'm not sure why you would want to do this instead of using normal PHP, but you could!
Sample HTML:
<p>Today's date is { date('F j, Y') }</p>
And uh..that's the only use I can think of.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Replace | |
$data = $query->fetch_all(MYSQLI_ASSOC); | |
// With | |
$rows = []; | |
while ( $row = mysqli_fetch_assoc($query) ) { | |
$rows[] = $row; | |
} | |
$data = $rows; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const MONTH = "Y-m"; // 2000-01 | |
const DAY = "Y-m-d"; // 2000-01-01 | |
const HALF_DAY = "Y-m-d-A"; // 2000-01-01-AM | |
const HOUR = "Y-m-d-H"; // 2000-01-01-24 | |
const MINUTE = "Y-m-d-H-i"; // 2000-01-01-24-60 | |
class Cache { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a email="ZW5jb2RlZEBlbWFpbC5jb20=">Enable JavaScript to view this email address</a> | |
<a email="YW5vdGhlckBlbWFpbC5jb20=">Enable JavaScript to view this email address</a> | |
<script> | |
document.querySelectorAll('[email]').forEach(email => { | |
let decodedEmail = atob(email.getAttribute('email')); | |
email.innerText = decodedEmail; | |
email.href = 'mailto:'+decodedEmail; | |
email.removeAttribute('email'); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Laravel Documentation Redirect | |
// @match https://laravel.com/docs/* | |
// @version 1.0 | |
// @author Jerome Paulos | |
// @description Automatically redirect to the latest Laravel documentation | |
// ==/UserScript== | |
(() => { | |
const latestUrl = document.querySelector('#version-switcher option[value*="/master/"] + option').value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SmoothAnimationOptions = { | |
condition: boolean, | |
addClass?: (node: HTMLElement) => void, | |
removeClass?: (node: HTMLElement) => void, | |
animationClass?: string | |
} | |
export function smoothAnimation(node: HTMLElement, { condition, addClass, removeClass, animationClass }: SmoothAnimationOptions) { | |
if(animationClass) { | |
if(!removeClass) removeClass = () => node.classList.remove(animationClass); |
OlderNewer