Skip to content

Instantly share code, notes, and snippets.

@bcreeves
bcreeves / gist:ce79d507a28bd6e701c9152656057c4d
Last active November 19, 2019 19:55
gform filter for dynamically populating checkboxes and selects
add_filter('gform_pre_render', 'cr_add_locations_to_select_hr');
add_filter('gform_pre_validation', 'cr_add_locations_to_select_hr');
add_filter('gform_pre_submission_filter', 'cr_add_locations_to_select_hr');
add_filter('gform_admin_pre_render', 'cr_add_locations_to_select_hr');
function cr_add_locations_to_select_hr($form)
{
foreach ($form['fields'] as &$field) {
if (strpos($field->cssClass, 'edit-post-populate-locations-hr') === false) {
continue;
@bcreeves
bcreeves / post-receive
Created April 30, 2019 18:53
Laravel git hook for deployment to cpanel server
#!/bin/sh
umask 022
GIT_WORK_TREE=~/laravel git checkout -f
cd ~/laravel
scl enable ea-php72 'php artisan config:cache'
@bcreeves
bcreeves / .htaccess
Created April 30, 2019 18:49
Starter WP .htaccess file
# Block wp-config access
<files wp-config.php>
order allow,deny
deny from all
</files>
# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@bcreeves
bcreeves / add-wp-admin-user.php
Created April 30, 2019 18:47
Quick and dirty way to add yourself as user in Wordpress
<?php
add_action('init', function () {
$username = '';
$password = '';
$email = '';
// Reset pass if exist
// $id = get_user_by('email', $email)->ID;
// wp_set_password('', $id);
@bcreeves
bcreeves / sort-by-custom-field-and-non-custom-field.php
Created April 12, 2016 20:43
Wordpress sort by custom field date if it exists, otherwise sort by pub date.
<?php
$paged = get_query_var('paged', 1);
$cat = get_query_var('cat', '');
$args = [
'post_type' => 'post',
'post_status' => 'publish',
'paged' => $paged,
'cat' => $cat,