Skip to content

Instantly share code, notes, and snippets.

Devin Price devinsays

View GitHub Profile
View devinsays-append-query-strings.php
<?php
function devinsays_append_query_strings( $url ) {
error_log('inital url');
error_log($url);
// If no cookie set, return.
if ( ! isset( $_COOKIE['affwp_ref'] ) ) {
return $url;
}
@devinsays
devinsays / answer.md
Created Aug 20, 2018
How to Convert a NodeList to an Array
View answer.md

Let's say you're selecting a DOM element like list items.

Option #1, use a spread:

const items = [... document.querySelectorAll('li')];

Option #2, use Array.from:

@devinsays
devinsays / timezone-laravel-fix.md
Created Jul 26, 2018
Resolving "Incorrect datetime value" in Laravel
View timezone-laravel-fix.md

While importing data into a local MySQL database in Laravel I hit this issue:

PDOException::("SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2018-03-11 02:04:15' for column 'created_at' at row 825")

The problem is due to daylight savings time (DST). In OSX MySQL is generally set to use SYSTEM time rather than UTC.

So, in my case, the issue was that datetime 2018-03-11 02:04:15 technically did not exist in CST.

@devinsays
devinsays / response.md
Created Jul 20, 2018
Support response that is not posting.
View response.md

Hi. After reviewing your site again I see that you are using a custom content type (portfolio) for the content, which is why it doesn't show up on the home page like standard posts.

You could try setting a static page as the home page and using the [portfolio] shortcode as described here: https://en.support.wordpress.com/portfolios/. However, the layout won't be the same as the standard posts.

Another option is to try another theme mentioned in that help doc that has specific portfolio content type support. These may provide better layout options for you.

Apologies for the delayed response. I typed out this whole message to you at once before, but it looks like it never finished posting.

Cheers!

@devinsays
devinsays / .htaccess
Created Mar 19, 2018
Restrict access to site to specific IPs
View .htaccess
order deny,allow
deny from all
allow from 98.6.000.111
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
@devinsays
devinsays / custom.css
Last active Mar 14, 2018
Change menu colors for Portfolio Press and Portfolio+
View custom.css
/* Menu text color and background color */
#navigation ul a,
#navigation .menu-toggle {
color: #333;
background: #f9f9f9;
}
/* Toggle menu on mobile needs padding if container background is white */
#navigation ul a,
#navigation .menu-toggle {
@devinsays
devinsays / enqueue.php
Last active Jan 28, 2018
Infinite Scroll
View enqueue.php
<?php
/**
* Load javascripts used by the theme
*/
function custom_theme_js() {
wp_register_script(
'infinite_scroll',
get_template_directory_uri() . '/js/infinite-scroll.pkgd.min.js',
array('jquery')
null,
@devinsays
devinsays / class-nf-hubspot.php
Created Jan 25, 2018
Custom Ninja Forms + Hubspot integration.
View class-nf-hubspot.php
<?php
/**
* Hubspot Integration for Ninja Forms.
*
* @package Nano
*/
class NF_Hubspot {
// Hooks into ninja_forms_after_submission
public function init() {
@devinsays
devinsays / class-nano-user-meta.php
Last active Dec 28, 2017
Adds meta fields to account profiles for business_account (wholesale) meta.
View class-nano-user-meta.php
<?php
/**
* Add extra profile fields for users in admin.
*
* @author Nano
* @version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
@devinsays
devinsays / wpesync.sh
Last active Apr 16, 2018
Script that automates some of the work involved with syncing a local development environment with the remote environment on WP Engine.
View wpesync.sh
#!/bin/bash -e
# Add an alais to your ~/.bash_profile
# alias wpesync='~/Scripts/wpesync.sh'
# Default false for flags
db=false
uploads=false
plugins=false
overwrite=false
You can’t perform that action at this time.