-
-
Save tommcfarlin/cfca668f3d1ade8335611f1434b94cf7 to your computer and use it in GitHub Desktop.
[WordPress] Append WordPress Page Content From the Database
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 | |
public function init() { | |
$page_id = get_option( 'acme_display_page_id', 0 ); | |
if ( 0 === $page_id ) { | |
return; | |
} | |
add_filter( 'the_content', array( $this, 'the_content' ) ); | |
} |
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 | |
private function get_users() { | |
$args = array( | |
'orderby' => 'ID', | |
'role' => 'Editor', | |
); | |
$user_query = new \WP_User_Query( $args ); | |
return $user_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
<?php | |
private function get_user_markup( $user_query ) { | |
$content = ''; | |
if ( 0 === $user_query->get_total() ) { | |
return; | |
} | |
$users = $user_query->get_results(); | |
$content = '<ul>'; | |
foreach ( $users as $user ) { | |
$login = $user->data->user_login; | |
$content .= "<li>$login</li>"; | |
} | |
$content .= '</ul>'; | |
// Note: Use proper escaping or wp_kses to sanitize this data. | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment