Basic help with a plugin

[ad_1]

add_filter( ‘plugins_loaded’, array( ‘FootballPoolExtensionRankingTemplate’, ‘init_extension’ ) );

class FootballPoolExtensionRankingTemplate {
protected static $items = array( ‘$50’, ‘$40’, ‘$30’ );
protected static $item_counter = 0;

public static function init_extension() {
// Laat een bericht zien als de Football Pool plugin niet geactiveerd is.
if ( ! class_exists( ‘Football_Pool’ ) ) {
add_action( ‘admin_notices’, array( __CLASS__, ‘no_fp_plugin_error’ ) );
return;
}

// Verander de template.
add_filter( ‘footballpool_ranking_ranking_row_template’, array( __CLASS__, ‘change_template’ ), 10, 2 );
}

public static function change_template( $ranking_template, $type ) {
$ranking_template = ‘<tr class=”%css_class% jokers-used-%jokers_used%”>
<td class=”user-rank”>%rank%.</td>
<td class=”user-name”><a href=”%user_link%”>%user_name%</a></td>
<td class=”user-score ranking score”>%points%</td>
<td class=”user-league”>%league_image%</td>
<td class=”user-prize”>’.self::$items[‘%rank%’].'</td>
</tr>’;
return $ranking_template;
}

public static function no_fp_plugin_error() {
$plugin_data = get_plugin_data( __FILE__ );
$plugin_name = isset( $plugin_data[‘Name’] ) ? $plugin_data[‘Name’] : __CLASS__;
echo “<div class=’error’><p>De Football Pool plugin is niet geactiveerd. ”
. “Zorg ervoor dat je het activeert zodat de extensie plugin ‘{$plugin_name}’ nuttig is.</p></div>”;
}
}

I’m trying to make my first smaller adaptation plugin for a plugin.
The code is as followed.
The problem i have is that (i assume) change\_template is called only once with placeholders and i want to add a variable from the array $items in the last TD of each TR.

I cannot seem to get this to work. The table shows which is good but my values from my array does not. First TR should show $50, next one $40, etc…

Anyone able to help a noob in this?
Thanks in advance.

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer