Skip to content

Instantly share code, notes, and snippets.

Avatar
somone said this would be easy. someone LIED.

Norcross norcross

somone said this would be easy. someone LIED.
View GitHub Profile
@norcross
norcross / country-array.php
Last active Jan 24, 2020 — forked from DHS/PHP Countries Array
PHP array of all country names
View country-array.php
<?php
$countries = array(
'Afghanistan',
'Albania',
'Algeria',
'American Samoa',
'Andorra',
'Angola',
'Anguilla',
View always-login.php
<?php
/**
* keeps a user always logged in
* don't use this on a production site, ever!
*/
add_action( 'init', 'rkv_auto_login' );
add_action( 'admin_init', 'rkv_auto_login' );
@norcross
norcross / shortcode-clean.php
Created Apr 27, 2015
remove some weird tags on shortcodes
View shortcode-clean.php
<?php
add_filter( 'the_content', 'rkv_shortcode_cleanup',1001 );
/**
* remove weird tags
*
* @param [type] $content [description]
*/
function rkv_shortcode_cleanup( $content ) {
@norcross
norcross / rkv-bypass-auto-update.php
Created Feb 19, 2015
prevent WordPress from sending emails when the auto update is successful
View rkv-bypass-auto-update.php
<?php
/**
* bypass the notification email on successful auto-updates
*
* @param [type] $send [description]
* @param [type] $type [description]
* @param [type] $core_update [description]
* @param [type] $result [description]
* @return [type] [description]
*/
@norcross
norcross / force-image-https.php
Created Jan 21, 2015
filter content to rewrite image src to https
View force-image-https.php
<?php
add_filter( 'the_content', 'rkv_force_https_images', 10 );
/**
* check image URLs and force https on them
*
* @param [type] $content [description]
*/
function rkv_force_https_images( $content ) {
return str_replace( 'src="http://css-tricks.com', 'src="https://css-tricks.com', $content );
@norcross
norcross / cun-notify-single.php
Created Jan 20, 2015
filter the content notification to a single post ID
View cun-notify-single.php
<?php
add_filter( 'cun_single_item_email', 'rkv_single_cun_notify' );
function rkv_single_cun_notify( $post_id ) {
return absint( $post_id ) === absint( THE_ID_I_WANT ) ? true : false;
}
@norcross
norcross / wp-comment-noreply-meta.php
Created Nov 25, 2014
remove the noindex meta tag from single reply comment links
View wp-comment-noreply-meta.php
<?php
add_action( 'init', 'rkv_comment_noindex_base' );
/**
* remove the noindex flag on the reply links
* when not using Yoast SEO
*
* @return null
*/
function rkv_comment_noindex_base() {
@norcross
norcross / remove-month-dropdown.php
Created Nov 5, 2014
remove the month drop down from post types
View remove-month-dropdown.php
<?php
add_filter( 'months_dropdown_results', 'rkv_remove_month_filters' ), 10, 2 );
/**
* remove the month drop down filter by
* spoofing WP and saying that none exist
* for specific post types
*
* @param array $months the original count
* @param string $post_type the post type
@norcross
norcross / on-click-example.js
Created Oct 20, 2014
example of using on.click with dynamic elements
View on-click-example.js
// the idea being that the container div exists outside of the
// dynamic element, and the anchor link is loaded.
jQuery( 'div.container' ).on( 'click', 'a.dynamic-element' function (){
// do your thing here
});
View .htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/