Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Use municipio helper to get post type meta keys #474

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions source/php/Helper/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@

class Post
{
/**
* Lists all meta-keys existing for the given posttype
*
* Attention: Since this method is using the database to get the
* metadata keys there need to be posts in the posttype to get results
*
* @param string $posttype The posttype
* @return array Meta keys as array
*/
public static function getPosttypeMetaKeys($posttype)
{
global $wpdb;
$metaKeys = $wpdb->get_results("
SELECT DISTINCT {$wpdb->postmeta}.meta_key
FROM {$wpdb->postmeta}
LEFT JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID
WHERE
{$wpdb->posts}.post_type = '$posttype'
AND NOT LEFT({$wpdb->postmeta}.meta_key, 1) = '_'
");

return $metaKeys;
}

/**
* Gets the post template of the current editor page
* @return string Template slug
Expand Down
2 changes: 1 addition & 1 deletion source/php/Module/Posts/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function getSortableMetaKeys()
die();
}

$meta = \Modularity\Helper\Post::getPosttypeMetaKeys($_POST['posttype']);
$meta = \Municipio\Helper\Post::getPosttypeMetaKeys($_POST['posttype']);

$response = [
'meta_keys' => $meta,
Expand Down
Loading