Skip to content

Instantly share code, notes, and snippets.

View johnjullies's full-sized avatar

John Jullies Palma johnjullies

View GitHub Profile
@johnjullies
johnjullies / functions.php
Created August 9, 2019 07:18
Custom WordPress function - coding exam submission
<?php
/**
* A wordpress function that triggers #publish button onClick
* when on a post page (admin); then:
* 1) gets all custom_fields of an extended Pod that are marked Required, of the current post_type
* 2) checks if all the required fields have a value, if not, throws an error
* 3) checks if custom_field XYZ has a value between 50 & 80, if not throws an error
* 4) changes post_status to "publish"
* 5) re-directs to homepage.
*/
@johnjullies
johnjullies / settings.json
Created July 17, 2019 05:01
My VSCode settings
{
"workbench.colorTheme": "Quiet Light",
"workbench.startupEditor": "newUntitledFile",
"breadcrumbs.enabled": false,
"liveSassCompile.settings.formats": [
{
"format": "compressed",
"extensionName": ".min.css",
"savePath": null
}
@johnjullies
johnjullies / functions.php
Created July 17, 2019 04:58
WordPress: Add custom post type to homepage
function add_custom_pt( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'the_custom_pt' ) );
}
}
add_action( 'pre_get_posts', 'add_custom_pt' );
@johnjullies
johnjullies / html.json
Last active July 10, 2019 03:47
Adds php tag autocomplete for VS Code
"php": {
"prefix": "php",
"body": [
"<?php $1 ?>"
],
"description": "php tag"
}
@johnjullies
johnjullies / functions.php
Created June 24, 2019 08:02
Change Custom Logo URL in Wordpress
/**
* Change the custom logo URL
*/
function my_custom_logo_link() {
// The logo
$custom_logo_id = get_theme_mod( 'custom_logo' );
// If has logo
if ( $custom_logo_id ) {
@johnjullies
johnjullies / font-family.css
Last active October 2, 2017 00:02
System Font Stack
/* System Fonts as used by Medium and WordPress */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
@johnjullies
johnjullies / functions.php
Created September 20, 2017 05:42
svg support for Wordpress
/**
* SVG support
*/
function svg_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;}
add_filter( 'upload_mimes', 'svg_mime_types' );
function svg_size() {
echo '<style>
@johnjullies
johnjullies / filename_to_array_loop.sh
Last active March 10, 2017 07:23
Gets the contents of a file into an array variable and outputs the string one line at a time. Source: http://stackoverflow.com/a/11393884/1444895
IFS=$'\r\n' GLOBIGNORE='*'
command eval 'arr=($(cat ep_names))'
for i in "${arr[@]}"
do
echo "$i"
done
set tabsize 4
set tabstospaces
set smooth
set tempfile
ARRAY=("Narcos - 01x01 - Descenso"
"Narcos - 01x02 - The Sword of Simon Bolivar"
"Narcos - 01x03 - The Men of Always"
"Narcos - 01x04 - The Palace in Flames"
"Narcos - 01x05 - There Will Be a Future"
"Narcos - 01x06 - Explosivos"
"Narcos - 01x07 - You Will Cry Tears of Blood"
"Narcos - 01x08 - La Gran Mentira"
"Narcos - 01x09 - La Catedral"
"Narcos - 01x10 - Despegue"); j=0; for i in *.srt; do mv "$i" "${ARRAY[$j]}".srt; let j=j+1;done