Skip to content

Instantly share code, notes, and snippets.

View DeoThemes's full-sized avatar
🏠
Working from home

DeoThemes

🏠
Working from home
View GitHub Profile
<?php
/**
* After import hook
* This hook is fired after the import is completed
*/
public function after_import() {
// Add filter of the link rel attr to avoid JSON damage.
add_filter( 'wp_targeted_link_rel', '__return_empty_string', 50, 1 );
@DeoThemes
DeoThemes / woocommerce-quantity-buttons.php
Last active June 16, 2021 23:08
Add quantity buttons to WooCommerce
<?php
/**
* Quantity buttons
*/
add_action( 'woocommerce_after_quantity_input_field', 'arendelle_quantity_plus_sign' );
function arendelle_quantity_plus_sign() {
echo '<span class="quantity__button quantity__plus"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg></span>';
}
<?php
// AppSumo AJAX form submission
add_action( 'wp_ajax_nopriv_deo_appsumo_submission', 'deo_appsumo_submission' );
add_action( 'wp_ajax_deo_appsumo_submission', 'deo_appsumo_submission' );
function deo_appsumo_submission() {
check_ajax_referer( 'deo_ajax_nonce', 'nonce' );
@DeoThemes
DeoThemes / deo-elementor-extension.php
Last active June 15, 2022 17:14
A simple Elementor extension to create icon boxes with custom icon font.
<?php
/**
* Plugin Name: Deo Elementor Extension
* Description: Custom Elementor extension.
* Plugin URI: https://elementor.com/
* Version: 1.0.0
* Author: DeoThemes
* Author URI: https://elementor.com/
* Text Domain: deo-elementor-extension
*/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="posts"></div>
<script id="jsbin-javascript">
// Literal notation
var person = {
name: "Alex",
age: 29,
greet: function() {
console.log("Hello, I'm " + this.name);
}
}
@DeoThemes
DeoThemes / first-shortcode.php
Created August 16, 2017 02:41
Get first gallery shortcode WordPress
<?php
function deo_get_attachment(){
global $post;
$pattern = get_shortcode_regex();
$output = '';
if( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches )
&& array_key_exists( 2, $matches )
&& in_array( 'gallery', $matches[2] ) ):