Skip to content

Instantly share code, notes, and snippets.

View jonathanbossenger's full-sized avatar
🏠
Working from home

Jonathan Bossenger jonathanbossenger

🏠
Working from home
View GitHub Profile
@jonathanbossenger
jonathanbossenger / mysql-backup.sh
Created February 17, 2019 07:46
Backup all MySQL databases on the command line
#!/bin/bash
USER="root"
PASSWORD="password"
databases=`mysql -u $USER -p$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
for db in $databases; do
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != "mysql" ]] && [[ "$db" != _* ]] ; then
echo "Dumping database: $db"
@jonathanbossenger
jonathanbossenger / gist:a3276f05c08044991ba246719d4893ff
Created February 20, 2019 19:12
Check for valid email example
jQuery(function ($) {
$( document ).ready(function() {
$(“.diviclick”).on(“click”, function(){
event.preventDefault();
if ($('#email').val().length > 0){
$(‘#guiarapidaoptin’).submit();
}else {
alert('A valid email address is required')
}
});
@jonathanbossenger
jonathanbossenger / project_debug.php
Last active May 27, 2019 12:35
Simple PHP debug function for WordPress
function custom_error_log( $message, $data = '' ) {
if ( ! defined( 'DEBUG' ) || ! DEBUG ) {
return;
}
// For plugins
$log = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'log/';
// For themes
// $log = trailingslashit( get_stylesheet_directory() ) . 'log/';
if ( ! is_dir( $log ) ) {
@jonathanbossenger
jonathanbossenger / functions.php
Created June 26, 2019 12:22 — forked from hlashbrooke/functions.php
Seriously Simple Podcasting: Add blog categories to podcast episodes (admin).
add_action( 'init', 'ssp_add_categories_to_podcast', 12 );
function ssp_add_categories_to_podcast () {
register_taxonomy_for_object_type( 'category', 'podcast' );
}
<?php
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', 'prefix_podcast_rss_feed', 10, 1 );
function prefix_podcast_rss_feed() {
load_template( SSP_PLUGIN_PATH . '/templates/feed-podcast.php' );
}
<?php
// add audio file duration to a podcast when using Simple Bulk Uploader
global $ss_podcasting;
$duration = $ss_podcasting->get_file_duration( $file );
if ( $duration ) {
update_post_meta( $post_id, 'duration', $duration );
}
<?php
//Hook into the ssp_episode_query_args to show episode stats for all public and private podcasts
add_filter( 'ssp_episode_query_args', 'ssp_episode_query_args_callback', 10, 2 );
function ssp_episode_query_args_callback( $args, $context ) {
if ( 'stats' !== $context ) {
return $args;
}
$args['post_status'] = array( 'publish', 'private' );
@jonathanbossenger
jonathanbossenger / my_custom_feed_item_author.php
Created August 2, 2019 10:08
Add a custom feed item author
<?php
add_filter('ssp_feed_item_author', 'ssp_my_custom_feed_item_author');
function ssp_my_custom_feed_item_author(){
return 'John Smith - CEO';
}
<?php
add_filter( 'ssp_widget_series_episodes_args', 'custom_ssp_widget_series_episodes_args' );
function custom_ssp_widget_series_episodes_args( $arguments ) {
$arguments['posts_per_page'] = 10;
return $arguments;
}
@jonathanbossenger
jonathanbossenger / DuskServiceProvider.php
Created September 19, 2019 15:23
Custom ServiceProvider to register scrollToElement macro for Dusk browser testing
<?php
namespace App\Providers;
use Laravel\Dusk\Browser;
use Illuminate\Support\ServiceProvider;
class DuskServiceProvider extends ServiceProvider
{
/**