Skip to content

Instantly share code, notes, and snippets.

@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@norcross
norcross / gist-shortcode-css.css
Created October 1, 2012 15:38
embed gist shortcode
/* Optional CSS for themes that don't wrap the pre tag properly */
div.github-gist-block pre {
background-color: #F5F5F5;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px 4px 4px 4px;
display: block;
font-size: 13px;
line-height: 20px;
margin: 0 0 10px;
padding: 9.5px;
<?php
function utm_welcome_redirect() {
// redirect anyone that is not logged in to /welcome
if ( !is_user_logged_in() )
{
wp_redirect( site_url( '/welcome' ), 303 );
die;
}
else
@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>
@barbwiredmedia
barbwiredmedia / functions.php
Last active February 23, 2023 23:55
Wordpress SEO Yoast Order meta box. This will change the priority of Yoasts meta box and move it to the bottom of all pages / posts.
// Move Yoast Meta Box to bottom
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
<?php
namespace Foo {
class Bar {
public function baz() {
return strlen('Regarding the overhead: Just keep in mind, that a typical application calls built-in functions many thousand times. Even if the difference is small: It exists.');
}
}
$start = microtime(true);
$foo = new Bar;
@mattradford
mattradford / acf_get_directions.php
Last active February 16, 2023 12:08
ACF Get Directions map link
<?php
$location = get_field('map_location');
if ( !empty( $location ) ) :
$map_url = 'https://www.google.com/maps/dir/?api=1&destination=' . $location['lat'] . ',' . $location['lng'];
echo '<a href=". esc_url( $map_url ) . '" rel="nooopener">Get directions</a>';
endif;
?>
<p>This should produce a link like this:</p>
<a href="https://www.google.com/maps/dir/?api=1&destination=51.072159,1.088130">Get directions</a>
<?php
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()