Created
October 6, 2014 14:21
-
-
Save igmoweb/69ac270f7f414d960d95 to your computer and use it in GitHub Desktop.
Creación de un plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Fictizia_Widget extends WP_Widget { | |
// El nombre de la clase tiene que coincidir con esta función | |
function Fictizia_Widget() { | |
// Argumentos | |
$args = array( 'classname' => 'fictizia-widget', 'description' => __( 'Fictizia Widget Description', 'fictizia' ) ); | |
// La clase superior es la que se encarga de crear realmente el widget | |
parent::WP_Widget( false, __( 'Fictizia Widget', 'fictizia' ), $args ); | |
} | |
function form($instance) { | |
// Formulario del widget en administración | |
} | |
function update($new_instance, $old_instance) { | |
// procesa las opciones del widget que se guardarán | |
} | |
function widget($args, $instance) { | |
// saca el contenido del widget | |
} | |
} | |
add_action( 'widgets_init', 'fictizia_register_widget' ); | |
function fictizia_register_widget() { | |
register_widget( 'Fictizia_Widget' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment