Jump to content

Determine Plugin Function Name


abinidi

Recommended Posts

I have the image-headlines plugin on my TCH-hosted WP site (www.paulpehrson.com), and I'm trying to package my theme for use by other people. I want to leave in the code that runs the image-headlines plugin, so I"m trying to insert some if/then logic in the pages.

 

WP includes the if function exists option shown below (replace the FUNCTION_NAME variable with the function's name):

 

><?php if (function_exists('FUNCTION_NAME')) { ?>

 

 

Ok. So if the plugin author doesn't tell you, and their support forums are closed, how do you determine what the function name is that you need to check for in order to see if the plugin is enabled?

 

FYI, I'm using WP 2.0.6, and the plugin is Headline Images v. 2.7. Their blog is http://www.coldforged.org/image-headlines-plugin-for-wordpress-15/

Edited by abinidi
Link to comment
Share on other sites

Thanks for the help, Bruce.

 

Unfortunately, however, that is a generic WP function, and it is used regardless of whether or not the Image Headlines plugin is enabled. Here is my code block:

 

><?php if (function_exists('FUNCTION_NAME')) { ?>
 <h2 id="post-<?php the_ID(); ?>"><?php the_title('-image-'); ?><span style="display:none"><?php the_title(); ?></span></h2>
<?php } else {?>
 <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
<?php } ?>

 

So the function the_title() is active in both cases. I'm looking for the function that WordPress uses to know that the Image Headlines plugin is actually active. There must be some way, because when you go to the plugin's page, the ImageHeadlines line is green, along with the other active plugins. I just wonder what the function name is that shows it is active.

 

Does that make sense?

Link to comment
Share on other sites

I was looking at the plugin source and all the functions within the plugin are using the php if clause so maybe it will just die gracefully if not activated.

 

Deactivate it on your site and see what happens. You can always get back to the admin panel with the your-blog-address/wp-admin/

Link to comment
Share on other sites

It doesn't kill the page, but it replaces the post title with the word "-image-" followed by the post's title. And it doesn't appear in the H2 style, as it should. It just appears as plain text.

 

That is why I hoped to include an if condition for if the plugin is active and an else condition for if the plugin is not active.

 

-Paul

Link to comment
Share on other sites

Sorry Paul, I just don't see it. I've been through the script several times. The problem is you are not calling a function Wordpress is using the -image- to trigger calling it somehow.

 

From their readme file.

In order to have your titles turned into images, you have to change how

you get your titles! Why? Well, if I went around changing every single

invocation of the title into an image you'd have images in your RSS feeds

and anywhere else you call "the_title()". You don't want that. Instead,

you tell me which of your titles you want to be images. You do that by

editing your template -- for instance, your Main Template which generally

controls how your home page will look -- and search for the following

text:

 

the_title();

 

Shouldn't be hard to find. Make certain that this is the one you want

changed, it might appear elsewhere in the file. This is the one somewhere

after the "while (have_posts()) : the_post()" stuff. You'll change this

text to look like this instead:

 

the_title('-image-');

 

That's it! What this does is tell the plugin "hey plugin, I want you to

magically turn this into an image for me, alright?" And the plugin will,

if everything is as it should be, turn it into an image for you.

Link to comment
Share on other sites

Sorry Paul, I just don't see it. I've been through the script several times. The problem is you are not calling a function Wordpress is using the -image- to trigger calling it somehow.

 

Thanks. I appreciate your help. Maybe the if function exists option won't work because maybe it isn't a standard function.

 

I'm kind of glad to know it isn't just me. Because I've been banging my head on the wall over this one all day. At least I didn't miss something obvious.

 

I wonder how the Plugins page knows that the plugin is active? I wonder if I could copy that little bit of code....

Link to comment
Share on other sites

abinidi, the function you're looking for is 'imageheadlines,' which is defined on line 933 of that plugin. The plugin works its voodoo by filtering the WP function the_title(). So I think what you're looking for is:

 

><?php if (function_exists('imageheadlines')) { ?>
  things to do if the plugin is enabled
<?php } else { ?>
  things to do if the plugin is disabled
<?php } ?>

Link to comment
Share on other sites

  • 3 weeks later...
abinidi, the function you're looking for is 'imageheadlines,' which is defined on line 933 of that plugin. The plugin works its voodoo by filtering the WP function the_title(). So I think what you're looking for is:

 

><?php if (function_exists('imageheadlines')) { ?>
  things to do if the plugin is enabled
<?php } else { ?>
  things to do if the plugin is disabled
<?php } ?>

 

Wow. I just saw this. THANK YOU!!!! You are my hero of the day!!! :thumbup:

 

Now I'll go add this and see how it works.

 

Thank you thank you thank you!

 

Yay!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...