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 pts_news_add() { | |
wp_add_dashboard_widget('pts_news_list', 'Poststat.us News', 'pts_news_list_build'); | |
} | |
add_action('wp_dashboard_setup', 'pts_news_add'); | |
function pts_news_list_build() { | |
$rss = fetch_feed('http://poststat.us/feed/'); |
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 | |
/** | |
* Helper to work with Wordpress admin notices | |
* | |
* @example | |
* Notice::success('All is good!'); | |
* | |
* @example | |
* Notice::warning('Do something please.', true); |
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 | |
add_filter( 'rest_prepare_post', __NAMESPACE__ . '\add_featured_image_data_to_rest', 70, 3 ); | |
/** | |
* Format the possible featured image metadata in the REST API response. | |
* | |
* @param WP_REST_Response $response The response object. | |
* @param WP_Post $item The original post object. | |
* @param WP_REST_Request $request The request used to generate the response. | |
* |
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 | |
/** | |
* handle the calculation | |
* @param integer $seconds [description] | |
* @return [type] [description] | |
*/ | |
function rkv_calc_read_time( $seconds = 0 ) { | |
// calc the minutes |
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
# custom login link | |
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L] |
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 confirm_css_unit( $string ) { | |
// First check for a null or allowed strings. | |
if ( empty( $string ) || null === $string || in_array( $string, [ 'auto', 'fit-content', 'inherit' ] ) ) { | |
return $string; | |
} | |
// Pull out the numerical portion. | |
$value = preg_replace( '~\D~', '', $string ); |
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
// ************************************************************** | |
// password validation | |
// ************************************************************** | |
function checkPassword(pass) { | |
var numbers = pass.match(/\d+/g); | |
var uppers = pass.match(/[A-Z]/); | |
var lowers = pass.match(/[a-z]/); | |
var special = pass.match(/[!@#$%\^&*\+]/); |
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
http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg | |
http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg | |
http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg | |
http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg | |
The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is: | |
http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg | |
For the high quality version of the thumbnail use a url similar to this: |
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 | |
/* | |
Plugin Name: Norcross Debug Functions | |
Plugin URI: https://gist.github.com/norcross/7864205/ | |
Description: A set of functions I use on all sites while building | |
Author: Andrew Norcross | |
Version: 0.0.1 | |
Requires at least: 3.0 | |
Author URI: http://andrewnorcross.com | |
*/ |
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 | |
$countries = array( | |
'Afghanistan', | |
'Albania', | |
'Algeria', | |
'American Samoa', | |
'Andorra', | |
'Angola', | |
'Anguilla', |
NewerOlder