• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Playing with Hooks, Actions and Filters...

Started by Madalin Adrian,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madalin AdrianTopic starter

I noticed that you took this idea from WordPress... so far that's a very good idea (or should I say brilliant?). The problem started when i tried to use it.

Take a look at this code:

<?php 

function content_for_html_head(){

$meta = '<!--

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pharetra rhoncus dolor sit amet viverra.

-->';

$meta .= "\n";

return $meta;

}


function apply_filter_for_html_head() {

echo apply_filters('vibe_meta_filter', content_for_html_head());

}

add_action('vibe_header', 'apply_filter_for_html_head', 1);


So what's the problem then?

Using the `add_action` from above, the dummy lorem ipsum paragraph it is showed after `header_add` (the first filter from `tpl globals` - picture 1)

For the following code (with the third variable changed to 0) it is showed before `meta_add` filter, on the first line off the html output (pic. # 2)

add_action('vibe_header', 'apply_filter_for_html_head', 0);


For values >= 2 the output is displayed exactly as in case 1.

*My code was inspired from `/lib/functions.php` and `/tpl/main/tpl.globals.php`.

So... what should i do to get my lorem ipsum content exactly after the first filter (between `meta_add` and `header_add`)?

#1


#2




PS: Now this is what i call a problem...




PHPVibe Rocks!
  •  

Madalin AdrianTopic starter

I can't modify the first post anymore...

So the problem is with the priority.

Quote* @param integer $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default=10, lower=earlier execution, and functions with the same priority are executed in the order in which they were added to the filter)

And this was from `/lib/functions.plugins.php` but i still don't understand why it is not working...
PHPVibe Rocks!
  •  

Marius P.

I will help you once all the filters are in place on rc2, they are a bit changed.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Madalin AdrianTopic starter

Quote from: @Mario on
I will help you once all the filters are in place on rc2, they are a bit changed.

Thank you.

You may also try to follow the wordpress way to use plugins: a special folder where you place your plugins, read some predefined settings frome one file (ex:settings.php), activate/deactivate the plugin from admin and maybe a options page in admin taking advantage in this way of the new added options api.

That would be great!

PHPVibe Rocks!
  •  

Marius P.

That's the plan, but it won't be a short development to get there.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Madalin AdrianTopic starter

PHPVibe Rocks!
  •  

Marius P.

How will that help?
There is already a built system of hooks and filters 99% borrowed from Wordpress...basically every tutorial for WP should work on the matter, but I need to document available/predefined filters already in the script.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Madalin AdrianTopic starter

I was talking about this:


Quote from: Madalin Adrian on
You may also try to follow the wordpress way to use plugins: a special folder where you place your plugins, read some predefined settings frome one file (ex:settings.php), activate/deactivate the plugin from admin and maybe a options page in admin taking advantage in this way of the new added options api.

That would be great!


PHPVibe Rocks!
  •  

Marius P.

What difference would it make if you do a include line for the plugin in load.php for example?
Would be safer, I got hacked from Wp countless times.


I understand what you are saying and it sounds useful as we talked about, but security raises a bit of concern, also the extra query to check if the plugin is enabled or so...many have to many videos to afford extra queries on any page.
Happy with my help? Buy me a coffee.
Please, always use the search before opening a new topic! We're all here on our (limited) free time! Make sure you help yourself too!
  •  

Madalin AdrianTopic starter

PHPVibe Rocks!
  •  

Similar topics (7)