Skip to content

Instantly share code, notes, and snippets.

@mediaformat
mediaformat / gist:e13dc652a0b79226a0e1
Created August 3, 2015 17:37
Test if page is a specific view in page.tpl.php
<?php
$view = views_get_page_view();
if(isset($view) && $view->name == 'VIEWS_MACHINE_NAME') : ?><!-- Do Something -->
<?php endif; ?>
@mediaformat
mediaformat / phpstorm-node_sass-config.txt
Created June 21, 2017 13:39
node-sass with sourcemap in phpstorm
Getting node-sass to output a sourcemap took a bit of trial & error
Mostly because phpstorm does not allow for the same colon syntax that most sources reference,
specifically the Output paths to reference only took 1 argument
---
Add File Watcher SCSS in settings
Watcher Settings
Program :
C:\Users\%username%\AppData\Roaming\npm\node-sass.cmd
Arguments :
--no-cache --update --source-map=$FileNameWithoutExtension$.css.map $FileName$ $FileNameWithoutExtension$.css
@mediaformat
mediaformat / add-wordpress-settings-page.php
Created February 16, 2018 19:43 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
175yQ2Mi94vnh3AWbsda37DfTp1Cxtc8cW https://explorer.blockstack.org/address/175yQ2Mi94vnh3AWbsda37DfTp1Cxtc8cW
version: '3'
services:
db:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
@mediaformat
mediaformat / CSS_cache_busting_WP.php
Last active June 6, 2018 20:07
Poor man's CSS cache busting in WP
<?php
function wp_scripts() {
//Internal cache tracking
wp_enqueue_style( 'theme-style', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() .'/style.css' ), 'all' );
//External cache tracking
wp_enqueue_style( 'global-styles', 'https://example-assets.com/css/global_styles.css', array(), strtotime( wp_remote_retrieve_header( wp_remote_get( 'https://example-assets.com/css/global_styles.css'), 'last-modified' ) ) );
}
?>
@mediaformat
mediaformat / .htaccess
Last active August 22, 2018 19:37
wordpress local development using images/uploads from production
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# custom rules for loading server images or any other uploaded media files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule ^.*/uploads/(.*)$ https://example.com/wp-content/uploads/$1 [L,R=301,NC]
@mediaformat
mediaformat / rss_cache_redudancy.php
Created November 1, 2018 20:15
RSS feed cache with redundancy
<?php
/*
* RSS Cache
* Cache: 1 hour
* Cache fallback: no expiry (not infaillible)
*/
// PROD
$newsURLall = 'https://news.example.com/';
@mediaformat
mediaformat / past_events_wpseo_tribe.php
Created May 12, 2020 15:53
auto remove past events from search engines (nofollow + sitemap) fror wpseo + tribe
<?php
// gleaned from https://wordpress.org/support/topic/remove-past-events-from-xml-sitemap/#post-11431056
/* Modify the WP-SEO plugin's defaults */
if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) {
/* add nofollow metatag to header of past events */
add_filter("wpseo_robots", function($robots) {
if (! is_singular( 'exhibition' ) && tribe_is_past_event() == true) {
return "noindex,follow";
@mediaformat
mediaformat / wp_ap_kses.txt
Created April 21, 2023 04:22
Mastodon supported rich text
p br span a del pre blockquote code b strong u i em ul ol li