This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# install WP CLI at your home-dir. Change if you want something else | |
# make executable: chmod u+x wpcli.sh | |
# use ./wpcli.sh | |
# | |
mkdir ~/wp-cli | |
wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O ~/wp-cli/wp | |
chmod 755 ~/wp-cli/wp | |
export PATH="$PATH:~/wp-cli" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Backup your widgets before you give a try to new theme | |
# | |
# https://guides.wp-bullet.com/using-wp-cli-backup-restore-wordpress-widgets/ | |
# | |
# create array of all widgets in the wp_options table | |
WIDGETSARRAY=($(wp db query "SELECT option_name FROM $(wp db prefix --allow-root)options WHERE option_name LIKE 'widget\_%'" --skip-column-names --allow-root)) | |
# loop through widgets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Restore your widgets after tried new theme | |
# | |
# https://guides.wp-bullet.com/using-wp-cli-backup-restore-wordpress-widgets/ | |
# | |
# loop through widget backups | |
for WIDGETBACKUP in /tmp/widgets/*.txt | |
do | |
# extract filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:PutLogEvents" | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set daemon 60 #check services every 60 seconds | |
set logfile /var/log/monit.log | |
set idfile /var/lib/monit/id | |
set statefile /var/lib/monit/state | |
#Event queue | |
set eventqueue | |
basedir /var/lib/monit/events # set the base directory where events will be stored | |
slots 100 # optionally limit the queue size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('manage_posts_columns', 'posts_columns_id', 5); | |
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2); | |
add_filter('manage_pages_columns', 'posts_columns_id', 5); | |
add_action('manage_pages_custom_column', 'posts_custom_id_columns', 5, 2); | |
function posts_columns_id($defaults){ | |
$defaults['wps_post_id'] = __('ID'); | |
return $defaults; | |
} | |
function posts_custom_id_columns($column_name, $id){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: NeatSnippet | |
Description: Show at plugin description | You can have even <a href="example.com">a link</a> here | |
*/ | |
/* Start Adding Functions Below this Line */ | |
/* Stop Adding Functions Below this Line */ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Podcast to wp-category | |
add_action( 'init', 'ssp_add_categories_to_podcast' ); | |
function ssp_add_categories_to_podcast () { | |
register_taxonomy_for_object_type( 'category', 'podcast' ); | |
} | |
add_action( 'pre_get_posts', 'ssp_add_podcast_to_category_archives' ); | |
function ssp_add_podcast_to_category_archives( $query ){ | |
if( is_admin() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_pre_get_posts($query) { | |
// validate | |
if(!is_admin() && $query->is_main_query()) { | |
if(is_archive()) { | |
$query->set('orderby', 'title'); // order posts by title | |
$query->set('order', 'ASC'); // and in ascending order | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add WooCommerce customer username to edit/view order admin page | |
add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_order_username', 10, 1 ); | |
function woo_display_order_username( $order ){ | |
global $post; | |
$customer_user = get_post_meta( $post->ID, '_customer_user', true ); | |
echo '<p><strong style="display: block;">'.__('Customer Username').':</strong> <a href="user-edit.php?user_id=' . $customer_user . '">' . get_user_meta( $customer_user, 'nickname', true ) . '</a></p>'; | |
} |