Sto cercando di aggiungere alcune funzionalità da un plug-in che ho trasformato in un tema Wordpress ma ho poca gioia. La documentazione in realtà non mi aiuta a risolvere il problema, quindi forse qualcuno qui può aiutarti.Wordpress: accesso a una funzione del plug-in da un tema
Ho un plugin in Wordpress che è attivato e funziona bene. La classe per questo plugin ha una funzione chiamata generateHtml a cui vorrei accedere da un tema Wordpress. Ma qualunque cosa provi, non riesco ad accedere al codice del mio plugin.
possibile darmi una sintesi di ciò che devo fare per ottenere un codice tema Accesso da un plugin e/o segnalare ci sto andando male nel mio codice:
Plugin:
<?php
/** Usual comments here **/
if (!class_exists("ImageRotator")) {
class ImageRotator {
private $uploadPath = '';
private $pluginPath = '';
private $options;
function __construct() {
$this->uploadPath = dirname(__file__).'\\uploads\\';
// add_shortcode('imagerotator', array(&$this, 'generateHtml'));
}
// Various functions for plugin
function generateHtml() {
echo '<p>Hello World</p>';
}
}
}
/**
* Create instance of image rotator
*/
$imageRotator = new ImageRotator();
/**
* Create actions & filters for Wordpress
*/
if (isset($imageRotator)) {
// Actions
add_action('admin_menu', array(&$imageRotator, 'createMenu'));
add_action('admin_init', array(&$imageRotator, 'registerSettings'));
add_action('imagerotator_show', array(&$imageRotator, 'generateHtml'));
}
Porzione di intestazione pagina tema:
<?php if (isset($imageRotator)) {
$imageRotator->generateHtml();
} else if (isset($ImageRotator)) {
print_r($ImageRotator);
} else {
echo '<p>Nope!</p>';
}
if (function_exists("imagerotator_show")) {
echo 'Function found';
} else {
echo 'Function NOT found';
}
?>
Attualmente tutti che io abbia mai visto è "No" e "funzione non trovato". Grazie per qualsiasi input.
Lee,
Come nota a margine, questo dovrebbe essere utile a tutti i progettisti di temi wordpress: http://devideas.blogetery.com/testing-wordpress-themes-easily/ – Sarfraz