/ Published in: PHP
Codigo base para un widget en Wordpress
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * @Author Jonathon byrd * @link http://www.jonathonbyrd.com * @Package Wordpress * @SubPackage Widgets * @copyright Proprietary Software, Copyright Byrd Incorporated. All Rights Reserved * @Since 1.0.0 * * Plugin Name: Document Widget * Plugin URI: http://www.redrokk.com * Description: <a href="http://redrokk.com" target="_blank">redrokk</a> Designs and develops software for WordPress, Drupal, Joomla, Cakephp, SugarCRM, Symfony and more! * Version: 1.0.0 * Author: redrokk * Author URI: http://www.redrokk.com * * */ /** * Initializing * * The directory separator is different between linux and microsoft servers. * Thankfully php sets the DIRECTORY_SEPARATOR constant so that we know what * to use. */ /** * Actions and Filters * * Register any and all actions here. Nothing should actually be called * directly, the entire system will be based on these actions and hooks. */ /** * * @author byrd * Document Widget */ class Document_Widget extends WP_Widget { /** * Constructor * * Registers the widget details with the parent class */ function Document_Widget() { // widget actual processes } function form($instance) { // outputs the options form on admin ?> Form goes here <?php } function update($new_instance, $old_instance) { // processes widget options to be saved $instance = wp_parse_args($old_instance, $new_instance); return $instance; } function widget($args, $instance) { // outputs the content of the widget $title = apply_filters( 'widget_title', $instance['title'] ); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?> Widget view to users goes here <?php } }
URL: https://raw.github.com/gist/1229641/0ee56f0a6acea66edace198c9866bad5f6701527/QuickWidget.php