Skip to content

Instantly share code, notes, and snippets.

// Change "Add to Cart" > "Add to Bag" in Shop Page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_shop_page_add_to_cart_callback' );
function woocommerce_shop_page_add_to_cart_callback() {
return __( 'Add to Bag', 'text-domain' );
}
// Change "Add to Cart" > "Add to Bag" in Single Page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_single_page_add_to_cart_callback' );
function woocommerce_single_page_add_to_cart_callback() {
return __( 'Add to Bag', 'text-domain' );
}
<?php
$check_page_exist = get_page_by_title('title_of_the_page', 'OBJECT', 'page');
// Check if the page already exists
if(empty($check_page_exist)) {
$page_id = wp_insert_post(
array(
'comment_status' => 'close',
'ping_status' => 'close',
'post_author' => 1,
add_filter('wpcf_default_single_campaign_tabs', 'single_tab_callback', 9);
function single_tab_callback( $tabs = array() ) {
$tabs['extra_tab'] = array(
'title' => __( 'Add Extra Tab', 'text_domain' ),
'callback' => 'tab_content_callback'
);
return $tabs;
}
function tab_content_callback(){
<?php
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
header($_SERVER["SERVER_PROTOCOL"]." 405 Method Not Allowed", true, 405);
exit;
}
$postData = trim(file_get_contents('php://input'));
libxml_use_internal_errors(true);
$xml = simplexml_load_string($postData);
<?php
echo 'PHP POST Request <br/>';
function curl_data($data) {
// make sure curl module is enable
// phpinfo();
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/xml_action/index.php'); // Response URL
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml") );
@anik
anik / fontawesome5.js
Created January 10, 2019 05:47
fontawesome 5 free as an array
var fontAwesome = [
'fas fa-ad',
'fas fa-address-book',
'fas fa-address-card',
'fas fa-adjust',
'fas fa-air-freshener',
'fas fa-align-center',
'fas fa-align-justify',
'fas fa-align-left',
'fas fa-align-right',
@anik
anik / Calender.js
Created October 12, 2018 19:35
ReactJS Calender Component
import React, { Component } from 'react'
const _month = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec']
const _days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
class Calendar extends Component {
state = { type: 'date', year: this._todaysDate('y'), month: this._todaysDate('m'), day: this._todaysDate('d') }
_daysInMonth(){
return new Date( this.state.year, this.state.month , 0 ).getDate()
@anik
anik / Filter.php
Last active October 12, 2018 19:17
tests
# Addon Generate.
add_filter( 'wppb_available_addons', 'wppb_dokan_addons_function' );
if ( ! function_exists('wppb_dokan_addons_function')){
function wppb_dokan_addons_function($addons){
$addons[] = 'WPPB_Dokan_Shortcode';
return $addons;
}
}
class WPPB_Dokan_Shortcode {
public function get_name(){
return 'wppb_dokan_shortcode';
}
public function get_icon() {
return 'wppb-font-Page-grid';
}
public function get_category_name(){
return __( 'Dokan Shortcode', 'wp-page-builder-dokan' );
}