Skip to content

Instantly share code, notes, and snippets.

View heldervilela's full-sized avatar

Helder Vilela heldervilela

View GitHub Profile
@heldervilela
heldervilela / nav-menu-item-custom-fields.php
Created April 16, 2016 19:32 — forked from kucrut/nav-menu-item-custom-fields.php
Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
<?php
/**
* Proof of concept for how to add new fields to nav_menu_item posts in the WordPress menu editor.
* @author Weston Ruter (@westonruter), X-Team
*/
add_action( 'init', array( 'XTeam_Nav_Menu_Item_Custom_Fields', 'setup' ) );
class XTeam_Nav_Menu_Item_Custom_Fields {
static $options = array(
add_filter( 'woocommerce_upsell_display_args', 'custom_woocommerce_upsell_display_args' );
function custom_woocommerce_upsell_display_args( $args ) {
$args['posts_per_page'] = 5; // Change this number
$args['columns'] = 5; // This is the number shown per row.
return $args;
}
@heldervilela
heldervilela / add-class-to-body.php
Last active December 19, 2020 01:25
Add Custom Class to Body
/**
* Add custom class to body
*
* @since 1.0.0
*/
add_filter( 'admin_body_class', function( $classes ) {
$classes .= ' --my-class-name ';
return $classes;
});
@heldervilela
heldervilela / replace.sql
Created August 31, 2016 09:59
Replace wp domain
UPDATE wp_options SET option_value = replace(option_value, 'http://extension.pixelthrone.info', 'http://v2.extension.pixelthrone.info') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://extension.pixelthrone.info','http://v2.extension.pixelthrone.info');
UPDATE wp_posts SET post_content = replace(post_content, 'http://extension.pixelthrone.info', 'http://v2.extension.pixelthrone.info');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://extension.pixelthrone.info','http://v2.extension.pixelthrone.info');
@heldervilela
heldervilela / admin-page-framework-demo-dynami-dropdown-in-repeatable-sections.php Demonstrates how a drop-down list can be updated dynamically in repeatable sections using Admin Page Framework.
<?php
/**
* Plugin Name: Admin Page Framework Demo - Dynamic Drop-down in Repeatable Sections
* Plugin URI: http://en.michaeluno.jp/admin-page-framework
* Description: Demonstrates how a drop-down list can be updated dynamically in repeatable sections.
* Author: Michael Uno
* Author URI: http://michaeluno.jp
* Version: 1.0.0
*/
@heldervilela
heldervilela / admin-page-framework-custom-text-after-form-submission.php
Created November 6, 2016 15:34 — forked from michaeluno/admin-page-framework-custom-text-after-form-submission.php
Displays custom text after the form is submitted with Admin Page Framework, a wordpress plugin/theme framework.
<?php
/*
Plugin Name: Admin Page Framework - Custom Text After Form Submission
Plugin URI: http://en.michaeluno.jp/admin-page-framework
Description: Displays custom text after the form is submitted.
Author: Michael Uno
*/
// Include the library file. Set your file path here.
include( dirname( dirname( __FILE__ ) ) . '/admin-page-framework/library/apf/admin-page-framework.php' );
@heldervilela
heldervilela / functions.php
Created March 21, 2017 19:12
Remove All Widgets from Sidebar
add_filter( 'sidebars_widgets', 'disable_all_widgets' );
function disable_all_widgets( $sidebars_widgets ) {
$sidebars_widgets = array( false );
return $sidebars_widgets;
}
@heldervilela
heldervilela / update_theme.php
Created September 13, 2017 14:26
How to integrate WordPress Core updates with your custom Plugin or Theme
<?php
/**
* How to integrate WordPress Core updates with your custom Plugin or Theme
*
* Filter the `update_plugins` transient to report your plugin as out of date.
* Themes have a similar transient you can filter.
*/
add_filter( 'site_transient_update_plugins', 'wprp_extend_filter_update_plugins' );
add_filter( 'transient_update_plugins', 'wprp_extend_filter_update_plugins' );
function wprp_extend_filter_update_plugins( $update_plugins ) {
@heldervilela
heldervilela / add-gift-box.php
Last active May 4, 2023 08:39
woocommerce custom checkout field to add fee to order ajax
<?php
/**
* Add html
*
* @version 1.0.0
* @since 1.0.0
*/
add_action( 'woocommerce_after_checkout_billing_form', 'add_box_option_to_checkout' );
function add_box_option_to_checkout( $checkout ) {
@heldervilela
heldervilela / name-collision.php
Created November 23, 2017 15:23
Themeforest — Excluding your plugin or theme from update checks
# For plugins
function cws_hidden_plugin_12345( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );
unset( $plugins->active[ array_search( plugin_basename( __FILE__ ), $plugins->active ) ] );
$r['body']['plugins'] = serialize( $plugins );
return $r;