Skip to content

Instantly share code, notes, and snippets.

@ericjuden
Last active December 12, 2015 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericjuden/4755566 to your computer and use it in GitHub Desktop.
Save ericjuden/4755566 to your computer and use it in GitHub Desktop.
WordPress St. Louis Developers Meetup: Security Best Practices
<?php
global $wpdb;
// Clean SQL before running
$sql = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE status = %s AND post_type = %s', 'publish', 'page');
// Return results
$results = $wpdb->get_results($sql);
?>
<?php
// Security Checkpoint
if(!current_user_can('edit_theme_options')){
wp_die(__('You do not have sufficient permissions to access this page.'));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment