Skip to content

Instantly share code, notes, and snippets.

View JoeSz's full-sized avatar

Joe JoeSz

View GitHub Profile
@JoeSz
JoeSz / is_rest.php
Created March 1, 2019 16:24 — forked from matzeeable/is_rest.php
Checks if the current request is a WP REST API request.
<?php
if (!function_exists('is_rest')) {
/**
* Checks if the current request is a WP REST API request.
*
* Case #1: After WP_REST_Request initialisation
* Case #2: Support "plain" permalink settings
* Case #3: URL Path begins with wp-json/ (your REST prefix)
* Also supports WP installations in subfolders
*
@JoeSz
JoeSz / jQueryPluginPatterns.js
Created July 5, 2019 08:00 — forked from addyosmani/jQueryPluginPatterns.js
jQuery Plugin Patterns
/*
A (very) WIP collection of optimized/recommended jQuery plugin patterns
from @addyosmani, @cowboy, @ajpiano and others.
Disclaimer:
-----------------------
Whilst the end-goal of this gist is to provide a list of recommended patterns, this
is still very much a work-in-progress. I am not advocating the use of anything here
until we've had sufficient time to tweak and weed out what the most useful patterns
@JoeSz
JoeSz / links.md
Created July 5, 2019 08:01 — forked from addyosmani/links.md
this.performance links
@JoeSz
JoeSz / listing-10-2.php
Created September 4, 2019 07:53 — forked from WordPress-Handbuch/listing-10-2.php
PHP/HTML blog snippet for proper WordPress HTML meta tag integration for social network sharing
<?php
if (is_single())
{
$title = htmlspecialchars( strip_tags( get_the_title( $post->ID ) ) );
$description = htmlspecialchars( strip_tags( get_the_excerpt( $post->ID ) ) );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$image = $thumbnail[0];
$type = 'article';
} elseif (is_page()) {
$title = htmlspecialchars( strip_tags( get_the_title( $post->ID ) ) );
@JoeSz
JoeSz / listing-18-2.php
Created September 4, 2019 08:09 — forked from WordPress-Handbuch/listing-18-2.php
WordPress hook to activate a basic maintenance mode showing a message for everybody but the administrator
function wh_maintenance_mode() {
if ( !is_user_logged_in() || !current_user_can('administrator') ) {
wp_die( 'Dritte Variante einer Wartungsseite', 'Wartung!', array( 'response' => '503'));
}
}
add_action( 'get_header', 'wh_maintenance_mode' );
\index.php
\wp-blog-header.php
\wp-load.php
\wp-config.php
\wp-settings.php
\wp-includes\load.php
\wp-includes\default-constants.php
\wp-includes\version.php
\wp-includes\compat.php
\wp-includes\random_compat\random.php
@JoeSz
JoeSz / loop-custom.php
Created June 17, 2020 07:03 — forked from kevinwhoffman/loop-custom.php
WordPress - Custom Post Type Loop
<?php
$loop = new WP_Query( array(
'post_type' => 'Property',
'posts_per_page' => -1
)
);
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
/**
* jQuery iLightBox - Revolutionary Lightbox Plugin
* http://www.ilightbox.net/
*
* @version: 2.2.3 - June 03, 2017
*
* @author: Hemn Chawroka
* http://www.iprodev.com/
*
*/
@JoeSz
JoeSz / functions.php
Created December 9, 2020 13:35 — forked from alexwcoleman/functions.php
WordPress: Redirect single custom post type to archive page.
// redirect single posts to the archive page, scrolled to the current member.
// * this is for a post type of "board_member"
add_action( 'template_redirect', function() {
if ( is_singular('board_member') ) {
// I used the two variables to put the member's name as the ID of the article
// so the redirect would automatically scroll. This can be removed.
$title = get_the_title();
$url_append = str_replace( ' ', '-', strtolower($title) );
global $post;
$redirectLink = get_post_type_archive_link( 'board_member' ) . "#" . $url_append;
@JoeSz
JoeSz / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Created January 24, 2022 19:22 — forked from Brainiarc7/VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".