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
#!/bin/bash | |
# Bash Script to change database using wp-cli | |
# Finds any previously exported .sql file and asks the user which one to change to (ie import) | |
# Recommended usage: Change your system to multiple ideal states and export the db for each (into main wp folder), then use this to switch between states. | |
# Example: I have db exports for empty installation, theme unit test data, woocommerce demo data, etc. | |
# Requires wp cli | |
# Needed on my Windows installation. YOU PROBABLY NEED TO REMOVE THIS IF NOT USING WINDOWS. | |
shopt -s expand_aliases | |
alias wp="wp.bat" |
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
#!/bin/bash | |
# Bash script to reset a WordPress database once you've messed the data up | |
# Does not delete themes, plugins, or media, just restores WordPress to an emtpy system, activate plugins, imports data, etc | |
# Requires wp cli | |
# Login details. EDIT THESE AS APPROPRIATE. | |
ADMIN_USER="admin" | |
ADMIN_PASSWORD="password" | |
ADMIN_EMAIL="person@domain.com" |
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
// to be added in functions.php within the PHP tags | |
function spc_list_comment_filters() { | |
// exit if not on a page that show comments (the Comments page or Edit post/page screen) | |
global $pagenow; | |
if ( 'edit-comments.php' != $pagenow && 'post.php' != $pagenow ) { | |
return; | |
} | |
// get global variable containing list of registered filters |
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 onEdit() { | |
var s = SpreadsheetApp.getActiveSheet(); | |
var r = s.getActiveCell(); | |
if( r.getColumn() != 2 && r.getRow() != 1 ) { //checks the column | |
var row = r.getRow(); | |
var time = new Date(); | |
var timezone = CalendarApp.getDefaultCalendar().getTimeZone(); | |
time = Utilities.formatDate(time, timezone, "dd/MM/yyyy, hh:mm:ss"); | |
SpreadsheetApp.getActiveSheet().getRange('B' + row.toString()).setValue(time); | |
}; |
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 | |
function filter_handler( $approved , $commentdata ) { | |
// get the comment author name and email and check how many comments that person has approved. | |
global $wpdb; | |
$author = $commentdata[ 'comment_author' ]; | |
$email = $commentdata[ 'comment_author_email' ]; | |
$comments_approved = $wpdb->get_var( "SELECT COUNT(comment_approved) FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1" ); | |
// if the author already has more than 5 comments approved, set this to approved, otherwise set as pending |
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 | |
// To be used by theme authors to avoid duplicate favicon code now that Site Icons have been added to WordPress 4.3 | |
// If a Site Icon hasn't been set or if the `has_site_icon` function doesn't exist (ie older than WordPress 4.3) | |
if ( ! ( function_exists( 'has_site_icon' ) && has_site_icon() ) ) { | |
// your theme specific custom favicon code goes here | |
} | |