turned custer into a repo
This commit is contained in:
94
queries.php
Normal file
94
queries.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
namespace CUSTER;
|
||||
|
||||
/*
|
||||
* it means someone outside wp is accessing the file, in this case kill it.
|
||||
*/
|
||||
if (!defined('ABSPATH')) {
|
||||
die('You can not access this file!');
|
||||
}
|
||||
|
||||
|
||||
function get_queries($user_id, $if_empty = '') {
|
||||
$special_queries = Custer::QUERIES;
|
||||
if (is_null($user_id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$queries = array();
|
||||
foreach($special_queries as $query) {
|
||||
$queries[$query] = \CUSTER\format_user_info($query, $user_id, $if_empty);
|
||||
}
|
||||
return $queries;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function find_author_page_url($user_id) {
|
||||
if (is_null($user_id)) {
|
||||
return null;
|
||||
}
|
||||
return get_author_posts_url($user_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* find the posts of the user and return the first one
|
||||
*
|
||||
*/
|
||||
function find_user_post_url($user_id) {
|
||||
if (is_null($user_id)) {
|
||||
return null;
|
||||
}
|
||||
$user_post_url = '';
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'post',
|
||||
'author' => $user_id,
|
||||
'posts_per_page' => 1,
|
||||
);
|
||||
$posts = get_posts($args);
|
||||
|
||||
if (empty($posts)) {
|
||||
$user_post_url = '';
|
||||
}
|
||||
else {
|
||||
$query = reset($posts);
|
||||
$user_post_url = get_permalink($query->ID);
|
||||
}
|
||||
|
||||
return $user_post_url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function find_admin_email($user_id = null) {
|
||||
$admin_email = get_option( 'admin_email' );
|
||||
return $admin_email;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function find_base_url($user_id = null) {
|
||||
$base_url = home_url();
|
||||
return $base_url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user