Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
<?php
add_action( 'rest_api_init', 'custom_routes_webhook_0277');
function custom_routes_webhook_0277(){
//(exemplo: /wp-json/exemplo/notificacoes)
register_rest_route(
'exemplo', '/notificacoes/', array(
'methods' => 'POST',
@dexit
dexit / gist:7dce5d51a374f1e3bbed6efc8bf70d62
Created December 16, 2024 16:28 — forked from NickMkrtchyan/gist:bbd3f05d233dff84484cd09260be0475
Complate Corporate/Customer Woo Script
<?php
// Custom registration form for WooCommerce
function custom_woocommerce_register_form() {
$user_role = ( ! empty( $_POST['user_role'] ) ) ? sanitize_text_field( $_POST['user_role'] ) : '';
$company_id = ( ! empty( $_POST['company_id'] ) ) ? sanitize_text_field( $_POST['company_id'] ) : '';
?>
<p class="form-row form-row-wide">
<label for="user_role"><?php _e( 'Choose account type', 'woodmart' ); ?></label>
@gingerbeardman
gingerbeardman / webhook.php
Last active February 10, 2025 23:11
Webhook receiver PHP script
<?php
// GitHub webhook secret (set this in your GitHub webhook settings)
$secret = "Y0UR-secret-text-here!";
// Get the payload
$payload = file_get_contents('php://input');
// Verify the signature
$signature = $_SERVER['HTTP_X_HUB_SIGNATURE'] ?? null;
@dexit
dexit / functions.php
Created June 12, 2024 19:17 — forked from JoelEadeDesign/functions.php
Elementor Display Conditions for Page Templates
<?php
/**
* Elementor Conditions based on Page Template
*
* @return void
*/
add_action( 'elementor/theme/register_conditions', function( $conditions_manager ) {
class Page_Template_Condition extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
@dexit
dexit / functions.php
Created June 12, 2024 13:49 — forked from pingram3541/functions.php
Elementor Form Validation - Block non-english bots
/**
* Checks form textarea content is english to reduce spam from non-english bots
**/
function elementor_form_message_field_validation( $field, $record, $ajax_handler ) {
// Let's check the message field only
if ( empty( $field ) || empty( $field['message'] ) ) {
return;
}
// Validate content format by language
$string = $field['message'];
add_action( 'elementor/query/myonmarketpropertyquery', 'elementor_query_on_market_only' );
function elementor_query_on_market_only( $query )
{
$meta_query = $query->get('meta_query');
$new_meta_query = $meta_query;
$new_meta_query[] = array(
'key' => '_on_market',
'value' => 'yes'
@dexit
dexit / elementor-tab-close.js
Created June 12, 2024 13:49 — forked from banarsiamin/elementor-tab-close.js
How to Set the Elementor Accordion Widget Closed by Default
jQuery(document).ready(function($) {
var delay = 100; setTimeout(function() {
$('.elementor-tab-title').removeClass('elementor-active');
$('.elementor-tab-content').css('display', 'none'); }, delay);
});
<?php
/**
* @credits https://jeroensormani.com/adding-a-custom-woocommerce-product-type/
*/
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
add_action('init' , 'wc_pm_load_product_type');
function wc_pm_load_product_type() {
<?php
$posts = maybeCache('remote_posts_data', 7200, function () {
return do_remote_get('https://jsonplaceholder.typicode.com/posts/');
});
foreach ($posts as $post) {
echo "<h2>{$post->title}</h2>";
}
@dexit
dexit / shortcode.php
Created April 11, 2024 09:11 — forked from igorbenic/shortcode.php
Conditional Enqueueing of scripts in WordPress
<?php
add_action('wp_enqueue_scripts', 'enqueue_if_shortcode');
function enqueue_if_shortcode(){
global $post;
if ( $post && has_shortcode( $post->post_content, 'your_shortcode_tag' ) {
// Enqueue
}