Skip to content

Instantly share code, notes, and snippets.

View MikeNGarrett's full-sized avatar
🤘
Rocking this project.

Mike Garrett MikeNGarrett

🤘
Rocking this project.
View GitHub Profile
<?php
/**
* This file will demonstrate a method to export fields to code.
* You can use this to easily create fields using the UI, export to code
* and then use in a custom module. Upon installation of the module
* your fields and instances will already be set up.
*/
// Create the fields you want using the Drupal UI.
// On the same site, go to example.com/devel/php
@MikeNGarrett
MikeNGarrett / devel-tool-export-field.php
Created October 10, 2017 16:23
Export a Drupal 7 field definition for use in custom modules.
<?php
// Found: https://steindom.com/articles/exporting-and-creating-field-definitions-drupal-7
// My new favorite developer because of this, "Now that you understand how it works, let me show you some easy tricks to incorporate this into your development workflow."
// Fill in these with your desired field details.
$entity_type = '';
$field_name = 'field_';
$bundle_name = '';
$info_config = field_info_field($field_name);
<?php
add_filter('the_content','add_my_content');
function add_my_content($content) {
$my_custom_text = '<hr><div class="patreonpara"><p><em>PARAGRAPH TEXT</em></p><a href="LINKURL" data-patreon-widget-type="become-patron-button" class="patreonbutton"><img src="FILEURL"></a></div>';
$my_custom_text_other = 'something else';
if(is_single() && !is_home()) {
if(in_category('videos')) {
$content .= $my_custom_text_other;
} else {
$content .= $my_custom_text;
@MikeNGarrett
MikeNGarrett / terminus-quick-tips.sh
Last active October 19, 2020 12:48
Quick tips for Pantheon's implementation of WordPress CLI.
# Pantheon's Terminus is awesome, but it can be frustrating when you're first getting used to the syntax.
# Some quick tips follow.
#
# The following applies for Terminus v1.4+
#
# When specifying WP CLI commands to run, separate the terminus commands from the wp cli commands with 2 dashes:
terminus remote:wp sitename.env -- command-name --flag=value "wp-content/path/to/file-name.ext"
# It also helps to wrap paths in double quotes.
;;
;; Domain: wrir.org
;; Exported: 2017-01-20 02:47:07
;;
;; This file is intended for use for informational and archival
;; purposes ONLY and MUST be edited before use on a production
;; DNS server. In particular, you must:
;; -- update the SOA record with the correct authoritative name server
;; -- update the SOA record with the contact e-mail address information
;; -- update the NS record(s) with the authoritative name servers for this domain.
@MikeNGarrett
MikeNGarrett / change-cpt-to-page.php
Last active October 20, 2016 15:10
If you need to switch a WordPress custom post type from post capability to page capability, do this.
<?php
/* This doesn't work and here's why not.
*
* The missing piece here has to do with rewrite rules.
* The registration process creates new rewrite rules during the process.
* This ensures the custom post type is set up appropriately.
* Modifying the url structure (which we're doing here) to hierarchical requires a change to the rewrite rules as well.
*
* The following is the first change you need to make. The rewrite change is not included here.
*/
@MikeNGarrett
MikeNGarrett / wp-cli-install-rec-plugins
Last active July 12, 2021 07:18
Chained WordPress CLI commands to install and activate recommended plugins.
# wordpress-seo provides ability to edit meta information and provides sitemap.
# w3-total-cache provides advanced caching no matter the server technology available.
# better-wp-security provides brute force protection and a number of WordPress enhancements.
# google-analytics-for-wordpress provides robust Google Analytics integration through the Google API.
# redirection detects 404s and 301s and allows admins to set up redirects in the WP admin.
# ewww-image-optimizer provides automatic optimization of uploaded images with local libraries instead of cloud-based services.
# backupwordpress simple backup solution that can store backups above web root.
# relevanssi provides better site search using a local index.
# cloudflare is the best. Free automatic CDN and security solution.
# jarvis is a quick search for the WordPress admin. Indespensible.
@MikeNGarrett
MikeNGarrett / categories.txt
Created September 22, 2016 15:46
iOS 10 App Store iMessages Sticker Categories
Animals & Nature
Art
Celebrations
Celebrities
Comics & Cartoons
Eating & Drinking
Emoji & Expressions
Fashion
Gaming
Kids & Family
@MikeNGarrett
MikeNGarrett / Contract Killer 3.md
Last active September 19, 2016 15:16 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@MikeNGarrett
MikeNGarrett / siege-ab.sh
Last active December 19, 2016 04:07
Load Testing Examples
# Siege attempts to recreate real traffic by using a CSV of urls to hit.
# This allows you to remove requests for assets, if you're running a CDN.
#
# c = concurrent users
# i = "like the internet would visit"
# b = benchmark (no delay needed)
# t = time
# f = file with urls 1 per line
siege -c100 -i -b -t120S -f urls.csv