Last active
December 12, 2015 09:58
-
-
Save ericjuden/4755566 to your computer and use it in GitHub Desktop.
WordPress St. Louis Developers Meetup: Security Best Practices
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 | |
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); | |
?> |
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 | |
// 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