Skip to content

Instantly share code, notes, and snippets.

View morganestes's full-sized avatar

Morgan Estes morganestes

View GitHub Profile
@morganestes
morganestes / WordPress get_the_ID() replacement.md
Last active May 16, 2021 21:15
Get the WordPress post ID no matter where you are.

This extends the built-in WordPress function get_the_ID() to return the post ID both inside and outside the loop.

Used outside the loop (in header.php):

<?php if ( function_exists( 'gt_hide_nav' ) && ! gt_hide_nav() ) : ?>
  <nav role="navigation">
    <?php if ( function_exists( 'bones_main_nav' ) ) bones_main_nav(); ?>
  </nav>
@morganestes
morganestes / extractaudio.bash
Created May 10, 2013 21:11
Extract audio with ffmpeg
# Extract audio from a video file with ffmpeg
function extractaudio() {
video=$1
ffmpeg -i "$video" -vn -ac 2 -ar 44100 -ab 320k -f mp3 "${video%.*}.mp3"
}
@morganestes
morganestes / functions.php
Last active December 19, 2015 06:29
Register and enqueue a script in WordPress
<?php
wp_enqueue_script( 'square-main', get_stylesheet_directory_uri() . '/js/scripts.js', array( 'jquery' ), null, true );
@morganestes
morganestes / .functions
Created August 2, 2013 15:04
bash functions to make life a little easier
# Use https://github.com/mathiasbynens/dotfiles as a starting point
# Read it all before you run it or you WILL jack some things up.
# Add your extra functions to the .functions file.
# Restart terminal, or just `source ~/.functions` to refresh
@morganestes
morganestes / PHPtoICS.php
Created August 6, 2013 16:24 — forked from jakebellacera/ICS.php
Create a valid ICS file to save an event to your calendar.
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@morganestes
morganestes / functions.php
Created August 6, 2013 16:45
chat help for John234
<?php
$profile = get_the_author_meta( 'description' );
if ( $profile )
echo $profile;
else
echo 'No information';
@morganestes
morganestes / months.php
Last active December 20, 2015 18:58
Cheaters to build forms with dates.
<select id="exp-month" name="exp-month" class="span2">
<option>Month</option>
<?php
$months = array(
1 => 'Jan',
2 => 'Feb',
3 => 'Mar',
4 => 'Apr',
5 => 'May',
6 => 'June',
@morganestes
morganestes / snippets.php
Last active December 21, 2015 00:49
Add a leading zero to months 1-9 for displaying. This makes the number a string.
<?php
$month = sprintf("%02s", $month);
[
{
"command": "go_to_function",
"keys": [
"super+b"
]
}
]
{
"bold_folder_labels": true,
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"detect_slow_plugins": false,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store",
"*.scssc"
],