Skip to content

Instantly share code, notes, and snippets.

@blaz-blazer
blaz-blazer / class-rate-my-post-public.php
Last active May 7, 2024 09:32
Test Nonce LiteSpeed Cache
<?php
/**
* The public-specific functionality of the plugin.
*
* @link http://wordpress.org/plugins/rate-my-post/
* @since 2.0.0
*
* @package Rate_My_Post
* @subpackage Rate_My_Post/public
@goaround
goaround / taxonomy-wp-rest-search.php
Created June 12, 2020 14:51
WordPress Plugin: Taxonomy WP REST Search for the WordPress Block Editor (Gutenberg)
<?php
/**
* Plugin Name: Taxonomy WP REST Search
* Plugin URI:
* Description: Taxonomy WP REST Search for the WordPress Block Editor (Gutenberg)
* Author: Johannes Kinast <[email protected]>
* Author URI: https://go-around.de
* Version: 1.0.0
*/
namespace Taxonomy_WP_REST_Search;
@cliffordp
cliffordp / functions.php
Last active August 3, 2021 09:58
The Events Calendar: v2 Views: Include the next 3 upcoming events after each post unless it's a TEC post or archive.
<?php
/**
* The Events Calendar: v2 Views: Include the next 3 upcoming events after each post unless it's a TEC post or archive.
*
* Tested working with TEC v5.1.1.
* Outputs a portion of v2's List View's HTML rendering without full styles/scripts.
* But this isn't the best way to use v2's views. For a lot of scenarios, it's better to just create your own new view.
*
* @link https://gist.github.com/cliffordp/9994cf05f6475922f451eaeacef2cd3c This snippet.
@skyshab
skyshab / example.php
Created April 27, 2020 17:39
Add an "Exchange" link on single event pages.
<?php
// Filter the output of the export links markup.
// This is just adding a copy of the "ical" download, as this file type can also be import into Exchange.
add_filter( 'tribe_events_ical_single_event_links', function( $links ){
$links = '<div class="tribe-events-cal-links">';
$links .= '<a class="tribe-events-gcal tribe-events-button" href="' . Tribe__Events__Main::instance()->esc_gcal_url( tribe_get_gcal_link() ) . '" title="' . esc_attr__( 'Add to Google Calendar', 'the-events-calendar' ) . '">+ ' . esc_html__( 'Google Calendar', 'the-events-calendar' ) . '</a>';
$links .= '<a class="tribe-events-gcal tribe-events-button" href="' . esc_url( tribe_get_single_ical_link() ) . '" title="' . esc_attr__( 'Download .ics file', 'the-events-calendar' ) . '" >+ ' . esc_html__( 'iCal Export', 'the-events-calendar' ) . '</a>';
$links .= '<a class="tribe-events-ical tribe-events-button" href="' . esc_url( tribe_get_single_ical_link() ) . '" title="' . esc_attr__( 'Download Exchange file', 'the-ev
@skyshab
skyshab / example.php
Last active August 2, 2021 15:28
Make the organizer or related fields be required on the Community Events page.
<?php
// Make the "organizer" field required in the community events "add event" form.
add_filter( 'tribe_events_community_required_fields', function( $fields ){
// This should be an array. If not, return the value and bail.
if ( ! is_array( $fields ) ) {
return $fields;
}
// Add the fields we want to make required to the $fields array.
@jchristopher
jchristopher / functions.php
Last active April 4, 2023 12:27
Use Elementor to power SearchWP Supplemental Engine
<?php
// @link https://searchwp.com/v3/docs/kb/using-elementor-for-supplemental-engines/
// We need to flag the search form.
add_action( 'elementor_pro/search_form/after_input', function( $form ) {
// Check to see if this is the right Search Form.
$settings = $form->get_data( 'settings' );
@imath
imath / post-taxonomy-panel.js
Created March 1, 2020 03:52
Example of use of the filter to replace the PostTaxonomy panel of the WordPress Block Editor
const { createElement, Component } = wp.element;
const { compose } = wp.compose;
const { RadioControl } = wp.components;
const { withSelect, withDispatch } = wp.data;
const { addFilter } = wp.hooks;
const { apiFetch } = wp;
const { __ } = wp.i18n;
class RiskDomain extends Component {
constructor() {
@joemaller
joemaller / README.md
Last active November 1, 2024 17:17
Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

Fixing post counts for WordPress taxonomies

The problem

For WordPress sites using Custom Post Types, Taxonomy admin listings show cumulative term-assignment totals for all post_types instead of counts specific to the selected post_type. Since Taxonomy listings are always attached to a single post_type, totals for shared taxonomies don't make sense.

The Goal

Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

@cliffordp
cliffordp / gist:0780d5a8a88a3cbf1dcb7000646fc536
Created February 25, 2020 22:53 — forked from zlove/gist:3b9b6a611715ec3a8a60
Preview WooCommerce Emails
<?php
/**
* Quick hack to preview WooCommerce e-mails.
* Based on drrobotnik's answer from Stack Overflow: http://stackoverflow.com/a/27072101/186136
*
* Add this to <yourtheme>/functions.php and then visit a url like:
* http://<site_url>/wp-admin/admin-ajax.php?action=previewemail
*
* @return null
*/
@florianbrinkmann
florianbrinkmann / index.js
Last active October 24, 2024 11:59
Gutenberg FormTokenField block with posts as source
/**
* External dependencies
*/
const { isUndefined, pickBy } = lodash;
/**
* WordPress dependencies
*/
const {
registerBlockType,