Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp extending class used in Wordpress plugin
    primarykey
    data
    text
    <p>First, a proviso - I'm a designer not a dev, so please be gentle ;)</p> <p>I'm trying to tweak a Wordpress plugin by extending a class. In the class in a bit of conditional if/elseif-ing the code calls one of two functions. Instead of these functions I've want to call two new ones (effectively the same functions as the old ones but again, slightly tweaked).</p> <p>I've done this successfully before by doing this:</p> <pre><code>class MY_CLASS extends MY_NEW_CLASS { ... </code></pre> <p>Then I change the code in the class and away we go. However, in this case it doesn't appear to be working?</p> <p>Below I've pasted the class code that I've put into my functions.php file:</p> <pre><code>class QA_AJAX_new extends QA_AJAX { function init() { add_action( 'wp_ajax_qa_vote', array( __CLASS__, 'vote' ) ); add_action( 'wp_ajax_qa_accept', array( __CLASS__, 'accept' ) ); } function vote() { global $_qa_votes; $_qa_votes-&gt;handle_voting(); $id = $_POST['post_id']; $post_type = get_post_type( $id ); if ( 'question' == $post_type ) the_question_voting_new( $id ); elseif ( 'answer' == $post_type ) the_answer_voting_new( $id ); else die( -1 ); die; } function accept() { global $_qa_votes; $_qa_votes-&gt;handle_accepting(); $id = $_POST['answer_id']; the_answer_accepted( $id ); die; } } QA_AJAX_new::init(); </code></pre> <p>About half way down you can see the two new functions I want the class to use, <code>the_question_voting_new</code> and <code>the_answer_voting_new</code>. I've also changed the code at the end that now says <code>QA_AJAX_new::init();</code> - I'm not sure if I'm supposed to do that, but I've tried it both ways and neither makes a difference.</p> <p>I'm clearly doing something wrong (or trying to do something that's not possible), something a dev would spot instantly, but my poor designer brain doesn't know enough about php to figure it out.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload