Skip to content

Instantly share code, notes, and snippets.

View kreamweb's full-sized avatar

Emanuela Antonina Castorina kreamweb

  • Kream di Emanuela Castorina
  • Acicatena (CT) - Italy
View GitHub Profile
<?php
add_action( 'admin_enqueue_scripts', 'ywpi_pdf_template_licence_key', 99 );
if ( ! function_exists( 'ywpi_pdf_template_licence_key' ) ) {
function ywpi_pdf_template_licence_key() {
$js = "wp.hooks.addFilter('ywpi_pdf_template_demo', 'yith-woocommerce-pdf-invoice/customization', (key) => {
return 'ywpi_live_demo';
} );";
wp_add_inline_script( 'ywpi-pdf-template-builder-script', $js, 'after' );
<?php
add_action( 'admin_enqueue_scripts', 'ywpi_pdf_template_licence_key', 99 );
if ( ! function_exists( 'ywpi_pdf_template_licence_key' ) ) {
function ywpi_pdf_template_licence_key() {
$js = "wp.hooks.addFilter('ywpi_pdf_template_demo', 'yith-woocommerce-pdf-invoice/customization', (key) => {
return 'ywpi_live_demo';
} );";
wp_add_inline_script( 'ywpi-pdf-template-builder-script', $js, 'after' );
import apiFetch from '@wordpress/api-fetch';
import {addQueryArgs} from '@wordpress/url';
import {getCurrentPost} = wp.data.select('core/editor');
const api_path = '/wp/v2/pdf_template/'; //this is the slug of rest_endpoint set inside the register_post_type
function TemplateList() {
function handleOnClick(template) {
@kreamweb
kreamweb / js
Created January 25, 2022 13:55
wp.domReady(() => {
find blocks styles
wp.blocks.getBlockTypes().forEach((block) => {
console.log(block);
if (_.isArray(block['styles'])) {
console.log(block.name, _.pluck(block['styles'], 'name'));
}
});
<?php
if ( function_exists( 'YITH_WC_Subscription_Frontend' ) ) {
add_filter( 'woocommerce_customer_get_downloadable_products', 'woocommerce_order_get_downloadable_items_ywsbs_helper' );
function woocommerce_order_get_downloadable_items_ywsbs_helper( $downloads ) {
if ( ! is_account_page() ) {
return $downloads;
}
<?php
if( defined('YITH_YWRAQ_PREMIUM') ){
add_action('wp_footer','raq_script',9999);
function raq_script() { ?>
<script>
jQuery(document).ready(function($) {
<?php
add_filter( 'x_sliders_meta', 'x_revolution_slider_add_slider_meta_tweek', 1 );
function x_revolution_slider_add_slider_meta_tweek( $meta ) {
return array_merge( $meta, x_revolution_slider_get_slider_meta_tweek() );
}
if( !function_exists('x_revolution_slider_get_slider_meta_tweek')){
function x_revolution_slider_get_slider_meta_tweek() {
$rs = new RevSlider();
<?php
add_action('woocommerce_email_footer', 'raq_quote_email', 1);
function raq_quote_email( $email ){
if( is_a( $email, 'YITH_YWRAQ_Send_Quote') && isset( $email->raq) ){
$raq = $email->raq;
$order = wc_get_order($raq['order-id']);
$other_fields = $order->get_meta('ywraq_other_email_fields', true );
foreach ( $other_fields as $key => $value ){
printf( '<p><strong>%s:</strong> %s</p>', $key, esc_html( $value ) );
}
<?php
if( class_exists('YITH_WC_Points_Rewards_Frontend')){
add_filter('ywpar_get_product_point_earned', 'ywpar_get_product_point_earned_gift_card', 10, 2 );
function ywpar_get_product_point_earned_gift_card( $points, $product ){
if( $product->is_type('gift-card')){
$points = 0;
}
return $points;
}
<?php
add_action( 'woocommerce_applied_coupon', 'change_subscription_next_payment_due_date' );
add_action( 'woocommerce_removed_coupon', 'change_subscription_next_payment_due_date_on_remove_coupon' );
function change_subscription_next_payment_due_date( $coupon_code ) {
if ( 'famille' === strtolower( $coupon_code ) ) {
replace_recurring_price( $coupon_code, 'add');
}
}