Taken from the source code of get_bloginfo()
, Here is a very very simple class you can utelize and extent at your will.
I have decided to make use of methods, making properties public from a class is really not great coding and not recommended. I know WordPress thrive on public properties, but that is WordPress.
Here is the class (which you should convert to make use of proper namespacing, as I said, this is an extremely simple and plain class)
class GetBlogInfo
{
// Return the home URL
public function homeURL()
{
return home_url();
}
// Return the site URL
public function siteURL()
{
return site_url();
}
// Return the blog description
public function description()
{
return get_option('blogdescription');
}
// Get the feed links
public function getFeedLink( $link = '' )
{
switch( $link ) {
case 'rdf_url':
$output="rdf";
break;
case 'rss_url':
$output="rss";
break;
case 'rss2_url':
$output="rss2";
break;
case 'atom_url':
$output="atom";
break;
case 'comments_atom_url':
$output="comments_atom";
break;
case 'comments_rss2_url':
$output="comments_rss2";
break;
default:
$output = false;
break;
}
if ( $output ) {
return get_feed_link( $output );
} else {
return false;
}
}
// Return the blog options. Default is name
public function getOptions( $option = 'name' )
{
switch( $option ) {
case 'admin_email':
$output="admin_email";
break;
case 'charset':
$output="blog_charset";
break;
case 'html_type':
$output="html_type";
break;
case 'name':
default:
$output="blogname";
break;
}
return get_option( $output );
}
// Return the blog language setting
public function language()
{
return str_replace( '_', '-', get_locale() );
}
// Return the WordPress version
public function version()
{
global $wp_version;
return $wp_version;
}
// Return the pingback URL
public function pingbackURL()
{
return site_url( 'xmlrpc.php' );
}
// Return the path to main stylesheet
public function stylesheetURL()
{
return get_stylesheet_uri();
}
// Return the stylesheet directory uri
public function stylesheetDirectory()
{
return get_stylesheet_directory_uri();
}
// Return the template directory uri
public function templateDirectory()
{
return get_template_directory_uri();
}
}
You can use the class as follow:
$q = new GetBlogInfo();
echo $q->homeURL() . '</br>';
echo $q->siteURL() . '</br>';
echo $q->description() . '</br>';
echo $q->getFeedLink( 'rdf_url' ) . '</br>';
echo $q->getFeedLink( 'rss_url' ) . '</br>';
echo $q->getFeedLink( 'rss2_url' ) . '</br>';
echo $q->getFeedLink( 'atom_url' ) . '</br>';
echo $q->getFeedLink( 'comments_atom_url' ) . '</br>';
echo $q->getFeedLink( 'comments_rss2_url' ) . '</br>';
echo $q->getOptions( 'name' ) . '</br>';
echo $q->getOptions( 'admin_email' ) . '</br>';
echo $q->getOptions( 'charset' ) . '</br>';
echo $q->getOptions( 'html_type' ) . '</br>';
echo $q->language() . '</br>';
echo $q->version() . '</br>';
echo $q->pingbackURL() . '</br>';
echo $q->stylesheetURL() . '</br>';
echo $q->stylesheetDirectory() . '</br>';
echo $q->templateDirectory() . '</br>';
This output the following as tested on my test install
http://localhost/wordpress
http://localhost/wordpress
Trots Afrikaans - Praat Afrikaans of hou jou bek!!!
http://localhost/wordpress/feed/rdf/
http://localhost/wordpress/feed/rss/
http://localhost/wordpress/feed/
http://localhost/wordpress/feed/atom/
http://localhost/wordpress/comments/feed/atom/
http://localhost/wordpress/comments/feed/
Pieter Goosen
[email protected]
UTF-8
text/html
af-AF
4.3.1
http://localhost/wordpress/xmlrpc.php
http://localhost/wordpress/wp-content/themes/pietergoosen2014/style.css
http://localhost/wordpress/wp-content/themes/pietergoosen2014
http://localhost/wordpress/wp-content/themes/pietergoosen2014