Skip to content

Instantly share code, notes, and snippets.

View stephenscaff's full-sized avatar

Stephen Scaff stephenscaff

View GitHub Profile
@stephenscaff
stephenscaff / wp-debuggers.php
Last active July 9, 2018 16:13
Debugger Utilities for Wp.
/**
* Formated Dumper (tee hee)
* @return {string} a parsable string representation of a variable
*/
function jumpoff_dump( $var, $name = '' ) {
echo '<pre>';
if ( '' !== $name ) {
echo $name . ': ';
}
var_export( $var );

Fields attributes cheatsheet

Overview of ACF field attributes to assist with field authorship via StoutLogic's Acf Builder.

Full description about registering ACF Fields for PHP is available her: Register fields via PHP

Construct Group

Default group attributes and group construction

@stephenscaff
stephenscaff / gmaps-helpers.js
Last active July 6, 2018 22:06
Google Maps API Helpers
/**
* Get Lat Lng from Address via gmaps geocode api
* results[0].geometry.location.lat(), results[0].geometry.location.lng()
*/
function geocodeAddress() {
var address = getAddress();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == 'OK') {
//console.log(results);
@stephenscaff
stephenscaff / NoConcurrentSessions.php
Created July 3, 2018 20:06
Prevent Concurrent Sessions in Wordpress, leveraging WP_Session_Tokens and wp_destroy_other_sessions() / wp_destroy_current_sessions().
/**
* No Current Sessions
* Simple class to prevent concurrent user sessions.
*/
class NoConcurrentSessions {
function __construct() {
add_action( 'init', array( $this, 'only_one' ) );
}
@stephenscaff
stephenscaff / ssl.conf
Created July 3, 2018 17:56
Apache Module mod_ssl (/etc/apache2/mods-available/ssl.conf. Install mod_ssl if need be. Restart apache after changes to config.
<IfModule mod_ssl.c>
# Enable TLSv1.2, disable SSLv3.0, TLSv1.0 and TLSv1.1
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
# Enable modern TLS cipher suites
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
# The order of cipher suites matters
SSLHonorCipherOrder on
@stephenscaff
stephenscaff / http-auth.php
Created June 30, 2018 16:09
PHP HTTP Auth
<?php
/**
* Authentication Login
* @link http://php.net/manual/en/features.http-auth.php
*/
if ( ! defined( 'ABSPATH' ) ) exit;
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
if ($_SERVER['PHP_AUTH_USER'] != 'admin' ||
@stephenscaff
stephenscaff / mysql.config
Created June 13, 2018 17:06
AMPPS MySQL not starting hotfix
# Open Ampps Application -> MySQL Tab -> Configuration.
# In [mysqld] section, add line:
innodb_force_recovery = 1
# If successful, comment out line.
@stephenscaff
stephenscaff / chatbox-integration.html
Created June 7, 2018 20:04
chatbox integration example
<button class="js-chat-btn btn-chat">
<svg class="btn-chat__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 426.667 426.667" width="25" height="25"><path d="M384 0H42.667C19.093 0 0 19.093 0 42.667v384l85.333-85.333H384c23.573 0 42.667-19.093 42.667-42.667v-256C426.667 19.093 407.573 0 384 0z" fill="#FFF"/></svg>
<span class="btn-chat__text">Live Chat?</span>
</button>
<style>
.btn-chat {
position: fixed;
left: 1em;
bottom: 1em;
@stephenscaff
stephenscaff / cookie-notice.html
Last active May 29, 2018 17:31
Function to print Cookie Consent notice to wp_footer. Intended for functions.php. Check options. Demo: https://codepen.io/StephenScaff/pen/OZeGYz/
@stephenscaff
stephenscaff / .htaccess
Created May 9, 2018 16:23
# Block WordPress xmlrpc.php requests
# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>