abinidi Posted January 8, 2007 Share Posted January 8, 2007 (edited) 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 January 8, 2007 by abinidi Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 8, 2007 Share Posted January 8, 2007 It looks like the function you need to test for is >the_title() Quote Link to comment Share on other sites More sharing options...
abinidi Posted January 8, 2007 Author Share Posted January 8, 2007 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? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 8, 2007 Share Posted January 8, 2007 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/ Quote Link to comment Share on other sites More sharing options...
abinidi Posted January 8, 2007 Author Share Posted January 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 8, 2007 Share Posted January 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
abinidi Posted January 8, 2007 Author Share Posted January 8, 2007 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.... Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 9, 2007 Share Posted January 9, 2007 Does it write the options to the database that you set? I assume it does. That must be how it's doing it. Quote Link to comment Share on other sites More sharing options...
joefish Posted January 9, 2007 Share Posted January 9, 2007 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 } ?> Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 9, 2007 Share Posted January 9, 2007 Thanks joefish! I swear I looked over that file several times and didn't see it. Thanks! Quote Link to comment Share on other sites More sharing options...
joefish Posted January 9, 2007 Share Posted January 9, 2007 Glad to help. That function is easy to miss. All those extra conditionals make it a tough read. Quote Link to comment Share on other sites More sharing options...
abinidi Posted January 25, 2007 Author Share Posted January 25, 2007 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!!! Now I'll go add this and see how it works. Thank you thank you thank you! Yay!!! Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted January 25, 2007 Share Posted January 25, 2007 Yes, joefish does know this WP stuff. He helped me sort out a theme issue so I can upgrade to WP 2.1. Thanks again Joe! Quote Link to comment Share on other sites More sharing options...
abinidi Posted January 25, 2007 Author Share Posted January 25, 2007 Awesome. Worked perfectly. Thanks again!!! Now I can share my theme Quote Link to comment Share on other sites More sharing options...
joefish Posted January 25, 2007 Share Posted January 25, 2007 You're welcome, both of you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.