Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Plugin Name: Simple Giveaways - Translating strings
* Description: This file can be saved under wp-content/plugins or just paste the code in your theme's functions.php.
* Version: 1.0.0
*/
if ( ! defined('ABSPATH') ) {
return;
@igorbenic
igorbenic / code.php
Created April 23, 2020 23:38
Pets and User Submitted Posts
<?php
function pets_usp_modify_post_type( $post_type ) {
return 'pets'; // edit post type as needed
}
add_filter( 'usp_post_type', 'pets_usp_modify_post_type' );
@igorbenic
igorbenic / field.php
Last active June 23, 2021 21:26
How to use the WooCommerce Postcode Validator | https://www.ibenic.com/woocommerce-postcode-validator
<?php
/**
* Shipping method id: rp_table_rate
* You can use any ID here and replace rp_table_rate to add this field to your shipping method settings page.
*/
add_filter( 'woocommerce_settings_api_form_fields_rp_table_rate', 'ibenic_add_postcodes_field_a_shipping_method' );
/**
* Add Postcodes field to the Table Rate
@igorbenic
igorbenic / validator.php
Created March 19, 2020 15:38
How to use the WooCommerce Postcode Validator | https://www.ibenic.com/woocommerce-postcode-validator
<?php
/**
* Used by shipping zones and taxes to compare a given $postcode to stored
* postcodes to find matches for numerical ranges, and wildcards.
*
* @since 2.6.0
* @param string $postcode Postcode you want to match against stored postcodes.
* @param array $objects Array of postcode objects from Database.
* @param string $object_id_key DB column name for the ID.
@igorbenic
igorbenic / remove-terms.php
Created March 12, 2020 12:16
Simple Sponsorships - Code Snippets
<?php
/**
* Remove Terms and Conditions Field
*/
add_filter( 'ss_form_sponsors_fields', 'ss_remove_terms_and_conditions' );
/**
* Filtering out the terms and conditions field
@igorbenic
igorbenic / disable-theme-comments.php
Last active February 21, 2024 21:34
Simple Feature Requests & GeneratePress snippets
<?php
add_action( 'jck_sfr_after_single_loop', 'jck_disable_theme_comments');
/**
* Disable the default theme comments form by disabling comments after the plugin comments form is rendered.
*/
function jck_disable_theme_comments() {
add_filter( 'comments_open', function( $open, $post_id ) {
if ( 'cpt_feature_requests' === get_post_type( $post_id ) ) {
@igorbenic
igorbenic / elementor-widget.php
Last active April 11, 2024 09:12
Ultimate Guide for JavaScript in Elementor Widgets
<?php
/**
* Plugin Name: Elementor Widget
* Text Domain: elementor-widget
* Domain Path: /languages
* Version: 0.1.0
*
* @package Elementor_Widget
*/
@igorbenic
igorbenic / App-1.js
Last active April 11, 2024 09:05
Headless WordPress: Displaying single articles | https://ibenic.com/headless-wordpress-displaying-articles
function App() {
const [loading, setLoading] = useState(false);
const [articles, setArticles] = useState([]);
const [notFoundSlugs, setNotFoundSlugs] = useState([]); // Adding not found slugs
// ... other code
}
@igorbenic
igorbenic / App-1.js
Last active April 11, 2024 09:05
Headless WordPress: React Router Pagination | https://ibenic.com/headless-wordpress-react-router-pagination
// Adding the React Router
import React, { useState, useEffect } from 'react';
import './App.scss';
import {
BrowserRouter as Router,
Switch,
Route,
Link,
useParams
} from "react-router-dom";
@igorbenic
igorbenic / form.html
Created January 7, 2020 22:59
Simple Giveaways - Remote Form
<!-- Replace:
{{GIVEAWAY_URL}} - The URL to the Giveaway main page (the giveaway landing page).
-->
<form id="giveasap_subscribe_form" class="giveasap_form" action="{{GIVEAWAY_URL}}" method="post">
<!-- Replace:
{{GIVEAWAY ID}} - the Giveaway ID, you can see the ID from the giveaway shortcode
-->
<input type="hidden" name="sg_giveaway_id" value="{{GIVEAWAY ID}}">
<!-- REQUIRED FIELD-->