0

I am using the Marketpress plugin. I want to modify single_order_funct() function HTML content in it. I want to make changes so that, when it is updated, I don't lose them.

class PluginClass{
 function single_order_funct() {
?>
   <h1>test</h1>
<?php
}

function orders_funct() {
 if (isset($_GET['order_id'])) {
    $this->single_order_funct();
    return;
 }
}

Whenever single_order_funct() function is called, I want to modify the HTML content it returns. How can I do it with remove_action() and add_action() or is there any other way to do it?

5
  • Please edit your question to include the function definition for single_order_funct(). Apr 10, 2014 at 20:55
  • @ChipBennett The single_order_funct() definition is there. Apr 10, 2014 at 20:58
  • single_order_funct() is available in the code i provided Apr 10, 2014 at 21:00
  • MarketPress has a support forum. Have you already asked there?
    – kaiser
    Apr 10, 2014 at 21:40
  • How is that code used? It doesn't use any hooks internally.
    – s_ha_dum
    Apr 10, 2014 at 21:45

1 Answer 1

0

If you want to make the output filterable, you simply need to define a custom filter, and pass the output through it.

Your function outputs (echoes) this value:

<h1>test</h1>

If you want it to be filterable, you need to put that output in a PHP string. Instead of this:

?>
    <h1>test</h1>
<?php

Do something like this:

$output = '<h1>test</h1>';

Then echo it:

// Define
$output = '<h1>test</h1>';
// Output
echo $output;

Now, you have something that you can pass through a custom filter, which you would define using apply_filters():

apply_filters( $filter_name, $value );

Let's call this filter wpse140953_order_funct:

// Define
$output = '<h1>test</h1>';
// Output
echo apply_filters( 'wpse140953_order_funct', $output );

...and that's it. Now the output is filterable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.