This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getColumnNumberByName(name, sheet) { | |
if (!sheet) { | |
sheet = SpreadsheetApp.getActiveSheet() | |
} | |
var headers = sheet.getDataRange().offset(0, 0, 1).getValues()[0] | |
var column = false | |
for (var i = 0; i < headers.length; i++) { | |
if (headers[i].trim() === name) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Parses $argv to get the command, arguments, options, and flags. | |
* | |
* @param array $args The $argv variable. | |
* @param array $short_opts Optional. An array with keys set to short options and their values set to the long option they're assigned to. | |
* @param array $flag_opts Optional. An array of options to be treated as flags. If a flag is not defined here, it will be treated as an option. | |
* | |
* @return array An array with the command, arguments, options, and flags keys. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* =WordPress Core | |
-------------------------------------------------------------- */ | |
.alignnone { | |
margin: 5px 20px 20px 0; | |
} | |
.aligncenter, | |
div.aligncenter { | |
display: block; | |
margin: 5px auto 5px auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Use a datalist in place of a select dropdown for wp_dropdown_users | |
add_filter('wp_dropdown_users', 'wp_dropdown_users_datalist'); | |
function wp_dropdown_users_datalist($html) { | |
preg_match("/name='(.*?)'/", $html, $name); | |
preg_match("/id='(.*?)'/", $html, $id); | |
$html = str_replace(array('<select', '/select>'), array('<datalist', '/datalist>'), $html); | |
$html = preg_replace("/id='$id[1]'/", "id='$id[1]-list'", $html); | |
$html = preg_replace("/name='$name[1]'/", '', $html); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin fancy-bottom-border($border-color: 'blue', $border-size: 4px, $line-height: 1rem) { | |
$bg-stop: calc(#{$line-height} - #{$border-size}); | |
background-image: linear-gradient(to bottom, transparent $bg-stop, $border-color $bg-stop, $border-color $line-height); | |
background-repeat: repeat-y; | |
background-size: 100% $line-height; | |
line-height: $line-height; | |
text-decoration: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Generate an email verification code and send it to their email | |
add_action('user_register', 'send_new_user_email_verification', 10, 1); | |
function send_new_user_email_verification($user_id) { | |
$user = get_userdata($user_id); | |
$email = $user->user_email; | |
$site_name = get_bloginfo('name'); | |
$code = wp_generate_password(32, false, false); | |
$hash = md5($code); | |
$link = add_query_arg(array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array map function that allows you to change keys as well as values | |
// Example: array_map_assoc(function($k, $v) { return array($k => $v); }, $array); | |
function array_map_assoc(callable $f, array $a) { | |
return array_merge(...array_map($f, array_keys($a), $a)); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Adds an "image_size" argument to get_avatar_data so that avatar image sizes | |
// can be defined by the image size name (requires the get_image_sizes function) | |
// (https://gist.github.com/kodie/19d027d2c0e2297d1e09b7b71505e774) | |
// Example: get_avatar_url($user_id, array('image_size' => 'thumbnail')); | |
add_filter('pre_get_avatar_data', 'avatar_data_image_size_arg', 10, 2); | |
function avatar_data_image_size_arg($args, $id_or_email) { | |
if (isset($args['image_size'])) { | |
if ($size = get_image_sizes($args['image_size'])) { | |
$args['height'] = $size['height']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Allows for custom avatars to be pulled from usermeta | |
add_filter('get_avatar_url', 'custom_user_avatar_url', 10, 3); | |
function custom_user_avatar_url($url, $id_or_email, $args) { | |
$image_url = false; | |
$user = false; | |
if (is_object($id_or_email) && isset($id_or_email->comment_ID)) { | |
$id_or_email = get_comment($id_or_email); | |
} |