Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
alexkingorg / laravel-5-mail-example.php
Last active August 18, 2016 13:55
Sane Laravel Mail example code
<?php
// note, to use $subject within your closure below you have to pass it along in the "use (...)" clause.
$subject = 'Welcome!';
Mail::send('emails.welcome', ['key' => 'value'], function($message) use ($subject) {
// note: if you don't set this, it will use the defaults from config/mail.php
$message->from('bar@example.com', 'Sender Name');
$message->to('foo@example.com', 'John Smith')
->subject($subject);
@alexkingorg
alexkingorg / sass-selectors.scss
Last active June 3, 2016 18:30
Use SASS variables for selectors.
// Vars - note the quotes around comma separated selectors
$a-tags: 'a, a:active, a:hover, a:visited';
$a-tags-hover: 'a:active, a:hover';
// Usage
#{$a-tags} {
color: red;
font-size: 1em;
text-decoration: none;
}
@alexkingorg
alexkingorg / .gitconfig
Created July 22, 2014 21:19
.gitconfig alias for recursively updating submodules
[alias]
subup = "!f() { git submodule sync; git submodule update --init --recursive; }; f"
@alexkingorg
alexkingorg / wp-customer-posts-per-page.php
Created January 12, 2014 17:31
Customize posts-per-page based on some condition.
<?php
// add filter for front-end requests
if (!is_admin() && !is_feed()) {
add_filter('parse_request', 'my_add_posts_per_page');
}
// add our condition-checking filter
function my_add_posts_per_page() {
add_filter('pre_get_posts', 'my_posts_per_page');
@alexkingorg
alexkingorg / register-all-postmeta.php
Created January 7, 2014 18:55
Register all WP postmeta keys using the [CF Revision Manager](https://github.com/crowdfavorite/wp-revision-manager)
<?php
global $wpdb;
$keys = $wpdb->get_col("
SELECT DISTINCT meta_key
FROM $wpdb->postmeta
");
foreach ($keys as $key) {
@alexkingorg
alexkingorg / column-view-default-hack.js
Created December 11, 2013 18:23
Replace default link with Column View
jQuery(function($) {
$('#menu-pages > a[href="edit.php?post_type=page"]')
.attr('href', 'edit.php?post_type=page&page=cf-admin-column-view-page');
})
@alexkingorg
alexkingorg / .gitconfig
Last active December 21, 2015 02:38
Some gitconfig aliases. #git
[alias]
up = "pull --rebase"
pullmerge = "pull --no-rebase"
subup = "!f() { git submodule sync; git submodule update --init --recursive; }; f"
subreset = "submodule foreach 'git reset --hard HEAD'"
who = shortlog -s --
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
info = remote -v
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..@{u})
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' @{u}..)
@alexkingorg
alexkingorg / github-activity-feed.php
Last active December 19, 2015 17:29
Pull GitHub activity feed into WordPress and output the items of interest.
<?php
$feed = fetch_feed('https://github.com/alexkingorg.atom');
// some activity isn't interesting enough to output
$ignore_types = array(
'issue_comment',
'watch',
);
@alexkingorg
alexkingorg / project-group-shortcode.php
Created July 13, 2013 17:27
Shortcode to output projects by group.
<?php
function akv3_project_group_shortcode($atts) {
extract(shortcode_atts(array(
'group' => null,
'description' => null,
), $atts));
if (empty($group)) {
return '';
}
@alexkingorg
alexkingorg / project-post-ids.php
Created July 13, 2013 17:16
Apply projects to existing posts.
<?php
function akv3_apply_projects_terms() {
$project_posts = array();
$project_posts['threads'] = array(16176);
$project_posts['carrington-build'] = array(16291, 13738, 5657, 5608, 4956, 4547, 4556, 4509);
$project_posts['carrington-core'] = array(12784, 14179, 13830, 13730, 13602, 12784, 5168, 5058, 4507, 4343, 3968, 3576, 3566, 3549, 3536, 3512, 3454, 3424, 3391, 3314, 3315, 3303, 3294, 3290, 3283, 3260, 3233, 3228, 3219, 3208);
$project_posts['sharethis'] = array(3133, 3012, 2979, 2948, 2603, 2704, 2681, 2627, 2600, 2620, 2595, 2568, 2581, 2577, 2535, 2511, 2032, 2484);