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
@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 / 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 / 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.

var states = {
'online' : 'offline',
'offline' : 'online',
'trial' : 'term',
'term' : 'trial',
'active' : 'expired' ,
'expired' : 'active'
};
var button = $('.trigger');
@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;
}
@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 / 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');}});})();
/**
* 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 / functions.php
Last active August 29, 2015 14:20
I don't really like categories. I prefer tags. Let's hide what's not going to be used.
<?php
namespace ChangeMe\Theme\Modules;
class Core {
public function __construct() {
add_action('admin_init', array($this, 'disable_category_feature'));
add_filter('rewrite_rules_array', array($this, 'remove_category_rewrites'));
}
@grok
grok / hide-menu-wordpress.php
Last active October 11, 2015 23:08
WordPress: Hiding admin menu and hiding dashboard widgets.
<?php
// ...class declaration...
// function that adds these actions.
add_action('admin_menu', array(&$this, 'remove_administration_menu'));
add_action('wp_dashboard_setup', array(&$this, 'remove_dashboard_widgets'));
public function remove_administration_menu() {
global $menu;
foreach($menu as $item) {
$slug = $item[2];