Skip to content

Instantly share code, notes, and snippets.

<?php
global $wpdb;
$tablename = $wpdb->prefix . 'fictizia_clientes';
$charset_collate = '';
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
<?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' ) );
<?php
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
?>
<?php echo $before_widget; ?>
<?php if ( $title )
echo $before_title . $title . $after_title; ?>
Hola, mundo
<?php
function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
?>
<?php echo $args['before_widget']; ?>
<?php if ( $title )
echo $args['before_title'] . $title . $args['after_title']; ?>
<?php
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$title = sanitize_text_field( $new_instance['title'] );
if ( ! empty( $title ) )
$instance['title'] = $title;
return $instance;
<?php
function form( $instance ) {
$defaults = array(
'title' => 'Fictizia Widget'
);
$instance = wp_parse_args( $instance, $defaults );
?>
<?php
function form($instance) {
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="" />
</label>
</p>
<?php
}
@igmoweb
igmoweb / fictizia-plugin-1.php
Created October 6, 2014 14:21
Creación de un plugin
<?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' ) );
@igmoweb
igmoweb / portofolio-query.php
Last active August 29, 2015 14:07
Portfolio Query
$args = array(
'ignore_sticky_posts' => true,
'posts_per_page' => $atts['items'],
'post_type' => 'post',
'post_status' => 'publish'
);
$posts = get_posts( $args );
$html = '<ul>';
@igmoweb
igmoweb / fictizia-change-strings.php
Created October 1, 2014 18:54
Cambiar strings en WordPress
add_filter( 'gettext', 'fictizia_change_strings', 10, 3 );
function fictizia_change_strings( $translate, $text, $domain ) {
if ( $text === 'Custom Header' && $domain === 'default' ) {
return 'Logotipo';
}
return $translate;
}