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 | |
wp_enqueue_script( | |
'your-plugin', // handle | |
plugins_url( 'your-file.js', __FILE__ ), // file | |
array( 'jquery' ), // dependencies | |
filemtime( plugin_dir_path( __FILE__ ) . '/your-file.js' ) // version: modified filemtime | |
// filemtime( get_template_directory() . '/your-file.js' ) // or this if a THEME not a PLUGIN | |
); | |
?> |
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
Posted on: <?php | |
// works unless multiple posts in one day | |
the_date(); | |
// always works | |
the_time(get_option('date_format')); | |
// always works | |
echo get_the_date(); |
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
<? | |
add_shortcode('years','ds_years_since'); | |
function ds_years_since($atts) { | |
$a = shortcode_atts( array('since' => date('r')), $atts ); | |
$then = new DateTime($a['since']); | |
$now = new DateTime(); | |
$interval = date_diff($then, $now); | |
return $interval->y; | |
} | |
?> |
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
<? | |
add_shortcode('readme','ds_show_readme'); | |
function ds_show_readme() { | |
ob_start(); | |
?> | |
<!-- [readme] shortcode --> | |
<div id='ds_readme'> | |
<?= file_get_contents(__DIR__.'/README.md') ?> | |
</div> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/showdown/1.7.1/showdown.min.js"></script> |
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
<? | |
global $_wp_admin_css_colors; | |
echo $_wp_admin_css_colors[get_user_option('admin_color')]->colors[2]; | |
// returns: #0073aa | |
?> |
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
chflags hidden /Users/yourusername/Library/Mobile Documents/com~apple~CloudDocs/Sites/_temp/ |
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
comment { | |
color:#4a4b4b; | |
font-style:italic; | |
font-weight:normal; | |
} | |
constant.numeric { | |
color:#f77b6f; | |
font-weight:normal; | |
} |
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
<? | |
/* in my theme's functions.php */ | |
// load the gist embed script | |
add_action( 'wp_enqueue_scripts', 'ds_make_scripts' ); | |
function ds_make_scripts() { | |
wp_register_script('gist-embed', get_template_directory_uri() . '/gist-embed.js', array('jquery'), 1, true); | |
wp_enqueue_script( 'gist-embed' ); | |
} |
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 sendToSlack($to,$title,$text,$color = "good") { | |
$inHook = 'https://hooks.slack.com/services/###/###/###'; | |
$data = json_encode(array( | |
"channel" => $to, | |
"username" => "Your App Name", | |
"icon_emoji" => ":beers:", // your app icon | |
"attachments" => array(array( | |
"fallback" => $title, |
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
<? | |
// in functions.php | |
add_filter( 'the_password_form', 'ds_password_form' ); | |
function ds_password_form() { | |
global $post; | |
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID ); | |
$link = esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ); | |
return " | |
<form action='{$link}' method='post' id='passwordForm'> | |
<input name='post_password' id='{$label}' type='password' size='20' maxlength='20' placeholder='Password' /> |