Skip to content

Instantly share code, notes, and snippets.

View barbareshet's full-sized avatar
🎯
Focusing

ido barnea barbareshet

🎯
Focusing
View GitHub Profile
@barbareshet
barbareshet / Simple Ajax Login Form.php
Created December 13, 2021 09:27 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
?>
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
[
{
"country-name": "Afghanistan",
"iso2": "AF",
"iso3": "AFG",
"top-level-domain": "af",
"fips": "AF",
"iso-numeric": "004",
"geonameid": "1149361",
"e164": "93",
@barbareshet
barbareshet / learnpress-enroll-status.php
Created June 8, 2022 12:04 — forked from wpacademy/learnpress-enroll-status.php
Check if user has enrolled into any course at your LearnPress website.
<?php
/*
* Function to check if given user is enrolled into any course.
*/
function wpac_check_enrolled_user($user_id){
if (is_numeric($user_id)) {
//Global WordPress DB object
global $wpdb;
@barbareshet
barbareshet / DNS Prefetch domains
Created August 15, 2022 11:10 — forked from lukecav/DNS Prefetch domains
WP Rocket - Advanced Options Prefetch DNS requests examples
//maps.googleapis.com
//maps.gstatic.com
//fonts.googleapis.com
//fonts.gstatic.com
//ajax.googleapis.com
//apis.google.com
//google-analytics.com
//www.google-analytics.com
//ssl.google-analytics.com
//youtube.com
@barbareshet
barbareshet / enqueue.php
Created August 22, 2022 16:28 — forked from ricardobrg/enqueue.php
Enqueue scripts in WordPress with defer or async
<?php
// This code is based in Mathew Horne blog post: https://matthewhorne.me/defer-async-wordpress-scripts/
//function to add async attribute
function add_async_attribute($tag, $handle) {
$scripts_to_async = array('my-js-handle-async', 'another-handle-async');
//check if this script is in the array
if (in_array($handle, $scripts_to_async)){
//return with async
return str_replace(' src', ' async="async" src', $tag);
@barbareshet
barbareshet / wc_order_status_changes.php
Created August 23, 2022 09:17 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@barbareshet
barbareshet / functions.php
Last active December 7, 2022 20:02 — forked from Anatal/functions.php
WP Ajax
function hello_elementor_child_enqueue_scripts() {
wp_enqueue_style(
'hello-elementor-child-style',
get_stylesheet_directory_uri() . '/style.css',
[
'hello-elementor-theme-style',
],
'1.0.0'
);
@barbareshet
barbareshet / class-rcp-payment-gateway.php
Created December 22, 2022 13:24 — forked from ashleyfae/class-rcp-payment-gateway.php
RCP payment gateway base class
<?php
/**
* Payment Gateway Base Class
*
* You can extend this class to add support for a custom gateway.
* @link http://docs.restrictcontentpro.com/article/1695-payment-gateway-api
*
* @package Restrict Content Pro
* @subpackage Classes/Gateway
* @copyright Copyright (c) 2017, Pippin Williamson
@barbareshet
barbareshet / wp-config.php
Created January 10, 2023 09:52 — forked from lukecav/wp-config.php
Exclude options data from being caching in Redis using the Redis Object Cache plugin
define( 'WP_REDIS_IGNORED_GROUPS', [ 'options' ]);
@barbareshet
barbareshet / woocommerce_events.md
Created May 31, 2023 05:51 — forked from mpdevcl/woocommerce_events.md
WooCommerce JS Events

WooCommerce JS Events

Source

Checkout

$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );