Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / display-special-field-woocommerce.php
Last active August 29, 2015 14:01
Displaying new custom option in WooCommerce
<?php
class WC_Settings_Hola_Dolly extends WC_Settings_Page {
public function __construct() {
$this->id = 'hola-dolly';
$this->label = __( 'Hola Dolly', 'hola-dolly' );
// Añadir pestaña
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
@igmoweb
igmoweb / display-textarea-woocommerce.php
Last active August 29, 2015 14:01
Display textarea in WooCommerce Settings
<?php
public function display_special_field( $field ) {
$option_value = get_option( $field['id'], $field['default'] );
?>
<label for="<?php echo $field['id']; ?>" ><?php echo esc_html( $field['title'] ); ?></label><br/>
<textarea name="<?php echo $field['id']; ?>" id="<?php echo $field['id']; ?>"><?php echo esc_textarea( $option_value ); ?></textarea>
<?php
@igmoweb
igmoweb / complete-woocommerce-setting-class.php
Created May 20, 2014 12:39
Woocommerce new setting class complete
<?php
class WC_Settings_Hola_Dolly extends WC_Settings_Page {
public function __construct() {
$this->id = 'hola-dolly';
$this->label = __( 'Hola Dolly', 'hola-dolly' );
// Añadir pestaña
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
@igmoweb
igmoweb / curso-fictizia-contact-form.php
Last active August 29, 2015 14:06
Formulario de contacto
<form action="" method="POST">
<p>
<label for="email"><?php _e( 'Email', 'ignacio' ); ?>
<input id="email" type="email" name="email" value="" />
</label>
</p>
<p>
<label for="message"><?php _e( 'Message', 'ignacio' ); ?></label>
<textarea id="message" name="message"></textarea>
</p>
@igmoweb
igmoweb / basic-comments.php
Last active August 29, 2015 14:06
Basic Comments
<?php
if ( post_password_required() )
return;
?>
<div id="comments" class="comments-area">
<?php if ( comments_open() && get_comments_number() ): ?>
@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;
}
@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-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' ) );
<?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
}
<?php
function form( $instance ) {
$defaults = array(
'title' => 'Fictizia Widget'
);
$instance = wp_parse_args( $instance, $defaults );
?>