Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Filters and Hooks Needed

  1. #1
    Thread Starter
    Rookie
    Not a Verified Customer
    rayray's Avatar
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Filters and Hooks Needed

    As eluded to in my previous post:
    http://appthemes.com/forum/showthrea...d-Types-Needed

    We need hooks and filters in CP. Why? So hacking the CP core is no longer needed.

    This poster also gets my point:
    http://appthemes.com/forum/showthrea...ith-V2.9-Looks

    But the developers can't seem to distinguish between a search filter and a Wordpress filter.

    How to add a filter to your code:
    http://codex.wordpress.org/Function_Ref ... ly_filters

    Example:

    In step-functions.php, we need a filter so we can override the custom post meta.

    Something like this will work in the cp_add_new_listing() on line 637:
    Code:
    $advals = apply_filters('cp_custom_meta', $advals);
    Then developers can easily override this via a plugin or a via a function in a child theme's functions.php.

    Like:

    Code:
    function my_cp_custommeta($advals)
      $advals = WHATEVER;
     
      return $advals;
    }
    add_filter( 'cp_custom_meta', 'my_cp_custommeta');
    I'd also remove line 640:
    Code:
    if (cp_str_starts_with($meta_key, 'cp_'))
    Not sure what the logic was in restricting postmeta to only the "cp_" prefix. Doesn't make sense to me.
    Last edited by pepsi; July 7th, 2010 at 04:19 AM.

  2. #2
    Thread Starter
    Rookie
    Not a Verified Customer
    rayray's Avatar
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filters and Hooks Needed

    I'm just re-reading my post and it does read like I'm being a little harsh!

    That wasn't my intention!

    Also I think the poster in this thread was talking about search filters after all. So I take back what I said there.

    But I do urge CP developers to consider filters and actions in a future release.

    Hacking the core isn't fun when it's time to upgrade.
    Last edited by pepsi; July 7th, 2010 at 04:20 AM.

  3. #3
    pepsi's Avatar
    Join Date
    Mar 2009
    Location
    New Zealand
    Posts
    14,883
    Thanks
    91
    Thanked 804 Times in 718 Posts

    Re: Filters and Hooks Needed

    If you refer to this thread http://appthemes.com/forum/showthrea...ch-by-Location, there is a comment by the developer which may be of interest to you which may clarify what you're asking..
    Last edited by pepsi; July 7th, 2010 at 04:20 AM.

  4. #4
    Thread Starter
    Rookie
    Not a Verified Customer
    rayray's Avatar
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filters and Hooks Needed

    Hi pepsi,

    Thanks for taking the time to answer, but that thread you pointed me to doesn't talk at all about plugin filters or actions; that thread talks about search filters, which isn't what I'm talking about.

    My request is more suited towards the codebase and not about features.

    If you can point the lead dev to take a look at this thread, I would very much appreciate it.

  5. #5
    pepsi's Avatar
    Join Date
    Mar 2009
    Location
    New Zealand
    Posts
    14,883
    Thanks
    91
    Thanked 804 Times in 718 Posts

    Re: Filters and Hooks Needed

    Sorry, I skimmed your post and saw reference to filters and went straight to the "usual" questions/comments about it being related to search.... I will refer the thread to one of the developers. Thanks.

  6. #6
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Filters and Hooks Needed

    Rayray,

    While I somewhat agree with you logic of building filters and hooks for the theme, we have not yet decided to implement that functionality. Instead we are using a more common and simple functionality for our functions, which is the ability to "override" the functions. This is the functionality that wordpress codex suggests in theme files.

    I have also GREATLY increased the ability to build child themes, thus removing the need to constantly worry during upgrades. After 3.0.3 I'll be releasing a tutorial on the blog that indicates some information about creating a child theme, and making and example modification. Then, when 3.1.0 comes out, all you will have to do is upgrade the core theme, and modify any of your child theme files that need to be adjusted to work properly based on the change_log.

    While I didn't answer your question the way you may wish, with a yes, its a "alternative" to what you are seeking to provides a similar end result.

    Make sure you read the "README-FIRST.txt" file in the new release, as it will have lots of information for you regarding which functions can be used with the override functionality in the functions.php file.
    ~ Seth Carstens, Sethmatics Inc.


  7. #7
    Thread Starter
    Rookie
    Not a Verified Customer
    rayray's Avatar
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filters and Hooks Needed

    Hi scarstens,

    Are you talking about making pluggable functions?
    That is okay, but still a little redundant. If you're going the pluggable route, how much of the codebase are you going to make pluggable? I still think filters are easier and require less duplication.

    Can you pass a link to the Wordpress codex article you touch upon?

    FYI, I've built child themes before.

    Thanks!

  8. #8
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Re: Filters and Hooks Needed

    http://codex.wordpress.org/Child_The..._functions.php

    I spent a LONG time looking to go through almost every function in the theme-functions.php file. Every function that we thought was something I've seen people overwrite in the forums, we allowed as pluggable. Again, see the README-FIRST file and you will see the VERY long list of pluggable function in 3.0.3.

    I'm not saying we will never build it in. Provide a "mod" tutorial in the forum where you convert one of the functions into a filtered function and then apply a filtered change. This would give light to the actual need of this feature request you have. We don't build it "just because" it would be nice, it needs to serve a quantifiable purpose to our license holders. I'm sure you understand this. Otherwise we have to charge 600-1,000 for a license like many of the other classified software's out there. I don't think David (the owner) is looking to be in that market at this point.
    ~ Seth Carstens, Sethmatics Inc.


  9. #9
    Veteran vienna's Avatar
    Join Date
    May 2010
    Location
    Vienna, Austria
    Posts
    718
    Thanks
    19
    Thanked 177 Times in 118 Posts

    Re: Filters and Hooks Needed

    Scarstens, you refer to reading the documentation for 3.0.3. Is 3.0.3 OUT already? I have not seen any reference to its release.

  10. #10
    Thread Starter
    Rookie
    Not a Verified Customer
    rayray's Avatar
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Filters and Hooks Needed

    I don't see any blog post about CP 3.0.3 being released. Glad to hear that pluggable functions are making its way in this release.

    As for a tutorial on plugin filters, see the first post in this thread where I highlight what can be done (applicable to CP 3.0.2). There's also a link to the plugin filters article on the WP codex. Tell your entire dev team to check it out.

    Yes, I agree that something such as plugin filters should be discussed with your CP dev team in regards to what sections of the code filters should apply to. This is similar to agreeing upon which functions should be pluggable.

    FYI, I'm currently hacking the cp_add_new_listing() function in /includes/form/step-functions.php, I'd suggest making some of those functions in that file pluggable as well.

    Also, just as a real-world example, BuddyPress' default parent theme uses filters, CP should think about it as well.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Google AdSense Competitive Ad Filters Needed
    By jschodde in forum ClassiPress General Discussion
    Replies: 5
    Last Post: August 26th, 2009, 04:40 PM