Skip to content

Instantly share code, notes, and snippets.

@igmoweb
igmoweb / setting-class-basico.php
Last active August 29, 2015 14:01
Hola Dollly WooCommerce API Basic Settings Class
<?php
class WC_Settings_Hola_Dolly extends WC_Settings_Page {
public function __construct() {
$this->id = 'hola-dolly';
$this->label = __( 'Hola Dolly', 'hola-dolly' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
@igmoweb
igmoweb / incluyendo-settings-class.php
Last active August 29, 2015 14:01
Incluyendo nuestra clase de opciones
<?php
add_filter( 'woocommerce_get_settings_pages', 'holadolly_include_woocommerce_setting_file' );
function holadolly_include_woocommerce_setting_file ( $settings ) {
$settings[] = include( HOLADOLLY_PLUGIN_DIR . 'class-wc-settings-holadolly.php' );
return $settings;
}
@igmoweb
igmoweb / gist:34b625214dae88dc220c
Last active August 29, 2015 14:01
Creando secciones
<?php
class WC_Settings_Hola_Dolly extends WC_Settings_Page {
public function __construct() {
$this->id = 'hola-dolly';
$this->label = __( 'Hola Dolly', 'hola-dolly' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
@igmoweb
igmoweb / campo-simple.php
Last active August 29, 2015 14:01
Creando un campo sencillo en las opciones de WooCommerce
<?php
public function get_settings() {
$settings = array(
array( 'title' => __( 'Opciones Generales', 'hola-dolly' ), 'type' => 'title', 'id' => 'holadolly_general_options', 'desc' => __( 'Nuestras opciones generales.', 'hola-dolly' ) ),
array(
'title' => __( 'Un número', 'hola-dolly' ),
'id' => 'holadolly_general_options_number',
@igmoweb
igmoweb / guardar-cambios.php
Last active August 29, 2015 14:01
Hook que guarda las opciones añadido
<?php
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 );
// Mostrar los campos
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
@igmoweb
igmoweb / pinteres-embed.php
Created May 14, 2014 09:11
Pinteres Embeds
<?php
/**
* Plugin Name: Pinterest embeds
*/
class Pinterest_Embed {
public $embedded = false;
@igmoweb
igmoweb / hook-ejecutado.php
Last active August 29, 2015 14:01
How to know if a hook has already been executed
<?php $hook_executed = did_action( 'init' ); ?>
@igmoweb
igmoweb / hooks-already-executed.php
Last active August 29, 2015 14:01
Check what hooks have been already executed
<?php
global $wp_actions;
var_dump($wp_actions);
@igmoweb
igmoweb / filter-being-executed.php
Created May 17, 2014 16:49
What filter is being executed
<?php $hook_name = current_filter(); ?>
@igmoweb
igmoweb / custom-options-woocommerce.php
Created May 20, 2014 12:02
Adding custom options with WooCommerce Settings API
<?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 );