Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
alexkingorg / laravel-5-mail-example.php
Last active Aug 18, 2016
Sane Laravel Mail example code
View laravel-5-mail-example.php
<?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 Jun 3, 2016
Use SASS variables for selectors.
View sass-selectors.scss
// 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 Jul 22, 2014
.gitconfig alias for recursively updating submodules
View .gitconfig
[alias]
subup = "!f() { git submodule sync; git submodule update --init --recursive; }; f"
@alexkingorg
alexkingorg / wp-customer-posts-per-page.php
Created Jan 12, 2014
Customize posts-per-page based on some condition.
View wp-customer-posts-per-page.php
<?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 Jan 7, 2014
Register all WP postmeta keys using the [CF Revision Manager](https://github.com/crowdfavorite/wp-revision-manager)
View register-all-postmeta.php
<?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 Dec 11, 2013
Replace default link with Column View
View column-view-default-hack.js
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 Dec 21, 2015
Some gitconfig aliases. #git
View .gitconfig
[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 Dec 19, 2015
Pull GitHub activity feed into WordPress and output the items of interest.
View github-activity-feed.php
<?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 Jul 13, 2013
Shortcode to output projects by group.
View project-group-shortcode.php
<?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 Jul 13, 2013
Apply projects to existing posts.
View project-post-ids.php
<?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);