Skip to content

Instantly share code, notes, and snippets.

View ioniacob's full-sized avatar
🐌
Exploring the code is like life itself.

Ion Iacob ioniacob

🐌
Exploring the code is like life itself.
View GitHub Profile
<?php
const ACTION_NAME = 'shea_ajax_example';
$handler = function () {
check_ajax_referer( ACTION_NAME );
wp_send_json_success( 'it works!' );
};
@anibalardid
anibalardid / selector.php
Last active July 16, 2019 12:01
[carga condicional plugins wp] codigo mio viejo #WordPress #Plugins
<?php
// My post: https://es.wordpress.org/support/topic/tutorial-como-deshabilitar-algunos-plugins-de-algunas-paginas-especificas/
/*
Plugin Name: Plugin Selector
Plugin URI: https://ardid.com.ar
Description: Removes plugins in selected pages
Author: Anibal Ardid
Version: 1.0
Author URI: https://ardid.com.ar
*/
@woogists
woogists / wc-hide-all-shipping-if-free-shipping-is-available.php
Last active November 23, 2023 12:30
[General Snippets][Hide other shipping methods when “Free Shipping” is available] Hides all other shipping methods but free_shipping if it’s available. Compatible with Shipping zones.
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
@woogists
woogists / wc-change-email-subject.php
Last active December 29, 2022 13:52
Change email subject lines
/*
* goes in theme functions.php or a custom plugin
*
* Subject filters:
* woocommerce_email_subject_new_order
* woocommerce_email_subject_customer_processing_order
* woocommerce_email_subject_customer_completed_order
* woocommerce_email_subject_customer_invoice
* woocommerce_email_subject_customer_note
* woocommerce_email_subject_low_stock
@woogists
woogists / wc-rename-tabs.php
Last active July 5, 2023 22:17
[Frontend Snippets][Editing product data tabs] Renaming product data tabs
/**
* Rename product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
@ioniacob
ioniacob / woocommerce-optimize-scripts.php
Created February 4, 2018 21:28 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@orfeomorello
orfeomorello / functions.php
Last active May 21, 2022 19:06
Customize Wordpress Profile
function remove_personal_options(){
echo '<script type="text/javascript">jQuery(document).ready(function($) {
$(\'form#your-profile > h2:first\').remove(); // remove the "Personal Options" title
$(\'form#your-profile tr.user-rich-editing-wrap\').remove(); // remove the "Visual Editor" field
$(\'form#your-profile tr.user-admin-color-wrap\').remove(); // remove the "Admin Color Scheme" field
$(\'form#your-profile tr.user-comment-shortcuts-wrap\').remove(); // remove the "Keyboard Shortcuts" field
@DreySkee
DreySkee / DataActions_Menus.js
Last active January 24, 2019 06:21
WP-API DataActions with menus endpoint
import axios from 'axios';
import alt from './../alt/alt.js';
class DataActions {
constructor() {
const appUrl = 'http://andreypokrovskiy.com/projects/wp-api'; // Wordpress installation url
this.pagesEndPoint = `${appUrl}/wp-json/wp/v2/pages`; // Endpoint for getting Wordpress Pages
this.postsEndPoint = `${appUrl}/wp-json/wp/v2/posts`; // Endpoint for getting Wordpress Posts
@ioniacob
ioniacob / gist:c7dd4254292c18506aee05704419d6d8
Created November 11, 2016 23:45 — forked from corsonr/gist:7839908
Automatically add product to cart on visit - WooCommerce
/*
* Add item to cart on visit
*/
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 64;
$found = false;
//check if product already in cart
if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
@evrpress
evrpress / Add user to list after click on link
Last active February 27, 2017 09:58
Assigns a subscriber to a certain list if a certain link has been clicked