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 print_m($s) { | |
echo '<pre>'; | |
print_r($s); | |
echo '</pre>'; | |
} | |
?> |
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
// get the the role object | |
$role_object = get_role( 'editor' ); | |
// add $cap capability to this role object | |
$role_object->add_cap( 'edit_theme_options' ); |
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
// join term_relationships and term_taxonomy | |
add_filter( 'getarchives_join', 'customarchives_join' ); | |
// add where condition for category | |
add_filter( 'getarchives_where', 'customarchives_where' ); | |
// add where condition for date | |
add_filter('getarchives_where','filter_until_year_archives'); | |
function customarchives_join($join_clause) { | |
global $wpdb; | |
return $join_clause." INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_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
// Add this to your wp-config file: | |
// Do not leave this enabled on a production environment | |
define('SAVEQUERIES', true); | |
//Then, somewhere in your template (probably at the end of the footer.php, add this code: | |
if (SAVEQUERIES) { | |
echo "<pre>"; | |
print_r($wpdb->queries); | |
echo "</pre>"; | |
} |
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 | |
$con = mysql_connect("localhost","peter","abc123"); | |
if (!$con) { | |
die('Could not connect: ' . mysql_error()); | |
} | |
mysql_select_db("my_db", $con) or die(mysql_error()); | |
// insert query |
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
$ cd /Users/<username>/Sites | |
$ sudo chown -R :_www [wordpress directory] | |
$ sudo chmod -R g+w wordpress directory] | |
In config file: | |
define('FS_METHOD', 'direct'); |
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 | |
namespace App\Http\Controllers; | |
use App\User; | |
use App\Http\Controllers\Controller; | |
class UserController extends Controller | |
{ | |
/** |
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
# General | |
alias zshconfig="vim ~/.zshrc" | |
alias zshreload="source ~/.zshrc" | |
alias hostfile="sudo vim /etc/hosts" | |
alias vi="vim" | |
# Vagrant | |
alias vu="vagrant up" | |
alias vp="vagrant provision" | |
alias vs="vagrant provision" |
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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="/Users/markderaaf/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes |