Well hi again. This is my first post in over 2 years lol. Been a while. Mainly cause I couldn't remember my username/password but will be around more now I'm sure.
Anyways, I finally have given in and decided to see if anyone here can help me with this (since I know someone here can).
I have a Wordpress plugin I'm updating and I have re-written my code to include a dashboard options page and made a Php class for it, which I'm going nuts with.
The admin options page works, is entirely functional and everything. It is a plugin for showing an author bio on blog posts, and the admin page uses a (preview/copy of author bio code) which changes based on the form settings, but I can not figure out how or what to do to make the code output on blog posts change too.
I basically am having a hard time with:
should I make the bio div a method, class, or object
and how do I use it both in the admin and on posts to show the same thing
or at the very least, how to get the code shown in posts to reflect the settings of the preview (working) code of the bio on the admin page.
I have read so many not-so helpful articles and tried too many different things that I've been unsuccessful with, or gain an understanding of what to do with all that I've read, leaving me more confused.
EDIT: Less important, but should mention. I just realized the admin page doesn't save the settings but does appear to upon submitting form, but when going to another page, then back to options page the default settings show again.
Here's the code used outside the class
function print_my_stylesheets(){
echo "<link rel='stylesheet' type='text/css' href='".WP_PLUGIN_URL."/authorbio/n2_authorbio.css' />";
}
add_action('wp_head','print_my_stylesheets');
/*************************************************/
/* Add Twitter profile field and remove Yahoo IM */
/*************************************************/
function add_twitter_field($contactmethods) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
// Remove Yahoo IM
unset($contactmethods['yim']);
return $contactmethods;
}
/*************************************************/
/* Add Facebook profile field and remove Yahoo IM */
/*************************************************/
function add_facebook_page($contactmethods) {
$contactmethods['facebook'] = 'Facebook';
return $contactmethods;
}
/*****************************/
/* Create the Author Bio box */
/*****************************/
function n2_author_box() {
global $n2_admin_hide, $n2_editor_hide, $n2_author_hide,
$n2_contrib_hide, $n2_gravatar_size, $n2_border_color,
$n2_text_color, $n2_bg_color, $n2_heading_color,
$n2_link_color, $n2_hover_color;
?>
<div id="n2authorbio">
<a href="<?php bloginfo('url'); ?>/author/<?php the_author_meta('nickname') ?>/" title="All posts by <?php the_author_meta('nickname'); ?>">
<?php if (function_exists('get_avatar')) { echo get_avatar(get_the_author_meta('user_email'), $n2_gravatar_size ); } ?>
</a>
<h2>About the Author</h2>
<p><?php the_author_meta('description'); ?></p>
<div class="authormeta">
<?php if (get_the_author_meta('user_url') && get_the_author_meta('user_url') != 'http://') { ?>
<a href="<?php the_author_meta('user_url'); ?>" title="Visit <?php the_author_meta('display_name'); ?>'s Website" target="_blank" class="website">Visit <?php the_author_meta('display_name'); ?>'s Website</a>
<?php
} // end check for url ?>
<?php if (get_the_author_meta('twitter')) { ?>
<a href="http://twitter.com/<?php the_author_meta('twitter'); ?>" title="Follow <?php the_author_meta('display_name'); ?> n Twitter" target="_blank" class="twitter">Follow <?php the_author_meta('display_name'); ?> on Twitter</a>
<?php } // End check for twitter ?>
</div>
</div>
<?php
} // end n2_author_box()
/***************************************/
/* Call the functions if on single.php */
/***************************************/
function display_author_info() {
if (is_single())
return n2_author_box().print_my_stylesheets();
}
/*****************/
/* Add the hooks */
/*****************/
add_filter('user_contactmethods','add_twitter_field',10,1);
add_filter('user_contactmethods','add_facebook_page',10,1);
/* add_filter('the_content', array(&$dl_pluginSeries, 'addContent'),1); */
add_filter('comments_template', 'display_author_info');
add_action( 'init', array('n2AuthorOptions', 'init') );
Sorry for my crappy code too btw.
Any help I can get would be extremely appreciated, I've put off learning and understanding OOP for a long time now after trying to learn it a few years ago and giving up. I regret that, since now I have spent the past few days working non-stop trying to get this to work.
Thanks in advance.