Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: Coauthors Plus QW Field
Description: Example of coauthors custom Query Wrangler field
Author: Jonathan Daggerhart
Version: 1.0
*/
add_filter('qw_fields', 'coauthors_plus_qw_field');
@daggerhart
daggerhart / blog-not-public-admin-notice.php
Created April 12, 2017 22:05
Very simple WordPress plugin that warns a user if their blog can not be indexed by search engines.
<?php
/*
* Plugin Name: Blog not public admin notice
* Description: Because this checkbox costs real people real money
* Version: 1.0.0
* Author: daggerhart
*/
add_action( 'wp_ajax_dismiss_blog_not_public_notice', function(){
update_option('blog_not_public_notice_dismissed', 1);
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 2f18c58..93ffef6 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -912,6 +912,7 @@ function _drupal_bootstrap($phase) {
drupal_unset_globals();
// Initialize the configuration
conf_init();
+ drupal_request_sanitizer_sanitize();
break;
@daggerhart
daggerhart / fast_machine_names.js
Created August 15, 2018 02:03
Fast machine names for Drupal 8 - hacky
(function ($, Drupal) {
delete Drupal.behaviors.machineName.transliterate;
Drupal.behaviors.machineName.transliterate = function(str) {
var transliterated = str.replace(' ', '_').replace(/[^\w]+/g,'').toLowerCase();
var deferred = $.Deferred();
var promise = deferred.promise();
deferred.resolve(transliterated);
promise.abort = function() {};
return promise;
@daggerhart
daggerhart / simple-json-api.php
Last active October 21, 2018 16:15
Simple Read-Only JSON API example for WordPress
<?php
/**
* Class Simple_Json_Api
*/
class Simple_Json_Api {
/**
* The top level argument for the endpoint.
* ex http://example.com/myjson/post/1
@daggerhart
daggerhart / template.php
Created March 21, 2019 15:13
Drupal 7 Rules UI improvements
<?php
/**
* Override the rules ui component row theme function so that we can show much
* more information about each parameter.
*
* - Changed "30" to "200" in the truncate_utf8 function call.
*
* @ingroup themeable
*/
@daggerhart
daggerhart / drupal7-force-modules-uninstall.php
Created August 16, 2014 15:48
Drupal 7 force uninstall of disabled modules.
<?php
// get disabled modules, skip 'test' modules
$modules = db_query("SELECT `name` FROM {system} WHERE TYPE = 'module' AND `status` = 0 AND `name` NOT LIKE '%test%' ORDER BY `name` DESC")->fetchCol();
// ensure disabled
module_disable($modules);
// force uninstall
foreach ($modules as $module) {
@daggerhart
daggerhart / _genCert.sh
Last active September 18, 2019 10:43
Simple script to generate a certificate used for local development on OSX
#!/bin/bash
read -p 'Domain: ' DOMAIN
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout "$DOMAIN".key \
-new \
@daggerhart
daggerhart / wordpress-missing-functions.php
Created March 24, 2016 22:19
WordPress functions that I tend to write often
<?php
/**
* Get a WP_Post object by its slug ( post_name )
*
* @param $post_name
*
* @return WP_Post|null
*/
function get_post_by_slug( $post_name ) {
@daggerhart
daggerhart / .lando.yml
Last active March 17, 2020 22:18
Example lando
name: aawp
recipe: wordpress
config:
webroot: wordpress_root
php: '7.3'
xdebug: true
config:
php: .lando/php.ini
#database: .lando/mysql.cnf
#server: .lando/apache.conf