Skip to content

Instantly share code, notes, and snippets.

View grok's full-sized avatar
🚀
Open to work!

Sterling Hamilton grok

🚀
Open to work!
View GitHub Profile
/**
* Excludes our theme from the WordPress update API calls.
*
* @param array $request The arguments used in an HTTP request
* @param string $url The request URL.
* @return array $request The arguments used in an HTTP request.
*/
public function excludeFromThemeUpdates($request, $url)
{
if(0 !== strpos($url, 'https://api.wordpress.org/themes/update-check'))
@grok
grok / bookmarklet.js
Last active August 29, 2015 14:16
Replicon Bookmarklet
javascript:(function(){var rows=jQuery('iframe#body').contents().find('.timesheet tr[type="time"]');rows.splice(-1,1);jQuery.map(rows,function(value,key){var that=value;var task=jQuery(value).find('.rowTask .taskPartName');var billing=jQuery(value).find('.rowBilling .additional');var task_number=jQuery(task).text().match(/\d{4}/g);var billing_numbers=jQuery(billing).text().match(/\d{4}/g);if(jQuery(billing_numbers).last().get(0)!==jQuery(task_number).last().get(0)){jQuery(that).css('background-color','#F26B6B');}else{jQuery(that).css('background-color','#6BD2F5');}});})();
@grok
grok / gist:e55e4ae71064a708c0d3
Created October 24, 2014 16:54
JIRA -- Subtasks get remaining hours.
jQuery('.issuerow .progress').click(function() {
var estimates = jQuery(this).find('img');
var hours = '';
jQuery(estimates).each(function() {
if(typeof(jQuery(this).attr('title')) != 'undefined') {
hours = hours + jQuery(this).attr('title') + "\n";
}
});
alert(hours);
});
@grok
grok / after.css
Created June 24, 2014 19:47
This is a possible solution for the overlapping on the Tesla Pre-Owned page. Example: http://imgur.com/ZoqZ1pr
.view-preowned-listing-page {
padding: 70px 18px;
}
var states = {
'online' : 'offline',
'offline' : 'online',
'trial' : 'term',
'term' : 'trial',
'active' : 'expired' ,
'expired' : 'active'
};
var button = $('.trigger');
@grok
grok / gitflow.md
Last active August 29, 2015 14:01

WordPress and WorkFlows

By: Sterling Hamilton

From time to time we invite developers who are doing interesting things on Pantheon to share what they are doing with others. This time Sterling Hamilton of Noble Studios is sharing with us what he and his team have learned about using Pantheon and workflows with WordPress.

Git Workflows

The many combinations for workflows your team can use, will no doubt make it difficult in deciding how to begin working with WordPress on Pantheon. This article is intended to provide you a an example of a simple workflow for maintaining your WordPress installation.

As you read through, remember that this is not the "end all be all" solution. This is a guideline intended to give you an immediate path to follow. You can alter, or come up with alternatives down the road.

Git Workflows

The many combinations for workflows your team can use, will no doubt make it difficult in deciding how to begin working with WordPress within Pantheon. This is intended to provide you a simple workflow for maintaining your WordPress intallation.

As you read through, remember that this is not the "end all be all" solution. This is a guideline intended to give you an immediate path to follow. You can alter, or come up with alternatives down the road.

Assumptions

  • You have created a new website.
  • You are using a WordPress distribution.
  • You have switched your connection mode to Git.
@grok
grok / gist:f1f3ecc29859ee4679b1
Created May 12, 2014 22:28
setcookie() in WordPress 3.9.1
./wp-admin/post.php: setcookie( 'wp-saving-post-' . $post_id, 'saved' );
./wp-includes/class-snoopy.php: $this->setcookies();
./wp-includes/class-snoopy.php: $this->setcookies();
./wp-includes/class-snoopy.php: Function: setcookies()
./wp-includes/class-snoopy.php: function setcookies()
./wp-includes/comment.php: setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
./wp-includes/comment.php: setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
./wp-includes/comment.php: setcookie('comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN);
./wp-includes/option.php: setcookie( 'wp-settings-' . $user_id, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH );
./wp-includes/option.php: setcookie( 'wp-settings-time-' . $user_id, time(), time() + YEAR_IN_SECONDS, SITECO
@grok
grok / get-admin-post-id.php
Created April 30, 2014 03:35
This is a really lame way to get the WordPress Post ID when on the administration screen.
<?php
// ...
// This should NOT be this difficult ... but at the moment it's what we have.
private function _get_admin_post_id()
{
return absint(isset($_GET['post']) ? $_GET['post'] : (isset($_POST['post_ID']) ? $_POST['post_ID'] : 0));
}
@grok
grok / git-update.sh
Created April 28, 2014 15:11
This was an old script I wrote, I later converted to ruby: https://github.com/grok/script-update-repositories
#!/bin/bash
# This is where I want my script to start.
cd ~/Projects/
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all directories here - that are at least 1 level down, but don't go any further than 1 directory.
# Go into those directories and pull the repository.