This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_route_enqueue_scripts() { | |
wp_enqueue_script('custom-route-script', plugin_dir_url(__FILE__) . 'custom-route-script.js', array(), '1.0', true); | |
} | |
add_action('wp_enqueue_scripts', 'custom_route_enqueue_scripts'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('DOMContentLoaded', async () => { | |
const data = { | |
key1: 'data1', | |
key2: 'data2', | |
}; | |
const response = await fetch('/wp-json/custom-api-route/v1/submit', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function process_data_submission(WP_REST_Request $request) { | |
$data = json_decode($request->get_body(), true); | |
// Perform your data processing here | |
$response = new WP_REST_Response(array('status' => 'success', 'message' => 'Data processed successfully')); | |
$response->set_status(200); | |
return $response; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('rest_api_init', 'register_custom_route'); | |
function register_custom_route() { | |
register_rest_route('custom-api-route/v1', '/submit', array( | |
'methods' => 'POST', | |
'callback' => 'process_data_submission', | |
'permission_callback' => '__return_true', | |
)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Custom API Route | |
Description: A simple plugin to demonstrate how to implement a custom JSON API route in WordPress. | |
Version: 1.0 | |
Author: Your Name | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="data-container"> | |
<div class="data-title">Details of your order</div> | |
<div class="data"> | |
<table style="width:100%;font-size:.8rem;"> | |
<tr> | |
<th style="width:2%;">Pos</th> | |
<th style="width:2%;">Qty</th> | |
<th style="width:70%;">Name</th> | |
<th style="width:20%;text-align:right;">Price</th> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import argparse | |
import json | |
import os | |
import sys | |
from typing import List, Optional | |
from urllib.request import urlopen | |
"""Downloads all files of messages of your Slack (workspace) JSON export. Each channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CurrencyInput < SimpleForm::Inputs::StringInput | |
def input(wrapper_options) | |
input_options = input_html_options.merge({data: {autonumeric: true}}) | |
merged_input_options = merge_wrapper_options(input_options, wrapper_options) | |
template.content_tag(:div, class: 'input-group') do | |
template.concat span_currency_sign | |
template.concat @builder.text_field(attribute_name, merged_input_options) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Python | |
brew install python@3.9 | |
# Install NVM | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash | |
# Update/check your source files (.zshrc, .bashrc, etc.) | |
export PATH="~/.nvm/current/bin:$PATH" | |
# Install specific Node version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hubspot = require('@hubspot/api-client'); | |
exports.main = async (event, callback) => { | |
// initialize the hubspot api client with your api secret | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.API_KEY | |
}); | |
// the ID of the email template | |
const EMAIL_TEMPLATE_ID = 82546305923; |
NewerOlder