Skip to content

Instantly share code, notes, and snippets.

View mobile-reset.css
*, *:before, *:after {
/* suppressing the tap highlight */
-webkit-tap-highlight-color: rgba(0,0,0,0);
/* this is a personal preference */
box-sizing: border-box;
vertical-align: top;
padding: 0;
margin: 0;
-webkit-font-smoothing: antialiased;
@jmsmrgn
jmsmrgn / clean-wp_nav_menu.php
Last active Feb 8, 2019
WordPress - Clean wp_nav_menu
View clean-wp_nav_menu.php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'first',
'last',
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'current-menu-ancestor',
View keybase.md

Keybase proof

I hereby claim:

  • I am jmsmrgn on github.
  • I am jmsmrgn (https://keybase.io/jmsmrgn) on keybase.
  • I have a public key ASCjDRHgAI0o4Zzt_NmDpQCBJvELDCoffpHOc3bHJ5MGPgo

To claim this, I am signing this object:

@jmsmrgn
jmsmrgn / osascript
Created Apr 17, 2018
Manipulate login items from command line
View osascript
osascript -e 'tell application "System Events" to get the name of every login item'
osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Applications/Name of app.app", hidden:false}'
osascript -e 'tell application "System Events" to delete login item "itemname"'
@jmsmrgn
jmsmrgn / sass-loader-options.js
Created Dec 21, 2016
webpack - sass loader data options
View sass-loader-options.js
new webpack.LoaderOptionsPlugin({
options: {
sassLoader: {
data: '@import "app/styles/settings/_settings.scss";',
includePaths: 'app/styles'
},
context: path.resolve(__dirname, '../../') // must evaluate to root of project
}
})
@jmsmrgn
jmsmrgn / async-scripts.php
Created Feb 1, 2016
WP - Async script load
View async-scripts.php
// Async load
function async_scripts($url) {
if (strpos( $url, '#asyncload') === false) {
return $url;
} else if (is_admin()) {
return str_replace('#asyncload', '', $url );
} else {
return str_replace('#asyncload', '', $url )."' async='async";
}
}
@jmsmrgn
jmsmrgn / search-filter.php
Created Jan 24, 2016
WP - Only return posts in search
View search-filter.php
/**
* Search should only return posts
*/
function search_filter($query) {
if (!$query->is_admin && $query->is_search) {
$query->set('post_type', 'post');
// $query->set('post__not_in', array(1,5,10));
}
return $query;
}
@jmsmrgn
jmsmrgn / is-blog.php
Created Jan 24, 2016
WP - Blog view conditional check
View is-blog.php
/**
* Blog view conditional check
*/
function is_blog() {
return (is_author() || is_category() || is_tag() || is_date() || is_home() || is_single()) && 'post' == get_post_type();
}
@jmsmrgn
jmsmrgn / nice-search-redirect.php
Created Jan 24, 2016
WP - Pretty urls for search results
View nice-search-redirect.php
/**
* Pretty urls for search results
*/
function nice_search_redirect() {
global $wp_rewrite;
if (!isset($wp_rewrite) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks())
return;
$search_base = $wp_rewrite->search_base;
@jmsmrgn
jmsmrgn / bootstrap-wp-pager.php
Last active Jan 3, 2016
Bootstrap styleable WP pager function
View bootstrap-wp-pager.php
function bootstrap_wp_pager() {
echo '<ul class="pager">';
$next = get_next_posts_link( 'Older &rarr;');
$prev = get_previous_posts_link( 'Newer &larr;' );
if ( !empty($prev) )
echo '<li class="previous">'.$prev.'</li>';
if ( !empty($next) )
echo '<li class="next">'.$next.'</li>';
echo '</ul>';
}