Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First Plugin
#1
Hi all,

I'm looking to create my first plugin here in GS. It's going to be very simple, just making vTicker available as a plugin to display rolling news on the sidebar, or anywhere in the page. I need some advice, and I have read the plugins wiki, but I'm still not clear on a few bits.

Here is my plan: I will need two files, jquery.js and vticker.php. I will
1. Create a submenu in theme tabs, used for configuring options and news content in vticker.
2. Content of vticker.js will be included into vticker.php as embedded JS. This JS code will need to be placed into header.php when placed on a page.
3. Dynamically, using PHP, to configure options and insert news content.
4. Create tags to place the content of vTicker.
5. Include additional styling options.

I'm having issues at point 2 and 4,
- Point 2: how do I place this piece of code into header.php using the plugin PHP file that I have?
- Point 4: how do I create a tag to be inserted in pages?

Regards,
Angela
Reply
#2
angelazou Wrote:Hi all,

I'm looking to create my first plugin here in GS. It's going to be very simple, just making vTicker available as a plugin to display rolling news on the sidebar, or anywhere in the page. I need some advice, and I have read the plugins wiki, but I'm still not clear on a few bits.

Here is my plan: I will need two files, jquery.js and vticker.php. I will
1. Create a submenu in theme tabs, used for configuring options and news content in vticker.
2. Content of vticker.js will be included into vticker.php as embedded JS. This JS code will need to be placed into header.php when placed on a page.
3. Dynamically, using PHP, to configure options and insert news content.
4. Create tags to place the content of vTicker.
5. Include additional styling options.

I'm having issues at point 2 and 4,
- Point 2: how do I place this piece of code into header.php using the plugin PHP file that I have?
- Point 4: how do I create a tag to be inserted in pages?

Regards,
Angela

4. It's just a function (maybe with parameters) in your plugin that will be called in your template or a component, e.g.
Code:
<?php get_vticker(); ?>

2. You don't need to put the JS into the header, just include it in the body when above function is called. As for jQuery, you can either state in your plugin's requirements that jQuery has to be included in the template, or if you include it yourself (where the function is called), you must provide an option to switch off inclusion.

2./5. If you want to have the JS, jQuery and possibly css styles in the header, you can use the hook theme-header.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Hi,

I think what I want to add is a tag like the one you use in the I18N gallery, so user can choose where to include this scroller and its related functions (although I think it's much more likely to see users placing the scroller on every single page, plus, I'm not sure I should be lazy enough to let the user do this work).

And the jQuery file you mention, the option to include it or not. I don't know how that would work out, honestly, because this original component requires at least jquery 1.4, and I have no idea where the user would place this file. I place it in the themes folder, another user might place it in the data folder. I would then need a function to search through the all the directories to find it? I'm not sure.
Still, I do think this is an important design option, don't get me wrong, but I'm just not sure if this is the best way to go.

Regards,
Angela
Reply
#4
angelazou Wrote:I think what I want to add is a tag like the one you use in the I18N gallery, so user can choose where to include this scroller and its related functions (although I think it's much more likely to see users placing the scroller on every single page, plus, I'm not sure I should be lazy enough to let the user do this work).

Then see the function i18n_gallery_replace, which is called on the content filter (add_filter('content','i18n_gallery_replace');/). If somebody wants to include the gallery in the sidebar, he can use get_i18n_gallery - both call i18n_gallery_display in the end.

angelazou Wrote:And the jQuery file you mention, the option to include it or not. I don't know how that would work out, honestly, because this original component requires at least jquery 1.4, and I have no idea where the user would place this file. I place it in the themes folder, another user might place it in the data folder. I would then need a function to search through the all the directories to find it? I'm not sure.
Still, I do think this is an important design option, don't get me wrong, but I'm just not sure if this is the best way to go.

The easiest way is to tell the user to make sure he includes jQuery 1.4+ in the template.

In I18N Gallery I include a version of jQuery in the plugin (in the directory i18n_gallery/js) and include it if needed.
Of course, if the user includes multiple plugins (on the same page or in the template and page) all using jQuery, he must include it himself and switch off jQuery inclusion in the plugins, as otherwise jQuery would be included multiple times.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)