Skip to content

Instantly share code, notes, and snippets.

@radovanx
radovanx / package.json
Created March 30, 2019 14:21 — forked from mburakerman/package.json
Webpack 4 config.js (SCSS to CSS and Babel) 👌 The Simplest Usage 👌
{
"name": "webpack-sass",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
}
@radovanx
radovanx / wp_custom_featured_image.php
Created March 22, 2018 10:11 — forked from mbijon/wp_custom_featured_image.php
Customize the WordPress Featured Image metabox: Because can't call add/remove_meta_box inline. Actions must be 'admin-head' or later
@radovanx
radovanx / global-variables-are-bad.js
Created October 11, 2017 09:24 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@radovanx
radovanx / wordpress-breadcrumb-advanced.php
Created September 1, 2017 10:49 — forked from TCotton/wordpress-breadcrumb-advanced.php
Code for creating Wordpress breadcrumbs in a theme including custom taxonomy
<?php
// --> http://www.suburban-glory.com/blog?page=170
/*
* based on http://snipplr.com/view/57988/
*/
function get_term_parents($id, $taxonomy, $link = false, $separator = '/', $nicename = false, $visited = array()) {
$chain = '';
$parent = &get_term($id, $taxonomy);
@radovanx
radovanx / SCSS.md
Created July 15, 2017 21:41 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@radovanx
radovanx / wpinstall.sh
Created April 21, 2017 13:42 — forked from anonymous/wpinstall.sh
wp cli
#!/bin/bash -e
wpuser='exampleuser'
clear
echo "================================================================="
echo "Awesome WordPress Installer!!"
echo "================================================================="
@radovanx
radovanx / admin_functions.php
Created December 20, 2016 10:17 — forked from chrisblakley/admin_functions.php
Business Hours Custom Field Group without ACF
<?php
//Add Open/Closed info to location listing columns
add_filter('manage_edit-location_columns', 'schc_location_hours_columns_head');
function schc_location_hours_columns_head($defaults){
$defaults['openclosed'] = 'Open/Closed';
return $defaults;
}
add_action('manage_location_posts_custom_column', 'schc_location_hours_columns_content', 15, 3);
function schc_location_hours_columns_content($column_name, $id){
if ( $column_name == 'openclosed' ){
@radovanx
radovanx / wpdb-transactions
Last active August 29, 2015 14:26 — forked from 5iDS/wpdb-transactions
MySQL database transaction, using the WordPress database object $wpdb. When you render a page in WordPress (front end or admin area), the $wpdb database object has already been initialised and opened up a connection to the database. Therefore we can recycle this database connection for our own needs. The $wpdb object saves the database handle as…
<?php
global $wpdb;
// @ prefix used to suppress errors, but you should do your own
// error checking by checking return values from each mysql_query()
// Start Transaction
@mysql_query("BEGIN", $wpdb->dbh);
// Do some expensive/related queries here