1

First of, I have read "Override default php function" and namespaces doesn't fulfil my need. I have also looked into PHP.net's override_function() but that can't help me with my problem either.

I am using a Wordpress plugin called Jigoshop as an eCommerce solution but in some cases I cannot remove the actions I need to apply my own structure to a 'single product' page. I do not want to edit the plugin files themselves as a plugin update may negate and remove my previous changes. Essentially, I want to control the output through my /themes/mytheme/functions.php file.

Has anyone come across this before whereby the original function is contained in a file I do not want to edit for that same 'updating' reason?

Thanks

EDIT (2012-11-21): I have a custom function in my functions.php file like so:

function prepare_jigoshop_wrappers() {
    remove_action('jigoshop_before_main_content', 'jigoshop_breadcrumb', 20);
    add_action('jigoshop_before_main_content', 'custom_jigoshop_breadcrumb', 10);
}
add_action('wp_head', 'prepare_jigoshop_wrappers');

This essentially allows me to apply my own structure & configuration. For other default functions, it is a little more difficult. For example, the 'quantity selector', 'Add to Cart' button and 'stock availability' all are contained within a function called jigoshop_template_single_summary in the jigoshop_template_actions.php file calling the likes of _title, _price, _excerpt, _meta, _sharing & _add_to_cart.

The order these are displayed, I cannot seem to change. Therefore, I want to essentially redefine function jigoshop_template_single_summary() {...}

Community
  • 1
  • 1
carmat
  • 328
  • 4
  • 12
  • Perhaps you could elaborate on the specifics of your problem as there may be alternate solutions that don't involve overriding at all. What output is the plugin function giving and how do you want to modify it? – Jared Nov 20 '12 at 17:36

2 Answers2

1

You may want to look into PECL extension. It may do what you need, docs on PHP.NET.

runkit_function_redefine

(PECL runkit >= 0.7.0)

Gary
  • 2,866
  • 1
  • 17
  • 20
  • runkit is basically dead. There's no stable release that builds on PHP 5.2, and none at all for 5.3 or later. –  Nov 20 '12 at 19:13
  • Disclaimer, I have not used, but...The official runkit extension is now hosted on http://github.com/zenovich/runkit The current master branch fully supports all contemporary PHP versions from 4.4 to 5.3 & 5.4 inclusively. – Gary Nov 20 '12 at 19:21
  • Thanks guys. Question though, can I do something like so with the runkit function? `runkit_function_redefine('original_function', $args, 'my_new_function');` I have also updated the question with some more info. Cheers – carmat Nov 21 '12 at 09:19
0

I don't know this plugin very well but probably this is what you Need Theming with Jigoshop

Override some functions in php(also in common..) is never a good idea. If the plugin doesn't provide a way to hook into it's functionality is sometimes better to use an alternative plugin or rewrite the core code..

Philipp
  • 15,377
  • 4
  • 35
  • 52
  • Thanks @Philipp. I have been following the Jigoshop instructions but I almost wish it was easier to customise the markup so I can have do exactly what I want it to. I have updated the original question with more info. Thanks though. – carmat Nov 21 '12 at 09:21