⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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
/* 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; |
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 | |
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 |
This extends the built-in WordPress function get_the_ID()
to return the post ID both inside and outside the loop.
<?php if ( function_exists( 'gt_hide_nav' ) && ! gt_hide_nav() ) : ?>
<nav role="navigation">
<?php if ( function_exists( 'bones_main_nav' ) ) bones_main_nav(); ?>
</nav>
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
// Move Yoast Meta Box to bottom | |
function yoasttobottom() { | |
return 'low'; | |
} | |
add_filter( 'wpseo_metabox_prio', 'yoasttobottom'); |
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 | |
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; |
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 | |
$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> |
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 | |
/** | |
* 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() |