Skip to content

Commit

Permalink
Remove hardcode table references
Browse files Browse the repository at this point in the history
  • Loading branch information
paulvanbuuren committed May 20, 2021
1 parent a9b743f commit 3c7f2ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion od/includes/hooks-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function od_create_page( $sPageTitle, $iMenuOrder = NULL, $sPageContent = NULL )
// early exit - slug exists
if( od_slug_exists($sPageSlug) ) {
global $wpdb;
$oPost = $wpdb->get_row("SELECT post_name FROM od_posts WHERE post_name = '".$sPageSlug."'");
$oPost = $wpdb->get_row( "SELECT post_name FROM $wpdb->posts WHERE post_name = '" . sanitize_title( $sPageSlug ) . "'" );
// we've got ourselves a page
if( $oPost->post_type == 'page' ) { return $oPost->ID; }
// not a page, better create one then
Expand Down
7 changes: 5 additions & 2 deletions od/includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ function od_get_id_by_slug( $object_slug ) {
*/
function od_slug_exists( $slug ) {
global $wpdb;
if( $wpdb->get_row("SELECT post_name FROM od_posts WHERE post_name = '".$slug."'", 'ARRAY_A') ) { return TRUE; }
else { return FALSE; }
if ( $wpdb->get_row( "SELECT post_name FROM $wpdb->posts WHERE post_name = '" . sanitize_title( $slug ) . "'", 'ARRAY_A' ) ) {
return true;
} else {
return false;
}
}

0 comments on commit 3c7f2ae

Please sign in to comment.