h6e

Zend Framework Wordpress plugin

This plugin simply embed and load the Zend Framework libraries so that they can be shared by different plugins on the same Wordpress instance.

The current version use Zend Framework 1.11.2.

SVN

Download

Usage

Zend Framework is automatically made available in the PHP include path.

Also, since 1.9.3, auto-loading is enabled, so you don't have to take care including the classes you want to use.

You just have to require and use your favorite libraries in your plugin code. Example:

function hi()
{
  $items = new Zend_Feed_Rss('http://wordpress.org/development/feed/');
  foreach ($items as $item) {
    echo '<p id="hello"><a href="' . $item->link() . '">' . $item->title() . '</p>';
    break;
  }
}
add_action('admin_footer', 'hi');

You may check Zend Framework availability using the WP_ZEND_FRAMEWORK constant:

function my_plugin_check_zend_framework()
{
  // if the ZF plugin is successfully loaded this constant is set to true
  if (defined('WP_ZEND_FRAMEWORK') && constant('WP_ZEND_FRAMEWORK')) {
    return true;
  }
  // you can also check if ZF is available on the system
  $paths = explode(PATH_SEPARATOR, get_include_path());
  foreach ($paths as $path) {
    if (file_exists("$path/Zend/Loader.php")) {
      define('WP_ZEND_FRAMEWORK', true);
      return true;
    }
  }
  // nothing found, you may advice the user to install the ZF plugin
  define('WP_ZEND_FRAMEWORK', false);
}
 
add_action('init', 'my_plugin_check_zend_framework');

Categories: Wordpress, PHP, Zend Framework

wordpress/plugins/zend-framework.txt · Last modified: 2011/01/10 10:05 by znarfor