Skip to content

Instantly share code, notes, and snippets.

View heldervilela's full-sized avatar

Helder Vilela heldervilela

View GitHub Profile
@heldervilela
heldervilela / functions.php
Created December 9, 2017 10:19
Add an Admin User in WordPress using FTP
function wpb_admin_account(){
$user = 'user';
$pass = 'pass';
$email = '[email protected]';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
@heldervilela
heldervilela / table-listing.php
Created November 30, 2017 00:33
WordPress Admin Table List Markup
<table class="widefat fixed" cellspacing="0">
<thead>
<tr>
<th id="cb" class="manage-column column-cb check-column" scope="col"></th> // this column contains checkboxes
<th id="columnname" class="manage-column column-columnname" scope="col"></th>
<th id="columnname" class="manage-column column-columnname num" scope="col"></th> // "num" added because the column contains numbers
</tr>
</thead>
@heldervilela
heldervilela / woocommerce--custom-fields.php
Last active March 26, 2019 05:11
WooCommerce Custom Fields
<?php
/**
* Display Fields using WooCommerce Action Hook
*
* @ref http://www.remicorson.com/woocommerce-custom-fields-for-variations/
* @ref http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
* @since 1.0.0
*/
add_action( 'woocommerce_product_options_general_product_data', 'woocom_general_product_data_custom_field' );
@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;
@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 / 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 / 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 / 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 / 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 / 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');