Skip to content

Instantly share code, notes, and snippets.

View acerus's full-sized avatar
🚀
to Infinity and Beyond!

Paul acerus

🚀
to Infinity and Beyond!
View GitHub Profile
@acerus
acerus / parallax.js
Created June 22, 2021 19:41
Simple parralax with lax.js
// parallax
import lax from 'lax.js';
const PARALLAX_ELEMENTS = document.getElementsByClassName('lax');
document.addEventListener('DOMContentLoaded', function() {
if (0 < PARALLAX_ELEMENTS.length) {
lax.init();
// Add a driver that we use to control our animations
@acerus
acerus / wordpress-semantic-urls.php
Created April 19, 2021 16:53
Create CPT with semantic URL structure (i.e. /taxonomy/term/post)
<?php
/**
* Services class file.
*
* @package WTF
*/
namespace WTF;
/**
@acerus
acerus / wordpress-mobile-auto-redirect.php
Created April 16, 2021 11:28
Auto redirect to different URLs based on mobile devices, WordPress
// Adds app redirect rules
add_action( 'wp_head', 'download' );
function download() { ?>
<script type="text/javascript">
// redirect for iPhone / iPad:
if (( navigator.userAgent.match( /iPhone|iPad|iPod/i ) )) {
@acerus
acerus / get-posts-from-all-blogs-in-multisite-wordpress-with-pagination.php
Last active March 31, 2024 16:43
Get posts from all blogs in multisite WordPress with pagination
<?php
//Querying all posts in the argument
$args = [
'post_type' => 'post',
'order' => 'DESC',
'category_name' => 'news',
'posts_per_page' => 999,
'post_status' => 'publish'
];
@acerus
acerus / addElement.js
Created April 7, 2021 11:11
Dynamically create elements (including nesting) in loops
function addElement( $tagName, $content, $class, $appendAfter, $returnNode = false ) {
// create a new div element
const newEl = document.createElement( $tagName );
if ( $class ) {
newEl.className = $class;
}
// and give it some content
if ( $tagName === 'img' ) {
@acerus
acerus / nginx.conf
Last active January 8, 2020 17:53
Get WP images on local dev environment from live site
location ~ ^/wp-content/uploads/(.*) {
try_files $uri @live_uploads;
}
location @live_uploads {
rewrite ^/wp-content/uploads/(.*)$ https://livesite.com/wp-content/uploads/$1 permanent;
}

Keybase proof

I hereby claim:

  • I am acerus on github.
  • I am acerus (https://keybase.io/acerus) on keybase.
  • I have a public key ASBuLEcUtdg5pC3H4fJxOnKZ3FHzpeRjVnKqIqcX8NVeogo

To claim this, I am signing this object:

<?php
class MyTheme
{
private function actionAfterSetup($function)
{
add_action('after_setup_theme', function() use ($function) {
$function();
});
}
@acerus
acerus / plugin-class-demo.php
Created June 28, 2019 16:01 — forked from thefuxia/plugin-class-demo.php
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: GPL
* Text Domain: plugin_unique_name